2 #ifdef HAVE_XORG_CONFIG_H
3 #include <xorg-config.h>
11 #include "scrnintstr.h"
12 #include "pixmapstr.h"
15 #include "colormapst.h"
33 int width
, int height
,
37 if(pSrcDraw
->bitsPerPixel
== 32) {
38 if(pDstDraw
->bitsPerPixel
== 32) {
39 if((pGC
->alu
== GXcopy
) && (pGC
->planemask
== 0xff000000)) {
40 return cfb32BitBlt (pSrcDraw
, pDstDraw
,
41 pGC
, srcx
, srcy
, width
, height
, dstx
, dsty
,
42 cfbDoBitblt8To8GXcopy
, 0L);
44 return(cfb32CopyArea(pSrcDraw
, pDstDraw
, pGC
, srcx
, srcy
,
45 width
, height
, dstx
, dsty
));
47 /* have to translate 32 -> 8 copies */
48 return cfb32BitBlt (pSrcDraw
, pDstDraw
,
49 pGC
, srcx
, srcy
, width
, height
, dstx
, dsty
,
50 cfbDoBitblt32To8
, 0L);
53 if(pDstDraw
->bitsPerPixel
== 32) {
54 /* have to translate 8 -> 32 copies */
55 return cfb32BitBlt (pSrcDraw
, pDstDraw
,
56 pGC
, srcx
, srcy
, width
, height
, dstx
, dsty
,
57 cfbDoBitblt8To32
, 0L);
59 return(cfbCopyArea(pSrcDraw
, pDstDraw
, pGC
, srcx
, srcy
,
60 width
, height
, dstx
, dsty
));
77 BoxPtr pbox
= REGION_RECTS(prgnDst
);
78 int nbox
= REGION_NUM_RECTS(prgnDst
);
79 unsigned char *ptr8
, *ptr32
;
80 unsigned char *data8
, *data32
;
84 cfbGetByteWidthAndPointer(pSrc
, pitch8
, ptr8
);
85 cfbGetByteWidthAndPointer(pDst
, pitch32
, ptr32
);
86 ptr32
+= 3; /* point to the top byte */
90 if((pm
== 0xff) && (rop
== GXcopy
)) {
91 for(;nbox
; pbox
++, pptSrc
++, nbox
--) {
92 data8
= ptr8
+ (pptSrc
->y
* pitch8
) + pptSrc
->x
;
93 data32
= ptr32
+ (pbox
->y1
* pitch32
) + (pbox
->x1
<< 2);
94 width
= pbox
->x2
- pbox
->x1
;
95 height
= pbox
->y2
- pbox
->y1
;
98 for(i
= 0; i
< width
; i
++)
99 data32
[i
<< 2] = data8
[i
];
104 } else { /* it ain't pretty, but hey */
105 for(;nbox
; pbox
++, pptSrc
++, nbox
--) {
106 data8
= ptr8
+ (pptSrc
->y
* pitch8
) + pptSrc
->x
;
107 data32
= ptr32
+ (pbox
->y1
* pitch32
) + (pbox
->x1
<< 2);
108 width
= pbox
->x2
- pbox
->x1
;
109 height
= pbox
->y2
- pbox
->y1
;
114 for(i
= 0; i
< width
; i
++)
115 data32
[i
<<2] = (data8
[i
] & pm
) | (data32
[i
<<2] & ~pm
);
118 for(i
= 0; i
< width
; i
++)
119 data32
[i
<<2] |= data8
[i
] & pm
;
122 for(i
= 0; i
< width
; i
++)
126 for(i
= 0; i
< width
; i
++)
127 data32
[i
<<2] &= data8
[i
] | ~pm
;
130 for(i
= 0; i
< width
; i
++)
131 data32
[i
<<2] = ~data32
[i
<<2] & (data8
[i
] | ~pm
);
134 for(i
= 0; i
< width
; i
++)
135 data32
[i
<<2] &= ~data8
[i
] | ~pm
;
140 for(i
= 0; i
< width
; i
++)
141 data32
[i
<<2] ^= data8
[i
] & pm
;
144 for(i
= 0; i
< width
; i
++)
145 data32
[i
<<2] = ~(data32
[i
<<2] | (data8
[i
] & pm
));
148 for(i
= 0; i
< width
; i
++)
149 data32
[i
<<2] = ~(data32
[i
<<2] ^ (data8
[i
] & pm
));
152 for(i
= 0; i
< width
; i
++)
156 for(i
= 0; i
< width
; i
++)
157 data32
[i
<<2] = ~data32
[i
<<2] | (data8
[i
] & pm
);
160 for(i
= 0; i
< width
; i
++)
161 data32
[i
<<2] = (~data8
[i
] & pm
) | (data32
[i
<<2] & ~pm
);
164 for(i
= 0; i
< width
; i
++)
165 data32
[i
<<2] |= ~data8
[i
] & pm
;
168 for(i
= 0; i
< width
; i
++)
169 data32
[i
<<2] = ~(data32
[i
<<2] & (data8
[i
] | ~pm
));
172 for(i
= 0; i
< width
; i
++)
193 BoxPtr pbox
= REGION_RECTS(prgnDst
);
194 int nbox
= REGION_NUM_RECTS(prgnDst
);
195 unsigned char *ptr8
, *ptr32
;
196 unsigned char *data8
, *data32
;
198 int height
, width
, i
;
200 cfbGetByteWidthAndPointer(pDst
, pitch8
, ptr8
);
201 cfbGetByteWidthAndPointer(pSrc
, pitch32
, ptr32
);
202 ptr32
+= 3; /* point to the top byte */
204 if(((pm
& 0xff) == 0xff) && (rop
== GXcopy
)) {
205 for(;nbox
; pbox
++, pptSrc
++, nbox
--) {
206 data8
= ptr8
+ (pbox
->y1
* pitch8
) + pbox
->x1
;
207 data32
= ptr32
+ (pptSrc
->y
* pitch32
) + (pptSrc
->x
<< 2);
209 width
= pbox
->x2
- pbox
->x1
;
210 height
= pbox
->y2
- pbox
->y1
;
213 for(i
= 0; i
< width
; i
++)
214 data8
[i
] = data32
[i
<< 2];
220 for(;nbox
; pbox
++, pptSrc
++, nbox
--) {
221 data8
= ptr8
+ (pbox
->y1
* pitch8
) + pbox
->x1
;
222 data32
= ptr32
+ (pptSrc
->y
* pitch32
) + (pptSrc
->x
<< 2);
224 width
= pbox
->x2
- pbox
->x1
;
225 height
= pbox
->y2
- pbox
->y1
;
230 for(i
= 0; i
< width
; i
++)
231 data8
[i
] = (data32
[i
<<2] & pm
) | (data8
[i
] & ~pm
);
234 for(i
= 0; i
< width
; i
++)
235 data8
[i
] |= data32
[i
<<2] & pm
;
238 for(i
= 0; i
< width
; i
++)
242 for(i
= 0; i
< width
; i
++)
243 data8
[i
] &= data32
[i
<<2] | ~pm
;
246 for(i
= 0; i
< width
; i
++)
247 data8
[i
] = ~data8
[i
] & (data32
[i
<<2] | ~pm
);
250 for(i
= 0; i
< width
; i
++)
251 data8
[i
] &= ~data32
[i
<<2] | ~pm
;
256 for(i
= 0; i
< width
; i
++)
257 data8
[i
] ^= data32
[i
<<2] & pm
;
260 for(i
= 0; i
< width
; i
++)
261 data8
[i
] = ~(data8
[i
] | (data32
[i
<<2] & pm
));
264 for(i
= 0; i
< width
; i
++)
265 data8
[i
] = ~(data8
[i
] ^ (data32
[i
<<2] & pm
));
268 for(i
= 0; i
< width
; i
++)
272 for(i
= 0; i
< width
; i
++)
273 data8
[i
] = ~data8
[i
] | (data32
[i
<<2] & pm
);
276 for(i
= 0; i
< width
; i
++)
277 data8
[i
] = (~data32
[i
<<2] & pm
) | (data8
[i
] & ~pm
);
280 for(i
= 0; i
< width
; i
++)
281 data8
[i
] |= ~data32
[i
<<2] & pm
;
284 for(i
= 0; i
< width
; i
++)
285 data8
[i
] = ~(data8
[i
] & (data32
[i
<<2] | ~pm
));
288 for(i
= 0; i
< width
; i
++)
303 unsigned char *SrcPtr
,
305 unsigned char *DstPtr
,
312 int i
, j
, width
, height
, ydir2
;
318 ydir2
= ydir
* DstPitch
;
321 for(;nbox
; pbox
++, pptSrc
++, nbox
--) {
322 src
= SrcPtr
+ (pptSrc
->y
* SrcPitch
) + (pptSrc
->x
<< 2);
323 dst
= DstPtr
+ (pbox
->y1
* DstPitch
) + (pbox
->x1
<< 2);
324 width
= pbox
->x2
- pbox
->x1
;
325 height
= pbox
->y2
- pbox
->y1
;
328 src
+= (height
- 1) * SrcPitch
;
329 dst
+= (height
- 1) * DstPitch
;
333 register int tmp
= (width
- 1) << 2;
339 for(i
= width
, j
= 0; i
--; j
+=xdir
)
349 unsigned char *SrcPtr
,
351 unsigned char *DstPtr
,
358 int i
, j
, width
, height
, ydir2
;
362 ydir2
= ydir
* DstPitch
;
365 for(;nbox
; pbox
++, pptSrc
++, nbox
--) {
366 src
= SrcPtr
+ (pptSrc
->y
* SrcPitch
) + (pptSrc
->x
<< 2);
367 dst
= DstPtr
+ (pbox
->y1
* DstPitch
) + (pbox
->x1
<< 2);
368 width
= pbox
->x2
- pbox
->x1
;
369 height
= pbox
->y2
- pbox
->y1
;
372 src
+= (height
- 1) * SrcPitch
;
373 dst
+= (height
- 1) * DstPitch
;
377 register int tmp
= (width
- 1) << 2;
383 for(i
= width
, j
= 0; i
--; j
+=xdir
) {
384 *((CARD16
*)(dst
+ j
)) = *((CARD32
*)(src
+ j
));
385 dst
[j
+ 2] = src
[j
+ 2];
401 unsigned char *SrcPtr
,
403 unsigned char *DstPtr
,
410 int nbox
, careful
, SrcPitch
, DstPitch
;
411 BoxPtr pbox
, pboxTmp
, pboxNext
, pboxBase
, pboxNew1
, pboxNew2
;
412 DDXPointPtr pptTmp
, pptNew1
, pptNew2
;
414 unsigned char *SrcPtr
, *DstPtr
;
416 /* XXX we have to err on the side of safety when both are windows,
417 * because we don't know if IncludeInferiors is being used.
419 careful
= ((pSrc
== pDst
) ||
420 ((pSrc
->type
== DRAWABLE_WINDOW
) &&
421 (pDst
->type
== DRAWABLE_WINDOW
)));
423 pbox
= REGION_RECTS(prgnDst
);
424 nbox
= REGION_NUM_RECTS(prgnDst
);
430 if (careful
&& (pptSrc
->y
< pbox
->y1
)) {
431 /* walk source botttom to top */
435 /* keep ordering in each band, reverse order of bands */
436 pboxNew1
= (BoxPtr
)ALLOCATE_LOCAL(sizeof(BoxRec
) * nbox
);
439 pptNew1
= (DDXPointPtr
)ALLOCATE_LOCAL(sizeof(DDXPointRec
) * nbox
);
441 DEALLOCATE_LOCAL(pboxNew1
);
444 pboxBase
= pboxNext
= pbox
+nbox
-1;
445 while (pboxBase
>= pbox
) {
446 while ((pboxNext
>= pbox
) &&
447 (pboxBase
->y1
== pboxNext
->y1
))
449 pboxTmp
= pboxNext
+1;
450 pptTmp
= pptSrc
+ (pboxTmp
- pbox
);
451 while (pboxTmp
<= pboxBase
) {
452 *pboxNew1
++ = *pboxTmp
++;
453 *pptNew1
++ = *pptTmp
++;
463 /* walk source top to bottom */
467 if (careful
&& (pptSrc
->x
< pbox
->x1
)) {
468 /* walk source right to left */
472 /* reverse order of rects in each band */
473 pboxNew2
= (BoxPtr
)ALLOCATE_LOCAL(sizeof(BoxRec
) * nbox
);
474 pptNew2
= (DDXPointPtr
)ALLOCATE_LOCAL(sizeof(DDXPointRec
) * nbox
);
475 if(!pboxNew2
|| !pptNew2
) {
476 if (pptNew2
) DEALLOCATE_LOCAL(pptNew2
);
477 if (pboxNew2
) DEALLOCATE_LOCAL(pboxNew2
);
479 DEALLOCATE_LOCAL(pptNew1
);
480 DEALLOCATE_LOCAL(pboxNew1
);
484 pboxBase
= pboxNext
= pbox
;
485 while (pboxBase
< pbox
+nbox
) {
486 while ((pboxNext
< pbox
+nbox
) &&
487 (pboxNext
->y1
== pboxBase
->y1
))
490 pptTmp
= pptSrc
+ (pboxTmp
- pbox
);
491 while (pboxTmp
!= pboxBase
) {
492 *pboxNew2
++ = *--pboxTmp
;
493 *pptNew2
++ = *--pptTmp
;
503 /* walk source left to right */
507 cfbGetByteWidthAndPointer(pSrc
, SrcPitch
, SrcPtr
);
508 cfbGetByteWidthAndPointer(pDst
, DstPitch
, DstPtr
);
510 (*DoBlt
)(SrcPtr
,SrcPitch
,DstPtr
,DstPitch
,nbox
,pptSrc
,pbox
,xdir
,ydir
);
513 DEALLOCATE_LOCAL(pptNew2
);
514 DEALLOCATE_LOCAL(pboxNew2
);
517 DEALLOCATE_LOCAL(pptNew1
);
518 DEALLOCATE_LOCAL(pboxNew1
);
524 /* A couple routines to speed up full planemask copies */
527 cfbDoBitblt8To8GXcopy(
535 cfb8_32DoBitBlt(pSrc
, pDst
, prgnDst
, pptSrc
, Do8To8Blt
);
540 cfbDoBitblt24To24GXcopy(
548 cfb8_32DoBitBlt(pSrc
, pDst
, prgnDst
, pptSrc
, Do24To24Blt
);