From 3be5ba19207c1115034dae5c1adf936a2ee8751a Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Tue, 14 May 2024 18:22:04 -0700 Subject: [PATCH] [Impeller] make default glyph atlas size much bigger. (flutter/engine#52787) Now that we no longer have a full CPU copy of the glyph atlas, it should be cheaper to make a larger initial atlas to reduce churn from resizing seen in applications like https://github.com/flutter/flutter/issues/138798 Requires https://github.com/flutter/engine/pull/52746 --- .../backends/skia/typographer_context_skia.cc | 9 ++------- .../impeller/typographer/typographer_unittests.cc | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/engine/src/flutter/impeller/typographer/backends/skia/typographer_context_skia.cc b/engine/src/flutter/impeller/typographer/backends/skia/typographer_context_skia.cc index ff258c9394..3357b6e026 100644 --- a/engine/src/flutter/impeller/typographer/backends/skia/typographer_context_skia.cc +++ b/engine/src/flutter/impeller/typographer/backends/skia/typographer_context_skia.cc @@ -194,16 +194,12 @@ static ISize OptimumAtlasSizeForFontGlyphPairs( const std::vector& pairs, std::vector& glyph_positions, const std::shared_ptr& atlas_context, - GlyphAtlas::Type type, const ISize& max_texture_size) { - static constexpr auto kMinAtlasSize = 8u; - static constexpr auto kMinAlphaBitmapSize = 1024u; + static constexpr ISize kMinAtlasSize = ISize{4096, 1024}; TRACE_EVENT0("impeller", __FUNCTION__); - ISize current_size = type == GlyphAtlas::Type::kAlphaBitmap - ? ISize(kMinAlphaBitmapSize, kMinAlphaBitmapSize) - : ISize(kMinAtlasSize, kMinAtlasSize); + ISize current_size = kMinAtlasSize; size_t total_pairs = pairs.size() + 1; do { auto rect_packer = std::shared_ptr( @@ -406,7 +402,6 @@ std::shared_ptr TypographerContextSkia::CreateGlyphAtlas( font_glyph_pairs, // glyph_positions, // atlas_context, // - type, // context.GetResourceAllocator()->GetMaxTextureSizeSupported() // ); diff --git a/engine/src/flutter/impeller/typographer/typographer_unittests.cc b/engine/src/flutter/impeller/typographer/typographer_unittests.cc index e28877d0b8..1b5003982d 100644 --- a/engine/src/flutter/impeller/typographer/typographer_unittests.cc +++ b/engine/src/flutter/impeller/typographer/typographer_unittests.cc @@ -151,8 +151,8 @@ TEST_P(TypographerTest, GlyphAtlasWithOddUniqueGlyphSize) { ASSERT_NE(atlas, nullptr); ASSERT_NE(atlas->GetTexture(), nullptr); - ASSERT_EQ(atlas->GetTexture()->GetSize().width, - atlas->GetTexture()->GetSize().height); + EXPECT_EQ(atlas->GetTexture()->GetSize().width, 4096u); + EXPECT_EQ(atlas->GetTexture()->GetSize().height, 1024u); } TEST_P(TypographerTest, GlyphAtlasIsRecycledIfUnchanged) {