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

Commit 7a28ecb9 authored by Chia-I Wu's avatar Chia-I Wu
Browse files

surfaceflinger: no re-saturation when in SRGB mode

Under ColorMode::SRGB and RenderIntent::ENHANCE, HWC always applies
the legacy sRGB saturation matrix.  SurfaceFlinger should not apply
the matrix.

Bug: 78891890
Test: no color shift when forcing GPU fallback
Change-Id: I7ebbefa38c5a6b72d326e0b2d4eee52d8409b5c7
parent 8e50e696
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -1873,13 +1873,13 @@ void SurfaceFlinger::rebuildLayerStacks() {
// Returns a dataspace that fits all visible layers.  The returned dataspace
// Returns a dataspace that fits all visible layers.  The returned dataspace
// can only be one of
// can only be one of
//
//
//  - Dataspace::V0_SRGB
//  - Dataspace::SRGB (use legacy dataspace and let HWC saturate when colors are enhanced)
//  - Dataspace::DISPLAY_P3
//  - Dataspace::DISPLAY_P3
//  - Dataspace::V0_SCRGB_LINEAR
//  - Dataspace::V0_SCRGB_LINEAR
// TODO(b/73825729) Add BT2020 data space.
// TODO(b/73825729) Add BT2020 data space.
ui::Dataspace SurfaceFlinger::getBestDataspace(
ui::Dataspace SurfaceFlinger::getBestDataspace(
        const sp<const DisplayDevice>& displayDevice) const {
        const sp<const DisplayDevice>& displayDevice) const {
    Dataspace bestDataspace = Dataspace::V0_SRGB;
    Dataspace bestDataspace = Dataspace::SRGB;
    for (const auto& layer : displayDevice->getVisibleLayersSortedByZ()) {
    for (const auto& layer : displayDevice->getVisibleLayersSortedByZ()) {
        switch (layer->getDataSpace()) {
        switch (layer->getDataSpace()) {
            case Dataspace::V0_SCRGB:
            case Dataspace::V0_SCRGB:
@@ -1930,7 +1930,7 @@ void SurfaceFlinger::pickColorMode(const sp<DisplayDevice>& displayDevice,
            break;
            break;
        default:
        default:
            *outMode = ColorMode::SRGB;
            *outMode = ColorMode::SRGB;
            *outDataSpace = Dataspace::V0_SRGB;
            *outDataSpace = Dataspace::SRGB;
            break;
            break;
    }
    }
}
}
@@ -2901,7 +2901,9 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& displayDev
            colorMatrix = mDrawingState.colorMatrix;
            colorMatrix = mDrawingState.colorMatrix;
        }
        }


        applyLegacyColorMatrix = mDisplayColorSetting == DisplayColorSetting::ENHANCED;
        applyLegacyColorMatrix = (mDisplayColorSetting == DisplayColorSetting::ENHANCED &&
                outputDataspace != Dataspace::UNKNOWN &&
                outputDataspace != Dataspace::SRGB);
        if (applyLegacyColorMatrix) {
        if (applyLegacyColorMatrix) {
            if (applyColorMatrix) {
            if (applyColorMatrix) {
                legacyColorMatrix = colorMatrix * mLegacySrgbSaturationMatrix;
                legacyColorMatrix = colorMatrix * mLegacySrgbSaturationMatrix;