mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
pass cache_document_size to document open
This is how mupdf API is structured
This commit is contained in:
2
pdf.c
2
pdf.c
@@ -166,7 +166,7 @@ static int openDocument(lua_State *L) {
|
||||
char *filename = strdup(luaL_checkstring(L, 1));
|
||||
int cachesize = luaL_optint(L, 2, 64 << 20); // 64 MB limit default
|
||||
char buf[15];
|
||||
printf("cachesize: %s\n",readable_fs(cachesize,buf));
|
||||
printf("## cachesize: %s\n",readable_fs(cachesize,buf));
|
||||
|
||||
PdfDocument *doc = (PdfDocument*) lua_newuserdata(L, sizeof(PdfDocument));
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ function PDFReader:open(filename)
|
||||
-- muPDF manages its own cache, set second parameter
|
||||
-- to the maximum size you want it to grow
|
||||
local ok
|
||||
ok, self.doc = pcall(pdf.openDocument, filename, 64*1024*1024)
|
||||
ok, self.doc = pcall(pdf.openDocument, filename, self.cache_document_size)
|
||||
if not ok then
|
||||
return false, self.doc -- will contain error message
|
||||
end
|
||||
|
||||
@@ -107,7 +107,7 @@ end
|
||||
|
||||
-- open a file and its settings store
|
||||
-- tips: you can use self:loadSettings in open() method.
|
||||
function UniReader:open(filename, password)
|
||||
function UniReader:open(filename, cache_size)
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -149,7 +149,7 @@ end
|
||||
|
||||
function UniReader:loadSettings(filename)
|
||||
if self.doc ~= nil then
|
||||
self.settings = DocSettings:open(filename)
|
||||
self.settings = DocSettings:open(filename,self.cache_document_size)
|
||||
|
||||
local gamma = self.settings:readSetting("gamma")
|
||||
if gamma then
|
||||
@@ -169,8 +169,6 @@ 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