322 TRACE_EVENT0(
"impeller", __FUNCTION__);
327 std::shared_ptr<GlyphAtlas> last_atlas = atlas_context->GetGlyphAtlas();
329 if (font_glyph_map.empty()) {
337 std::vector<FontGlyphPair> new_glyphs;
338 for (
const auto& font_value : font_glyph_map) {
339 const ScaledFont& scaled_font = font_value.first;
340 const FontGlyphAtlas* font_glyph_atlas =
341 last_atlas->GetFontGlyphAtlas(scaled_font.font, scaled_font.scale);
342 if (font_glyph_atlas) {
343 for (
const Glyph& glyph : font_value.second) {
344 if (!font_glyph_atlas->FindGlyphBounds(glyph)) {
345 new_glyphs.emplace_back(scaled_font, glyph);
349 for (
const Glyph& glyph : font_value.second) {
350 new_glyphs.emplace_back(scaled_font, glyph);
354 if (last_atlas->GetType() == type && new_glyphs.size() == 0) {
363 std::vector<Rect> glyph_positions;
364 if (last_atlas->GetType() == type &&
366 atlas_context->GetAtlasSize(),
367 atlas_context->GetRectPacker())) {
375 for (
size_t i = 0, count = glyph_positions.size(); i < count; i++) {
376 last_atlas->AddTypefaceGlyphPosition(new_glyphs[i], glyph_positions[i]);
382 auto bitmap = atlas_context_skia.GetBitmap();
400 std::vector<FontGlyphPair> font_glyph_pairs;
401 font_glyph_pairs.reserve(std::accumulate(
402 font_glyph_map.begin(), font_glyph_map.end(), 0,
403 [](
const int a,
const auto&
b) { return a + b.second.size(); }));
404 for (
const auto& font_value : font_glyph_map) {
405 const ScaledFont& scaled_font = font_value.first;
406 for (
const Glyph& glyph : font_value.second) {
407 font_glyph_pairs.push_back({scaled_font, glyph});
410 auto glyph_atlas = std::make_shared<GlyphAtlas>(type);
416 context.GetResourceAllocator()->GetMaxTextureSizeSupported()
419 atlas_context->UpdateGlyphAtlas(glyph_atlas, atlas_size);
420 if (atlas_size.IsEmpty()) {
429 if (glyph_positions.size() != font_glyph_pairs.size()) {
438 for (
auto it = font_glyph_pairs.begin(); it != font_glyph_pairs.end();
440 glyph_atlas->AddTypefaceGlyphPosition(*it, glyph_positions[i]);
451 atlas_context_skia.UpdateBitmap(bitmap);
459 format = context.GetCapabilities()->GetDefaultGlyphAtlasFormat();
474 glyph_atlas->SetTexture(std::move(texture));