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

Commit c6e0cce6 authored by Patrick Williams's avatar Patrick Williams
Browse files

Update inverseLayerTransform for screenshots

This fixes a bug where texture filtering is incorrectly requested.
OutputLayer::calculateInitialCrop uses both layerTransform and
inverseLayerTransform so both values need to be updated. The result of
OutputLayer::calculateInitialCrop is used in
OutputLayer::needsFiltering.

Bug: 270537962
Change-Id: I793de6211b262a564b6ebce4db5ca7f5e36069ad
Test: atest TextureFilteringTest
Test: local revert of ag/21593142 then atest SurfaceControlTest
parent f8a49a24
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -7115,6 +7115,8 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl(
        captureResults.capturedHdrLayers |= isHdrLayer(*snapshot);
        layerFE->mSnapshot->geomLayerTransform =
                renderArea->getTransform() * layerFE->mSnapshot->geomLayerTransform;
        layerFE->mSnapshot->geomInverseLayerTransform =
                layerFE->mSnapshot->geomLayerTransform.inverse();
    }

    // We allow the system server to take screenshots of secure layers for
+13 −2
Original line number Diff line number Diff line
@@ -187,8 +187,6 @@ TEST_F(TextureFilteringTest, LayerCaptureWithCropNoFiltering) {

// Expect no filtering because the output source crop and output buffer are the same size.
TEST_F(TextureFilteringTest, OutputSourceCropDisplayFrameMatchNoFiltering) {
    // Transaction().setCrop(mLayer, Rect{25, 25, 75, 75}).apply();

    gui::DisplayCaptureArgs captureArgs;
    captureArgs.displayToken = mDisplay;
    captureArgs.width = 50;
@@ -224,4 +222,17 @@ TEST_F(TextureFilteringTest, ParentCropNoFiltering) {
    mCapture->expectColor(Rect{50, 25, 75, 75}, Color::BLUE);
}

// Expect no filtering because parent's position transform shouldn't scale the layer.
TEST_F(TextureFilteringTest, ParentHasTransformNoFiltering) {
    Transaction().setPosition(mParent, 100, 100).apply();

    LayerCaptureArgs captureArgs;
    captureArgs.layerHandle = mParent->getHandle();
    captureArgs.sourceCrop = Rect{0, 0, 100, 100};
    ScreenCapture::captureLayers(&mCapture, captureArgs);

    mCapture->expectColor(Rect{0, 0, 50, 100}, Color::RED);
    mCapture->expectColor(Rect{50, 0, 100, 100}, Color::BLUE);
}

} // namespace android