From b58a6a39c1568800938eb0e3ebc7664683b61200 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 23 Jun 2010 23:56:44 +0100 Subject: uxa: Fallback to pixman if source is out-of-bounds If the source is outside the drawable, then CopyArea will fail to initialise the source correctly. The simplest fix in this case is to fallback to pixman to generate the source texture. Fixes: Bug 28497 - Graphics corruption after opening a specific website https://bugs.freedesktop.org/show_bug.cgi?id=28497 Signed-off-by: Chris Wilson --- uxa/uxa-render.c | 55 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'uxa') diff --git a/uxa/uxa-render.c b/uxa/uxa-render.c index a4cebe3d..9709a14e 100644 --- a/uxa/uxa-render.c +++ b/uxa/uxa-render.c @@ -761,6 +761,21 @@ uxa_render_picture(ScreenPtr screen, return picture; } +static int +drawable_contains (DrawablePtr drawable, int x, int y, int w, int h) +{ + if (x < 0 || y < 0) + return FALSE; + + if (x + w > drawable->width) + return FALSE; + + if (y + h > drawable->height) + return FALSE; + + return TRUE; +} + PicturePtr uxa_acquire_drawable(ScreenPtr pScreen, PicturePtr pSrc, @@ -770,14 +785,15 @@ uxa_acquire_drawable(ScreenPtr pScreen, { PixmapPtr pPixmap; PicturePtr pDst; - GCPtr pGC; int depth, error; int tx, ty; + GCPtr pGC; depth = pSrc->pDrawable->depth; - if (depth == 1 || - pSrc->filter == PictFilterConvolution || /* XXX */ - !transform_is_integer_translation(pSrc->transform, &tx, &ty)) { + if (!transform_is_integer_translation(pSrc->transform, &tx, &ty) || + !drawable_contains(pSrc->pDrawable, x + tx, y + ty, width, height) || + depth == 1 || + pSrc->filter == PictFilterConvolution) { /* XXX extract the sample extents and do the transformation on the GPU */ pDst = uxa_render_picture(pScreen, pSrc, pSrc->format | (BitsPerPixel(pSrc->pDrawable->depth) << 24), @@ -785,7 +801,7 @@ uxa_acquire_drawable(ScreenPtr pScreen, goto done; } else { - if (width == pSrc->pDrawable->width && height == pSrc->pDrawable->depth) { + if (width == pSrc->pDrawable->width && height == pSrc->pDrawable->height) { *out_x = x + pSrc->pDrawable->x; *out_y = y + pSrc->pDrawable->y; return pSrc; @@ -799,7 +815,7 @@ uxa_acquire_drawable(ScreenPtr pScreen, return 0; /* Skip the copy if the result remains in memory and not a bo */ - if (!uxa_drawable_is_offscreen(&pPixmap->drawable)) { + if (!uxa_pixmap_is_offscreen(pPixmap)) { pScreen->DestroyPixmap(pPixmap); return 0; } @@ -816,15 +832,15 @@ uxa_acquire_drawable(ScreenPtr pScreen, FreeScratchGC(pGC); pDst = CreatePicture(0, &pPixmap->drawable, - PictureMatchFormat(pScreen, depth, pSrc->format), - 0, 0, serverClient, &error); + PictureMatchFormat(pScreen, depth, pSrc->format), + 0, 0, serverClient, &error); pScreen->DestroyPixmap(pPixmap); ValidatePicture(pDst); done: pDst->componentAlpha = pSrc->componentAlpha; - *out_x = x; - *out_y = y; + *out_x = 0; + *out_y = 0; return pDst; } @@ -844,8 +860,8 @@ uxa_acquire_picture(ScreenPtr screen, *out_x = x + src->pDrawable->x; *out_y = y + src->pDrawable->y; } else { - *out_x = 0; - *out_y = 0; + *out_x = x; + *out_y = y; } return src; } @@ -1477,21 +1493,6 @@ compatible_formats (CARD8 op, PicturePtr dst, PicturePtr src) return 0; } -static int -drawable_contains (DrawablePtr drawable, int x, int y, int w, int h) -{ - if (x < 0 || y < 0) - return FALSE; - - if (x + w > drawable->width) - return FALSE; - - if (y + h > drawable->height) - return FALSE; - - return TRUE; -} - void uxa_composite(CARD8 op, PicturePtr pSrc, -- cgit v1.2.3