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

Commit 0c9866a6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Rounded corner: fix layer settings when inherited from parent settings" into main

parents 9636fa28 e9295679
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -982,6 +982,8 @@ void LayerSnapshotBuilder::updateRoundedCorner(LayerSnapshot& snapshot,
        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;
+36 −1
Original line number Diff line number Diff line
@@ -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 @@ TEST_F(LayerSnapshotTest, ignoreCornerRadius) {
    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, childInheritsParentIntendedCornerRadius) {
}

TEST_F(LayerSnapshotTest, childIgnoreCornerRadiusOverridesParent) {
    // ROOT
    // ├── 1 (crop rect set to contain child layers )
    // │   ├── 11
    // │   │   └── 111

    static constexpr float RADIUS = 123.f;

    setRoundedCorners(1, RADIUS);