Skip to content

Commit 0c9866a

Browse files
Treehugger RobotAndroid (Google) Code Review
authored andcommitted
Merge "Rounded corner: fix layer settings when inherited from parent settings" into main
2 parents 9636fa2 + e929567 commit 0c9866a

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,8 @@ void LayerSnapshotBuilder::updateRoundedCorner(LayerSnapshot& snapshot,
982982
parentRoundedCorner.cropRect = t.transform(parentRoundedCorner.cropRect);
983983
parentRoundedCorner.radius.x *= t.getScaleX();
984984
parentRoundedCorner.radius.y *= t.getScaleY();
985+
parentRoundedCorner.requestedRadius.x *= t.getScaleX();
986+
parentRoundedCorner.requestedRadius.y *= t.getScaleY();
985987
}
986988

987989
FloatRect layerCropRect = snapshot.croppedBufferSize;

services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "ui/GraphicTypes.h"
2929

3030
#include <com_android_graphics_libgui_flags.h>
31+
#include <cmath>
3132

3233
#define UPDATE_AND_VERIFY(BUILDER, ...) \
3334
({ \
@@ -1443,7 +1444,36 @@ TEST_F(LayerSnapshotTest, ignoreCornerRadius) {
14431444
EXPECT_EQ(getSnapshot({.id = 1})->roundedCorner.radius.x, 0.f);
14441445
}
14451446

1446-
TEST_F(LayerSnapshotTest, childInheritsParentIntendedCornerRadius) {
1447+
TEST_F(LayerSnapshotTest, childInheritsParentScaledSettings) {
1448+
// ROOT
1449+
// ├── 1 (crop rect set to contain child layer)
1450+
// │ ├── 11
1451+
static constexpr float RADIUS = 123.f;
1452+
1453+
setRoundedCorners(1, RADIUS);
1454+
FloatRect parentCropRect(1, 1, 999, 999);
1455+
setCrop(1, parentCropRect);
1456+
// Rotate surface by 90
1457+
setMatrix(11, 0.f, -1.f, 1.f, 0.f);
1458+
1459+
UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
1460+
1461+
ui::Transform t = getSnapshot({.id = 11})->localTransform.inverse();
1462+
1463+
UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
1464+
EXPECT_EQ(getSnapshot({.id = 11})->roundedCorner.cropRect, t.transform(parentCropRect));
1465+
EXPECT_EQ(getSnapshot({.id = 11})->roundedCorner.radius.x, RADIUS * t.getScaleX());
1466+
EXPECT_EQ(getSnapshot({.id = 11})->roundedCorner.radius.y, RADIUS * t.getScaleY());
1467+
EXPECT_EQ(getSnapshot({.id = 11})->roundedCorner.requestedRadius.x, RADIUS * t.getScaleX());
1468+
EXPECT_EQ(getSnapshot({.id = 11})->roundedCorner.requestedRadius.y, RADIUS * t.getScaleY());
1469+
}
1470+
1471+
TEST_F(LayerSnapshotTest, childInheritsParentClientDrawnCornerRadius) {
1472+
// ROOT
1473+
// ├── 1 (crop rect set to contain child layers )
1474+
// │ ├── 11
1475+
// │ │ └── 111
1476+
14471477
static constexpr float RADIUS = 123.f;
14481478

14491479
setClientDrawnCornerRadius(1, RADIUS);
@@ -1457,6 +1487,11 @@ TEST_F(LayerSnapshotTest, childInheritsParentIntendedCornerRadius) {
14571487
}
14581488

14591489
TEST_F(LayerSnapshotTest, childIgnoreCornerRadiusOverridesParent) {
1490+
// ROOT
1491+
// ├── 1 (crop rect set to contain child layers )
1492+
// │ ├── 11
1493+
// │ │ └── 111
1494+
14601495
static constexpr float RADIUS = 123.f;
14611496

14621497
setRoundedCorners(1, RADIUS);

0 commit comments

Comments
 (0)