Merge branch 'master' into feat-reading-stats

This commit is contained in:
jpirnay
2026-05-21 11:38:59 +02:00
committed by GitHub
16 changed files with 1082 additions and 352 deletions
@@ -348,6 +348,10 @@ void EpubReaderActivity::onExit() {
// no live epub reference and persists the JSON. Sleep paths that bypass
// onExit() still end up here on resume because the activity is recreated.
globalReadingSessionTracker().end();
// If a pre-render left the next page in the frame buffer, redraw the current page so the
// next activity (notably SleepActivity's OVERLAY mode) sees what the user was looking at.
// Must run before section.reset() and the orientation reset below.
restoreCurrentPageToBufferIfPreRendered();
// Save bookmarks before exit
bookmarkStore.save();
@@ -2266,6 +2270,31 @@ void EpubReaderActivity::displayPreRenderedPage(const Page& page, const int orie
}
}
void EpubReaderActivity::restoreCurrentPageToBufferIfPreRendered() {
if (!preRenderedPage.ready || !section || !epub) {
return;
}
int orientedMarginTop, orientedMarginRight, orientedMarginBottom, orientedMarginLeft;
renderer.getOrientedViewableTRBL(&orientedMarginTop, &orientedMarginRight, &orientedMarginBottom,
&orientedMarginLeft);
const int statusBarTopHeight = UITheme::getStatusBarTopHeight(automaticPageTurnActive);
const int statusBarBottomHeight = UITheme::getStatusBarBottomHeight(automaticPageTurnActive);
orientedMarginTop += std::max(static_cast<int>(SETTINGS.screenMargin), statusBarTopHeight);
orientedMarginLeft += SETTINGS.screenMargin;
orientedMarginRight += SETTINGS.screenMargin;
orientedMarginBottom += std::max(static_cast<int>(SETTINGS.screenMargin), statusBarBottomHeight);
auto p = section->loadPageFromSectionFile();
if (!p) {
return;
}
renderPageContentOnly(*p, orientedMarginTop, orientedMarginRight, orientedMarginBottom, orientedMarginLeft);
preRenderedPage.ready = false;
pendingPreRender = false;
usePreRenderedBuffer = false;
}
void EpubReaderActivity::renderStatusBar() const {
// Calculate progress in book
const int currentPage = section->currentPage + 1;