2013-04-23 22:59:52 +00:00
|
|
|
require "dbg"
|
2013-01-03 14:24:38 +00:00
|
|
|
require "cache"
|
|
|
|
require "ui/geometry"
|
|
|
|
require "ui/device"
|
|
|
|
require "ui/reader/readerconfig"
|
|
|
|
|
2013-04-23 22:59:52 +00:00
|
|
|
KoptInterface = {
|
|
|
|
tessocr_data = "data",
|
|
|
|
ocr_lang = "eng",
|
2013-04-30 05:52:10 +00:00
|
|
|
ocr_type = 3, -- default 0, for more accuracy use 3
|
2013-04-23 22:59:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ContextCacheItem = CacheItem:new{}
|
|
|
|
|
|
|
|
function ContextCacheItem:onFree()
|
|
|
|
if self.kctx.free then
|
|
|
|
DEBUG("free koptcontext", self.kctx)
|
|
|
|
self.kctx:free()
|
|
|
|
end
|
|
|
|
end
|
2013-03-12 12:26:02 +00:00
|
|
|
|
2013-04-30 05:52:10 +00:00
|
|
|
OCREngine = CacheItem:new{}
|
|
|
|
|
|
|
|
function OCREngine:onFree()
|
|
|
|
if self.ocrengine.freeOCR then
|
|
|
|
DEBUG("free OCREngine", self.ocrengine)
|
|
|
|
self.ocrengine:freeOCR()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-12 12:26:02 +00:00
|
|
|
function KoptInterface:waitForContext(kc)
|
2013-04-08 07:38:04 +00:00
|
|
|
-- if koptcontext is being processed in background thread
|
2013-03-12 12:26:02 +00:00
|
|
|
-- the isPreCache will return 1.
|
|
|
|
while kc and kc:isPreCache() == 1 do
|
|
|
|
DEBUG("waiting for background rendering")
|
|
|
|
util.usleep(100000)
|
|
|
|
end
|
2013-04-23 22:59:52 +00:00
|
|
|
return kc
|
2013-03-12 12:26:02 +00:00
|
|
|
end
|
|
|
|
|
2013-04-23 22:59:52 +00:00
|
|
|
--[[
|
|
|
|
get reflow context
|
|
|
|
--]]
|
|
|
|
function KoptInterface:createContext(doc, pageno, bbox)
|
2013-04-20 08:12:43 +00:00
|
|
|
-- Now koptcontext keeps track of its dst bitmap reflowed by libk2pdfopt.
|
|
|
|
-- So there is no need to check background context when creating new context.
|
2013-01-03 14:24:38 +00:00
|
|
|
local kc = KOPTContext.new()
|
2013-02-25 13:29:41 +00:00
|
|
|
local screen_size = Screen:getSize()
|
2013-01-03 14:24:38 +00:00
|
|
|
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)
|
2013-02-10 16:51:55 +00:00
|
|
|
kc:setDeviceDim(screen_size.w, screen_size.h)
|
2013-01-03 14:24:38 +00:00
|
|
|
kc:setDeviceDPI(doc.screen_dpi)
|
|
|
|
kc:setStraighten(doc.configurable.auto_straighten)
|
|
|
|
kc:setJustification(doc.configurable.justification)
|
|
|
|
kc:setZoom(doc.configurable.font_size)
|
|
|
|
kc:setMargin(doc.configurable.page_margin)
|
|
|
|
kc:setQuality(doc.configurable.quality)
|
|
|
|
kc:setContrast(doc.configurable.contrast)
|
|
|
|
kc:setDefectSize(doc.configurable.defect_size)
|
|
|
|
kc:setLineSpacing(doc.configurable.line_spacing)
|
|
|
|
kc:setWordSpacing(doc.configurable.word_spacing)
|
2013-07-19 18:46:51 +00:00
|
|
|
kc:setLanguage(doc.configurable.doc_language)
|
2013-01-03 14:24:38 +00:00
|
|
|
kc:setBBox(bbox.x0, bbox.y0, bbox.x1, bbox.y1)
|
2013-04-23 22:59:52 +00:00
|
|
|
if Dbg.is_on then kc:setDebug() end
|
2013-01-03 14:24:38 +00:00
|
|
|
return kc
|
|
|
|
end
|
|
|
|
|
2013-02-25 13:29:41 +00:00
|
|
|
function KoptInterface:getContextHash(doc, pageno, bbox)
|
|
|
|
local screen_size = Screen:getSize()
|
|
|
|
local screen_size_hash = screen_size.w.."|"..screen_size.h
|
|
|
|
local bbox_hash = bbox.x0.."|"..bbox.y0.."|"..bbox.x1.."|"..bbox.y1
|
|
|
|
return doc.file.."|"..pageno.."|"..doc.configurable:hash("|").."|"..bbox_hash.."|"..screen_size_hash
|
|
|
|
end
|
|
|
|
|
2013-04-14 07:16:42 +00:00
|
|
|
function KoptInterface:getAutoBBox(doc, pageno)
|
2013-07-19 18:51:17 +00:00
|
|
|
local native_size = Document.getNativePageDimensions(doc, pageno)
|
2013-07-13 03:18:49 +00:00
|
|
|
local bbox = {
|
|
|
|
x0 = 0, y0 = 0,
|
2013-07-19 18:51:17 +00:00
|
|
|
x1 = native_size.w,
|
|
|
|
y1 = native_size.h,
|
2013-07-13 03:18:49 +00:00
|
|
|
}
|
|
|
|
local context_hash = self:getContextHash(doc, pageno, bbox)
|
|
|
|
local hash = "autobbox|"..context_hash
|
|
|
|
local cached = Cache:check(hash)
|
|
|
|
if not cached then
|
|
|
|
local page = doc._document:openPage(pageno)
|
|
|
|
local kc = self:createContext(doc, pageno, bbox)
|
|
|
|
bbox.x0, bbox.y0, bbox.x1, bbox.y1 = page:getAutoBBox(kc)
|
|
|
|
DEBUG("Auto detected bbox", bbox)
|
|
|
|
page:close()
|
|
|
|
Cache:insert(hash, CacheItem:new{ autobbox = bbox })
|
|
|
|
return bbox
|
|
|
|
else
|
|
|
|
return cached.autobbox
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function KoptInterface:getSemiAutoBBox(doc, pageno)
|
2013-07-09 11:15:45 +00:00
|
|
|
-- use manual bbox
|
|
|
|
local bbox = Document.getPageBBox(doc, pageno)
|
2013-04-14 07:16:42 +00:00
|
|
|
local context_hash = self:getContextHash(doc, pageno, bbox)
|
2013-07-13 03:18:49 +00:00
|
|
|
local hash = "semiautobbox|"..context_hash
|
2013-04-14 07:16:42 +00:00
|
|
|
local cached = Cache:check(hash)
|
|
|
|
if not cached then
|
|
|
|
local page = doc._document:openPage(pageno)
|
2013-04-23 22:59:52 +00:00
|
|
|
local kc = self:createContext(doc, pageno, bbox)
|
2013-07-09 11:15:45 +00:00
|
|
|
local auto_bbox = {}
|
|
|
|
auto_bbox.x0, auto_bbox.y0, auto_bbox.x1, auto_bbox.y1 = page:getAutoBBox(kc)
|
|
|
|
auto_bbox.x0 = auto_bbox.x0 + bbox.x0
|
|
|
|
auto_bbox.y0 = auto_bbox.y0 + bbox.y0
|
|
|
|
auto_bbox.x1 = auto_bbox.x1 + bbox.x0
|
|
|
|
auto_bbox.y1 = auto_bbox.y1 + bbox.y0
|
2013-07-13 03:18:49 +00:00
|
|
|
DEBUG("Semi-auto detected bbox", auto_bbox)
|
2013-04-14 07:16:42 +00:00
|
|
|
page:close()
|
2013-07-13 03:18:49 +00:00
|
|
|
Cache:insert(hash, CacheItem:new{ semiautobbox = auto_bbox })
|
2013-07-09 11:15:45 +00:00
|
|
|
return auto_bbox
|
2013-04-14 07:16:42 +00:00
|
|
|
else
|
2013-07-13 03:18:49 +00:00
|
|
|
return cached.semiautobbox
|
2013-04-23 22:59:52 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-05-01 15:43:53 +00:00
|
|
|
function KoptInterface:getReflewTextBoxes(doc, pageno)
|
2013-04-23 22:59:52 +00:00
|
|
|
local bbox = doc:getPageBBox(pageno)
|
|
|
|
local context_hash = self:getContextHash(doc, pageno, bbox)
|
2013-05-01 15:43:53 +00:00
|
|
|
local hash = "rfpgboxes|"..context_hash
|
2013-04-23 22:59:52 +00:00
|
|
|
local cached = Cache:check(hash)
|
|
|
|
if not cached then
|
|
|
|
local kctx_hash = "kctx|"..context_hash
|
|
|
|
local cached = Cache:check(kctx_hash)
|
|
|
|
if cached then
|
|
|
|
local kc = self:waitForContext(cached.kctx)
|
2013-07-19 18:46:51 +00:00
|
|
|
--kc:setDebug()
|
|
|
|
local lang = doc.configurable.doc_language
|
|
|
|
if lang == "chi_sim" or lang == "chi_tra" or
|
|
|
|
lang == "jpn" or lang == "kor" then
|
|
|
|
kc:setCJKChar()
|
|
|
|
end
|
|
|
|
kc:setLanguage(lang)
|
2013-04-23 22:59:52 +00:00
|
|
|
local fullwidth, fullheight = kc:getPageDim()
|
2013-05-01 15:43:53 +00:00
|
|
|
local boxes = kc:getWordBoxes(0, 0, fullwidth, fullheight)
|
|
|
|
Cache:insert(hash, CacheItem:new{ rfpgboxes = boxes })
|
|
|
|
return boxes
|
2013-04-23 22:59:52 +00:00
|
|
|
end
|
|
|
|
else
|
2013-05-01 15:43:53 +00:00
|
|
|
return cached.rfpgboxes
|
2013-04-14 07:16:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-05-01 15:43:53 +00:00
|
|
|
function KoptInterface:getTextBoxes(doc, pageno)
|
|
|
|
local hash = "pgboxes|"..doc.file.."|"..pageno
|
|
|
|
local cached = Cache:check(hash)
|
|
|
|
if not cached then
|
|
|
|
local kc_hash = "kctx|"..doc.file.."|"..pageno
|
|
|
|
local kc = KOPTContext.new()
|
|
|
|
kc:setDebug()
|
2013-07-19 18:46:51 +00:00
|
|
|
local lang = doc.configurable.doc_language
|
|
|
|
if lang == "chi_sim" or lang == "chi_tra" or
|
|
|
|
lang == "jpn" or lang == "kor" then
|
|
|
|
kc:setCJKChar()
|
|
|
|
end
|
|
|
|
kc:setLanguage(lang)
|
2013-05-01 15:43:53 +00:00
|
|
|
local page = doc._document:openPage(pageno)
|
|
|
|
page:getPagePix(kc)
|
|
|
|
local fullwidth, fullheight = kc:getPageDim()
|
|
|
|
local boxes = kc:getWordBoxes(0, 0, fullwidth, fullheight)
|
|
|
|
Cache:insert(hash, CacheItem:new{ pgboxes = boxes })
|
|
|
|
Cache:insert(kc_hash, ContextCacheItem:new{ kctx = kc })
|
|
|
|
return boxes
|
|
|
|
else
|
|
|
|
return cached.pgboxes
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[
|
|
|
|
get word from OCR in reflew page
|
|
|
|
--]]
|
|
|
|
function KoptInterface:getReflewOCRWord(doc, pageno, rect)
|
2013-04-30 05:52:10 +00:00
|
|
|
local ocrengine = "ocrengine"
|
|
|
|
if not Cache:check(ocrengine) then
|
|
|
|
local dummy = KOPTContext.new()
|
|
|
|
Cache:insert(ocrengine, OCREngine:new{ ocrengine = dummy })
|
|
|
|
end
|
2013-07-19 18:46:51 +00:00
|
|
|
self.ocr_lang = doc.configurable.doc_language
|
2013-04-23 22:59:52 +00:00
|
|
|
local bbox = doc:getPageBBox(pageno)
|
|
|
|
local context_hash = self:getContextHash(doc, pageno, bbox)
|
2013-05-01 15:43:53 +00:00
|
|
|
local hash = "rfocrword|"..context_hash..rect.x..rect.y..rect.w..rect.h
|
2013-04-23 22:59:52 +00:00
|
|
|
local cached = Cache:check(hash)
|
|
|
|
if not cached then
|
|
|
|
local kctx_hash = "kctx|"..context_hash
|
|
|
|
local cached = Cache:check(kctx_hash)
|
|
|
|
if cached then
|
|
|
|
local kc = self:waitForContext(cached.kctx)
|
2013-05-01 15:43:53 +00:00
|
|
|
local ok, word = pcall(
|
|
|
|
kc.getTOCRWord, kc,
|
|
|
|
rect.x, rect.y, rect.w, rect.h,
|
|
|
|
self.tessocr_data, self.ocr_lang, self.ocr_type, 0, 1)
|
|
|
|
Cache:insert(hash, CacheItem:new{ rfocrword = word })
|
|
|
|
return word
|
|
|
|
end
|
|
|
|
else
|
|
|
|
return cached.rfocrword
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[
|
|
|
|
get word from OCR in non-reflew page
|
|
|
|
--]]
|
|
|
|
function KoptInterface:getOCRWord(doc, pageno, rect)
|
|
|
|
local ocrengine = "ocrengine"
|
|
|
|
if not Cache:check(ocrengine) then
|
|
|
|
local dummy = KOPTContext.new()
|
|
|
|
Cache:insert(ocrengine, OCREngine:new{ ocrengine = dummy })
|
|
|
|
end
|
2013-07-19 18:46:51 +00:00
|
|
|
self.ocr_lang = doc.configurable.doc_language
|
2013-05-01 15:43:53 +00:00
|
|
|
local hash = "ocrword|"..doc.file.."|"..pageno..rect.x..rect.y..rect.w..rect.h
|
|
|
|
local cached = Cache:check(hash)
|
|
|
|
if not cached then
|
|
|
|
local pgboxes_hash = "pgboxes|"..doc.file.."|"..pageno
|
|
|
|
local pgboxes_cached = Cache:check(pgboxes_hash)
|
|
|
|
local kc_hash = "kctx|"..doc.file.."|"..pageno
|
|
|
|
local kc_cashed = Cache:check(kc_hash)
|
|
|
|
if pgboxes_cached and kc_cashed then
|
|
|
|
local kc = kc_cashed.kctx
|
2013-04-23 22:59:52 +00:00
|
|
|
local ok, word = pcall(
|
2013-04-30 05:52:10 +00:00
|
|
|
kc.getTOCRWord, kc,
|
|
|
|
rect.x, rect.y, rect.w, rect.h,
|
|
|
|
self.tessocr_data, self.ocr_lang, self.ocr_type, 0, 1)
|
2013-04-23 22:59:52 +00:00
|
|
|
Cache:insert(hash, CacheItem:new{ ocrword = word })
|
|
|
|
return word
|
|
|
|
end
|
|
|
|
else
|
|
|
|
return cached.ocrword
|
|
|
|
end
|
2013-03-12 12:26:02 +00:00
|
|
|
end
|
|
|
|
|
2013-04-23 22:59:52 +00:00
|
|
|
--[[
|
|
|
|
get cached koptcontext for centain page. if context doesn't exist in cache make
|
2013-07-01 06:41:33 +00:00
|
|
|
new context and reflow the src page immediatly, or wait background thread for
|
2013-04-23 22:59:52 +00:00
|
|
|
reflowed context.
|
|
|
|
--]]
|
2013-04-20 08:12:43 +00:00
|
|
|
function KoptInterface:getCachedContext(doc, pageno)
|
2013-02-11 17:15:19 +00:00
|
|
|
local bbox = doc:getPageBBox(pageno)
|
2013-02-25 13:29:41 +00:00
|
|
|
local context_hash = self:getContextHash(doc, pageno, bbox)
|
2013-04-20 08:12:43 +00:00
|
|
|
local kctx_hash = "kctx|"..context_hash
|
|
|
|
local cached = Cache:check(kctx_hash)
|
2013-01-03 14:24:38 +00:00
|
|
|
if not cached then
|
2013-04-20 08:12:43 +00:00
|
|
|
-- If kctx is not cached, create one and get reflowed bmp in foreground.
|
2013-04-23 22:59:52 +00:00
|
|
|
local kc = self:createContext(doc, pageno, bbox)
|
2013-01-03 14:24:38 +00:00
|
|
|
local page = doc._document:openPage(pageno)
|
|
|
|
-- reflow page
|
2013-03-11 08:24:27 +00:00
|
|
|
--local secs, usecs = util.gettime()
|
2013-01-03 14:24:38 +00:00
|
|
|
page:reflow(kc, 0)
|
2013-04-20 08:12:43 +00:00
|
|
|
page:close()
|
2013-03-11 08:24:27 +00:00
|
|
|
--local nsecs, nusecs = util.gettime()
|
|
|
|
--local dur = nsecs - secs + (nusecs - usecs) / 1000000
|
|
|
|
--DEBUG("Reflow duration:", dur)
|
|
|
|
--self:logReflowDuration(pageno, dur)
|
2013-01-03 14:24:38 +00:00
|
|
|
local fullwidth, fullheight = kc:getPageDim()
|
2013-04-20 08:12:43 +00:00
|
|
|
DEBUG("reflowed page", pageno, "fullwidth:", fullwidth, "fullheight:", fullheight)
|
2013-04-23 22:59:52 +00:00
|
|
|
Cache:insert(kctx_hash, ContextCacheItem:new{ kctx = kc })
|
2013-04-20 08:12:43 +00:00
|
|
|
return kc
|
|
|
|
else
|
2013-04-23 22:59:52 +00:00
|
|
|
-- wait for background thread
|
|
|
|
return self:waitForContext(cached.kctx)
|
2013-01-03 14:24:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-04-23 22:59:52 +00:00
|
|
|
--[[
|
|
|
|
get reflowed page dimensions
|
|
|
|
--]]
|
2013-04-20 08:12:43 +00:00
|
|
|
function KoptInterface:getPageDimensions(doc, pageno, zoom, rotation)
|
2013-04-23 22:59:52 +00:00
|
|
|
local kc = self:getCachedContext(doc, pageno)
|
|
|
|
local fullwidth, fullheight = kc:getPageDim()
|
2013-04-20 08:12:43 +00:00
|
|
|
return Geom:new{ w = fullwidth, h = fullheight }
|
|
|
|
end
|
|
|
|
|
2013-04-23 22:59:52 +00:00
|
|
|
--[[
|
|
|
|
inherited from common document interface
|
|
|
|
render reflowed page into tile cache.
|
|
|
|
--]]
|
2013-04-20 08:12:43 +00:00
|
|
|
function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, render_mode)
|
|
|
|
doc.render_mode = render_mode
|
|
|
|
local bbox = doc:getPageBBox(pageno)
|
|
|
|
local context_hash = self:getContextHash(doc, pageno, bbox)
|
|
|
|
local renderpg_hash = "renderpg|"..context_hash
|
|
|
|
|
|
|
|
local cached = Cache:check(renderpg_hash)
|
|
|
|
if not cached then
|
|
|
|
-- do the real reflowing if kctx is not been cached yet
|
2013-04-23 22:59:52 +00:00
|
|
|
local kc = self:getCachedContext(doc, pageno)
|
|
|
|
local fullwidth, fullheight = kc:getPageDim()
|
2013-04-20 08:12:43 +00:00
|
|
|
if not Cache:willAccept(fullwidth * fullheight / 2) then
|
|
|
|
-- whole page won't fit into cache
|
|
|
|
error("aborting, since we don't have enough cache for this page")
|
|
|
|
end
|
|
|
|
local page = doc._document:openPage(pageno)
|
2013-04-08 07:38:04 +00:00
|
|
|
-- prepare cache item with contained blitbuffer
|
2013-03-12 12:26:02 +00:00
|
|
|
local tile = CacheItem:new{
|
|
|
|
size = fullwidth * fullheight / 2 + 64, -- estimation
|
|
|
|
excerpt = Geom:new{ w = fullwidth, h = fullheight },
|
|
|
|
pageno = pageno,
|
|
|
|
bb = Blitbuffer.new(fullwidth, fullheight)
|
|
|
|
}
|
2013-04-23 22:59:52 +00:00
|
|
|
page:rfdraw(kc, tile.bb)
|
2013-03-12 12:26:02 +00:00
|
|
|
page:close()
|
2013-04-20 08:12:43 +00:00
|
|
|
Cache:insert(renderpg_hash, tile)
|
2013-03-12 12:26:02 +00:00
|
|
|
return tile
|
|
|
|
else
|
2013-04-20 08:12:43 +00:00
|
|
|
return cached
|
2013-03-12 12:26:02 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-04-23 22:59:52 +00:00
|
|
|
--[[
|
2013-07-01 06:41:33 +00:00
|
|
|
inherited from common document interface render reflowed page into cache in
|
|
|
|
background thread. this method returns immediatly leaving the precache flag on
|
|
|
|
in context. subsequent usage of this context should wait for the precache flag
|
|
|
|
off by calling self:waitForContext(kctx)
|
2013-04-23 22:59:52 +00:00
|
|
|
--]]
|
2013-03-12 12:26:02 +00:00
|
|
|
function KoptInterface:hintPage(doc, pageno, zoom, rotation, gamma, render_mode)
|
|
|
|
local bbox = doc:getPageBBox(pageno)
|
|
|
|
local context_hash = self:getContextHash(doc, pageno, bbox)
|
2013-04-20 08:12:43 +00:00
|
|
|
local kctx_hash = "kctx|"..context_hash
|
|
|
|
local cached = Cache:check(kctx_hash)
|
2013-03-12 12:26:02 +00:00
|
|
|
if not cached then
|
2013-04-23 22:59:52 +00:00
|
|
|
local kc = self:createContext(doc, pageno, bbox)
|
2013-03-12 12:26:02 +00:00
|
|
|
local page = doc._document:openPage(pageno)
|
|
|
|
DEBUG("hinting page", pageno, "in background")
|
2013-04-20 08:12:43 +00:00
|
|
|
-- reflow will return immediately and running in background thread
|
|
|
|
kc:setPreCache()
|
2013-03-12 12:26:02 +00:00
|
|
|
page:reflow(kc, 0)
|
2013-01-03 14:24:38 +00:00
|
|
|
page:close()
|
2013-04-23 22:59:52 +00:00
|
|
|
Cache:insert(kctx_hash, ContextCacheItem:new{ kctx = kc })
|
2013-01-03 14:24:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-04-23 22:59:52 +00:00
|
|
|
--[[
|
|
|
|
inherited from common document interface
|
|
|
|
draw cached tile pixels into target blitbuffer.
|
|
|
|
--]]
|
2013-01-03 14:24:38 +00:00
|
|
|
function KoptInterface:drawPage(doc, target, x, y, rect, pageno, zoom, rotation, render_mode)
|
|
|
|
local tile = self:renderPage(doc, pageno, rect, zoom, rotation, render_mode)
|
2013-02-10 16:51:55 +00:00
|
|
|
--DEBUG("now painting", tile, rect)
|
2013-01-03 14:24:38 +00:00
|
|
|
target:blitFrom(tile.bb,
|
2013-04-08 07:38:04 +00:00
|
|
|
x, y,
|
2013-01-03 14:24:38 +00:00
|
|
|
rect.x - tile.excerpt.x,
|
|
|
|
rect.y - tile.excerpt.y,
|
|
|
|
rect.w, rect.h)
|
|
|
|
end
|
2013-04-23 22:59:52 +00:00
|
|
|
|
|
|
|
--[[
|
|
|
|
helper functions
|
|
|
|
--]]
|
|
|
|
function KoptInterface:logReflowDuration(pageno, dur)
|
|
|
|
local file = io.open("reflowlog.txt", "a+")
|
|
|
|
if file then
|
|
|
|
if file:seek("end") == 0 then -- write the header only once
|
|
|
|
file:write("PAGE\tDUR\n")
|
|
|
|
end
|
|
|
|
file:write(string.format("%s\t%s\n", pageno, dur))
|
|
|
|
file:close()
|
|
|
|
end
|
|
|
|
end
|