[Impeller] dont treat non-rects as rects. (flutter/engine#46218)
We were going down this branch for all closed paths, but we should only be taking it for closed paths that are also rectangles.
This commit is contained in:
@@ -1288,6 +1288,28 @@ TEST_P(AiksTest, CanDrawAnOpenPath) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, CanDrawAnOpenPathThatIsntARect) {
|
||||
Canvas canvas;
|
||||
|
||||
// Draw a stroked path that is explicitly closed to verify
|
||||
// It doesn't become a rectangle.
|
||||
PathBuilder builder;
|
||||
builder.MoveTo({50, 50});
|
||||
builder.LineTo({520, 120});
|
||||
builder.LineTo({300, 310});
|
||||
builder.LineTo({100, 50});
|
||||
builder.Close();
|
||||
|
||||
Paint paint;
|
||||
paint.color = Color::Red();
|
||||
paint.style = Paint::Style::kStroke;
|
||||
paint.stroke_width = 10;
|
||||
|
||||
canvas.DrawPath(builder.TakePath(), paint);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
static sk_sp<SkData> OpenFixtureAsSkData(const char* fixture_name) {
|
||||
auto mapping = flutter::testing::OpenFixtureAsMapping(fixture_name);
|
||||
if (!mapping) {
|
||||
|
||||
@@ -851,7 +851,7 @@ void DlDispatcher::drawPath(const SkPath& path) {
|
||||
|
||||
// We can't "optimize" a path into a rectangle if it's open.
|
||||
bool closed;
|
||||
if (path.isRect(&rect, &closed); closed) {
|
||||
if (path.isRect(&rect, &closed) && closed) {
|
||||
canvas_.DrawRect(skia_conversions::ToRect(rect), paint_);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user