sna: Reduce damage after complete solid fills

RenderFillRectangles is often used to initially clear a pixmap after
creation by flooding it with a solid colour, as is PolyRect. We can
reduce further damage operations by checking for this condition.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2011-12-22 14:30:04 +00:00
parent 7a6a2c5d4c
commit 1f2cd536bc
2 changed files with 19 additions and 3 deletions

View File

@ -6283,7 +6283,13 @@ sna_poly_fill_rect_blt(DrawablePtr drawable,
gc->alu)) {
if (damage) {
assert_pixmap_contains_box(pixmap, &r);
sna_damage_add_box(damage, &r);
if (r.x2 - r.x1 == pixmap->drawable.width &&
r.y2 - r.y1 == pixmap->drawable.height)
sna_damage_all(damage,
pixmap->drawable.width,
pixmap->drawable.height);
else
sna_damage_add_box(damage, &r);
}
} else
success = false;

View File

@ -742,7 +742,17 @@ sna_composite_rectangles(CARD8 op,
}
assert_pixmap_contains_box(pixmap, RegionExtents(&region));
sna_damage_add(&priv->gpu_damage, &region);
/* Clearing a pixmap after creation is a common operation, so take
* advantage and reduce further damage operations.
*/
if (region.data == NULL &&
region.extents.x2 - region.extents.x1 == pixmap->drawable.width &&
region.extents.y2 - region.extents.y1 == pixmap->drawable.height)
sna_damage_all(&priv->gpu_damage,
pixmap->drawable.width, pixmap->drawable.height);
else
sna_damage_add(&priv->gpu_damage, &region);
goto done;
@ -759,7 +769,7 @@ fallback:
!sna_drawable_move_to_cpu(dst->alphaMap->pDrawable, error))
goto done;
if (op == PictOpSrc || op == PictOpClear) {
if (op <= PictOpSrc) {
int nbox = REGION_NUM_RECTS(&region);
BoxPtr box = REGION_RECTS(&region);
uint32_t pixel;