2 * Copyright © 1998 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Keith Packard not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Keith Packard makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
23 #ifdef HAVE_DIX_CONFIG_H
24 #include <dix-config.h>
31 typedef void (*FbArc
) (FbBits
* dst
,
34 xArc
* arc
, int dx
, int dy
, FbBits
and, FbBits
xor);
37 fbPolyArc(DrawablePtr pDrawable
, GCPtr pGC
, int narcs
, xArc
* parcs
)
41 if (pGC
->lineWidth
== 0) {
43 if (pGC
->lineStyle
== LineSolid
&& pGC
->fillStyle
== FillSolid
) {
44 switch (pDrawable
->bitsPerPixel
) {
60 FbGCPrivPtr pPriv
= fbGetGCPrivate(pGC
);
69 #ifdef FB_ACCESS_WRAPPER
73 cclip
= fbGetCompositeClip(pGC
);
74 fbGetDrawable(pDrawable
, dst
, dstStride
, dstBpp
, dstXoff
, dstYoff
);
76 if (miCanZeroArc(parcs
)) {
77 box
.x1
= parcs
->x
+ pDrawable
->x
;
78 box
.y1
= parcs
->y
+ pDrawable
->y
;
80 * Because box.x2 and box.y2 get truncated to 16 bits, and the
81 * RECT_IN_REGION test treats the resulting number as a signed
82 * integer, the RECT_IN_REGION test alone can go the wrong way.
83 * This can result in a server crash because the rendering
84 * routines in this file deal directly with cpu addresses
85 * of pixels to be stored, and do not clip or otherwise check
86 * that all such addresses are within their respective pixmaps.
87 * So we only allow the RECT_IN_REGION test to be used for
88 * values that can be expressed correctly in a signed short.
90 x2
= box
.x1
+ (int) parcs
->width
+ 1;
92 y2
= box
.y1
+ (int) parcs
->height
+ 1;
94 if ((x2
<= SHRT_MAX
) && (y2
<= SHRT_MAX
) &&
95 (RegionContainsRect(cclip
, &box
) == rgnIN
)) {
96 #ifdef FB_ACCESS_WRAPPER
98 fbPrepareAccess(pDrawable
);
102 (*arc
) (dst
, dstStride
, dstBpp
,
103 parcs
, pDrawable
->x
+ dstXoff
,
104 pDrawable
->y
+ dstYoff
, pPriv
->and, pPriv
->xor);
107 #ifdef FB_ACCESS_WRAPPER
109 fbFinishAccess(pDrawable
);
113 miZeroPolyArc(pDrawable
, pGC
, 1, parcs
);
117 #ifdef FB_ACCESS_WRAPPER
119 fbFinishAccess(pDrawable
);
123 miPolyArc(pDrawable
, pGC
, 1, parcs
);
127 #ifdef FB_ACCESS_WRAPPER
129 fbFinishAccess(pDrawable
);
135 miZeroPolyArc(pDrawable
, pGC
, narcs
, parcs
);
138 miPolyArc(pDrawable
, pGC
, narcs
, parcs
);