summaryrefslogtreecommitdiff
path: root/hw/xfree86/xaa/xaaCpyArea.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xfree86/xaa/xaaCpyArea.c')
-rw-r--r--hw/xfree86/xaa/xaaCpyArea.c409
1 files changed, 0 insertions, 409 deletions
diff --git a/hw/xfree86/xaa/xaaCpyArea.c b/hw/xfree86/xaa/xaaCpyArea.c
deleted file mode 100644
index 0b11b810e..000000000
--- a/hw/xfree86/xaa/xaaCpyArea.c
+++ /dev/null
@@ -1,409 +0,0 @@
1
2#ifdef HAVE_XORG_CONFIG_H
3#include <xorg-config.h>
4#endif
5
6#include "misc.h"
7#include "xf86.h"
8#include "xf86_OSproc.h"
9
10#include <X11/X.h>
11#include "scrnintstr.h"
12#include "xf86str.h"
13#include "xaa.h"
14#include "xaalocal.h"
15#include "migc.h"
16#include "gcstruct.h"
17#include "pixmapstr.h"
18
19/*
20 Written mostly by Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
21 */
22
23RegionPtr
24XAACopyArea(DrawablePtr pSrcDrawable,
25 DrawablePtr pDstDrawable,
26 GC * pGC,
27 int srcx, int srcy, int width, int height, int dstx, int dsty)
28{
29 XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
30
31 if (pDstDrawable->type == DRAWABLE_WINDOW) {
32 if ((pSrcDrawable->type == DRAWABLE_WINDOW) ||
33 IS_OFFSCREEN_PIXMAP(pSrcDrawable)) {
34 if (infoRec->ScreenToScreenBitBlt &&
35 CHECK_ROP(pGC, infoRec->ScreenToScreenBitBltFlags) &&
36 CHECK_ROPSRC(pGC, infoRec->ScreenToScreenBitBltFlags) &&
37 CHECK_PLANEMASK(pGC, infoRec->ScreenToScreenBitBltFlags))
38 return (XAABitBlt(pSrcDrawable, pDstDrawable,
39 pGC, srcx, srcy, width, height, dstx, dsty,
40 XAADoBitBlt, 0L));
41 }
42 else {
43 if (infoRec->WritePixmap &&
44 ((pDstDrawable->bitsPerPixel == pSrcDrawable->bitsPerPixel) ||
45 ((pDstDrawable->bitsPerPixel == 24) &&
46 (pSrcDrawable->bitsPerPixel == 32) &&
47 (infoRec->WritePixmapFlags & CONVERT_32BPP_TO_24BPP))) &&
48 CHECK_ROP(pGC, infoRec->WritePixmapFlags) &&
49 CHECK_ROPSRC(pGC, infoRec->WritePixmapFlags) &&
50 CHECK_PLANEMASK(pGC, infoRec->WritePixmapFlags) &&
51 CHECK_NO_GXCOPY(pGC, infoRec->WritePixmapFlags))
52 return (XAABitBlt(pSrcDrawable, pDstDrawable,
53 pGC, srcx, srcy, width, height, dstx, dsty,
54 XAADoImageWrite, 0L));
55 }
56 }
57 else if (IS_OFFSCREEN_PIXMAP(pDstDrawable)) {
58 if ((pSrcDrawable->type == DRAWABLE_WINDOW) ||
59 IS_OFFSCREEN_PIXMAP(pSrcDrawable)) {
60 if (infoRec->ScreenToScreenBitBlt &&
61 CHECK_ROP(pGC, infoRec->ScreenToScreenBitBltFlags) &&
62 CHECK_ROPSRC(pGC, infoRec->ScreenToScreenBitBltFlags) &&
63 CHECK_PLANEMASK(pGC, infoRec->ScreenToScreenBitBltFlags))
64 return (XAABitBlt(pSrcDrawable, pDstDrawable,
65 pGC, srcx, srcy, width, height, dstx, dsty,
66 XAADoBitBlt, 0L));
67 }
68 }
69
70 return (XAAFallbackOps.CopyArea(pSrcDrawable, pDstDrawable, pGC,
71 srcx, srcy, width, height, dstx, dsty));
72}
73
74void
75XAADoBitBlt(DrawablePtr pSrc,
76 DrawablePtr pDst, GC * pGC, RegionPtr prgnDst, DDXPointPtr pptSrc)
77{
78 int nbox, careful;
79 BoxPtr pbox, pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
80 DDXPointPtr pptTmp, pptNew1, pptNew2;
81 int xdir, ydir;
82 XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
83
84 /* XXX we have to err on the side of safety when both are windows,
85 * because we don't know if IncludeInferiors is being used.
86 */
87 careful = ((pSrc == pDst) ||
88 ((pSrc->type == DRAWABLE_WINDOW) &&
89 (pDst->type == DRAWABLE_WINDOW)));
90
91 pbox = RegionRects(prgnDst);
92 nbox = RegionNumRects(prgnDst);
93
94 pboxNew1 = NULL;
95 pptNew1 = NULL;
96 pboxNew2 = NULL;
97 pptNew2 = NULL;
98 if (careful && (pptSrc->y < pbox->y1)) {
99 /* walk source botttom to top */
100 ydir = -1;
101
102 if (nbox > 1) {
103 /* keep ordering in each band, reverse order of bands */
104 pboxNew1 = (BoxPtr) malloc(sizeof(BoxRec) * nbox);
105 if (!pboxNew1)
106 return;
107 pptNew1 = (DDXPointPtr) malloc(sizeof(DDXPointRec) * nbox);
108 if (!pptNew1) {
109 free(pboxNew1);
110 return;
111 }
112 pboxBase = pboxNext = pbox + nbox - 1;
113 while (pboxBase >= pbox) {
114 while ((pboxNext >= pbox) && (pboxBase->y1 == pboxNext->y1))
115 pboxNext--;
116 pboxTmp = pboxNext + 1;
117 pptTmp = pptSrc + (pboxTmp - pbox);
118 while (pboxTmp <= pboxBase) {
119 *pboxNew1++ = *pboxTmp++;
120 *pptNew1++ = *pptTmp++;
121 }
122 pboxBase = pboxNext;
123 }
124 pboxNew1 -= nbox;
125 pbox = pboxNew1;
126 pptNew1 -= nbox;
127 pptSrc = pptNew1;
128 }
129 }
130 else {
131 /* walk source top to bottom */
132 ydir = 1;
133 }
134
135 if (careful && (pptSrc->x < pbox->x1)) {
136 /* walk source right to left */
137 xdir = -1;
138
139 if (nbox > 1) {
140 /* reverse order of rects in each band */
141 pboxNew2 = (BoxPtr) malloc(sizeof(BoxRec) * nbox);
142 pptNew2 = (DDXPointPtr) malloc(sizeof(DDXPointRec) * nbox);
143 if (!pboxNew2 || !pptNew2) {
144 free(pptNew2);
145 free(pboxNew2);
146 if (pboxNew1) {
147 free(pptNew1);
148 free(pboxNew1);
149 }
150 return;
151 }
152 pboxBase = pboxNext = pbox;
153 while (pboxBase < pbox + nbox) {
154 while ((pboxNext < pbox + nbox) &&
155 (pboxNext->y1 == pboxBase->y1))
156 pboxNext++;
157 pboxTmp = pboxNext;
158 pptTmp = pptSrc + (pboxTmp - pbox);
159 while (pboxTmp != pboxBase) {
160 *pboxNew2++ = *--pboxTmp;
161 *pptNew2++ = *--pptTmp;
162 }
163 pboxBase = pboxNext;
164 }
165 pboxNew2 -= nbox;
166 pbox = pboxNew2;
167 pptNew2 -= nbox;
168 pptSrc = pptNew2;
169 }
170 }
171 else {
172 /* walk source left to right */
173 xdir = 1;
174 }
175
176 (*infoRec->ScreenToScreenBitBlt) (infoRec->pScrn, nbox, pptSrc, pbox,
177 xdir, ydir, pGC->alu, pGC->planemask);
178
179 if (pboxNew2) {
180 free(pptNew2);
181 free(pboxNew2);
182 }
183 if (pboxNew1) {
184 free(pptNew1);
185 free(pboxNew1);
186 }
187
188}
189
190void
191XAADoImageWrite(DrawablePtr pSrc,
192 DrawablePtr pDst,
193 GC * pGC, RegionPtr prgnDst, DDXPointPtr pptSrc)
194{
195 int srcwidth;
196 unsigned char *psrcBase; /* start of image */
197 unsigned char *srcPntr; /* index into the image */
198 BoxPtr pbox = RegionRects(prgnDst);
199 int nbox = RegionNumRects(prgnDst);
200 XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
201 int Bpp = pSrc->bitsPerPixel >> 3;
202
203 psrcBase = (unsigned char *) ((PixmapPtr) pSrc)->devPrivate.ptr;
204 srcwidth = (int) ((PixmapPtr) pSrc)->devKind;
205
206 for (; nbox; pbox++, pptSrc++, nbox--) {
207 srcPntr = psrcBase + (pptSrc->y * srcwidth) + (pptSrc->x * Bpp);
208
209 (*infoRec->WritePixmap) (infoRec->pScrn, pbox->x1, pbox->y1,
210 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
211 srcPntr, srcwidth, pGC->alu, pGC->planemask,
212 -1, pSrc->bitsPerPixel, pSrc->depth);
213 }
214}
215
216void
217XAADoImageRead(DrawablePtr pSrc,
218 DrawablePtr pDst,
219 GC * pGC, RegionPtr prgnDst, DDXPointPtr pptSrc)
220{
221 int dstwidth;
222 unsigned char *pdstBase; /* start of image */
223 unsigned char *dstPntr; /* index into the image */
224 BoxPtr pbox = RegionRects(prgnDst);
225 int nbox = RegionNumRects(prgnDst);
226 XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
227 int Bpp = pSrc->bitsPerPixel >> 3; /* wouldn't get here unless both
228 src and dst have same bpp */
229
230 pdstBase = (unsigned char *) ((PixmapPtr) pDst)->devPrivate.ptr;
231 dstwidth = (int) ((PixmapPtr) pDst)->devKind;
232
233 for (; nbox; pbox++, pptSrc++, nbox--) {
234 dstPntr = pdstBase + (pbox->y1 * dstwidth) + (pbox->x1 * Bpp);
235
236 (*infoRec->ReadPixmap) (infoRec->pScrn, pptSrc->x, pptSrc->y,
237 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
238 dstPntr, dstwidth, pSrc->bitsPerPixel,
239 pSrc->depth);
240 }
241}
242
243void
244XAAScreenToScreenBitBlt(ScrnInfoPtr pScrn,
245 int nbox,
246 DDXPointPtr pptSrc,
247 BoxPtr pbox,
248 int xdir, int ydir, int alu, unsigned int planemask)
249{
250 XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
251 int dirsetup;
252
253 if ((!(infoRec->CopyAreaFlags & ONLY_TWO_BITBLT_DIRECTIONS)
254 || (xdir == ydir)) &&
255 (!(infoRec->CopyAreaFlags & ONLY_LEFT_TO_RIGHT_BITBLT)
256 || (xdir == 1))) {
257 (*infoRec->SetupForScreenToScreenCopy) (pScrn,
258 xdir, ydir, alu, planemask, -1);
259 for (; nbox; pbox++, pptSrc++, nbox--)
260 (*infoRec->SubsequentScreenToScreenCopy) (pScrn, pptSrc->x,
261 pptSrc->y, pbox->x1,
262 pbox->y1,
263 pbox->x2 - pbox->x1,
264 pbox->y2 - pbox->y1);
265 SET_SYNC_FLAG(infoRec);
266 return;
267 }
268
269 if (infoRec->CopyAreaFlags & ONLY_LEFT_TO_RIGHT_BITBLT) {
270 /*
271 * This is the case of a chip that only supports xdir = 1,
272 * with ydir = 1 or ydir = -1, but we have xdir = -1.
273 */
274 (*infoRec->SetupForScreenToScreenCopy) (pScrn,
275 1, ydir, alu, planemask, -1);
276 for (; nbox; pbox++, pptSrc++, nbox--)
277 if (pptSrc->y != pbox->y1 || pptSrc->x >= pbox->x1)
278 /* No problem. Do a xdir = 1 blit instead. */
279 (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
280 pptSrc->x, pptSrc->y,
281 pbox->x1, pbox->y1,
282 pbox->x2 - pbox->x1,
283 pbox->y2 - pbox->y1);
284 else {
285 /*
286 * This is the difficult case. Needs striping into
287 * non-overlapping horizontal chunks.
288 */
289 int stripeWidth, w, fullStripes, extra, i;
290
291 stripeWidth = 16;
292 w = pbox->x2 - pbox->x1;
293 if (pbox->x1 - pptSrc->x < stripeWidth)
294 stripeWidth = pbox->x1 - pptSrc->x;
295 fullStripes = w / stripeWidth;
296 extra = w % stripeWidth;
297
298 /* First, take care of the little bit on the far right */
299 if (extra)
300 (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
301 pptSrc->x +
302 fullStripes *
303 stripeWidth,
304 pptSrc->y,
305 pbox->x1 +
306 fullStripes *
307 stripeWidth,
308 pbox->y1, extra,
309 pbox->y2 -
310 pbox->y1);
311
312 /* Now, take care of the rest of the blit */
313 for (i = fullStripes - 1; i >= 0; i--)
314 (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
315 pptSrc->x +
316 i * stripeWidth,
317 pptSrc->y,
318 pbox->x1 +
319 i * stripeWidth,
320 pbox->y1,
321 stripeWidth,
322 pbox->y2 -
323 pbox->y1);
324 }
325 SET_SYNC_FLAG(infoRec);
326 return;
327 }
328
329 /*
330 * Now the case of a chip that only supports xdir = ydir = 1 or
331 * xdir = ydir = -1, but we have xdir != ydir.
332 */
333 dirsetup = 0; /* No direction set up yet. */
334 for (; nbox; pbox++, pptSrc++, nbox--) {
335 if (xdir == 1 && pptSrc->y != pbox->y1) {
336 /* Do a xdir = ydir = -1 blit instead. */
337 if (dirsetup != -1) {
338 (*infoRec->SetupForScreenToScreenCopy) (pScrn,
339 -1, -1, alu, planemask,
340 -1);
341 dirsetup = -1;
342 }
343 (*infoRec->SubsequentScreenToScreenCopy) (pScrn, pptSrc->x,
344 pptSrc->y, pbox->x1,
345 pbox->y1,
346 pbox->x2 - pbox->x1,
347 pbox->y2 - pbox->y1);
348 }
349 else if (xdir == -1 && pptSrc->y != pbox->y1) {
350 /* Do a xdir = ydir = 1 blit instead. */
351 if (dirsetup != 1) {
352 (*infoRec->SetupForScreenToScreenCopy) (pScrn,
353 1, 1, alu, planemask,
354 -1);
355 dirsetup = 1;
356 }
357 (*infoRec->SubsequentScreenToScreenCopy) (pScrn, pptSrc->x,
358 pptSrc->y, pbox->x1,
359 pbox->y1,
360 pbox->x2 - pbox->x1,
361 pbox->y2 - pbox->y1);
362 }
363 else if (xdir == 1) {
364 /*
365 * xdir = 1, ydir = -1.
366 * Perform line-by-line xdir = ydir = 1 blits, going up.
367 */
368 int i;
369
370 if (dirsetup != 1) {
371 (*infoRec->SetupForScreenToScreenCopy) (pScrn,
372 1, 1, alu, planemask,
373 -1);
374 dirsetup = 1;
375 }
376 for (i = pbox->y2 - pbox->y1 - 1; i >= 0; i--)
377 (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
378 pptSrc->x,
379 pptSrc->y + i,
380 pbox->x1,
381 pbox->y1 + i,
382 pbox->x2 - pbox->x1,
383 1);
384 }
385 else {
386 /*
387 * xdir = -1, ydir = 1.
388 * Perform line-by-line xdir = ydir = -1 blits, going down.
389 */
390 int i;
391
392 if (dirsetup != -1) {
393 (*infoRec->SetupForScreenToScreenCopy) (pScrn,
394 -1, -1, alu, planemask,
395 -1);
396 dirsetup = -1;
397 }
398 for (i = 0; i < pbox->y2 - pbox->y1; i++)
399 (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
400 pptSrc->x,
401 pptSrc->y + i,
402 pbox->x1,
403 pbox->y1 + i,
404 pbox->x2 - pbox->x1,
405 1);
406 }
407 } /* next box */
408 SET_SYNC_FLAG(infoRec);
409}