From b3659beec8c4126de5da4df5cb2cc077b7af6c0b Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 15 Jun 2012 11:08:18 +0100 Subject: [PATCH] sna: Check for zero-sized damage regions after trimming Windows to their pixmaps Reported-by: Zdenek Kabelac Signed-off-by: Chris Wilson --- src/sna/sna_accel.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 982f5623..ab451f9b 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1736,6 +1736,11 @@ out: return true; } +static inline bool box_empty(const BoxRec *box) +{ + return box->x2 <= box->x1 || box->y2 <= box->y1; +} + bool sna_drawable_move_to_cpu(DrawablePtr drawable, unsigned flags) { @@ -1770,6 +1775,9 @@ sna_drawable_move_to_cpu(DrawablePtr drawable, unsigned flags) if (region.extents.y2 > pixmap->drawable.height) region.extents.y2 = pixmap->drawable.height; + if (box_empty(®ion.extents)) + return true; + return sna_drawable_move_region_to_cpu(&pixmap->drawable, ®ion, flags); } @@ -2714,11 +2722,6 @@ static inline void box32_add_rect(Box32Rec *box, const xRectangle *r) box->y2 = v; } -static inline bool box_empty(const BoxRec *box) -{ - return box->x2 <= box->x1 || box->y2 <= box->y1; -} - static Bool sna_put_image_upload_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region, int x, int y, int w, int h, char *bits, int stride)