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

Commit 36574d99 authored by Chia-I Wu's avatar Chia-I Wu
Browse files

surfaceflinger: fix screenshot dataspace under WCG

Commit a252d895 (Use GraphicBuffer instead of GBP for screenshots)
removed the ability to query the dataspace of the screenshots.  WM
assumes they are sRGB anyway.  Let's force screenshots to be in
sRGB.

Bug: 79547689
Test: no color shift during Photos rotation
Change-Id: If57cba1b5a50c4e1f9b305af39d9588b3dd1775d
parent 7c964b3d
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -336,13 +336,6 @@ public:
    bool isSecure() const override { return mDevice->isSecure(); }
    bool needsFiltering() const override { return mDevice->needsFiltering(); }
    Rect getSourceCrop() const override { return mSourceCrop; }
    bool getWideColorSupport() const override { return mDevice->hasWideColorGamut(); }
    ui::Dataspace getDataSpace() const override {
        return mDevice->getCompositionDataSpace();
    }
    float getDisplayMaxLuminance() const override {
        return mDevice->getHdrCapabilities().getDesiredMaxLuminance();
    }

private:
    const sp<const DisplayDevice> mDevice;
+0 −3
Original line number Diff line number Diff line
@@ -30,9 +30,6 @@ public:
    virtual bool isSecure() const = 0;
    virtual bool needsFiltering() const = 0;
    virtual Rect getSourceCrop() const = 0;
    virtual bool getWideColorSupport() const = 0;
    virtual ui::Dataspace getDataSpace() const = 0;
    virtual float getDisplayMaxLuminance() const = 0;

    virtual void render(std::function<void()> drawLayers) { drawLayers(); }

+3 −12
Original line number Diff line number Diff line
@@ -4810,12 +4810,6 @@ status_t SurfaceFlinger::captureLayers(const sp<IBinder>& layerHandleBinder,
                return mCrop;
            }
        }
        bool getWideColorSupport() const override { return false; }
        Dataspace getDataSpace() const override { return Dataspace::UNKNOWN; }
        float getDisplayMaxLuminance() const override {
            return DisplayDevice::sDefaultMaxLumiance;
        }

        class ReparentForDrawing {
        public:
            const sp<Layer>& oldParent;
@@ -5013,12 +5007,9 @@ void SurfaceFlinger::renderScreenImplLocked(const RenderArea& renderArea,
        ALOGE("Invalid crop rect: b = %d (> %d)", sourceCrop.bottom, raHeight);
    }

    Dataspace outputDataspace = Dataspace::UNKNOWN;
    if (renderArea.getWideColorSupport()) {
        outputDataspace = renderArea.getDataSpace();
    }
    engine.setOutputDataSpace(outputDataspace);
    engine.setDisplayMaxLuminance(renderArea.getDisplayMaxLuminance());
    // assume ColorMode::SRGB / RenderIntent::COLORIMETRIC
    engine.setOutputDataSpace(Dataspace::SRGB);
    engine.setDisplayMaxLuminance(DisplayDevice::sDefaultMaxLumiance);

    // make sure to clear all GL error flags
    engine.checkErrors();