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.
pull/2/merge
chrox 12 years ago
parent 3ec818a3cd
commit 12a76fee33

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

@ -106,12 +106,7 @@ function UIManager:sendEvent(event)
end
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
function UIManager:checkTasks()
local now = { util.gettime() }
-- check if we have timed events in our queue and search next one
@ -141,6 +136,17 @@ function UIManager:run()
end
end
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("exec stack", self._execution_stack)
@ -176,6 +182,8 @@ function UIManager:run()
self.refresh_type = 1
end
self:checkTasks()
-- wait for next event
-- note that we will skip that if in the meantime we have tasks that are ready to run
local input_event = nil

Loading…
Cancel
Save