From 25154333d5181e77e287d814a24a1930a6c7f9c8 Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Tue, 30 May 2023 13:13:36 -0700 Subject: [PATCH] [Impeller] Fixed GlyphAtlasWithLotsOfdUniqueGlyphSize (flutter/engine#42423) fixes https://github.com/flutter/flutter/issues/127715 ## 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] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat --- .../typographer/typographer_unittests.cc | 26 ++++++++++++++----- engine/src/flutter/testing/run_tests.py | 2 -- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/engine/src/flutter/impeller/typographer/typographer_unittests.cc b/engine/src/flutter/impeller/typographer/typographer_unittests.cc index ad18242615..24564dac3f 100644 --- a/engine/src/flutter/impeller/typographer/typographer_unittests.cc +++ b/engine/src/flutter/impeller/typographer/typographer_unittests.cc @@ -165,18 +165,20 @@ TEST_P(TypographerTest, GlyphAtlasWithLotsOfdUniqueGlyphSize) { ASSERT_TRUE(context && context->IsValid()); SkFont sk_font; - auto blob = SkTextBlob::MakeFromString( + const char* test_string = "QWERTYUIOPASDFGHJKLZXCVBNMqewrtyuiopasdfghjklzxcvbnm,.<>[]{};':" "2134567890-=!@#$%^&*()_+" "œ∑´®†¥¨ˆøπ““‘‘åß∂ƒ©˙∆˚¬…æ≈ç√∫˜µ≤≥≥≥≥÷¡™£¢∞§¶•ªº–≠⁄€‹›fifl‡°·‚—±Œ„´‰Á¨Ø∏”’/" - "* Í˝ */¸˛Ç◊ı˜Â¯˘¿", - sk_font); + "* Í˝ */¸˛Ç◊ı˜Â¯˘¿"; + + auto blob = SkTextBlob::MakeFromString(test_string, sk_font); ASSERT_TRUE(blob); TextFrame frame; size_t count = 0; + const int size_count = 8; TextRenderContext::FrameIterator iterator = [&]() -> const TextFrame* { - if (count < 8) { + if (count < size_count) { count++; frame = TextFrameFromTextBlob(blob, 0.6 * count); return &frame; @@ -188,8 +190,20 @@ TEST_P(TypographerTest, GlyphAtlasWithLotsOfdUniqueGlyphSize) { ASSERT_NE(atlas, nullptr); ASSERT_NE(atlas->GetTexture(), nullptr); - ASSERT_EQ(atlas->GetTexture()->GetSize().width * 2, - atlas->GetTexture()->GetSize().height); + std::set unique_glyphs; + std::vector total_glyphs; + atlas->IterateGlyphs([&](const FontGlyphPair& pair, const Rect& rect) { + unique_glyphs.insert(pair.glyph.index); + total_glyphs.push_back(pair.glyph.index); + return true; + }); + + EXPECT_EQ(unique_glyphs.size() * size_count, atlas->GetGlyphCount()); + EXPECT_EQ(total_glyphs.size(), atlas->GetGlyphCount()); + + EXPECT_TRUE(atlas->GetGlyphCount() > 0); + EXPECT_TRUE(atlas->GetTexture()->GetSize().width > 0); + EXPECT_TRUE(atlas->GetTexture()->GetSize().height > 0); } TEST_P(TypographerTest, GlyphAtlasTextureIsRecycledIfUnchanged) { diff --git a/engine/src/flutter/testing/run_tests.py b/engine/src/flutter/testing/run_tests.py index 30a93a0ef2..739f7ae62a 100755 --- a/engine/src/flutter/testing/run_tests.py +++ b/engine/src/flutter/testing/run_tests.py @@ -1201,12 +1201,10 @@ Flutter Wiki page on the subject: https://github.com/flutter/flutter/wiki/Testin 'impeller_unittests', engine_filter, # TODO(https://github.com/flutter/flutter/issues/127714): Remove test exemption. - # TODO(https://github.com/flutter/flutter/issues/127715): Remove test exemption. shuffle_flags + [ '--gtest_filter=-' '*/OpenGLES:' 'Play/TypographerTest.MaybeHasOverlapping/Vulkan:' - 'Play/TypographerTest.GlyphAtlasWithLotsOfdUniqueGlyphSize/Vulkan', ], coverage=args.coverage )