From eceffaa289c022818ed526ef89253e2a977fa361 Mon Sep 17 00:00:00 2001 From: Dave Allie Date: Sat, 6 Dec 2025 22:12:01 +1100 Subject: [PATCH] Reduce number of full screen refreshes to once every 20 pages --- lib/Epub/Epub/EpubHtmlParserSlim.cpp | 11 ++++------- src/screens/EpubReaderScreen.cpp | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/Epub/Epub/EpubHtmlParserSlim.cpp b/lib/Epub/Epub/EpubHtmlParserSlim.cpp index 1d4bda0..cb425ee 100644 --- a/lib/Epub/Epub/EpubHtmlParserSlim.cpp +++ b/lib/Epub/Epub/EpubHtmlParserSlim.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "Page.h" #include "htmlEntities.h" @@ -52,8 +53,6 @@ void EpubHtmlParserSlim::startNewTextBlock(const BLOCK_STYLE style) { currentTextBlock = new TextBlock(style); } -#include - void XMLCALL EpubHtmlParserSlim::startElement(void* userData, const XML_Char* name, const XML_Char** atts) { auto* self = static_cast(userData); (void)atts; @@ -154,11 +153,9 @@ void XMLCALL EpubHtmlParserSlim::endElement(void* userData, const XML_Char* name // We don't want to flush out content when closing inline tags like . // Currently this also flushes out on closing and tags, but they are line tags so that shouldn't happen, // text styling needs to be overhauled to fix it. - const bool shouldBreakText = matches(name, BLOCK_TAGS, NUM_BLOCK_TAGS) || - matches(name, HEADER_TAGS, NUM_HEADER_TAGS) || - matches(name, BOLD_TAGS, NUM_BOLD_TAGS) || - matches(name, ITALIC_TAGS, NUM_ITALIC_TAGS) || - self->depth == 1; + const bool shouldBreakText = + matches(name, BLOCK_TAGS, NUM_BLOCK_TAGS) || matches(name, HEADER_TAGS, NUM_HEADER_TAGS) || + matches(name, BOLD_TAGS, NUM_BOLD_TAGS) || matches(name, ITALIC_TAGS, NUM_ITALIC_TAGS) || self->depth == 1; if (shouldBreakText) { self->partWordBuffer[self->partWordBufferIndex] = '\0'; diff --git a/src/screens/EpubReaderScreen.cpp b/src/screens/EpubReaderScreen.cpp index 6452df8..5a87fc1 100644 --- a/src/screens/EpubReaderScreen.cpp +++ b/src/screens/EpubReaderScreen.cpp @@ -5,7 +5,7 @@ #include "Battery.h" -constexpr int PAGES_PER_REFRESH = 10; +constexpr int PAGES_PER_REFRESH = 20; constexpr unsigned long SKIP_CHAPTER_MS = 700; void EpubReaderScreen::taskTrampoline(void* param) {