From 7af80f63f6f40dcc51c4ca8ae6da82c570299554 Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 11 Feb 2013 00:51:55 +0800 Subject: [PATCH] check screen mode in koptinterface --- frontend/document/koptinterface.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/document/koptinterface.lua b/frontend/document/koptinterface.lua index a3d4ebb14..b29257b12 100644 --- a/frontend/document/koptinterface.lua +++ b/frontend/document/koptinterface.lua @@ -191,12 +191,13 @@ KoptInterface = {} -- get reflow context function KoptInterface:getKOPTContext(doc, pageno, bbox) 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) kc:setRotate(doc.configurable.screen_rotation) kc:setColumns(doc.configurable.max_columns) - kc:setDeviceDim(doc.screen_size.w, doc.screen_size.h) + kc:setDeviceDim(screen_size.w, screen_size.h) kc:setDeviceDPI(doc.screen_dpi) kc:setStraighten(doc.configurable.auto_straighten) kc:setJustification(doc.configurable.justification) @@ -215,8 +216,9 @@ end function KoptInterface:getPageDimensions(doc, pageno, zoom, rotation) -- check cached page size self.cur_bbox = doc:getPageBBox(pageno) - local bbox = self.cur_bbox - local hash = "kctx|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..bbox.x0.."|"..bbox.y0.."|"..bbox.x1.."|"..bbox.y1 + 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 cached = Cache:check(hash) if not cached then local kc = self:getKOPTContext(doc, pageno, self.cur_bbox) @@ -240,8 +242,9 @@ end function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, render_mode) doc.render_mode = render_mode self.cur_bbox = doc:getPageBBox(pageno) - local bbox = self.cur_bbox - local hash = "renderpg|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..bbox.x0.."|"..bbox.y0.."|"..bbox.x1.."|"..bbox.y1 + 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 page_size = self:getPageDimensions(doc, pageno, zoom, rotation) -- this will be the size we actually render local size = page_size @@ -272,13 +275,13 @@ function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, render_mode } -- draw to blitbuffer - local kc_hash = "kctx|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..bbox.x0.."|"..bbox.y0.."|"..bbox.x1.."|"..bbox.y1 + local kc_hash = "kctx|"..doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..bbox_hash.."|"..self.screen_mode local page = doc._document:openPage(pageno) local cached = Cache:check(kc_hash) if cached then page:rfdraw(cached.kctx, tile.bb) page:close() - DEBUG("cached hash", hash) + --DEBUG("cached hash", hash) if not Cache:check(hash) then Cache:insert(hash, tile) end @@ -289,7 +292,7 @@ end function KoptInterface:drawPage(doc, target, x, y, rect, pageno, zoom, rotation, render_mode) local tile = self:renderPage(doc, pageno, rect, zoom, rotation, render_mode) - DEBUG("now painting", tile, rect) + --DEBUG("now painting", tile, rect) target:blitFrom(tile.bb, x, y, rect.x - tile.excerpt.x,