diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-11-14 12:04:49 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-11-14 12:13:58 +0000 |
commit | 99338ebe61917a07611cbc81cfaf70c0ec905014 (patch) | |
tree | b015493a2affc8842050f81ead913ef17b2ff159 | |
parent | 00d1c539e4b69636bfc35c0c47a6f1db3a33e731 (diff) |
sna: Check whether damage can be reduced to all-damage on moving to GPU
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/sna_accel.c | 11 | ||||
-rw-r--r-- | src/sna/sna_damage.c | 12 | ||||
-rw-r--r-- | src/sna/sna_damage.h | 29 |
3 files changed, 31 insertions, 21 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 9fd5accf..ac76525f 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -712,8 +712,7 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, BoxPtr box) assert(priv->gpu); assert(priv->gpu_bo); - sna_damage_reduce(&priv->cpu_damage, - pixmap->drawable.width, pixmap->drawable.height); + sna_damage_reduce(&priv->cpu_damage); DBG(("%s: CPU damage? %d\n", __FUNCTION__, priv->cpu_damage != NULL)); if (priv->cpu_damage == NULL) @@ -1008,8 +1007,7 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap) if (priv == NULL) return NULL; - sna_damage_reduce(&priv->cpu_damage, - pixmap->drawable.width, pixmap->drawable.height); + sna_damage_reduce(&priv->cpu_damage); DBG(("%s: CPU damage? %d\n", __FUNCTION__, priv->cpu_damage != NULL)); if (priv->gpu_bo == NULL) { @@ -1069,9 +1067,10 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap) __sna_damage_destroy(priv->cpu_damage); priv->cpu_damage = NULL; - sna_damage_reduce(&priv->gpu_damage, - pixmap->drawable.width, pixmap->drawable.height); + sna_damage_reduce(&priv->gpu_damage); done: + sna_damage_reduce_all(&priv->gpu_damage, + pixmap->drawable.width, pixmap->drawable.height); list_del(&priv->list); priv->gpu = true; return priv; diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index 2d7d65d7..95a92a53 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -1242,10 +1242,9 @@ 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, - int width, int height) +struct sna_damage *_sna_damage_reduce(struct sna_damage *damage) { - DBG(("%s(width=%d, height=%d)\n", __FUNCTION__, width, height)); + DBG(("%s\n", __FUNCTION__)); if (damage->n) __sna_damage_reduce(damage); @@ -1253,13 +1252,6 @@ 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 c62e8310..7fc6d024 100644 --- a/src/sna/sna_damage.h +++ b/src/sna/sna_damage.h @@ -127,15 +127,34 @@ 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, - int width, int height); -static inline void sna_damage_reduce(struct sna_damage **damage, - int width, int height) +struct sna_damage *_sna_damage_reduce(struct sna_damage *damage); +static inline void sna_damage_reduce(struct sna_damage **damage) { if (*damage == NULL) return; - *damage = _sna_damage_reduce(*damage, width, height); + if ((*damage)->mode != DAMAGE_ALL) + *damage = _sna_damage_reduce(*damage); +} + +static inline void sna_damage_reduce_all(struct sna_damage **damage, + int width, int height) +{ + DBG(("%s(width=%d, height=%d)\n", __FUNCTION__, width, height)); + + if (*damage == NULL) + return; + + if ((*damage)->mode == DAMAGE_ADD && + (*damage)->extents.x1 <= 0 && + (*damage)->extents.y1 <= 0 && + (*damage)->extents.x2 >= width && + (*damage)->extents.y2 >= height) { + if ((*damage)->n) + *damage = _sna_damage_reduce(*damage); + if ((*damage)->region.data == NULL) + *damage = _sna_damage_all(*damage, width, height); + } } void __sna_damage_destroy(struct sna_damage *damage); |