From 8764b8aa4fd5c6d624a39fdeb818420d71dffe09 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sun, 1 Apr 2012 00:57:22 +0800 Subject: [PATCH] fix: force freeing biltbuffer on cache evict Also move cache display code above reading progress code. --- unireader.lua | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/unireader.lua b/unireader.lua index db5eed43c..bfee46a41 100644 --- a/unireader.lua +++ b/unireader.lua @@ -210,6 +210,7 @@ function UniReader:cacheClaim(size) else -- cache slot is at end of life, so kick it out self.cache_current_memsize = self.cache_current_memsize - self.cache[k].size + self.cache[k].bb:free() self.cache[k] = nil end end @@ -805,13 +806,22 @@ function UniReader:showHighLight() end function UniReader:showMenu() - local ypos = height - 50 local load_percent = (self.pageno / self.doc:getPages()) + local face, fhash = Font:getFaceAndHash(22) - fb.bb:paintRect(0, ypos, width, 50, 0) + -- display memory on top of page + fb.bb:paintRect(0, 0, width, 15+6*2, 0) + renderUtf8Text(fb.bb, 10, 15+6, face, fhash, + "Memory: ".. + math.ceil( self.cache_current_memsize / 1024 ).."/"..math.ceil( self.cache_max_memsize / 1024 ).. + " "..math.ceil( self.cache_item_max_pixels / 1024 ).." ".. + " "..math.ceil( self.doc:getCacheSize() / 1024 ).."/"..math.ceil( self.cache_document_size / 1024 ).." k", + true) + -- display reading progress on bottom of page + local ypos = height - 50 + fb.bb:paintRect(0, ypos, width, 50, 0) ypos = ypos + 15 - local face, fhash = Font:getFaceAndHash(22) local cur_section = self:getTOCTitleByPage(self.pageno) if cur_section ~= "" then cur_section = "Section: "..cur_section @@ -824,15 +834,6 @@ function UniReader:showMenu() blitbuffer.progressBar(fb.bb, 10, ypos, width-20, 15, 5, 4, load_percent, 8) - -- display memory on top of page - fb.bb:paintRect(0, 0, width, 15+6*2, 0) - renderUtf8Text(fb.bb, 10, 15+6, face, fhash, - "Memory: ".. - math.ceil( self.cache_current_memsize / 1024 ).."/"..math.ceil( self.cache_max_memsize / 1024 ).. - " "..math.ceil( self.cache_item_max_pixels / 1024 ).." ".. - " "..math.ceil( self.doc:getCacheSize() / 1024 ).."/"..math.ceil( self.cache_document_size / 1024 ).." k", - true) - fb:refresh(1) while 1 do local ev = input.waitForEvent()