| 439 | } |
| 440 | |
| 441 | void AddGlyphByIndex(dmRender::HFontMap font_map, HFont font, uint32_t glyph_index, FontGlyph* glyph) |
| 442 | { |
| 443 | DM_MUTEX_SCOPED_LOCK(font_map->m_Mutex); |
| 444 | |
| 445 | uint64_t key = MakeGlyphIndexKey(font, glyph_index); |
| 446 | FontGlyph** pglyph = font_map->m_Glyphs.Get(key); |
| 447 | if (pglyph) |
| 448 | { |
| 449 | FontFreeGlyph(font, *pglyph); |
| 450 | delete *pglyph; |
| 451 | } |
| 452 | |
| 453 | if (font_map->m_Glyphs.Full()) |
| 454 | font_map->m_Glyphs.OffsetCapacity(16); |
| 455 | |
| 456 | font_map->m_Glyphs.Put(key, glyph); |
| 457 | |
| 458 | |
| 459 | uint16_t prev_width, prev_height, prev_ascent; |
| 460 | dmRender::GetFontMapCacheSize(font_map, &prev_width, &prev_height, &prev_ascent); |
| 461 | |
| 462 | uint16_t bitmap_width = (uint16_t)glyph->m_Bitmap.m_Width; |
| 463 | uint16_t bitmap_height = (uint16_t)glyph->m_Bitmap.m_Height; |
| 464 | uint16_t ascent = (uint16_t)glyph->m_Ascent; |
| 465 | bool dirty = bitmap_width > prev_width || |
| 466 | bitmap_height > prev_height || |
| 467 | ascent > prev_ascent; |
| 468 | if (dirty) |
| 469 | { |
| 470 | font_map->m_CacheCellWidth = dmMath::Max(bitmap_width, prev_width); |
| 471 | font_map->m_CacheCellHeight = dmMath::Max(bitmap_height, prev_height); |
| 472 | font_map->m_CacheCellMaxAscent = dmMath::Max(ascent, prev_ascent); |
| 473 | dmRender::SetFontMapCacheSize(font_map, font_map->m_CacheCellWidth, font_map->m_CacheCellHeight, font_map->m_CacheCellMaxAscent); |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | void RemoveGlyphByIndex(dmRender::HFontMap font_map, HFont font, uint32_t glyph_index) |
| 478 | { |
no test coverage detected