2
0
mirror of https://github.com/koreader/koreader synced 2024-11-13 19:11:25 +00:00
koreader/frontend/document/tilecacheitem.lua

31 lines
958 B
Lua
Raw Normal View History

local Blitbuffer = require("ffi/blitbuffer")
2013-10-18 20:38:07 +00:00
local CacheItem = require("cacheitem")
local serial = require("serialize")
local logger = require("logger")
2013-10-18 20:38:07 +00:00
local TileCacheItem = CacheItem:new{}
function TileCacheItem:onFree()
2014-03-13 13:52:43 +00:00
if self.bb.free then
logger.dbg("free blitbuffer", self.bb)
2014-03-13 13:52:43 +00:00
self.bb:free()
end
2013-10-18 20:38:07 +00:00
end
function TileCacheItem:dump(filename)
logger.dbg("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)
logger.dbg("loading tile cache from", filename, self)
end
2013-10-18 20:38:07 +00:00
return TileCacheItem