OSDN Git Service

Use wide gamut only when necessary
authorRomain Guy <romainguy@google.com>
Thu, 1 Jun 2017 02:22:30 +0000 (19:22 -0700)
committerRomain Guy <romainguy@google.com>
Thu, 1 Jun 2017 02:31:47 +0000 (19:31 -0700)
Set the dataspace of the screenshot based on the result of
the composition. When no wide gamut app is visible, the screenshot
will be in sRGB, otherwise in Display P3. On device that do not
support wide gamut, the color space will be unknown (native).

Bug: 29940137
Test: screencap and Android Studio
Change-Id: I93f3f8e5afebb9f3f17b835fdf5bc215b0856d55

services/surfaceflinger/SurfaceFlinger.cpp
services/surfaceflinger/SurfaceFlinger.h

index beefc50..000b4c6 100644 (file)
@@ -152,7 +152,6 @@ SurfaceFlinger::SurfaceFlinger()
         mPrimaryDispSync("PrimaryDispSync"),
         mPrimaryHWVsyncEnabled(false),
         mHWVsyncAvailable(false),
-        mHasColorMatrix(false),
         mHasPoweredOff(false),
         mFrameBuckets(),
         mTotalTime(0),
@@ -4331,8 +4330,6 @@ status_t SurfaceFlinger::captureScreenImplLocked(
         err |= native_window_set_scaling_mode(window, NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);
         err |= native_window_set_buffers_format(window, HAL_PIXEL_FORMAT_RGBA_8888);
         err |= native_window_set_usage(window, usage);
-        err |= native_window_set_buffers_data_space(window, hw->getWideColorSupport()
-                ? HAL_DATASPACE_DISPLAY_P3 : HAL_DATASPACE_V0_SRGB);
 
         if (err == NO_ERROR) {
             ANativeWindowBuffer* buffer;
@@ -4359,6 +4356,14 @@ status_t SurfaceFlinger::captureScreenImplLocked(
                             hw, sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ, true,
                             useIdentityTransform, rotation);
 
+#ifdef USE_HWC2
+                        if (hasWideColorDisplay) {
+                            native_window_set_buffers_data_space(window,
+                                getRenderEngine().usesWideColor() ?
+                                    HAL_DATASPACE_DISPLAY_P3 : HAL_DATASPACE_V0_SRGB);
+                        }
+#endif
+
                         // Attempt to create a sync khr object that can produce a sync point. If that
                         // isn't available, create a non-dupable sync object in the fallback path and
                         // wait on it directly.
index 1bc689d..e849313 100644 (file)
@@ -705,7 +705,6 @@ private:
 
     mat4 mPreviousColorMatrix;
     mat4 mColorMatrix;
-    bool mHasColorMatrix;
 
     // Static screen stats
     bool mHasPoweredOff;