Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up page turning on big cre documents #3740

Merged
merged 19 commits into from
Mar 12, 2018
Merged
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
9 changes: 9 additions & 0 deletions frontend/apps/reader/modules/readerrolling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
13 changes: 13 additions & 0 deletions frontend/document/credocument.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down