#include #include "internal.h" SGC *lx__new_sgc(LX_CONN *xc) { SGC *sgc; int x; int newn; SGC **newv; sgc = malloc(sizeof(SGC)); if (! sgc) return(0); x = xc->minfreesgc; while ((x < xc->nsgc) && xc->sgcv[x]) x ++; if (x >= xc->nsgc) { newn = xc->nsgc + 16; newv = realloc(xc->sgcv,newn*sizeof(SGC *)); if (! newv) { free(sgc); return(0); } xc->nsgc = newn; xc->sgcv = newv; } xc->sgcv[x] = sgc; xc->minfreesgc = x + 1; sgc->xc = xc; sgc->sgcid = x; sgc->gcid = LX_GC_None; sgc->shadow.function = LX_GCFUNCTION_Copy; sgc->shadow.plane_mask = ~0U; sgc->shadow.foreground = 0; sgc->shadow.background = 1; sgc->shadow.line_width = 0; sgc->shadow.line_style = LX_GCLINESTYLE_Solid; sgc->shadow.cap_style = LX_GCCAPSTYLE_Butt; sgc->shadow.join_style = LX_GCJOINSTYLE_Miter; sgc->shadow.fill_style = LX_GCFILLSTYLE_Solid; sgc->shadow.fill_rule = LX_GCFILLRULE_EvenOdd; // sgc->shadow.tile not set // sgc->shadow.stipple not set sgc->shadow.tile_stip_x_origin = 0; sgc->shadow.tile_stip_y_origin = 0; // sgc->shadow.font not set sgc->shadow.subwindow_mode = LX_GCSUBWINDOWMODE_ClipByChildren; sgc->shadow.graphics_exposures = 1; sgc->shadow.clip_x_origin = 0; sgc->shadow.clip_y_origin = 0; sgc->shadow.clip_mask = LX_GCCLIPMASK_None; sgc->shadow.dash_offset = 0; sgc->shadow.dashes = 4; sgc->shadow.arc_mode = LX_GCARCMODE_PieSlice; sgc->set = 0; sgc->unk = LX_GCM_Tile | LX_GCM_Stipple | LX_GCM_Font; return(sgc); } void lx__free_sgc(LX_CONN *xc, SGC *sgc) { if ((sgc->xc != xc) || (sgc->sgcid >= xc->nsgc) || (xc->sgcv[sgc->sgcid] != sgc)) { lx_abort(); return; } xc->sgcv[sgc->sgcid] = 0; if (sgc->sgcid < xc->minfreesgc) xc->minfreesgc = sgc->sgcid; free(sgc); } SGC *lx__lookup_sgc(LX_CONN *xc, LX_XID id) { SGC *sgc; if (id >= xc->nsgc) return(0); sgc = xc->sgcv[id]; if (! sgc) return(0); if ((sgc->xc != xc) || (sgc->sgcid != id)) { lx_abort(); return(0); } return(sgc); }