Merge "Rounded corner: fix layer settings when inherited from parent settings" into main
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
index 0be3a11..7289e2f 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
@@ -982,6 +982,8 @@
parentRoundedCorner.cropRect = t.transform(parentRoundedCorner.cropRect);
parentRoundedCorner.radius.x *= t.getScaleX();
parentRoundedCorner.radius.y *= t.getScaleY();
+ parentRoundedCorner.requestedRadius.x *= t.getScaleX();
+ parentRoundedCorner.requestedRadius.y *= t.getScaleY();
}
FloatRect layerCropRect = snapshot.croppedBufferSize;
diff --git a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
index 2deb177..ab8c733 100644
--- a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
+++ b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
@@ -28,6 +28,7 @@
#include "ui/GraphicTypes.h"
#include <com_android_graphics_libgui_flags.h>
+#include <cmath>
#define UPDATE_AND_VERIFY(BUILDER, ...) \
({ \
@@ -1443,7 +1444,36 @@
EXPECT_EQ(getSnapshot({.id = 1})->roundedCorner.radius.x, 0.f);
}
-TEST_F(LayerSnapshotTest, childInheritsParentIntendedCornerRadius) {
+TEST_F(LayerSnapshotTest, childInheritsParentScaledSettings) {
+ // ROOT
+ // ├── 1 (crop rect set to contain child layer)
+ // │ ├── 11
+ static constexpr float RADIUS = 123.f;
+
+ setRoundedCorners(1, RADIUS);
+ FloatRect parentCropRect(1, 1, 999, 999);
+ setCrop(1, parentCropRect);
+ // Rotate surface by 90
+ setMatrix(11, 0.f, -1.f, 1.f, 0.f);
+
+ UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
+
+ ui::Transform t = getSnapshot({.id = 11})->localTransform.inverse();
+
+ UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
+ EXPECT_EQ(getSnapshot({.id = 11})->roundedCorner.cropRect, t.transform(parentCropRect));
+ EXPECT_EQ(getSnapshot({.id = 11})->roundedCorner.radius.x, RADIUS * t.getScaleX());
+ EXPECT_EQ(getSnapshot({.id = 11})->roundedCorner.radius.y, RADIUS * t.getScaleY());
+ EXPECT_EQ(getSnapshot({.id = 11})->roundedCorner.requestedRadius.x, RADIUS * t.getScaleX());
+ EXPECT_EQ(getSnapshot({.id = 11})->roundedCorner.requestedRadius.y, RADIUS * t.getScaleY());
+}
+
+TEST_F(LayerSnapshotTest, childInheritsParentClientDrawnCornerRadius) {
+ // ROOT
+ // ├── 1 (crop rect set to contain child layers )
+ // │ ├── 11
+ // │ │ └── 111
+
static constexpr float RADIUS = 123.f;
setClientDrawnCornerRadius(1, RADIUS);
@@ -1457,6 +1487,11 @@
}
TEST_F(LayerSnapshotTest, childIgnoreCornerRadiusOverridesParent) {
+ // ROOT
+ // ├── 1 (crop rect set to contain child layers )
+ // │ ├── 11
+ // │ │ └── 111
+
static constexpr float RADIUS = 123.f;
setRoundedCorners(1, RADIUS);