Some review comments
This commit is contained in:
@@ -851,7 +851,14 @@ static void renderCharImpl(const GfxRenderer& renderer, GfxRenderer::RenderMode
|
|||||||
// Fast path: 1-bit BW mode, non-rotated text — byte-level framebuffer writes, no drawPixel() per pixel.
|
// Fast path: 1-bit BW mode, non-rotated text — byte-level framebuffer writes, no drawPixel() per pixel.
|
||||||
if constexpr (rotation == TextRotation::None) {
|
if constexpr (rotation == TextRotation::None) {
|
||||||
if (renderMode == GfxRenderer::BW) {
|
if (renderMode == GfxRenderer::BW) {
|
||||||
renderGlyphFastBW(renderer.getFrameBuffer(), bitmap, width, height, innerBase, outerBase, pixelState,
|
// Use getWriteTarget() for buffer-routing symmetry with the 2-bit fast path above.
|
||||||
|
// renderGlyphFastBW is NOT strip-aware (no fbOriginY/fbRows in its signature), so it
|
||||||
|
// can only safely write to the full framebuffer. Today no caller activates a strip in
|
||||||
|
// BW mode (only the grayscale planes do), so this is equivalent to getFrameBuffer().
|
||||||
|
// The assert is a tripwire if a future BW-under-strip path is added without
|
||||||
|
// retrofitting renderGlyphFastBW with strip-aware row math.
|
||||||
|
assert(!renderer.isStripActive());
|
||||||
|
renderGlyphFastBW(renderer.getWriteTarget(), bitmap, width, height, innerBase, outerBase, pixelState,
|
||||||
renderer.getOrientation(), renderer.getDisplayWidth(), renderer.getDisplayHeight(),
|
renderer.getOrientation(), renderer.getDisplayWidth(), renderer.getDisplayHeight(),
|
||||||
renderer.getDisplayWidthBytes());
|
renderer.getDisplayWidthBytes());
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -118,7 +118,8 @@ inline void logReaderMemSnapshot(const char*) {}
|
|||||||
// renderCharImpl culls out-of-band glyphs before bitmap decode so the cost
|
// renderCharImpl culls out-of-band glyphs before bitmap decode so the cost
|
||||||
// stays close to one render. Only renderTextOnly() is called here, matching the
|
// stays close to one render. Only renderTextOnly() is called here, matching the
|
||||||
// legacy AA pass — images and HRs do not participate in grayscale.
|
// legacy AA pass — images and HRs do not participate in grayscale.
|
||||||
bool runTiledGrayscalePass(GfxRenderer& renderer, Page& page, int fontId, int marginLeft, int contentTop, bool fastAA) {
|
bool runTiledGrayscalePass(GfxRenderer& renderer, const Page& page, int fontId, int marginLeft, int contentTop,
|
||||||
|
bool fastAA) {
|
||||||
if (!renderer.supportsStripGrayscale()) return false;
|
if (!renderer.supportsStripGrayscale()) return false;
|
||||||
|
|
||||||
// Push the SETTINGS toggle into the SDK before the AA refresh. No-op on X4;
|
// Push the SETTINGS toggle into the SDK before the AA refresh. No-op on X4;
|
||||||
@@ -2126,11 +2127,13 @@ void EpubReaderActivity::renderContents(std::unique_ptr<Page> page, const int or
|
|||||||
} else {
|
} else {
|
||||||
// Legacy fallback: save (partial) BW frame, render LSB+MSB planes into the
|
// Legacy fallback: save (partial) BW frame, render LSB+MSB planes into the
|
||||||
// live framebuffer, display, then restore. Pre-check heap to avoid entering
|
// live framebuffer, display, then restore. Pre-check heap to avoid entering
|
||||||
// the chunk-retry path when success is unlikely.
|
// the chunk-retry path when success is unlikely. Skip the snapshot entirely
|
||||||
|
// when AA is off — there is nothing to restore from since no grayscale pass
|
||||||
|
// will run.
|
||||||
const uint32_t bwStoreFreeHeap = esp_get_free_heap_size();
|
const uint32_t bwStoreFreeHeap = esp_get_free_heap_size();
|
||||||
const uint32_t bwStoreContigHeap = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_DEFAULT);
|
const uint32_t bwStoreContigHeap = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_DEFAULT);
|
||||||
const bool shouldAttemptBwSnapshot =
|
const bool shouldAttemptBwSnapshot = aaEnabledForThisRender && bwStoreFreeHeap >= BW_SNAPSHOT_MIN_FREE_HEAP_BYTES &&
|
||||||
bwStoreFreeHeap >= BW_SNAPSHOT_MIN_FREE_HEAP_BYTES && bwStoreContigHeap >= BW_SNAPSHOT_MIN_CONTIG_HEAP_BYTES;
|
bwStoreContigHeap >= BW_SNAPSHOT_MIN_CONTIG_HEAP_BYTES;
|
||||||
|
|
||||||
logReaderMemSnapshot("bw_store_begin");
|
logReaderMemSnapshot("bw_store_begin");
|
||||||
bool bwBufferStored = false;
|
bool bwBufferStored = false;
|
||||||
@@ -2152,15 +2155,15 @@ void EpubReaderActivity::renderContents(std::unique_ptr<Page> page, const int or
|
|||||||
const int contentRight = std::max(contentLeft, renderer.getScreenWidth() - orientedMarginRight);
|
const int contentRight = std::max(contentLeft, renderer.getScreenWidth() - orientedMarginRight);
|
||||||
bwBufferStored =
|
bwBufferStored =
|
||||||
renderer.storeBwBufferRect(contentLeft, 0, contentRight - contentLeft, renderer.getScreenHeight());
|
renderer.storeBwBufferRect(contentLeft, 0, contentRight - contentLeft, renderer.getScreenHeight());
|
||||||
} else {
|
} else if (aaEnabledForThisRender) {
|
||||||
LOG_INF("ERS", "Skipping BW snapshot precheck (free=%lu contig=%lu, need free>=%lu contig>=%lu)", bwStoreFreeHeap,
|
LOG_INF("ERS", "Skipping BW snapshot precheck (free=%lu contig=%lu, need free>=%lu contig>=%lu)", bwStoreFreeHeap,
|
||||||
bwStoreContigHeap, static_cast<uint32_t>(BW_SNAPSHOT_MIN_FREE_HEAP_BYTES),
|
bwStoreContigHeap, static_cast<uint32_t>(BW_SNAPSHOT_MIN_FREE_HEAP_BYTES),
|
||||||
static_cast<uint32_t>(BW_SNAPSHOT_MIN_CONTIG_HEAP_BYTES));
|
static_cast<uint32_t>(BW_SNAPSHOT_MIN_CONTIG_HEAP_BYTES));
|
||||||
}
|
}
|
||||||
const auto tBwStore = millis();
|
const auto tBwStore = millis();
|
||||||
logReaderMemSnapshot("bw_store_end");
|
logReaderMemSnapshot("bw_store_end");
|
||||||
if (!bwBufferStored) {
|
if (aaEnabledForThisRender && !bwBufferStored) {
|
||||||
if (aaEnabledForThisRender && !antiAliasingSuspendedLowMemory) {
|
if (!antiAliasingSuspendedLowMemory) {
|
||||||
antiAliasingSuspendedLowMemory = true;
|
antiAliasingSuspendedLowMemory = true;
|
||||||
const uint32_t freeHeapNow = esp_get_free_heap_size();
|
const uint32_t freeHeapNow = esp_get_free_heap_size();
|
||||||
const uint32_t contigHeapNow = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_DEFAULT);
|
const uint32_t contigHeapNow = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_DEFAULT);
|
||||||
@@ -2297,8 +2300,7 @@ void EpubReaderActivity::displayPreRenderedPage(const Page& page, const int orie
|
|||||||
// support strip grayscale or when the strip scratch can't be allocated.
|
// support strip grayscale or when the strip scratch can't be allocated.
|
||||||
const bool aaConfigured = SETTINGS.textAntiAliasing && !antiAliasingSuspendedLowMemory;
|
const bool aaConfigured = SETTINGS.textAntiAliasing && !antiAliasingSuspendedLowMemory;
|
||||||
if (aaConfigured) {
|
if (aaConfigured) {
|
||||||
Page& pageRef = const_cast<Page&>(page);
|
if (runTiledGrayscalePass(renderer, page, getEffectiveReaderFontId(), orientedMarginLeft, contentTop,
|
||||||
if (runTiledGrayscalePass(renderer, pageRef, getEffectiveReaderFontId(), orientedMarginLeft, contentTop,
|
|
||||||
SETTINGS.fastAntiAliasing)) {
|
SETTINGS.fastAntiAliasing)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user