|
|
|
@ -189,9 +189,8 @@ KoptOptions = {
|
|
|
|
|
KoptInterface = {}
|
|
|
|
|
|
|
|
|
|
-- get reflow context
|
|
|
|
|
function KoptInterface:getKOPTContext(doc, pageno, bbox)
|
|
|
|
|
function KoptInterface:getKOPTContext(doc, pageno, bbox, screen_size)
|
|
|
|
|
local kc = KOPTContext.new()
|
|
|
|
|
local screen_size = Screen:getSize()
|
|
|
|
|
kc:setTrim(doc.configurable.trim_page)
|
|
|
|
|
kc:setWrap(doc.configurable.text_wrap)
|
|
|
|
|
kc:setIndent(doc.configurable.detect_indent)
|
|
|
|
@ -215,13 +214,14 @@ end
|
|
|
|
|
-- calculates page dimensions
|
|
|
|
|
function KoptInterface:getPageDimensions(doc, pageno, zoom, rotation)
|
|
|
|
|
-- check cached page size
|
|
|
|
|
self.cur_bbox = doc:getPageBBox(pageno)
|
|
|
|
|
self.screen_mode = Screen:getScreenMode()
|
|
|
|
|
local bbox_hash = self.cur_bbox.x0.."|"..self.cur_bbox.y0.."|"..self.cur_bbox.x1.."|"..self.cur_bbox.y1
|
|
|
|
|
local hash = "kctx|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..bbox_hash.."|"..self.screen_mode
|
|
|
|
|
local bbox = doc:getPageBBox(pageno)
|
|
|
|
|
local bbox_hash = bbox.x0.."|"..bbox.y0.."|"..bbox.x1.."|"..bbox.y1
|
|
|
|
|
local screen_size = Screen:getSize()
|
|
|
|
|
local screen_size_hash = screen_size.w.."|"..screen_size.h
|
|
|
|
|
local hash = "kctx|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..bbox_hash.."|"..screen_size_hash
|
|
|
|
|
local cached = Cache:check(hash)
|
|
|
|
|
if not cached then
|
|
|
|
|
local kc = self:getKOPTContext(doc, pageno, self.cur_bbox)
|
|
|
|
|
local kc = self:getKOPTContext(doc, pageno, bbox, screen_size)
|
|
|
|
|
local page = doc._document:openPage(pageno)
|
|
|
|
|
-- reflow page
|
|
|
|
|
page:reflow(kc, 0)
|
|
|
|
@ -241,10 +241,11 @@ end
|
|
|
|
|
|
|
|
|
|
function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, render_mode)
|
|
|
|
|
doc.render_mode = render_mode
|
|
|
|
|
self.cur_bbox = doc:getPageBBox(pageno)
|
|
|
|
|
self.screen_mode = Screen:getScreenMode()
|
|
|
|
|
local bbox_hash = self.cur_bbox.x0.."|"..self.cur_bbox.y0.."|"..self.cur_bbox.x1.."|"..self.cur_bbox.y1
|
|
|
|
|
local hash = "renderpg|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..bbox_hash.."|"..self.screen_mode
|
|
|
|
|
local bbox = doc:getPageBBox(pageno)
|
|
|
|
|
local bbox_hash = bbox.x0.."|"..bbox.y0.."|"..bbox.x1.."|"..bbox.y1
|
|
|
|
|
local screen_size = Screen:getSize()
|
|
|
|
|
local screen_size_hash = screen_size.w.."|"..screen_size.h
|
|
|
|
|
local hash = "renderpg|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..bbox_hash.."|"..screen_size_hash
|
|
|
|
|
local page_size = self:getPageDimensions(doc, pageno, zoom, rotation)
|
|
|
|
|
-- this will be the size we actually render
|
|
|
|
|
local size = page_size
|
|
|
|
@ -275,7 +276,7 @@ function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, render_mode
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- draw to blitbuffer
|
|
|
|
|
local kc_hash = "kctx|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..bbox_hash.."|"..self.screen_mode
|
|
|
|
|
local kc_hash = "kctx|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..bbox_hash.."|"..screen_size_hash
|
|
|
|
|
local page = doc._document:openPage(pageno)
|
|
|
|
|
local cached = Cache:check(kc_hash)
|
|
|
|
|
if cached then
|
|
|
|
|