Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Epub/Epub/ReferencePageNavigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(
(static_cast<uint64_t>(clampedUnitOffset) * visibleTextLength) / spineUnitCount);
const uint32_t targetVisibleOffset =
static_cast<uint32_t>((static_cast<uint64_t>(clampedUnitOffset) * visibleTextLength) / spineUnitCount);
uint16_t page = 0;
for (size_t i = 1; i < pageIndex.size(); ++i) {
if (pageIndex[i].visibleTextOffset > targetVisibleOffset) break;
Expand Down
8 changes: 4 additions & 4 deletions src/SettingsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,10 @@ inline const std::vector<SettingInfo>& 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,
Expand Down
12 changes: 6 additions & 6 deletions src/activities/boot_sleep/SleepActivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename SourceStateFn>
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)
Expand All @@ -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);
Expand All @@ -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);
Expand Down
79 changes: 38 additions & 41 deletions src/activities/reader/EpubReaderActivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5821,43 +5821,43 @@ void EpubReaderActivity::render(RenderLock&& lock) {
(anchorJump ? !anchorPageReady()
: pendingRelayoutReposition ? !isRelayoutCatchUpComplete()
: static_cast<int>(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<int>(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<int>(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) {
Expand Down Expand Up @@ -7070,14 +7070,11 @@ bool EpubReaderActivity::renderContents(std::unique_ptr<Page> 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<EpubReaderActivity*>(context)
->pendingManualPageTurns.hasPending();
},
this)) {
if (EpubGrayscale::runTiledGrayscalePass(
renderer, *page, fontId, orientedMarginLeft, orientedMarginTop, foregroundBlack, needsTextGrayscale,
needsImageGrayscale, grayscaleStripScratch.get(), grayscaleStripScratchSize, overlapRefresh,
[](void* context) { return static_cast<EpubReaderActivity*>(context)->pendingManualPageTurns.hasPending(); },
this)) {
return true;
}

Expand Down
8 changes: 7 additions & 1 deletion src/components/icons/keyboardIcons.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};
4 changes: 1 addition & 3 deletions test/stable_page_navigation/StablePageNavigationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ TEST(StablePageNavigation, RequiresAtLeastOneUsableSpineRange) {
const std::array<Span, 2> 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) {
Expand All @@ -106,7 +105,6 @@ TEST(StablePageSelection, ClampsStepsAndMapsSliderEndpoints) {
EXPECT_EQ(stablePageToPermille(300, 300), 1000);
}


TEST(StablePageNavigation, UsesSourceOffsetsForUnevenRenderedPages) {
const std::array<PageStart, 4> pageStarts = {{{0}, {50}, {60}, {300}}};

Expand Down
Loading