add current bbox in page rendering hash

So that changing bbox could take effect on current page.
pull/2/merge
chrox 11 years ago
parent 92586a3b95
commit 4675a220d8

@ -178,7 +178,7 @@ KoptOptions = {
KoptInterface = {} KoptInterface = {}
-- get reflow context -- get reflow context
function KoptInterface:getKOPTContext(doc, pageno) function KoptInterface:getKOPTContext(doc, pageno, bbox)
local kc = KOPTContext.new() local kc = KOPTContext.new()
kc:setTrim(doc.configurable.trim_page) kc:setTrim(doc.configurable.trim_page)
kc:setWrap(doc.configurable.text_wrap) kc:setWrap(doc.configurable.text_wrap)
@ -196,7 +196,6 @@ function KoptInterface:getKOPTContext(doc, pageno)
kc:setDefectSize(doc.configurable.defect_size) kc:setDefectSize(doc.configurable.defect_size)
kc:setLineSpacing(doc.configurable.line_spacing) kc:setLineSpacing(doc.configurable.line_spacing)
kc:setWordSpacing(doc.configurable.word_spacing) kc:setWordSpacing(doc.configurable.word_spacing)
local bbox = doc:getPageBBox(pageno)
kc:setBBox(bbox.x0, bbox.y0, bbox.x1, bbox.y1) kc:setBBox(bbox.x0, bbox.y0, bbox.x1, bbox.y1)
return kc return kc
end end
@ -204,10 +203,11 @@ end
-- calculates page dimensions -- calculates page dimensions
function KoptInterface:getPageDimensions(doc, pageno, zoom, rotation) function KoptInterface:getPageDimensions(doc, pageno, zoom, rotation)
-- check cached page size -- check cached page size
local hash = "kctx|"..doc.file.."|"..pageno.."|"..doc.configurable:hash('|') self.cur_bbox = doc:getPageBBox(pageno)
local hash = "kctx|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..tostring(self.cur_bbox)
local cached = Cache:check(hash) local cached = Cache:check(hash)
if not cached then if not cached then
local kc = self:getKOPTContext(doc, pageno) local kc = self:getKOPTContext(doc, pageno, self.cur_bbox)
local page = doc._document:openPage(pageno) local page = doc._document:openPage(pageno)
-- reflow page -- reflow page
page:reflow(kc, 0) page:reflow(kc, 0)
@ -227,7 +227,8 @@ end
function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, render_mode) function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, render_mode)
doc.render_mode = render_mode doc.render_mode = render_mode
local hash = "renderpg|"..doc.file.."|"..pageno.."|"..doc.configurable:hash('|') self.cur_bbox = doc:getPageBBox(pageno)
local hash = "renderpg|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..tostring(self.cur_bbox)
local page_size = self:getPageDimensions(doc, pageno, zoom, rotation) local page_size = self:getPageDimensions(doc, 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
@ -242,7 +243,7 @@ function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, render_mode
return return
end end
-- only render required part -- only render required part
hash = "renderpg|"..doc.file.."|"..pageno.."|"..doc.configurable:hash('|').."|"..tostring(rect) hash = "renderpg|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..tostring(rect)
size = rect size = rect
end end
@ -258,7 +259,7 @@ function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, render_mode
} }
-- draw to blitbuffer -- draw to blitbuffer
local kc_hash = "kctx|"..doc.file.."|"..pageno.."|"..doc.configurable:hash('|') local kc_hash = "kctx|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..tostring(self.cur_bbox)
local page = doc._document:openPage(pageno) local page = doc._document:openPage(pageno)
local cached = Cache:check(kc_hash) local cached = Cache:check(kc_hash)
if cached then if cached then

Loading…
Cancel
Save