show djvu cache size #80

Currently it shows cache_max_memsize and cache_item_max_pixels from
lua and djvu cache size on menu key
pull/2/merge
Dobrica Pavlinusic 13 years ago
parent dbeef1b4c2
commit 92ec4213c0

@ -447,6 +447,14 @@ static int drawPage(lua_State *L) {
return 0; return 0;
} }
static int getCacheSize(lua_State *L) {
DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument");
unsigned long size = ddjvu_cache_get_size(doc->context);
printf("ddjvu_cache_get_size = %d\n", size);
lua_pushnumber(L, size);
return 1;
}
static const struct luaL_Reg djvu_func[] = { static const struct luaL_Reg djvu_func[] = {
{"openDocument", openDocument}, {"openDocument", openDocument},
{NULL, NULL} {NULL, NULL}
@ -458,6 +466,7 @@ static const struct luaL_Reg djvudocument_meth[] = {
{"getTOC", getTableOfContent}, {"getTOC", getTableOfContent},
{"getPageText", getPageText}, {"getPageText", getPageText},
{"close", closeDocument}, {"close", closeDocument},
{"getCacheSize", getCacheSize},
{"__gc", closeDocument}, {"__gc", closeDocument},
{NULL, NULL} {NULL, NULL}
}; };

@ -126,6 +126,13 @@ function UniReader:toggleTextHighLight(word_list)
return return
end end
----------------------------------------------------
-- renderer memory
----------------------------------------------------
function UniReader:getCacheSize()
return -1
end
--[ following are default methods ]-- --[ following are default methods ]--
@ -799,7 +806,7 @@ function UniReader:showMenu()
end end
renderUtf8Text(fb.bb, 10, ypos+6, face, fhash, renderUtf8Text(fb.bb, 10, ypos+6, face, fhash,
"Page: "..self.pageno.."/"..self.doc:getPages().. "Page: "..self.pageno.."/"..self.doc:getPages()..
" "..cur_section, true) " "..cur_section.." Memory: "..( self.cache_max_memsize / 1024 ).." "..( self.cache_item_max_pixels / 1024 ).." "..( self.doc:getCacheSize() / 1024 ).." k", true)
ypos = ypos + 15 ypos = ypos + 15
blitbuffer.progressBar(fb.bb, 10, ypos, width-20, 15, blitbuffer.progressBar(fb.bb, 10, ypos, width-20, 15,

Loading…
Cancel
Save