Skip to content

Commit 144bdbd

Browse files
committed
Fix framebuffer pixel comparison
- fix pixel comparison between VNC image buffer and framebuffer, - reset comparison matrix grid distance from 12x12 to 4x4, because dirty regions remain when using some Kodi skins, - filling image buffer in every line with memcpy, instead of filling from byte to byte by a for loop.
1 parent b4fbba5 commit 144bdbd

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

updateScreen.c

+9-11
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,28 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2121

2222
#define OUT_T CONCAT3E(uint,OUT,_t)
2323
#define FUNCTION CONCAT2E(update_screen_,OUT)
24-
#define COMPRECT 12
24+
#define COMPRECT 4
2525
#define MIN(a,b) (((a)<(b))?(a):(b))
2626
#define MAX(a,b) (((a)>(b))?(a):(b))
2727

2828
void FUNCTION(void) {
2929
OUT_T* b = (OUT_T*)readBufferFB();
3030
OUT_T* a = (OUT_T*)vncbuf;
3131

32+
struct fb_var_screeninfo scrinfo; //we'll need this to detect double FB on framebuffer
33+
scrinfo = FB_getscrinfo();
34+
3235
idle = 1;
3336

3437
int i, j;
35-
int offset = 0;
38+
int offset = 0, fb_offset = 0;
3639
int max_x = -1, max_y = -1, min_x = 99999, min_y = 99999;
3740

3841
for (j = 0; j < vncscr->height; j+=COMPRECT) {
3942
offset = j * vncscr->width;
43+
fb_offset = (j + scrinfo.yoffset) * scrinfo.xres_virtual + scrinfo.xoffset;
4044
for (i = 0; i < vncscr->width; i+=COMPRECT) {
41-
if (a[i + offset] != b[i + offset]) {
45+
if (a[i + offset] != b[i + fb_offset]) {
4246
min_y=MIN(j - COMPRECT, min_y);
4347
max_y=MAX(j + COMPRECT, max_y);
4448
idle = 0;
@@ -52,18 +56,12 @@ void FUNCTION(void) {
5256
max_x=screenformat.width - 1;
5357
max_y=MIN(screenformat.height - 1, max_y);
5458

55-
struct fb_var_screeninfo scrinfo; //we'll need this to detect double FB on framebuffer
56-
scrinfo = FB_getscrinfo();
57-
5859
for (j = min_y; j <= max_y; j++) {
5960
offset = j * vncscr->width;
60-
for (i = 0; i < vncscr->width; i++) {
61-
a[i + offset] = b[PIXEL_TO_VIRTUALPIXEL_FB(i, j)];
62-
}
61+
fb_offset = (j + scrinfo.yoffset) * scrinfo.xres_virtual + scrinfo.xoffset;
62+
memcpy(vncbuf + offset, b + fb_offset, screenformat.width * screenformat.bitsPerPixel / CHAR_BIT);
6363
}
6464

65-
offset = screenformat.width * min_y;
66-
memcpy(vncbuf + offset, a + offset, screenformat.width * (max_y - min_y) * screenformat.bitsPerPixel / CHAR_BIT);
6765
rfbMarkRectAsModified(vncscr, min_x, min_y, max_x, max_y);
6866
}
6967
}

0 commit comments

Comments
 (0)