Skip to content

Commit eb145ff

Browse files
authored
Update CanRenderTiledTexture unit tests (#173553)
The current version relies on a Skia quirk where leading moveTos defeat the simple shape detection in SkPath::addPath(). Skia is updating its behavior to make shape detection more robust, and that breaks the assertion EXPECT_FALSE(path.IsOval(nullptr)). To address, construct an equivalent circle using four conic verbs, which will not be identified as a simple shape. This preserves all related assertions in the unit test. This unblocks some Skia shape detection improvements.
1 parent cb4dfc0 commit eb145ff

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

engine/src/flutter/impeller/display_list/aiks_dl_basic_unittests.cc

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,17 @@ void CanRenderTiledTexture(AiksTest* aiks_test,
156156

157157
{
158158
// Should not change the image. Tests the Convex short-cut code.
159-
DlPath circle = DlPath::MakeCircle(DlPoint(150, 450), 150);
160159

161-
// Unfortunately, the circle path can be simplified...
162-
EXPECT_TRUE(circle.IsOval(nullptr));
163-
// At least it's convex, though...
164-
EXPECT_TRUE(circle.IsConvex());
165-
166-
// Let's make a copy that doesn't remember that it's just a circle...
167-
DlPathBuilder path_builder;
168-
// This moveTo confuses addPath into appending rather than replacing,
169-
// which prevents it from noticing that it's just a circle...
170-
path_builder.MoveTo({10, 10});
171-
path_builder.AddPath(circle);
172-
DlPath path = path_builder.TakePath();
160+
// To avoid simplification, construct an explicit circle using conics.
161+
constexpr float kConicWeight = 0.707106781f; // sqrt(2)/2
162+
const DlPath path = DlPathBuilder()
163+
.MoveTo({150, 300})
164+
.ConicCurveTo({300, 300}, {300, 450}, kConicWeight)
165+
.ConicCurveTo({300, 600}, {150, 600}, kConicWeight)
166+
.ConicCurveTo({0, 600}, {0, 450}, kConicWeight)
167+
.ConicCurveTo({0, 300}, {150, 300}, kConicWeight)
168+
.Close()
169+
.TakePath();
173170

174171
// Make sure path cannot be simplified...
175172
EXPECT_FALSE(path.IsRect(nullptr));

0 commit comments

Comments
 (0)