[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
This commit is contained in:
Jonah Williams
2024-05-14 18:22:04 -07:00
committed by GitHub
parent 8ea8f2bb5b
commit 3be5ba1920
2 changed files with 4 additions and 9 deletions

View File

@@ -194,16 +194,12 @@ static ISize OptimumAtlasSizeForFontGlyphPairs(
const std::vector<FontGlyphPair>& pairs,
std::vector<Rect>& glyph_positions,
const std::shared_ptr<GlyphAtlasContext>& 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<RectanglePacker>(
@@ -406,7 +402,6 @@ std::shared_ptr<GlyphAtlas> TypographerContextSkia::CreateGlyphAtlas(
font_glyph_pairs, //
glyph_positions, //
atlas_context, //
type, //
context.GetResourceAllocator()->GetMaxTextureSizeSupported() //
);

View File

@@ -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) {