rio, libdraw: experimental removal of redundant flushimage() calls for roundtrip latency reduction
- remove redundant flushimage() calls before readmouse() - remove flushimage() calls for allocimage(),freeimage() and originwindow() this is experimental. it will break allocimage() error handling unless the caller does explicit flushimage() calls, tho the gains in usability over high latency connections is huge. in most cases, programs will just terminate when encountering these errors.
This commit is contained in:
parent
bf6ba56817
commit
9dc9c6c5ef
|
@ -421,6 +421,7 @@ deletethread(void*)
|
||||||
originwindow(i, i->r.min, view->r.max);
|
originwindow(i, i->r.min, view->r.max);
|
||||||
}
|
}
|
||||||
freeimage(i);
|
freeimage(i);
|
||||||
|
flushimage(display, 1);
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -850,9 +851,6 @@ sweep(void)
|
||||||
r.max = p;
|
r.max = p;
|
||||||
oi = nil;
|
oi = nil;
|
||||||
while(mouse->buttons == 4){
|
while(mouse->buttons == 4){
|
||||||
readmouse(mousectl);
|
|
||||||
if(mouse->buttons != 4 && mouse->buttons != 0)
|
|
||||||
break;
|
|
||||||
if(!eqpt(mouse->xy, p)){
|
if(!eqpt(mouse->xy, p)){
|
||||||
p = onscreen(mouse->xy);
|
p = onscreen(mouse->xy);
|
||||||
r = canonrect(Rpt(p0, p));
|
r = canonrect(Rpt(p0, p));
|
||||||
|
@ -864,9 +862,9 @@ sweep(void)
|
||||||
oi = i;
|
oi = i;
|
||||||
border(i, r, Selborder, sizecol, ZP);
|
border(i, r, Selborder, sizecol, ZP);
|
||||||
draw(i, insetrect(r, Selborder), cols[BACK], nil, ZP);
|
draw(i, insetrect(r, Selborder), cols[BACK], nil, ZP);
|
||||||
flushimage(display, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
readmouse(mousectl);
|
||||||
}
|
}
|
||||||
if(mouse->buttons != 0)
|
if(mouse->buttons != 0)
|
||||||
goto Rescue;
|
goto Rescue;
|
||||||
|
@ -939,12 +937,10 @@ drag(Window *w)
|
||||||
d = subpt(w->screenr.max, w->screenr.min);
|
d = subpt(w->screenr.max, w->screenr.min);
|
||||||
op = subpt(mouse->xy, dm);
|
op = subpt(mouse->xy, dm);
|
||||||
drawborder(Rect(op.x, op.y, op.x+d.x, op.y+d.y), 1);
|
drawborder(Rect(op.x, op.y, op.x+d.x, op.y+d.y), 1);
|
||||||
flushimage(display, 1);
|
|
||||||
while(mouse->buttons==4){
|
while(mouse->buttons==4){
|
||||||
p = subpt(mouse->xy, dm);
|
p = subpt(mouse->xy, dm);
|
||||||
if(!eqpt(p, op)){
|
if(!eqpt(p, op)){
|
||||||
drawborder(Rect(p.x, p.y, p.x+d.x, p.y+d.y), 1);
|
drawborder(Rect(p.x, p.y, p.x+d.x, p.y+d.y), 1);
|
||||||
flushimage(display, 1);
|
|
||||||
op = p;
|
op = p;
|
||||||
}
|
}
|
||||||
readmouse(mousectl);
|
readmouse(mousectl);
|
||||||
|
@ -954,7 +950,6 @@ drag(Window *w)
|
||||||
cornercursor(w, mouse->xy, 1);
|
cornercursor(w, mouse->xy, 1);
|
||||||
moveto(mousectl, mouse->xy); /* force cursor update; ugly */
|
moveto(mousectl, mouse->xy); /* force cursor update; ugly */
|
||||||
menuing = FALSE;
|
menuing = FALSE;
|
||||||
flushimage(display, 1);
|
|
||||||
if(mouse->buttons!=0 || !goodrect(r)){
|
if(mouse->buttons!=0 || !goodrect(r)){
|
||||||
while(mouse->buttons)
|
while(mouse->buttons)
|
||||||
readmouse(mousectl);
|
readmouse(mousectl);
|
||||||
|
@ -1050,14 +1045,12 @@ bandsize(Window *w)
|
||||||
r = whichrect(w->screenr, p, which);
|
r = whichrect(w->screenr, p, which);
|
||||||
if(!eqrect(r, or) && goodrect(r)){
|
if(!eqrect(r, or) && goodrect(r)){
|
||||||
drawborder(r, 1);
|
drawborder(r, 1);
|
||||||
flushimage(display, 1);
|
|
||||||
or = r;
|
or = r;
|
||||||
}
|
}
|
||||||
readmouse(mousectl);
|
readmouse(mousectl);
|
||||||
}
|
}
|
||||||
p = mouse->xy;
|
p = mouse->xy;
|
||||||
drawborder(or, 0);
|
drawborder(or, 0);
|
||||||
flushimage(display, 1);
|
|
||||||
wsetcursor(w, 1);
|
wsetcursor(w, 1);
|
||||||
if(mouse->buttons!=0 || !goodrect(or)){
|
if(mouse->buttons!=0 || !goodrect(or)){
|
||||||
while(mouse->buttons)
|
while(mouse->buttons)
|
||||||
|
|
|
@ -174,7 +174,7 @@ winctl(void *arg)
|
||||||
Stringpair pair;
|
Stringpair pair;
|
||||||
Wctlmesg wcm;
|
Wctlmesg wcm;
|
||||||
Completion *cr;
|
Completion *cr;
|
||||||
char *kbdq[8], *kbds;
|
char *kbdq[32], *kbds;
|
||||||
int kbdqr, kbdqw;
|
int kbdqr, kbdqw;
|
||||||
|
|
||||||
w = arg;
|
w = arg;
|
||||||
|
@ -1032,7 +1032,6 @@ wselect(Window *w)
|
||||||
if(q0==q1 && selectq==w->q0){
|
if(q0==q1 && selectq==w->q0){
|
||||||
wdoubleclick(w, &q0, &q1);
|
wdoubleclick(w, &q0, &q1);
|
||||||
wsetselect(w, q0, q1);
|
wsetselect(w, q0, q1);
|
||||||
flushimage(display, 1);
|
|
||||||
x = w->mc.xy.x;
|
x = w->mc.xy.x;
|
||||||
y = w->mc.xy.y;
|
y = w->mc.xy.y;
|
||||||
/* stay here until something interesting happens */
|
/* stay here until something interesting happens */
|
||||||
|
@ -1072,7 +1071,6 @@ wselect(Window *w)
|
||||||
}else
|
}else
|
||||||
clickwin = nil;
|
clickwin = nil;
|
||||||
wsetselect(w, q0, q1);
|
wsetselect(w, q0, q1);
|
||||||
flushimage(display, 1);
|
|
||||||
while(w->mc.buttons){
|
while(w->mc.buttons){
|
||||||
w->mc.msec = 0;
|
w->mc.msec = 0;
|
||||||
b = w->mc.buttons;
|
b = w->mc.buttons;
|
||||||
|
@ -1089,7 +1087,6 @@ wselect(Window *w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wscrdraw(w);
|
wscrdraw(w);
|
||||||
flushimage(display, 1);
|
|
||||||
while(w->mc.buttons == b)
|
while(w->mc.buttons == b)
|
||||||
readmouse(&w->mc);
|
readmouse(&w->mc);
|
||||||
clickwin = nil;
|
clickwin = nil;
|
||||||
|
@ -1414,6 +1411,7 @@ wclosewin(Window *w)
|
||||||
/* move it off-screen to hide it, in case client is slow in letting it go */
|
/* move it off-screen to hide it, in case client is slow in letting it go */
|
||||||
MOVEIT originwindow(i, i->r.min, view->r.max);
|
MOVEIT originwindow(i, i->r.min, view->r.max);
|
||||||
freeimage(i);
|
freeimage(i);
|
||||||
|
flushimage(display, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,6 @@ _allocimage(Image *ai, Display *d, Rectangle r, ulong chan, int repl, ulong col,
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* flush pending data so we don't get error allocating the image */
|
|
||||||
flushimage(d, 0);
|
|
||||||
a = bufimage(d, 1+4+4+1+4+1+4*4+4*4+4);
|
a = bufimage(d, 1+4+4+1+4+1+4*4+4*4+4);
|
||||||
if(a == nil)
|
if(a == nil)
|
||||||
goto Error;
|
goto Error;
|
||||||
|
@ -74,8 +72,6 @@ _allocimage(Image *ai, Display *d, Rectangle r, ulong chan, int repl, ulong col,
|
||||||
BPLONG(a+39, clipr.max.x);
|
BPLONG(a+39, clipr.max.x);
|
||||||
BPLONG(a+43, clipr.max.y);
|
BPLONG(a+43, clipr.max.y);
|
||||||
BPLONG(a+47, col);
|
BPLONG(a+47, col);
|
||||||
if(flushimage(d, 0) < 0)
|
|
||||||
goto Error;
|
|
||||||
|
|
||||||
if(ai != nil)
|
if(ai != nil)
|
||||||
i = ai;
|
i = ai;
|
||||||
|
@ -207,7 +203,6 @@ _freeimage1(Image *i)
|
||||||
if(i == nil || i->display == nil)
|
if(i == nil || i->display == nil)
|
||||||
return 0;
|
return 0;
|
||||||
d = i->display;
|
d = i->display;
|
||||||
flushimage(d, 0);
|
|
||||||
if(i->screen != nil){
|
if(i->screen != nil){
|
||||||
w = d->windows;
|
w = d->windows;
|
||||||
if(w == i)
|
if(w == i)
|
||||||
|
@ -226,9 +221,6 @@ _freeimage1(Image *i)
|
||||||
return -1;
|
return -1;
|
||||||
a[0] = 'f';
|
a[0] = 'f';
|
||||||
BPLONG(a+1, i->id);
|
BPLONG(a+1, i->id);
|
||||||
if(flushimage(d, i->screen!=nil) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,6 @@ originwindow(Image *w, Point log, Point scr)
|
||||||
uchar *b;
|
uchar *b;
|
||||||
Point delta;
|
Point delta;
|
||||||
|
|
||||||
flushimage(w->display, 0);
|
|
||||||
b = bufimage(w->display, 1+4+2*4+2*4);
|
b = bufimage(w->display, 1+4+2*4+2*4);
|
||||||
if(b == nil)
|
if(b == nil)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -211,8 +210,6 @@ originwindow(Image *w, Point log, Point scr)
|
||||||
BPLONG(b+9, log.y);
|
BPLONG(b+9, log.y);
|
||||||
BPLONG(b+13, scr.x);
|
BPLONG(b+13, scr.x);
|
||||||
BPLONG(b+17, scr.y);
|
BPLONG(b+17, scr.y);
|
||||||
if(flushimage(w->display, 1) < 0)
|
|
||||||
return -1;
|
|
||||||
delta = subpt(log, w->r.min);
|
delta = subpt(log, w->r.min);
|
||||||
w->r = rectaddpt(w->r, delta);
|
w->r = rectaddpt(w->r, delta);
|
||||||
w->clipr = rectaddpt(w->clipr, delta);
|
w->clipr = rectaddpt(w->clipr, delta);
|
||||||
|
|
|
@ -96,7 +96,6 @@ frselect(Frame *f, Mousectl *mc) /* when called, button 1 is down */
|
||||||
}
|
}
|
||||||
if(scrled)
|
if(scrled)
|
||||||
(*f->scroll)(f, 0);
|
(*f->scroll)(f, 0);
|
||||||
flushimage(f->display, 1);
|
|
||||||
if(!scrled)
|
if(!scrled)
|
||||||
readmouse(mc);
|
readmouse(mc);
|
||||||
mp = mc->xy;
|
mp = mc->xy;
|
||||||
|
|
Loading…
Reference in a new issue