diff --git a/impeller/typographer/backends/stb/typographer_context_stb.cc b/impeller/typographer/backends/stb/typographer_context_stb.cc index 5669d7eba7837..a3cf14b91837a 100644 --- a/impeller/typographer/backends/stb/typographer_context_stb.cc +++ b/impeller/typographer/backends/stb/typographer_context_stb.cc @@ -160,10 +160,10 @@ static ISize OptimumAtlasSizeForFontGlyphPairs( const std::vector& pairs, std::vector& glyph_positions, const std::shared_ptr& atlas_context, - GlyphAtlas::Type type) { + GlyphAtlas::Type type, + const ISize& max_texture_size) { static constexpr auto kMinAtlasSize = 8u; static constexpr auto kMinAlphaBitmapSize = 1024u; - static constexpr auto kMaxAtlasSize = 2048u; // QNX required 2048 or less. TRACE_EVENT0("impeller", __FUNCTION__); @@ -190,8 +190,8 @@ static ISize OptimumAtlasSizeForFontGlyphPairs( Allocation::NextPowerOfTwoSize(current_size.width + 1), Allocation::NextPowerOfTwoSize(current_size.height + 1)); } - } while (current_size.width <= kMaxAtlasSize && - current_size.height <= kMaxAtlasSize); + } while (current_size.width <= max_texture_size.width && + current_size.height <= max_texture_size.height); return ISize{0, 0}; } @@ -469,7 +469,12 @@ std::shared_ptr TypographerContextSTB::CreateGlyphAtlas( } auto glyph_atlas = std::make_shared(type); auto atlas_size = OptimumAtlasSizeForFontGlyphPairs( - font_glyph_pairs, glyph_positions, atlas_context, type); + font_glyph_pairs, // + glyph_positions, // + atlas_context, // + type, // + context.GetResourceAllocator()->GetMaxTextureSizeSupported() // + ); atlas_context->UpdateGlyphAtlas(glyph_atlas, atlas_size); if (atlas_size.IsEmpty()) {