1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun *
3*4882a593Smuzhiyun * Copyright © 1999 Keith Packard
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Permission to use, copy, modify, distribute, and sell this software and its
6*4882a593Smuzhiyun * documentation for any purpose is hereby granted without fee, provided that
7*4882a593Smuzhiyun * the above copyright notice appear in all copies and that both that
8*4882a593Smuzhiyun * copyright notice and this permission notice appear in supporting
9*4882a593Smuzhiyun * documentation, and that the name of Keith Packard not be used in
10*4882a593Smuzhiyun * advertising or publicity pertaining to distribution of the software without
11*4882a593Smuzhiyun * specific, written prior permission. Keith Packard makes no
12*4882a593Smuzhiyun * representations about the suitability of this software for any purpose. It
13*4882a593Smuzhiyun * is provided "as is" without express or implied warranty.
14*4882a593Smuzhiyun *
15*4882a593Smuzhiyun * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16*4882a593Smuzhiyun * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17*4882a593Smuzhiyun * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18*4882a593Smuzhiyun * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19*4882a593Smuzhiyun * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20*4882a593Smuzhiyun * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21*4882a593Smuzhiyun * PERFORMANCE OF THIS SOFTWARE.
22*4882a593Smuzhiyun */
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun #include "exa_priv.h"
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun #include "mipict.h"
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun /*
29*4882a593Smuzhiyun * These functions wrap the low-level fb rendering functions and
30*4882a593Smuzhiyun * synchronize framebuffer/accelerated drawing by stalling until
31*4882a593Smuzhiyun * the accelerator is idle
32*4882a593Smuzhiyun */
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun /**
35*4882a593Smuzhiyun * Calls exaPrepareAccess with EXA_PREPARE_SRC for the tile, if that is the
36*4882a593Smuzhiyun * current fill style.
37*4882a593Smuzhiyun *
38*4882a593Smuzhiyun * Solid doesn't use an extra pixmap source, and Stippled/OpaqueStippled are
39*4882a593Smuzhiyun * 1bpp and never in fb, so we don't worry about them.
40*4882a593Smuzhiyun * We should worry about them for completeness sake and going forward.
41*4882a593Smuzhiyun */
42*4882a593Smuzhiyun void
exaPrepareAccessGC(GCPtr pGC)43*4882a593Smuzhiyun exaPrepareAccessGC(GCPtr pGC)
44*4882a593Smuzhiyun {
45*4882a593Smuzhiyun if (pGC->stipple)
46*4882a593Smuzhiyun exaPrepareAccess(&pGC->stipple->drawable, EXA_PREPARE_MASK);
47*4882a593Smuzhiyun if (pGC->fillStyle == FillTiled)
48*4882a593Smuzhiyun exaPrepareAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC);
49*4882a593Smuzhiyun }
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun /**
52*4882a593Smuzhiyun * Finishes access to the tile in the GC, if used.
53*4882a593Smuzhiyun */
54*4882a593Smuzhiyun void
exaFinishAccessGC(GCPtr pGC)55*4882a593Smuzhiyun exaFinishAccessGC(GCPtr pGC)
56*4882a593Smuzhiyun {
57*4882a593Smuzhiyun if (pGC->fillStyle == FillTiled)
58*4882a593Smuzhiyun exaFinishAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC);
59*4882a593Smuzhiyun if (pGC->stipple)
60*4882a593Smuzhiyun exaFinishAccess(&pGC->stipple->drawable, EXA_PREPARE_MASK);
61*4882a593Smuzhiyun }
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun #if DEBUG_TRACE_FALL
64*4882a593Smuzhiyun char
exaDrawableLocation(DrawablePtr pDrawable)65*4882a593Smuzhiyun exaDrawableLocation(DrawablePtr pDrawable)
66*4882a593Smuzhiyun {
67*4882a593Smuzhiyun return exaDrawableIsOffscreen(pDrawable) ? 's' : 'm';
68*4882a593Smuzhiyun }
69*4882a593Smuzhiyun #endif /* DEBUG_TRACE_FALL */
70*4882a593Smuzhiyun
71*4882a593Smuzhiyun void
ExaCheckFillSpans(DrawablePtr pDrawable,GCPtr pGC,int nspans,DDXPointPtr ppt,int * pwidth,int fSorted)72*4882a593Smuzhiyun ExaCheckFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nspans,
73*4882a593Smuzhiyun DDXPointPtr ppt, int *pwidth, int fSorted)
74*4882a593Smuzhiyun {
75*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
76*4882a593Smuzhiyun EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
77*4882a593Smuzhiyun exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
78*4882a593Smuzhiyun exaPrepareAccessGC(pGC);
79*4882a593Smuzhiyun pGC->ops->FillSpans(pDrawable, pGC, nspans, ppt, pwidth, fSorted);
80*4882a593Smuzhiyun exaFinishAccessGC(pGC);
81*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
82*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
83*4882a593Smuzhiyun }
84*4882a593Smuzhiyun
85*4882a593Smuzhiyun void
ExaCheckSetSpans(DrawablePtr pDrawable,GCPtr pGC,char * psrc,DDXPointPtr ppt,int * pwidth,int nspans,int fSorted)86*4882a593Smuzhiyun ExaCheckSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *psrc,
87*4882a593Smuzhiyun DDXPointPtr ppt, int *pwidth, int nspans, int fSorted)
88*4882a593Smuzhiyun {
89*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
90*4882a593Smuzhiyun EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
91*4882a593Smuzhiyun exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
92*4882a593Smuzhiyun pGC->ops->SetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
93*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
94*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
95*4882a593Smuzhiyun }
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun void
ExaCheckPutImage(DrawablePtr pDrawable,GCPtr pGC,int depth,int x,int y,int w,int h,int leftPad,int format,char * bits)98*4882a593Smuzhiyun ExaCheckPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
99*4882a593Smuzhiyun int x, int y, int w, int h, int leftPad, int format,
100*4882a593Smuzhiyun char *bits)
101*4882a593Smuzhiyun {
102*4882a593Smuzhiyun PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable);
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun ExaPixmapPriv(pPixmap);
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
107*4882a593Smuzhiyun EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
108*4882a593Smuzhiyun if (!pExaScr->prepare_access_reg || !pExaPixmap->pDamage ||
109*4882a593Smuzhiyun exaGCReadsDestination(pDrawable, pGC->planemask, pGC->fillStyle,
110*4882a593Smuzhiyun pGC->alu, pGC->clientClip != NULL))
111*4882a593Smuzhiyun exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
112*4882a593Smuzhiyun else
113*4882a593Smuzhiyun pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_DEST,
114*4882a593Smuzhiyun DamagePendingRegion(pExaPixmap->pDamage));
115*4882a593Smuzhiyun pGC->ops->PutImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format,
116*4882a593Smuzhiyun bits);
117*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
118*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
119*4882a593Smuzhiyun }
120*4882a593Smuzhiyun
121*4882a593Smuzhiyun void
ExaCheckCopyNtoN(DrawablePtr pSrc,DrawablePtr pDst,GCPtr pGC,BoxPtr pbox,int nbox,int dx,int dy,Bool reverse,Bool upsidedown,Pixel bitplane,void * closure)122*4882a593Smuzhiyun ExaCheckCopyNtoN(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
123*4882a593Smuzhiyun BoxPtr pbox, int nbox, int dx, int dy, Bool reverse,
124*4882a593Smuzhiyun Bool upsidedown, Pixel bitplane, void *closure)
125*4882a593Smuzhiyun {
126*4882a593Smuzhiyun RegionRec reg;
127*4882a593Smuzhiyun int xoff, yoff;
128*4882a593Smuzhiyun
129*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
130*4882a593Smuzhiyun EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst,
131*4882a593Smuzhiyun exaDrawableLocation(pSrc), exaDrawableLocation(pDst)));
132*4882a593Smuzhiyun
133*4882a593Smuzhiyun if (pExaScr->prepare_access_reg && RegionInitBoxes(®, pbox, nbox)) {
134*4882a593Smuzhiyun PixmapPtr pPixmap = exaGetDrawablePixmap(pSrc);
135*4882a593Smuzhiyun
136*4882a593Smuzhiyun exaGetDrawableDeltas(pSrc, pPixmap, &xoff, &yoff);
137*4882a593Smuzhiyun RegionTranslate(®, xoff + dx, yoff + dy);
138*4882a593Smuzhiyun pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, ®);
139*4882a593Smuzhiyun RegionUninit(®);
140*4882a593Smuzhiyun }
141*4882a593Smuzhiyun else
142*4882a593Smuzhiyun exaPrepareAccess(pSrc, EXA_PREPARE_SRC);
143*4882a593Smuzhiyun
144*4882a593Smuzhiyun if (pExaScr->prepare_access_reg &&
145*4882a593Smuzhiyun !exaGCReadsDestination(pDst, pGC->planemask, pGC->fillStyle,
146*4882a593Smuzhiyun pGC->alu, pGC->clientClip != NULL) &&
147*4882a593Smuzhiyun RegionInitBoxes(®, pbox, nbox)) {
148*4882a593Smuzhiyun PixmapPtr pPixmap = exaGetDrawablePixmap(pDst);
149*4882a593Smuzhiyun
150*4882a593Smuzhiyun exaGetDrawableDeltas(pDst, pPixmap, &xoff, &yoff);
151*4882a593Smuzhiyun RegionTranslate(®, xoff, yoff);
152*4882a593Smuzhiyun pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_DEST, ®);
153*4882a593Smuzhiyun RegionUninit(®);
154*4882a593Smuzhiyun }
155*4882a593Smuzhiyun else
156*4882a593Smuzhiyun exaPrepareAccess(pDst, EXA_PREPARE_DEST);
157*4882a593Smuzhiyun
158*4882a593Smuzhiyun /* This will eventually call fbCopyNtoN, with some calculation overhead. */
159*4882a593Smuzhiyun while (nbox--) {
160*4882a593Smuzhiyun pGC->ops->CopyArea(pSrc, pDst, pGC, pbox->x1 - pSrc->x + dx,
161*4882a593Smuzhiyun pbox->y1 - pSrc->y + dy, pbox->x2 - pbox->x1,
162*4882a593Smuzhiyun pbox->y2 - pbox->y1, pbox->x1 - pDst->x,
163*4882a593Smuzhiyun pbox->y1 - pDst->y);
164*4882a593Smuzhiyun pbox++;
165*4882a593Smuzhiyun }
166*4882a593Smuzhiyun exaFinishAccess(pSrc, EXA_PREPARE_SRC);
167*4882a593Smuzhiyun exaFinishAccess(pDst, EXA_PREPARE_DEST);
168*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
169*4882a593Smuzhiyun }
170*4882a593Smuzhiyun
171*4882a593Smuzhiyun static void
ExaFallbackPrepareReg(DrawablePtr pDrawable,GCPtr pGC,int x,int y,int width,int height,int index,Bool checkReads)172*4882a593Smuzhiyun ExaFallbackPrepareReg(DrawablePtr pDrawable,
173*4882a593Smuzhiyun GCPtr pGC,
174*4882a593Smuzhiyun int x, int y, int width, int height,
175*4882a593Smuzhiyun int index, Bool checkReads)
176*4882a593Smuzhiyun {
177*4882a593Smuzhiyun ScreenPtr pScreen = pDrawable->pScreen;
178*4882a593Smuzhiyun
179*4882a593Smuzhiyun ExaScreenPriv(pScreen);
180*4882a593Smuzhiyun
181*4882a593Smuzhiyun if (pExaScr->prepare_access_reg &&
182*4882a593Smuzhiyun !(checkReads && exaGCReadsDestination(pDrawable, pGC->planemask,
183*4882a593Smuzhiyun pGC->fillStyle, pGC->alu,
184*4882a593Smuzhiyun pGC->clientClip != NULL))) {
185*4882a593Smuzhiyun BoxRec box;
186*4882a593Smuzhiyun RegionRec reg;
187*4882a593Smuzhiyun int xoff, yoff;
188*4882a593Smuzhiyun PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable);
189*4882a593Smuzhiyun
190*4882a593Smuzhiyun exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
191*4882a593Smuzhiyun box.x1 = pDrawable->x + x + xoff;
192*4882a593Smuzhiyun box.y1 = pDrawable->y + y + yoff;
193*4882a593Smuzhiyun box.x2 = box.x1 + width;
194*4882a593Smuzhiyun box.y2 = box.y1 + height;
195*4882a593Smuzhiyun
196*4882a593Smuzhiyun RegionInit(®, &box, 1);
197*4882a593Smuzhiyun pExaScr->prepare_access_reg(pPixmap, index, ®);
198*4882a593Smuzhiyun RegionUninit(®);
199*4882a593Smuzhiyun }
200*4882a593Smuzhiyun else
201*4882a593Smuzhiyun exaPrepareAccess(pDrawable, index);
202*4882a593Smuzhiyun }
203*4882a593Smuzhiyun
204*4882a593Smuzhiyun RegionPtr
ExaCheckCopyArea(DrawablePtr pSrc,DrawablePtr pDst,GCPtr pGC,int srcx,int srcy,int w,int h,int dstx,int dsty)205*4882a593Smuzhiyun ExaCheckCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
206*4882a593Smuzhiyun int srcx, int srcy, int w, int h, int dstx, int dsty)
207*4882a593Smuzhiyun {
208*4882a593Smuzhiyun RegionPtr ret;
209*4882a593Smuzhiyun
210*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
211*4882a593Smuzhiyun EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst,
212*4882a593Smuzhiyun exaDrawableLocation(pSrc), exaDrawableLocation(pDst)));
213*4882a593Smuzhiyun ExaFallbackPrepareReg(pSrc, pGC, srcx, srcy, w, h, EXA_PREPARE_SRC, FALSE);
214*4882a593Smuzhiyun ExaFallbackPrepareReg(pDst, pGC, dstx, dsty, w, h, EXA_PREPARE_DEST, TRUE);
215*4882a593Smuzhiyun ret = pGC->ops->CopyArea(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);
216*4882a593Smuzhiyun exaFinishAccess(pSrc, EXA_PREPARE_SRC);
217*4882a593Smuzhiyun exaFinishAccess(pDst, EXA_PREPARE_DEST);
218*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
219*4882a593Smuzhiyun
220*4882a593Smuzhiyun return ret;
221*4882a593Smuzhiyun }
222*4882a593Smuzhiyun
223*4882a593Smuzhiyun RegionPtr
ExaCheckCopyPlane(DrawablePtr pSrc,DrawablePtr pDst,GCPtr pGC,int srcx,int srcy,int w,int h,int dstx,int dsty,unsigned long bitPlane)224*4882a593Smuzhiyun ExaCheckCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
225*4882a593Smuzhiyun int srcx, int srcy, int w, int h, int dstx, int dsty,
226*4882a593Smuzhiyun unsigned long bitPlane)
227*4882a593Smuzhiyun {
228*4882a593Smuzhiyun RegionPtr ret;
229*4882a593Smuzhiyun
230*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
231*4882a593Smuzhiyun EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst,
232*4882a593Smuzhiyun exaDrawableLocation(pSrc), exaDrawableLocation(pDst)));
233*4882a593Smuzhiyun ExaFallbackPrepareReg(pSrc, pGC, srcx, srcy, w, h, EXA_PREPARE_SRC, FALSE);
234*4882a593Smuzhiyun ExaFallbackPrepareReg(pDst, pGC, dstx, dsty, w, h, EXA_PREPARE_DEST, TRUE);
235*4882a593Smuzhiyun ret = pGC->ops->CopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty,
236*4882a593Smuzhiyun bitPlane);
237*4882a593Smuzhiyun exaFinishAccess(pSrc, EXA_PREPARE_SRC);
238*4882a593Smuzhiyun exaFinishAccess(pDst, EXA_PREPARE_DEST);
239*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
240*4882a593Smuzhiyun
241*4882a593Smuzhiyun return ret;
242*4882a593Smuzhiyun }
243*4882a593Smuzhiyun
244*4882a593Smuzhiyun void
ExaCheckPolyPoint(DrawablePtr pDrawable,GCPtr pGC,int mode,int npt,DDXPointPtr pptInit)245*4882a593Smuzhiyun ExaCheckPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
246*4882a593Smuzhiyun DDXPointPtr pptInit)
247*4882a593Smuzhiyun {
248*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
249*4882a593Smuzhiyun EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
250*4882a593Smuzhiyun exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
251*4882a593Smuzhiyun pGC->ops->PolyPoint(pDrawable, pGC, mode, npt, pptInit);
252*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
253*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
254*4882a593Smuzhiyun }
255*4882a593Smuzhiyun
256*4882a593Smuzhiyun void
ExaCheckPolylines(DrawablePtr pDrawable,GCPtr pGC,int mode,int npt,DDXPointPtr ppt)257*4882a593Smuzhiyun ExaCheckPolylines(DrawablePtr pDrawable, GCPtr pGC,
258*4882a593Smuzhiyun int mode, int npt, DDXPointPtr ppt)
259*4882a593Smuzhiyun {
260*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
261*4882a593Smuzhiyun EXA_FALLBACK(("to %p (%c), width %d, mode %d, count %d\n",
262*4882a593Smuzhiyun pDrawable, exaDrawableLocation(pDrawable),
263*4882a593Smuzhiyun pGC->lineWidth, mode, npt));
264*4882a593Smuzhiyun
265*4882a593Smuzhiyun exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
266*4882a593Smuzhiyun exaPrepareAccessGC(pGC);
267*4882a593Smuzhiyun pGC->ops->Polylines(pDrawable, pGC, mode, npt, ppt);
268*4882a593Smuzhiyun exaFinishAccessGC(pGC);
269*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
270*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
271*4882a593Smuzhiyun }
272*4882a593Smuzhiyun
273*4882a593Smuzhiyun void
ExaCheckPolySegment(DrawablePtr pDrawable,GCPtr pGC,int nsegInit,xSegment * pSegInit)274*4882a593Smuzhiyun ExaCheckPolySegment(DrawablePtr pDrawable, GCPtr pGC,
275*4882a593Smuzhiyun int nsegInit, xSegment * pSegInit)
276*4882a593Smuzhiyun {
277*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
278*4882a593Smuzhiyun EXA_FALLBACK(("to %p (%c) width %d, count %d\n", pDrawable,
279*4882a593Smuzhiyun exaDrawableLocation(pDrawable), pGC->lineWidth, nsegInit));
280*4882a593Smuzhiyun
281*4882a593Smuzhiyun exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
282*4882a593Smuzhiyun exaPrepareAccessGC(pGC);
283*4882a593Smuzhiyun pGC->ops->PolySegment(pDrawable, pGC, nsegInit, pSegInit);
284*4882a593Smuzhiyun exaFinishAccessGC(pGC);
285*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
286*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
287*4882a593Smuzhiyun }
288*4882a593Smuzhiyun
289*4882a593Smuzhiyun void
ExaCheckPolyArc(DrawablePtr pDrawable,GCPtr pGC,int narcs,xArc * pArcs)290*4882a593Smuzhiyun ExaCheckPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc * pArcs)
291*4882a593Smuzhiyun {
292*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
293*4882a593Smuzhiyun EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
294*4882a593Smuzhiyun
295*4882a593Smuzhiyun exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
296*4882a593Smuzhiyun exaPrepareAccessGC(pGC);
297*4882a593Smuzhiyun pGC->ops->PolyArc(pDrawable, pGC, narcs, pArcs);
298*4882a593Smuzhiyun exaFinishAccessGC(pGC);
299*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
300*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
301*4882a593Smuzhiyun }
302*4882a593Smuzhiyun
303*4882a593Smuzhiyun void
ExaCheckPolyFillRect(DrawablePtr pDrawable,GCPtr pGC,int nrect,xRectangle * prect)304*4882a593Smuzhiyun ExaCheckPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
305*4882a593Smuzhiyun int nrect, xRectangle *prect)
306*4882a593Smuzhiyun {
307*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
308*4882a593Smuzhiyun EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
309*4882a593Smuzhiyun
310*4882a593Smuzhiyun exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
311*4882a593Smuzhiyun exaPrepareAccessGC(pGC);
312*4882a593Smuzhiyun pGC->ops->PolyFillRect(pDrawable, pGC, nrect, prect);
313*4882a593Smuzhiyun exaFinishAccessGC(pGC);
314*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
315*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
316*4882a593Smuzhiyun }
317*4882a593Smuzhiyun
318*4882a593Smuzhiyun void
ExaCheckImageGlyphBlt(DrawablePtr pDrawable,GCPtr pGC,int x,int y,unsigned int nglyph,CharInfoPtr * ppci,void * pglyphBase)319*4882a593Smuzhiyun ExaCheckImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
320*4882a593Smuzhiyun int x, int y, unsigned int nglyph,
321*4882a593Smuzhiyun CharInfoPtr * ppci, void *pglyphBase)
322*4882a593Smuzhiyun {
323*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
324*4882a593Smuzhiyun EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
325*4882a593Smuzhiyun exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
326*4882a593Smuzhiyun exaPrepareAccessGC(pGC);
327*4882a593Smuzhiyun pGC->ops->ImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
328*4882a593Smuzhiyun exaFinishAccessGC(pGC);
329*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
330*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
331*4882a593Smuzhiyun }
332*4882a593Smuzhiyun
333*4882a593Smuzhiyun void
ExaCheckPolyGlyphBlt(DrawablePtr pDrawable,GCPtr pGC,int x,int y,unsigned int nglyph,CharInfoPtr * ppci,void * pglyphBase)334*4882a593Smuzhiyun ExaCheckPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
335*4882a593Smuzhiyun int x, int y, unsigned int nglyph,
336*4882a593Smuzhiyun CharInfoPtr * ppci, void *pglyphBase)
337*4882a593Smuzhiyun {
338*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
339*4882a593Smuzhiyun EXA_FALLBACK(("to %p (%c), style %d alu %d\n", pDrawable,
340*4882a593Smuzhiyun exaDrawableLocation(pDrawable), pGC->fillStyle, pGC->alu));
341*4882a593Smuzhiyun exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
342*4882a593Smuzhiyun exaPrepareAccessGC(pGC);
343*4882a593Smuzhiyun pGC->ops->PolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
344*4882a593Smuzhiyun exaFinishAccessGC(pGC);
345*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
346*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
347*4882a593Smuzhiyun }
348*4882a593Smuzhiyun
349*4882a593Smuzhiyun void
ExaCheckPushPixels(GCPtr pGC,PixmapPtr pBitmap,DrawablePtr pDrawable,int w,int h,int x,int y)350*4882a593Smuzhiyun ExaCheckPushPixels(GCPtr pGC, PixmapPtr pBitmap,
351*4882a593Smuzhiyun DrawablePtr pDrawable, int w, int h, int x, int y)
352*4882a593Smuzhiyun {
353*4882a593Smuzhiyun EXA_PRE_FALLBACK_GC(pGC);
354*4882a593Smuzhiyun EXA_FALLBACK(("from %p to %p (%c,%c)\n", pBitmap, pDrawable,
355*4882a593Smuzhiyun exaDrawableLocation(&pBitmap->drawable),
356*4882a593Smuzhiyun exaDrawableLocation(pDrawable)));
357*4882a593Smuzhiyun ExaFallbackPrepareReg(pDrawable, pGC, x, y, w, h, EXA_PREPARE_DEST, TRUE);
358*4882a593Smuzhiyun ExaFallbackPrepareReg(&pBitmap->drawable, pGC, 0, 0, w, h,
359*4882a593Smuzhiyun EXA_PREPARE_SRC, FALSE);
360*4882a593Smuzhiyun exaPrepareAccessGC(pGC);
361*4882a593Smuzhiyun pGC->ops->PushPixels(pGC, pBitmap, pDrawable, w, h, x, y);
362*4882a593Smuzhiyun exaFinishAccessGC(pGC);
363*4882a593Smuzhiyun exaFinishAccess(&pBitmap->drawable, EXA_PREPARE_SRC);
364*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
365*4882a593Smuzhiyun EXA_POST_FALLBACK_GC(pGC);
366*4882a593Smuzhiyun }
367*4882a593Smuzhiyun
368*4882a593Smuzhiyun void
ExaCheckCopyWindow(WindowPtr pWin,DDXPointRec ptOldOrg,RegionPtr prgnSrc)369*4882a593Smuzhiyun ExaCheckCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
370*4882a593Smuzhiyun {
371*4882a593Smuzhiyun DrawablePtr pDrawable = &pWin->drawable;
372*4882a593Smuzhiyun ScreenPtr pScreen = pDrawable->pScreen;
373*4882a593Smuzhiyun
374*4882a593Smuzhiyun EXA_PRE_FALLBACK(pScreen);
375*4882a593Smuzhiyun EXA_FALLBACK(("from %p\n", pWin));
376*4882a593Smuzhiyun
377*4882a593Smuzhiyun /* Only need the source bits, the destination region will be overwritten */
378*4882a593Smuzhiyun if (pExaScr->prepare_access_reg) {
379*4882a593Smuzhiyun PixmapPtr pPixmap = pScreen->GetWindowPixmap(pWin);
380*4882a593Smuzhiyun int xoff, yoff;
381*4882a593Smuzhiyun
382*4882a593Smuzhiyun exaGetDrawableDeltas(&pWin->drawable, pPixmap, &xoff, &yoff);
383*4882a593Smuzhiyun RegionTranslate(prgnSrc, xoff, yoff);
384*4882a593Smuzhiyun pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, prgnSrc);
385*4882a593Smuzhiyun RegionTranslate(prgnSrc, -xoff, -yoff);
386*4882a593Smuzhiyun }
387*4882a593Smuzhiyun else
388*4882a593Smuzhiyun exaPrepareAccess(pDrawable, EXA_PREPARE_SRC);
389*4882a593Smuzhiyun
390*4882a593Smuzhiyun swap(pExaScr, pScreen, CopyWindow);
391*4882a593Smuzhiyun pScreen->CopyWindow(pWin, ptOldOrg, prgnSrc);
392*4882a593Smuzhiyun swap(pExaScr, pScreen, CopyWindow);
393*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_SRC);
394*4882a593Smuzhiyun EXA_POST_FALLBACK(pScreen);
395*4882a593Smuzhiyun }
396*4882a593Smuzhiyun
397*4882a593Smuzhiyun void
ExaCheckGetImage(DrawablePtr pDrawable,int x,int y,int w,int h,unsigned int format,unsigned long planeMask,char * d)398*4882a593Smuzhiyun ExaCheckGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
399*4882a593Smuzhiyun unsigned int format, unsigned long planeMask, char *d)
400*4882a593Smuzhiyun {
401*4882a593Smuzhiyun ScreenPtr pScreen = pDrawable->pScreen;
402*4882a593Smuzhiyun
403*4882a593Smuzhiyun EXA_PRE_FALLBACK(pScreen);
404*4882a593Smuzhiyun EXA_FALLBACK(("from %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
405*4882a593Smuzhiyun
406*4882a593Smuzhiyun ExaFallbackPrepareReg(pDrawable, NULL, x, y, w, h, EXA_PREPARE_SRC, FALSE);
407*4882a593Smuzhiyun swap(pExaScr, pScreen, GetImage);
408*4882a593Smuzhiyun pScreen->GetImage(pDrawable, x, y, w, h, format, planeMask, d);
409*4882a593Smuzhiyun swap(pExaScr, pScreen, GetImage);
410*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_SRC);
411*4882a593Smuzhiyun EXA_POST_FALLBACK(pScreen);
412*4882a593Smuzhiyun }
413*4882a593Smuzhiyun
414*4882a593Smuzhiyun void
ExaCheckGetSpans(DrawablePtr pDrawable,int wMax,DDXPointPtr ppt,int * pwidth,int nspans,char * pdstStart)415*4882a593Smuzhiyun ExaCheckGetSpans(DrawablePtr pDrawable,
416*4882a593Smuzhiyun int wMax,
417*4882a593Smuzhiyun DDXPointPtr ppt, int *pwidth, int nspans, char *pdstStart)
418*4882a593Smuzhiyun {
419*4882a593Smuzhiyun ScreenPtr pScreen = pDrawable->pScreen;
420*4882a593Smuzhiyun
421*4882a593Smuzhiyun EXA_PRE_FALLBACK(pScreen);
422*4882a593Smuzhiyun EXA_FALLBACK(("from %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
423*4882a593Smuzhiyun exaPrepareAccess(pDrawable, EXA_PREPARE_SRC);
424*4882a593Smuzhiyun swap(pExaScr, pScreen, GetSpans);
425*4882a593Smuzhiyun pScreen->GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
426*4882a593Smuzhiyun swap(pExaScr, pScreen, GetSpans);
427*4882a593Smuzhiyun exaFinishAccess(pDrawable, EXA_PREPARE_SRC);
428*4882a593Smuzhiyun EXA_POST_FALLBACK(pScreen);
429*4882a593Smuzhiyun }
430*4882a593Smuzhiyun
431*4882a593Smuzhiyun static void
ExaSrcValidate(DrawablePtr pDrawable,int x,int y,int width,int height,unsigned int subWindowMode)432*4882a593Smuzhiyun ExaSrcValidate(DrawablePtr pDrawable,
433*4882a593Smuzhiyun int x, int y, int width, int height, unsigned int subWindowMode)
434*4882a593Smuzhiyun {
435*4882a593Smuzhiyun ScreenPtr pScreen = pDrawable->pScreen;
436*4882a593Smuzhiyun
437*4882a593Smuzhiyun ExaScreenPriv(pScreen);
438*4882a593Smuzhiyun PixmapPtr pPix = exaGetDrawablePixmap(pDrawable);
439*4882a593Smuzhiyun BoxRec box;
440*4882a593Smuzhiyun RegionRec reg;
441*4882a593Smuzhiyun RegionPtr dst;
442*4882a593Smuzhiyun int xoff, yoff;
443*4882a593Smuzhiyun
444*4882a593Smuzhiyun if (pExaScr->srcPix == pPix)
445*4882a593Smuzhiyun dst = &pExaScr->srcReg;
446*4882a593Smuzhiyun else if (pExaScr->maskPix == pPix)
447*4882a593Smuzhiyun dst = &pExaScr->maskReg;
448*4882a593Smuzhiyun else
449*4882a593Smuzhiyun return;
450*4882a593Smuzhiyun
451*4882a593Smuzhiyun exaGetDrawableDeltas(pDrawable, pPix, &xoff, &yoff);
452*4882a593Smuzhiyun
453*4882a593Smuzhiyun box.x1 = x + xoff;
454*4882a593Smuzhiyun box.y1 = y + yoff;
455*4882a593Smuzhiyun box.x2 = box.x1 + width;
456*4882a593Smuzhiyun box.y2 = box.y1 + height;
457*4882a593Smuzhiyun
458*4882a593Smuzhiyun RegionInit(®, &box, 1);
459*4882a593Smuzhiyun RegionUnion(dst, dst, ®);
460*4882a593Smuzhiyun RegionUninit(®);
461*4882a593Smuzhiyun
462*4882a593Smuzhiyun if (pExaScr->SavedSourceValidate) {
463*4882a593Smuzhiyun swap(pExaScr, pScreen, SourceValidate);
464*4882a593Smuzhiyun pScreen->SourceValidate(pDrawable, x, y, width, height, subWindowMode);
465*4882a593Smuzhiyun swap(pExaScr, pScreen, SourceValidate);
466*4882a593Smuzhiyun }
467*4882a593Smuzhiyun }
468*4882a593Smuzhiyun
469*4882a593Smuzhiyun static Bool
ExaPrepareCompositeReg(ScreenPtr pScreen,CARD8 op,PicturePtr pSrc,PicturePtr pMask,PicturePtr pDst,INT16 xSrc,INT16 ySrc,INT16 xMask,INT16 yMask,INT16 xDst,INT16 yDst,CARD16 width,CARD16 height)470*4882a593Smuzhiyun ExaPrepareCompositeReg(ScreenPtr pScreen,
471*4882a593Smuzhiyun CARD8 op,
472*4882a593Smuzhiyun PicturePtr pSrc,
473*4882a593Smuzhiyun PicturePtr pMask,
474*4882a593Smuzhiyun PicturePtr pDst,
475*4882a593Smuzhiyun INT16 xSrc,
476*4882a593Smuzhiyun INT16 ySrc,
477*4882a593Smuzhiyun INT16 xMask,
478*4882a593Smuzhiyun INT16 yMask,
479*4882a593Smuzhiyun INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
480*4882a593Smuzhiyun {
481*4882a593Smuzhiyun RegionRec region;
482*4882a593Smuzhiyun RegionPtr dstReg = NULL;
483*4882a593Smuzhiyun RegionPtr srcReg = NULL;
484*4882a593Smuzhiyun RegionPtr maskReg = NULL;
485*4882a593Smuzhiyun PixmapPtr pSrcPix = NULL;
486*4882a593Smuzhiyun PixmapPtr pMaskPix = NULL;
487*4882a593Smuzhiyun PixmapPtr pDstPix;
488*4882a593Smuzhiyun
489*4882a593Smuzhiyun ExaScreenPriv(pScreen);
490*4882a593Smuzhiyun Bool ret;
491*4882a593Smuzhiyun
492*4882a593Smuzhiyun RegionNull(®ion);
493*4882a593Smuzhiyun
494*4882a593Smuzhiyun if (pSrc->pDrawable) {
495*4882a593Smuzhiyun pSrcPix = exaGetDrawablePixmap(pSrc->pDrawable);
496*4882a593Smuzhiyun RegionNull(&pExaScr->srcReg);
497*4882a593Smuzhiyun srcReg = &pExaScr->srcReg;
498*4882a593Smuzhiyun pExaScr->srcPix = pSrcPix;
499*4882a593Smuzhiyun if (pSrc != pDst)
500*4882a593Smuzhiyun RegionTranslate(pSrc->pCompositeClip,
501*4882a593Smuzhiyun -pSrc->pDrawable->x, -pSrc->pDrawable->y);
502*4882a593Smuzhiyun } else
503*4882a593Smuzhiyun pExaScr->srcPix = NULL;
504*4882a593Smuzhiyun
505*4882a593Smuzhiyun if (pMask && pMask->pDrawable) {
506*4882a593Smuzhiyun pMaskPix = exaGetDrawablePixmap(pMask->pDrawable);
507*4882a593Smuzhiyun RegionNull(&pExaScr->maskReg);
508*4882a593Smuzhiyun maskReg = &pExaScr->maskReg;
509*4882a593Smuzhiyun pExaScr->maskPix = pMaskPix;
510*4882a593Smuzhiyun if (pMask != pDst && pMask != pSrc)
511*4882a593Smuzhiyun RegionTranslate(pMask->pCompositeClip,
512*4882a593Smuzhiyun -pMask->pDrawable->x, -pMask->pDrawable->y);
513*4882a593Smuzhiyun } else
514*4882a593Smuzhiyun pExaScr->maskPix = NULL;
515*4882a593Smuzhiyun
516*4882a593Smuzhiyun RegionTranslate(pDst->pCompositeClip,
517*4882a593Smuzhiyun -pDst->pDrawable->x, -pDst->pDrawable->y);
518*4882a593Smuzhiyun
519*4882a593Smuzhiyun pExaScr->SavedSourceValidate = ExaSrcValidate;
520*4882a593Smuzhiyun swap(pExaScr, pScreen, SourceValidate);
521*4882a593Smuzhiyun ret = miComputeCompositeRegion(®ion, pSrc, pMask, pDst,
522*4882a593Smuzhiyun xSrc, ySrc, xMask, yMask,
523*4882a593Smuzhiyun xDst, yDst, width, height);
524*4882a593Smuzhiyun swap(pExaScr, pScreen, SourceValidate);
525*4882a593Smuzhiyun
526*4882a593Smuzhiyun RegionTranslate(pDst->pCompositeClip,
527*4882a593Smuzhiyun pDst->pDrawable->x, pDst->pDrawable->y);
528*4882a593Smuzhiyun if (pSrc->pDrawable && pSrc != pDst)
529*4882a593Smuzhiyun RegionTranslate(pSrc->pCompositeClip,
530*4882a593Smuzhiyun pSrc->pDrawable->x, pSrc->pDrawable->y);
531*4882a593Smuzhiyun if (pMask && pMask->pDrawable && pMask != pDst && pMask != pSrc)
532*4882a593Smuzhiyun RegionTranslate(pMask->pCompositeClip,
533*4882a593Smuzhiyun pMask->pDrawable->x, pMask->pDrawable->y);
534*4882a593Smuzhiyun
535*4882a593Smuzhiyun if (!ret) {
536*4882a593Smuzhiyun if (srcReg)
537*4882a593Smuzhiyun RegionUninit(srcReg);
538*4882a593Smuzhiyun if (maskReg)
539*4882a593Smuzhiyun RegionUninit(maskReg);
540*4882a593Smuzhiyun
541*4882a593Smuzhiyun return FALSE;
542*4882a593Smuzhiyun }
543*4882a593Smuzhiyun
544*4882a593Smuzhiyun /**
545*4882a593Smuzhiyun * Don't limit alphamaps readbacks for now until we've figured out how that
546*4882a593Smuzhiyun * should be done.
547*4882a593Smuzhiyun */
548*4882a593Smuzhiyun
549*4882a593Smuzhiyun if (pSrc->alphaMap && pSrc->alphaMap->pDrawable)
550*4882a593Smuzhiyun pExaScr->
551*4882a593Smuzhiyun prepare_access_reg(exaGetDrawablePixmap(pSrc->alphaMap->pDrawable),
552*4882a593Smuzhiyun EXA_PREPARE_AUX_SRC, NULL);
553*4882a593Smuzhiyun if (pMask && pMask->alphaMap && pMask->alphaMap->pDrawable)
554*4882a593Smuzhiyun pExaScr->
555*4882a593Smuzhiyun prepare_access_reg(exaGetDrawablePixmap(pMask->alphaMap->pDrawable),
556*4882a593Smuzhiyun EXA_PREPARE_AUX_MASK, NULL);
557*4882a593Smuzhiyun
558*4882a593Smuzhiyun if (pSrcPix)
559*4882a593Smuzhiyun pExaScr->prepare_access_reg(pSrcPix, EXA_PREPARE_SRC, srcReg);
560*4882a593Smuzhiyun
561*4882a593Smuzhiyun if (pMaskPix)
562*4882a593Smuzhiyun pExaScr->prepare_access_reg(pMaskPix, EXA_PREPARE_MASK, maskReg);
563*4882a593Smuzhiyun
564*4882a593Smuzhiyun if (srcReg)
565*4882a593Smuzhiyun RegionUninit(srcReg);
566*4882a593Smuzhiyun if (maskReg)
567*4882a593Smuzhiyun RegionUninit(maskReg);
568*4882a593Smuzhiyun
569*4882a593Smuzhiyun pDstPix = exaGetDrawablePixmap(pDst->pDrawable);
570*4882a593Smuzhiyun if (!exaOpReadsDestination(op)) {
571*4882a593Smuzhiyun int xoff;
572*4882a593Smuzhiyun int yoff;
573*4882a593Smuzhiyun
574*4882a593Smuzhiyun exaGetDrawableDeltas(pDst->pDrawable, pDstPix, &xoff, &yoff);
575*4882a593Smuzhiyun RegionTranslate(®ion, pDst->pDrawable->x + xoff,
576*4882a593Smuzhiyun pDst->pDrawable->y + yoff);
577*4882a593Smuzhiyun dstReg = ®ion;
578*4882a593Smuzhiyun }
579*4882a593Smuzhiyun
580*4882a593Smuzhiyun if (pDst->alphaMap && pDst->alphaMap->pDrawable)
581*4882a593Smuzhiyun pExaScr->
582*4882a593Smuzhiyun prepare_access_reg(exaGetDrawablePixmap(pDst->alphaMap->pDrawable),
583*4882a593Smuzhiyun EXA_PREPARE_AUX_DEST, dstReg);
584*4882a593Smuzhiyun pExaScr->prepare_access_reg(pDstPix, EXA_PREPARE_DEST, dstReg);
585*4882a593Smuzhiyun
586*4882a593Smuzhiyun RegionUninit(®ion);
587*4882a593Smuzhiyun return TRUE;
588*4882a593Smuzhiyun }
589*4882a593Smuzhiyun
590*4882a593Smuzhiyun void
ExaCheckComposite(CARD8 op,PicturePtr pSrc,PicturePtr pMask,PicturePtr pDst,INT16 xSrc,INT16 ySrc,INT16 xMask,INT16 yMask,INT16 xDst,INT16 yDst,CARD16 width,CARD16 height)591*4882a593Smuzhiyun ExaCheckComposite(CARD8 op,
592*4882a593Smuzhiyun PicturePtr pSrc,
593*4882a593Smuzhiyun PicturePtr pMask,
594*4882a593Smuzhiyun PicturePtr pDst,
595*4882a593Smuzhiyun INT16 xSrc,
596*4882a593Smuzhiyun INT16 ySrc,
597*4882a593Smuzhiyun INT16 xMask,
598*4882a593Smuzhiyun INT16 yMask,
599*4882a593Smuzhiyun INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
600*4882a593Smuzhiyun {
601*4882a593Smuzhiyun ScreenPtr pScreen = pDst->pDrawable->pScreen;
602*4882a593Smuzhiyun PictureScreenPtr ps = GetPictureScreen(pScreen);
603*4882a593Smuzhiyun
604*4882a593Smuzhiyun EXA_PRE_FALLBACK(pScreen);
605*4882a593Smuzhiyun
606*4882a593Smuzhiyun if (pExaScr->prepare_access_reg) {
607*4882a593Smuzhiyun if (!ExaPrepareCompositeReg(pScreen, op, pSrc, pMask, pDst, xSrc,
608*4882a593Smuzhiyun ySrc, xMask, yMask, xDst, yDst, width,
609*4882a593Smuzhiyun height))
610*4882a593Smuzhiyun goto out_no_clip;
611*4882a593Smuzhiyun }
612*4882a593Smuzhiyun else {
613*4882a593Smuzhiyun
614*4882a593Smuzhiyun /* We need to prepare access to any separate alpha maps first,
615*4882a593Smuzhiyun * in case the driver doesn't support EXA_PREPARE_AUX*,
616*4882a593Smuzhiyun * in which case EXA_PREPARE_SRC may be used for moving them out.
617*4882a593Smuzhiyun */
618*4882a593Smuzhiyun
619*4882a593Smuzhiyun if (pSrc->alphaMap && pSrc->alphaMap->pDrawable)
620*4882a593Smuzhiyun exaPrepareAccess(pSrc->alphaMap->pDrawable, EXA_PREPARE_AUX_SRC);
621*4882a593Smuzhiyun if (pMask && pMask->alphaMap && pMask->alphaMap->pDrawable)
622*4882a593Smuzhiyun exaPrepareAccess(pMask->alphaMap->pDrawable, EXA_PREPARE_AUX_MASK);
623*4882a593Smuzhiyun if (pDst->alphaMap && pDst->alphaMap->pDrawable)
624*4882a593Smuzhiyun exaPrepareAccess(pDst->alphaMap->pDrawable, EXA_PREPARE_AUX_DEST);
625*4882a593Smuzhiyun
626*4882a593Smuzhiyun exaPrepareAccess(pDst->pDrawable, EXA_PREPARE_DEST);
627*4882a593Smuzhiyun
628*4882a593Smuzhiyun EXA_FALLBACK(("from picts %p/%p to pict %p\n", pSrc, pMask, pDst));
629*4882a593Smuzhiyun
630*4882a593Smuzhiyun if (pSrc->pDrawable != NULL)
631*4882a593Smuzhiyun exaPrepareAccess(pSrc->pDrawable, EXA_PREPARE_SRC);
632*4882a593Smuzhiyun if (pMask && pMask->pDrawable != NULL)
633*4882a593Smuzhiyun exaPrepareAccess(pMask->pDrawable, EXA_PREPARE_MASK);
634*4882a593Smuzhiyun }
635*4882a593Smuzhiyun
636*4882a593Smuzhiyun swap(pExaScr, ps, Composite);
637*4882a593Smuzhiyun ps->Composite(op,
638*4882a593Smuzhiyun pSrc,
639*4882a593Smuzhiyun pMask,
640*4882a593Smuzhiyun pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
641*4882a593Smuzhiyun swap(pExaScr, ps, Composite);
642*4882a593Smuzhiyun if (pMask && pMask->pDrawable != NULL)
643*4882a593Smuzhiyun exaFinishAccess(pMask->pDrawable, EXA_PREPARE_MASK);
644*4882a593Smuzhiyun if (pSrc->pDrawable != NULL)
645*4882a593Smuzhiyun exaFinishAccess(pSrc->pDrawable, EXA_PREPARE_SRC);
646*4882a593Smuzhiyun exaFinishAccess(pDst->pDrawable, EXA_PREPARE_DEST);
647*4882a593Smuzhiyun if (pDst->alphaMap && pDst->alphaMap->pDrawable)
648*4882a593Smuzhiyun exaFinishAccess(pDst->alphaMap->pDrawable, EXA_PREPARE_AUX_DEST);
649*4882a593Smuzhiyun if (pSrc->alphaMap && pSrc->alphaMap->pDrawable)
650*4882a593Smuzhiyun exaFinishAccess(pSrc->alphaMap->pDrawable, EXA_PREPARE_AUX_SRC);
651*4882a593Smuzhiyun if (pMask && pMask->alphaMap && pMask->alphaMap->pDrawable)
652*4882a593Smuzhiyun exaFinishAccess(pMask->alphaMap->pDrawable, EXA_PREPARE_AUX_MASK);
653*4882a593Smuzhiyun
654*4882a593Smuzhiyun out_no_clip:
655*4882a593Smuzhiyun EXA_POST_FALLBACK(pScreen);
656*4882a593Smuzhiyun }
657*4882a593Smuzhiyun
658*4882a593Smuzhiyun /**
659*4882a593Smuzhiyun * Avoid migration ping-pong when using a mask.
660*4882a593Smuzhiyun */
661*4882a593Smuzhiyun void
ExaCheckGlyphs(CARD8 op,PicturePtr pSrc,PicturePtr pDst,PictFormatPtr maskFormat,INT16 xSrc,INT16 ySrc,int nlist,GlyphListPtr list,GlyphPtr * glyphs)662*4882a593Smuzhiyun ExaCheckGlyphs(CARD8 op,
663*4882a593Smuzhiyun PicturePtr pSrc,
664*4882a593Smuzhiyun PicturePtr pDst,
665*4882a593Smuzhiyun PictFormatPtr maskFormat,
666*4882a593Smuzhiyun INT16 xSrc,
667*4882a593Smuzhiyun INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr * glyphs)
668*4882a593Smuzhiyun {
669*4882a593Smuzhiyun ScreenPtr pScreen = pDst->pDrawable->pScreen;
670*4882a593Smuzhiyun
671*4882a593Smuzhiyun EXA_PRE_FALLBACK(pScreen);
672*4882a593Smuzhiyun
673*4882a593Smuzhiyun miGlyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
674*4882a593Smuzhiyun
675*4882a593Smuzhiyun EXA_POST_FALLBACK(pScreen);
676*4882a593Smuzhiyun }
677*4882a593Smuzhiyun
678*4882a593Smuzhiyun void
ExaCheckAddTraps(PicturePtr pPicture,INT16 x_off,INT16 y_off,int ntrap,xTrap * traps)679*4882a593Smuzhiyun ExaCheckAddTraps(PicturePtr pPicture,
680*4882a593Smuzhiyun INT16 x_off, INT16 y_off, int ntrap, xTrap * traps)
681*4882a593Smuzhiyun {
682*4882a593Smuzhiyun ScreenPtr pScreen = pPicture->pDrawable->pScreen;
683*4882a593Smuzhiyun PictureScreenPtr ps = GetPictureScreen(pScreen);
684*4882a593Smuzhiyun
685*4882a593Smuzhiyun EXA_PRE_FALLBACK(pScreen);
686*4882a593Smuzhiyun
687*4882a593Smuzhiyun EXA_FALLBACK(("to pict %p (%c)\n", pPicture,
688*4882a593Smuzhiyun exaDrawableLocation(pPicture->pDrawable)));
689*4882a593Smuzhiyun exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
690*4882a593Smuzhiyun swap(pExaScr, ps, AddTraps);
691*4882a593Smuzhiyun ps->AddTraps(pPicture, x_off, y_off, ntrap, traps);
692*4882a593Smuzhiyun swap(pExaScr, ps, AddTraps);
693*4882a593Smuzhiyun exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
694*4882a593Smuzhiyun EXA_POST_FALLBACK(pScreen);
695*4882a593Smuzhiyun }
696*4882a593Smuzhiyun
697*4882a593Smuzhiyun /**
698*4882a593Smuzhiyun * Gets the 0,0 pixel of a pixmap. Used for doing solid fills of tiled pixmaps
699*4882a593Smuzhiyun * that happen to be 1x1. Pixmap must be at least 8bpp.
700*4882a593Smuzhiyun */
701*4882a593Smuzhiyun CARD32
exaGetPixmapFirstPixel(PixmapPtr pPixmap)702*4882a593Smuzhiyun exaGetPixmapFirstPixel(PixmapPtr pPixmap)
703*4882a593Smuzhiyun {
704*4882a593Smuzhiyun switch (pPixmap->drawable.bitsPerPixel) {
705*4882a593Smuzhiyun case 32:
706*4882a593Smuzhiyun {
707*4882a593Smuzhiyun CARD32 pixel;
708*4882a593Smuzhiyun
709*4882a593Smuzhiyun pPixmap->drawable.pScreen->GetImage(&pPixmap->drawable, 0, 0, 1, 1,
710*4882a593Smuzhiyun ZPixmap, ~0, (char *) &pixel);
711*4882a593Smuzhiyun return pixel;
712*4882a593Smuzhiyun }
713*4882a593Smuzhiyun case 16:
714*4882a593Smuzhiyun {
715*4882a593Smuzhiyun CARD16 pixel;
716*4882a593Smuzhiyun
717*4882a593Smuzhiyun pPixmap->drawable.pScreen->GetImage(&pPixmap->drawable, 0, 0, 1, 1,
718*4882a593Smuzhiyun ZPixmap, ~0, (char *) &pixel);
719*4882a593Smuzhiyun return pixel;
720*4882a593Smuzhiyun }
721*4882a593Smuzhiyun case 8:
722*4882a593Smuzhiyun case 4:
723*4882a593Smuzhiyun case 1:
724*4882a593Smuzhiyun {
725*4882a593Smuzhiyun CARD8 pixel;
726*4882a593Smuzhiyun
727*4882a593Smuzhiyun pPixmap->drawable.pScreen->GetImage(&pPixmap->drawable, 0, 0, 1, 1,
728*4882a593Smuzhiyun ZPixmap, ~0, (char *) &pixel);
729*4882a593Smuzhiyun return pixel;
730*4882a593Smuzhiyun }
731*4882a593Smuzhiyun default:
732*4882a593Smuzhiyun FatalError("%s called for invalid bpp %d\n", __func__,
733*4882a593Smuzhiyun pPixmap->drawable.bitsPerPixel);
734*4882a593Smuzhiyun }
735*4882a593Smuzhiyun }
736