[Impeller] Use Matrix::MakeTranslateScale to compute the source-to-destination mapping in DrawImageRect (flutter/engine#56433)

This commit is contained in:
Jason Simmons
2024-11-07 12:41:16 -08:00
committed by GitHub
parent 995852f467
commit 73f6b6562a

View File

@@ -692,12 +692,7 @@ void Canvas::DrawImageRect(const std::shared_ptr<Texture>& image,
Scalar sy = dest.GetHeight() / source.GetHeight();
Scalar tx = dest.GetLeft() - source.GetLeft() * sx;
Scalar ty = dest.GetTop() - source.GetTop() * sy;
// clang-format off
Matrix src_to_dest( sx, 0.0f, 0.0f, 0.0f,
0.0f, sy, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
tx, ty, 0.0f, 1.0f);
// clang-format on
Matrix src_to_dest = Matrix::MakeTranslateScale({sx, sy, 1}, {tx, ty, 0});
dest = clipped_source->TransformBounds(src_to_dest);
}