Skip to content

Commit 64705ac

Browse files
authored
[Impeller] Fix STB backend to account for max texture sizes. (flutter#46010)
Gets rid of the hardcoded 2048 px size. Followup from review comment left unaddressed in flutter-team-archive/engine#45992. Missing this will be less easy after flutter#133029.
1 parent 3303a3e commit 64705ac

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎impeller/typographer/backends/stb/typographer_context_stb.cc‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ static ISize OptimumAtlasSizeForFontGlyphPairs(
160160
const std::vector<FontGlyphPair>& pairs,
161161
std::vector<Rect>& glyph_positions,
162162
const std::shared_ptr<GlyphAtlasContext>& atlas_context,
163-
GlyphAtlas::Type type) {
163+
GlyphAtlas::Type type,
164+
const ISize& max_texture_size) {
164165
static constexpr auto kMinAtlasSize = 8u;
165166
static constexpr auto kMinAlphaBitmapSize = 1024u;
166-
static constexpr auto kMaxAtlasSize = 2048u; // QNX required 2048 or less.
167167

168168
TRACE_EVENT0("impeller", __FUNCTION__);
169169

@@ -190,8 +190,8 @@ static ISize OptimumAtlasSizeForFontGlyphPairs(
190190
Allocation::NextPowerOfTwoSize(current_size.width + 1),
191191
Allocation::NextPowerOfTwoSize(current_size.height + 1));
192192
}
193-
} while (current_size.width <= kMaxAtlasSize &&
194-
current_size.height <= kMaxAtlasSize);
193+
} while (current_size.width <= max_texture_size.width &&
194+
current_size.height <= max_texture_size.height);
195195
return ISize{0, 0};
196196
}
197197

@@ -469,7 +469,12 @@ std::shared_ptr<GlyphAtlas> TypographerContextSTB::CreateGlyphAtlas(
469469
}
470470
auto glyph_atlas = std::make_shared<GlyphAtlas>(type);
471471
auto atlas_size = OptimumAtlasSizeForFontGlyphPairs(
472-
font_glyph_pairs, glyph_positions, atlas_context, type);
472+
font_glyph_pairs, //
473+
glyph_positions, //
474+
atlas_context, //
475+
type, //
476+
context.GetResourceAllocator()->GetMaxTextureSizeSupported() //
477+
);
473478

474479
atlas_context->UpdateGlyphAtlas(glyph_atlas, atlas_size);
475480
if (atlas_size.IsEmpty()) {

0 commit comments

Comments
 (0)