mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
add current bbox in page rendering hash
So that changing bbox could take effect on current page.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user