Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] Fix convex triangulation winding bug for multi-contour paths. #51198

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions impeller/aiks/aiks_path_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -398,5 +398,37 @@ TEST_P(AiksTest, CanRenderClips) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, CanRenderOverlappingMultiContourPath) {
Canvas canvas;

Paint paint;
paint.color = Color::Red();

PathBuilder::RoundingRadii radii;
radii.top_left = {50, 50};
radii.top_right = {50, 50};
radii.bottom_right = {50, 50};
radii.bottom_left = {50, 50};

const Scalar kTriangleHeight = 100;
canvas.Translate(Vector2(200, 200));
// Form a path similar to the Material drop slider value indicator.
auto path =
PathBuilder{}
.MoveTo({0, kTriangleHeight})
.LineTo({-kTriangleHeight / 2.0f, 0})
.LineTo({kTriangleHeight / 2.0f, 0})
.Close()
.AddRoundedRect(
Rect::MakeXYWH(-kTriangleHeight / 2.0f, -kTriangleHeight / 2.0f,
kTriangleHeight, kTriangleHeight),
radii)
.TakePath();

canvas.DrawPath(path, paint);

ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

} // namespace testing
} // namespace impeller
1 change: 1 addition & 0 deletions impeller/tessellator/tessellator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ std::vector<Point> Tessellator::TessellateConvex(const Path& path,
output.emplace_back(output.back());
output.emplace_back(first_point);
output.emplace_back(first_point);
output.emplace_back(first_point);
} else {
output.emplace_back(first_point);
}
Expand Down
4 changes: 2 additions & 2 deletions impeller/tessellator/tessellator_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ TEST(TessellatorTest, TessellateConvex) {
1.0);

std::vector<Point> expected = {{0, 0}, {10, 0}, {0, 10}, {10, 10},
{10, 10}, {20, 20}, {20, 20}, {30, 20},
{20, 30}, {30, 30}};
{10, 10}, {20, 20}, {20, 20}, {20, 20},
{30, 20}, {20, 30}, {30, 30}};
EXPECT_EQ(pts, expected);
}
}
Expand Down
3 changes: 3 additions & 0 deletions testing/impeller_golden_tests_output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ impeller_Play_AiksTest_CanRenderNestedClips_Vulkan.png
impeller_Play_AiksTest_CanRenderOffscreenCheckerboard_Metal.png
impeller_Play_AiksTest_CanRenderOffscreenCheckerboard_OpenGLES.png
impeller_Play_AiksTest_CanRenderOffscreenCheckerboard_Vulkan.png
impeller_Play_AiksTest_CanRenderOverlappingMultiContourPath_Metal.png
impeller_Play_AiksTest_CanRenderOverlappingMultiContourPath_OpenGLES.png
impeller_Play_AiksTest_CanRenderOverlappingMultiContourPath_Vulkan.png
impeller_Play_AiksTest_CanRenderRadialGradientManyColors_Metal.png
impeller_Play_AiksTest_CanRenderRadialGradientManyColors_OpenGLES.png
impeller_Play_AiksTest_CanRenderRadialGradientManyColors_Vulkan.png
Expand Down