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

Commit 1148147c authored by Chia-I Wu's avatar Chia-I Wu
Browse files

surfaceflinger: re-saturate all legacy dataspaces

We changed HIDL interface to re-saturate any legacy dataspace.
Update SurfaceFlinger to match the behavior.

Bug: 78303195
Test: videos are re-saturated as well in GPU fallback
Change-Id: Idfa74783061a62d79ca5d9f38e50f4095ce38322
parent 72128ee8
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -528,11 +528,9 @@ Region BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime
        recomputeVisibleRegions = true;
    }

    // Dataspace::V0_SRGB and Dataspace::V0_SRGB_LINEAR are not legacy
    // data space, however since framework doesn't distinguish them out of
    // legacy SRGB, we have to treat them as the same for now.
    // UNKNOWN is treated as legacy SRGB when the connected api is EGL.
    ui::Dataspace dataSpace = mConsumer->getCurrentDataSpace();
    // treat modern dataspaces as legacy dataspaces whenever possible, until
    // we can trust the buffer producers
    switch (dataSpace) {
        case ui::Dataspace::V0_SRGB:
            dataSpace = ui::Dataspace::SRGB;
@@ -540,10 +538,17 @@ Region BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime
        case ui::Dataspace::V0_SRGB_LINEAR:
            dataSpace = ui::Dataspace::SRGB_LINEAR;
            break;
        case ui::Dataspace::UNKNOWN:
            if (mConsumer->getCurrentApi() == NATIVE_WINDOW_API_EGL) {
                dataSpace = ui::Dataspace::SRGB;
            }
        case ui::Dataspace::V0_JFIF:
            dataSpace = ui::Dataspace::JFIF;
            break;
        case ui::Dataspace::V0_BT601_625:
            dataSpace = ui::Dataspace::BT601_625;
            break;
        case ui::Dataspace::V0_BT601_525:
            dataSpace = ui::Dataspace::BT601_525;
            break;
        case ui::Dataspace::V0_BT709:
            dataSpace = ui::Dataspace::BT709;
            break;
        default:
            break;
+4 −3
Original line number Diff line number Diff line
@@ -1650,9 +1650,10 @@ bool Layer::detachChildren() {
    return true;
}

bool Layer::isLegacySrgbDataSpace() const {
    return mDrawingState.dataSpace == ui::Dataspace::SRGB ||
        mDrawingState.dataSpace == ui::Dataspace::SRGB_LINEAR;
bool Layer::isLegacyDataSpace() const {
    // return true when no higher bits are set
    return !(mDrawingState.dataSpace & (ui::Dataspace::STANDARD_MASK |
                ui::Dataspace::TRANSFER_MASK | ui::Dataspace::RANGE_MASK));
}

void Layer::setParent(const sp<Layer>& layer) {
+2 −2
Original line number Diff line number Diff line
@@ -303,8 +303,8 @@ public:
    // desaturated in order to match what they appears like visually.
    // With color management, these contents will appear desaturated, thus
    // needed to be saturated so that they match what they are designed for
    // visually. When returns true, legacy SRGB data space is passed to HWC.
    bool isLegacySrgbDataSpace() const;
    // visually.
    bool isLegacyDataSpace() const;

    // If we have received a new buffer this frame, we will pass its surface
    // damage down to hardware composer. Otherwise, we must send a region with
+1 −1
Original line number Diff line number Diff line
@@ -2989,7 +2989,7 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& displayDev
                        bool restore = false;
                        mat4 savedMatrix;
                        if (mDisplayColorSetting == DisplayColorSetting::ENHANCED &&
                            layer->isLegacySrgbDataSpace()) {
                            layer->isLegacyDataSpace()) {
                            savedMatrix =
                                getRenderEngine().setupColorTransform(legacySrgbSaturationMatrix);
                            restore = true;