Skip to content

Commit

Permalink
update playground tests to include all modified cases and fix matrix …
Browse files Browse the repository at this point in the history
…ordering
  • Loading branch information
flar committed Nov 8, 2023
1 parent 23e60b7 commit 4e1604f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
46 changes: 40 additions & 6 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,23 @@ void CanRenderTiledTexture(AiksTest* aiks_test,
canvas.DrawRect(Rect::MakeXYWH(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);
{
// 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);
}

{
// Should not change the image. Tests the Convex short-cut code.
PathBuilder path_builder;
path_builder.AddCircle({150, 450}, 150);
path_builder.SetConvexity(Convexity::kConvex);
paint.style = Paint::Style::kFill;
canvas.DrawPath(path_builder.TakePath(), paint);
}

ASSERT_TRUE(aiks_test->OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}
Expand Down Expand Up @@ -3744,6 +3755,29 @@ TEST_P(AiksTest, VerticesGeometryUVPositionData) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

// Regression test for https://github.com/flutter/flutter/issues/135441 .
TEST_P(AiksTest, VerticesGeometryUVPositionDataWithTranslate) {
Canvas canvas;
Paint paint;
auto texture = CreateTextureForFixture("table_mountain_nx.png");

paint.color_source = ColorSource::MakeImage(
texture, Entity::TileMode::kClamp, Entity::TileMode::kClamp, {},
Matrix::MakeTranslation({100.0, 100.0}));

auto vertices = {Point(0, 0), Point(texture->GetSize().width, 0),
Point(0, texture->GetSize().height)};
std::vector<uint16_t> indices = {0u, 1u, 2u};
std::vector<Point> texture_coordinates = {};
std::vector<Color> vertex_colors = {};
auto geometry = std::make_shared<VerticesGeometry>(
vertices, indices, texture_coordinates, vertex_colors,
Rect::MakeLTRB(0, 0, 1, 1), VerticesGeometry::VertexMode::kTriangleStrip);

canvas.DrawVertices(geometry, BlendMode::kSourceOver, paint);
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, ClearBlendWithBlur) {
Canvas canvas;
Paint white;
Expand Down
2 changes: 1 addition & 1 deletion impeller/entity/geometry/fill_path_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ GeometryResult FillPathGeometry::GetPositionUVBuffer(
using VS = TextureFillVertexShader;

auto uv_transform =
effect_transform * texture_coverage.GetNormalizingTransform();
texture_coverage.GetNormalizingTransform() * effect_transform;

if (path_.GetFillType() == FillType::kNonZero && //
path_.IsConvex()) {
Expand Down
2 changes: 1 addition & 1 deletion impeller/entity/geometry/geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ GeometryResult ComputeUVGeometryForRect(Rect source_rect,
auto& host_buffer = pass.GetTransientsBuffer();

auto uv_transform =
effect_transform * texture_coverage.GetNormalizingTransform();
texture_coverage.GetNormalizingTransform() * effect_transform;
std::vector<Point> data(8);
auto points = source_rect.GetPoints();
for (auto i = 0u, j = 0u; i < 8; i += 2, j++) {
Expand Down
2 changes: 1 addition & 1 deletion impeller/entity/geometry/vertices_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ GeometryResult VerticesGeometry::GetPositionUVBuffer(
auto index_count = indices_.size();
auto vertex_count = vertices_.size();
auto uv_transform =
effect_transform * texture_coverage.GetNormalizingTransform();
texture_coverage.GetNormalizingTransform() * effect_transform;
auto has_texture_coordinates = HasTextureCoordinates();
std::vector<VS::PerVertexData> vertex_data(vertex_count);
{
Expand Down

0 comments on commit 4e1604f

Please sign in to comment.