ref: 55f6ab5055793d69cd0ae8c0bbd3a952ef1fd505
parent: e545d605f8dd7ab25f19170673e530bac510ae6b
author: Yaroslav Kolomiiets <yarikos@gmail.com>
date: Mon Aug 8 12:42:32 EDT 2016
cosmetics
--- a/draw.c
+++ b/draw.c
@@ -8,11 +8,11 @@
void
drawimgupdate(Rdp *c, Share* s)
{
+ int (*loadfn)(Image*,Rectangle,uchar*,int,uchar*);
uchar* p, *ep;
- int n, err, nr;
+ int n, nr;
Rectangle r;
- Imgupd iu;
- int (*loadfunc)(Image*,Rectangle,uchar*,int,uchar*);
+ Imgupd u;
static Image* pad;
assert(s->type == ShUimg);
@@ -29,15 +29,19 @@
sysfatal("drawimgupdate: %r");
}
while(p<ep && nr>0){
- if((n = getimgupd(&iu, p, ep-p)) < 0)
+ if((n = getimgupd(&u, p, ep-p)) < 0)
sysfatal("getimgupd: %r");
- if(iu.depth != pad->depth)
+ if(u.depth != pad->depth)
sysfatal("bad image depth");
- r = Rect(iu.x, iu.y, iu.xm+1, iu.ym+1);
+
+ loadfn = loadbmp;
+ if(u.iscompr)
+ loadfn = loadrle;
+
+ r = Rect(u.x, u.y, u.xm+1, u.ym+1);
r = rectaddpt(r, screen->r.min);
- loadfunc = (iu.iscompr? loadrle : loadbmp);
- err = loadfunc(pad, r, iu.bytes, iu.nbytes, c->cmap);
- if(err < 0)
+
+ if(loadfn(pad, r, u.bytes, u.nbytes, c->cmap) < 0)
sysfatal("%r");
draw(screen, r, pad, nil, r.min);
p += n;