xf86-video-intel: src/i830_render.c src/i915_render.c src/i965_render.c uxa/uxa-render.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Sep 14 08:30:36 PDT 2009


 src/i830_render.c |   46 ++++-----
 src/i915_render.c |   44 ++++----
 src/i965_render.c |   46 ++++-----
 uxa/uxa-render.c  |  274 ++++++++++++++++++++++++++++++++++++++++--------------
 4 files changed, 278 insertions(+), 132 deletions(-)

New commits:
commit c2abfa8e54acab61250dba1e435760e3b1499c8c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Sep 4 17:10:25 2009 +0100

    Avoid fallbacks for compositing gradient patterns
    
    Currently when asked to composite using a gradient source or mask, we
    fallback to using fbComposite().  This has the side-effect of causing a
    readback on the destination surface, stalling the GPU pipeline.  Instead,
    like uxa_trapezoids(), we can use pixman to fill a scratch pixmap and then
    copy that to an offscreen pixmap for use with uxa_composite().
    
    Speedups on i915:
    firefox-talos-svg:  710378.14 -> 549262.96:  1.29x speedup
    
    No slowdowns.
    
    Thanks to Søeren Sandmann Pedersen for spotting the missing
    ValidatePicture().
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/i830_render.c b/src/i830_render.c
index dbee446..b9bbbdb 100644
--- a/src/i830_render.c
+++ b/src/i830_render.c
@@ -221,26 +221,8 @@ static Bool i830_get_blend_cntl(ScrnInfoPtr pScrn, int op, PicturePtr pMask,
     return TRUE;
 }
 
-static Bool i830_check_composite_texture(PicturePtr pPict, int unit)
+static Bool i830_check_composite_texture(ScrnInfoPtr pScrn, PicturePtr pPict, int unit)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pPict->pDrawable->pScreen->myNum];
-    int w = pPict->pDrawable->width;
-    int h = pPict->pDrawable->height;
-    int i;
-
-    if ((w > 2048) || (h > 2048))
-        I830FALLBACK("Picture w/h too large (%dx%d)\n", w, h);
-
-    for (i = 0; i < sizeof(i830_tex_formats) / sizeof(i830_tex_formats[0]);
-	 i++)
-    {
-        if (i830_tex_formats[i].fmt == pPict->format)
-            break;
-    }
-    if (i == sizeof(i830_tex_formats) / sizeof(i830_tex_formats[0]))
-        I830FALLBACK("Unsupported picture format 0x%x\n",
-		     (int)pPict->format);
-
     if (pPict->repeatType > RepeatReflect)
         I830FALLBACK("Unsupported picture repeat %d\n", pPict->repeatType);
 
@@ -250,6 +232,26 @@ static Bool i830_check_composite_texture(PicturePtr pPict, int unit)
         I830FALLBACK("Unsupported filter 0x%x\n", pPict->filter);
     }
 
+    if (pPict->pDrawable)
+    {
+	int w, h, i;
+
+	w = pPict->pDrawable->width;
+	h = pPict->pDrawable->height;
+	if ((w > 2048) || (h > 2048))
+	    I830FALLBACK("Picture w/h too large (%dx%d)\n", w, h);
+
+	for (i = 0; i < sizeof(i830_tex_formats) / sizeof(i830_tex_formats[0]);
+	     i++)
+	{
+	    if (i830_tex_formats[i].fmt == pPict->format)
+		break;
+	}
+	if (i == sizeof(i830_tex_formats) / sizeof(i830_tex_formats[0]))
+	    I830FALLBACK("Unsupported picture format 0x%x\n",
+			 (int)pPict->format);
+    }
+
     return TRUE;
 }
 
@@ -380,9 +382,9 @@ i830_check_composite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
 			     "alpha and source value blending.\n");
     }
 
-    if (!i830_check_composite_texture(pSrcPicture, 0))
+    if (!i830_check_composite_texture(pScrn, pSrcPicture, 0))
         I830FALLBACK("Check Src picture texture\n");
-    if (pMaskPicture != NULL && !i830_check_composite_texture(pMaskPicture, 1))
+    if (pMaskPicture != NULL && !i830_check_composite_texture(pScrn, pMaskPicture, 1))
         I830FALLBACK("Check Mask picture texture\n");
 
     if (!i830_get_dest_format(pDstPicture, &tmp1))
@@ -396,7 +398,7 @@ i830_prepare_composite(int op, PicturePtr pSrcPicture,
 		       PicturePtr pMaskPicture, PicturePtr pDstPicture,
 		       PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pSrcPicture->pDrawable->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86Screens[pDstPicture->pDrawable->pScreen->myNum];
     I830Ptr pI830 = I830PTR(pScrn);
 
     pI830->render_src_picture = pSrcPicture;
diff --git a/src/i915_render.c b/src/i915_render.c
index ed0b615..9d5d425 100644
--- a/src/i915_render.c
+++ b/src/i915_render.c
@@ -169,26 +169,8 @@ static Bool i915_get_dest_format(PicturePtr pDstPicture, uint32_t *dst_format)
     return TRUE;
 }
 
-static Bool i915_check_composite_texture(PicturePtr pPict, int unit)
+static Bool i915_check_composite_texture(ScrnInfoPtr pScrn, PicturePtr pPict, int unit)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pPict->pDrawable->pScreen->myNum];
-    int w = pPict->pDrawable->width;
-    int h = pPict->pDrawable->height;
-    int i;
-
-    if ((w > 2048) || (h > 2048))
-        I830FALLBACK("Picture w/h too large (%dx%d)\n", w, h);
-
-    for (i = 0; i < sizeof(i915_tex_formats) / sizeof(i915_tex_formats[0]);
-	 i++)
-    {
-        if (i915_tex_formats[i].fmt == pPict->format)
-            break;
-    }
-    if (i == sizeof(i915_tex_formats) / sizeof(i915_tex_formats[0]))
-        I830FALLBACK("Unsupported picture format 0x%x\n",
-		     (int)pPict->format);
-
     if (pPict->repeatType > RepeatReflect)
         I830FALLBACK("Unsupported picture repeat %d\n", pPict->repeatType);
 
@@ -196,6 +178,26 @@ static Bool i915_check_composite_texture(PicturePtr pPict, int unit)
         pPict->filter != PictFilterBilinear)
         I830FALLBACK("Unsupported filter 0x%x\n", pPict->filter);
 
+    if (pPict->pDrawable)
+    {
+	int w, h, i;
+
+	w = pPict->pDrawable->width;
+	h = pPict->pDrawable->height;
+	if ((w > 2048) || (h > 2048))
+	    I830FALLBACK("Picture w/h too large (%dx%d)\n", w, h);
+
+	for (i = 0; i < sizeof(i915_tex_formats) / sizeof(i915_tex_formats[0]);
+	     i++)
+	{
+	    if (i915_tex_formats[i].fmt == pPict->format)
+		break;
+	}
+	if (i == sizeof(i915_tex_formats) / sizeof(i915_tex_formats[0]))
+	    I830FALLBACK("Unsupported picture format 0x%x\n",
+			 (int)pPict->format);
+    }
+
     return TRUE;
 }
 
@@ -222,9 +224,9 @@ i915_check_composite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
 			     "alpha and source value blending.\n");
     }
 
-    if (!i915_check_composite_texture(pSrcPicture, 0))
+    if (!i915_check_composite_texture(pScrn, pSrcPicture, 0))
         I830FALLBACK("Check Src picture texture\n");
-    if (pMaskPicture != NULL && !i915_check_composite_texture(pMaskPicture, 1))
+    if (pMaskPicture != NULL && !i915_check_composite_texture(pScrn, pMaskPicture, 1))
         I830FALLBACK("Check Mask picture texture\n");
 
     if (!i915_get_dest_format(pDstPicture, &tmp1))
diff --git a/src/i965_render.c b/src/i965_render.c
index 1a8075b..7251e3a 100644
--- a/src/i965_render.c
+++ b/src/i965_render.c
@@ -181,26 +181,8 @@ static Bool i965_get_dest_format(PicturePtr pDstPicture, uint32_t *dst_format)
     return TRUE;
 }
 
-static Bool i965_check_composite_texture(PicturePtr pPict, int unit)
+static Bool i965_check_composite_texture(ScrnInfoPtr pScrn, PicturePtr pPict, int unit)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pPict->pDrawable->pScreen->myNum];
-    int w = pPict->pDrawable->width;
-    int h = pPict->pDrawable->height;
-    int i;
-
-    if ((w > 8192) || (h > 8192))
-        I830FALLBACK("Picture w/h too large (%dx%d)\n", w, h);
-
-    for (i = 0; i < sizeof(i965_tex_formats) / sizeof(i965_tex_formats[0]);
-	 i++)
-    {
-        if (i965_tex_formats[i].fmt == pPict->format)
-            break;
-    }
-    if (i == sizeof(i965_tex_formats) / sizeof(i965_tex_formats[0]))
-        I830FALLBACK("Unsupported picture format 0x%x\n",
-		     (int)pPict->format);
-
     if (pPict->repeatType > RepeatReflect)
 	I830FALLBACK("extended repeat (%d) not supported\n",
 		     pPict->repeatType);
@@ -211,6 +193,26 @@ static Bool i965_check_composite_texture(PicturePtr pPict, int unit)
         I830FALLBACK("Unsupported filter 0x%x\n", pPict->filter);
     }
 
+    if (pPict->pDrawable)
+    {
+	int w, h, i;
+
+	w = pPict->pDrawable->width;
+	h = pPict->pDrawable->height;
+	if ((w > 8192) || (h > 8192))
+	    I830FALLBACK("Picture w/h too large (%dx%d)\n", w, h);
+
+	for (i = 0; i < sizeof(i965_tex_formats) / sizeof(i965_tex_formats[0]);
+	     i++)
+	{
+	    if (i965_tex_formats[i].fmt == pPict->format)
+		break;
+	}
+	if (i == sizeof(i965_tex_formats) / sizeof(i965_tex_formats[0]))
+	    I830FALLBACK("Unsupported picture format 0x%x\n",
+			 (int)pPict->format);
+    }
+
     return TRUE;
 }
 
@@ -239,9 +241,9 @@ i965_check_composite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
 	}
     } 
 
-    if (!i965_check_composite_texture(pSrcPicture, 0))
+    if (!i965_check_composite_texture(pScrn, pSrcPicture, 0))
         I830FALLBACK("Check Src picture texture\n");
-    if (pMaskPicture != NULL && !i965_check_composite_texture(pMaskPicture, 1))
+    if (pMaskPicture != NULL && !i965_check_composite_texture(pScrn, pMaskPicture, 1))
         I830FALLBACK("Check Mask picture texture\n");
 
     if (!i965_get_dest_format(pDstPicture, &tmp1))
@@ -1438,7 +1440,7 @@ i965_prepare_composite(int op, PicturePtr pSrcPicture,
 		       PicturePtr pMaskPicture, PicturePtr pDstPicture,
 		       PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pSrcPicture->pDrawable->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86Screens[pDstPicture->pDrawable->pScreen->myNum];
     I830Ptr pI830 = I830PTR(pScrn);
     struct gen4_render_state *render_state= pI830->gen4_render_state;
     gen4_composite_op *composite_op = &render_state->composite_op;
diff --git a/uxa/uxa-render.c b/uxa/uxa-render.c
index 13128ed..e071fc4 100644
--- a/uxa/uxa-render.c
+++ b/uxa/uxa-render.c
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 
 #include "uxa-priv.h"
+#include <xorgVersion.h>
 
 #ifdef RENDER
 #include "mipict.h"
@@ -314,6 +315,137 @@ uxa_try_driver_solid_fill(PicturePtr	pSrc,
     return 1;
 }
 
+static PicturePtr
+uxa_picture_from_pixman_image (ScreenPtr pScreen,
+			       pixman_image_t *image,
+			       pixman_format_code_t format)
+{
+    PicturePtr pPicture;
+    PixmapPtr pPixmap;
+    GCPtr pGC;
+    int width, height, depth;
+    int error;
+
+    width = pixman_image_get_width (image);
+    height = pixman_image_get_height (image);
+    depth = pixman_image_get_depth (image);
+
+    pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, depth,
+					UXA_CREATE_PIXMAP_FOR_MAP);
+    if (!pPixmap)
+	return 0;
+
+    pPicture = CreatePicture (0, &pPixmap->drawable,
+			      PictureMatchFormat (pScreen, depth, format),
+			      0, 0, serverClient, &error);
+    (*pScreen->DestroyPixmap) (pPixmap);
+    ValidatePicture (pPicture);
+
+    pPixmap = GetScratchPixmapHeader(pScreen, width, height, depth,
+				     BitsPerPixel (depth),
+				     pixman_image_get_stride (image),
+				     pixman_image_get_data (image));
+    if (!pPixmap)
+    {
+	FreePicture (pPicture, 0);
+	return 0;
+    }
+
+    pGC = GetScratchGC (depth, pScreen);
+    if (!pGC)
+    {
+	FreeScratchPixmapHeader (pPixmap);
+	FreePicture (pPicture, 0);
+	return 0;
+    }
+    ValidateGC (pPicture->pDrawable, pGC);
+
+    (*pGC->ops->CopyArea) (&pPixmap->drawable, pPicture->pDrawable,
+			   pGC, 0, 0, width, height, 0, 0);
+
+    FreeScratchGC (pGC);
+    FreeScratchPixmapHeader (pPixmap);
+
+    return pPicture;
+}
+
+#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC (1,6,99,1,0)
+#define IMAGE_FROM_PICT(P) image_from_pict(P, 0)
+#else
+#define IMAGE_FROM_PICT(P) image_from_pict(P, 0, 0)
+#endif
+
+static PicturePtr
+uxa_acquire_pattern (ScreenPtr pScreen,
+		     PicturePtr pPict,
+		     pixman_format_code_t format,
+		     INT16 x, INT16 y,
+		     CARD16 width, CARD16 height)
+{
+    pixman_image_t *source, *image;
+
+    source = IMAGE_FROM_PICT (pPict);
+    if (!source)
+	return 0;
+
+    image = pixman_image_create_bits (format, width, height, NULL, 0);
+    if (!image) {
+	pixman_image_unref (source);
+	return 0;
+    }
+
+    pixman_image_composite (PIXMAN_OP_SRC,
+			    source, NULL, image,
+			    x, y,
+			    0, 0,
+			    0, 0,
+			    width, height);
+    pixman_image_unref (source);
+
+    pPict = uxa_picture_from_pixman_image (pScreen, image, format);
+    pixman_image_unref (image);
+
+    return pPict;
+}
+
+static PicturePtr
+uxa_acquire_source (ScreenPtr pScreen,
+		    PicturePtr pPict,
+		    INT16 x, INT16 y,
+		    CARD16 width, CARD16 height,
+		    INT16 *out_x, INT16 *out_y)
+{
+    if (pPict->pDrawable) {
+	*out_x = x + pPict->pDrawable->x;
+	*out_y = y + pPict->pDrawable->y;
+	return pPict;
+    }
+
+    *out_x = 0;
+    *out_y = 0;
+    return uxa_acquire_pattern (pScreen, pPict,
+				PICT_a8r8g8b8, x, y, width, height);
+}
+
+static PicturePtr
+uxa_acquire_mask (ScreenPtr pScreen,
+		  PicturePtr pPict,
+		  INT16 x, INT16 y,
+		  INT16 width, INT16 height,
+		  INT16 *out_x, INT16 *out_y)
+{
+    if (pPict->pDrawable) {
+	*out_x = x + pPict->pDrawable->x;
+	*out_y = y + pPict->pDrawable->y;
+	return pPict;
+    }
+
+    *out_x = 0;
+    *out_y = 0;
+    return uxa_acquire_pattern (pScreen, pPict,
+				PICT_a8, x, y, width, height);
+}
+
 static int
 uxa_try_driver_composite_rects(CARD8		    op,
 			       PicturePtr	    pSrc,
@@ -333,7 +465,7 @@ uxa_try_driver_composite_rects(CARD8		    op,
     {
 	return -1;
     }
-    
+
     pDstPix = uxa_get_offscreen_pixmap(pDst->pDrawable, &dst_off_x, &dst_off_y);
     if (!pDstPix)
 	return 0;
@@ -453,48 +585,84 @@ uxa_try_driver_composite(CARD8		op,
     int nbox;
     int src_off_x, src_off_y, mask_off_x, mask_off_y, dst_off_x, dst_off_y;
     PixmapPtr pSrcPix, pMaskPix = NULL, pDstPix;
+    PicturePtr localSrc, localMask = NULL;
 
     xDst += pDst->pDrawable->x;
     yDst += pDst->pDrawable->y;
 
+    localSrc = uxa_acquire_source (pDst->pDrawable->pScreen,
+				   pSrc, xSrc, ySrc, width, height,
+				   &xSrc, &ySrc);
+    if (! localSrc)
+	return 0;
+
     if (pMask) {
-	xMask += pMask->pDrawable->x;
-	yMask += pMask->pDrawable->y;
-    }
+	localMask = uxa_acquire_mask (pDst->pDrawable->pScreen,
+				      pMask, xMask, yMask, width, height,
+				      &xMask, &yMask);
+	if (! localMask) {
+	    if (localSrc != pSrc)
+		FreePicture (localSrc, 0);
 
-    xSrc += pSrc->pDrawable->x;
-    ySrc += pSrc->pDrawable->y;
+	    return 0;
+	}
+    }
 
     if (uxa_screen->info->check_composite &&
-	!(*uxa_screen->info->check_composite) (op, pSrc, pMask, pDst))
+	!(*uxa_screen->info->check_composite) (op, localSrc, localMask, pDst))
     {
+	if (localSrc != pSrc)
+	    FreePicture (localSrc, 0);
+	if (localMask && localMask != pMask)
+	    FreePicture (localMask, 0);
+
 	return -1;
     }
 
-    if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
+    if (!miComputeCompositeRegion (&region, localSrc, localMask, pDst,
 				   xSrc, ySrc, xMask, yMask, xDst, yDst,
 				   width, height))
+    {
+	if (localSrc != pSrc)
+	    FreePicture (localSrc, 0);
+	if (localMask && localMask != pMask)
+	    FreePicture (localMask, 0);
+
 	return 1;
+    }
 
     pDstPix = uxa_get_offscreen_pixmap (pDst->pDrawable, &dst_off_x, &dst_off_y);
 
-    pSrcPix = uxa_get_offscreen_pixmap (pSrc->pDrawable, &src_off_x, &src_off_y);
+    pSrcPix = uxa_get_offscreen_pixmap (localSrc->pDrawable,
+					&src_off_x, &src_off_y);
 
-    if (pMask)
-	pMaskPix = uxa_get_offscreen_pixmap (pMask->pDrawable, &mask_off_x,
-					     &mask_off_y);
+    if (localMask)
+	pMaskPix = uxa_get_offscreen_pixmap (localMask->pDrawable,
+					     &mask_off_x, &mask_off_y);
 
-    if (!pDstPix || !pSrcPix || (pMask && !pMaskPix)) {
+    if (!pDstPix || !pSrcPix || (localMask && !pMaskPix)) {
 	REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+
+	if (localSrc != pSrc)
+	    FreePicture (localSrc, 0);
+	if (localMask && localMask != pMask)
+	    FreePicture (localMask, 0);
+
 	return 0;
     }
 
     REGION_TRANSLATE(pScreen, &region, dst_off_x, dst_off_y);
 
-    if (!(*uxa_screen->info->prepare_composite) (op, pSrc, pMask, pDst, pSrcPix,
-						 pMaskPix, pDstPix))
+    if (!(*uxa_screen->info->prepare_composite) (op, localSrc, localMask, pDst,
+						 pSrcPix, pMaskPix, pDstPix))
     {
 	REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+
+	if (localSrc != pSrc)
+	    FreePicture (localSrc, 0);
+	if (localMask && localMask != pMask)
+	    FreePicture (localMask, 0);
+
 	return -1;
     }
 
@@ -523,6 +691,12 @@ uxa_try_driver_composite(CARD8		op,
     (*uxa_screen->info->done_composite) (pDstPix);
 
     REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+
+    if (localSrc != pSrc)
+	FreePicture (localSrc, 0);
+    if (localMask && localMask != pMask)
+	FreePicture (localMask, 0);
+
     return 1;
 }
 
@@ -636,14 +810,11 @@ uxa_composite(CARD8	op,
     Bool saveMaskRepeat = pMask ? pMask->repeat : 0;
     RegionRec region;
 
-    /* We currently don't support acceleration of gradients, or other pictures
-     * with a NULL pDrawable.
-     */
-    if (uxa_screen->swappedOut ||
-	pSrc->pDrawable == NULL || (pMask != NULL && pMask->pDrawable == NULL))
-    {
+    if (uxa_screen->swappedOut)
 	goto fallback;
-    }
+
+    if (pSrc->pDrawable == NULL || (pMask && pMask->pDrawable == NULL))
+	goto composite;
 
     /* Remove repeat in source if useless */
     if (pSrc->repeat && !pSrc->transform && xSrc >= 0 &&
@@ -738,10 +909,11 @@ uxa_composite(CARD8	op,
 	}
     }
 
+composite:
     /* Remove repeat in mask if useless */
-    if (pMask && pMask->repeat && !pMask->transform && xMask >= 0 &&
-	(xMask + width) <= pMask->pDrawable->width && yMask >= 0 &&
-	(yMask + height) <= pMask->pDrawable->height)
+    if (pMask && pMask->repeat && !pMask->transform && pMask->pDrawable &&
+	xMask >= 0 && (xMask + width) <= pMask->pDrawable->width &&
+	yMask >= 0 && (yMask + height) <= pMask->pDrawable->height)
 	    pMask->repeat = 0;
 
     if (uxa_screen->info->prepare_composite &&
@@ -757,7 +929,8 @@ uxa_composite(CARD8	op,
 	/* For generic masks and solid src pictures, mach64 can do Over in two
 	 * passes, similar to the component-alpha case.
 	 */
-	isSrcSolid = pSrc->pDrawable->width == 1 &&
+	isSrcSolid = pSrc->pDrawable &&
+		     pSrc->pDrawable->width == 1 &&
 		     pSrc->pDrawable->height == 1 &&
 		     pSrc->repeat;
 
@@ -888,62 +1061,29 @@ uxa_trapezoids (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
 	PicturePtr	pPicture;
 	INT16		xDst, yDst;
 	INT16		xRel, yRel;
-	int		width, height, stride;
-	PixmapPtr	pPixmap;
-	GCPtr		pGC;
+	int		width, height;
 	pixman_image_t	*image;
+	pixman_format_code_t format;
 
 	xDst = traps[0].left.p1.x >> 16;
 	yDst = traps[0].left.p1.y >> 16;
 
 	width = bounds.x2 - bounds.x1;
 	height = bounds.y2 - bounds.y1;
-	stride = (width * BitsPerPixel (maskFormat->depth) + 7) / 8;
 
-	pPicture = uxa_create_alpha_picture (pScreen, pDst, maskFormat,
-					     width, height);
-	if (!pPicture)
+	format = maskFormat->format | (BitsPerPixel (maskFormat->depth) << 24);
+	image = pixman_image_create_bits (format, width, height, NULL, 0);
+	if (!image)
 	    return;
 
-	image = pixman_image_create_bits (pPicture->format,
-					  width, height,
-					  NULL, stride);
-	if (!image) {
-	    FreePicture (pPicture, 0);
-	    return;
-	}
-
 	for (; ntrap; ntrap--, traps++)
 	    pixman_rasterize_trapezoid (image, (pixman_trapezoid_t *) traps,
 					-bounds.x1, -bounds.y1);
 
-	pPixmap = GetScratchPixmapHeader(pScreen, width, height,
-					 maskFormat->depth,
-					 BitsPerPixel (maskFormat->depth),
-					 PixmapBytePad (width, maskFormat->depth),
-					 pixman_image_get_data (image));
-	if (!pPixmap) {
-	    FreePicture (pPicture, 0);
-	    pixman_image_unref (image);
-	    return;
-	}
-
-	pGC = GetScratchGC (pPicture->pDrawable->depth, pScreen);
-	if (!pGC)
-	{
-	    FreeScratchPixmapHeader (pPixmap);
-	    pixman_image_unref (image);
-	    FreePicture (pPicture, 0);
-	    return;
-	}
-	ValidateGC (pPicture->pDrawable, pGC);
-
-	(*pGC->ops->CopyArea) (&pPixmap->drawable, pPicture->pDrawable,
-			       pGC, 0, 0, width, height, 0, 0);
-
-	FreeScratchGC (pGC);
-	FreeScratchPixmapHeader (pPixmap);
+	pPicture = uxa_picture_from_pixman_image (pScreen, image, format);
 	pixman_image_unref (image);
+	if (!pPicture)
+	    return;
 
 	xRel = bounds.x1 + xSrc - xDst;
 	yRel = bounds.y1 + ySrc - yDst;


More information about the xorg-commit mailing list