[Impeller] Fix the issue that 'coverage_coords' is incorrectly calculated in 'FillPathGeometry::GetPositionUVBuffer' (flutter/engine#42155)

fix https://github.com/flutter/flutter/issues/127183

## without patch
![3Q7pxQTjei](https://github.com/flutter/engine/assets/31977171/5d7ce98a-afef-4d42-96a4-b3524345e69a)
## whti patch
![LRG6o1t9mm](https://github.com/flutter/engine/assets/31977171/66c9c3f9-762c-4dc8-b10b-cde179a7bbc4)
This commit is contained in:
ColdPaleLight
2023-05-20 07:45:22 +08:00
committed by GitHub
parent dcfd92f566
commit 026967383a
2 changed files with 9 additions and 4 deletions

View File

@@ -172,6 +172,13 @@ void CanRenderTiledTexture(AiksTest* aiks_test, Entity::TileMode tile_mode) {
canvas.DrawRect({0, 0, 600, 600}, paint);
}
// Should not change the image.
PathBuilder path_builder;
path_builder.AddCircle({150, 150}, 150);
path_builder.AddRoundedRect(Rect::MakeLTRB(300, 300, 600, 600), 10);
paint.style = Paint::Style::kFill;
canvas.DrawPath(path_builder.TakePath(), paint);
ASSERT_TRUE(aiks_test->OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}
} // namespace

View File

@@ -207,8 +207,7 @@ GeometryResult FillPathGeometry::GetPositionUVBuffer(
VS::PerVertexData data;
data.position = points[i];
auto coverage_coords =
((points[i] - texture_coverage.origin) / texture_coverage.size) /
texture_coverage.size;
(points[i] - texture_coverage.origin) / texture_coverage.size;
data.texture_coords = effect_transform * coverage_coords;
vertex_builder.AppendVertex(data);
}
@@ -238,8 +237,7 @@ GeometryResult FillPathGeometry::GetPositionUVBuffer(
Point vtx = {vertices[i], vertices[i + 1]};
data.position = vtx;
auto coverage_coords =
((vtx - texture_coverage.origin) / texture_coverage.size) /
texture_coverage.size;
(vtx - texture_coverage.origin) / texture_coverage.size;
data.texture_coords = effect_transform * coverage_coords;
vertex_builder.AppendVertex(data);
}