From fc3f2e0d91270aa45305ae0925cfe26ae00a6e1a Mon Sep 17 00:00:00 2001 From: deuce <> Date: Thu, 15 Feb 2018 20:48:10 +0000 Subject: [PATCH] Some updates to make X11 mode more efficient for remote terminals... 1) Send updates in 16-lines chunks rather than a single large update. 2) Keep the last screen rectangle around, and compare against it. 3) pre-calculate values. --- src/conio/x_events.c | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src/conio/x_events.c b/src/conio/x_events.c index f7c4394ee8..540e58b6f9 100644 --- a/src/conio/x_events.c +++ b/src/conio/x_events.c @@ -405,20 +405,39 @@ static int video_init() return(0); } +static struct rectlist *last = NULL; + static void local_draw_rect(struct rectlist *rect) { int x,y,xscale,yscale; unsigned int r, g, b; unsigned long pixel; + int cleft = rect->rect.width+1; + int cright = -1; + int ctop = 0; + int idx; /* TODO: Translate into local colour depth */ for(y=0;y<rect->rect.height;y++) { + idx = y*rect->rect.width+x; for(x=0; x<rect->rect.width; x++) { + if (last) { + if (last->data[idx] != rect->data[idx]) { + if (x < cleft) + cleft = x; + if (x > cright) + cright = x; + } + else { + idx++; + continue; + } + } for(yscale=0; yscale<x_cvstat.scaling*x_cvstat.vmultiplier; yscale++) { for(xscale=0; xscale<x_cvstat.scaling; xscale++) { - r = rect->data[y*rect->rect.width+x] >> 16 & 0xff; - g = rect->data[y*rect->rect.width+x] >> 8 & 0xff; - b = rect->data[y*rect->rect.width+x] & 0xff; + r = rect->data[idx] >> 16 & 0xff; + g = rect->data[idx] >> 8 & 0xff; + b = rect->data[idx] & 0xff; r = (r<<8)|r; g = (g<<8)|g; b = (b<<8)|b; @@ -442,12 +461,22 @@ static void local_draw_rect(struct rectlist *rect) #endif } } + idx++; + } + /* This line was changed */ + if (last && (((y & 0x1f) == 0x1f) || (y == rect->rect.height-1)) && cright >= 0) { + x11.XPutImage(dpy,win,gc,xim,cleft*x_cvstat.scaling,ctop*x_cvstat.scaling*x_cvstat.vmultiplier,cleft*x_cvstat.scaling,ctop*x_cvstat.scaling*x_cvstat.vmultiplier,(cright-cleft+1)*x_cvstat.scaling,(y-ctop+1)*x_cvstat.scaling*x_cvstat.vmultiplier); + cleft = rect->rect.width+1; + cright = -1; + ctop = y+1; } } - x11.XPutImage(dpy,win,gc,xim,rect->rect.x*x_cvstat.scaling,rect->rect.y*x_cvstat.scaling*x_cvstat.vmultiplier,rect->rect.x*x_cvstat.scaling,rect->rect.y*x_cvstat.scaling*x_cvstat.vmultiplier,rect->rect.width*x_cvstat.scaling,rect->rect.height*x_cvstat.scaling*x_cvstat.vmultiplier); - - bitmap_drv_free_rect(rect); + if (last == NULL) + x11.XPutImage(dpy,win,gc,xim,rect->rect.x*x_cvstat.scaling,rect->rect.y*x_cvstat.scaling*x_cvstat.vmultiplier,rect->rect.x*x_cvstat.scaling,rect->rect.y*x_cvstat.scaling*x_cvstat.vmultiplier,rect->rect.width*x_cvstat.scaling,rect->rect.height*x_cvstat.scaling*x_cvstat.vmultiplier); + else + bitmap_drv_free_rect(last); + last = rect; } static void handle_resize_event(int width, int height) -- GitLab