|
|
@ -72,6 +72,10 @@ function Document:_init()
|
|
|
|
author = "",
|
|
|
|
author = "",
|
|
|
|
date = ""
|
|
|
|
date = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Should be updated by a call to Document.updateColorRendering(self)
|
|
|
|
|
|
|
|
-- in subclasses
|
|
|
|
|
|
|
|
self.render_color = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- override this method to open a document
|
|
|
|
-- override this method to open a document
|
|
|
@ -269,14 +273,30 @@ function Document:findText()
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function Document:getFullPageHash(pageno, zoom, rotation, gamma, render_mode)
|
|
|
|
function Document:updateColorRendering()
|
|
|
|
|
|
|
|
if self.is_color_capable and Screen:isColorEnabled() then
|
|
|
|
|
|
|
|
self.render_color = true
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
self.render_color = false
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Document:preRenderPage()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Document:postRenderPage()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Document:getFullPageHash(pageno, zoom, rotation, gamma, render_mode, color)
|
|
|
|
return "renderpg|"..self.file.."|"..self.mod_time.."|"..pageno.."|"
|
|
|
|
return "renderpg|"..self.file.."|"..self.mod_time.."|"..pageno.."|"
|
|
|
|
..zoom.."|"..rotation.."|"..gamma.."|"..render_mode
|
|
|
|
..zoom.."|"..rotation.."|"..gamma.."|"..render_mode..(color and "|color" or "")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode)
|
|
|
|
function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode)
|
|
|
|
local hash_excerpt
|
|
|
|
local hash_excerpt
|
|
|
|
local hash = self:getFullPageHash(pageno, zoom, rotation, gamma, render_mode)
|
|
|
|
local hash = self:getFullPageHash(pageno, zoom, rotation, gamma, render_mode, self.render_color)
|
|
|
|
local tile = Cache:check(hash, TileCacheItem)
|
|
|
|
local tile = Cache:check(hash, TileCacheItem)
|
|
|
|
if not tile then
|
|
|
|
if not tile then
|
|
|
|
hash_excerpt = hash.."|"..tostring(rect)
|
|
|
|
hash_excerpt = hash.."|"..tostring(rect)
|
|
|
@ -284,6 +304,8 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if tile then return tile end
|
|
|
|
if tile then return tile end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self:preRenderPage()
|
|
|
|
|
|
|
|
|
|
|
|
local page_size = self:getPageDimensions(pageno, zoom, rotation)
|
|
|
|
local page_size = self:getPageDimensions(pageno, zoom, rotation)
|
|
|
|
-- this will be the size we actually render
|
|
|
|
-- this will be the size we actually render
|
|
|
|
local size = page_size
|
|
|
|
local size = page_size
|
|
|
@ -303,16 +325,12 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- prepare cache item with contained blitbuffer
|
|
|
|
-- prepare cache item with contained blitbuffer
|
|
|
|
local bbtype = nil -- use Blitbuffer default greyscale type
|
|
|
|
|
|
|
|
if self.is_color_capable and Screen:isColorEnabled() then
|
|
|
|
|
|
|
|
bbtype = Blitbuffer.TYPE_BBRGB32
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tile = TileCacheItem:new{
|
|
|
|
tile = TileCacheItem:new{
|
|
|
|
persistent = true,
|
|
|
|
persistent = true,
|
|
|
|
size = size.w * size.h + 64, -- estimation
|
|
|
|
size = size.w * size.h + 64, -- estimation
|
|
|
|
excerpt = size,
|
|
|
|
excerpt = size,
|
|
|
|
pageno = pageno,
|
|
|
|
pageno = pageno,
|
|
|
|
bb = Blitbuffer.new(size.w, size.h, bbtype)
|
|
|
|
bb = Blitbuffer.new(size.w, size.h, self.render_color and Blitbuffer.TYPE_BBRGB32 or nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-- create a draw context
|
|
|
|
-- create a draw context
|
|
|
@ -339,6 +357,7 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode)
|
|
|
|
page:close()
|
|
|
|
page:close()
|
|
|
|
Cache:insert(hash, tile)
|
|
|
|
Cache:insert(hash, tile)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self:postRenderPage()
|
|
|
|
return tile
|
|
|
|
return tile
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|