surfaceflinger: simplify P3 support in RE
RE always knows how to convert sRGB/P3/BT2020 to P3. The conversion
is enabled by SurfaceFlinger whenever the color mode is P3 (and when
hasWideColorDisplay is true). This change simplifies or removes
some wide color state functions from RE, and moves the burden to
SurfaceFlinger. It also changes GLES20RenderEngine::drawMesh to
inspect mDataSpace and mOutputDataSpace directly.
This allows us to enable the conversion in more cases more easily.
For example, we can choose to set the RE output dataspace to P3 even
when the display color mode is NATIVE.
Test: manual with UiBench
Change-Id: I5e701dd6b01764efbbab967dc4a26a4d008dfc09
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 0961058..87fd2f1 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2738,10 +2738,13 @@
if (hasClientComposition) {
ALOGV("hasClientComposition");
- getBE().mRenderEngine->setWideColor(
- displayDevice->getWideColorSupport() && !mForceNativeColorMode);
- getBE().mRenderEngine->setColorMode(mForceNativeColorMode ?
- HAL_COLOR_MODE_NATIVE : displayDevice->getActiveColorMode());
+ android_dataspace outputDataspace = HAL_DATASPACE_UNKNOWN;
+ if (!mForceNativeColorMode && displayDevice->getWideColorSupport() &&
+ displayDevice->getActiveColorMode() == HAL_COLOR_MODE_DISPLAY_P3) {
+ outputDataspace = HAL_DATASPACE_DISPLAY_P3;
+ }
+ getBE().mRenderEngine->setOutputDataSpace(outputDataspace);
+
if (!displayDevice->makeCurrent()) {
ALOGW("DisplayDevice::makeCurrent failed. Aborting surface composition for display %s",
displayDevice->getDisplayName().string());
@@ -4596,9 +4599,12 @@
ALOGE("Invalid crop rect: b = %d (> %d)", sourceCrop.bottom, raHeight);
}
- engine.setWideColor(renderArea.getWideColorSupport() && !mForceNativeColorMode);
- engine.setColorMode(mForceNativeColorMode ? HAL_COLOR_MODE_NATIVE
- : renderArea.getActiveColorMode());
+ android_dataspace outputDataspace = HAL_DATASPACE_UNKNOWN;
+ if (!mForceNativeColorMode && renderArea.getWideColorSupport() &&
+ renderArea.getActiveColorMode() == HAL_COLOR_MODE_DISPLAY_P3) {
+ outputDataspace = HAL_DATASPACE_DISPLAY_P3;
+ }
+ getBE().mRenderEngine->setOutputDataSpace(outputDataspace);
// make sure to clear all GL error flags
engine.checkErrors();