From f4eb9e79829dd12ffde67de4dd8723eb0744cfd5 Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 12 Nov 2012 01:38:13 +0800 Subject: [PATCH] bugfix: update cur_bbox with correct page number when doing precache Otherwise with the wrong pagehash the precache will be invalid and page need to be reflowed twice. --- koptreader.lua | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/koptreader.lua b/koptreader.lua index 88ec44951..4c05eb5fa 100644 --- a/koptreader.lua +++ b/koptreader.lua @@ -229,7 +229,7 @@ function KOPTReader:drawOrCache(no, preCache) return nil end - local kc = self:getContext(page, preCache) + local kc = self:getContext(page, no, preCache) -- check if we have relevant cache contents local bbox = self.cur_bbox @@ -351,7 +351,7 @@ function KOPTReader:drawOrCache(no, preCache) end -- get reflow context -function KOPTReader:getContext(page, preCache) +function KOPTReader:getContext(page, pnumber, preCache) local kc = self:makeContext() local pwidth, pheight = page:getSize(self.nulldc) local width, height = G_width, G_height @@ -378,21 +378,21 @@ function KOPTReader:getContext(page, preCache) if self.bbox.enabled then Debug("ORIGINAL page::getUsedBBox", x0,y0, x1,y1 ) - local bbox = self.bbox[self.pageno] -- exact + local bbox = self.bbox[pnumber] -- exact - local oddEven = self:oddEven(self.pageno) + local oddEven = self:oddEven(pnumber) if bbox ~= nil then - Debug("bbox from", self.pageno) + Debug("bbox from", pnumber) else bbox = self.bbox[oddEven] -- odd/even end if bbox ~= nil then -- last used up to this page Debug("bbox from", oddEven) else - for i = 0,self.pageno do - bbox = self.bbox[ self.pageno - i ] + for i = 0,pnumber do + bbox = self.bbox[ pnumber - i ] if bbox ~= nil then - Debug("bbox from", self.pageno - i) + Debug("bbox from", pnumber - i) break end end @@ -411,19 +411,14 @@ function KOPTReader:getContext(page, preCache) else kc:setBBox(x0, y0, x1, y1) end - - if not preCache then -- save current page fullsize - self.cur_full_width = self.fullwidth - self.cur_full_height = self.fullheight - self.cur_bbox = { - ["x0"] = x0, - ["y0"] = y0, - ["x1"] = x1, - ["y1"] = y1, - } - Debug("cur_bbox", self.cur_bbox) - end + self.cur_bbox = { + ["x0"] = x0, + ["y0"] = y0, + ["x1"] = x1, + ["y1"] = y1, + } + Debug("cur_bbox", self.cur_bbox) return kc end