2
* Copyright 1996 The XFree86 Project
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17
* HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
* Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
24
/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaFillArc.c,v 1.4 1999/05/30 03:03:31 dawes Exp $ */
27
* Filled solid arcs, based on cfbfillarc.c.
29
* Fill arc using calls to low-level span fill. Because the math for
30
* each span can be done concurrently with the drawing of the span
31
* with a graphics coprocessor operation, this is faster than just
32
* using miPolyFillArc, which first calculates all the spans and then
35
* Clipped arcs are dispatched to FillSpans.
39
#include "xf86_ansic.h"
40
#include "xf86_OSproc.h"
43
#include "scrnintstr.h"
44
#include "pixmapstr.h"
48
#include "mifillarc.h"
52
* This is based on the integer-math versions from mi. Perhaps on a
53
* Pentium, the floating-point (double)-math version is faster.
57
XAAFillEllipseSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
59
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
61
int yk, xk, ym, xm, dx, dy, xorg, yorg;
65
(*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
68
miFillArcSetup(arc, &info);
79
(*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, xorg - x,
81
if (miFillArcLower(slw))
82
(*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
83
xorg - x, yorg + y + dy, slw, 1);
87
SET_SYNC_FLAG(infoRec);
91
#define ADDSPAN(l,r) \
93
(*infoRec->SubsequentSolidFillRect)( \
94
infoRec->pScrn, l, ya, r - l + 1, 1);
96
#define ADDSLICESPANS(flip) \
110
XAAFillArcSliceSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
112
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
113
int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
114
register int x, y, e;
119
(*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
122
miFillArcSetup(arc, &info);
123
miFillArcSliceSetup(arc, &slice, pGC);
126
if (slice.flip_top || slice.flip_bot)
127
slw += (arc->height >> 1) + 1;
128
if (pGC->miTranslate)
132
slice.edge1.x += pDraw->x;
133
slice.edge2.x += pDraw->x;
138
MIARCSLICESTEP(slice.edge1);
139
MIARCSLICESTEP(slice.edge2);
140
if (miFillSliceUpper(slice))
143
MIARCSLICEUPPER(xl, xr, slice, slw);
145
ADDSLICESPANS(slice.flip_top);
147
if (miFillSliceLower(slice))
150
MIARCSLICELOWER(xl, xr, slice, slw);
151
ADDSLICESPANS(slice.flip_bot);
155
SET_SYNC_FLAG(infoRec);
160
XAAPolyFillArcSolid(pDraw, pGC, narcs, parcs)
172
cclip = pGC->pCompositeClip;
174
if(!REGION_NUM_RECTS(cclip))
177
for (arc = parcs, i = narcs; --i >= 0; arc++)
179
if (miFillArcEmpty(arc))
181
if (miCanFillArc(arc))
183
box.x1 = arc->x + pDraw->x;
184
box.y1 = arc->y + pDraw->y;
186
* Because box.x2 and box.y2 get truncated to 16 bits, and the
187
* RECT_IN_REGION test treats the resulting number as a signed
188
* integer, the RECT_IN_REGION test alone can go the wrong way.
189
* This can result in a server crash because the rendering
190
* routines in this file deal directly with cpu addresses
191
* of pixels to be stored, and do not clip or otherwise check
192
* that all such addresses are within their respective pixmaps.
193
* So we only allow the RECT_IN_REGION test to be used for
194
* values that can be expressed correctly in a signed short.
196
x2 = box.x1 + (int)arc->width + 1;
198
y2 = box.y1 + (int)arc->height + 1;
200
if ( (x2 <= MAXSHORT) && (y2 <= MAXSHORT) &&
201
(RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) )
203
if ((arc->angle2 >= FULLCIRCLE) ||
204
(arc->angle2 <= -FULLCIRCLE))
205
XAAFillEllipseSolid(pDraw, pGC, arc);
207
XAAFillArcSliceSolid(pDraw, pGC, arc);
211
miPolyFillArc(pDraw, pGC, 1, arc);