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

Commit 0391288e authored by Peiyong Lin's avatar Peiyong Lin
Browse files

[SurfaceFlinger] Use SDR data space for HDR video if it's in GPU composition.

If hardware composer supports HDR layer, then this will likely happen in window
transition and rotation, etc, and blending might happen on HDR layer. However,
blending in PQ gamma space is not nice, and thus we pick the widest SDR data
space for HDR video if it's in GPU composition.

As a result, color shift will be observed until RenderEngine can align with the
behaviour of hardware composer.

BUG: 130400004
Test: Verify with Youtube HDR rotation.
Change-Id: I3f517205fa319fe7c8f003f5997a4fe97be9b214
parent ab54fb71
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -2195,8 +2195,9 @@ void SurfaceFlinger::rebuildLayerStacks() {
//  - Dataspace::UNKNOWN
//  - Dataspace::BT2020_HLG
//  - Dataspace::BT2020_PQ
Dataspace SurfaceFlinger::getBestDataspace(const sp<const DisplayDevice>& display,
                                           Dataspace* outHdrDataSpace) const {
Dataspace SurfaceFlinger::getBestDataspace(const sp<DisplayDevice>& display,
                                           Dataspace* outHdrDataSpace,
                                           bool* outIsHdrClientComposition) const {
    Dataspace bestDataSpace = Dataspace::V0_SRGB;
    *outHdrDataSpace = Dataspace::UNKNOWN;

@@ -2217,6 +2218,7 @@ Dataspace SurfaceFlinger::getBestDataspace(const sp<const DisplayDevice>& displa
            case Dataspace::BT2020_ITU_PQ:
                bestDataSpace = Dataspace::DISPLAY_P3;
                *outHdrDataSpace = Dataspace::BT2020_PQ;
                *outIsHdrClientComposition = layer->getForceClientComposition(display);
                break;
            case Dataspace::BT2020_HLG:
            case Dataspace::BT2020_ITU_HLG:
@@ -2246,7 +2248,8 @@ void SurfaceFlinger::pickColorMode(const sp<DisplayDevice>& display, ColorMode*
    }

    Dataspace hdrDataSpace;
    Dataspace bestDataSpace = getBestDataspace(display, &hdrDataSpace);
    bool isHdrClientComposition = false;
    Dataspace bestDataSpace = getBestDataspace(display, &hdrDataSpace, &isHdrClientComposition);

    auto* profile = display->getCompositionDisplay()->getDisplayColorProfile();

@@ -2262,8 +2265,8 @@ void SurfaceFlinger::pickColorMode(const sp<DisplayDevice>& display, ColorMode*
    }

    // respect hdrDataSpace only when there is no legacy HDR support
    const bool isHdr =
            hdrDataSpace != Dataspace::UNKNOWN && !profile->hasLegacyHdrSupport(hdrDataSpace);
    const bool isHdr = hdrDataSpace != Dataspace::UNKNOWN &&
            !profile->hasLegacyHdrSupport(hdrDataSpace) && !isHdrClientComposition;
    if (isHdr) {
        bestDataSpace = hdrDataSpace;
    }
+2 −2
Original line number Diff line number Diff line
@@ -734,8 +734,8 @@ private:
                                    nsecs_t compositeToPresentLatency);
    void rebuildLayerStacks();

    ui::Dataspace getBestDataspace(const sp<const DisplayDevice>& display,
                                   ui::Dataspace* outHdrDataSpace) const;
    ui::Dataspace getBestDataspace(const sp<DisplayDevice>& display, ui::Dataspace* outHdrDataSpace,
                                   bool* outIsHdrClientComposition) const;

    // Returns the appropriate ColorMode, Dataspace and RenderIntent for the
    // DisplayDevice. The function only returns the supported ColorMode,