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
14591489TEST_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