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

Commit 4e1604f

Browse files
committed
update playground tests to include all modified cases and fix matrix ordering
1 parent 23e60b7 commit 4e1604f

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

impeller/aiks/aiks_unittests.cc

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,23 @@ void CanRenderTiledTexture(AiksTest* aiks_test,
206206
canvas.DrawRect(Rect::MakeXYWH(0, 0, 600, 600), paint);
207207
}
208208

209-
// Should not change the image.
210-
PathBuilder path_builder;
211-
path_builder.AddCircle({150, 150}, 150);
212-
path_builder.AddRoundedRect(Rect::MakeLTRB(300, 300, 600, 600), 10);
213-
paint.style = Paint::Style::kFill;
214-
canvas.DrawPath(path_builder.TakePath(), paint);
209+
{
210+
// Should not change the image.
211+
PathBuilder path_builder;
212+
path_builder.AddCircle({150, 150}, 150);
213+
path_builder.AddRoundedRect(Rect::MakeLTRB(300, 300, 600, 600), 10);
214+
paint.style = Paint::Style::kFill;
215+
canvas.DrawPath(path_builder.TakePath(), paint);
216+
}
217+
218+
{
219+
// Should not change the image. Tests the Convex short-cut code.
220+
PathBuilder path_builder;
221+
path_builder.AddCircle({150, 450}, 150);
222+
path_builder.SetConvexity(Convexity::kConvex);
223+
paint.style = Paint::Style::kFill;
224+
canvas.DrawPath(path_builder.TakePath(), paint);
225+
}
215226

216227
ASSERT_TRUE(aiks_test->OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
217228
}
@@ -3744,6 +3755,29 @@ TEST_P(AiksTest, VerticesGeometryUVPositionData) {
37443755
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
37453756
}
37463757

3758+
// Regression test for https://github.com/flutter/flutter/issues/135441 .
3759+
TEST_P(AiksTest, VerticesGeometryUVPositionDataWithTranslate) {
3760+
Canvas canvas;
3761+
Paint paint;
3762+
auto texture = CreateTextureForFixture("table_mountain_nx.png");
3763+
3764+
paint.color_source = ColorSource::MakeImage(
3765+
texture, Entity::TileMode::kClamp, Entity::TileMode::kClamp, {},
3766+
Matrix::MakeTranslation({100.0, 100.0}));
3767+
3768+
auto vertices = {Point(0, 0), Point(texture->GetSize().width, 0),
3769+
Point(0, texture->GetSize().height)};
3770+
std::vector<uint16_t> indices = {0u, 1u, 2u};
3771+
std::vector<Point> texture_coordinates = {};
3772+
std::vector<Color> vertex_colors = {};
3773+
auto geometry = std::make_shared<VerticesGeometry>(
3774+
vertices, indices, texture_coordinates, vertex_colors,
3775+
Rect::MakeLTRB(0, 0, 1, 1), VerticesGeometry::VertexMode::kTriangleStrip);
3776+
3777+
canvas.DrawVertices(geometry, BlendMode::kSourceOver, paint);
3778+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
3779+
}
3780+
37473781
TEST_P(AiksTest, ClearBlendWithBlur) {
37483782
Canvas canvas;
37493783
Paint white;

impeller/entity/geometry/fill_path_geometry.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ GeometryResult FillPathGeometry::GetPositionUVBuffer(
8383
using VS = TextureFillVertexShader;
8484

8585
auto uv_transform =
86-
effect_transform * texture_coverage.GetNormalizingTransform();
86+
texture_coverage.GetNormalizingTransform() * effect_transform;
8787

8888
if (path_.GetFillType() == FillType::kNonZero && //
8989
path_.IsConvex()) {

impeller/entity/geometry/geometry.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ GeometryResult ComputeUVGeometryForRect(Rect source_rect,
7676
auto& host_buffer = pass.GetTransientsBuffer();
7777

7878
auto uv_transform =
79-
effect_transform * texture_coverage.GetNormalizingTransform();
79+
texture_coverage.GetNormalizingTransform() * effect_transform;
8080
std::vector<Point> data(8);
8181
auto points = source_rect.GetPoints();
8282
for (auto i = 0u, j = 0u; i < 8; i += 2, j++) {

impeller/entity/geometry/vertices_geometry.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ GeometryResult VerticesGeometry::GetPositionUVBuffer(
228228
auto index_count = indices_.size();
229229
auto vertex_count = vertices_.size();
230230
auto uv_transform =
231-
effect_transform * texture_coverage.GetNormalizingTransform();
231+
texture_coverage.GetNormalizingTransform() * effect_transform;
232232
auto has_texture_coordinates = HasTextureCoordinates();
233233
std::vector<VS::PerVertexData> vertex_data(vertex_count);
234234
{

0 commit comments

Comments
 (0)