2 #ifdef HAVE_XORG_CONFIG_H
3 #include <xorg-config.h>
10 #include "xf86_OSproc.h"
13 #include "scrnintstr.h"
19 #include "pixmapstr.h"
22 static void XAAValidateGC(GCPtr pGC
, unsigned long changes
, DrawablePtr pDraw
);
23 static void XAAChangeGC(GCPtr pGC
, unsigned long mask
);
24 static void XAACopyGC(GCPtr pGCSrc
, unsigned long mask
, GCPtr pGCDst
);
25 static void XAADestroyGC(GCPtr pGC
);
26 static void XAAChangeClip(GCPtr pGC
, int type
, pointer pvalue
, int nrects
);
27 static void XAADestroyClip(GCPtr pGC
);
28 static void XAACopyClip(GCPtr pgcDst
, GCPtr pgcSrc
);
30 GCFuncs XAAGCFuncs
= {
31 XAAValidateGC
, XAAChangeGC
, XAACopyGC
, XAADestroyGC
,
32 XAAChangeClip
, XAADestroyClip
, XAACopyClip
35 extern GCOps XAAPixmapOps
;
38 XAACreateGC(GCPtr pGC
)
40 ScreenPtr pScreen
= pGC
->pScreen
;
41 XAAGCPtr pGCPriv
= (XAAGCPtr
)(pGC
->devPrivates
[XAAGetGCIndex()].ptr
);
44 XAA_SCREEN_PROLOGUE(pScreen
,CreateGC
);
46 if((ret
= (*pScreen
->CreateGC
)(pGC
))) {
47 pGCPriv
->wrapOps
= NULL
;
48 pGCPriv
->wrapFuncs
= pGC
->funcs
;
49 pGCPriv
->XAAOps
= &XAAFallbackOps
;
51 pGCPriv
->DashLength
= 0;
52 pGCPriv
->DashPattern
= NULL
;
54 /* initialize any other private fields here */
55 pGC
->funcs
= &XAAGCFuncs
;
58 XAA_SCREEN_EPILOGUE(pScreen
,CreateGC
,XAACreateGC
);
67 unsigned long changes
,
70 XAAInfoRecPtr infoRec
= GET_XAAINFORECPTR_FROM_GC(pGC
);
71 XAA_GC_FUNC_PROLOGUE(pGC
);
73 (*pGC
->funcs
->ValidateGC
)(pGC
, changes
, pDraw
);
75 if((changes
& GCPlaneMask
) &&
76 ((pGC
->planemask
& infoRec
->FullPlanemasks
[pGC
->depth
- 1]) ==
77 infoRec
->FullPlanemasks
[pGC
->depth
- 1]))
82 if(pGC
->depth
!= 32) {
83 if(pGC
->bgPixel
== -1) /* -1 is reserved for transparency */
84 pGC
->bgPixel
= 0x7fffffff;
85 if(pGC
->fgPixel
== -1) /* -1 is reserved for transparency */
86 pGC
->fgPixel
= 0x7fffffff;
89 if((pDraw
->type
== DRAWABLE_PIXMAP
) && !IS_OFFSCREEN_PIXMAP(pDraw
)){
90 pGCPriv
->flags
= OPS_ARE_PIXMAP
;
91 pGCPriv
->changes
|= changes
;
93 /* make sure we're not using videomemory pixmaps to render
94 onto system memory drawables */
96 if((pGC
->fillStyle
== FillTiled
) &&
97 IS_OFFSCREEN_PIXMAP(pGC
->tile
.pixmap
) &&
98 !OFFSCREEN_PIXMAP_LOCKED(pGC
->tile
.pixmap
)) {
100 XAAPixmapPtr pPriv
= XAA_GET_PIXMAP_PRIVATE(pGC
->tile
.pixmap
);
101 FBAreaPtr area
= pPriv
->offscreenArea
;
103 XAARemoveAreaCallback(area
); /* clobbers pPriv->offscreenArea */
104 xf86FreeOffscreenArea(area
);
107 else if(!infoRec
->pScrn
->vtSema
&& (pDraw
->type
== DRAWABLE_WINDOW
)) {
109 pGCPriv
->changes
|= changes
;
112 if(!(pGCPriv
->flags
& OPS_ARE_ACCEL
)) {
113 changes
|= pGCPriv
->changes
;
114 pGCPriv
->changes
= 0;
116 pGCPriv
->flags
= OPS_ARE_ACCEL
;
119 /* Ugh. If we can't use the blitter on offscreen pixmaps used
120 as tiles, then we need to move them out as cfb can't handle
121 tiles with non-zero origins */
123 if((pGC
->fillStyle
== FillTiled
) &&
124 IS_OFFSCREEN_PIXMAP(pGC
->tile
.pixmap
) &&
125 (DO_PIXMAP_COPY
!= (*infoRec
->TiledFillChooser
)(pGC
))) {
127 XAAPixmapPtr pPriv
= XAA_GET_PIXMAP_PRIVATE(pGC
->tile
.pixmap
);
128 FBAreaPtr area
= pPriv
->offscreenArea
;
130 XAARemoveAreaCallback(area
); /* clobbers pPriv->offscreenArea */
131 xf86FreeOffscreenArea(area
);
136 XAA_GC_FUNC_EPILOGUE(pGC
);
138 if(!(pGCPriv
->flags
& OPS_ARE_ACCEL
)) return;
140 if((changes
& GCTile
) && !pGC
->tileIsPixel
&& pGC
->tile
.pixmap
){
141 XAAPixmapPtr pixPriv
= XAA_GET_PIXMAP_PRIVATE(pGC
->tile
.pixmap
);
143 if(pixPriv
->flags
& DIRTY
) {
144 pixPriv
->flags
&= ~(DIRTY
| REDUCIBILITY_MASK
);
145 pGC
->tile
.pixmap
->drawable
.serialNumber
= NEXT_SERIAL_NUMBER
;
148 if((changes
& GCStipple
) && pGC
->stipple
){
149 XAAPixmapPtr pixPriv
= XAA_GET_PIXMAP_PRIVATE(pGC
->stipple
);
151 if(pixPriv
->flags
& DIRTY
) {
152 pixPriv
->flags
&= ~(DIRTY
| REDUCIBILITY_MASK
);
153 pGC
->stipple
->drawable
.serialNumber
= NEXT_SERIAL_NUMBER
;
157 /* If our Ops are still the default ones we need to allocate new ones */
158 if(pGC
->ops
== &XAAFallbackOps
) {
159 if(!(pGCPriv
->XAAOps
= xalloc(sizeof(GCOps
)))) {
160 pGCPriv
->XAAOps
= &XAAFallbackOps
;
163 /* make a modifiable copy of the default ops */
164 memcpy(pGCPriv
->XAAOps
, &XAAFallbackOps
, sizeof(GCOps
));
165 pGC
->ops
= pGCPriv
->XAAOps
;
171 if((changes
& GCDashList
) && infoRec
->ComputeDash
)
172 infoRec
->ComputeDash(pGC
);
174 if(changes
& infoRec
->FillSpansMask
)
175 (*infoRec
->ValidateFillSpans
)(pGC
, changes
, pDraw
);
177 if(changes
& infoRec
->SetSpansMask
)
178 (*infoRec
->ValidateSetSpans
)(pGC
, changes
, pDraw
);
180 if(changes
& infoRec
->PutImageMask
)
181 (*infoRec
->ValidatePutImage
)(pGC
, changes
, pDraw
);
183 if(changes
& infoRec
->CopyAreaMask
)
184 (*infoRec
->ValidateCopyArea
)(pGC
, changes
, pDraw
);
186 if(changes
& infoRec
->CopyPlaneMask
)
187 (*infoRec
->ValidateCopyPlane
)(pGC
, changes
, pDraw
);
189 if(changes
& infoRec
->PolyPointMask
)
190 (*infoRec
->ValidatePolyPoint
)(pGC
, changes
, pDraw
);
192 if(changes
& infoRec
->PolylinesMask
)
193 (*infoRec
->ValidatePolylines
)(pGC
, changes
, pDraw
);
195 if(changes
& infoRec
->PolySegmentMask
)
196 (*infoRec
->ValidatePolySegment
)(pGC
, changes
, pDraw
);
198 if(changes
& infoRec
->PolyRectangleMask
)
199 (*infoRec
->ValidatePolyRectangle
)(pGC
, changes
, pDraw
);
201 if(changes
& infoRec
->PolyArcMask
)
202 (*infoRec
->ValidatePolyArc
)(pGC
, changes
, pDraw
);
204 if(changes
& infoRec
->FillPolygonMask
)
205 (*infoRec
->ValidateFillPolygon
)(pGC
, changes
, pDraw
);
207 if(changes
& infoRec
->PolyFillRectMask
)
208 (*infoRec
->ValidatePolyFillRect
)(pGC
, changes
, pDraw
);
210 if(changes
& infoRec
->PolyFillArcMask
)
211 (*infoRec
->ValidatePolyFillArc
)(pGC
, changes
, pDraw
);
213 if(changes
& infoRec
->PolyGlyphBltMask
)
214 (*infoRec
->ValidatePolyGlyphBlt
)(pGC
, changes
, pDraw
);
216 if(changes
& infoRec
->ImageGlyphBltMask
)
217 (*infoRec
->ValidateImageGlyphBlt
)(pGC
, changes
, pDraw
);
219 if(changes
& infoRec
->PolyText8Mask
)
220 (*infoRec
->ValidatePolyText8
)(pGC
, changes
, pDraw
);
222 if(changes
& infoRec
->PolyText16Mask
)
223 (*infoRec
->ValidatePolyText16
)(pGC
, changes
, pDraw
);
225 if(changes
& infoRec
->ImageText8Mask
)
226 (*infoRec
->ValidateImageText8
)(pGC
, changes
, pDraw
);
228 if(changes
& infoRec
->ImageText16Mask
)
229 (*infoRec
->ValidateImageText16
)(pGC
, changes
, pDraw
);
231 if(changes
& infoRec
->PushPixelsMask
)
232 (*infoRec
->ValidatePushPixels
)(pGC
, changes
, pDraw
);
237 XAADestroyGC(GCPtr pGC
)
239 XAA_GC_FUNC_PROLOGUE (pGC
);
241 if(pGCPriv
->XAAOps
!= &XAAFallbackOps
)
242 xfree(pGCPriv
->XAAOps
);
244 if(pGCPriv
->DashPattern
)
245 xfree(pGCPriv
->DashPattern
);
247 (*pGC
->funcs
->DestroyGC
)(pGC
);
248 XAA_GC_FUNC_EPILOGUE (pGC
);
257 XAA_GC_FUNC_PROLOGUE (pGC
);
258 (*pGC
->funcs
->ChangeGC
) (pGC
, mask
);
259 XAA_GC_FUNC_EPILOGUE (pGC
);
261 /* we have to assume that shared memory pixmaps are dirty
262 because we can't wrap all operations on them */
264 if((mask
& GCTile
) && !pGC
->tileIsPixel
&&
265 PIXMAP_IS_SHARED(pGC
->tile
.pixmap
))
267 XAAPixmapPtr pPixPriv
= XAA_GET_PIXMAP_PRIVATE(pGC
->tile
.pixmap
);
268 pPixPriv
->flags
|= DIRTY
;
271 if((mask
& GCStipple
) && PIXMAP_IS_SHARED(pGC
->stipple
)){
272 XAAPixmapPtr pPixPriv
= XAA_GET_PIXMAP_PRIVATE(pGC
->stipple
);
273 pPixPriv
->flags
|= DIRTY
;
283 XAA_GC_FUNC_PROLOGUE (pGCDst
);
284 (*pGCDst
->funcs
->CopyGC
) (pGCSrc
, mask
, pGCDst
);
285 XAA_GC_FUNC_EPILOGUE (pGCDst
);
294 XAA_GC_FUNC_PROLOGUE (pGC
);
295 (*pGC
->funcs
->ChangeClip
) (pGC
, type
, pvalue
, nrects
);
296 XAA_GC_FUNC_EPILOGUE (pGC
);
300 XAACopyClip(GCPtr pgcDst
, GCPtr pgcSrc
)
302 XAA_GC_FUNC_PROLOGUE (pgcDst
);
303 (* pgcDst
->funcs
->CopyClip
)(pgcDst
, pgcSrc
);
304 XAA_GC_FUNC_EPILOGUE (pgcDst
);
308 XAADestroyClip(GCPtr pGC
)
310 XAA_GC_FUNC_PROLOGUE (pGC
);
311 (* pGC
->funcs
->DestroyClip
)(pGC
);
312 XAA_GC_FUNC_EPILOGUE (pGC
);
315 /**** Pixmap Wrappers ****/
328 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
329 (*pGC
->ops
->FillSpans
)(pDraw
, pGC
, nInit
, pptInit
, pwidthInit
, fSorted
);
330 XAA_PIXMAP_OP_EPILOGUE(pGC
);
338 register DDXPointPtr ppt
,
343 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
344 (*pGC
->ops
->SetSpans
)(pDraw
, pGC
, pcharsrc
, ppt
, pwidth
, nspans
, fSorted
);
345 XAA_PIXMAP_OP_EPILOGUE(pGC
);
353 int x
, int y
, int w
, int h
,
358 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
359 (*pGC
->ops
->PutImage
)(pDraw
, pGC
, depth
, x
, y
, w
, h
,
360 leftPad
, format
, pImage
);
361 XAA_PIXMAP_OP_EPILOGUE(pGC
);
370 int width
, int height
,
373 XAAInfoRecPtr infoRec
= GET_XAAINFORECPTR_FROM_GC(pGC
);
376 if(infoRec
->pScrn
->vtSema
&&
377 ((pSrc
->type
== DRAWABLE_WINDOW
) || IS_OFFSCREEN_PIXMAP(pSrc
)))
379 if(infoRec
->ReadPixmap
&& (pGC
->alu
== GXcopy
) &&
380 (pSrc
->bitsPerPixel
== pDst
->bitsPerPixel
) &&
381 ((pGC
->planemask
& infoRec
->FullPlanemasks
[pSrc
->depth
- 1])
382 == infoRec
->FullPlanemasks
[pSrc
->depth
- 1]))
384 XAAPixmapPtr pixPriv
= XAA_GET_PIXMAP_PRIVATE((PixmapPtr
)(pDst
));
385 pixPriv
->flags
|= DIRTY
;
387 return (XAABitBlt( pSrc
, pDst
, pGC
,
388 srcx
, srcy
, width
, height
, dstx
, dsty
,
389 XAADoImageRead
, 0L));
391 if(infoRec
->NeedToSync
) {
392 (*infoRec
->Sync
)(infoRec
->pScrn
);
393 infoRec
->NeedToSync
= FALSE
;
398 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDst
);
399 ret
= (*pGC
->ops
->CopyArea
)(pSrc
, pDst
,
400 pGC
, srcx
, srcy
, width
, height
, dstx
, dsty
);
401 XAA_PIXMAP_OP_EPILOGUE(pGC
);
412 int width
, int height
,
414 unsigned long bitPlane
416 XAAInfoRecPtr infoRec
= GET_XAAINFORECPTR_FROM_GC(pGC
);
419 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDst
);
421 if(infoRec
->pScrn
->vtSema
&&
422 ((pSrc
->type
== DRAWABLE_WINDOW
) || IS_OFFSCREEN_PIXMAP(pSrc
))){
423 if(infoRec
->NeedToSync
) {
424 (*infoRec
->Sync
)(infoRec
->pScrn
);
425 infoRec
->NeedToSync
= FALSE
;
429 ret
= (*pGC
->ops
->CopyPlane
)(pSrc
, pDst
,
430 pGC
, srcx
, srcy
, width
, height
, dstx
, dsty
, bitPlane
);
431 XAA_PIXMAP_OP_EPILOGUE(pGC
);
443 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
444 (*pGC
->ops
->PolyPoint
)(pDraw
, pGC
, mode
, npt
, pptInit
);
445 XAA_PIXMAP_OP_EPILOGUE(pGC
);
457 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
458 (*pGC
->ops
->Polylines
)(pDraw
, pGC
, mode
, npt
, pptInit
);
459 XAA_PIXMAP_OP_EPILOGUE(pGC
);
463 XAAPolySegmentPixmap(
469 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
470 (*pGC
->ops
->PolySegment
)(pDraw
, pGC
, nseg
, pSeg
);
471 XAA_PIXMAP_OP_EPILOGUE(pGC
);
475 XAAPolyRectanglePixmap(
479 xRectangle
*pRectsInit
481 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
482 (*pGC
->ops
->PolyRectangle
)(pDraw
, pGC
, nRectsInit
, pRectsInit
);
483 XAA_PIXMAP_OP_EPILOGUE(pGC
);
493 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
494 (*pGC
->ops
->PolyArc
)(pDraw
, pGC
, narcs
, parcs
);
495 XAA_PIXMAP_OP_EPILOGUE(pGC
);
499 XAAFillPolygonPixmap(
507 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
508 (*pGC
->ops
->FillPolygon
)(pDraw
, pGC
, shape
, mode
, count
, ptsIn
);
509 XAA_PIXMAP_OP_EPILOGUE(pGC
);
514 XAAPolyFillRectPixmap(
518 xRectangle
*prectInit
520 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
521 (*pGC
->ops
->PolyFillRect
)(pDraw
, pGC
, nrectFill
, prectInit
);
522 XAA_PIXMAP_OP_EPILOGUE(pGC
);
527 XAAPolyFillArcPixmap(
533 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
534 (*pGC
->ops
->PolyFillArc
)(pDraw
, pGC
, narcs
, parcs
);
535 XAA_PIXMAP_OP_EPILOGUE(pGC
);
549 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
550 ret
= (*pGC
->ops
->PolyText8
)(pDraw
, pGC
, x
, y
, count
, chars
);
551 XAA_PIXMAP_OP_EPILOGUE(pGC
);
562 unsigned short *chars
566 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
567 ret
= (*pGC
->ops
->PolyText16
)(pDraw
, pGC
, x
, y
, count
, chars
);
568 XAA_PIXMAP_OP_EPILOGUE(pGC
);
581 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
582 (*pGC
->ops
->ImageText8
)(pDraw
, pGC
, x
, y
, count
, chars
);
583 XAA_PIXMAP_OP_EPILOGUE(pGC
);
586 XAAImageText16Pixmap(
592 unsigned short *chars
594 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
595 (*pGC
->ops
->ImageText16
)(pDraw
, pGC
, x
, y
, count
, chars
);
596 XAA_PIXMAP_OP_EPILOGUE(pGC
);
601 XAAImageGlyphBltPixmap(
604 int xInit
, int yInit
,
609 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
610 (*pGC
->ops
->ImageGlyphBlt
)(pDraw
, pGC
, xInit
, yInit
, nglyph
,
612 XAA_PIXMAP_OP_EPILOGUE(pGC
);
616 XAAPolyGlyphBltPixmap(
619 int xInit
, int yInit
,
624 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
625 (*pGC
->ops
->PolyGlyphBlt
)(pDraw
, pGC
, xInit
, yInit
, nglyph
,
627 XAA_PIXMAP_OP_EPILOGUE(pGC
);
635 int dx
, int dy
, int xOrg
, int yOrg
637 XAA_PIXMAP_OP_PROLOGUE(pGC
, pDraw
);
638 (*pGC
->ops
->PushPixels
)(pGC
, pBitMap
, pDraw
, dx
, dy
, xOrg
, yOrg
);
639 XAA_PIXMAP_OP_EPILOGUE(pGC
);
642 GCOps XAAPixmapOps
= {
643 XAAFillSpansPixmap
, XAASetSpansPixmap
,
644 XAAPutImagePixmap
, XAACopyAreaPixmap
,
645 XAACopyPlanePixmap
, XAAPolyPointPixmap
,
646 XAAPolylinesPixmap
, XAAPolySegmentPixmap
,
647 XAAPolyRectanglePixmap
, XAAPolyArcPixmap
,
648 XAAFillPolygonPixmap
, XAAPolyFillRectPixmap
,
649 XAAPolyFillArcPixmap
, XAAPolyText8Pixmap
,
650 XAAPolyText16Pixmap
, XAAImageText8Pixmap
,
651 XAAImageText16Pixmap
, XAAImageGlyphBltPixmap
,
652 XAAPolyGlyphBltPixmap
, XAAPushPixelsPixmap
,
653 {NULL
} /* devPrivate */