diff --git a/engine/src/flutter/impeller/aiks/aiks_unittests.cc b/engine/src/flutter/impeller/aiks/aiks_unittests.cc index ded5012878..caa3372e93 100644 --- a/engine/src/flutter/impeller/aiks/aiks_unittests.cc +++ b/engine/src/flutter/impeller/aiks/aiks_unittests.cc @@ -3559,5 +3559,27 @@ TEST_P(AiksTest, ReleasesTextureOnTeardown) { "released."; } +// Regression test for https://github.com/flutter/flutter/issues/135441 . +TEST_P(AiksTest, VerticesGeometryUVPositionData) { + Canvas canvas; + Paint paint; + auto texture = CreateTextureForFixture("table_mountain_nx.png"); + + paint.color_source = ColorSource::MakeImage(texture, Entity::TileMode::kClamp, + Entity::TileMode::kClamp, {}, {}); + + auto vertices = {Point(0, 0), Point(texture->GetSize().width, 0), + Point(0, texture->GetSize().height)}; + std::vector indices = {0u, 1u, 2u}; + std::vector texture_coordinates = {}; + std::vector vertex_colors = {}; + auto geometry = std::make_shared( + 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())); +} + } // namespace testing } // namespace impeller diff --git a/engine/src/flutter/impeller/entity/geometry/vertices_geometry.cc b/engine/src/flutter/impeller/entity/geometry/vertices_geometry.cc index 8c1a0c0d54..23a1c32a5f 100644 --- a/engine/src/flutter/impeller/entity/geometry/vertices_geometry.cc +++ b/engine/src/flutter/impeller/entity/geometry/vertices_geometry.cc @@ -229,11 +229,13 @@ GeometryResult VerticesGeometry::GetPositionUVBuffer( auto vertex_count = vertices_.size(); auto size = texture_coverage.size; auto origin = texture_coverage.origin; + auto has_texture_coordinates = HasTextureCoordinates(); std::vector vertex_data(vertex_count); { for (auto i = 0u; i < vertex_count; i++) { auto vertex = vertices_[i]; - auto texture_coord = texture_coordinates_[i]; + auto texture_coord = + has_texture_coordinates ? texture_coordinates_[i] : vertices_[i]; auto uv = effect_transform * Point((texture_coord.x - origin.x) / size.width, (texture_coord.y - origin.y) / size.height);