2
0
mirror of https://github.com/koreader/koreader synced 2024-11-11 19:11:14 +00:00

add pre-rendering in pdf/djvu readers

"HintPage" tasks are scheduled into the execution stack of UIManager
after each page drawing. These tasks should be checked immediately after
screen is refreshed so tasks are double-checked in the main loop.
This commit is contained in:
chrox 2013-01-05 22:28:14 +08:00
parent 3ec818a3cd
commit 12a76fee33
2 changed files with 43 additions and 30 deletions

View File

@ -50,6 +50,7 @@ function ReaderView:paintTo(bb, x, y)
self.state.zoom, self.state.zoom,
self.state.rotation, self.state.rotation,
self.render_mode) self.render_mode)
UIManager:scheduleIn(0, function() self.ui:handleEvent(Event:new("HintPage")) end)
else else
if self.view_mode == "page" then if self.view_mode == "page" then
self.ui.document:drawCurrentViewByPage( self.ui.document:drawCurrentViewByPage(
@ -162,6 +163,10 @@ function ReaderView:onRotationUpdate(rotation)
self:recalculate() self:recalculate()
end end
function ReaderView:onHintPage()
self.ui.document:hintPage(self.state.page+1, self.state.zoom, self.state.rotation)
end
function ReaderView:onCloseDocument() function ReaderView:onCloseDocument()
self.ui.doc_settings:saveSetting("render_mode", self.render_mode) self.ui.doc_settings:saveSetting("render_mode", self.render_mode)
end end

View File

@ -106,12 +106,7 @@ function UIManager:sendEvent(event)
end end
end end
-- this is the main loop of the UI controller function UIManager:checkTasks()
-- it is intended to manage input events and delegate
-- them to dialogs
function UIManager:run()
self._running = true
while self._running do
local now = { util.gettime() } local now = { util.gettime() }
-- check if we have timed events in our queue and search next one -- check if we have timed events in our queue and search next one
@ -141,6 +136,17 @@ function UIManager:run()
end end
end end
until all_tasks_checked until all_tasks_checked
return wait_until
end
-- this is the main loop of the UI controller
-- it is intended to manage input events and delegate
-- them to dialogs
function UIManager:run()
self._running = true
while self._running do
local now = { util.gettime() }
local wait_until = self:checkTasks()
--DEBUG("---------------------------------------------------") --DEBUG("---------------------------------------------------")
--DEBUG("exec stack", self._execution_stack) --DEBUG("exec stack", self._execution_stack)
@ -176,6 +182,8 @@ function UIManager:run()
self.refresh_type = 1 self.refresh_type = 1
end end
self:checkTasks()
-- wait for next event -- wait for next event
-- note that we will skip that if in the meantime we have tasks that are ready to run -- note that we will skip that if in the meantime we have tasks that are ready to run
local input_event = nil local input_event = nil