#include #include "lx.h" #include "internal.h" typedef struct priv_fill_arc PRIV_FILL_ARC; #define BATCHSIZE 100 struct priv_fill_arc { LX_XID d; LX_XID gc; int narcs; LX_ARC arcs[BATCHSIZE]; } ; static void *chain_fill_arc_start(LX_CONN *xc __attribute__((__unused__))) { PRIV_FILL_ARC *p; p = malloc(sizeof(PRIV_FILL_ARC)); p->d = LX_WINDOW_None; p->gc = LX_GC_None; p->narcs = 0; return(p); } static void chain_fill_arc_done(LX_CONN *xc, void *pv) { PRIV_FILL_ARC *p; p = pv; lx__PolyFillArc_inbatch(xc,p->d,p->gc,p->narcs,&p->arcs[0]); free(p); } static CHAINER chain_fill_arc = CHAINER_INIT(fill_arc); static void chain_fill_arc_changed(LX_CONN *xc, void *pv) { PRIV_FILL_ARC *p; p = pv; if (p->d != LX_WINDOW_None) lx__PolyFillArc_inbatch(xc,p->d,p->gc,p->narcs,&p->arcs[0]); p->narcs = 0; } void lx_fill_arc(LX_CONN *xc, LX_XID d, LX_XID gc, int x, int y, unsigned int w, unsigned int h, int a1, int a2) { LX_ARC *a; PRIV_FILL_ARC *p; if ( (x < -32768) || (x > 32767) || (y < -32768) || (y > 32767) || (w > 65535) || (h > 65535) || (a1 < -32768) || (a1 > 32767) || (a2 < -32768) || (a2 > 32767) ) { lx__bad_call(xc,"lx_fill_arc"); return; } p = lx__chainable(xc,&chain_fill_arc); if (! p) { lx__nomem_fail(xc); return; } if ((p->d != d) || (p->gc != gc) || (p->narcs >= BATCHSIZE)) { chain_fill_arc_changed(xc,p); p->d = d; p->gc = gc; } a = &p->arcs[p->narcs++]; a->x = x; a->y = y; a->w = w; a->h = h; a->a1 = a1; a->a2 = a2; }