diff --git a/engine/src/flutter/impeller/aiks/canvas.cc b/engine/src/flutter/impeller/aiks/canvas.cc index 8a7e001a21..1949ad8a40 100644 --- a/engine/src/flutter/impeller/aiks/canvas.cc +++ b/engine/src/flutter/impeller/aiks/canvas.cc @@ -80,6 +80,10 @@ void Canvas::Translate(const Vector3& offset) { Concat(Matrix::MakeTranslation(offset)); } +void Canvas::Scale(const Vector2& scale) { + Concat(Matrix::MakeScale(scale)); +} + void Canvas::Scale(const Vector3& scale) { Concat(Matrix::MakeScale(scale)); } @@ -283,7 +287,7 @@ void Canvas::DrawTextFrame(TextFrame text_frame, Point position, Paint paint) { auto text_contents = std::make_shared(); text_contents->SetTextFrame(std::move(text_frame)); text_contents->SetGlyphAtlas(std::move(lazy_glyph_atlas)); - text_contents->SetColor(paint.color.Premultiply()); + text_contents->SetColor(paint.color); Entity entity; entity.SetTransformation(GetCurrentTransformation() * diff --git a/engine/src/flutter/impeller/aiks/canvas.h b/engine/src/flutter/impeller/aiks/canvas.h index 30eed9b6f0..71486def8e 100644 --- a/engine/src/flutter/impeller/aiks/canvas.h +++ b/engine/src/flutter/impeller/aiks/canvas.h @@ -52,6 +52,8 @@ class Canvas { void Translate(const Vector3& offset); + void Scale(const Vector2& scale); + void Scale(const Vector3& scale); void Skew(Scalar sx, Scalar sy); diff --git a/engine/src/flutter/impeller/entity/contents/text_contents.cc b/engine/src/flutter/impeller/entity/contents/text_contents.cc index 018cebb661..f64957f58f 100644 --- a/engine/src/flutter/impeller/entity/contents/text_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/text_contents.cc @@ -80,7 +80,7 @@ bool TextContents::Render(const ContentContext& renderer, frame_info.atlas_size = Point{static_cast(atlas->GetTexture()->GetSize().width), static_cast(atlas->GetTexture()->GetSize().height)}; - frame_info.text_color = ToVector(color_); + frame_info.text_color = ToVector(color_.Premultiply()); VS::BindFrameInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frame_info)); // Common fragment uniforms for all glyphs. diff --git a/engine/src/flutter/impeller/geometry/geometry_unittests.cc b/engine/src/flutter/impeller/geometry/geometry_unittests.cc index 111dd541a7..705c54c4ca 100644 --- a/engine/src/flutter/impeller/geometry/geometry_unittests.cc +++ b/engine/src/flutter/impeller/geometry/geometry_unittests.cc @@ -37,13 +37,24 @@ TEST(GeometryTest, RotationMatrix) { } TEST(GeometryTest, InvertMultMatrix) { - auto rotation = Matrix::MakeRotationZ(Radians{M_PI_4}); - auto invert = rotation.Invert(); - auto expect = Matrix{0.707, -0.707, 0, 0, // - 0.707, 0.707, 0, 0, // - 0, 0, 1, 0, // - 0, 0, 0, 1}; - ASSERT_MATRIX_NEAR(invert, expect); + { + auto rotation = Matrix::MakeRotationZ(Radians{M_PI_4}); + auto invert = rotation.Invert(); + auto expect = Matrix{0.707, -0.707, 0, 0, // + 0.707, 0.707, 0, 0, // + 0, 0, 1, 0, // + 0, 0, 0, 1}; + ASSERT_MATRIX_NEAR(invert, expect); + } + { + auto scale = Matrix::MakeScale(Vector2{2, 4}); + auto invert = scale.Invert(); + auto expect = Matrix{0.5, 0, 0, 0, // + 0, 0.25, 0, 0, // + 0, 0, 1, 0, // + 0, 0, 0, 1}; + ASSERT_MATRIX_NEAR(invert, expect); + } } TEST(GeometryTest, MutliplicationMatrix) { diff --git a/engine/src/flutter/impeller/geometry/matrix.h b/engine/src/flutter/impeller/geometry/matrix.h index 539ae84ae3..10051467f4 100644 --- a/engine/src/flutter/impeller/geometry/matrix.h +++ b/engine/src/flutter/impeller/geometry/matrix.h @@ -80,6 +80,10 @@ struct Matrix { // clang-format on } + static constexpr Matrix MakeScale(const Vector2& s) { + return MakeScale(Vector3(s.x, s.y, 1.0)); + } + static constexpr Matrix MakeSkew(Scalar sx, Scalar sy) { // clang-format off return Matrix(1.0, sy , 0.0, 0.0,