7 Copyright 1989, 1998 The Open Group
9 Permission to use, copy, modify, distribute, and sell this software and its
10 documentation for any purpose is hereby granted without fee, provided that
11 the above copyright notice appear in all copies and that both that
12 copyright notice and this permission notice appear in supporting
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of The Open Group shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings
27 in this Software without prior written authorization from The Open Group.
31 #ifdef HAVE_DIX_CONFIG_H
32 #include <dix-config.h>
40 #include "pixmapstr.h"
41 #include "scrnintstr.h"
42 #include "windowstr.h"
45 #include "cfbmskbits.h"
50 cfbFillBoxTileOdd (pDrawable
, n
, rects
, tile
, xrot
, yrot
)
51 DrawablePtr pDrawable
;
58 if (tile
->drawable
.width
& 3)
60 if (tile
->drawable
.width
& PIM
)
62 cfbFillBoxTileOddCopy (pDrawable
, n
, rects
, tile
, xrot
, yrot
, GXcopy
, ~0L);
64 cfbFillBoxTile32sCopy (pDrawable
, n
, rects
, tile
, xrot
, yrot
, GXcopy
, ~0L);
68 cfbFillRectTileOdd (pDrawable
, pGC
, nBox
, pBox
)
69 DrawablePtr pDrawable
;
75 void (*fill
)(DrawablePtr
, int, BoxPtr
, PixmapPtr
, int, int, int, unsigned long);
77 xrot
= pDrawable
->x
+ pGC
->patOrg
.x
;
78 yrot
= pDrawable
->y
+ pGC
->patOrg
.y
;
80 if (pGC
->tile
.pixmap
->drawable
.width
& 3)
82 if (pGC
->tile
.pixmap
->drawable
.width
& PIM
)
85 fill
= cfbFillBoxTileOddGeneral
;
86 if ((pGC
->planemask
& PMSK
) == PMSK
)
88 if (pGC
->alu
== GXcopy
)
89 fill
= cfbFillBoxTileOddCopy
;
94 fill
= cfbFillBoxTile32sGeneral
;
95 if ((pGC
->planemask
& PMSK
) == PMSK
)
97 if (pGC
->alu
== GXcopy
)
98 fill
= cfbFillBoxTile32sCopy
;
101 (*fill
) (pDrawable
, nBox
, pBox
, pGC
->tile
.pixmap
, xrot
, yrot
, pGC
->alu
, pGC
->planemask
);
104 #define NUM_STACK_RECTS 1024
107 cfbPolyFillRect(pDrawable
, pGC
, nrectFill
, prectInit
)
108 DrawablePtr pDrawable
;
110 int nrectFill
; /* number of rectangles to fill */
111 xRectangle
*prectInit
; /* Pointer to first rectangle to fill */
115 register BoxPtr pbox
;
116 register BoxPtr pboxClipped
;
117 BoxPtr pboxClippedBase
;
119 BoxRec stackRects
[NUM_STACK_RECTS
];
122 void (*BoxFill
)(DrawablePtr
, GCPtr
, int, BoxPtr
);
127 if ((pGC
->fillStyle
== FillStippled
) ||
128 (pGC
->fillStyle
== FillOpaqueStippled
)) {
129 miPolyFillRect(pDrawable
, pGC
, nrectFill
, prectInit
);
134 priv
= cfbGetGCPrivate(pGC
);
135 prgnClip
= pGC
->pCompositeClip
;
138 switch (pGC
->fillStyle
)
143 BoxFill
= cfbFillRectSolidCopy
;
146 BoxFill
= cfbFillRectSolidXor
;
149 BoxFill
= cfbFillRectSolidGeneral
;
154 if (!pGC
->pRotatedPixmap
)
155 BoxFill
= cfbFillRectTileOdd
;
158 if (pGC
->alu
== GXcopy
&& (pGC
->planemask
& PMSK
) == PMSK
)
159 BoxFill
= cfbFillRectTile32Copy
;
161 BoxFill
= cfbFillRectTile32General
;
166 if (!pGC
->pRotatedPixmap
)
167 BoxFill
= cfb8FillRectStippledUnnatural
;
169 BoxFill
= cfb8FillRectTransparentStippled32
;
171 case FillOpaqueStippled
:
172 if (!pGC
->pRotatedPixmap
)
173 BoxFill
= cfb8FillRectStippledUnnatural
;
175 BoxFill
= cfb8FillRectOpaqueStippled32
;
196 numRects
= REGION_NUM_RECTS(prgnClip
) * nrectFill
;
197 if (numRects
> NUM_STACK_RECTS
)
199 pboxClippedBase
= (BoxPtr
)ALLOCATE_LOCAL(numRects
* sizeof(BoxRec
));
200 if (!pboxClippedBase
)
204 pboxClippedBase
= stackRects
;
206 pboxClipped
= pboxClippedBase
;
208 if (REGION_NUM_RECTS(prgnClip
) == 1)
210 int x1
, y1
, x2
, y2
, bx2
, by2
;
212 pextent
= REGION_RECTS(prgnClip
);
219 if ((pboxClipped
->x1
= prect
->x
) < x1
)
220 pboxClipped
->x1
= x1
;
222 if ((pboxClipped
->y1
= prect
->y
) < y1
)
223 pboxClipped
->y1
= y1
;
225 bx2
= (int) prect
->x
+ (int) prect
->width
;
228 pboxClipped
->x2
= bx2
;
230 by2
= (int) prect
->y
+ (int) prect
->height
;
233 pboxClipped
->y2
= by2
;
236 if ((pboxClipped
->x1
< pboxClipped
->x2
) &&
237 (pboxClipped
->y1
< pboxClipped
->y2
))
245 int x1
, y1
, x2
, y2
, bx2
, by2
;
247 pextent
= REGION_EXTENTS(pGC
->pScreen
, prgnClip
);
256 if ((box
.x1
= prect
->x
) < x1
)
259 if ((box
.y1
= prect
->y
) < y1
)
262 bx2
= (int) prect
->x
+ (int) prect
->width
;
267 by2
= (int) prect
->y
+ (int) prect
->height
;
274 if ((box
.x1
>= box
.x2
) || (box
.y1
>= box
.y2
))
277 n
= REGION_NUM_RECTS (prgnClip
);
278 pbox
= REGION_RECTS(prgnClip
);
280 /* clip the rectangle to each box in the clip region
281 this is logically equivalent to calling Intersect()
285 pboxClipped
->x1
= max(box
.x1
, pbox
->x1
);
286 pboxClipped
->y1
= max(box
.y1
, pbox
->y1
);
287 pboxClipped
->x2
= min(box
.x2
, pbox
->x2
);
288 pboxClipped
->y2
= min(box
.y2
, pbox
->y2
);
291 /* see if clipping left anything */
292 if(pboxClipped
->x1
< pboxClipped
->x2
&&
293 pboxClipped
->y1
< pboxClipped
->y2
)
300 if (pboxClipped
!= pboxClippedBase
)
301 (*BoxFill
) (pDrawable
, pGC
,
302 pboxClipped
-pboxClippedBase
, pboxClippedBase
);
303 if (pboxClippedBase
!= stackRects
)
304 DEALLOCATE_LOCAL(pboxClippedBase
);