#include #include "lx.h" #include "internal.h" typedef struct priv_draw_point PRIV_DRAW_POINT; #define BATCHSIZE 100 struct priv_draw_point { LX_XID d; LX_XID gc; int npts; LX_POINT pts[BATCHSIZE]; } ; static void *chain_draw_point_start(LX_CONN *xc __attribute__((__unused__))) { PRIV_DRAW_POINT *p; p = malloc(sizeof(PRIV_DRAW_POINT)); p->d = LX_WINDOW_None; p->gc = LX_GC_None; p->npts = 0; return(p); } static void chain_draw_point_done(LX_CONN *xc, void *pv) { PRIV_DRAW_POINT *p; p = pv; lx__PolyPoint_inbatch(xc,p->d,p->gc,LX_COORDMODE_Origin,p->npts,&p->pts[0]); free(p); } static CHAINER chain_draw_point = CHAINER_INIT(draw_point); static void chain_draw_point_changed(LX_CONN *xc, void *pv) { PRIV_DRAW_POINT *p; p = pv; if (p->d != LX_WINDOW_None) lx__PolyPoint_inbatch(xc,p->d,p->gc,LX_COORDMODE_Origin,p->npts,&p->pts[0]); p->npts = 0; } void lx_draw_point(LX_CONN *xc, LX_XID d, LX_XID gc, int x, int y) { LX_POINT *pt; PRIV_DRAW_POINT *p; if ((x < -32768) || (x > 32767) || (y < -32768) || (y > 32767)) { lx__bad_call(xc,"lx_draw_point"); return; } p = lx__chainable(xc,&chain_draw_point); if (! p) { lx__nomem_fail(xc); return; } if ((p->d != d) || (p->gc != gc) || (p->npts >= BATCHSIZE)) { chain_draw_point_changed(xc,p); p->d = d; p->gc = gc; } pt = &p->pts[p->npts++]; pt->x = x; pt->y = y; }