From 52b11f63d7922032caef0f0a5979b080dbddcbfc Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 16 Feb 2012 11:22:23 +0000 Subject: [PATCH] sna: Upconvert fallback trapezoids to a8 Since the hardware only handles a8 without tricky emulation and pixman insists on using a1 for sharp trapezoids we need to ensure that we convert the a1 to a8 for our trapezoidal mask. More worryingly, this path should never be hit... References: https://bugs.freedesktop.org/show_bug.cgi?id=46156 Signed-off-by: Chris Wilson --- src/sna/sna_trapezoids.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c index 28c8a677..b02f8f71 100644 --- a/src/sna/sna_trapezoids.c +++ b/src/sna/sna_trapezoids.c @@ -2009,20 +2009,41 @@ trapezoids_fallback(CARD8 op, PicturePtr src, PicturePtr dst, DBG(("%s: mask (%dx%d) depth=%d, format=%08x\n", __FUNCTION__, width, height, depth, format)); scratch = sna_pixmap_create_upload(screen, - width, height, depth, + width, height, 8, KGEM_BUFFER_WRITE); if (!scratch) return; - memset(scratch->devPrivate.ptr, 0, scratch->devKind*height); - image = pixman_image_create_bits(format, width, height, - scratch->devPrivate.ptr, - scratch->devKind); + if (depth < 8) { + image = pixman_image_create_bits(format, width, height, + NULL, 0); + } else { + memset(scratch->devPrivate.ptr, 0, scratch->devKind*height); + image = pixman_image_create_bits(format, width, height, + scratch->devPrivate.ptr, + scratch->devKind); + } if (image) { for (; ntrap; ntrap--, traps++) pixman_rasterize_trapezoid(image, (pixman_trapezoid_t *)traps, -bounds.x1, -bounds.y1); + if (depth < 8) { + pixman_image_t *a8; + + a8 = pixman_image_create_bits(PIXMAN_a8, width, height, + scratch->devPrivate.ptr, + scratch->devKind); + if (a8) { + pixman_image_composite(PIXMAN_OP_SRC, + image, NULL, a8, + 0, 0, + 0, 0, + 0, 0, + width, height); + pixman_image_unref (a8); + } + } pixman_image_unref(image); }