Speed up page turning on big cre documents (#3740)

Page turning, menu opening, ... everything actually
pull/3751/head
poire-z 6 years ago committed by GitHub
parent c5b547f6b3
commit 7d71d73cc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -99,6 +99,9 @@ function ReaderRolling:init()
end)
table.insert(self.ui.postReaderCallback, function()
self:updatePos()
-- Disable crengine internal history, with required redraw
self.ui.document:enableInternalHistory(false)
self:onRedrawCurrentView()
end)
self.ui.menu:registerToMainMenu(self)
end
@ -566,10 +569,16 @@ function ReaderRolling:onSetDimensions(dimen)
end
function ReaderRolling:onChangeScreenMode(mode)
-- We need to temporarily re-enable internal history as crengine
-- uses it to reposition after resize
self.ui.document:enableInternalHistory(true)
self.ui:handleEvent(Event:new("SetScreenMode", mode))
self.ui.document:setViewDimen(Screen:getSize())
self:onChangeViewMode()
self:onUpdatePos()
-- Re-disable internal history, with required redraw
self.ui.document:enableInternalHistory(false)
self:onRedrawCurrentView()
end
function ReaderRolling:onColorRenderingUpdate()

@ -540,6 +540,19 @@ function CreDocument:findText(pattern, origin, reverse, caseInsensitive)
pattern, origin, reverse, caseInsensitive and 1 or 0)
end
function CreDocument:enableInternalHistory(toggle)
-- Setting this to 0 unsets crengine internal bookmarks highlighting,
-- and as a side effect, disable internal history and the need to build
-- a bookmark at each page turn: this speeds up a lot page turning
-- and menu opening on big books.
-- It has to be called late in the document opening process, and setting
-- it to false needs to be followed by a redraw.
-- It needs to be temporarily re-enabled on page resize for crengine to
-- keep track of position in page and restore it after resize.
logger.dbg("CreDocument: set bookmarks highlight and internal history", toggle)
self._document:setIntProperty("crengine.highlight.bookmarks", toggle and 2 or 0)
end
function CreDocument:register(registry)
registry:addProvider("azw", "application/vnd.amazon.mobi8-ebook", self, 90)
registry:addProvider("chm", "application/vnd.ms-htmlhelp", self, 90)

Loading…
Cancel
Save