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

Commit dfde5119 authored by Peiyong Lin's avatar Peiyong Lin
Browse files

[SurfaceFlinger] Respect HDR data space.

Respect HDR data space when there is no legacy HDR support. Previously we only
cared about HDR data space when it is supported, however, on Pixel 2 there is
no HDR mode support. This patch makes sure that when HDR mode is not supported,
we fall back to Display P3 color mode correctly.

BUG: 80404330
Test: Build, flash and watch Youtube HDR
Change-Id: I7d27711fe4d33268e5ebbd14fce0975f9e642e84
parent 7ea1dc7f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -760,12 +760,12 @@ bool DisplayDevice::hasRenderIntent(RenderIntent intent) const {
    return iter != mColorModes.end() && iter->second.renderIntent == intent;
}

bool DisplayDevice::hasModernHdrSupport(Dataspace dataspace) const {
bool DisplayDevice::hasLegacyHdrSupport(Dataspace dataspace) const {
    if ((dataspace == Dataspace::BT2020_PQ && hasHDR10Support()) ||
        (dataspace == Dataspace::BT2020_HLG && hasHLGSupport())) {
        auto iter =
                mColorModes.find(getColorModeKey(dataspace, RenderIntent::TONE_MAP_COLORIMETRIC));
        return iter != mColorModes.end() && iter->second.dataspace == dataspace;
        return iter == mColorModes.end() || iter->second.dataspace != dataspace;
    }

    return false;
+3 −3
Original line number Diff line number Diff line
@@ -152,9 +152,9 @@ public:
    bool hasHLGSupport() const { return mHasHLG; }
    bool hasDolbyVisionSupport() const { return mHasDolbyVision; }

    // Return true if the corresponding color mode for the HDR dataspace is
    // supported.
    bool hasModernHdrSupport(ui::Dataspace dataspace) const;
    // Return true if the HDR dataspace is supported but
    // there is no corresponding color mode.
    bool hasLegacyHdrSupport(ui::Dataspace dataspace) const;

    // The returned HdrCapabilities is the combination of HDR capabilities from
    // hardware composer and RenderEngine. When the DisplayDevice supports wide
+2 −2
Original line number Diff line number Diff line
@@ -1857,9 +1857,9 @@ void SurfaceFlinger::pickColorMode(const sp<DisplayDevice>& display, ColorMode*
    Dataspace hdrDataSpace;
    Dataspace bestDataSpace = getBestDataspace(display, &hdrDataSpace);

    // respect hdrDataSpace only when there is modern HDR support
    // respect hdrDataSpace only when there is no legacy HDR support
    const bool isHdr = hdrDataSpace != Dataspace::UNKNOWN &&
        display->hasModernHdrSupport(hdrDataSpace);
        !display->hasLegacyHdrSupport(hdrDataSpace);
    if (isHdr) {
        bestDataSpace = hdrDataSpace;
    }