diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-11-12 19:35:43 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-11-12 20:08:13 +0000 |
commit | 87147b63e905c3566ac1c12e0712f068e90d5e2e (patch) | |
tree | 7ffcbaed6feb0c1e623afea8ee7d2dd27bdbde8a | |
parent | e8799cdea461df5102d421fda26fecceae79b929 (diff) |
sna/damage: Reduce the damage for evaluating sna_damage_is_all
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/gen3_render.c | 5 | ||||
-rw-r--r-- | src/sna/gen4_render.c | 4 | ||||
-rw-r--r-- | src/sna/gen5_render.c | 4 | ||||
-rw-r--r-- | src/sna/gen6_render.c | 4 | ||||
-rw-r--r-- | src/sna/gen7_render.c | 4 | ||||
-rw-r--r-- | src/sna/sna_accel.c | 19 | ||||
-rw-r--r-- | src/sna/sna_blt.c | 8 | ||||
-rw-r--r-- | src/sna/sna_damage.c | 40 | ||||
-rw-r--r-- | src/sna/sna_damage.h | 15 |
9 files changed, 49 insertions, 54 deletions
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 54ccb931..0a17e4c3 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -2187,10 +2187,7 @@ reduce_damage(struct sna_composite_op *op, r.y1 = dst_y + op->dst.y; r.y2 = r.y1 + height; - if (sna_damage_is_all(op->damage, - op->dst.pixmap->drawable.width, - op->dst.pixmap->drawable.width) || - sna_damage_contains_box(*op->damage, &r) == PIXMAN_REGION_IN) + if (sna_damage_contains_box(*op->damage, &r) == PIXMAN_REGION_IN) op->damage = NULL; } diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index e3a715ed..ae535b10 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -1826,8 +1826,8 @@ gen4_composite_set_target(PicturePtr dst, struct sna_composite_op *op) return FALSE; op->dst.bo = priv->gpu_bo; - if (!priv->gpu_only && - !sna_damage_is_all(&priv->gpu_damage, op->dst.width, op->dst.height)) + if (!sna_damage_is_all(&priv->gpu_damage, + op->dst.width, op->dst.height)) op->damage = &priv->gpu_damage; DBG(("%s: gpu_only=%d, all-damaged=%d, damage=%p\n", __FUNCTION__, priv->gpu_only, diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index 82a84d6a..0b8a947a 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -1877,8 +1877,8 @@ gen5_composite_set_target(PicturePtr dst, struct sna_composite_op *op) op->dst.bo = priv->gpu_bo; - if (!priv->gpu_only && - !sna_damage_is_all(&priv->gpu_damage, op->dst.width, op->dst.height)) + if (!sna_damage_is_all(&priv->gpu_damage, + op->dst.width, op->dst.height)) op->damage = &priv->gpu_damage; DBG(("%s: bo=%p, damage=%p\n", __FUNCTION__, op->dst.bo, op->damage)); diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 9e184452..12fcd312 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -2046,8 +2046,8 @@ gen6_composite_set_target(struct sna_composite_op *op, PicturePtr dst) return FALSE; op->dst.bo = priv->gpu_bo; - if (!priv->gpu_only && - !sna_damage_is_all(&priv->gpu_damage, op->dst.width, op->dst.height)) + if (!sna_damage_is_all(&priv->gpu_damage, + op->dst.width, op->dst.height)) op->damage = &priv->gpu_damage; } diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index 5fe25991..f620285e 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2177,8 +2177,8 @@ gen7_composite_set_target(struct sna_composite_op *op, PicturePtr dst) return FALSE; op->dst.bo = priv->gpu_bo; - if (!priv->gpu_only && - !sna_damage_is_all(&priv->gpu_damage, op->dst.width, op->dst.height)) + if (!sna_damage_is_all(&priv->gpu_damage, + op->dst.width, op->dst.height)) op->damage = &priv->gpu_damage; } diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index df237071..4d4d408c 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -710,7 +710,8 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, BoxPtr box) assert(priv->gpu); assert(priv->gpu_bo); - sna_damage_reduce(&priv->cpu_damage); + sna_damage_reduce(&priv->cpu_damage, + pixmap->drawable.width, pixmap->drawable.height); DBG(("%s: CPU damage? %d\n", __FUNCTION__, priv->cpu_damage != NULL)); if (priv->cpu_damage == NULL) @@ -804,10 +805,7 @@ _sna_drawable_use_gpu_bo(DrawablePtr drawable, sna_pixmap_move_area_to_gpu(pixmap, &extents); done: if (damage) { - if (!sna_damage_is_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height) && - sna_damage_contains_box(priv->gpu_damage, + if (sna_damage_contains_box(priv->gpu_damage, &extents) != PIXMAN_REGION_IN) *damage = &priv->gpu_damage; else @@ -860,10 +858,7 @@ _sna_drawable_use_cpu_bo(DrawablePtr drawable, done: if (damage) { - if (!sna_damage_is_all(&priv->cpu_damage, - pixmap->drawable.width, - pixmap->drawable.height) && - sna_damage_contains_box(priv->cpu_damage, + if (sna_damage_contains_box(priv->cpu_damage, &extents) != PIXMAN_REGION_IN) *damage = &priv->cpu_damage; else @@ -1011,7 +1006,8 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap) if (priv == NULL) return NULL; - sna_damage_reduce(&priv->cpu_damage); + sna_damage_reduce(&priv->cpu_damage, + pixmap->drawable.width, pixmap->drawable.height); DBG(("%s: CPU damage? %d\n", __FUNCTION__, priv->cpu_damage != NULL)); if (priv->gpu_bo == NULL) { @@ -1071,7 +1067,8 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap) __sna_damage_destroy(priv->cpu_damage); priv->cpu_damage = NULL; - sna_damage_reduce(&priv->gpu_damage); + sna_damage_reduce(&priv->gpu_damage, + pixmap->drawable.width, pixmap->drawable.height); done: list_del(&priv->list); priv->gpu = true; diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 2e61bb98..0290a33f 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -1219,10 +1219,7 @@ reduce_damage(struct sna_composite_op *op, r.y1 = dst_y + op->dst.y; r.y2 = r.y1 + height; - if (sna_damage_is_all(op->damage, - op->dst.pixmap->drawable.width, - op->dst.pixmap->drawable.width) || - sna_damage_contains_box(*op->damage, &r) == PIXMAN_REGION_IN) + if (sna_damage_contains_box(*op->damage, &r) == PIXMAN_REGION_IN) op->damage = NULL; } @@ -1274,8 +1271,7 @@ sna_blt_composite(struct sna *sna, get_drawable_deltas(dst->pDrawable, tmp->dst.pixmap, &tmp->dst.x, &tmp->dst.y); tmp->dst.bo = priv->gpu_bo; - if (!priv->gpu_only && - !sna_damage_is_all(&priv->gpu_damage, + if (!sna_damage_is_all(&priv->gpu_damage, tmp->dst.width, tmp->dst.height)) tmp->damage = &priv->gpu_damage; if (width && height) diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index 6492205b..5a4d67c3 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -941,14 +941,10 @@ struct sna_damage *_sna_damage_all(struct sna_damage *damage, struct sna_damage *_sna_damage_is_all(struct sna_damage *damage, int width, int height) { - BoxRec box; - - box.x1 = box.y1 = 0; - box.x2 = width; - box.y2 = height; + if (damage->n) + __sna_damage_reduce(damage); - if (pixman_region_contains_rectangle(&damage->region, - &box) != PIXMAN_REGION_IN) + if (damage->region.data) return damage; return _sna_damage_all(damage, width, height); @@ -1114,6 +1110,8 @@ fastcall struct sna_damage *_sna_damage_subtract_box(struct sna_damage *damage, static int _sna_damage_contains_box(struct sna_damage *damage, const BoxRec *box) { + int ret; + if (!damage) return PIXMAN_REGION_OUT; @@ -1123,18 +1121,14 @@ static int _sna_damage_contains_box(struct sna_damage *damage, if (!sna_damage_maybe_contains_box(damage, box)) return PIXMAN_REGION_OUT; - if (damage->n) { - if (damage->mode != DAMAGE_SUBTRACT) { - int ret = pixman_region_contains_rectangle(&damage->region, - (BoxPtr)box); - if (ret == PIXMAN_REGION_IN) - return PIXMAN_REGION_IN; - } - + if (damage->mode == DAMAGE_SUBTRACT) __sna_damage_reduce(damage); - } - return pixman_region_contains_rectangle(&damage->region, (BoxPtr)box); + ret = pixman_region_contains_rectangle(&damage->region, (BoxPtr)box); + if (damage->n == 0) + return ret; + + return ret == PIXMAN_REGION_IN ? PIXMAN_REGION_IN : PIXMAN_REGION_OUT; } #if DEBUG_DAMAGE @@ -1235,9 +1229,10 @@ static int _sna_damage_get_boxes(struct sna_damage *damage, BoxPtr *boxes) return REGION_NUM_RECTS(&damage->region); } -struct sna_damage *_sna_damage_reduce(struct sna_damage *damage) +struct sna_damage *_sna_damage_reduce(struct sna_damage *damage, + int width, int height) { - DBG(("%s()\n", __FUNCTION__)); + DBG(("%s(width=%d, height=%d)\n", __FUNCTION__, width, height)); if (damage->n) __sna_damage_reduce(damage); @@ -1245,6 +1240,13 @@ struct sna_damage *_sna_damage_reduce(struct sna_damage *damage) if (!pixman_region_not_empty(&damage->region)) { __sna_damage_destroy(damage); damage = NULL; + } else { + if (damage->region.data == NULL && + damage->extents.x1 <= 0 && + damage->extents.y1 <= 0 && + damage->extents.x2 >= width && + damage->extents.y2 >= height) + damage = _sna_damage_all(damage, width, height); } return damage; diff --git a/src/sna/sna_damage.h b/src/sna/sna_damage.h index 2dc27375..c62e8310 100644 --- a/src/sna/sna_damage.h +++ b/src/sna/sna_damage.h @@ -79,9 +79,6 @@ static inline bool sna_damage_is_all(struct sna_damage **damage, if (*damage == NULL) return false; - if ((*damage)->n) - return false; - switch ((*damage)->mode) { case DAMAGE_ALL: return true; @@ -89,6 +86,10 @@ static inline bool sna_damage_is_all(struct sna_damage **damage, return false; default: case DAMAGE_ADD: + if ((*damage)->extents.x2 < width || (*damage)->extents.x1 > 0) + return false; + if ((*damage)->extents.y2 < height || (*damage)->extents.y1 > 0) + return false; *damage = _sna_damage_is_all(*damage, width, height); return (*damage)->mode == DAMAGE_ALL; } @@ -126,13 +127,15 @@ int sna_damage_contains_box(struct sna_damage *damage, int sna_damage_get_boxes(struct sna_damage *damage, BoxPtr *boxes); -struct sna_damage *_sna_damage_reduce(struct sna_damage *damage); -static inline void sna_damage_reduce(struct sna_damage **damage) +struct sna_damage *_sna_damage_reduce(struct sna_damage *damage, + int width, int height); +static inline void sna_damage_reduce(struct sna_damage **damage, + int width, int height) { if (*damage == NULL) return; - *damage = _sna_damage_reduce(*damage); + *damage = _sna_damage_reduce(*damage, width, height); } void __sna_damage_destroy(struct sna_damage *damage); |