aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/fb
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-03-04 13:54:03 +0000
committermarha <marha@users.sourceforge.net>2011-03-04 13:54:03 +0000
commit0a5888393c68f6f7db86206d1f277232db18240b (patch)
tree9afe740e7b124ea8d2125ef7be0d42760d3b8e6a /xorg-server/fb
parent56950d7bed70ee82186f44f9333537cdbb33c448 (diff)
downloadvcxsrv-0a5888393c68f6f7db86206d1f277232db18240b.tar.gz
vcxsrv-0a5888393c68f6f7db86206d1f277232db18240b.tar.bz2
vcxsrv-0a5888393c68f6f7db86206d1f277232db18240b.zip
xserver xkeyboard-config mesa git update 4 Marc 2011
Diffstat (limited to 'xorg-server/fb')
-rw-r--r--xorg-server/fb/fbpict.c744
-rw-r--r--xorg-server/fb/fbpict.h156
-rw-r--r--xorg-server/fb/fbtrap.c369
3 files changed, 671 insertions, 598 deletions
diff --git a/xorg-server/fb/fbpict.c b/xorg-server/fb/fbpict.c
index c27fb4e20..312f3df21 100644
--- a/xorg-server/fb/fbpict.c
+++ b/xorg-server/fb/fbpict.c
@@ -1,371 +1,373 @@
-/*
- *
- * Copyright © 2000 SuSE, Inc.
- * Copyright © 2007 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of SuSE not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. SuSE makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Keith Packard, SuSE, Inc.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <string.h>
-
-#include "fb.h"
-
-#include "picturestr.h"
-#include "mipict.h"
-#include "fbpict.h"
-
-void
-fbComposite (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height)
-{
- pixman_image_t *src, *mask, *dest;
- int src_xoff, src_yoff;
- int msk_xoff, msk_yoff;
- int dst_xoff, dst_yoff;
-
- miCompositeSourceValidate (pSrc, xSrc - xDst, ySrc - yDst, width, height);
- if (pMask)
- miCompositeSourceValidate (pMask, xMask - xDst, yMask - yDst, width, height);
-
- src = image_from_pict (pSrc, FALSE, &src_xoff, &src_yoff);
- mask = image_from_pict (pMask, FALSE, &msk_xoff, &msk_yoff);
- dest = image_from_pict (pDst, TRUE, &dst_xoff, &dst_yoff);
-
- if (src && dest && !(pMask && !mask))
- {
- pixman_image_composite (op, src, mask, dest,
- xSrc + src_xoff, ySrc + src_yoff,
- xMask + msk_xoff, yMask + msk_yoff,
- xDst + dst_xoff, yDst + dst_yoff,
- width, height);
- }
-
- free_pixman_pict (pSrc, src);
- free_pixman_pict (pMask, mask);
- free_pixman_pict (pDst, dest);
-}
-
-static pixman_image_t *
-create_solid_fill_image (PicturePtr pict)
-{
- PictSolidFill *solid = &pict->pSourcePict->solidFill;
- pixman_color_t color;
- CARD32 a, r, g, b;
-
- a = (solid->color & 0xff000000) >> 24;
- r = (solid->color & 0x00ff0000) >> 16;
- g = (solid->color & 0x0000ff00) >> 8;
- b = (solid->color & 0x000000ff) >> 0;
-
- color.alpha = (a << 8) | a;
- color.red = (r << 8) | r;
- color.green = (g << 8) | g;
- color.blue = (b << 8) | b;
-
- return pixman_image_create_solid_fill (&color);
-}
-
-static pixman_image_t *
-create_linear_gradient_image (PictGradient *gradient)
-{
- PictLinearGradient *linear = (PictLinearGradient *)gradient;
- pixman_point_fixed_t p1;
- pixman_point_fixed_t p2;
-
- p1.x = linear->p1.x;
- p1.y = linear->p1.y;
- p2.x = linear->p2.x;
- p2.y = linear->p2.y;
-
- return pixman_image_create_linear_gradient (
- &p1, &p2, (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
-}
-
-static pixman_image_t *
-create_radial_gradient_image (PictGradient *gradient)
-{
- PictRadialGradient *radial = (PictRadialGradient *)gradient;
- pixman_point_fixed_t c1;
- pixman_point_fixed_t c2;
-
- c1.x = radial->c1.x;
- c1.y = radial->c1.y;
- c2.x = radial->c2.x;
- c2.y = radial->c2.y;
-
- return pixman_image_create_radial_gradient (
- &c1, &c2, radial->c1.radius,
- radial->c2.radius,
- (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
-}
-
-static pixman_image_t *
-create_conical_gradient_image (PictGradient *gradient)
-{
- PictConicalGradient *conical = (PictConicalGradient *)gradient;
- pixman_point_fixed_t center;
-
- center.x = conical->center.x;
- center.y = conical->center.y;
-
- return pixman_image_create_conical_gradient (
- &center, conical->angle, (pixman_gradient_stop_t *)gradient->stops,
- gradient->nstops);
-}
-
-static pixman_image_t *
-create_bits_picture (PicturePtr pict,
- Bool has_clip,
- int *xoff,
- int *yoff)
-{
- PixmapPtr pixmap;
- FbBits *bits;
- FbStride stride;
- int bpp;
- pixman_image_t *image;
-
- fbGetDrawablePixmap (pict->pDrawable, pixmap, *xoff, *yoff);
- fbGetPixmapBitsData(pixmap, bits, stride, bpp);
-
- image = pixman_image_create_bits (
- pict->format,
- pixmap->drawable.width, pixmap->drawable.height,
- (uint32_t *)bits, stride * sizeof (FbStride));
-
-
-#ifdef FB_ACCESS_WRAPPER
-#if FB_SHIFT==5
-
- pixman_image_set_accessors (image,
- (pixman_read_memory_func_t)wfbReadMemory,
- (pixman_write_memory_func_t)wfbWriteMemory);
-
-#else
-
-#error The pixman library only works when FbBits is 32 bits wide
-
-#endif
-#endif
-
- /* pCompositeClip is undefined for source pictures, so
- * only set the clip region for pictures with drawables
- */
- if (has_clip)
- {
- if (pict->clientClipType != CT_NONE)
- pixman_image_set_has_client_clip (image, TRUE);
-
- if (*xoff || *yoff)
- pixman_region_translate (pict->pCompositeClip, *xoff, *yoff);
-
- pixman_image_set_clip_region (image, pict->pCompositeClip);
-
- if (*xoff || *yoff)
- pixman_region_translate (pict->pCompositeClip, -*xoff, -*yoff);
- }
-
- /* Indexed table */
- if (pict->pFormat->index.devPrivate)
- pixman_image_set_indexed (image, pict->pFormat->index.devPrivate);
-
- /* Add in drawable origin to position within the image */
- *xoff += pict->pDrawable->x;
- *yoff += pict->pDrawable->y;
-
- return image;
-}
-
-static pixman_image_t *
-image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map);
-
-static void
-set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map)
-{
- pixman_repeat_t repeat;
- pixman_filter_t filter;
-
- if (pict->transform)
- {
- /* For source images, adjust the transform to account
- * for the drawable offset within the pixman image,
- * then set the offset to 0 as it will be used
- * to compute positions within the transformed image.
- */
- if (!has_clip) {
- struct pixman_transform adjusted;
-
- adjusted = *pict->transform;
- pixman_transform_translate(&adjusted,
- NULL,
- pixman_int_to_fixed(*xoff),
- pixman_int_to_fixed(*yoff));
- pixman_image_set_transform (image, &adjusted);
- *xoff = 0;
- *yoff = 0;
- } else
- pixman_image_set_transform (image, pict->transform);
- }
-
- switch (pict->repeatType)
- {
- default:
- case RepeatNone:
- repeat = PIXMAN_REPEAT_NONE;
- break;
-
- case RepeatPad:
- repeat = PIXMAN_REPEAT_PAD;
- break;
-
- case RepeatNormal:
- repeat = PIXMAN_REPEAT_NORMAL;
- break;
-
- case RepeatReflect:
- repeat = PIXMAN_REPEAT_REFLECT;
- break;
- }
-
- pixman_image_set_repeat (image, repeat);
-
- /* Fetch alpha map unless 'pict' is being used
- * as the alpha map for this operation
- */
- if (pict->alphaMap && !is_alpha_map)
- {
- int alpha_xoff, alpha_yoff;
- pixman_image_t *alpha_map = image_from_pict_internal (pict->alphaMap, FALSE, &alpha_xoff, &alpha_yoff, TRUE);
-
- pixman_image_set_alpha_map (
- image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
-
- free_pixman_pict (pict->alphaMap, alpha_map);
- }
-
- pixman_image_set_component_alpha (image, pict->componentAlpha);
-
- switch (pict->filter)
- {
- default:
- case PictFilterNearest:
- case PictFilterFast:
- filter = PIXMAN_FILTER_NEAREST;
- break;
-
- case PictFilterBilinear:
- case PictFilterGood:
- filter = PIXMAN_FILTER_BILINEAR;
- break;
-
- case PictFilterConvolution:
- filter = PIXMAN_FILTER_CONVOLUTION;
- break;
- }
-
- pixman_image_set_filter (image, filter, (pixman_fixed_t *)pict->filter_params, pict->filter_nparams);
- pixman_image_set_source_clipping (image, TRUE);
-}
-
-static pixman_image_t *
-image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map)
-{
- pixman_image_t *image = NULL;
-
- if (!pict)
- return NULL;
-
- if (pict->pDrawable)
- {
- image = create_bits_picture (pict, has_clip, xoff, yoff);
- }
- else if (pict->pSourcePict)
- {
- SourcePict *sp = pict->pSourcePict;
-
- if (sp->type == SourcePictTypeSolidFill)
- {
- image = create_solid_fill_image (pict);
- }
- else
- {
- PictGradient *gradient = &pict->pSourcePict->gradient;
-
- if (sp->type == SourcePictTypeLinear)
- image = create_linear_gradient_image (gradient);
- else if (sp->type == SourcePictTypeRadial)
- image = create_radial_gradient_image (gradient);
- else if (sp->type == SourcePictTypeConical)
- image = create_conical_gradient_image (gradient);
- }
- *xoff = *yoff = 0;
- }
-
- if (image)
- set_image_properties (image, pict, has_clip, xoff, yoff, is_alpha_map);
-
- return image;
-}
-
-pixman_image_t *
-image_from_pict (PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
-{
- return image_from_pict_internal (pict, has_clip, xoff, yoff, FALSE);
-}
-
-void
-free_pixman_pict (PicturePtr pict, pixman_image_t *image)
-{
- if (image && pixman_image_unref (image) && pict->pDrawable)
- fbFinishAccess (pict->pDrawable);
-}
-
-Bool
-fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
-{
-
- PictureScreenPtr ps;
-
- if (!miPictureInit (pScreen, formats, nformats))
- return FALSE;
- ps = GetPictureScreen(pScreen);
- ps->Composite = fbComposite;
- ps->Glyphs = miGlyphs;
- ps->CompositeRects = miCompositeRects;
- ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
- ps->AddTraps = fbAddTraps;
- ps->AddTriangles = fbAddTriangles;
-
- return TRUE;
-}
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+
+#include "fb.h"
+
+#include "picturestr.h"
+#include "mipict.h"
+#include "fbpict.h"
+
+void
+fbComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ pixman_image_t *src, *mask, *dest;
+ int src_xoff, src_yoff;
+ int msk_xoff, msk_yoff;
+ int dst_xoff, dst_yoff;
+
+ miCompositeSourceValidate (pSrc, xSrc - xDst, ySrc - yDst, width, height);
+ if (pMask)
+ miCompositeSourceValidate (pMask, xMask - xDst, yMask - yDst, width, height);
+
+ src = image_from_pict (pSrc, FALSE, &src_xoff, &src_yoff);
+ mask = image_from_pict (pMask, FALSE, &msk_xoff, &msk_yoff);
+ dest = image_from_pict (pDst, TRUE, &dst_xoff, &dst_yoff);
+
+ if (src && dest && !(pMask && !mask))
+ {
+ pixman_image_composite (op, src, mask, dest,
+ xSrc + src_xoff, ySrc + src_yoff,
+ xMask + msk_xoff, yMask + msk_yoff,
+ xDst + dst_xoff, yDst + dst_yoff,
+ width, height);
+ }
+
+ free_pixman_pict (pSrc, src);
+ free_pixman_pict (pMask, mask);
+ free_pixman_pict (pDst, dest);
+}
+
+static pixman_image_t *
+create_solid_fill_image (PicturePtr pict)
+{
+ PictSolidFill *solid = &pict->pSourcePict->solidFill;
+ pixman_color_t color;
+ CARD32 a, r, g, b;
+
+ a = (solid->color & 0xff000000) >> 24;
+ r = (solid->color & 0x00ff0000) >> 16;
+ g = (solid->color & 0x0000ff00) >> 8;
+ b = (solid->color & 0x000000ff) >> 0;
+
+ color.alpha = (a << 8) | a;
+ color.red = (r << 8) | r;
+ color.green = (g << 8) | g;
+ color.blue = (b << 8) | b;
+
+ return pixman_image_create_solid_fill (&color);
+}
+
+static pixman_image_t *
+create_linear_gradient_image (PictGradient *gradient)
+{
+ PictLinearGradient *linear = (PictLinearGradient *)gradient;
+ pixman_point_fixed_t p1;
+ pixman_point_fixed_t p2;
+
+ p1.x = linear->p1.x;
+ p1.y = linear->p1.y;
+ p2.x = linear->p2.x;
+ p2.y = linear->p2.y;
+
+ return pixman_image_create_linear_gradient (
+ &p1, &p2, (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
+}
+
+static pixman_image_t *
+create_radial_gradient_image (PictGradient *gradient)
+{
+ PictRadialGradient *radial = (PictRadialGradient *)gradient;
+ pixman_point_fixed_t c1;
+ pixman_point_fixed_t c2;
+
+ c1.x = radial->c1.x;
+ c1.y = radial->c1.y;
+ c2.x = radial->c2.x;
+ c2.y = radial->c2.y;
+
+ return pixman_image_create_radial_gradient (
+ &c1, &c2, radial->c1.radius,
+ radial->c2.radius,
+ (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
+}
+
+static pixman_image_t *
+create_conical_gradient_image (PictGradient *gradient)
+{
+ PictConicalGradient *conical = (PictConicalGradient *)gradient;
+ pixman_point_fixed_t center;
+
+ center.x = conical->center.x;
+ center.y = conical->center.y;
+
+ return pixman_image_create_conical_gradient (
+ &center, conical->angle, (pixman_gradient_stop_t *)gradient->stops,
+ gradient->nstops);
+}
+
+static pixman_image_t *
+create_bits_picture (PicturePtr pict,
+ Bool has_clip,
+ int *xoff,
+ int *yoff)
+{
+ PixmapPtr pixmap;
+ FbBits *bits;
+ FbStride stride;
+ int bpp;
+ pixman_image_t *image;
+
+ fbGetDrawablePixmap (pict->pDrawable, pixmap, *xoff, *yoff);
+ fbGetPixmapBitsData(pixmap, bits, stride, bpp);
+
+ image = pixman_image_create_bits (
+ pict->format,
+ pixmap->drawable.width, pixmap->drawable.height,
+ (uint32_t *)bits, stride * sizeof (FbStride));
+
+
+#ifdef FB_ACCESS_WRAPPER
+#if FB_SHIFT==5
+
+ pixman_image_set_accessors (image,
+ (pixman_read_memory_func_t)wfbReadMemory,
+ (pixman_write_memory_func_t)wfbWriteMemory);
+
+#else
+
+#error The pixman library only works when FbBits is 32 bits wide
+
+#endif
+#endif
+
+ /* pCompositeClip is undefined for source pictures, so
+ * only set the clip region for pictures with drawables
+ */
+ if (has_clip)
+ {
+ if (pict->clientClipType != CT_NONE)
+ pixman_image_set_has_client_clip (image, TRUE);
+
+ if (*xoff || *yoff)
+ pixman_region_translate (pict->pCompositeClip, *xoff, *yoff);
+
+ pixman_image_set_clip_region (image, pict->pCompositeClip);
+
+ if (*xoff || *yoff)
+ pixman_region_translate (pict->pCompositeClip, -*xoff, -*yoff);
+ }
+
+ /* Indexed table */
+ if (pict->pFormat->index.devPrivate)
+ pixman_image_set_indexed (image, pict->pFormat->index.devPrivate);
+
+ /* Add in drawable origin to position within the image */
+ *xoff += pict->pDrawable->x;
+ *yoff += pict->pDrawable->y;
+
+ return image;
+}
+
+static pixman_image_t *
+image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map);
+
+static void
+set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map)
+{
+ pixman_repeat_t repeat;
+ pixman_filter_t filter;
+
+ if (pict->transform)
+ {
+ /* For source images, adjust the transform to account
+ * for the drawable offset within the pixman image,
+ * then set the offset to 0 as it will be used
+ * to compute positions within the transformed image.
+ */
+ if (!has_clip) {
+ struct pixman_transform adjusted;
+
+ adjusted = *pict->transform;
+ pixman_transform_translate(&adjusted,
+ NULL,
+ pixman_int_to_fixed(*xoff),
+ pixman_int_to_fixed(*yoff));
+ pixman_image_set_transform (image, &adjusted);
+ *xoff = 0;
+ *yoff = 0;
+ } else
+ pixman_image_set_transform (image, pict->transform);
+ }
+
+ switch (pict->repeatType)
+ {
+ default:
+ case RepeatNone:
+ repeat = PIXMAN_REPEAT_NONE;
+ break;
+
+ case RepeatPad:
+ repeat = PIXMAN_REPEAT_PAD;
+ break;
+
+ case RepeatNormal:
+ repeat = PIXMAN_REPEAT_NORMAL;
+ break;
+
+ case RepeatReflect:
+ repeat = PIXMAN_REPEAT_REFLECT;
+ break;
+ }
+
+ pixman_image_set_repeat (image, repeat);
+
+ /* Fetch alpha map unless 'pict' is being used
+ * as the alpha map for this operation
+ */
+ if (pict->alphaMap && !is_alpha_map)
+ {
+ int alpha_xoff, alpha_yoff;
+ pixman_image_t *alpha_map = image_from_pict_internal (pict->alphaMap, FALSE, &alpha_xoff, &alpha_yoff, TRUE);
+
+ pixman_image_set_alpha_map (
+ image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
+
+ free_pixman_pict (pict->alphaMap, alpha_map);
+ }
+
+ pixman_image_set_component_alpha (image, pict->componentAlpha);
+
+ switch (pict->filter)
+ {
+ default:
+ case PictFilterNearest:
+ case PictFilterFast:
+ filter = PIXMAN_FILTER_NEAREST;
+ break;
+
+ case PictFilterBilinear:
+ case PictFilterGood:
+ filter = PIXMAN_FILTER_BILINEAR;
+ break;
+
+ case PictFilterConvolution:
+ filter = PIXMAN_FILTER_CONVOLUTION;
+ break;
+ }
+
+ pixman_image_set_filter (image, filter, (pixman_fixed_t *)pict->filter_params, pict->filter_nparams);
+ pixman_image_set_source_clipping (image, TRUE);
+}
+
+static pixman_image_t *
+image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map)
+{
+ pixman_image_t *image = NULL;
+
+ if (!pict)
+ return NULL;
+
+ if (pict->pDrawable)
+ {
+ image = create_bits_picture (pict, has_clip, xoff, yoff);
+ }
+ else if (pict->pSourcePict)
+ {
+ SourcePict *sp = pict->pSourcePict;
+
+ if (sp->type == SourcePictTypeSolidFill)
+ {
+ image = create_solid_fill_image (pict);
+ }
+ else
+ {
+ PictGradient *gradient = &pict->pSourcePict->gradient;
+
+ if (sp->type == SourcePictTypeLinear)
+ image = create_linear_gradient_image (gradient);
+ else if (sp->type == SourcePictTypeRadial)
+ image = create_radial_gradient_image (gradient);
+ else if (sp->type == SourcePictTypeConical)
+ image = create_conical_gradient_image (gradient);
+ }
+ *xoff = *yoff = 0;
+ }
+
+ if (image)
+ set_image_properties (image, pict, has_clip, xoff, yoff, is_alpha_map);
+
+ return image;
+}
+
+pixman_image_t *
+image_from_pict (PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
+{
+ return image_from_pict_internal (pict, has_clip, xoff, yoff, FALSE);
+}
+
+void
+free_pixman_pict (PicturePtr pict, pixman_image_t *image)
+{
+ if (image && pixman_image_unref (image) && pict->pDrawable)
+ fbFinishAccess (pict->pDrawable);
+}
+
+Bool
+fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+{
+
+ PictureScreenPtr ps;
+
+ if (!miPictureInit (pScreen, formats, nformats))
+ return FALSE;
+ ps = GetPictureScreen(pScreen);
+ ps->Composite = fbComposite;
+ ps->Glyphs = miGlyphs;
+ ps->CompositeRects = miCompositeRects;
+ ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
+ ps->Trapezoids = fbTrapezoids;
+ ps->AddTraps = fbAddTraps;
+ ps->AddTriangles = fbAddTriangles;
+ ps->Triangles = fbTriangles;
+
+ return TRUE;
+}
diff --git a/xorg-server/fb/fbpict.h b/xorg-server/fb/fbpict.h
index e7daaa245..b880ebbe1 100644
--- a/xorg-server/fb/fbpict.h
+++ b/xorg-server/fb/fbpict.h
@@ -1,68 +1,88 @@
-/*
- *
- * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef _FBPICT_H_
-#define _FBPICT_H_
-
-/* fbpict.c */
-extern _X_EXPORT void
-fbComposite (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height);
-
-/* fbtrap.c */
-
-extern _X_EXPORT void
-fbAddTraps (PicturePtr pPicture,
- INT16 xOff,
- INT16 yOff,
- int ntrap,
- xTrap *traps);
-
-extern _X_EXPORT void
-fbRasterizeTrapezoid (PicturePtr alpha,
- xTrapezoid *trap,
- int x_off,
- int y_off);
-
-extern _X_EXPORT void
-fbAddTriangles (PicturePtr pPicture,
- INT16 xOff,
- INT16 yOff,
- int ntri,
- xTriangle *tris);
-
-#endif /* _FBPICT_H_ */
+/*
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _FBPICT_H_
+#define _FBPICT_H_
+
+/* fbpict.c */
+extern _X_EXPORT void
+fbComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+/* fbtrap.c */
+
+extern _X_EXPORT void
+fbAddTraps (PicturePtr pPicture,
+ INT16 xOff,
+ INT16 yOff,
+ int ntrap,
+ xTrap *traps);
+
+extern _X_EXPORT void
+fbRasterizeTrapezoid (PicturePtr alpha,
+ xTrapezoid *trap,
+ int x_off,
+ int y_off);
+
+extern _X_EXPORT void
+fbAddTriangles (PicturePtr pPicture,
+ INT16 xOff,
+ INT16 yOff,
+ int ntri,
+ xTriangle *tris);
+
+extern _X_EXPORT void
+fbTrapezoids (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntrap,
+ xTrapezoid *traps);
+
+extern _X_EXPORT void
+fbTriangles (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntris,
+ xTriangle *tris);
+
+#endif /* _FBPICT_H_ */
diff --git a/xorg-server/fb/fbtrap.c b/xorg-server/fb/fbtrap.c
index e52f84cd7..2554fccbf 100644
--- a/xorg-server/fb/fbtrap.c
+++ b/xorg-server/fb/fbtrap.c
@@ -1,159 +1,210 @@
-/*
- * Copyright © 2004 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-#include "picturestr.h"
-#include "mipict.h"
-#include "fbpict.h"
-
-void
-fbAddTraps (PicturePtr pPicture,
- INT16 x_off,
- INT16 y_off,
- int ntrap,
- xTrap *traps)
-{
- int image_xoff, image_yoff;
- pixman_image_t *image = image_from_pict (pPicture, FALSE, &image_xoff, &image_yoff);
-
- if (!image)
- return;
-
- pixman_add_traps (image, x_off, y_off, ntrap, (pixman_trap_t *)traps);
-
- free_pixman_pict (pPicture, image);
-}
-
-void
-fbRasterizeTrapezoid (PicturePtr pPicture,
- xTrapezoid *trap,
- int x_off,
- int y_off)
-{
- int mask_xoff, mask_yoff;
- pixman_image_t *image = image_from_pict (pPicture, FALSE, &mask_xoff, &mask_yoff);
-
- if (!image)
- return;
-
- pixman_rasterize_trapezoid (image, (pixman_trapezoid_t *)trap, x_off, y_off);
-
- free_pixman_pict (pPicture, image);
-}
-
-static int
-_GreaterY (xPointFixed *a, xPointFixed *b)
-{
- if (a->y == b->y)
- return a->x > b->x;
- return a->y > b->y;
-}
-
-/*
- * Note that the definition of this function is a bit odd because
- * of the X coordinate space (y increasing downwards).
- */
-static int
-_Clockwise (xPointFixed *ref, xPointFixed *a, xPointFixed *b)
-{
- xPointFixed ad, bd;
-
- ad.x = a->x - ref->x;
- ad.y = a->y - ref->y;
- bd.x = b->x - ref->x;
- bd.y = b->y - ref->y;
-
- return ((xFixed_32_32) bd.y * ad.x - (xFixed_32_32) ad.y * bd.x) < 0;
-}
-
-/* FIXME -- this could be made more efficient */
-void
-fbAddTriangles (PicturePtr pPicture,
- INT16 x_off,
- INT16 y_off,
- int ntri,
- xTriangle *tris)
-{
- xPointFixed *top, *left, *right, *tmp;
- xTrapezoid trap;
-
- for (; ntri; ntri--, tris++)
- {
- top = &tris->p1;
- left = &tris->p2;
- right = &tris->p3;
- if (_GreaterY (top, left)) {
- tmp = left; left = top; top = tmp;
- }
- if (_GreaterY (top, right)) {
- tmp = right; right = top; top = tmp;
- }
- if (_Clockwise (top, right, left)) {
- tmp = right; right = left; left = tmp;
- }
-
- /*
- * Two cases:
- *
- * + +
- * / \ / \
- * / \ / \
- * / + + \
- * / -- -- \
- * / -- -- \
- * / --- --- \
- * +-- --+
- */
-
- trap.top = top->y;
- trap.left.p1 = *top;
- trap.left.p2 = *left;
- trap.right.p1 = *top;
- trap.right.p2 = *right;
- if (right->y < left->y)
- trap.bottom = right->y;
- else
- trap.bottom = left->y;
- fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off);
- if (right->y < left->y)
- {
- trap.top = right->y;
- trap.bottom = left->y;
- trap.right.p1 = *right;
- trap.right.p2 = *left;
- }
- else
- {
- trap.top = left->y;
- trap.bottom = right->y;
- trap.left.p1 = *left;
- trap.left.p2 = *right;
- }
- fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off);
- }
-}
-
+/*
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+#include "picturestr.h"
+#include "mipict.h"
+#include "fbpict.h"
+
+void
+fbAddTraps (PicturePtr pPicture,
+ INT16 x_off,
+ INT16 y_off,
+ int ntrap,
+ xTrap *traps)
+{
+ int image_xoff, image_yoff;
+ pixman_image_t *image = image_from_pict (pPicture, FALSE, &image_xoff, &image_yoff);
+
+ if (!image)
+ return;
+
+ pixman_add_traps (image, x_off, y_off, ntrap, (pixman_trap_t *)traps);
+
+ free_pixman_pict (pPicture, image);
+}
+
+void
+fbRasterizeTrapezoid (PicturePtr pPicture,
+ xTrapezoid *trap,
+ int x_off,
+ int y_off)
+{
+ int mask_xoff, mask_yoff;
+ pixman_image_t *image = image_from_pict (pPicture, FALSE, &mask_xoff, &mask_yoff);
+
+ if (!image)
+ return;
+
+ pixman_rasterize_trapezoid (image, (pixman_trapezoid_t *)trap, x_off, y_off);
+
+ free_pixman_pict (pPicture, image);
+}
+
+void
+fbAddTriangles (PicturePtr pPicture,
+ INT16 x_off,
+ INT16 y_off,
+ int ntri,
+ xTriangle *tris)
+{
+ int image_xoff, image_yoff;
+ pixman_image_t *image =
+ image_from_pict (pPicture, FALSE, &image_xoff, &image_yoff);
+
+ if (!image)
+ return;
+
+ pixman_add_triangles (image, x_off, y_off, ntri, (pixman_triangle_t *)tris);
+
+ free_pixman_pict (pPicture, image);
+}
+
+typedef void (* CompositeShapesFunc) (pixman_op_t op,
+ pixman_image_t *src,
+ pixman_image_t *dst,
+ pixman_format_code_t mask_format,
+ int x_src, int y_src,
+ int x_dst, int y_dst,
+ int n_shapes, const uint8_t *shapes);
+
+static void
+fbShapes (CompositeShapesFunc composite,
+ pixman_op_t op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ int16_t xSrc,
+ int16_t ySrc,
+ int16_t xDst,
+ int16_t yDst,
+ int nshapes,
+ int shape_size,
+ const uint8_t * shapes)
+{
+ pixman_image_t *src, *dst;
+ int src_xoff, src_yoff;
+ int dst_xoff, dst_yoff;
+
+ src = image_from_pict (pSrc, FALSE, &src_xoff, &src_yoff);
+ dst = image_from_pict (pDst, TRUE, &dst_xoff, &dst_yoff);
+
+ if (src && dst)
+ {
+ pixman_format_code_t format;
+
+ if (!maskFormat)
+ {
+ int i;
+
+ if (pDst->polyEdge == PolyEdgeSharp)
+ format = PIXMAN_a1;
+ else
+ format = PIXMAN_a8;
+
+ for (i = 0; i < nshapes; ++i)
+ {
+ composite (op, src, dst, format,
+ xSrc + src_xoff,
+ ySrc + src_yoff,
+ xDst + dst_xoff,
+ yDst + dst_yoff,
+ 1, shapes + i * shape_size);
+ }
+ }
+ else
+ {
+ switch (PICT_FORMAT_A (maskFormat->format))
+ {
+ case 1:
+ format = PIXMAN_a1;
+ break;
+
+ case 4:
+ format = PIXMAN_a4;
+ break;
+
+ default:
+ case 8:
+ format = PIXMAN_a8;
+ break;
+ }
+
+ composite (op, src, dst, format,
+ xSrc + src_xoff,
+ ySrc + src_yoff,
+ xDst + dst_xoff,
+ yDst + dst_yoff,
+ nshapes, shapes);
+ }
+ }
+
+ free_pixman_pict (pSrc, src);
+ free_pixman_pict (pDst, dst);
+}
+
+void
+fbTrapezoids (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntrap,
+ xTrapezoid *traps)
+{
+ int xDst, yDst;
+
+ xDst = traps[0].left.p1.x >> 16;
+ yDst = traps[0].left.p1.y >> 16;
+
+ fbShapes ((CompositeShapesFunc)pixman_composite_trapezoids,
+ op, pSrc, pDst, maskFormat,
+ xSrc, ySrc, xDst, yDst,
+ ntrap, sizeof (xTrapezoid), (const uint8_t *)traps);
+}
+
+void
+fbTriangles (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntris,
+ xTriangle *tris)
+{
+ int xDst, yDst;
+
+ xDst = tris[0].p1.x >> 16;
+ yDst = tris[0].p1.y >> 16;
+
+ fbShapes ((CompositeShapesFunc)pixman_composite_triangles,
+ op, pSrc, pDst, maskFormat,
+ xSrc, ySrc, xDst, yDst,
+ ntris, sizeof (xTriangle), (const uint8_t *)tris);
+}