From bb010156f59ca3ad18f0312c7d165ca520ae6793 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 22 Jul 2024 12:03:04 -0700 Subject: [PATCH] [Impeller] ensure fp rounding errors don't cause us to lose a row of pixels when computing text positions. (flutter/engine#54015) Dividing then multipliying can lead to position values like 432.99987 which end up losing a pixel. --- engine/src/flutter/impeller/entity/contents/text_contents.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/impeller/entity/contents/text_contents.cc b/engine/src/flutter/impeller/entity/contents/text_contents.cc index 9090118dc7..6dde4e65b6 100644 --- a/engine/src/flutter/impeller/entity/contents/text_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/text_contents.cc @@ -254,8 +254,9 @@ bool TextContents::Render(const ContentContext& renderer, for (const Point& point : unit_points) { Point position; if (is_translation_scale) { - position = screen_glyph_position + - (basis_transform * point * scaled_bounds.GetSize()); + position = (screen_glyph_position + + (basis_transform * point * scaled_bounds.GetSize())) + .Round(); } else { position = entity_transform * (glyph_position.position + scaled_bounds.GetLeftTop() +