save two blitbuffer memory allocations for crengine on each page turn

One for drawbuffer at CreDocument:drawCurrentView and another for
resizing of drawBuf at cre.drawCurrentPage.
This commit is contained in:
chrox
2014-10-27 22:03:20 +08:00
parent f7cf20f86b
commit c2726a8f62
3 changed files with 11 additions and 6 deletions

View File

@@ -212,10 +212,15 @@ function CreDocument:getScreenBoxesFromPositions(pos0, pos1)
end
function CreDocument:drawCurrentView(target, x, y, rect, pos)
tile_bb = Blitbuffer.new(rect.w, rect.h)
self._document:drawCurrentPage(tile_bb)
target:blitFrom(tile_bb, x, y, 0, 0, rect.w, rect.h)
tile_bb:free()
if self.buffer and (self.buffer.w ~= rect.w or self.buffer.h ~= rect.h) then
self.buffer:free()
self.buffer = nil
end
if not self.buffer then
self.buffer = Blitbuffer.new(rect.w, rect.h)
end
self._document:drawCurrentPage(self.buffer)
target:blitFrom(self.buffer, x, y, 0, 0, rect.w, rect.h)
end
function CreDocument:drawCurrentViewByPos(target, x, y, rect, pos)