diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-24 17:23:43 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-24 18:54:07 +0000 |
commit | 4aef9e6f50cb96c57b7ba345a18e55c97d788192 (patch) | |
tree | 1ebf6377b6e960b39fe9bb622e77c95bc1634f0f | |
parent | 16462e551d575bd5a370a8ac8b450ba72fea7d47 (diff) |
sna: Add more damage-is-contained asserts
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/sna_accel.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 5b90941d..44912b8f 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -168,9 +168,27 @@ static void _assert_pixmap_contains_box(PixmapPtr pixmap, BoxPtr box, const char assert(0); } } + +static void _assert_drawable_contains_box(DrawablePtr drawable, const BoxRec *box, const char *function) +{ + if (box->x1 < drawable->x || + box->y1 < drawable->y || + box->x2 > drawable->x + drawable->width || + box->y2 > drawable->y + drawable->height) + { + ErrorF("%s: damage box is beyond the drawable: box=(%d, %d), (%d, %d), drawable=(%d, %d)x(%d, %d)\n", + __FUNCTION__, + box->x1, box->y1, box->x2, box->y2, + drawable->x, drawable->y, + drawable->width, drawable->height); + assert(0); + } +} #define assert_pixmap_contains_box(p, b) _assert_pixmap_contains_box(p, b, __FUNCTION__) +#define assert_drawable_contains_box(d, b) _assert_drawable_contains_box(d, b, __FUNCTION__) #else #define assert_pixmap_contains_box(p, b) +#define assert_drawable_contains_box(d, b) #endif inline static bool @@ -1054,10 +1072,10 @@ pixmap_contains_damage(PixmapPtr pixmap, struct sna_damage *damage) return true; damage = DAMAGE_PTR(damage); - return damage->extents.x2 <= pixmap->drawable.width && + return (damage->extents.x2 <= pixmap->drawable.width && damage->extents.y2 <= pixmap->drawable.height && damage->extents.x1 >= 0 && - damage->extents.y1 >= 0; + damage->extents.y1 >= 0); } #endif @@ -1119,6 +1137,8 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable, RegionExtents(region)->x2, RegionExtents(region)->y2, flags)); + assert_pixmap_contains_box(pixmap, ®ion->extents); + priv = sna_pixmap(pixmap); if (priv == NULL) { DBG(("%s: not attached to %p\n", __FUNCTION__, pixmap)); @@ -1508,6 +1528,8 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, BoxPtr box, unsigned int flags) DBG(("%s()\n", __FUNCTION__)); + assert_pixmap_contains_box(pixmap, box); + if (DAMAGE_IS_ALL(priv->gpu_damage)) goto done; @@ -1660,6 +1682,8 @@ _sna_drawable_use_gpu_bo(DrawablePtr drawable, BoxRec extents; int16_t dx, dy; + assert_drawable_contains_box(drawable, box); + if (priv == NULL) { DBG(("%s: not attached\n", __FUNCTION__)); return FALSE; @@ -1792,6 +1816,8 @@ _sna_drawable_use_cpu_bo(DrawablePtr drawable, BoxRec extents; int16_t dx, dy; + assert_drawable_contains_box(drawable, box); + if (priv == NULL || priv->cpu_bo == NULL) return FALSE; |