mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
paintRect should support negative x and y
without this page, highlights which land outside of page in negative direction will core-dump reader
This commit is contained in:
24
blitbuffer.c
24
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,
|
||||
|
||||
Reference in New Issue
Block a user