From 71569e8603054024bbed404e345202d58470ba31 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 20 Sep 2026 19:41:14 +0000 Subject: [PATCH 1/2] Initial plan From bc9393a4b6495c3163fcde90060cba80a30e9c8a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 20 Sep 2026 19:45:11 +0000 Subject: [PATCH 2/2] chore: fix clang-format drift Co-authored-by: prokrypt <1832555+prokrypt@users.noreply.github.com> --- lib/Epub/Epub/ReferencePageNavigation.h | 4 +- src/SettingsList.h | 8 +- src/activities/boot_sleep/SleepActivity.cpp | 12 +-- src/activities/reader/EpubReaderActivity.cpp | 79 +++++++++---------- src/components/icons/keyboardIcons.h | 8 +- .../StablePageNavigationTest.cpp | 4 +- 6 files changed, 58 insertions(+), 57 deletions(-) diff --git a/lib/Epub/Epub/ReferencePageNavigation.h b/lib/Epub/Epub/ReferencePageNavigation.h index 51eeb3734fe..003a8713396 100644 --- a/lib/Epub/Epub/ReferencePageNavigation.h +++ b/lib/Epub/Epub/ReferencePageNavigation.h @@ -73,8 +73,8 @@ uint16_t resolveReferenceTargetToRenderedPage(const uint32_t spineUnitOffset, co if (pageIndex.empty() || spineUnitCount == 0 || visibleTextLength == 0) return 0; const uint32_t clampedUnitOffset = std::min(spineUnitOffset, spineUnitCount); - const uint32_t targetVisibleOffset = static_cast( - (static_cast(clampedUnitOffset) * visibleTextLength) / spineUnitCount); + const uint32_t targetVisibleOffset = + static_cast((static_cast(clampedUnitOffset) * visibleTextLength) / spineUnitCount); uint16_t page = 0; for (size_t i = 1; i < pageIndex.size(); ++i) { if (pageIndex[i].visibleTextOffset > targetVisibleOffset) break; diff --git a/src/SettingsList.h b/src/SettingsList.h index ca7651ffff7..69a4c89f291 100644 --- a/src/SettingsList.h +++ b/src/SettingsList.h @@ -682,10 +682,10 @@ inline const std::vector& getBaseSettingsList() { StrId::STR_CAT_READER)); add(SettingInfo::Toggle(StrId::STR_GUIDE_READING, &CrossPointSettings::guideReadingEnabled, "guideReadingEnabled", StrId::STR_CAT_READER)); - add(SettingInfo::Enum(StrId::STR_INDEXING_METHOD, &CrossPointSettings::indexingMethod, - {StrId::STR_INDEXING_INCREMENTAL, StrId::STR_INDEXING_FULL_SECTION, - StrId::STR_INDEXING_INCREMENTAL_MENTAL}, - "indexingMethod", StrId::STR_CAT_READER)); + add(SettingInfo::Enum( + StrId::STR_INDEXING_METHOD, &CrossPointSettings::indexingMethod, + {StrId::STR_INDEXING_INCREMENTAL, StrId::STR_INDEXING_FULL_SECTION, StrId::STR_INDEXING_INCREMENTAL_MENTAL}, + "indexingMethod", StrId::STR_CAT_READER)); // --- Controls --- add(SettingInfo::Toggle(StrId::STR_PINCH_FONT_RESIZE, &CrossPointSettings::pinchFontResizeEnabled, diff --git a/src/activities/boot_sleep/SleepActivity.cpp b/src/activities/boot_sleep/SleepActivity.cpp index 15d939486f2..8bbca095b0e 100644 --- a/src/activities/boot_sleep/SleepActivity.cpp +++ b/src/activities/boot_sleep/SleepActivity.cpp @@ -53,8 +53,8 @@ bool sleepCoverFilterInvertsGeneratedScreen() { // Fills the letterbox/pillarbox margins left by a centered image at [left,right)x[top,bottom) // by sampling `sourceStateAt(col, row)` for each margin pixel, skipping the drawn image area. template -void fillMargins(const GfxRenderer& renderer, int left, int top, int right, int bottom, int pageWidth, - int pageHeight, SourceStateFn sourceStateAt) { +void fillMargins(const GfxRenderer& renderer, int left, int top, int right, int bottom, int pageWidth, int pageHeight, + SourceStateFn sourceStateAt) { if (left >= right || top >= bottom) return; for (int row = 0; row < top; ++row) @@ -80,8 +80,8 @@ int mirrorCoordinate(int c, int lo, int hi) { // Fills the letterbox/pillarbox margins left by a centered image with clamped // copies of its nearest edge pixel, instead of leaving them blank/white. -void extendBitmapEdges(const GfxRenderer& renderer, int drawX, int drawY, int drawWidth, int drawHeight, - int pageWidth, int pageHeight) { +void extendBitmapEdges(const GfxRenderer& renderer, int drawX, int drawY, int drawWidth, int drawHeight, int pageWidth, + int pageHeight) { if (drawWidth <= 0 || drawHeight <= 0) return; const int left = std::clamp(drawX, 0, pageWidth); const int top = std::clamp(drawY, 0, pageHeight); @@ -97,8 +97,8 @@ void extendBitmapEdges(const GfxRenderer& renderer, int drawX, int drawY, int dr // Same as extendBitmapEdges, but reflects the drawn image outward into the margins // instead of repeating a single edge pixel, so the fill keeps the cover's texture. -void mirrorBitmapEdges(const GfxRenderer& renderer, int drawX, int drawY, int drawWidth, int drawHeight, - int pageWidth, int pageHeight) { +void mirrorBitmapEdges(const GfxRenderer& renderer, int drawX, int drawY, int drawWidth, int drawHeight, int pageWidth, + int pageHeight) { if (drawWidth <= 0 || drawHeight <= 0) return; const int left = std::clamp(drawX, 0, pageWidth); const int top = std::clamp(drawY, 0, pageHeight); diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 8e5b3d14123..99524568f47 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -5821,43 +5821,43 @@ void EpubReaderActivity::render(RenderLock&& lock) { (anchorJump ? !anchorPageReady() : pendingRelayoutReposition ? !isRelayoutCatchUpComplete() : static_cast(section->pageCount) <= target)) { - if (cancelBuildForBack()) { - break; - } - if (buildPopupPending && millis() - buildStartMs >= BUILD_POPUP_DEADLINE_MS) { - showBuildPopup(); - } - if (!section->buildSomeMore(INTERACTIVE_BUILD_PAGES_PER_CHUNK)) { - LOG_ERR("ERS", "Failed during incremental section build"); - buildFailed = true; - break; - } + if (cancelBuildForBack()) { + break; } - if (!buildFailed && pendingRelayoutReposition && section->isBuilding() && isRelayoutCatchUpComplete()) { - LOG_DBG("ERS", "Incremental relayout reached prior watermark: pages=%u target=%d", section->pageCount, - cachedChapterPageWatermark); + if (buildPopupPending && millis() - buildStartMs >= BUILD_POPUP_DEADLINE_MS) { + showBuildPopup(); } - attemptLayoutAbortedForLowMemory = - attemptLayoutAbortedForLowMemory || section->lastBuildLayoutAbortedForLowMemory(); - const bool requestedPageAvailable = anchorJump ? anchorPageReady() - : pendingRelayoutReposition - ? isRelayoutCatchUpComplete() - : target >= 0 && target < static_cast(section->pageCount); - if (buildCancelledForBack) { - buildFailed = false; + if (!section->buildSomeMore(INTERACTIVE_BUILD_PAGES_PER_CHUNK)) { + LOG_ERR("ERS", "Failed during incremental section build"); + buildFailed = true; + break; } - if (buildFailed && attemptLayoutAbortedForLowMemory && requestedPageAvailable) { - LOG_ERR("ERS", "Incremental section build paused for low heap after reaching requested page"); - attemptLayoutAbortedForLowMemory = false; - buildFailed = false; - } - buildSucceeded = - buildCancelledForBack || (!buildFailed && (section->pageCount > 0 || section->isBuildComplete())); - } else { - attemptLayoutAbortedForLowMemory = - attemptLayoutAbortedForLowMemory || section->lastBuildLayoutAbortedForLowMemory(); } - buildPopupPending = false; + if (!buildFailed && pendingRelayoutReposition && section->isBuilding() && isRelayoutCatchUpComplete()) { + LOG_DBG("ERS", "Incremental relayout reached prior watermark: pages=%u target=%d", section->pageCount, + cachedChapterPageWatermark); + } + attemptLayoutAbortedForLowMemory = + attemptLayoutAbortedForLowMemory || section->lastBuildLayoutAbortedForLowMemory(); + const bool requestedPageAvailable = anchorJump ? anchorPageReady() + : pendingRelayoutReposition + ? isRelayoutCatchUpComplete() + : target >= 0 && target < static_cast(section->pageCount); + if (buildCancelledForBack) { + buildFailed = false; + } + if (buildFailed && attemptLayoutAbortedForLowMemory && requestedPageAvailable) { + LOG_ERR("ERS", "Incremental section build paused for low heap after reaching requested page"); + attemptLayoutAbortedForLowMemory = false; + buildFailed = false; + } + buildSucceeded = + buildCancelledForBack || (!buildFailed && (section->pageCount > 0 || section->isBuildComplete())); + } else { + attemptLayoutAbortedForLowMemory = + attemptLayoutAbortedForLowMemory || section->lastBuildLayoutAbortedForLowMemory(); + } + buildPopupPending = false; } layoutAbortedForLowMemory = attemptLayoutAbortedForLowMemory; if (buildSucceeded) { @@ -7070,14 +7070,11 @@ bool EpubReaderActivity::renderContents(std::unique_ptr page, const int fo if (needsAnyGrayscale) { ensureGrayscaleStripScratch(); } - if (EpubGrayscale::runTiledGrayscalePass(renderer, *page, fontId, orientedMarginLeft, orientedMarginTop, - foregroundBlack, needsTextGrayscale, needsImageGrayscale, - grayscaleStripScratch.get(), grayscaleStripScratchSize, overlapRefresh, - [](void* context) { - return static_cast(context) - ->pendingManualPageTurns.hasPending(); - }, - this)) { + if (EpubGrayscale::runTiledGrayscalePass( + renderer, *page, fontId, orientedMarginLeft, orientedMarginTop, foregroundBlack, needsTextGrayscale, + needsImageGrayscale, grayscaleStripScratch.get(), grayscaleStripScratchSize, overlapRefresh, + [](void* context) { return static_cast(context)->pendingManualPageTurns.hasPending(); }, + this)) { return true; } diff --git a/src/components/icons/keyboardIcons.h b/src/components/icons/keyboardIcons.h index 571baba9b52..643c58e5f62 100644 --- a/src/components/icons/keyboardIcons.h +++ b/src/components/icons/keyboardIcons.h @@ -6,5 +6,11 @@ // Sizes: 28px. Icons: 1. // backspace (lucide: delete) -static const uint8_t icon_backspace_28_bits[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x7F, 0xFF, 0x00, 0x00, 0x3F, 0xFE, 0x1F, 0xFF, 0x1F, 0xFC, 0x7F, 0xFF, 0x9F, 0xF8, 0xFF, 0xFF, 0x9F, 0xF1, 0xF8, 0xE3, 0x9F, 0xE3, 0xF8, 0x43, 0x9F, 0xC7, 0xFC, 0x07, 0x9F, 0x8F, 0xFE, 0x0F, 0x9F, 0x8F, 0xFE, 0x0F, 0x9F, 0xC7, 0xFC, 0x07, 0x9F, 0xE3, 0xF8, 0x43, 0x9F, 0xF1, 0xF8, 0xE3, 0x9F, 0xF8, 0xFF, 0xFF, 0x9F, 0xFC, 0x7F, 0xFF, 0x9F, 0xFE, 0x1F, 0xFF, 0x1F, 0xFF, 0x00, 0x00, 0x3F, 0xFF, 0xC0, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; +static const uint8_t icon_backspace_28_bits[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xC0, 0x00, 0x7F, 0xFF, 0x00, 0x00, 0x3F, 0xFE, 0x1F, 0xFF, 0x1F, 0xFC, 0x7F, 0xFF, 0x9F, 0xF8, 0xFF, + 0xFF, 0x9F, 0xF1, 0xF8, 0xE3, 0x9F, 0xE3, 0xF8, 0x43, 0x9F, 0xC7, 0xFC, 0x07, 0x9F, 0x8F, 0xFE, 0x0F, 0x9F, 0x8F, + 0xFE, 0x0F, 0x9F, 0xC7, 0xFC, 0x07, 0x9F, 0xE3, 0xF8, 0x43, 0x9F, 0xF1, 0xF8, 0xE3, 0x9F, 0xF8, 0xFF, 0xFF, 0x9F, + 0xFC, 0x7F, 0xFF, 0x9F, 0xFE, 0x1F, 0xFF, 0x1F, 0xFF, 0x00, 0x00, 0x3F, 0xFF, 0xC0, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; static const freeink::Icon icon_backspace_28 = {28, 28, 14, icon_backspace_28_bits}; diff --git a/test/stable_page_navigation/StablePageNavigationTest.cpp b/test/stable_page_navigation/StablePageNavigationTest.cpp index bf8c59be2cc..39198361837 100644 --- a/test/stable_page_navigation/StablePageNavigationTest.cpp +++ b/test/stable_page_navigation/StablePageNavigationTest.cpp @@ -80,8 +80,7 @@ TEST(StablePageNavigation, RequiresAtLeastOneUsableSpineRange) { const std::array outOfBoundsSpans = {{{300, 50}, {400, 50}}}; EXPECT_FALSE(EpubNavigation::hasResolvableReferencePageRanges(300, emptySpans.data(), emptySpans.size())); - EXPECT_FALSE( - EpubNavigation::hasResolvableReferencePageRanges(300, outOfBoundsSpans.data(), outOfBoundsSpans.size())); + EXPECT_FALSE(EpubNavigation::hasResolvableReferencePageRanges(300, outOfBoundsSpans.data(), outOfBoundsSpans.size())); } TEST(StablePageNavigation, FallsBackToLastReadableSpineForInconsistentTotals) { @@ -106,7 +105,6 @@ TEST(StablePageSelection, ClampsStepsAndMapsSliderEndpoints) { EXPECT_EQ(stablePageToPermille(300, 300), 1000); } - TEST(StablePageNavigation, UsesSourceOffsetsForUnevenRenderedPages) { const std::array pageStarts = {{{0}, {50}, {60}, {300}}};