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

Commit 226bdaec authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Remove double display rotation for touchable region crop" into main

parents 412b7222 1ba381e8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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
+17 −0
Original line number Diff line number Diff line
@@ -353,6 +353,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));