diff options
author | Romain Guy | 2017-10-24 15:40:32 -0500 |
---|---|---|
committer | android-build-team Robot | 2017-10-25 00:30:30 -0500 |
commit | 4ba7d2ec503655357acd6513cd2709934c015d63 (patch) | |
tree | a3c036ea017a5f130937c5647894342c2ad8bdbe | |
parent | d8f66b08ea607fb6c4bcbb8a62a0a99f82d909f9 (diff) | |
download | frameworks-native-4ba7d2ec503655357acd6513cd2709934c015d63.tar.gz frameworks-native-4ba7d2ec503655357acd6513cd2709934c015d63.tar.xz frameworks-native-4ba7d2ec503655357acd6513cd2709934c015d63.zip |
Add new color setting
On devices that support wide color rendering and color management,
add a new setting to disable color management ("saturated" color
mode). To disable color management, the framework can set a persistent
property. Color management can be also toggled by using a Binder
transaction. Finally this change adds a new Binder query so Settings
can easily check whether the device supports wide color rendering.
Bug: 68159303
Test: manual (adb shell + apps)
Change-Id: If74d9b0273bc04f4a3d11e63fe2ec96451fbcc2e
(cherry picked from commit 54f154a28284eabb52ade2689d4a9f8fa190163b)
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 42 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 1 |
2 files changed, 35 insertions, 8 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index c05ac8aaa..bb0e33cb4 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp | |||
@@ -656,6 +656,12 @@ void SurfaceFlinger::readPersistentProperties() { | |||
656 | property_get("persist.sys.sf.color_saturation", value, "1.0"); | 656 | property_get("persist.sys.sf.color_saturation", value, "1.0"); |
657 | mSaturation = atof(value); | 657 | mSaturation = atof(value); |
658 | ALOGV("Saturation is set to %.2f", mSaturation); | 658 | ALOGV("Saturation is set to %.2f", mSaturation); |
659 | |||
660 | property_get("persist.sys.sf.native_mode", value, "0"); | ||
661 | mForceNativeColorMode = atoi(value) == 1; | ||
662 | if (mForceNativeColorMode) { | ||
663 | ALOGV("Forcing native color mode"); | ||
664 | } | ||
659 | } | 665 | } |
660 | 666 | ||
661 | void SurfaceFlinger::startBootAnim() { | 667 | void SurfaceFlinger::startBootAnim() { |
@@ -1235,12 +1241,13 @@ void SurfaceFlinger::createDefaultDisplayDevice() { | |||
1235 | break; | 1241 | break; |
1236 | } | 1242 | } |
1237 | } | 1243 | } |
1244 | bool useWideColorMode = hasWideColorModes && hasWideColorDisplay && !mForceNativeColorMode; | ||
1238 | sp<DisplayDevice> hw = new DisplayDevice(this, DisplayDevice::DISPLAY_PRIMARY, type, isSecure, | 1245 | sp<DisplayDevice> hw = new DisplayDevice(this, DisplayDevice::DISPLAY_PRIMARY, type, isSecure, |
1239 | token, fbs, producer, mRenderEngine->getEGLConfig(), | 1246 | token, fbs, producer, mRenderEngine->getEGLConfig(), |
1240 | hasWideColorModes && hasWideColorDisplay); | 1247 | useWideColorMode); |
1241 | mDisplays.add(token, hw); | 1248 | mDisplays.add(token, hw); |
1242 | android_color_mode defaultColorMode = HAL_COLOR_MODE_NATIVE; | 1249 | android_color_mode defaultColorMode = HAL_COLOR_MODE_NATIVE; |
1243 | if (hasWideColorModes && hasWideColorDisplay) { | 1250 | if (useWideColorMode) { |
1244 | defaultColorMode = HAL_COLOR_MODE_SRGB; | 1251 | defaultColorMode = HAL_COLOR_MODE_SRGB; |
1245 | } | 1252 | } |
1246 | setActiveColorModeInternal(hw, defaultColorMode); | 1253 | setActiveColorModeInternal(hw, defaultColorMode); |
@@ -1756,6 +1763,10 @@ mat4 SurfaceFlinger::computeSaturationMatrix() const { | |||
1756 | // pickColorMode translates a given dataspace into the best available color mode. | 1763 | // pickColorMode translates a given dataspace into the best available color mode. |
1757 | // Currently only support sRGB and Display-P3. | 1764 | // Currently only support sRGB and Display-P3. |
1758 | android_color_mode SurfaceFlinger::pickColorMode(android_dataspace dataSpace) const { | 1765 | android_color_mode SurfaceFlinger::pickColorMode(android_dataspace dataSpace) const { |
1766 | if (mForceNativeColorMode) { | ||
1767 | return HAL_COLOR_MODE_NATIVE; | ||
1768 | } | ||
1769 | |||
1759 | switch (dataSpace) { | 1770 | switch (dataSpace) { |
1760 | // treat Unknown as regular SRGB buffer, since that's what the rest of the | 1771 | // treat Unknown as regular SRGB buffer, since that's what the rest of the |
1761 | // system expects. | 1772 | // system expects. |
@@ -2590,8 +2601,10 @@ bool SurfaceFlinger::doComposeSurfaces( | |||
2590 | ALOGV("hasClientComposition"); | 2601 | ALOGV("hasClientComposition"); |
2591 | 2602 | ||
2592 | #ifdef USE_HWC2 | 2603 | #ifdef USE_HWC2 |
2593 | mRenderEngine->setWideColor(displayDevice->getWideColorSupport()); | 2604 | mRenderEngine->setWideColor( |
2594 | mRenderEngine->setColorMode(displayDevice->getActiveColorMode()); | 2605 | displayDevice->getWideColorSupport() && !mForceNativeColorMode); |
2606 | mRenderEngine->setColorMode(mForceNativeColorMode ? | ||
2607 | HAL_COLOR_MODE_NATIVE : displayDevice->getActiveColorMode()); | ||
2595 | #endif | 2608 | #endif |
2596 | if (!displayDevice->makeCurrent(mEGLDisplay, mEGLContext)) { | 2609 | if (!displayDevice->makeCurrent(mEGLDisplay, mEGLContext)) { |
2597 | ALOGW("DisplayDevice::makeCurrent failed. Aborting surface composition for display %s", | 2610 | ALOGW("DisplayDevice::makeCurrent failed. Aborting surface composition for display %s", |
@@ -3632,6 +3645,7 @@ void SurfaceFlinger::dumpBufferingStats(String8& result) const { | |||
3632 | 3645 | ||
3633 | void SurfaceFlinger::dumpWideColorInfo(String8& result) const { | 3646 | void SurfaceFlinger::dumpWideColorInfo(String8& result) const { |
3634 | result.appendFormat("hasWideColorDisplay: %d\n", hasWideColorDisplay); | 3647 | result.appendFormat("hasWideColorDisplay: %d\n", hasWideColorDisplay); |
3648 | result.appendFormat("forceNativeColorMode: %d\n", mForceNativeColorMode); | ||
3635 | 3649 | ||
3636 | // TODO: print out if wide-color mode is active or not | 3650 | // TODO: print out if wide-color mode is active or not |
3637 | 3651 | ||
@@ -4085,6 +4099,17 @@ status_t SurfaceFlinger::onTransact( | |||
4085 | repaintEverything(); | 4099 | repaintEverything(); |
4086 | return NO_ERROR; | 4100 | return NO_ERROR; |
4087 | } | 4101 | } |
4102 | case 1023: { // Set native mode | ||
4103 | mForceNativeColorMode = data.readInt32() == 1; | ||
4104 | |||
4105 | invalidateHwcGeometry(); | ||
4106 | repaintEverything(); | ||
4107 | return NO_ERROR; | ||
4108 | } | ||
4109 | case 1024: { // Is wide color gamut rendering/color management supported? | ||
4110 | reply->writeBool(hasWideColorDisplay); | ||
4111 | return NO_ERROR; | ||
4112 | } | ||
4088 | } | 4113 | } |
4089 | } | 4114 | } |
4090 | return err; | 4115 | return err; |
@@ -4242,8 +4267,9 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display, | |||
4242 | WindowDisconnector disconnector(window, NATIVE_WINDOW_API_EGL); | 4267 | WindowDisconnector disconnector(window, NATIVE_WINDOW_API_EGL); |
4243 | 4268 | ||
4244 | ANativeWindowBuffer* buffer = nullptr; | 4269 | ANativeWindowBuffer* buffer = nullptr; |
4245 | result = getWindowBuffer(window, reqWidth, reqHeight, hasWideColorDisplay, | 4270 | result = getWindowBuffer(window, reqWidth, reqHeight, |
4246 | getRenderEngine().usesWideColor(), &buffer); | 4271 | hasWideColorDisplay && !mForceNativeColorMode, |
4272 | getRenderEngine().usesWideColor(), &buffer); | ||
4247 | if (result != NO_ERROR) { | 4273 | if (result != NO_ERROR) { |
4248 | return result; | 4274 | return result; |
4249 | } | 4275 | } |
@@ -4345,8 +4371,8 @@ void SurfaceFlinger::renderScreenImplLocked( | |||
4345 | } | 4371 | } |
4346 | 4372 | ||
4347 | #ifdef USE_HWC2 | 4373 | #ifdef USE_HWC2 |
4348 | engine.setWideColor(hw->getWideColorSupport()); | 4374 | engine.setWideColor(hw->getWideColorSupport() && !mForceNativeColorMode); |
4349 | engine.setColorMode(hw->getActiveColorMode()); | 4375 | engine.setColorMode(mForceNativeColorMode ? HAL_COLOR_MODE_NATIVE : hw->getActiveColorMode()); |
4350 | #endif | 4376 | #endif |
4351 | 4377 | ||
4352 | // make sure to clear all GL error flags | 4378 | // make sure to clear all GL error flags |
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 13a057f2b..7606e10a6 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h | |||
@@ -814,6 +814,7 @@ private: | |||
814 | #endif | 814 | #endif |
815 | 815 | ||
816 | float mSaturation = 1.0f; | 816 | float mSaturation = 1.0f; |
817 | bool mForceNativeColorMode = false; | ||
817 | }; | 818 | }; |
818 | }; // namespace android | 819 | }; // namespace android |
819 | 820 | ||