fix: Skip Underline Calculations During Font Cache Scan Pass (#2237)
## Summary This PR optimizes the text rendering process by skipping underline style calculations and measurements during the initial font cache scanning phase. This prevents excessive and unnecessary SD card reads on pages with heavy use of underlines (e.g., Table of Contents pages). ### **The Problem** During the first rendering pass (the font cache scan pass used to collect text for prewarming), `GfxRenderer::drawText()` early-returns after recording text as expected. However, `TextBlock::render()` continued past this point to execute the underline decoration logic. Because underline calculation calls `getTextWidth()` and `getTextAdvanceX()`, it triggered immediate glyph lookups via `EpdFont::getGlyph()`. Since the SD card font had not been prewarmed yet at this stage, the lookups fell back to the `glyphMissHandler`, resulting in hundreds of individual, slow SD card reads into a limited 8-slot ring buffer. ### **The Fix** 1. **Exposed Scan State:** Added `GfxRenderer::isFontCacheScanning()` to safely check if the font cache manager is currently in text-collection/scan mode. 2. **Bypassed Underline Logic:** Modified `TextBlock::render()` to check this state and skip underline measurement and drawing entirely while scanning is active. > [!NOTE] > The text itself is still properly captured for prewarming via `drawText()`. The underlines will be safely and efficiently calculated and drawn during the actual render pass after the fonts have been completely prewarmed. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**< YES >**_
This commit is contained in:
@@ -104,6 +104,7 @@ class GfxRenderer {
|
||||
}
|
||||
void setFontCacheManager(FontCacheManager* m) { fontCacheManager_ = m; }
|
||||
FontCacheManager* getFontCacheManager() const { return fontCacheManager_; }
|
||||
bool isFontCacheScanning() const;
|
||||
const std::map<int, EpdFontFamily>& getFontMap() const { return fontMap; }
|
||||
void registerSdCardFont(int fontId, SdCardFont* font) { sdCardFonts_[fontId] = font; }
|
||||
void unregisterSdCardFont(int fontId) { removeFont(fontId); }
|
||||
|
||||
Reference in New Issue
Block a user