From 37605e8490bef4b64663325800d673741f98c685 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 9 May 2023 17:29:27 -0700 Subject: [PATCH] [Impeller] increase minimum size of alpha glyph atlas --- .../backends/skia/text_render_context_skia.cc | 10 +++++++--- impeller/typographer/typographer_unittests.cc | 4 +--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/impeller/typographer/backends/skia/text_render_context_skia.cc b/impeller/typographer/backends/skia/text_render_context_skia.cc index 886674ea456f8..15334b4237115 100644 --- a/impeller/typographer/backends/skia/text_render_context_skia.cc +++ b/impeller/typographer/backends/skia/text_render_context_skia.cc @@ -135,13 +135,17 @@ namespace { ISize OptimumAtlasSizeForFontGlyphPairs( const FontGlyphPair::Set& pairs, std::vector& glyph_positions, - const std::shared_ptr& atlas_context) { + const std::shared_ptr& atlas_context, + GlyphAtlas::Type type) { static constexpr auto kMinAtlasSize = 8u; + static constexpr auto kMinAlphaBitmapSize = 1024u; static constexpr auto kMaxAtlasSize = 4096u; TRACE_EVENT0("impeller", __FUNCTION__); - ISize current_size(kMinAtlasSize, kMinAtlasSize); + ISize current_size = type == GlyphAtlas::Type::kAlphaBitmap + ? ISize(kMinAlphaBitmapSize, kMinAlphaBitmapSize) + : ISize(kMinAtlasSize, kMinAtlasSize); size_t total_pairs = pairs.size() + 1; do { auto rect_packer = std::shared_ptr( @@ -403,7 +407,7 @@ std::shared_ptr TextRenderContextSkia::CreateGlyphAtlas( // --------------------------------------------------------------------------- auto glyph_atlas = std::make_shared(type); auto atlas_size = OptimumAtlasSizeForFontGlyphPairs( - font_glyph_pairs, glyph_positions, atlas_context); + font_glyph_pairs, glyph_positions, atlas_context, type); atlas_context->UpdateGlyphAtlas(glyph_atlas, atlas_size); if (atlas_size.IsEmpty()) { diff --git a/impeller/typographer/typographer_unittests.cc b/impeller/typographer/typographer_unittests.cc index 31c649fab0d4c..a425612ea8421 100644 --- a/impeller/typographer/typographer_unittests.cc +++ b/impeller/typographer/typographer_unittests.cc @@ -189,9 +189,7 @@ TEST_P(TypographerTest, GlyphAtlasWithLotsOfdUniqueGlyphSize) { atlas->GetTexture()->GetSize().height); } -// TODO(jonahwilliams): Re-enable -// https://github.com/flutter/flutter/issues/122839 -TEST_P(TypographerTest, DISABLED_GlyphAtlasTextureIsRecycledIfUnchanged) { +TEST_P(TypographerTest, GlyphAtlasTextureIsRecycledIfUnchanged) { auto context = TextRenderContext::Create(GetContext()); auto atlas_context = std::make_shared(); ASSERT_TRUE(context && context->IsValid());