mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[CRe] Ensure toggling nightmode invalidates the drawCurrentView cache (#6854)
* Use a CRe set* method when toggling nightmode This ensures it gets flagged as add_reset by the call cache, and that CRe will actually re-render, as it's necessary if nightmode_images is enabled (the default). Fix #6845 * Prevent ReaderHighlight:onTap from running ReaderHighlight:clear when it's unnecessary. Avoiding a clearSelection call in CRe that could invalidate the cache and cause unnecessary redraws. * Don't store empty highlight arrays when all HLs on a page have been deleted
This commit is contained in:
@@ -25,6 +25,7 @@ local CreDocument = Document:new{
|
||||
_view_mode = nil,
|
||||
_smooth_scaling = false,
|
||||
_nightmode_images = true,
|
||||
_nightmode = false,
|
||||
|
||||
line_space_percent = 100,
|
||||
default_font = "Noto Serif",
|
||||
@@ -423,7 +424,7 @@ function CreDocument:drawCurrentView(target, x, y, rect, pos)
|
||||
|
||||
--local start_ts = FFIUtil.getTimestamp()
|
||||
self._drawn_images_count, self._drawn_images_surface_ratio =
|
||||
self._document:drawCurrentPage(self.buffer, self.render_color, Screen.night_mode and self._nightmode_images, self._smooth_scaling, Screen.sw_dithering)
|
||||
self._document:drawCurrentPage(self.buffer, self.render_color, self._nightmode and self._nightmode_images, self._smooth_scaling, Screen.sw_dithering)
|
||||
--local end_ts = FFIUtil.getTimestamp()
|
||||
--print(string.format("CreDocument:drawCurrentView: Rendering took %9.3f ms", (end_ts - start_ts) * 1000))
|
||||
|
||||
@@ -877,6 +878,11 @@ function CreDocument:setNightmodeImages(toggle)
|
||||
self._nightmode_images = toggle
|
||||
end
|
||||
|
||||
function CreDocument:setNightMode(toggle)
|
||||
logger.dbg("CreDocument: set nightmode", toggle)
|
||||
self._nightmode = toggle
|
||||
end
|
||||
|
||||
function CreDocument:setFloatingPunctuation(enabled)
|
||||
--- @fixme occasional segmentation fault when toggling floating punctuation
|
||||
logger.dbg("CreDocument: set floating punctuation", enabled)
|
||||
|
||||
Reference in New Issue
Block a user