mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
control renderer memory usage #80
added setCacheSize and cache_document_size configuration vairable
This commit is contained in:
9
djvu.c
9
djvu.c
@@ -455,6 +455,14 @@ static int getCacheSize(lua_State *L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int setCacheSize(lua_State *L) {
|
||||
DjvuDocument *doc = (DjvuDocument*) luaL_checkudata(L, 1, "djvudocument");
|
||||
int size = luaL_checkint(L, 2);
|
||||
printf("ddjvu_cache_set_size = %d\n", size);
|
||||
ddjvu_cache_set_size(doc->context, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct luaL_Reg djvu_func[] = {
|
||||
{"openDocument", openDocument},
|
||||
{NULL, NULL}
|
||||
@@ -467,6 +475,7 @@ static const struct luaL_Reg djvudocument_meth[] = {
|
||||
{"getPageText", getPageText},
|
||||
{"close", closeDocument},
|
||||
{"getCacheSize", getCacheSize},
|
||||
{"setCacheSize", setCacheSize},
|
||||
{"__gc", closeDocument},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -72,6 +72,8 @@ UniReader = {
|
||||
-- tile cache state:
|
||||
cache_current_memsize = 0,
|
||||
cache = {},
|
||||
-- renderer cache size
|
||||
cache_document_size = 1024*1024*8, -- FIXME random, needs testing
|
||||
|
||||
pagehash = nil,
|
||||
|
||||
@@ -134,6 +136,11 @@ function UniReader:getCacheSize()
|
||||
return -1
|
||||
end
|
||||
|
||||
function UniReader:setCacheSize(size)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--[ following are default methods ]--
|
||||
|
||||
function UniReader:loadSettings(filename)
|
||||
@@ -158,6 +165,8 @@ function UniReader:loadSettings(filename)
|
||||
self.globalzoom = self.settings:readSetting("globalzoom") or 1.0
|
||||
self.globalzoommode = self.settings:readSetting("globalzoommode") or -1
|
||||
|
||||
self.doc:setCacheSize( self.cache_document_size )
|
||||
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user