381 TRACE_EVENT0(
"impeller", __FUNCTION__);
386 std::shared_ptr<GlyphAtlas> last_atlas = atlas_context->GetGlyphAtlas();
388 if (font_glyph_map.empty()) {
396 std::vector<FontGlyphPair> new_glyphs;
397 for (
const auto& font_value : font_glyph_map) {
398 const ScaledFont& scaled_font = font_value.first;
399 const FontGlyphAtlas* font_glyph_atlas =
400 last_atlas->GetFontGlyphAtlas(scaled_font.font, scaled_font.scale);
401 if (font_glyph_atlas) {
402 for (
const Glyph& glyph : font_value.second) {
403 if (!font_glyph_atlas->FindGlyphBounds(glyph)) {
404 new_glyphs.emplace_back(scaled_font, glyph);
408 for (
const Glyph& glyph : font_value.second) {
409 new_glyphs.emplace_back(scaled_font, glyph);
413 if (last_atlas->GetType() == type && new_glyphs.size() == 0) {
422 std::vector<Rect> glyph_positions;
423 if (last_atlas->GetType() == type &&
425 atlas_context->GetAtlasSize(),
426 atlas_context->GetRectPacker())) {
434 for (
size_t i = 0, count = glyph_positions.size(); i < count; i++) {
435 last_atlas->AddTypefaceGlyphPosition(new_glyphs[i], glyph_positions[i]);
442 auto bitmap = atlas_context_stb.GetBitmap();
460 std::vector<FontGlyphPair> font_glyph_pairs;
461 font_glyph_pairs.reserve(std::accumulate(
462 font_glyph_map.begin(), font_glyph_map.end(), 0,
463 [](
const int a,
const auto& b) { return a + b.second.size(); }));
464 for (
const auto& font_value : font_glyph_map) {
465 const ScaledFont& scaled_font = font_value.first;
466 for (
const Glyph& glyph : font_value.second) {
467 font_glyph_pairs.push_back({scaled_font, glyph});
470 auto glyph_atlas = std::make_shared<GlyphAtlas>(type);
476 context.GetResourceAllocator()->GetMaxTextureSizeSupported()
479 atlas_context->UpdateGlyphAtlas(glyph_atlas, atlas_size);
480 if (atlas_size.IsEmpty()) {
490 if (glyph_positions.size() != font_glyph_pairs.size()) {
499 for (
auto it = font_glyph_pairs.begin(); it != font_glyph_pairs.end();
501 glyph_atlas->AddTypefaceGlyphPosition(*it, glyph_positions[i]);
512 atlas_context_stb.UpdateBitmap(bitmap);
536 glyph_atlas->SetTexture(std::move(texture));