From 4675a220d8789dd4fe3bf5fc42fd29270c80e97e Mon Sep 17 00:00:00 2001 From: chrox Date: Sun, 3 Feb 2013 21:36:11 +0800 Subject: [PATCH] add current bbox in page rendering hash So that changing bbox could take effect on current page. --- frontend/document/koptinterface.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/frontend/document/koptinterface.lua b/frontend/document/koptinterface.lua index 9f12e7530..0c5abc44c 100644 --- a/frontend/document/koptinterface.lua +++ b/frontend/document/koptinterface.lua @@ -178,7 +178,7 @@ KoptOptions = { KoptInterface = {} -- get reflow context -function KoptInterface:getKOPTContext(doc, pageno) +function KoptInterface:getKOPTContext(doc, pageno, bbox) local kc = KOPTContext.new() kc:setTrim(doc.configurable.trim_page) kc:setWrap(doc.configurable.text_wrap) @@ -196,7 +196,6 @@ function KoptInterface:getKOPTContext(doc, pageno) kc:setDefectSize(doc.configurable.defect_size) kc:setLineSpacing(doc.configurable.line_spacing) kc:setWordSpacing(doc.configurable.word_spacing) - local bbox = doc:getPageBBox(pageno) kc:setBBox(bbox.x0, bbox.y0, bbox.x1, bbox.y1) return kc end @@ -204,10 +203,11 @@ end -- calculates page dimensions function KoptInterface:getPageDimensions(doc, pageno, zoom, rotation) -- 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) 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) -- reflow page page:reflow(kc, 0) @@ -227,7 +227,8 @@ end function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, 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) -- this will be the size we actually render local size = page_size @@ -242,7 +243,7 @@ function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, render_mode return end -- 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 end @@ -258,7 +259,7 @@ function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, render_mode } -- 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 cached = Cache:check(kc_hash) if cached then