mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge branch 'master' of github.com:hwhw/kindlepdfviewer
This commit is contained in:
27
Makefile
27
Makefile
@@ -16,9 +16,10 @@ TTF_FONTS_DIR=$(MUPDFDIR)/fonts
|
||||
|
||||
# set this to your ARM cross compiler:
|
||||
|
||||
CC:=arm-unknown-linux-gnueabi-gcc
|
||||
CXX:=arm-unknown-linux-gnueabi-g++
|
||||
HOST:=arm-unknown-linux-gnueabi
|
||||
HOST:=arm-none-linux-gnueabi
|
||||
CC:=$(HOST)-gcc
|
||||
CXX:=$(HOST)-g++
|
||||
STRIP:=$(HOST)-strip
|
||||
ifdef SBOX_UNAME_MACHINE
|
||||
CC:=gcc
|
||||
CXX:=g++
|
||||
@@ -26,11 +27,18 @@ endif
|
||||
HOSTCC:=gcc
|
||||
HOSTCXX:=g++
|
||||
|
||||
CFLAGS:=-O3
|
||||
CFLAGS:=-O3 $(SYSROOT)
|
||||
CXXFLAGS:=-O3 $(SYSROOT)
|
||||
LDFLAGS:= $(SYSROOT)
|
||||
ARM_CFLAGS:=-march=armv6
|
||||
# use this for debugging:
|
||||
#CFLAGS:=-O0 -g
|
||||
|
||||
DYNAMICLIBSTDCPP:=-lstdc++
|
||||
ifdef STATICLIBSTDCPP
|
||||
DYNAMICLIBSTDCPP:=
|
||||
endif
|
||||
|
||||
# you can configure an emulation for the (eink) framebuffer here.
|
||||
# the application won't use the framebuffer (and the special e-ink ioctls)
|
||||
# in that case.
|
||||
@@ -79,7 +87,7 @@ LUALIB := $(LUADIR)/src/liblua.a
|
||||
all:kpdfview
|
||||
|
||||
kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o drawcontext.o input.o util.o ft.o lfs.o $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIB) djvu.o $(DJVULIBS) cre.o $(CRENGINELIBS)
|
||||
$(CC) -lm -ldl -lpthread $(EMU_LDFLAGS) -lstdc++ \
|
||||
$(CC) -lm -ldl -lpthread $(EMU_LDFLAGS) $(DYNAMICLIBSTDCPP) \
|
||||
kpdfview.o \
|
||||
einkfb.o \
|
||||
pdf.o \
|
||||
@@ -96,6 +104,7 @@ kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o drawcontext.o input.o util.o ft
|
||||
$(DJVULIBS) \
|
||||
cre.o \
|
||||
$(CRENGINELIBS) \
|
||||
$(STATICLIBSTDCPP) \
|
||||
-o kpdfview
|
||||
|
||||
slider_watcher: slider_watcher.c
|
||||
@@ -192,13 +201,15 @@ VERSION?=$(shell git rev-parse --short HEAD)
|
||||
customupdate: all
|
||||
# ensure that build binary is for ARM
|
||||
file kpdfview | grep ARM || exit 1
|
||||
$(STRIP) --strip-unneeded kpdfview
|
||||
-rm kindlepdfviewer-$(VERSION).zip
|
||||
rm -Rf $(INSTALL_DIR)
|
||||
mkdir $(INSTALL_DIR)
|
||||
cp -p README.TXT COPYING kpdfview *.lua $(INSTALL_DIR)
|
||||
mkdir $(INSTALL_DIR)/data
|
||||
cp -rpL data/*.css $(INSTALL_DIR)/data
|
||||
cp -rp fonts $(INSTALL_DIR)
|
||||
mkdir -p $(INSTALL_DIR)/fonts/host
|
||||
zip -r kindlepdfviewer-$(VERSION).zip $(INSTALL_DIR) launchpad/
|
||||
cp -rpL fonts $(INSTALL_DIR)
|
||||
mkdir $(INSTALL_DIR)/fonts/host
|
||||
zip -9 -r kindlepdfviewer-$(VERSION).zip $(INSTALL_DIR) launchpad/
|
||||
rm -Rf $(INSTALL_DIR)
|
||||
@echo "copy kindlepdfviewer-$(VERSION).zip to /mnt/us/customupdates and install with shift+shift+I"
|
||||
|
||||
62
blitbuffer.c
62
blitbuffer.c
@@ -423,6 +423,67 @@ static int invertRect(lua_State *L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dimRect(lua_State *L) {
|
||||
BlitBuffer *dst = (BlitBuffer*) luaL_checkudata(L, 1, "blitbuffer");
|
||||
int x = luaL_checkint(L, 2);
|
||||
int y = luaL_checkint(L, 3);
|
||||
int w = luaL_checkint(L, 4);
|
||||
int h = luaL_checkint(L, 5);
|
||||
uint8_t *dstptr;
|
||||
|
||||
int cy, cx;
|
||||
if(w <= 0 || h <= 0 || x >= dst->w || y >= dst->h) {
|
||||
return 0;
|
||||
}
|
||||
if(x + w > dst->w) {
|
||||
w = dst->w - x;
|
||||
}
|
||||
if(y + h > dst->h) {
|
||||
h = dst->h - y;
|
||||
}
|
||||
|
||||
if(x & 1) {
|
||||
/* This will dimm the leftmost column
|
||||
* in the case when x is odd. After this,
|
||||
* x will become even. */
|
||||
dstptr = (uint8_t*)(dst->data +
|
||||
y * dst->pitch +
|
||||
x / 2);
|
||||
for(cy = 0; cy < h; cy++) {
|
||||
int px = *dstptr & 0x0F;
|
||||
*dstptr &= 0xF0 | px >> 1;
|
||||
dstptr += dst->pitch;
|
||||
}
|
||||
x++;
|
||||
w--;
|
||||
}
|
||||
dstptr = (uint8_t*)(dst->data +
|
||||
y * dst->pitch +
|
||||
x / 2);
|
||||
for(cy = 0; cy < h; cy++) {
|
||||
for(cx = 0; cx < w/2; cx++) {
|
||||
*(dstptr+cx) =
|
||||
*(dstptr+cx) >> 1 & 0xF0 |
|
||||
*(dstptr+cx) & 0x0F >> 1;
|
||||
}
|
||||
dstptr += dst->pitch;
|
||||
}
|
||||
if(w & 1) {
|
||||
/* This will dimm the rightmost column
|
||||
* in the case when (w & 1) && !(x & 1) or
|
||||
* !(w & 1) && (x & 1). */
|
||||
dstptr = (uint8_t*)(dst->data +
|
||||
y * dst->pitch +
|
||||
(x + w) / 2);
|
||||
for(cy = 0; cy < h; cy++) {
|
||||
int px = *dstptr & 0xF0;
|
||||
*dstptr &= 0x0F | ( px >> 1 & 0xF0 );
|
||||
dstptr += dst->pitch;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct luaL_Reg blitbuffer_func[] = {
|
||||
{"new", newBlitBuffer},
|
||||
{NULL, NULL}
|
||||
@@ -436,6 +497,7 @@ static const struct luaL_Reg blitbuffer_meth[] = {
|
||||
{"blitFullFrom", blitFullToBuffer},
|
||||
{"paintRect", paintRect},
|
||||
{"invertRect", invertRect},
|
||||
{"dimRect", dimRect},
|
||||
{"free", freeBlitBuffer},
|
||||
{"__gc", freeBlitBuffer},
|
||||
{NULL, NULL}
|
||||
|
||||
@@ -111,6 +111,14 @@ function CREReader:goto(pos, pos_type)
|
||||
|
||||
self.doc:drawCurrentPage(self.nulldc, fb.bb)
|
||||
|
||||
print("## self.show_overlap "..self.show_overlap)
|
||||
if self.show_overlap < 0 then
|
||||
fb.bb:dimRect(0,0, width, -self.show_overlap)
|
||||
elseif self.show_overlap > 0 then
|
||||
fb.bb:dimRect(0,height - self.show_overlap, width, self.show_overlap)
|
||||
end
|
||||
self.show_overlap = 0
|
||||
|
||||
if self.rcount == self.rcountmax then
|
||||
print("full refresh")
|
||||
self.rcount = 1
|
||||
@@ -136,10 +144,12 @@ function CREReader:gotoTocEntry(entry)
|
||||
end
|
||||
|
||||
function CREReader:nextView()
|
||||
self.show_overlap = -self.pan_overlap_vertical
|
||||
return self.pos + G_height - self.pan_overlap_vertical
|
||||
end
|
||||
|
||||
function CREReader:prevView()
|
||||
self.show_overlap = self.pan_overlap_vertical
|
||||
return self.pos - G_height + self.pan_overlap_vertical
|
||||
end
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#!./kpdfview
|
||||
require "rendertext"
|
||||
require "graphics"
|
||||
|
||||
fb = einkfb.open("/dev/fb0")
|
||||
G_width, G_height = fb:getSize()
|
||||
|
||||
print("open")
|
||||
|
||||
face = freetype.newBuiltinFace("sans", 64)
|
||||
--face = freetype.newFace("test.ttf", 64)
|
||||
print("got face")
|
||||
|
||||
if face:hasKerning() then
|
||||
print("has kerning")
|
||||
end
|
||||
|
||||
fb.bb:paintRect(1,1,599,300,7);
|
||||
|
||||
renderUtf8Text(fb.bb, 100, 100, face, "h", "AV T.T: gxyt!", true)
|
||||
renderUtf8Text(fb.bb, 100, 200, face, "h", "AV T.T: gxyt!", false)
|
||||
|
||||
fb:refresh()
|
||||
|
||||
while true do
|
||||
local ev = input.waitForEvent()
|
||||
end
|
||||
BIN
test/tall.pdf
Normal file
BIN
test/tall.pdf
Normal file
Binary file not shown.
@@ -54,6 +54,7 @@ UniReader = {
|
||||
pan_y = 0,
|
||||
pan_margin = 20, -- horizontal margin for two-column zoom
|
||||
pan_overlap_vertical = 30,
|
||||
show_overlap = 0,
|
||||
|
||||
-- the document:
|
||||
doc = nil,
|
||||
@@ -355,6 +356,9 @@ end
|
||||
|
||||
-- blank the cache
|
||||
function UniReader:clearCache()
|
||||
for k, _ in pairs(self.cache) do
|
||||
self.cache[k].bb:free()
|
||||
end
|
||||
self.cache = {}
|
||||
self.cache_current_memsize = 0
|
||||
end
|
||||
@@ -552,6 +556,14 @@ function UniReader:show(no)
|
||||
"width:"..width..", height:"..height)
|
||||
fb.bb:blitFrom(bb, dest_x, dest_y, offset_x, offset_y, width, height)
|
||||
|
||||
print("## self.show_overlap "..self.show_overlap)
|
||||
if self.show_overlap < 0 then
|
||||
fb.bb:dimRect(0,0, width, dest_y - self.show_overlap)
|
||||
elseif self.show_overlap > 0 then
|
||||
fb.bb:dimRect(0,dest_y + height - self.show_overlap, width, self.show_overlap)
|
||||
end
|
||||
self.show_overlap = 0
|
||||
|
||||
-- render highlights to page
|
||||
if self.highlight[no] then
|
||||
self:toggleTextHighLight(self.highlight[no])
|
||||
@@ -668,6 +680,7 @@ function UniReader:nextView()
|
||||
-- goto next view of current page
|
||||
self.offset_y = self.offset_y - G_height
|
||||
+ self.pan_overlap_vertical
|
||||
self.show_overlap = -self.pan_overlap_vertical -- top < 0
|
||||
end
|
||||
else
|
||||
-- not in fit to content width pan mode, just do a page turn
|
||||
@@ -695,6 +708,7 @@ function UniReader:prevView()
|
||||
-- goto previous view of current page
|
||||
self.offset_y = self.offset_y + G_height
|
||||
- self.pan_overlap_vertical
|
||||
self.show_overlap = self.pan_overlap_vertical -- bottom > 0
|
||||
end
|
||||
else
|
||||
-- not in fit to content width pan mode, just do a page turn
|
||||
@@ -1183,8 +1197,8 @@ function UniReader:addAllCommands()
|
||||
x = unireader.shift_x / 5
|
||||
y = unireader.shift_y / 5
|
||||
elseif unireader.pan_by_page then
|
||||
x = G_width;
|
||||
y = G_height - unireader.pan_overlap_vertical; -- overlap for lines which didn't fit
|
||||
x = G_width
|
||||
y = G_height - unireader.pan_overlap_vertical -- overlap for lines which didn't fit
|
||||
else
|
||||
x = unireader.shift_x
|
||||
y = unireader.shift_y
|
||||
@@ -1226,11 +1240,15 @@ function UniReader:addAllCommands()
|
||||
unireader.offset_y = unireader.offset_y + y
|
||||
if unireader.offset_y > 0 then
|
||||
unireader.offset_y = 0
|
||||
elseif unireader.pan_by_page then
|
||||
unireader.show_overlap = unireader.pan_overlap_vertical -- bottom
|
||||
end
|
||||
elseif keydef.keycode == KEY_FW_DOWN then
|
||||
unireader.offset_y = unireader.offset_y - y
|
||||
if unireader.offset_y < unireader.min_offset_y then
|
||||
unireader.offset_y = unireader.min_offset_y
|
||||
elseif unireader.pan_by_page then
|
||||
unireader.show_overlap = -unireader.pan_overlap_vertical -- top
|
||||
end
|
||||
elseif keydef.keycode == KEY_FW_PRESS then
|
||||
if keydef.modifier==MOD_SHIFT then
|
||||
|
||||
Reference in New Issue
Block a user