surfaceflinger: support BT2020_ITU_PQ
Games use BT2020_PQ while videos use BT2020_ITU_PQ usually. We can
support both and treat them as the same, since the YUV->RGB
conversion happens before the pixel data are uploaded to texture, or
happens inside the GLES driver.
The only caveat is that we treat RGBA1010102/BT2020_ITU_PQ from
media specially. The hack is also updated in this change.
Test: manual
Change-Id: I1e4b8e0d907af5e5a95cf7fde1a7ea67a4e7da0b
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 974a261..d8740d9 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1816,8 +1816,13 @@
if (a == HAL_DATASPACE_V0_SCRGB || b == HAL_DATASPACE_V0_SCRGB) {
return HAL_DATASPACE_DISPLAY_P3;
}
- if (!hasHdr && (a == HAL_DATASPACE_BT2020_PQ || b == HAL_DATASPACE_BT2020_PQ)) {
- return HAL_DATASPACE_DISPLAY_P3;
+ if (!hasHdr) {
+ if (a == HAL_DATASPACE_BT2020_PQ || b == HAL_DATASPACE_BT2020_PQ) {
+ return HAL_DATASPACE_DISPLAY_P3;
+ }
+ if (a == HAL_DATASPACE_BT2020_ITU_PQ || b == HAL_DATASPACE_BT2020_ITU_PQ) {
+ return HAL_DATASPACE_DISPLAY_P3;
+ }
}
return HAL_DATASPACE_V0_SRGB;
@@ -1900,7 +1905,8 @@
"display %zd: %d", displayId, result);
}
for (auto& layer : displayDevice->getVisibleLayersSortedByZ()) {
- if (layer->getDataSpace() == HAL_DATASPACE_BT2020_PQ &&
+ if ((layer->getDataSpace() == HAL_DATASPACE_BT2020_PQ ||
+ layer->getDataSpace() == HAL_DATASPACE_BT2020_ITU_PQ) &&
!displayDevice->getHdrSupport()) {
layer->forceClientComposition(hwcId);
}