MCPcopy Create free account
hub / github.com/defold/defold / ResetCache

Function ResetCache

engine/render/src/render/font/fontmap.cpp:542–573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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)

Callers 1

UpdateCacheTextureFunction · 0.85

Calls 7

GetNextCacheSizeFunction · 0.85
IsPowerOfTwoFunction · 0.85
NextPowerOfTwoFunction · 0.85
RecreateTextureFunction · 0.85
ClearTextureFunction · 0.85
SetFontMapCacheSizeFunction · 0.85
MaxFunction · 0.50

Tested by

no test coverage detected