2 * Copyright © 2004 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 #include "picturestr.h"
33 #include "renderedge.h"
37 fbAddTraps (PicturePtr pPicture
,
43 pixman_image_t
*image
= image_from_pict (pPicture
, FALSE
);
48 pixman_add_traps (image
, x_off
, y_off
, ntrap
, (pixman_trap_t
*)traps
);
50 free_pixman_pict (pPicture
, image
);
54 fbRasterizeTrapezoid (PicturePtr pPicture
,
59 pixman_image_t
*image
= image_from_pict (pPicture
, FALSE
);
64 pixman_rasterize_trapezoid (image
, (pixman_trapezoid_t
*)trap
, x_off
, y_off
);
66 free_pixman_pict (pPicture
, image
);
70 _GreaterY (xPointFixed
*a
, xPointFixed
*b
)
78 * Note that the definition of this function is a bit odd because
79 * of the X coordinate space (y increasing downwards).
82 _Clockwise (xPointFixed
*ref
, xPointFixed
*a
, xPointFixed
*b
)
91 return ((xFixed_32_32
) bd
.y
* ad
.x
- (xFixed_32_32
) ad
.y
* bd
.x
) < 0;
94 /* FIXME -- this could be made more efficient */
96 fbAddTriangles (PicturePtr pPicture
,
102 xPointFixed
*top
, *left
, *right
, *tmp
;
105 for (; ntri
; ntri
--, tris
++)
110 if (_GreaterY (top
, left
)) {
111 tmp
= left
; left
= top
; top
= tmp
;
113 if (_GreaterY (top
, right
)) {
114 tmp
= right
; right
= top
; top
= tmp
;
116 if (_Clockwise (top
, right
, left
)) {
117 tmp
= right
; right
= left
; left
= tmp
;
135 trap
.left
.p2
= *left
;
136 trap
.right
.p1
= *top
;
137 trap
.right
.p2
= *right
;
138 if (right
->y
< left
->y
)
139 trap
.bottom
= right
->y
;
141 trap
.bottom
= left
->y
;
142 fbRasterizeTrapezoid (pPicture
, &trap
, x_off
, y_off
);
143 if (right
->y
< left
->y
)
146 trap
.bottom
= left
->y
;
147 trap
.right
.p1
= *right
;
148 trap
.right
.p2
= *left
;
153 trap
.bottom
= right
->y
;
154 trap
.left
.p1
= *left
;
155 trap
.left
.p2
= *right
;
157 fbRasterizeTrapezoid (pPicture
, &trap
, x_off
, y_off
);