summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChavi Weingarten <chaviw@google.com>2024-01-09 21:54:11 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-01-11 22:18:01 +0000
commit196f68cffb90b111581e6a47ec0ce2c1fd70e7d8 (patch)
tree5e3cd09398ba0691418e83c85973ee0a4bb4122b
parent8748247dc23093761cc62c8feda4ff88bab46d22 (diff)
downloadnative-196f68cffb90b111581e6a47ec0ce2c1fd70e7d8.tar.gz
Remove double display rotation for touchable region crop
inputBoundsInDisplaySpace is already in display space so remove the second call to transform the rect by the display transform. This causes a bug if the layer is using layer crop for touchable region and the display is rotated since the bounds will get double transformed, causing the touchable region to be offscreen. Bug: 312984511 Test: LayerSnapshotTest#CanCropTouchableRegionWithDisplayTransform (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:1ba381e89fe7dfa20b0c8c1a880af59e2698925a) Merged-In: I7d3eb9d5f129988573907658795e3a4349a5ece9 Change-Id: I7d3eb9d5f129988573907658795e3a4349a5ece9
-rw-r--r--services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp4
-rw-r--r--services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp17
2 files changed, 19 insertions, 2 deletions
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
index ad5e42be37..bb32afa991 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
@@ -1217,8 +1217,8 @@ void LayerSnapshotBuilder::updateTouchableRegionCrop(const Args& args) {
Rect inputBoundsInDisplaySpace =
getInputBoundsInDisplaySpace(*cropLayerSnapshot, inputBounds,
displayInfo.transform);
- snapshot->inputInfo.touchableRegion = snapshot->inputInfo.touchableRegion.intersect(
- displayInfo.transform.transform(inputBoundsInDisplaySpace));
+ snapshot->inputInfo.touchableRegion =
+ snapshot->inputInfo.touchableRegion.intersect(inputBoundsInDisplaySpace);
}
// If the layer is a clone, we need to crop the input region to cloned root to prevent
diff --git a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
index 50cd784725..f7492c32af 100644
--- a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
+++ b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
@@ -354,6 +354,23 @@ TEST_F(LayerSnapshotTest, CanCropTouchableRegion) {
EXPECT_EQ(getSnapshot({.id = 111})->inputInfo.touchableRegion.bounds(), modifiedTouchCrop);
}
+TEST_F(LayerSnapshotTest, CanCropTouchableRegionWithDisplayTransform) {
+ DisplayInfo displayInfo;
+ displayInfo.transform = ui::Transform(ui::Transform::RotationFlags::ROT_90, 1000, 1000);
+ mFrontEndDisplayInfos.emplace_or_replace(ui::LayerStack::fromValue(1), displayInfo);
+
+ Rect touchCrop{300, 300, 400, 500};
+ createRootLayer(3);
+ setCrop(3, touchCrop);
+ setLayerStack(3, 1);
+ Region touch{Rect{0, 0, 1000, 1000}};
+ setTouchableRegionCrop(3, touch, /*touchCropId=*/3, /*replaceTouchableRegionWithCrop=*/false);
+
+ UPDATE_AND_VERIFY(mSnapshotBuilder, {1, 11, 111, 12, 121, 122, 1221, 13, 2, 3});
+ Rect rotatedCrop = {500, 300, 700, 400};
+ EXPECT_EQ(getSnapshot({.id = 3})->inputInfo.touchableRegion.bounds(), rotatedCrop);
+}
+
TEST_F(LayerSnapshotTest, blurUpdatesWhenAlphaChanges) {
int blurRadius = 42;
setBackgroundBlurRadius(1221, static_cast<uint32_t>(blurRadius));