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

31 lines
939 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")
2013-10-22 18:51:29 +00:00
local DEBUG = require("dbg")
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
DEBUG("free blitbuffer", self.bb)
self.bb:free()
end
2013-10-18 20:38:07 +00:00
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
2013-10-18 20:38:07 +00:00
return TileCacheItem