mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
serialize the most recently used blitbuffer/koptcontext
to speedup koreader startup for PDF/DJVU documents especially when reflowing
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
local Blitbuffer = require("ffi/blitbuffer")
|
||||
local CacheItem = require("cacheitem")
|
||||
local serial = require("serialize")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
local TileCacheItem = CacheItem:new{}
|
||||
@@ -10,4 +12,19 @@ function TileCacheItem:onFree()
|
||||
end
|
||||
end
|
||||
|
||||
function TileCacheItem:dump(filename)
|
||||
DEBUG("dumping tile cache to", filename, self.excerpt)
|
||||
return serial.dump(self.size, self.excerpt, self.pageno,
|
||||
self.bb.w, self.bb.h, self.bb.pitch, self.bb:getType(),
|
||||
Blitbuffer.tostring(self.bb), filename)
|
||||
end
|
||||
|
||||
function TileCacheItem:load(filename)
|
||||
local w, h, pitch, bb_type, bb_data
|
||||
self.size, self.excerpt, self.pageno,
|
||||
w, h, pitch, bb_type, bb_data = serial.load(filename)
|
||||
self.bb = Blitbuffer.fromstring(w, h, bb_type, bb_data, pitch)
|
||||
DEBUG("loading tile cache from", filename, self)
|
||||
end
|
||||
|
||||
return TileCacheItem
|
||||
|
||||
Reference in New Issue
Block a user