Merge "Fix alignment in YUVConverter in goldfish gralloc."
GitOrigin-RevId: 23df1b192edeb63a0a0d2fb90afbc07c891a6af9
Change-Id: Ie19bfd6cf387d1142a5021791bd0fa43cd535147
diff --git a/stream-servers/RenderLibImpl.cpp b/stream-servers/RenderLibImpl.cpp
index c91e91b..35c4617 100644
--- a/stream-servers/RenderLibImpl.cpp
+++ b/stream-servers/RenderLibImpl.cpp
@@ -100,8 +100,7 @@
}
void RenderLibImpl::setGrallocImplementation(GrallocImplementation gralloc) {
- // TODO(joshuaduong): need a full CP of go/oag/1950399
- (void) gralloc;
+ emugl::setGrallocImplementation(gralloc);
}
bool RenderLibImpl::getOpt(RenderOpt* opt) {
diff --git a/stream-servers/gl/YUVConverter.cpp b/stream-servers/gl/YUVConverter.cpp
index 457e7c3..3837ff6 100644
--- a/stream-servers/gl/YUVConverter.cpp
+++ b/stream-servers/gl/YUVConverter.cpp
@@ -329,21 +329,23 @@
*yWidth = width;
*yHeight = height;
*yOffsetBytes = 0;
- // Luma stride is 32 bytes aligned.
- *yStridePixels = alignToPower2(width, 32);
+ // Luma stride is 32 bytes aligned in minigbm, 16 in goldfish
+ // gralloc.
+ *yStridePixels = alignToPower2(width, emugl::getGrallocImplementation() == MINIGBM
+ ? 32 : 16);
*yStrideBytes = *yStridePixels;
// Chroma stride is 16 bytes aligned.
*vWidth = width / 2;
*vHeight = height / 2;
*vOffsetBytes = (*yStrideBytes) * (*yHeight);
- *vStridePixels = (*yStridePixels) / 2;
+ *vStridePixels = alignToPower2((*yStridePixels) / 2, 16);
*vStrideBytes = (*vStridePixels);
*uWidth = width / 2;
*uHeight = height / 2;
*uOffsetBytes = (*vOffsetBytes) + ((*vStrideBytes) * (*vHeight));
- *uStridePixels = (*yStridePixels) / 2;
+ *uStridePixels = alignToPower2((*yStridePixels) / 2, 16);
*uStrideBytes = *uStridePixels;
break;
}