Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit bf1c6da

Browse files
author
Jonah Williams
authored
[Impeller] make default glyph atlas size much bigger. (#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 flutter/flutter#138798 Requires #52746
1 parent d35a1a6 commit bf1c6da

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

impeller/typographer/backends/skia/typographer_context_skia.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,12 @@ static ISize OptimumAtlasSizeForFontGlyphPairs(
194194
const std::vector<FontGlyphPair>& pairs,
195195
std::vector<Rect>& glyph_positions,
196196
const std::shared_ptr<GlyphAtlasContext>& atlas_context,
197-
GlyphAtlas::Type type,
198197
const ISize& max_texture_size) {
199-
static constexpr auto kMinAtlasSize = 8u;
200-
static constexpr auto kMinAlphaBitmapSize = 1024u;
198+
static constexpr ISize kMinAtlasSize = ISize{4096, 1024};
201199

202200
TRACE_EVENT0("impeller", __FUNCTION__);
203201

204-
ISize current_size = type == GlyphAtlas::Type::kAlphaBitmap
205-
? ISize(kMinAlphaBitmapSize, kMinAlphaBitmapSize)
206-
: ISize(kMinAtlasSize, kMinAtlasSize);
202+
ISize current_size = kMinAtlasSize;
207203
size_t total_pairs = pairs.size() + 1;
208204
do {
209205
auto rect_packer = std::shared_ptr<RectanglePacker>(
@@ -406,7 +402,6 @@ std::shared_ptr<GlyphAtlas> TypographerContextSkia::CreateGlyphAtlas(
406402
font_glyph_pairs, //
407403
glyph_positions, //
408404
atlas_context, //
409-
type, //
410405
context.GetResourceAllocator()->GetMaxTextureSizeSupported() //
411406
);
412407

impeller/typographer/typographer_unittests.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ TEST_P(TypographerTest, GlyphAtlasWithOddUniqueGlyphSize) {
151151
ASSERT_NE(atlas, nullptr);
152152
ASSERT_NE(atlas->GetTexture(), nullptr);
153153

154-
ASSERT_EQ(atlas->GetTexture()->GetSize().width,
155-
atlas->GetTexture()->GetSize().height);
154+
EXPECT_EQ(atlas->GetTexture()->GetSize().width, 4096u);
155+
EXPECT_EQ(atlas->GetTexture()->GetSize().height, 1024u);
156156
}
157157

158158
TEST_P(TypographerTest, GlyphAtlasIsRecycledIfUnchanged) {

0 commit comments

Comments
 (0)