diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-18 21:29:45 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-19 00:45:08 +0000 |
commit | 05f9764a8860cbdd7ea2ce7f04c221ec8481e0bc (patch) | |
tree | ddcf33e58b59eb085e8e569261f8f0c84222472c /src/sna/sna_damage.c | |
parent | 96529e345d0718d253e4abfa0a02cd1f9f7c0406 (diff) |
sna/damage: Fast path singular regions
Mainly for consistency, so that we treat it like the other damage
addition functions.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna_damage.c')
-rw-r--r-- | src/sna/sna_damage.c | 91 |
1 files changed, 47 insertions, 44 deletions
diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index a68db552..eda52c01 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -534,6 +534,50 @@ static void damage_union(struct sna_damage *damage, const BoxRec *box) } } +static void _pixman_region_union_box(RegionRec *region, const BoxRec *box) +{ + RegionRec u = { *box, NULL }; + pixman_region_union(region, region, &u); +} + +static struct sna_damage *__sna_damage_add_box(struct sna_damage *damage, + const BoxRec *box) +{ + if (box->y2 <= box->y1 || box->x2 <= box->x1) + return damage; + + if (!damage) { + damage = _sna_damage_create(); + if (damage == NULL) + return NULL; + } else switch (damage->mode) { + case DAMAGE_ALL: + return damage; + case DAMAGE_SUBTRACT: + __sna_damage_reduce(damage); + case DAMAGE_ADD: + break; + } + + switch (REGION_NUM_RECTS(&damage->region)) { + case 0: + pixman_region_init_rects(&damage->region, box, 1); + damage_union(damage, box); + return damage; + case 1: + _pixman_region_union_box(&damage->region, box); + damage_union(damage, box); + return damage; + } + + if (pixman_region_contains_rectangle(&damage->region, + (BoxPtr)box) == PIXMAN_REGION_IN) + return damage; + + damage_union(damage, box); + return _sna_damage_create_elt(damage, box, 1); +} + inline static struct sna_damage *__sna_damage_add(struct sna_damage *damage, RegionPtr region) { @@ -552,6 +596,9 @@ inline static struct sna_damage *__sna_damage_add(struct sna_damage *damage, break; } + if (region->data == NULL) + return __sna_damage_add_box(damage, ®ion->extents); + if (REGION_NUM_RECTS(&damage->region) <= 1) { pixman_region_union(&damage->region, &damage->region, region); damage_union(damage, ®ion->extents); @@ -594,50 +641,6 @@ fastcall struct sna_damage *_sna_damage_add(struct sna_damage *damage, } #endif -static void _pixman_region_union_box(RegionRec *region, const BoxRec *box) -{ - RegionRec u = { *box, NULL }; - pixman_region_union(region, region, &u); -} - -static struct sna_damage *__sna_damage_add_box(struct sna_damage *damage, - const BoxRec *box) -{ - if (box->y2 <= box->y1 || box->x2 <= box->x1) - return damage; - - if (!damage) { - damage = _sna_damage_create(); - if (damage == NULL) - return NULL; - } else switch (damage->mode) { - case DAMAGE_ALL: - return damage; - case DAMAGE_SUBTRACT: - __sna_damage_reduce(damage); - case DAMAGE_ADD: - break; - } - - switch (REGION_NUM_RECTS(&damage->region)) { - case 0: - pixman_region_init_rects(&damage->region, box, 1); - damage_union(damage, box); - return damage; - case 1: - _pixman_region_union_box(&damage->region, box); - damage_union(damage, box); - return damage; - } - - if (pixman_region_contains_rectangle(&damage->region, - (BoxPtr)box) == PIXMAN_REGION_IN) - return damage; - - damage_union(damage, box); - return _sna_damage_create_elt(damage, box, 1); -} - inline static struct sna_damage * __sna_damage_add_boxes(struct sna_damage *damage, const BoxRec *box, int n, |