prerender book covers and thumbnails when opening a book for the first time
Moves cover/thumbnail generation from lazy (Home screen, Sleep screen) into each reader activity's onEnter(). On first open, generates all needed BMPs (cover, cover_crop, thumbnails for all theme heights) with a "Preparing book..." progress popup. Subsequent opens skip instantly when files exist. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -57,6 +57,15 @@ void TxtReaderActivity::onEnter() {
|
||||
|
||||
txt->setupCacheDir();
|
||||
|
||||
// Prerender cover on first open so the Sleep screen is instant.
|
||||
// generateCoverBmp() is a no-op if the file already exists, so this only does work once.
|
||||
// TXT has no thumbnail support, so only the sleep screen cover is generated.
|
||||
if (!Storage.exists(txt->getCoverBmpPath().c_str())) {
|
||||
Rect popupRect = GUI.drawPopup(renderer, "Preparing book...");
|
||||
txt->generateCoverBmp();
|
||||
GUI.fillPopupProgress(renderer, popupRect, 100);
|
||||
}
|
||||
|
||||
// Save current txt as last opened file and add to recent books
|
||||
auto filePath = txt->getPath();
|
||||
auto fileName = filePath.substr(filePath.rfind('/') + 1);
|
||||
|
||||
Reference in New Issue
Block a user