Merge changes I09f4a157,I738be45b
* changes:
[SurfaceFlinger] Remove saturation matrix of Adaptive mode.
[SurfaceFlinger] Remove usage of legacy data spaces.
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index d37b810..67afbd6 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -207,7 +207,7 @@
}
TEST_F(SurfaceTest, QueryDefaultBuffersDataSpace) {
- const android_dataspace TEST_DATASPACE = HAL_DATASPACE_SRGB;
+ const android_dataspace TEST_DATASPACE = HAL_DATASPACE_V0_SRGB;
sp<IGraphicBufferProducer> producer;
sp<IGraphicBufferConsumer> consumer;
BufferQueue::createBufferQueue(&producer, &consumer);
diff --git a/opengl/libs/EGL/egl_platform_entries.cpp b/opengl/libs/EGL/egl_platform_entries.cpp
index 4ebd8bd..79166a7 100644
--- a/opengl/libs/EGL/egl_platform_entries.cpp
+++ b/opengl/libs/EGL/egl_platform_entries.cpp
@@ -461,7 +461,7 @@
if (colorspace == EGL_GL_COLORSPACE_LINEAR_KHR) {
return HAL_DATASPACE_UNKNOWN;
} else if (colorspace == EGL_GL_COLORSPACE_SRGB_KHR) {
- return HAL_DATASPACE_SRGB;
+ return HAL_DATASPACE_V0_SRGB;
} else if (colorspace == EGL_GL_COLORSPACE_DISPLAY_P3_EXT) {
return HAL_DATASPACE_DISPLAY_P3;
} else if (colorspace == EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT) {
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
index 9b1c0db..4e4d7dd 100644
--- a/services/surfaceflinger/BufferLayer.cpp
+++ b/services/surfaceflinger/BufferLayer.cpp
@@ -431,26 +431,25 @@
}
ui::Dataspace dataSpace = getDrawingDataSpace();
- // treat modern dataspaces as legacy dataspaces whenever possible, until
- // we can trust the buffer producers
+ // translate legacy dataspaces to modern dataspaces
switch (dataSpace) {
- case ui::Dataspace::V0_SRGB:
- dataSpace = ui::Dataspace::SRGB;
+ case ui::Dataspace::SRGB:
+ dataSpace = ui::Dataspace::V0_SRGB;
break;
- case ui::Dataspace::V0_SRGB_LINEAR:
- dataSpace = ui::Dataspace::SRGB_LINEAR;
+ case ui::Dataspace::SRGB_LINEAR:
+ dataSpace = ui::Dataspace::V0_SRGB_LINEAR;
break;
- case ui::Dataspace::V0_JFIF:
- dataSpace = ui::Dataspace::JFIF;
+ case ui::Dataspace::JFIF:
+ dataSpace = ui::Dataspace::V0_JFIF;
break;
- case ui::Dataspace::V0_BT601_625:
- dataSpace = ui::Dataspace::BT601_625;
+ case ui::Dataspace::BT601_625:
+ dataSpace = ui::Dataspace::V0_BT601_625;
break;
- case ui::Dataspace::V0_BT601_525:
- dataSpace = ui::Dataspace::BT601_525;
+ case ui::Dataspace::BT601_525:
+ dataSpace = ui::Dataspace::V0_BT601_525;
break;
- case ui::Dataspace::V0_BT709:
- dataSpace = ui::Dataspace::BT709;
+ case ui::Dataspace::BT709:
+ dataSpace = ui::Dataspace::V0_BT709;
break;
default:
break;
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 48fd47f..2963a97 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -98,7 +98,7 @@
Dataspace colorModeToDataspace(ColorMode mode) {
switch (mode) {
case ColorMode::SRGB:
- return Dataspace::SRGB;
+ return Dataspace::V0_SRGB;
case ColorMode::DISPLAY_P3:
return Dataspace::DISPLAY_P3;
case ColorMode::DISPLAY_BT2020:
@@ -817,7 +817,7 @@
bool DisplayDevice::hasRenderIntent(RenderIntent intent) const {
// assume a render intent is supported when SRGB supports it; we should
// get rid of that assumption.
- auto iter = mColorModes.find(getColorModeKey(Dataspace::SRGB, intent));
+ auto iter = mColorModes.find(getColorModeKey(Dataspace::V0_SRGB, intent));
return iter != mColorModes.end() && iter->second.renderIntent == intent;
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index a142928..a14ca2d 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -734,24 +734,6 @@
ALOGE("Run StartPropertySetThread failed!");
}
- // This is a hack. Per definition of getDataspaceSaturationMatrix, the returned matrix
- // is used to saturate legacy sRGB content. However, to make sure the same color under
- // Display P3 will be saturated to the same color, we intentionally break the API spec
- // and apply this saturation matrix on Display P3 content. Unless the risk of applying
- // such saturation matrix on Display P3 is understood fully, the API should always return
- // identify matrix.
- mEnhancedSaturationMatrix =
- getHwComposer().getDataspaceSaturationMatrix(*display->getId(), Dataspace::SRGB_LINEAR);
-
- // we will apply this on Display P3.
- if (mEnhancedSaturationMatrix != mat4()) {
- ColorSpace srgb(ColorSpace::sRGB());
- ColorSpace displayP3(ColorSpace::DisplayP3());
- mat4 srgbToP3 = mat4(ColorSpaceConnector(srgb, displayP3).getTransform());
- mat4 p3ToSrgb = mat4(ColorSpaceConnector(displayP3, srgb).getTransform());
- mEnhancedSaturationMatrix = srgbToP3 * mEnhancedSaturationMatrix * p3ToSrgb;
- }
-
ALOGV("Done initializing");
}
@@ -2106,7 +2088,7 @@
// - Dataspace::BT2020_PQ
Dataspace SurfaceFlinger::getBestDataspace(const sp<const DisplayDevice>& display,
Dataspace* outHdrDataSpace) const {
- Dataspace bestDataSpace = Dataspace::SRGB;
+ Dataspace bestDataSpace = Dataspace::V0_SRGB;
*outHdrDataSpace = Dataspace::UNKNOWN;
for (const auto& layer : display->getVisibleLayersSortedByZ()) {
@@ -2431,7 +2413,7 @@
Dataspace defaultDataSpace = Dataspace::UNKNOWN;
if (display->hasWideColorGamut()) {
defaultColorMode = ColorMode::SRGB;
- defaultDataSpace = Dataspace::SRGB;
+ defaultDataSpace = Dataspace::V0_SRGB;
}
setActiveColorModeInternal(display, defaultColorMode, defaultDataSpace,
RenderIntent::COLORIMETRIC);
@@ -3085,7 +3067,6 @@
mat4 colorMatrix;
bool applyColorMatrix = false;
- bool needsEnhancedColorMatrix = false;
// Framebuffer will live in this scope for GPU composition.
std::unique_ptr<renderengine::BindNativeBufferAsFramebuffer> fbo;
@@ -3132,16 +3113,6 @@
colorMatrix = mDrawingState.colorMatrix;
}
- // The current enhanced saturation matrix is designed to enhance Display P3,
- // thus we only apply this matrix when the render intent is not colorimetric
- // and the output color space is Display P3.
- needsEnhancedColorMatrix =
- (display->getActiveRenderIntent() >= RenderIntent::ENHANCE &&
- outputDataspace == Dataspace::DISPLAY_P3);
- if (needsEnhancedColorMatrix) {
- colorMatrix *= mEnhancedSaturationMatrix;
- }
-
display->setViewportAndProjection();
// Never touch the framebuffer if we don't have any framebuffer layers
@@ -3216,9 +3187,6 @@
tmpMatrix = mDrawingState.colorMatrix;
}
tmpMatrix *= layer->getColorTransform();
- if (needsEnhancedColorMatrix) {
- tmpMatrix *= mEnhancedSaturationMatrix;
- }
getRenderEngine().setColorTransform(tmpMatrix);
} else {
getRenderEngine().setColorTransform(colorMatrix);
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 9f52058..4977ca0 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -986,8 +986,6 @@
std::thread::id mMainThreadId;
DisplayColorSetting mDisplayColorSetting = DisplayColorSetting::ENHANCED;
- // Applied on Display P3 layers when the render intent is non-colorimetric.
- mat4 mEnhancedSaturationMatrix;
ui::Dataspace mDefaultCompositionDataspace;
ui::Dataspace mWideColorGamutCompositionDataspace;
diff --git a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
index 34cee3e..02aa5ce 100644
--- a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
@@ -1144,7 +1144,7 @@
getBestColorMode();
- ASSERT_EQ(ui::Dataspace::SRGB, mOutDataspace);
+ ASSERT_EQ(ui::Dataspace::V0_SRGB, mOutDataspace);
ASSERT_EQ(ui::ColorMode::SRGB, mOutColorMode);
ASSERT_EQ(ui::RenderIntent::COLORIMETRIC, mOutRenderIntent);
}