From 1eb7162796668f2ee0fb8fc1f03b752cdf6fecc4 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Mon, 10 Sep 2012 21:45:05 +0800 Subject: [PATCH] set crengine cache size in lua code --- cre.cpp | 10 ++++++++-- crereader.lua | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cre.cpp b/cre.cpp index 31659b1e2..062c2fbcd 100644 --- a/cre.cpp +++ b/cre.cpp @@ -33,6 +33,13 @@ typedef struct CreDocument { ldomDocument *dom_doc; } CreDocument; +static int initCache(lua_State *L) { + int cache_size = luaL_optint(L, 1, (2 << 20) * 64); // 64Mb on disk cache for DOM + + ldomDocCache::init(lString16("./cr3cache"), cache_size); + + return 0; +} static int openDocument(lua_State *L) { const char *file_name = luaL_checkstring(L, 1); @@ -493,6 +500,7 @@ static int findText(lua_State *L) { } static const struct luaL_Reg cre_func[] = { + {"initCache", initCache}, {"openDocument", openDocument}, {"getFontFaces", getFontFaces}, {"getGammaIndex", getGammaIndex}, @@ -546,8 +554,6 @@ int luaopen_cre(lua_State *L) { /* initialize font manager for CREngine */ InitFontManager(lString8()); - ldomDocCache::init(lString16("./cr3cache"), 1024 * 1024 * 64); // 64Mb on disk cache for DOM - #ifdef DEBUG_CRENGINE CRLog::setStdoutLogger(); CRLog::setLogLevel(CRLog::LL_DEBUG); diff --git a/crereader.lua b/crereader.lua index e761b4b9d..94e356355 100644 --- a/crereader.lua +++ b/crereader.lua @@ -18,6 +18,9 @@ CREReader = UniReader:new{ function CREReader:init() self:addAllCommands() self:adjustCreReaderCommands() + + -- initialize cache + cre.initCache(1024*1024*64) -- we need to initialize the CRE font list local fonts = Font:getFontList() for _k, _v in ipairs(fonts) do