gralloc: Modify check for uncompressed RGB buffers
The previous check for RGB formats skipped certain formats and hence
the alignment was incorrect.
Add a check for all non-compressed RGB formats before calling
getGpuAlignedWidthHeight
CRs-fixed: 888733
Change-Id: Icae4cfb92ceae5e593fd6c5658999fc90ef97ea1
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index 26e3ec5..8eaf7f4 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -170,13 +170,38 @@
}
+bool isUncompressedRgbFormat(int format)
+{
+ bool is_rgb_format = false;
+
+ switch (format)
+ {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ case HAL_PIXEL_FORMAT_RGB_888:
+ case HAL_PIXEL_FORMAT_RGB_565:
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ case HAL_PIXEL_FORMAT_RGBA_5551:
+ case HAL_PIXEL_FORMAT_RGBA_4444:
+ case HAL_PIXEL_FORMAT_R_8:
+ case HAL_PIXEL_FORMAT_RG_88:
+ case HAL_PIXEL_FORMAT_BGRX_8888: // Intentional fallthrough
+ is_rgb_format = true;
+ break;
+ default:
+ break;
+ }
+
+ return is_rgb_format;
+}
+
void AdrenoMemInfo::getAlignedWidthAndHeight(int width, int height, int format,
int usage, int& aligned_w, int& aligned_h)
{
bool ubwc_enabled = isUBwcEnabled(format, usage);
// Currently surface padding is only computed for RGB* surfaces.
- if (format <= HAL_PIXEL_FORMAT_BGRA_8888) {
+ if (isUncompressedRgbFormat(format) == true) {
int tileEnabled = ubwc_enabled || isMacroTileEnabled(format, usage);
getGpuAlignedWidthHeight(width, height, format, tileEnabled, aligned_w, aligned_h);
return;