6 #include "x11-memdraw.h"
8 static int xdraw(Memdrawparam*);
11 * The X acceleration doesn't fit into the standard hwaccel
12 * model because we have the extra steps of pulling the image
13 * data off the server and putting it back when we're done.
16 memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point sp,
17 Memimage *mask, Point mp, int op)
21 if((par = _memimagedrawsetup(dst, r, src, sp, mask, mp, op)) == nil)
24 /* only fetch dst data if we need it */
25 if((par->state&(Simplemask|Fullmask)) != (Simplemask|Fullmask))
26 _xgetxdata(par->dst, par->r);
28 /* always fetch source and mask */
29 _xgetxdata(par->src, par->sr);
30 _xgetxdata(par->mask, par->mr);
32 /* now can run memimagedraw on the in-memory bits */
38 /* put bits back on x server */
39 _xputxdata(par->dst, par->r);
43 xdraw(Memdrawparam *par)
53 if(par->dst->X == nil)
62 * If we have an opaque mask and source is one opaque pixel,
63 * we can convert to the destination format and just XFillRectangle.
65 m = Simplesrc|Fullsrc|Simplemask|Fullmask;
67 _xfillcolor(dst, r, par->sdval);
68 /* xdirtyxdata(dst, r); */
73 * If no source alpha and an opaque mask, we can just copy
74 * the source onto the destination. If the channels are the
75 * same and the source is not replicated, XCopyArea works.
77 * This is disabled because Ubuntu Precise seems to ship with
78 * a buggy X server that sometimes drops the XCopyArea
79 * requests on the floor.
80 m = Simplemask|Fullmask;
81 if((state&(m|Replsrc))==m && src->chan==dst->chan && src->X){
87 dp = subpt(r.min, dst->r.min);
88 sp = subpt(par->sr.min, src->r.min);
89 gc = dst->chan==GREY1 ? _x.gccopy0 : _x.gccopy;
91 XCopyArea(_x.display, xsrc->pixmap, xdst->pixmap, gc,
92 sp.x, sp.y, Dx(r), Dy(r), dp.x, dp.y);
93 /* xdirtyxdata(dst, r); * /
99 * If no source alpha, a 1-bit mask, and a simple source,
100 * we can copy through the mask onto the destination.
102 if(dst->X && mask->X && !(mask->flags&Frepl)
103 && mask->chan==GREY1 && (state&Simplesrc)){
108 dp = subpt(r.min, dst->r.min);
109 mp = subpt(r.min, subpt(par->mr.min, mask->r.min));
111 if(dst->chan == GREY1){
112 gc = _x.gcsimplesrc0;
113 if(_x.gcsimplesrc0color != sdval){
114 XSetForeground(_x.display, gc, sdval);
115 _x.gcsimplesrc0color = sdval;
117 if(_x.gcsimplesrc0pixmap != xmask->pixmap){
118 XSetStipple(_x.display, gc, xmask->pixmap);
119 _x.gcsimplesrc0pixmap = xmask->pixmap;
122 /* this doesn't work on rob's mac? */
124 /* gc = _x.gcsimplesrc;
125 if(dst->chan == CMAP8 && _x.usetable)
126 sdval = _x.tox11[sdval];
128 if(_x.gcsimplesrccolor != sdval){
129 XSetForeground(_x.display, gc, sdval);
130 _x.gcsimplesrccolor = sdval;
132 if(_x.gcsimplesrcpixmap != xmask->pixmap){
133 XSetStipple(_x.display, gc, xmask->pixmap);
134 _x.gcsimplesrcpixmap = xmask->pixmap;
138 XSetTSOrigin(_x.display, gc, mp.x, mp.y);
139 XFillRectangle(_x.display, xdst->pixmap, gc, dp.x, dp.y,
141 /* xdirtyxdata(dst, r); */