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>
29 #include "picturestr.h"
35 fbAddTraps(PicturePtr pPicture
,
36 INT16 x_off
, INT16 y_off
, int ntrap
, xTrap
* traps
)
38 pixman_image_t
*image
;
39 int dst_xoff
, dst_yoff
;
41 if (!(image
= image_from_pict(pPicture
, FALSE
, &dst_xoff
, &dst_yoff
)))
44 pixman_add_traps(image
, x_off
+ dst_xoff
, y_off
+ dst_yoff
,
45 ntrap
, (pixman_trap_t
*) traps
);
47 free_pixman_pict(pPicture
, image
);
51 fbRasterizeTrapezoid(PicturePtr pPicture
,
52 xTrapezoid
* trap
, int x_off
, int y_off
)
54 pixman_image_t
*image
;
55 int dst_xoff
, dst_yoff
;
57 if (!(image
= image_from_pict(pPicture
, FALSE
, &dst_xoff
, &dst_yoff
)))
60 pixman_rasterize_trapezoid(image
, (pixman_trapezoid_t
*) trap
,
61 x_off
+ dst_xoff
, y_off
+ dst_yoff
);
63 free_pixman_pict(pPicture
, image
);
67 fbAddTriangles(PicturePtr pPicture
,
68 INT16 x_off
, INT16 y_off
, int ntri
, xTriangle
* tris
)
70 pixman_image_t
*image
;
71 int dst_xoff
, dst_yoff
;
73 if (!(image
= image_from_pict(pPicture
, FALSE
, &dst_xoff
, &dst_yoff
)))
76 pixman_add_triangles(image
,
77 dst_xoff
+ x_off
, dst_yoff
+ y_off
,
78 ntri
, (pixman_triangle_t
*) tris
);
80 free_pixman_pict(pPicture
, image
);
83 typedef void (*CompositeShapesFunc
) (pixman_op_t op
,
86 pixman_format_code_t mask_format
,
89 int n_shapes
, const uint8_t * shapes
);
92 fbShapes(CompositeShapesFunc composite
,
96 PictFormatPtr maskFormat
,
98 int16_t ySrc
, int nshapes
, int shape_size
, const uint8_t * shapes
)
100 pixman_image_t
*src
, *dst
;
101 int src_xoff
, src_yoff
;
102 int dst_xoff
, dst_yoff
;
104 miCompositeSourceValidate(pSrc
);
106 src
= image_from_pict(pSrc
, FALSE
, &src_xoff
, &src_yoff
);
107 dst
= image_from_pict(pDst
, TRUE
, &dst_xoff
, &dst_yoff
);
110 pixman_format_code_t format
;
112 DamageRegionAppend(pDst
->pDrawable
, pDst
->pCompositeClip
);
117 if (pDst
->polyEdge
== PolyEdgeSharp
)
122 for (i
= 0; i
< nshapes
; ++i
) {
123 composite(op
, src
, dst
, format
,
126 dst_xoff
, dst_yoff
, 1, shapes
+ i
* shape_size
);
130 switch (PICT_FORMAT_A(maskFormat
->format
)) {
145 composite(op
, src
, dst
, format
,
147 ySrc
+ src_yoff
, dst_xoff
, dst_yoff
, nshapes
, shapes
);
150 DamageRegionProcessPending(pDst
->pDrawable
);
153 free_pixman_pict(pSrc
, src
);
154 free_pixman_pict(pDst
, dst
);
158 fbTrapezoids(CARD8 op
,
161 PictFormatPtr maskFormat
,
162 INT16 xSrc
, INT16 ySrc
, int ntrap
, xTrapezoid
* traps
)
164 xSrc
-= (traps
[0].left
.p1
.x
>> 16);
165 ySrc
-= (traps
[0].left
.p1
.y
>> 16);
167 fbShapes((CompositeShapesFunc
) pixman_composite_trapezoids
,
168 op
, pSrc
, pDst
, maskFormat
,
169 xSrc
, ySrc
, ntrap
, sizeof(xTrapezoid
), (const uint8_t *) traps
);
173 fbTriangles(CARD8 op
,
176 PictFormatPtr maskFormat
,
177 INT16 xSrc
, INT16 ySrc
, int ntris
, xTriangle
* tris
)
179 xSrc
-= (tris
[0].p1
.x
>> 16);
180 ySrc
-= (tris
[0].p1
.y
>> 16);
182 fbShapes((CompositeShapesFunc
) pixman_composite_triangles
,
183 op
, pSrc
, pDst
, maskFormat
,
184 xSrc
, ySrc
, ntris
, sizeof(xTriangle
), (const uint8_t *) tris
);