Support more color buffer formats in gralloc
This patch adds basic supports for the following formats:
HAL_PIXEL_FORMAT_RGBA_FP16
HAL_PIXEL_FORMAT_RGBA_1010102
It also removes camera flag for HAL_PIXEL_FORMAT_BLOB.
b/37719518
Test: cts-tradefed run cts -m CtsHardwareTestCases -t
android.hardware.cts.HardwareBufferTest#testCreate
Change-Id: Idaa39eb3c716e7c6327ad646b6bdfc023b6df555
diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp
index 4e63b00..0c5a613 100644
--- a/system/gralloc/gralloc.cpp
+++ b/system/gralloc/gralloc.cpp
@@ -370,6 +370,15 @@
if (convertedBuf) delete [] convertedBuf;
}
+#ifndef GL_RGBA16F
+#define GL_RGBA16F 0x881A
+#endif // GL_RGBA16F
+#ifndef GL_UNSIGNED_INT_10_10_10_2
+#define GL_UNSIGNED_INT_10_10_10_2 0x8DF6
+#endif // GL_UNSIGNED_INT_10_10_10_2
+#ifndef GL_HALF_FLOAT
+#define GL_HALF_FLOAT 0x140B
+#endif // GL_HALF_FLOAT
//
// gralloc device functions (alloc interface)
//
@@ -469,6 +478,16 @@
glFormat = GL_RGB;
glType = GL_UNSIGNED_SHORT_5_6_5;
break;
+ case HAL_PIXEL_FORMAT_RGBA_FP16:
+ bpp = 16;
+ glFormat = GL_RGBA16F;
+ glType = GL_HALF_FLOAT;
+ break;
+ case HAL_PIXEL_FORMAT_RGBA_1010102:
+ bpp = 4;
+ glFormat = GL_RGBA;
+ glType = GL_UNSIGNED_INT_10_10_10_2;
+ break;
#if PLATFORM_SDK_VERSION >= 21
case HAL_PIXEL_FORMAT_RAW16:
case HAL_PIXEL_FORMAT_Y16:
@@ -488,8 +507,10 @@
#if PLATFORM_SDK_VERSION >= 17
case HAL_PIXEL_FORMAT_BLOB:
bpp = 1;
- if (! (sw_read && hw_cam_write) ) {
+ if (! (sw_read) ) {
// Blob data cannot be used by HW other than camera emulator
+ // But there is a CTS test trying to have access to it
+ // BUG: https://buganizer.corp.google.com/issues/37719518
return -EINVAL;
}
// Not expecting to actually create any GL surfaces for this