Something went wrong. Try again.
A fork of https://github.com/crosspoint-reader/crosspoint-reader
Something went wrong. Try again.
1.6 kB · 55 lines
C
at master
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556#pragma once
#include <EpdFontFamily.h>
#include <cstdint>#include <map>#include <string>
class FontDecompressor;
class FontCacheManager { public: explicit FontCacheManager(const std::map<int, EpdFontFamily>& fontMap);
void setFontDecompressor(FontDecompressor* d);
void clearCache(); void prewarmCache(int fontId, const char* utf8Text, uint8_t styleMask = 0x0F); void logStats(const char* label = "render"); void resetStats();
// Scan-mode API: called by GfxRenderer::drawText() during scan pass bool isScanning() const; void recordText(const char* text, int fontId, EpdFontFamily::Style style);
// The FontDecompressor pointer, needed by GfxRenderer::getGlyphBitmap() FontDecompressor* getDecompressor() const { return fontDecompressor_; }
// RAII scope for two-pass prewarm pattern class PrewarmScope { public: explicit PrewarmScope(FontCacheManager& manager); ~PrewarmScope(); void endScanAndPrewarm(); PrewarmScope(PrewarmScope&& other) noexcept; PrewarmScope& operator=(PrewarmScope&&) = delete; PrewarmScope(const PrewarmScope&) = delete; PrewarmScope& operator=(const PrewarmScope&) = delete;
private: FontCacheManager* manager_; bool active_ = true; }; PrewarmScope createPrewarmScope();
private: const std::map<int, EpdFontFamily>& fontMap_; FontDecompressor* fontDecompressor_ = nullptr;
enum class ScanMode : uint8_t { None, Scanning }; ScanMode scanMode_ = ScanMode::None; std::string scanText_; uint32_t scanStyleCounts_[4] = {}; int scanFontId_ = -1;};