~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/xfree86/exa/exa_unaccel.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 * Copyright ļæ½ 1999 Keith Packard
 
4
 *
 
5
 * Permission to use, copy, modify, distribute, and sell this software and its
 
6
 * documentation for any purpose is hereby granted without fee, provided that
 
7
 * the above copyright notice appear in all copies and that both that
 
8
 * copyright notice and this permission notice appear in supporting
 
9
 * documentation, and that the name of Keith Packard not be used in
 
10
 * advertising or publicity pertaining to distribution of the software without
 
11
 * specific, written prior permission.  Keith Packard makes no
 
12
 * representations about the suitability of this software for any purpose.  It
 
13
 * is provided "as is" without express or implied warranty.
 
14
 *
 
15
 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
16
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
17
 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
18
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
19
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
20
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
21
 * PERFORMANCE OF THIS SOFTWARE.
 
22
 */
 
23
 
 
24
#include "exaPriv.h"
 
25
 
 
26
/*
 
27
 * These functions wrap the low-level fb rendering functions and
 
28
 * synchronize framebuffer/accelerated drawing by stalling until
 
29
 * the accelerator is idle
 
30
 */
 
31
 
 
32
void
 
33
ExaCheckFillSpans  (DrawablePtr pDrawable, GCPtr pGC, int nspans,
 
34
                   DDXPointPtr ppt, int *pwidth, int fSorted)
 
35
{
 
36
    EXA_FALLBACK(("to 0x%lx\n", (long)pDrawable));
 
37
    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
38
    fbFillSpans (pDrawable, pGC, nspans, ppt, pwidth, fSorted);
 
39
    exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
40
}
 
41
 
 
42
void
 
43
ExaCheckSetSpans (DrawablePtr pDrawable, GCPtr pGC, char *psrc,
 
44
                 DDXPointPtr ppt, int *pwidth, int nspans, int fSorted)
 
45
{
 
46
    EXA_FALLBACK(("to 0x%lx\n", (long)pDrawable));
 
47
    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
48
    fbSetSpans (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
 
49
    exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
50
}
 
51
 
 
52
void
 
53
ExaCheckPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth,
 
54
                 int x, int y, int w, int h, int leftPad, int format,
 
55
                 char *bits)
 
56
{
 
57
    EXA_FALLBACK(("to 0x%lx\n", (long)pDrawable));
 
58
    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
59
    fbPutImage (pDrawable, pGC, depth, x, y, w, h, leftPad, format, bits);
 
60
    exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
61
}
 
62
 
 
63
RegionPtr
 
64
ExaCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
 
65
                 int srcx, int srcy, int w, int h, int dstx, int dsty)
 
66
{
 
67
    RegionPtr ret;
 
68
 
 
69
    EXA_FALLBACK(("from 0x%lx to 0x%lx\n", (long)pSrc, (long)pDst));
 
70
    exaPrepareAccess (pDst, EXA_PREPARE_DEST);
 
71
    exaPrepareAccess (pSrc, EXA_PREPARE_SRC);
 
72
    ret = fbCopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);
 
73
    exaFinishAccess (pSrc, EXA_PREPARE_SRC);
 
74
    exaFinishAccess (pDst, EXA_PREPARE_DEST);
 
75
 
 
76
    return ret;
 
77
}
 
78
 
 
79
RegionPtr
 
80
ExaCheckCopyPlane (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
 
81
                  int srcx, int srcy, int w, int h, int dstx, int dsty,
 
82
                  unsigned long bitPlane)
 
83
{
 
84
    RegionPtr ret;
 
85
 
 
86
    EXA_FALLBACK(("from 0x%lx to 0x%lx\n", (long)pSrc, (long)pDst));
 
87
    exaPrepareAccess (pDst, EXA_PREPARE_DEST);
 
88
    exaPrepareAccess (pSrc, EXA_PREPARE_SRC);
 
89
    ret = fbCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty,
 
90
                       bitPlane);
 
91
    exaFinishAccess (pSrc, EXA_PREPARE_SRC);
 
92
    exaFinishAccess (pDst, EXA_PREPARE_DEST);
 
93
 
 
94
    return ret;
 
95
}
 
96
 
 
97
void
 
98
ExaCheckPolyPoint (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
 
99
                  DDXPointPtr pptInit)
 
100
{
 
101
    EXA_FALLBACK(("to 0x%lx\n", (long)pDrawable));
 
102
    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
103
    fbPolyPoint (pDrawable, pGC, mode, npt, pptInit);
 
104
    exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
105
}
 
106
 
 
107
void
 
108
ExaCheckPolylines (DrawablePtr pDrawable, GCPtr pGC,
 
109
                  int mode, int npt, DDXPointPtr ppt)
 
110
{
 
111
    EXA_FALLBACK(("to 0x%lx\n", (long)pDrawable));
 
112
 
 
113
    if (pGC->lineWidth == 0) {
 
114
        exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
115
        fbPolyLine (pDrawable, pGC, mode, npt, ppt);
 
116
        exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
117
        return;
 
118
    }
 
119
    fbPolyLine (pDrawable, pGC, mode, npt, ppt);
 
120
}
 
121
 
 
122
void
 
123
ExaCheckPolySegment (DrawablePtr pDrawable, GCPtr pGC,
 
124
                    int nsegInit, xSegment *pSegInit)
 
125
{
 
126
    EXA_FALLBACK(("to 0x%lx\n", (long)pDrawable));
 
127
    if (pGC->lineWidth == 0) {
 
128
        exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
129
        fbPolySegment (pDrawable, pGC, nsegInit, pSegInit);
 
130
        exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
131
        return;
 
132
    }
 
133
    fbPolySegment (pDrawable, pGC, nsegInit, pSegInit);
 
134
}
 
135
 
 
136
void
 
137
ExaCheckPolyRectangle (DrawablePtr pDrawable, GCPtr pGC,
 
138
                      int nrects, xRectangle *prect)
 
139
{
 
140
    EXA_FALLBACK(("to 0x%lx\n", (long)pDrawable));
 
141
    if (pGC->lineWidth == 0) {
 
142
        exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
143
        fbPolyRectangle (pDrawable, pGC, nrects, prect);
 
144
        exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
145
        return;
 
146
    }
 
147
    fbPolyRectangle (pDrawable, pGC, nrects, prect);
 
148
}
 
149
 
 
150
void
 
151
ExaCheckPolyArc (DrawablePtr pDrawable, GCPtr pGC,
 
152
                int narcs, xArc *pArcs)
 
153
{
 
154
    EXA_FALLBACK(("to 0x%lx\n", (long)pDrawable));
 
155
    if (pGC->lineWidth == 0)
 
156
    {
 
157
        exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
158
        fbPolyArc (pDrawable, pGC, narcs, pArcs);
 
159
        exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
160
        return;
 
161
    }
 
162
    miPolyArc (pDrawable, pGC, narcs, pArcs);
 
163
}
 
164
 
 
165
#if 0
 
166
void
 
167
ExaCheckFillPolygon (DrawablePtr pDrawable, GCPtr pGC,
 
168
                    int shape, int mode, int count, DDXPointPtr pPts)
 
169
{
 
170
    EXA_FALLBACK(("to 0x%lx\n", (long)pDrawable));
 
171
    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
172
    fbFillPolygon (pDrawable, pGC, mode, count, pPts);
 
173
    exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
174
}
 
175
#endif
 
176
 
 
177
void
 
178
ExaCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
 
179
                     int nrect, xRectangle *prect)
 
180
{
 
181
    EXA_FALLBACK(("to 0x%lx\n", (long)pDrawable));
 
182
    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
183
    fbPolyFillRect (pDrawable, pGC, nrect, prect);
 
184
    exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
185
}
 
186
 
 
187
void
 
188
ExaCheckPolyFillArc (DrawablePtr pDrawable, GCPtr pGC,
 
189
                    int narcs, xArc *pArcs)
 
190
{
 
191
    EXA_FALLBACK(("to 0x%lx\n", (long)pDrawable));
 
192
    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
193
    fbPolyFillArc (pDrawable, pGC, narcs, pArcs);
 
194
    exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
195
}
 
196
 
 
197
void
 
198
ExaCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
 
199
                      int x, int y, unsigned int nglyph,
 
200
                      CharInfoPtr *ppci, pointer pglyphBase)
 
201
{
 
202
    EXA_FALLBACK(("to 0x%lx\n", (long)pDrawable));
 
203
    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
204
    fbImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
 
205
    exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
206
}
 
207
 
 
208
void
 
209
ExaCheckPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
 
210
                     int x, int y, unsigned int nglyph,
 
211
                     CharInfoPtr *ppci, pointer pglyphBase)
 
212
{
 
213
    EXA_FALLBACK(("to 0x%lx\n", (long)pDrawable));
 
214
    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
215
    fbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
 
216
    exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
217
}
 
218
 
 
219
void
 
220
ExaCheckPushPixels (GCPtr pGC, PixmapPtr pBitmap,
 
221
                   DrawablePtr pDrawable,
 
222
                   int w, int h, int x, int y)
 
223
{
 
224
    EXA_FALLBACK(("from 0x%lx to 0x%lx\n", (long)pBitmap, (long)pDrawable));
 
225
    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 
226
    fbPushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
 
227
    exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
228
}
 
229
 
 
230
void
 
231
ExaCheckGetImage (DrawablePtr pDrawable,
 
232
                 int x, int y, int w, int h,
 
233
                 unsigned int format, unsigned long planeMask,
 
234
                 char *d)
 
235
{
 
236
    EXA_FALLBACK(("from 0x%lx\n", (long)pDrawable));
 
237
    exaPrepareAccess (pDrawable, EXA_PREPARE_SRC);
 
238
    fbGetImage (pDrawable, x, y, w, h, format, planeMask, d);
 
239
    exaFinishAccess (pDrawable, EXA_PREPARE_SRC);
 
240
}
 
241
 
 
242
void
 
243
ExaCheckGetSpans (DrawablePtr pDrawable,
 
244
                 int wMax,
 
245
                 DDXPointPtr ppt,
 
246
                 int *pwidth,
 
247
                 int nspans,
 
248
                 char *pdstStart)
 
249
{
 
250
    EXA_FALLBACK(("from 0x%lx\n", (long)pDrawable));
 
251
    exaPrepareAccess (pDrawable, EXA_PREPARE_SRC);
 
252
    fbGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
 
253
    exaFinishAccess (pDrawable, EXA_PREPARE_SRC);
 
254
}
 
255
 
 
256
void
 
257
ExaCheckSaveAreas (PixmapPtr    pPixmap,
 
258
                  RegionPtr     prgnSave,
 
259
                  int           xorg,
 
260
                  int           yorg,
 
261
                  WindowPtr     pWin)
 
262
{
 
263
    EXA_FALLBACK(("from 0x%lx\n", (long)&pPixmap->drawable));
 
264
    exaPrepareAccess ((DrawablePtr)pPixmap, EXA_PREPARE_DEST);
 
265
    fbSaveAreas (pPixmap, prgnSave, xorg, yorg, pWin);
 
266
    exaFinishAccess ((DrawablePtr)pPixmap, EXA_PREPARE_DEST);
 
267
}
 
268
 
 
269
void
 
270
ExaCheckRestoreAreas (PixmapPtr pPixmap,
 
271
                     RegionPtr  prgnSave,
 
272
                     int        xorg,
 
273
                     int        yorg,
 
274
                     WindowPtr  pWin)
 
275
{
 
276
    EXA_FALLBACK(("to 0x%lx\n", (long)&pPixmap->drawable));
 
277
    exaPrepareAccess ((DrawablePtr)pPixmap, EXA_PREPARE_DEST);
 
278
    fbRestoreAreas (pPixmap, prgnSave, xorg, yorg, pWin);
 
279
    exaFinishAccess ((DrawablePtr)pPixmap, EXA_PREPARE_DEST);
 
280
}
 
281
 
 
282
void
 
283
ExaCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what)
 
284
{
 
285
    EXA_FALLBACK(("from 0x%lx\n", (long)pWin));
 
286
    exaPrepareAccess (&pWin->drawable, EXA_PREPARE_DEST);
 
287
    fbPaintWindow (pWin, pRegion, what);
 
288
    exaFinishAccess (&pWin->drawable, EXA_PREPARE_DEST);
 
289
}
 
290
 
 
291
void
 
292
ExaCheckComposite (CARD8      op,
 
293
                   PicturePtr pSrc,
 
294
                   PicturePtr pMask,
 
295
                   PicturePtr pDst,
 
296
                   INT16      xSrc,
 
297
                   INT16      ySrc,
 
298
                   INT16      xMask,
 
299
                   INT16      yMask,
 
300
                   INT16      xDst,
 
301
                   INT16      yDst,
 
302
                   CARD16     width,
 
303
                   CARD16     height)
 
304
{
 
305
    EXA_FALLBACK(("from picts 0x%lx/0x%lx to pict 0x%lx\n",
 
306
                 (long)pSrc, (long)pMask, (long)pDst));
 
307
    exaPrepareAccess (pDst->pDrawable, EXA_PREPARE_DEST);
 
308
    exaPrepareAccess (pSrc->pDrawable, EXA_PREPARE_SRC);
 
309
    if (pMask)
 
310
        exaPrepareAccess (pMask->pDrawable, EXA_PREPARE_MASK);
 
311
    fbComposite (op,
 
312
                 pSrc,
 
313
                 pMask,
 
314
                 pDst,
 
315
                 xSrc,
 
316
                 ySrc,
 
317
                 xMask,
 
318
                 yMask,
 
319
                 xDst,
 
320
                 yDst,
 
321
                 width,
 
322
                 height);
 
323
    if (pMask)
 
324
        exaFinishAccess (pMask->pDrawable, EXA_PREPARE_MASK);
 
325
    exaFinishAccess (pSrc->pDrawable, EXA_PREPARE_SRC);
 
326
    exaFinishAccess (pDst->pDrawable, EXA_PREPARE_DEST);
 
327
}
 
328
 
 
329
/*
 
330
 * Only need to stall for CopyArea/CopyPlane, but we want to have the chance to
 
331
 * do migration for CopyArea.
 
332
 */
 
333
const GCOps exaAsyncPixmapGCOps = {
 
334
    ExaCheckFillSpans,
 
335
    ExaCheckSetSpans,
 
336
    ExaCheckPutImage,
 
337
    exaCopyArea,
 
338
    ExaCheckCopyPlane,
 
339
    ExaCheckPolyPoint,
 
340
    ExaCheckPolylines,
 
341
    ExaCheckPolySegment,
 
342
    ExaCheckPolyRectangle,
 
343
    ExaCheckPolyArc,
 
344
    ExaCheckFillPolygon,
 
345
    ExaCheckPolyFillRect,
 
346
    ExaCheckPolyFillArc,
 
347
    miPolyText8,
 
348
    miPolyText16,
 
349
    miImageText8,
 
350
    miImageText16,
 
351
    ExaCheckImageGlyphBlt,
 
352
    ExaCheckPolyGlyphBlt,
 
353
    ExaCheckPushPixels
 
354
#ifdef NEED_LINEHELPER
 
355
    ,NULL
 
356
#endif
 
357
};