diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-06 12:39:49 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-06 12:39:49 +0000 |
commit | eac0d9652b2399f8c36ba0288db6fe347ed78dc9 (patch) | |
tree | ebb362b2de62f3884f15e8c28610777dcb9253a3 | |
parent | a3699fff5ada85e4dea739aade25ebbb728e18f4 (diff) |
sna: Optimise sna_poly_segment() for the frequent no-op case
Strange as it may seem... But the principle of doing less work with
greater locality should help everywhere, just not as noticeable when
real work is performed.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/sna_accel.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 8d6f584e..7ae76eba 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -5556,15 +5556,11 @@ sna_poly_segment_extents(DrawablePtr drawable, GCPtr gc, BoxPtr out) { BoxRec box; - int extra = gc->lineWidth; bool clipped, can_blit; if (n == 0) return 0; - if (gc->capStyle != CapProjecting) - extra >>= 1; - if (seg->x2 >= seg->x1) { box.x1 = seg->x1; box.x2 = seg->x2; @@ -5607,11 +5603,16 @@ sna_poly_segment_extents(DrawablePtr drawable, GCPtr gc, box.x2++; box.y2++; - if (extra) { - box.x1 -= extra; - box.x2 += extra; - box.y1 -= extra; - box.y2 += extra; + if (gc->lineWidth) { + int extra = gc->lineWidth; + if (gc->capStyle != CapProjecting) + extra >>= 1; + if (extra) { + box.x1 -= extra; + box.x2 += extra; + box.y1 -= extra; + box.y2 += extra; + } } DBG(("%s: unclipped, untranslated extents (%d, %d), (%d, %d)\n", @@ -5628,8 +5629,8 @@ sna_poly_segment_extents(DrawablePtr drawable, GCPtr gc, static void sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) { - PixmapPtr pixmap = get_drawable_pixmap(drawable); - struct sna *sna = to_sna_from_pixmap(pixmap); + PixmapPtr pixmap; + struct sna *sna; struct sna_damage **damage; RegionRec region; unsigned flags; @@ -5650,6 +5651,9 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) if (FORCE_FALLBACK) goto fallback; + pixmap = get_drawable_pixmap(drawable); + sna = to_sna_from_pixmap(pixmap); + if (wedged(sna)) { DBG(("%s: fallback -- wedged\n", __FUNCTION__)); goto fallback; |