| 540 | } |
| 541 | |
| 542 | static void ResetCache(HFontMap font_map, dmGraphics::HContext graphics_context, bool recreate_texture, |
| 543 | uint16_t cell_width, uint16_t cell_height, uint16_t max_ascent) |
| 544 | { |
| 545 | if (font_map->m_IsCacheSizeTooSmall) |
| 546 | { |
| 547 | GetNextCacheSize(font_map, &font_map->m_CacheWidth, &font_map->m_CacheHeight); |
| 548 | font_map->m_IsCacheSizeTooSmall = 0; |
| 549 | } |
| 550 | else |
| 551 | { |
| 552 | font_map->m_CacheWidth = dmMath::Max(font_map->m_CacheWidth, (uint16_t)cell_width); |
| 553 | font_map->m_CacheHeight = dmMath::Max(font_map->m_CacheHeight, (uint16_t)cell_height); |
| 554 | } |
| 555 | |
| 556 | if (!IsPowerOfTwo(font_map->m_CacheWidth)) |
| 557 | font_map->m_CacheWidth = NextPowerOfTwo(font_map->m_CacheWidth); |
| 558 | if (!IsPowerOfTwo(font_map->m_CacheHeight)) |
| 559 | font_map->m_CacheHeight = NextPowerOfTwo(font_map->m_CacheHeight); |
| 560 | |
| 561 | #if defined(__EMSCRIPTEN__) |
| 562 | // Currently the web gpu backend has a bug in the SetTexture mechanism. |
| 563 | // So we recreate the texture for now. |
| 564 | RecreateTexture(font_map, graphics_context, font_map->m_CacheWidth, font_map->m_CacheHeight); |
| 565 | #else |
| 566 | if (recreate_texture) |
| 567 | RecreateTexture(font_map, graphics_context, font_map->m_CacheWidth, font_map->m_CacheHeight); |
| 568 | else |
| 569 | ClearTexture(font_map, font_map->m_CacheWidth, font_map->m_CacheHeight); |
| 570 | #endif |
| 571 | |
| 572 | SetFontMapCacheSize(font_map, cell_width, cell_height, max_ascent); |
| 573 | } |
| 574 | |
| 575 | // Is the font cache too small for the largest glyph? |
| 576 | static bool IsTextureTooSmall(HFontMap font_map) |
no test coverage detected