mirror of
https://github.com/koreader/koreader
synced 2024-10-31 21:20:20 +00:00
Merge pull request #600 from chrox/k2pdfopt-v1.62
update k2pdfopt to version 1.62
This commit is contained in:
commit
f3f193c69b
2
Makefile
2
Makefile
@ -85,7 +85,7 @@ endif
|
|||||||
|
|
||||||
# standard includes
|
# standard includes
|
||||||
KPDFREADER_CFLAGS=$(CFLAGS) -I$(LUADIR)/src -I$(MUPDFDIR)/
|
KPDFREADER_CFLAGS=$(CFLAGS) -I$(LUADIR)/src -I$(MUPDFDIR)/
|
||||||
K2PDFOPT_CFLAGS=-I$(MUPDFDIR)/ -I$(DJVUDIR)/ -I$(K2PDFOPTLIBDIR)/
|
K2PDFOPT_CFLAGS=-I$(K2PDFOPTLIBDIR)/willuslib -I$(K2PDFOPTLIBDIR)/k2pdfoptlib -I$(K2PDFOPTLIBDIR)/
|
||||||
|
|
||||||
# enable tracing output:
|
# enable tracing output:
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
#include "k2pdfopt.h"
|
#include "koptreflow.h"
|
||||||
|
|
||||||
int luaopen_koptcontext(lua_State *L);
|
int luaopen_koptcontext(lua_State *L);
|
||||||
#endif
|
#endif
|
||||||
|
@ -253,7 +253,7 @@ function KOPTReader:drawOrCache(no, preCache)
|
|||||||
self.min_offset_y = 0
|
self.min_offset_y = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.offset_y == -2012534 then
|
if self.offset_y <= -201253 then
|
||||||
self.offset_y = self.min_offset_y
|
self.offset_y = self.min_offset_y
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -289,28 +289,43 @@ function KOPTReader:drawOrCache(no, preCache)
|
|||||||
if self.precache_kc ~= nil then
|
if self.precache_kc ~= nil then
|
||||||
if self.precache_kc:isPreCache() == 1 then
|
if self.precache_kc:isPreCache() == 1 then
|
||||||
Debug("waiting threaded precache to finish.")
|
Debug("waiting threaded precache to finish.")
|
||||||
return
|
return nil
|
||||||
else
|
else
|
||||||
Debug("threaded preCache is finished.")
|
Debug("threaded preCache is finished.")
|
||||||
return self:writeToCache(self.precache_kc, page, pagehash, preCache)
|
Debug("current pagehash", pagehash)
|
||||||
|
Debug("precache pagehash", self.precache_pagehash)
|
||||||
|
if self.precache_pagehash == pagehash then
|
||||||
|
Debug("write cache ", self.precache_pagehash)
|
||||||
|
return self:writeToCache(self.precache_kc, page, self.precache_pagehash, preCache)
|
||||||
|
else
|
||||||
|
self.precache_kc = nil
|
||||||
|
self.precache_pagehash = nil
|
||||||
|
Debug("discard cache ", self.precache_pagehash)
|
||||||
|
return nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self.precache_kc = kc
|
self.precache_kc = kc
|
||||||
|
self.precache_pagehash = pagehash
|
||||||
self.precache_kc:setPreCache()
|
self.precache_kc:setPreCache()
|
||||||
page:reflow(self.precache_kc, self.render_mode)
|
page:reflow(self.precache_kc, self.render_mode)
|
||||||
Debug("threaded preCache is returned.")
|
Debug("threaded preCache is returned.")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if use_threads and self.precache_kc and self.precache_kc:isPreCache() == 1 and self.cache[self.cached_pagehash] then
|
if use_threads and self.precache_kc ~= nil and self.precache_kc:isPreCache() == 1 then
|
||||||
Debug("How about staying here and wait?")
|
if self.cache[self.cached_pagehash] then
|
||||||
InfoMessage:inform("Rendering in background...", DINFO_DELAY, 1, MSG_WARN)
|
InfoMessage:inform("Rendering in background...", DINFO_DELAY, 1, MSG_WARN)
|
||||||
return self.cached_pagehash, self.cached_offset_x, self.cached_offset_y
|
return self.cached_pagehash, self.cached_offset_x, self.cached_offset_y
|
||||||
else
|
else
|
||||||
--local secs, usecs = util.gettime()
|
Debug("ERROR something wrong happens .. why cached page is missing?")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local secs, usecs = util.gettime()
|
||||||
page:reflow(kc, self.render_mode)
|
page:reflow(kc, self.render_mode)
|
||||||
--local nsecs, nusecs = util.gettime()
|
local nsecs, nusecs = util.gettime()
|
||||||
--local dur = (nsecs - secs) * 1000000 + nusecs - usecs
|
local dur = (nsecs - secs) * 1000000 + nusecs - usecs
|
||||||
--Debug("Reflow duration:", dur)
|
Debug("Reflow duration:", dur)
|
||||||
--self:logReflowDuration(no, dur)
|
--self:logReflowDuration(no, dur)
|
||||||
return self:writeToCache(kc, page, pagehash, preCache)
|
return self:writeToCache(kc, page, pagehash, preCache)
|
||||||
end
|
end
|
||||||
@ -333,9 +348,6 @@ function KOPTReader:writeToCache(kc, page, pagehash, preCache)
|
|||||||
w = width, h = height }
|
w = width, h = height }
|
||||||
-- can we cache the full page?
|
-- can we cache the full page?
|
||||||
local max_cache = self.cache_max_memsize
|
local max_cache = self.cache_max_memsize
|
||||||
if preCache then
|
|
||||||
max_cache = max_cache - self.cache[self.pagehash].size
|
|
||||||
end
|
|
||||||
|
|
||||||
self.fullwidth, self.fullheight = kc:getPageDim()
|
self.fullwidth, self.fullheight = kc:getPageDim()
|
||||||
self.reflow_zoom = kc:getZoom()
|
self.reflow_zoom = kc:getZoom()
|
||||||
@ -348,12 +360,15 @@ function KOPTReader:writeToCache(kc, page, pagehash, preCache)
|
|||||||
tile.w = self.fullwidth
|
tile.w = self.fullwidth
|
||||||
tile.h = self.fullheight
|
tile.h = self.fullheight
|
||||||
else
|
else
|
||||||
if not preCache then
|
Debug("ERROR not enough memory in cache left, reflowed page is too large.")
|
||||||
Debug("ERROR not enough memory in cache left, probably a bug.")
|
|
||||||
end
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
self:cacheClaim(tile.w * tile.h / 2);
|
if not self:cacheClaim(tile.w * tile.h / 2) then
|
||||||
|
Debug("ERROR not enough memory in cache left, cache claim failed.")
|
||||||
|
return nil
|
||||||
|
else
|
||||||
|
Debug("Cache claim succeed.")
|
||||||
|
end
|
||||||
self.cache[pagehash] = {
|
self.cache[pagehash] = {
|
||||||
x = tile.x,
|
x = tile.x,
|
||||||
y = tile.y,
|
y = tile.y,
|
||||||
@ -363,7 +378,7 @@ function KOPTReader:writeToCache(kc, page, pagehash, preCache)
|
|||||||
size = tile.w * tile.h / 2,
|
size = tile.w * tile.h / 2,
|
||||||
bb = Blitbuffer.new(tile.w, tile.h)
|
bb = Blitbuffer.new(tile.w, tile.h)
|
||||||
}
|
}
|
||||||
--Debug ("new biltbuffer:"..dump(self.cache[pagehash]))
|
Debug ("new biltbuffer:"..dump(self.cache[pagehash]))
|
||||||
Debug("page::drawReflowedPage:", "rendering page:", no, "width:", self.cache[pagehash].w, "height:", self.cache[pagehash].h)
|
Debug("page::drawReflowedPage:", "rendering page:", no, "width:", self.cache[pagehash].w, "height:", self.cache[pagehash].h)
|
||||||
page:rfdraw(kc, self.cache[pagehash].bb)
|
page:rfdraw(kc, self.cache[pagehash].bb)
|
||||||
page:close()
|
page:close()
|
||||||
@ -381,7 +396,7 @@ function KOPTReader:writeToCache(kc, page, pagehash, preCache)
|
|||||||
self.min_offset_y = 0
|
self.min_offset_y = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.offset_y == -2012534 then
|
if self.offset_y <= -201253 then
|
||||||
self.offset_y = self.min_offset_y
|
self.offset_y = self.min_offset_y
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -528,6 +543,8 @@ function KOPTReader:loadSettings(filename)
|
|||||||
--Debug("loaded configurable:", dump(self.configurable))
|
--Debug("loaded configurable:", dump(self.configurable))
|
||||||
-- backup global variable that may be changed in koptreader
|
-- backup global variable that may be changed in koptreader
|
||||||
self.orig_globalzoom_mode = self.settings:readSetting("globalzoom_mode") or -1
|
self.orig_globalzoom_mode = self.settings:readSetting("globalzoom_mode") or -1
|
||||||
|
self.orig_dbackground_color = DBACKGROUND_COLOR
|
||||||
|
DBACKGROUND_COLOR = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function KOPTReader:saveSpecialSettings()
|
function KOPTReader:saveSpecialSettings()
|
||||||
@ -536,6 +553,7 @@ function KOPTReader:saveSpecialSettings()
|
|||||||
--Debug("saved configurable:", dump(self.configurable))
|
--Debug("saved configurable:", dump(self.configurable))
|
||||||
-- restore global variable from backups
|
-- restore global variable from backups
|
||||||
self.settings:saveSetting("globalzoom_mode", self.orig_globalzoom_mode)
|
self.settings:saveSetting("globalzoom_mode", self.orig_globalzoom_mode)
|
||||||
|
DBACKGROUND_COLOR = self.orig_dbackground_color
|
||||||
end
|
end
|
||||||
|
|
||||||
function KOPTReader:init()
|
function KOPTReader:init()
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 9f405ca3823e637d83db1a8e6c4989bf5e188ff3
|
Subproject commit 38fba22a7bbc4d20f04d7d0df18f9431a8115c54
|
Loading…
Reference in New Issue
Block a user