Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b0e4ddf authored by Chia-I Wu's avatar Chia-I Wu
Browse files

surfaceflinger: fix WCG flag in DisplayDevice creation

When a display does not support any wide color mode, yet it is
plugged when mForceNativeColorMode is true, we would incorrectly
mark the display as supporting wide color.

We should ignore mForceNativeColorMode entirely in DisplayDevice
creation because mForceNativeColorMode may change at runtime.

Test: builds
Change-Id: Icb245a2e78954b90d6c5461de8f4ef571858d959
parent 78e2069b
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -2266,9 +2266,8 @@ void SurfaceFlinger::processDisplayChangesLocked() {
                const wp<IBinder>& display(curr.keyAt(i));

                if (dispSurface != nullptr) {
                    bool useWideColorMode = hasWideColorDisplay;
                    if (!mForceNativeColorMode) {
                        bool hasWideColorModes = false;
                    bool hasWideColorSupport = false;
                    if (hasWideColorDisplay) {
                        std::vector<android_color_mode_t> modes =
                                getHwComposer().getColorModes(state.type);
                        for (android_color_mode_t colorMode : modes) {
@@ -2276,13 +2275,12 @@ void SurfaceFlinger::processDisplayChangesLocked() {
                                case HAL_COLOR_MODE_DISPLAY_P3:
                                case HAL_COLOR_MODE_ADOBE_RGB:
                                case HAL_COLOR_MODE_DCI_P3:
                                    hasWideColorModes = true;
                                    hasWideColorSupport = true;
                                    break;
                                default:
                                    break;
                            }
                        }
                        useWideColorMode = hasWideColorModes && hasWideColorDisplay;
                    }

                    bool hasHdrSupport = false;
@@ -2296,11 +2294,11 @@ void SurfaceFlinger::processDisplayChangesLocked() {

                    sp<DisplayDevice> hw =
                            new DisplayDevice(this, state.type, hwcId, state.isSecure, display,
                                              dispSurface, producer, useWideColorMode,
                                              dispSurface, producer, hasWideColorSupport,
                                              hasHdrSupport);

                    android_color_mode defaultColorMode = HAL_COLOR_MODE_NATIVE;
                    if (useWideColorMode) {
                    if (hasWideColorSupport) {
                        defaultColorMode = HAL_COLOR_MODE_SRGB;
                    }
                    setActiveColorModeInternal(hw, defaultColorMode);