Blame SOURCES/exa-only-draw-valid-trapezoids.patch

d64d53
From patchwork Wed Oct  2 13:47:54 2013
d64d53
Content-Type: text/plain; charset="utf-8"
d64d53
MIME-Version: 1.0
d64d53
Content-Transfer-Encoding: 7bit
d64d53
Subject: exa: only draw valid trapezoids
d64d53
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
d64d53
X-Patchwork-Id: 14769
d64d53
Message-Id: <524C240A.9010607@canonical.com>
d64d53
To: "X.Org Devel List" <xorg-devel@lists.freedesktop.org>
d64d53
Date: Wed, 02 Oct 2013 15:47:54 +0200
d64d53
d64d53
Fixes freedesktop.org bug https://bugs.freedesktop.org/show_bug.cgi?id=67484
d64d53
d64d53
If t->bottom is close to MIN_INT, removing top can wraparound, so do the check properly.
d64d53
A similar fix should also be applied to pixman.
d64d53
d64d53
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
d64d53
d64d53
---
d64d53
d64d53
d64d53
diff --git a/exa/exa_render.c b/exa/exa_render.c
d64d53
index 172e2b5..807eeba 100644
d64d53
--- a/exa/exa_render.c
d64d53
+++ b/exa/exa_render.c
d64d53
@@ -1141,7 +1141,8 @@ exaTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
d64d53
 
d64d53
         exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
d64d53
         for (; ntrap; ntrap--, traps++)
d64d53
-            (*ps->RasterizeTrapezoid) (pPicture, traps, -bounds.x1, -bounds.y1);
d64d53
+            if (xTrapezoidValid(traps))
d64d53
+                (*ps->RasterizeTrapezoid) (pPicture, traps, -bounds.x1, -bounds.y1);
d64d53
         exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
d64d53
 
d64d53
         xRel = bounds.x1 + xSrc - xDst;
d64d53
diff --git a/render/picture.h b/render/picture.h
d64d53
index c85353a..fcd6401 100644
d64d53
--- a/render/picture.h
d64d53
+++ b/render/picture.h
d64d53
@@ -211,7 +211,7 @@ typedef pixman_fixed_t xFixed;
d64d53
 /* whether 't' is a well defined not obviously empty trapezoid */
d64d53
 #define xTrapezoidValid(t)  ((t)->left.p1.y != (t)->left.p2.y && \
d64d53
 			     (t)->right.p1.y != (t)->right.p2.y && \
d64d53
-			     (int) ((t)->bottom - (t)->top) > 0)
d64d53
+			     ((t)->bottom > (t)->top))
d64d53
 
d64d53
 /*
d64d53
  * Standard NTSC luminance conversions: