Tweaked TextContents math to avoid floating point errors (#162480)
This gets rid of artifacts in characters. ## before  ## after  ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
parent
3dc4e01670
commit
f949d8eaed
@ -155,6 +155,28 @@ TEST_P(AiksTest, CanRenderTextFrameWithHalfScaling) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
// This is a test that looks for glyph artifacts we've see.
|
||||
TEST_P(AiksTest, ScaledK) {
|
||||
DisplayListBuilder builder;
|
||||
DlPaint paint;
|
||||
paint.setColor(DlColor::ARGB(1, 0.1, 0.1, 0.1));
|
||||
builder.DrawPaint(paint);
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
builder.Save();
|
||||
builder.Translate(300 * i, 0);
|
||||
Scalar scale = 0.445 - (i / 1000.f);
|
||||
builder.Scale(scale, scale);
|
||||
RenderTextInCanvasSkia(
|
||||
GetContext(), builder, "k", "Roboto-Regular.ttf",
|
||||
TextRenderOptions{.font_size = 600, .position = DlPoint(10, 500)});
|
||||
RenderTextInCanvasSkia(
|
||||
GetContext(), builder, "k", "Roboto-Regular.ttf",
|
||||
TextRenderOptions{.font_size = 300, .position = DlPoint(10, 800)});
|
||||
builder.Restore();
|
||||
}
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, CanRenderTextFrameWithFractionScaling) {
|
||||
Scalar fine_scale = 0.f;
|
||||
bool is_subpixel = false;
|
||||
|
@ -187,7 +187,9 @@ void TextContents::ComputeVertexData(
|
||||
Point position;
|
||||
if (is_translation_scale) {
|
||||
position = (screen_glyph_position +
|
||||
(basis_transform * point * scaled_bounds.GetSize()))
|
||||
((basis_transform.m[0] < 0 ? Matrix::MakeScale({-1, 1, 1})
|
||||
: Matrix()) *
|
||||
point * glyph_bounds.GetSize()))
|
||||
.Round();
|
||||
} else {
|
||||
position = entity_transform *
|
||||
|
@ -880,6 +880,9 @@ impeller_Play_AiksTest_SaveLayerDrawsBehindSubsequentEntities_Vulkan.png
|
||||
impeller_Play_AiksTest_SaveLayerFiltersScaleWithTransform_Metal.png
|
||||
impeller_Play_AiksTest_SaveLayerFiltersScaleWithTransform_OpenGLES.png
|
||||
impeller_Play_AiksTest_SaveLayerFiltersScaleWithTransform_Vulkan.png
|
||||
impeller_Play_AiksTest_ScaledK_Metal.png
|
||||
impeller_Play_AiksTest_ScaledK_OpenGLES.png
|
||||
impeller_Play_AiksTest_ScaledK_Vulkan.png
|
||||
impeller_Play_AiksTest_SetContentsWithRegion_Metal.png
|
||||
impeller_Play_AiksTest_SetContentsWithRegion_OpenGLES.png
|
||||
impeller_Play_AiksTest_SetContentsWithRegion_Vulkan.png
|
||||
|
Loading…
x
Reference in New Issue
Block a user