Integrate upstream #1392 by adriancaruana

This commit is contained in:
jpirnay
2026-04-28 10:00:22 +02:00
parent ac96d89f83
commit aa9fae16d9
29 changed files with 3083 additions and 77 deletions
+24 -1
View File
@@ -2,18 +2,35 @@
#include <FontDecompressor.h>
#include <Logging.h>
#include <SdCardFont.h>
#include <cstring>
FontCacheManager::FontCacheManager(const std::map<int, EpdFontFamily>& fontMap) : fontMap_(fontMap) {}
FontCacheManager::FontCacheManager(const std::map<int, EpdFontFamily>& fontMap,
const std::map<int, SdCardFont*>& sdCardFonts)
: fontMap_(fontMap), sdCardFonts_(sdCardFonts) {}
void FontCacheManager::setFontDecompressor(FontDecompressor* d) { fontDecompressor_ = d; }
void FontCacheManager::clearCache() {
if (fontDecompressor_) fontDecompressor_->clearCache();
for (auto& [id, font] : sdCardFonts_) {
font->clearCache();
}
}
void FontCacheManager::prewarmCache(int fontId, const char* utf8Text, uint8_t styleMask) {
// SD card font prewarm path: prewarm all requested styles in one call
auto sdIt = sdCardFonts_.find(fontId);
if (sdIt != sdCardFonts_.end()) {
int missed = sdIt->second->prewarm(utf8Text, styleMask);
if (missed > 0) {
LOG_DBG("FCM", "prewarmCache(SD): %d glyph(s) not found (styleMask=0x%02X)", missed, styleMask);
}
return;
}
// Standard compressed font prewarm path: loop over all requested styles
if (!fontDecompressor_ || fontMap_.count(fontId) == 0) return;
for (uint8_t i = 0; i < 4; i++) {
@@ -30,10 +47,16 @@ void FontCacheManager::prewarmCache(int fontId, const char* utf8Text, uint8_t st
void FontCacheManager::logStats(const char* label) {
if (fontDecompressor_) fontDecompressor_->logStats(label);
for (auto& [id, font] : sdCardFonts_) {
font->logStats(label);
}
}
void FontCacheManager::resetStats() {
if (fontDecompressor_) fontDecompressor_->resetStats();
for (auto& [id, font] : sdCardFonts_) {
font->resetStats();
}
}
bool FontCacheManager::isScanning() const { return scanMode_ == ScanMode::Scanning; }