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

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

Remove hard code color space.

In general when there's a color space involved, we must explicitly
specify instead of hard coding.

Bug: N/A
Test: atest SurfaceFlinger_unittest
Change-Id: I87c84990b4ec4bd815d7d552346c5fc8c7274135
parent b467d487
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -592,19 +592,20 @@ status_t CaptureArgs::write(Parcel& output) const {
    SAFE_PARCEL(output.writeFloat, frameScale);
    SAFE_PARCEL(output.writeBool, captureSecureLayers);
    SAFE_PARCEL(output.writeInt32, uid);
    SAFE_PARCEL(output.writeBool, useRGBColorSpace);
    SAFE_PARCEL(output.writeInt32, static_cast<int32_t>(dataspace));
    return NO_ERROR;
}

status_t CaptureArgs::read(const Parcel& input) {
    int32_t format = 0;
    SAFE_PARCEL(input.readInt32, &format);
    pixelFormat = static_cast<ui::PixelFormat>(format);
    int32_t value = 0;
    SAFE_PARCEL(input.readInt32, &value);
    pixelFormat = static_cast<ui::PixelFormat>(value);
    SAFE_PARCEL(input.read, sourceCrop);
    SAFE_PARCEL(input.readFloat, &frameScale);
    SAFE_PARCEL(input.readBool, &captureSecureLayers);
    SAFE_PARCEL(input.readInt32, &uid);
    SAFE_PARCEL(input.readBool, &useRGBColorSpace);
    SAFE_PARCEL(input.readInt32, &value);
    dataspace = static_cast<ui::Dataspace>(value);
    return NO_ERROR;
}

+5 −5
Original line number Diff line number Diff line
@@ -312,12 +312,12 @@ struct CaptureArgs {
    float frameScale{1};
    bool captureSecureLayers{false};
    int32_t uid{UNSET_UID};
    // True to force using RGB color as the capture result.
    // Force capture to be in a color space. If the value is ui::Dataspace::UNKNOWN, the captured
    // result will be in the display's colorspace.
    // The display may use non-RGB dataspace (ex. displayP3) that could cause pixel data could be
    // different from RGB (byte per color), and failed when checking colors.
    // NOTE: This should only be used for testing since in normal cases, we want the screen
    // capture's colorspace to match the display's colorspace
    bool useRGBColorSpace{false};
    // different from SRGB (byte per color), and failed when checking colors in tests.
    // NOTE: In normal cases, we want the screen to be captured in display's colorspace.
    ui::Dataspace dataspace = ui::Dataspace::UNKNOWN;

    virtual status_t write(Parcel& output) const;
    virtual status_t read(const Parcel& input);
+4 −6
Original line number Diff line number Diff line
@@ -5414,9 +5414,8 @@ status_t SurfaceFlinger::captureDisplay(const DisplayCaptureArgs& args,
        // (ex. displayP3) to enhance the content, but some cases are checking native RGB in bytes,
        // and failed if display is not in native mode. This provide a way to force using native
        // colors when capture.
        if (args.useRGBColorSpace) {
            dataspace = Dataspace::V0_SRGB;
        } else {
        dataspace = args.dataspace;
        if (dataspace == ui::Dataspace::UNKNOWN) {
            const ui::ColorMode colorMode = display->getCompositionDisplay()->getState().colorMode;
            dataspace = pickDataspaceFromColorMode(colorMode);
        }
@@ -5580,9 +5579,8 @@ status_t SurfaceFlinger::captureLayers(const LayerCaptureArgs& args,
        // (ex. displayP3) to enhance the content, but some cases are checking native RGB in bytes,
        // and failed if display is not in native mode. This provide a way to force using native
        // colors when capture.
        if (args.useRGBColorSpace) {
            dataspace = Dataspace::V0_SRGB;
        } else {
        dataspace = args.dataspace;
        if (dataspace == ui::Dataspace::UNKNOWN) {
            const ui::ColorMode colorMode = display->getCompositionDisplay()->getState().colorMode;
            dataspace = pickDataspaceFromColorMode(colorMode);
        }
+2 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ public:
        const auto sf = ComposerService::getComposerService();
        SurfaceComposerClient::Transaction().apply(true);

        captureArgs.useRGBColorSpace = true;
        captureArgs.dataspace = ui::Dataspace::V0_SRGB;
        const sp<SyncScreenCaptureListener> captureListener = new SyncScreenCaptureListener();
        status_t status = sf->captureDisplay(captureArgs, captureListener);

@@ -67,7 +67,7 @@ public:
        const auto sf = ComposerService::getComposerService();
        SurfaceComposerClient::Transaction().apply(true);

        captureArgs.useRGBColorSpace = true;
        captureArgs.dataspace = ui::Dataspace::V0_SRGB;
        const sp<SyncScreenCaptureListener> captureListener = new SyncScreenCaptureListener();
        status_t status = sf->captureLayers(captureArgs, captureListener);
        if (status != NO_ERROR) {