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

Commit cd580e58 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix SurfaceFlinger_test failed when display color mode changed"

parents 24e1e94c 79e81aa6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -541,6 +541,7 @@ 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);
    return NO_ERROR;
}

@@ -552,7 +553,7 @@ status_t CaptureArgs::read(const Parcel& input) {
    SAFE_PARCEL(input.readFloat, &frameScale);
    SAFE_PARCEL(input.readBool, &captureSecureLayers);
    SAFE_PARCEL(input.readInt32, &uid);

    SAFE_PARCEL(input.readBool, &useRGBColorSpace);
    return NO_ERROR;
}

+6 −0
Original line number Diff line number Diff line
@@ -341,6 +341,12 @@ struct CaptureArgs {
    float frameScale{1};
    bool captureSecureLayers{false};
    int32_t uid{UNSET_UID};
    // True to force using RGB color as the capture result.
    // 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};

    virtual status_t write(Parcel& output) const;
    virtual status_t read(const Parcel& input);
+20 −4
Original line number Diff line number Diff line
@@ -5515,9 +5515,17 @@ status_t SurfaceFlinger::captureDisplay(const DisplayCaptureArgs& args,
            reqSize = display->getLayerStackSpaceRect().getSize();
        }

        // The dataspace is depended on the color mode of display, that could use non-native mode
        // (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 {
            const ui::ColorMode colorMode = display->getCompositionDisplay()->getState().colorMode;
            dataspace = pickDataspaceFromColorMode(colorMode);
        }
    }

    RenderAreaFuture renderAreaFuture = promise::defer([=] {
        return DisplayRenderArea::create(displayWeak, args.sourceCrop, reqSize, dataspace,
@@ -5673,8 +5681,16 @@ status_t SurfaceFlinger::captureLayers(const LayerCaptureArgs& args,

        layerStackSpaceRect = display->getLayerStackSpaceRect();

        // The dataspace is depended on the color mode of display, that could use non-native mode
        // (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 {
            const ui::ColorMode colorMode = display->getCompositionDisplay()->getState().colorMode;
            dataspace = pickDataspaceFromColorMode(colorMode);
        }

        captureSecureLayers = args.captureSecureLayers && display->isSecure();
    } // mStateLock
+1 −1
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ TEST_F(CredentialsTest, AllowedGetterMethodsTest) {
    Vector<DisplayConfig> configs;
    ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getDisplayConfigs(display, &configs));

    ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveConfig(display));
    ASSERT_TRUE(SurfaceComposerClient::getActiveConfig(display) >= 0);

    ASSERT_NE(static_cast<ui::ColorMode>(BAD_VALUE),
              SurfaceComposerClient::getActiveColorMode(display));
+3 −0
Original line number Diff line number Diff line
@@ -34,8 +34,10 @@ public:
        const auto sf = ComposerService::getComposerService();
        SurfaceComposerClient::Transaction().apply(true);

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

        if (status != NO_ERROR) {
            return status;
        }
@@ -65,6 +67,7 @@ public:
        const auto sf = ComposerService::getComposerService();
        SurfaceComposerClient::Transaction().apply(true);

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