free blitbuffer as soon as tile is kicked out from cache

other than waiting for the lazy garbage collector of lua
This commit is contained in:
chrox
2013-10-13 15:30:42 +08:00
parent 3934176b6c
commit 39da1251ec
2 changed files with 35 additions and 5 deletions

View File

@@ -28,6 +28,14 @@ function DocumentRegistry:openDocument(file)
end
end
TileCacheItem = CacheItem:new{}
function TileCacheItem:onFree()
if self.bb.free then
DEBUG("free blitbuffer", self.bb)
self.bb:free()
end
end
--[[
This is an abstract interface to a document
@@ -216,7 +224,7 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode)
end
-- prepare cache item with contained blitbuffer
local tile = CacheItem:new{
local tile = TileCacheItem:new{
size = size.w * size.h / 2 + 64, -- estimation
excerpt = size,
pageno = pageno,
@@ -296,7 +304,6 @@ function Document:getPageText(pageno)
return text
end
-- load implementations:
require "document/pdfdocument"