SurfaceFlinger: Inherit non-transform Scaling from parent.
When a Layer is fixed-size, we may apply additional scaling
to the buffer not accounted for in the transform. This means
that if the WindowManager calls setSize we will scale the parent
surface but not the child surfaces, breaking the contract that
the WM can treat the child surfaces as pixels in the parent.
Test: Included test in Transaction_test.
Bug: 36820947
Bug: 37344435
Change-Id: I5478bad176388fe8e5407379bc36cdfd6600ab97
diff --git a/services/surfaceflinger/tests/Transaction_test.cpp b/services/surfaceflinger/tests/Transaction_test.cpp
index 441fc7e..7a8b4ab 100644
--- a/services/surfaceflinger/tests/Transaction_test.cpp
+++ b/services/surfaceflinger/tests/Transaction_test.cpp
@@ -909,4 +909,36 @@
}
}
+TEST_F(ChildLayerTest, ChildrenInheritNonTransformScalingFromParent) {
+ SurfaceComposerClient::openGlobalTransaction();
+ mChild->show();
+ mChild->setPosition(0, 0);
+ mFGSurfaceControl->setPosition(0, 0);
+ SurfaceComposerClient::closeGlobalTransaction(true);
+
+ {
+ ScreenCapture::captureScreen(&mCapture);
+ // We've positioned the child in the top left.
+ mCapture->expectChildColor(0, 0);
+ // But it's only 10x10.
+ mCapture->expectFGColor(10, 10);
+ }
+
+ SurfaceComposerClient::openGlobalTransaction();
+ mFGSurfaceControl->setOverrideScalingMode(NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);
+ // We cause scaling by 2.
+ mFGSurfaceControl->setSize(128, 128);
+ SurfaceComposerClient::closeGlobalTransaction();
+
+ {
+ ScreenCapture::captureScreen(&mCapture);
+ // We've positioned the child in the top left.
+ mCapture->expectChildColor(0, 0);
+ mCapture->expectChildColor(10, 10);
+ mCapture->expectChildColor(19, 19);
+ // And now it should be scaled all the way to 20x20
+ mCapture->expectFGColor(20, 20);
+ }
+}
+
}