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

Commit 905222c

Browse files
author
Jonah Williams
authored
[Impeller] Increase minimum size of alpha glyph atlas. (#41880)
Fixes flutter/flutter#122839 Fixes flutter/flutter#126103 Unlike Skia which starts with 2048x2048, I decreased the size of 1024x1024. Now that we'll never switch this to a color bitmap, the memory impact is dramatically lessened.
1 parent 688782f commit 905222c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

impeller/typographer/backends/skia/text_render_context_skia.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,17 @@ namespace {
135135
ISize OptimumAtlasSizeForFontGlyphPairs(
136136
const FontGlyphPair::Set& pairs,
137137
std::vector<Rect>& glyph_positions,
138-
const std::shared_ptr<GlyphAtlasContext>& atlas_context) {
138+
const std::shared_ptr<GlyphAtlasContext>& atlas_context,
139+
GlyphAtlas::Type type) {
139140
static constexpr auto kMinAtlasSize = 8u;
141+
static constexpr auto kMinAlphaBitmapSize = 1024u;
140142
static constexpr auto kMaxAtlasSize = 4096u;
141143

142144
TRACE_EVENT0("impeller", __FUNCTION__);
143145

144-
ISize current_size(kMinAtlasSize, kMinAtlasSize);
146+
ISize current_size = type == GlyphAtlas::Type::kAlphaBitmap
147+
? ISize(kMinAlphaBitmapSize, kMinAlphaBitmapSize)
148+
: ISize(kMinAtlasSize, kMinAtlasSize);
145149
size_t total_pairs = pairs.size() + 1;
146150
do {
147151
auto rect_packer = std::shared_ptr<GrRectanizer>(
@@ -403,7 +407,7 @@ std::shared_ptr<GlyphAtlas> TextRenderContextSkia::CreateGlyphAtlas(
403407
// ---------------------------------------------------------------------------
404408
auto glyph_atlas = std::make_shared<GlyphAtlas>(type);
405409
auto atlas_size = OptimumAtlasSizeForFontGlyphPairs(
406-
font_glyph_pairs, glyph_positions, atlas_context);
410+
font_glyph_pairs, glyph_positions, atlas_context, type);
407411

408412
atlas_context->UpdateGlyphAtlas(glyph_atlas, atlas_size);
409413
if (atlas_size.IsEmpty()) {

impeller/typographer/typographer_unittests.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ TEST_P(TypographerTest, GlyphAtlasWithLotsOfdUniqueGlyphSize) {
189189
atlas->GetTexture()->GetSize().height);
190190
}
191191

192-
// TODO(jonahwilliams): Re-enable
193-
// https://github.com/flutter/flutter/issues/122839
194-
TEST_P(TypographerTest, DISABLED_GlyphAtlasTextureIsRecycledIfUnchanged) {
192+
TEST_P(TypographerTest, GlyphAtlasTextureIsRecycledIfUnchanged) {
195193
auto context = TextRenderContext::Create(GetContext());
196194
auto atlas_context = std::make_shared<GlyphAtlasContext>();
197195
ASSERT_TRUE(context && context->IsValid());

0 commit comments

Comments
 (0)