1706f2543Smrg
2706f2543Smrg#ifdef HAVE_XORG_CONFIG_H
3706f2543Smrg#include <xorg-config.h>
4706f2543Smrg#endif
5706f2543Smrg
6706f2543Smrg#include "misc.h"
7706f2543Smrg#include "xf86.h"
8706f2543Smrg#include "xf86_OSproc.h"
9706f2543Smrg
10706f2543Smrg#include <X11/X.h>
11706f2543Smrg#include "scrnintstr.h"
12706f2543Smrg#include "xf86str.h"
13706f2543Smrg#include "xaa.h"
14706f2543Smrg#include "xaalocal.h"
15706f2543Smrg#include "gcstruct.h"
16706f2543Smrg#include "pixmapstr.h"
17706f2543Smrg#include "xaawrap.h"
18706f2543Smrg
19706f2543Smrg
20706f2543Smrg
21706f2543Smrgstatic void
22706f2543SmrgXAAFillSpansFallback(
23706f2543Smrg    DrawablePtr pDraw,
24706f2543Smrg    GC		*pGC,
25706f2543Smrg    int		nInit,
26706f2543Smrg    DDXPointPtr pptInit,
27706f2543Smrg    int *pwidthInit,
28706f2543Smrg    int fSorted )
29706f2543Smrg{
30706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
31706f2543Smrg    SYNC_CHECK(pGC);
32706f2543Smrg    (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
33706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
34706f2543Smrg}
35706f2543Smrg
36706f2543Smrgstatic void
37706f2543SmrgXAASetSpansFallback(
38706f2543Smrg    DrawablePtr		pDraw,
39706f2543Smrg    GCPtr		pGC,
40706f2543Smrg    char		*pcharsrc,
41706f2543Smrg    register DDXPointPtr ppt,
42706f2543Smrg    int			*pwidth,
43706f2543Smrg    int			nspans,
44706f2543Smrg    int			fSorted )
45706f2543Smrg{
46706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
47706f2543Smrg    SYNC_CHECK(pGC);
48706f2543Smrg    (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
49706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
50706f2543Smrg}
51706f2543Smrg
52706f2543Smrgstatic void
53706f2543SmrgXAAPutImageFallback(
54706f2543Smrg    DrawablePtr pDraw,
55706f2543Smrg    GCPtr	pGC,
56706f2543Smrg    int		depth,
57706f2543Smrg    int x, int y, int w, int h,
58706f2543Smrg    int		leftPad,
59706f2543Smrg    int		format,
60706f2543Smrg    char 	*pImage )
61706f2543Smrg{
62706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
63706f2543Smrg    SYNC_CHECK(pGC);
64706f2543Smrg    (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
65706f2543Smrg		leftPad, format, pImage);
66706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
67706f2543Smrg}
68706f2543Smrg
69706f2543Smrgstatic RegionPtr
70706f2543SmrgXAACopyAreaFallback(
71706f2543Smrg    DrawablePtr pSrc,
72706f2543Smrg    DrawablePtr pDst,
73706f2543Smrg    GC *pGC,
74706f2543Smrg    int srcx, int srcy,
75706f2543Smrg    int width, int height,
76706f2543Smrg    int dstx, int dsty )
77706f2543Smrg{
78706f2543Smrg    RegionPtr ret;
79706f2543Smrg
80706f2543Smrg    XAA_GC_OP_PROLOGUE(pGC);
81706f2543Smrg    if((pSrc->type == DRAWABLE_WINDOW) || (pDst->type == DRAWABLE_WINDOW) ||
82706f2543Smrg	IS_OFFSCREEN_PIXMAP(pSrc) || IS_OFFSCREEN_PIXMAP(pDst)) {
83706f2543Smrg	SYNC_CHECK(pGC);
84706f2543Smrg    }
85706f2543Smrg    ret = (*pGC->ops->CopyArea)(pSrc, pDst,
86706f2543Smrg            pGC, srcx, srcy, width, height, dstx, dsty);
87706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
88706f2543Smrg    return ret;
89706f2543Smrg}
90706f2543Smrg
91706f2543Smrgstatic RegionPtr
92706f2543SmrgXAACopyPlaneFallback(
93706f2543Smrg    DrawablePtr	pSrc,
94706f2543Smrg    DrawablePtr	pDst,
95706f2543Smrg    GCPtr pGC,
96706f2543Smrg    int	srcx, int srcy,
97706f2543Smrg    int	width, int height,
98706f2543Smrg    int	dstx, int dsty,
99706f2543Smrg    unsigned long bitPlane )
100706f2543Smrg{
101706f2543Smrg    RegionPtr ret;
102706f2543Smrg
103706f2543Smrg    XAA_GC_OP_PROLOGUE(pGC);
104706f2543Smrg    if((pSrc->type == DRAWABLE_WINDOW) || (pDst->type == DRAWABLE_WINDOW) ||
105706f2543Smrg	IS_OFFSCREEN_PIXMAP(pSrc) || IS_OFFSCREEN_PIXMAP(pDst)) {
106706f2543Smrg	SYNC_CHECK(pGC);
107706f2543Smrg    }
108706f2543Smrg    ret = (*pGC->ops->CopyPlane)(pSrc, pDst,
109706f2543Smrg	       pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
110706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
111706f2543Smrg    return ret;
112706f2543Smrg}
113706f2543Smrg
114706f2543Smrgstatic void
115706f2543SmrgXAAPolyPointFallback(
116706f2543Smrg    DrawablePtr pDraw,
117706f2543Smrg    GCPtr pGC,
118706f2543Smrg    int mode,
119706f2543Smrg    int npt,
120706f2543Smrg    xPoint *pptInit )
121706f2543Smrg{
122706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
123706f2543Smrg    SYNC_CHECK(pGC);
124706f2543Smrg    (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
125706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
126706f2543Smrg}
127706f2543Smrg
128706f2543Smrg
129706f2543Smrgstatic void
130706f2543SmrgXAAPolylinesFallback(
131706f2543Smrg    DrawablePtr pDraw,
132706f2543Smrg    GCPtr	pGC,
133706f2543Smrg    int		mode,
134706f2543Smrg    int		npt,
135706f2543Smrg    DDXPointPtr pptInit )
136706f2543Smrg{
137706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
138706f2543Smrg    SYNC_CHECK(pGC);
139706f2543Smrg    (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
140706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
141706f2543Smrg}
142706f2543Smrg
143706f2543Smrgstatic void
144706f2543SmrgXAAPolySegmentFallback(
145706f2543Smrg    DrawablePtr	pDraw,
146706f2543Smrg    GCPtr	pGC,
147706f2543Smrg    int		nseg,
148706f2543Smrg    xSegment	*pSeg )
149706f2543Smrg{
150706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
151706f2543Smrg    SYNC_CHECK(pGC);
152706f2543Smrg    (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
153706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
154706f2543Smrg}
155706f2543Smrg
156706f2543Smrgstatic void
157706f2543SmrgXAAPolyRectangleFallback(
158706f2543Smrg    DrawablePtr  pDraw,
159706f2543Smrg    GCPtr        pGC,
160706f2543Smrg    int	         nRectsInit,
161706f2543Smrg    xRectangle  *pRectsInit )
162706f2543Smrg{
163706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
164706f2543Smrg    SYNC_CHECK(pGC);
165706f2543Smrg    (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit);
166706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
167706f2543Smrg}
168706f2543Smrg
169706f2543Smrgstatic void
170706f2543SmrgXAAPolyArcFallback(
171706f2543Smrg    DrawablePtr	pDraw,
172706f2543Smrg    GCPtr	pGC,
173706f2543Smrg    int		narcs,
174706f2543Smrg    xArc	*parcs )
175706f2543Smrg{
176706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
177706f2543Smrg    SYNC_CHECK(pGC);
178706f2543Smrg    (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
179706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
180706f2543Smrg}
181706f2543Smrg
182706f2543Smrgstatic void
183706f2543SmrgXAAFillPolygonFallback(
184706f2543Smrg    DrawablePtr	pDraw,
185706f2543Smrg    GCPtr	pGC,
186706f2543Smrg    int		shape,
187706f2543Smrg    int		mode,
188706f2543Smrg    int		count,
189706f2543Smrg    DDXPointPtr	ptsIn )
190706f2543Smrg{
191706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
192706f2543Smrg    SYNC_CHECK(pGC);
193706f2543Smrg    (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
194706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
195706f2543Smrg}
196706f2543Smrg
197706f2543Smrg
198706f2543Smrgstatic void
199706f2543SmrgXAAPolyFillRectFallback(
200706f2543Smrg    DrawablePtr	pDraw,
201706f2543Smrg    GCPtr	pGC,
202706f2543Smrg    int		nrectFill,
203706f2543Smrg    xRectangle	*prectInit )
204706f2543Smrg{
205706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
206706f2543Smrg    SYNC_CHECK(pGC);
207706f2543Smrg    (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
208706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
209706f2543Smrg}
210706f2543Smrg
211706f2543Smrg
212706f2543Smrgstatic void
213706f2543SmrgXAAPolyFillArcFallback(
214706f2543Smrg    DrawablePtr	pDraw,
215706f2543Smrg    GCPtr	pGC,
216706f2543Smrg    int		narcs,
217706f2543Smrg    xArc	*parcs )
218706f2543Smrg{
219706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
220706f2543Smrg    SYNC_CHECK(pGC);
221706f2543Smrg    (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
222706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
223706f2543Smrg}
224706f2543Smrg
225706f2543Smrgstatic int
226706f2543SmrgXAAPolyText8Fallback(
227706f2543Smrg    DrawablePtr pDraw,
228706f2543Smrg    GCPtr	pGC,
229706f2543Smrg    int		x,
230706f2543Smrg    int 	y,
231706f2543Smrg    int 	count,
232706f2543Smrg    char	*chars )
233706f2543Smrg{
234706f2543Smrg    int ret;
235706f2543Smrg
236706f2543Smrg    XAA_GC_OP_PROLOGUE(pGC);
237706f2543Smrg    SYNC_CHECK(pGC);
238706f2543Smrg    ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
239706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
240706f2543Smrg    return ret;
241706f2543Smrg}
242706f2543Smrg
243706f2543Smrgstatic int
244706f2543SmrgXAAPolyText16Fallback(
245706f2543Smrg    DrawablePtr pDraw,
246706f2543Smrg    GCPtr	pGC,
247706f2543Smrg    int		x,
248706f2543Smrg    int		y,
249706f2543Smrg    int 	count,
250706f2543Smrg    unsigned short *chars )
251706f2543Smrg{
252706f2543Smrg    int ret;
253706f2543Smrg
254706f2543Smrg    XAA_GC_OP_PROLOGUE(pGC);
255706f2543Smrg    SYNC_CHECK(pGC);
256706f2543Smrg    ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
257706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
258706f2543Smrg    return ret;
259706f2543Smrg}
260706f2543Smrg
261706f2543Smrgstatic void
262706f2543SmrgXAAImageText8Fallback(
263706f2543Smrg    DrawablePtr pDraw,
264706f2543Smrg    GCPtr	pGC,
265706f2543Smrg    int		x,
266706f2543Smrg    int		y,
267706f2543Smrg    int 	count,
268706f2543Smrg    char	*chars )
269706f2543Smrg{
270706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
271706f2543Smrg    SYNC_CHECK(pGC);
272706f2543Smrg    (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
273706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
274706f2543Smrg}
275706f2543Smrg
276706f2543Smrgstatic void
277706f2543SmrgXAAImageText16Fallback(
278706f2543Smrg    DrawablePtr pDraw,
279706f2543Smrg    GCPtr	pGC,
280706f2543Smrg    int		x,
281706f2543Smrg    int		y,
282706f2543Smrg    int 	count,
283706f2543Smrg    unsigned short *chars )
284706f2543Smrg{
285706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
286706f2543Smrg    SYNC_CHECK(pGC);
287706f2543Smrg    (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
288706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
289706f2543Smrg}
290706f2543Smrg
291706f2543Smrg
292706f2543Smrgstatic void
293706f2543SmrgXAAImageGlyphBltFallback(
294706f2543Smrg    DrawablePtr pDraw,
295706f2543Smrg    GCPtr pGC,
296706f2543Smrg    int xInit, int yInit,
297706f2543Smrg    unsigned int nglyph,
298706f2543Smrg    CharInfoPtr *ppci,
299706f2543Smrg    pointer pglyphBase )
300706f2543Smrg{
301706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
302706f2543Smrg    SYNC_CHECK(pGC);
303706f2543Smrg    (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
304706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
305706f2543Smrg}
306706f2543Smrg
307706f2543Smrgstatic void
308706f2543SmrgXAAPolyGlyphBltFallback(
309706f2543Smrg    DrawablePtr pDraw,
310706f2543Smrg    GCPtr pGC,
311706f2543Smrg    int xInit, int yInit,
312706f2543Smrg    unsigned int nglyph,
313706f2543Smrg    CharInfoPtr *ppci,
314706f2543Smrg    pointer pglyphBase )
315706f2543Smrg{
316706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
317706f2543Smrg    SYNC_CHECK(pGC);
318706f2543Smrg    (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
319706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
320706f2543Smrg}
321706f2543Smrg
322706f2543Smrgstatic void
323706f2543SmrgXAAPushPixelsFallback(
324706f2543Smrg    GCPtr	pGC,
325706f2543Smrg    PixmapPtr	pBitMap,
326706f2543Smrg    DrawablePtr pDraw,
327706f2543Smrg    int	dx, int dy, int xOrg, int yOrg )
328706f2543Smrg{
329706f2543Smrg    XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
330706f2543Smrg    SYNC_CHECK(pGC);
331706f2543Smrg    (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
332706f2543Smrg    XAA_GC_OP_EPILOGUE(pGC);
333706f2543Smrg}
334706f2543Smrg
335706f2543SmrgGCOps XAAFallbackOps = {
336706f2543Smrg    XAAFillSpansFallback, XAASetSpansFallback,
337706f2543Smrg    XAAPutImageFallback, XAACopyAreaFallback,
338706f2543Smrg    XAACopyPlaneFallback, XAAPolyPointFallback,
339706f2543Smrg    XAAPolylinesFallback, XAAPolySegmentFallback,
340706f2543Smrg    XAAPolyRectangleFallback, XAAPolyArcFallback,
341706f2543Smrg    XAAFillPolygonFallback, XAAPolyFillRectFallback,
342706f2543Smrg    XAAPolyFillArcFallback, XAAPolyText8Fallback,
343706f2543Smrg    XAAPolyText16Fallback, XAAImageText8Fallback,
344706f2543Smrg    XAAImageText16Fallback, XAAImageGlyphBltFallback,
345706f2543Smrg    XAAPolyGlyphBltFallback, XAAPushPixelsFallback,
346706f2543Smrg};
347706f2543Smrg
348706f2543SmrgGCOps *XAAGetFallbackOps(void)
349706f2543Smrg{
350706f2543Smrg    return &XAAFallbackOps;
351706f2543Smrg}
352