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
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index eecfeb6..f0f1632 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -7115,6 +7115,8 @@
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
diff --git a/services/surfaceflinger/tests/TextureFiltering_test.cpp b/services/surfaceflinger/tests/TextureFiltering_test.cpp
index e9b1fbb..d0ab105 100644
--- a/services/surfaceflinger/tests/TextureFiltering_test.cpp
+++ b/services/surfaceflinger/tests/TextureFiltering_test.cpp
@@ -187,8 +187,6 @@
// 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 @@
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