-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Increased the glyph atlas resolution 2x #162555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Maybe this would be better off as a golden test. |
|
I also wrote a golden test for this. When the test is written this way, gaps of 3 pixels are not seen. This PR however does reduce the number of times the expectation fails though from 16 to 11. So this PR does seem to have a positive effect. namespace {
int32_t CalculateSpaceBetweenUI(const impeller::testing::Screenshot* img) {
const uint32_t* ptr = reinterpret_cast<const uint32_t*>(img->GetBytes());
ptr += img->GetWidth() * static_cast<int32_t>(img->GetHeight() / 2.0);
std::vector<size_t> boundaries;
uint32_t value = *ptr++;
for (size_t i = 1; i < img->GetWidth(); ++i) {
if (((*ptr & 0x00ffffff) != 0) != ((value & 0x00ffffff) != 0)) {
boundaries.push_back(i);
}
value = *ptr++;
}
assert(boundaries.size() == 6);
return boundaries[4] - boundaries[3];
}
} // namespace
TEST_P(DlGoldenTest, MaintainsSpace) {
SetWindowSize(impeller::ISize(1024, 200));
impeller::Scalar font_size = 300;
auto callback = [&](const char* text,
impeller::Scalar scale) -> sk_sp<DisplayList> {
DisplayListBuilder builder;
DlPaint paint;
paint.setColor(DlColor::ARGB(1, 0, 0, 0));
builder.DrawPaint(paint);
builder.Scale(scale, scale);
RenderTextInCanvasSkia(&builder, text, "Roboto-Regular.ttf",
DlPoint::MakeXY(10, 300),
TextRenderOptions{
.font_size = font_size,
});
return builder.Build();
};
std::optional<int32_t> space;
for (int i = 0; i <= 100; ++i) {
Scalar scale = 0.440 + i / 1000.0;
std::unique_ptr<impeller::testing::Screenshot> right =
MakeScreenshot(callback("ui", scale));
right->WriteToPNG("/Users/aaclarke/foo.png");
if (!right) {
GTEST_SKIP() << "making screenshots not supported.";
}
int32_t diff = CalculateSpaceBetweenUI(right.get());
if (space.has_value()) {
EXPECT_TRUE(diff >= *space)
<< "i" << i << " diff:" << diff << " space:" << *space;
}
space = diff;
}
} |
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
autosubmit label was removed for flutter/flutter/162555, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
I'm swapping out the geometry test for a pixel test. This is more accurate and shows the results nicer. Before this change we'd see the gap between glyphs shrink 2 pixels despite the scale increasing. Now we only see it decrease 1 pixel. |
issue: flutter#149652 This makes flutter#149652 better. It doesn't completely it better though, there is still a shrinking of whitespace at larger scales. Without this patch though the test will fail with many 3 pixel jumps between glyphs. I think scaling in the thousands is reasonable so this is an adequate test. ## 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 `///`). - [x] 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
issue: flutter#149652 This makes flutter#149652 better. It doesn't completely it better though, there is still a shrinking of whitespace at larger scales. Without this patch though the test will fail with many 3 pixel jumps between glyphs. I think scaling in the thousands is reasonable so this is an adequate test. ## 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 `///`). - [x] 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 is a cherry-pick for all the changes that went into fixing #149652 It looks like a lot but most of it is testing and refactoring. ## PRs included - #161625 - #162351 - #162415 - #162555 - #162824 ## Impacted Users All users of Impeller. ## Impact Description Animating text with translations and scales can cause: - jitter between glyphs - jitter between glyphs and the baseline - artifacts when rendering glyphs at non integer scales ## Workaround Use skia. ## Risk Since this edits how text is rendered, the risk is pretty high. The actual changes are small and there are unit tests for them. Golden test coverage for cherry-picks is not complete and text rendering golden coverage for android is problematic. ## Test Coverage Yes. ## Validation Steps The reproduction code in #149652 is good.
This is a cherry-pick for all the changes that went into fixing flutter#149652 It looks like a lot but most of it is testing and refactoring. - flutter#161625 - flutter#162351 - flutter#162415 - flutter#162555 - flutter#162824 All users of Impeller. Animating text with translations and scales can cause: - jitter between glyphs - jitter between glyphs and the baseline - artifacts when rendering glyphs at non integer scales Use skia. Since this edits how text is rendered, the risk is pretty high. The actual changes are small and there are unit tests for them. Golden test coverage for cherry-picks is not complete and text rendering golden coverage for android is problematic. Yes. The reproduction code in flutter#149652 is good.
This is a cherry-pick for all the changes that went into fixing flutter/flutter#149652 It looks like a lot but most of it is testing and refactoring. ## PRs included - flutter/flutter#161625 - flutter/flutter#162351 - flutter/flutter#162415 - flutter/flutter#162555 - flutter/flutter#162824 ## Impacted Users All users of Impeller. ## Impact Description Animating text with translations and scales can cause: - jitter between glyphs - jitter between glyphs and the baseline - artifacts when rendering glyphs at non integer scales ## Workaround Use skia. ## Risk Since this edits how text is rendered, the risk is pretty high. The actual changes are small and there are unit tests for them. Golden test coverage for cherry-picks is not complete and text rendering golden coverage for android is problematic. ## Test Coverage Yes. ## Validation Steps The reproduction code in flutter/flutter#149652 is good.
issue: #149652
This makes #149652 better. It doesn't completely it better though, there is still a shrinking of whitespace at larger scales. Without this patch though the test will fail with many 3 pixel jumps between glyphs.
I think scaling in the thousands is reasonable so this is an adequate test.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.