mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
45
blitbuffer.c
45
blitbuffer.c
@@ -332,9 +332,25 @@ static int paintRect(lua_State *L) {
|
||||
uint8_t *dstptr;
|
||||
|
||||
int cy;
|
||||
if(w <= 0 || h <= 0 || x >= dst->w || y >= dst->h) {
|
||||
return 0;
|
||||
|
||||
if(x < 0) {
|
||||
if (x+w > 0) {
|
||||
w += x;
|
||||
x = 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(y < 0) {
|
||||
if (y+h > 0) {
|
||||
h += y;
|
||||
y = 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(x + w > dst->w) {
|
||||
w = dst->w - x;
|
||||
}
|
||||
@@ -342,6 +358,10 @@ static int paintRect(lua_State *L) {
|
||||
h = dst->h - y;
|
||||
}
|
||||
|
||||
if(w <= 0 || h <= 0 || x >= dst->w || y >= dst->h) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(x & 1) {
|
||||
/* This will render the leftmost column
|
||||
* in the case when x is odd. After this,
|
||||
@@ -469,6 +489,27 @@ static int dimRect(lua_State *L) {
|
||||
uint8_t *dstptr;
|
||||
|
||||
int cy, cx;
|
||||
|
||||
if (x < 0) {
|
||||
if ( x + w > 0 ) {
|
||||
w = w + x;
|
||||
x = 0;
|
||||
} else {
|
||||
//printf("## invertRect x out of bound\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (y < 0) {
|
||||
if ( y + h > 0 ) {
|
||||
h = h + y;
|
||||
y = 0;
|
||||
} else {
|
||||
//printf("## invertRect y out of bound\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(w <= 0 || h <= 0 || x >= dst->w || y >= dst->h) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1532,12 +1532,37 @@ function UniReader:goto(no, is_ignore_jump)
|
||||
-- TODO: move the following to a more appropriate place
|
||||
-- into the caching section
|
||||
if no < numpages then
|
||||
if #self.bbox == 0 or not self.bbox.enabled then
|
||||
-- pre-cache next page, but if we will modify bbox don't!
|
||||
-- Tigran: I think we should _always_ precache the page
|
||||
-- because of the benefits of pre-decoding it (for DjVu).
|
||||
self:drawOrCache(no+1, true)
|
||||
end
|
||||
|
||||
local old = {
|
||||
globalzoom = self.globalzoom,
|
||||
offset_x = self.offset_x,
|
||||
offset_y = self.offset_y,
|
||||
dest_x = self.dest_x,
|
||||
dest_y = self.dest_y,
|
||||
min_offset_x = self.min_offset_x,
|
||||
min_offset_y = self.min_offset_y,
|
||||
pan_x = self.pan_x,
|
||||
pan_y = self.pan_y
|
||||
}
|
||||
|
||||
self:drawOrCache(no+1, true)
|
||||
|
||||
-- restore currently visible values, not from preCache page
|
||||
self.globalzoom = old.globalzoom
|
||||
self.offset_x = old.offset_x
|
||||
self.offset_y = old.offset_y
|
||||
self.dest_x = old.dest_x
|
||||
self.dest_y = old.dest_y
|
||||
self.min_offset_x = old.min_offset_x
|
||||
self.min_offset_y = old.min_offset_y
|
||||
self.pan_x = old.pan_x
|
||||
self.pan_y = old.pan_y
|
||||
|
||||
Debug("pre-cached page ", no+1, " and restored offsets")
|
||||
|
||||
|
||||
Debug("globalzoom_mode:", self.globalzoom_mode, " globalzoom:", self.globalzoom, " globalrotate:", self.globalrotate, " offset:", self.offset_x, self.offset_y, " pagesize:", self.fullwidth, self.fullheight, " min_offset:", self.min_offset_x, self.min_offset_y)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2935,18 +2960,22 @@ function UniReader:addAllCommands()
|
||||
local face = Font:getFace("rifont", font_size)
|
||||
|
||||
local page_links = 0
|
||||
local visible_links = {}
|
||||
|
||||
for i, link in ipairs(links) do
|
||||
if link.page then
|
||||
local x,y,w,h = self:zoomedRectCoordTransform( link.x0,link.y0, link.x1,link.y1 )
|
||||
fb.bb:dimRect(x,y,w,h) -- black 50%
|
||||
fb.bb:dimRect(x,y,w,h) -- black 25%
|
||||
page_links = page_links + 1
|
||||
if x > 0 and y > 0 and x < G_width and y < G_height then
|
||||
fb.bb:dimRect(x,y,w,h) -- black 50%
|
||||
fb.bb:dimRect(x,y,w,h) -- black 25%
|
||||
page_links = page_links + 1
|
||||
visible_links[page_links] = link
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if page_links == 0 then
|
||||
InfoMessage:inform("No links on this page ", 2000, 1, MSG_WARN)
|
||||
InfoMessage:inform("No visible links on this page ", 2000, 1, MSG_WARN)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -2962,7 +2991,7 @@ function UniReader:addAllCommands()
|
||||
shortcut_map = {}
|
||||
|
||||
for i = 1, #SelectMenu.item_shortcuts, 1 do
|
||||
local link = links[ i + shortcut_offset ]
|
||||
local link = visible_links[ i + shortcut_offset ]
|
||||
if link == nil then break end
|
||||
Debug("link", i, shortcut_offset, link)
|
||||
if link.page then
|
||||
@@ -3007,7 +3036,7 @@ function UniReader:addAllCommands()
|
||||
link = 30
|
||||
elseif ev.code == KEY_BACK then
|
||||
goto_page = unireader.pageno
|
||||
elseif ( ev.code == KEY_FW_RIGHT or ev.code == KEY_FW_DOWN ) and shortcut_offset <= #links - 30 then
|
||||
elseif ( ev.code == KEY_FW_RIGHT or ev.code == KEY_FW_DOWN ) and shortcut_offset <= #visible_links - 30 then
|
||||
shortcut_offset = shortcut_offset + 30
|
||||
render_shortcuts()
|
||||
elseif ( ev.code == KEY_FW_LEFT or ev.code == KEY_FW_UP ) and shortcut_offset >= 30 then
|
||||
@@ -3018,7 +3047,7 @@ function UniReader:addAllCommands()
|
||||
|
||||
if link then
|
||||
link = shortcut_map[link]
|
||||
if links[link] ~= nil and links[link].page ~= nil then
|
||||
if visible_links[link] ~= nil and visible_links[link].page ~= nil then
|
||||
goto_page = links[link].page + 1
|
||||
else
|
||||
Debug("missing link", link)
|
||||
|
||||
Reference in New Issue
Block a user