diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-06-05 12:26:23 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-06-05 13:58:27 +0100 |
commit | 9566fc0ccc71bc4fcd6bf83b567a41cc5366f5ee (patch) | |
tree | cb78754fc20bc549d87b2fae8920bf1a688df6f9 | |
parent | 1327918f91dce2051b809594db5a3ed555934612 (diff) |
sna: Curry parameters to sna_damage_all()
It is far easily to pass the PixmapPtr into the function and have it
pluck out the width and height than do so in all callers.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/sna_accel.c | 134 | ||||
-rw-r--r-- | src/sna/sna_composite.c | 17 | ||||
-rw-r--r-- | src/sna/sna_damage.h | 16 | ||||
-rw-r--r-- | src/sna/sna_display.c | 5 | ||||
-rw-r--r-- | src/sna/sna_dri3.c | 8 | ||||
-rw-r--r-- | src/sna/sna_trapezoids.c | 4 | ||||
-rw-r--r-- | src/sna/sna_trapezoids_imprecise.c | 4 |
7 files changed, 60 insertions, 128 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 70211eb0..a307d9e8 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -768,14 +768,10 @@ struct sna_pixmap *sna_pixmap_attach_to_bo(PixmapPtr pixmap, struct kgem_bo *bo) if (bo->snoop) { priv->cpu_bo = bo; - sna_damage_all(&priv->cpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->cpu_damage, pixmap); } else { priv->gpu_bo = bo; - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); } return priv; @@ -996,7 +992,7 @@ fallback: priv->shm = true; priv->stride = pitch; priv->ptr = MAKE_STATIC_PTR(addr); - sna_damage_all(&priv->cpu_damage, width, height); + sna_damage_all(&priv->cpu_damage, pixmap); pixmap->devKind = pitch; pixmap->devPrivate.ptr = addr; @@ -1061,7 +1057,7 @@ sna_pixmap_create_scratch(ScreenPtr screen, return NullPixmap; } - sna_damage_all(&priv->gpu_damage, width, height); + sna_damage_all(&priv->gpu_damage, pixmap); assert(to_sna_from_pixmap(pixmap) == sna); assert(pixmap->drawable.pScreen == screen); @@ -1198,9 +1194,7 @@ sna_set_shared_pixmap_backing(PixmapPtr pixmap, void *fd_handle) if (bo == NULL) return FALSE; - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); bo->pitch = pixmap->devKind; priv->stride = pixmap->devKind; @@ -1274,7 +1268,7 @@ sna_create_pixmap_shared(struct sna *sna, ScreenPtr screen, priv->mapped = MAPPED_GTT; assert_pixmap_map(pixmap, priv); - sna_damage_all(&priv->gpu_damage, width, height); + sna_damage_all(&priv->gpu_damage, pixmap); } return pixmap; @@ -2131,9 +2125,7 @@ _sna_pixmap_move_to_cpu(PixmapPtr pixmap, unsigned int flags) assert(has_coherent_ptr(sna, priv, flags)); assert(priv->gpu_bo->proxy == NULL); - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); sna_damage_destroy(&priv->cpu_damage); priv->clear = false; list_del(&priv->flush_list); @@ -2194,9 +2186,7 @@ skip_inplace_map: if (flags & MOVE_WRITE) { assert(priv->gpu_bo->proxy == NULL); - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); sna_damage_destroy(&priv->cpu_damage); sna_pixmap_free_cpu(sna, priv, priv->cpu); list_del(&priv->flush_list); @@ -2236,9 +2226,7 @@ skip_inplace_map: if (flags & MOVE_WRITE) { assert(priv->gpu_bo->proxy == NULL); - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); sna_damage_destroy(&priv->cpu_damage); sna_pixmap_free_cpu(sna, priv, priv->cpu); list_del(&priv->flush_list); @@ -2301,9 +2289,7 @@ skip_inplace_map: priv->clear_color); } - sna_damage_all(&priv->cpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->cpu_damage, pixmap); sna_pixmap_free_gpu(sna, priv); assert(priv->gpu_damage == NULL); assert(priv->clear == false); @@ -2334,9 +2320,7 @@ skip_inplace_map: if (flags & MOVE_WRITE || priv->create & KGEM_CAN_CREATE_LARGE) { mark_damage: DBG(("%s: marking as damaged\n", __FUNCTION__)); - sna_damage_all(&priv->cpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->cpu_damage, pixmap); sna_pixmap_free_gpu(sna, priv); assert(priv->gpu_damage == NULL); assert(priv->clear == false); @@ -2572,9 +2556,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable, sna_add_flush_pixmap(sna, priv, priv->gpu_bo); assert(priv->cpu_damage == NULL); - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); sna_damage_subtract(&priv->gpu_damage, region); discard_gpu = false; } @@ -2773,9 +2755,7 @@ move_to_cpu: sna_damage_subtract(&priv->cpu_damage, region); if (sna_pixmap_move_to_gpu(pixmap, MOVE_READ | MOVE_ASYNC_HINT)) { assert(priv->gpu_bo); - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); sna_pixmap_free_cpu(sna, priv, false); } } @@ -2976,9 +2956,7 @@ done: assert(!DAMAGE_IS_ALL(priv->cpu_damage)); assert_pixmap_contains_box(pixmap, RegionExtents(region)); sna_damage_add(&priv->cpu_damage, region); - sna_damage_reduce_all(&priv->cpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_reduce_all(&priv->cpu_damage, pixmap); if (DAMAGE_IS_ALL(priv->cpu_damage)) { DBG(("%s: replaced entire pixmap\n", __FUNCTION__)); sna_pixmap_free_gpu(sna, priv); @@ -3141,9 +3119,7 @@ __sna_pixmap_for_gpu(struct sna *sna, PixmapPtr pixmap, unsigned flags) if (priv == NULL) return NULL; - sna_damage_all(&priv->cpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->cpu_damage, pixmap); assert(priv->gpu_bo == NULL); assert(priv->gpu_damage == NULL); @@ -3406,9 +3382,7 @@ done: __FUNCTION__)); assert(priv->gpu_bo); assert(priv->gpu_bo->proxy == NULL); - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); } if (DAMAGE_IS_ALL(priv->gpu_damage)) sna_pixmap_free_cpu(sna, priv, priv->cpu); @@ -3892,8 +3866,8 @@ sna_pixmap_create_upload(ScreenPtr screen, * but will work so long as we always check before doing the * transfer. */ - sna_damage_all(&priv->gpu_damage, width, height); - sna_damage_all(&priv->cpu_damage, width, height); + sna_damage_all(&priv->gpu_damage, pixmap); + sna_damage_all(&priv->cpu_damage, pixmap); pixmap->devKind = priv->gpu_bo->pitch; pixmap->devPrivate.ptr = ptr; @@ -4016,9 +3990,7 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags) priv->cpu_bo = NULL; priv->ptr = NULL; pixmap->devPrivate.ptr = NULL; - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); sna_damage_destroy(&priv->cpu_damage); goto done; } @@ -4051,9 +4023,7 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags) */ assert(priv->gpu_bo); assert(priv->gpu_bo->proxy == NULL); - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); DBG(("%s: marking as all-damaged for GPU\n", __FUNCTION__)); goto active; @@ -4085,9 +4055,7 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags) priv->cpu_bo = NULL; priv->ptr = NULL; pixmap->devPrivate.ptr = NULL; - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); sna_damage_destroy(&priv->cpu_damage); goto done; } @@ -4147,18 +4115,14 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags) assert(!priv->shm); assert(priv->gpu_bo); assert(priv->gpu_bo->proxy == NULL); - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); sna_pixmap_free_cpu(sna, priv, (priv->create & KGEM_CAN_CREATE_LARGE) ? false : priv->cpu); } done: list_del(&priv->flush_list); - sna_damage_reduce_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_reduce_all(&priv->gpu_damage, pixmap); if (DAMAGE_IS_ALL(priv->gpu_damage)) sna_pixmap_free_cpu(sna, priv, priv->cpu); @@ -4520,14 +4484,10 @@ try_upload_blt(PixmapPtr pixmap, RegionRec *region, if (!DAMAGE_IS_ALL(priv->gpu_damage)) { assert(!priv->clear); if (region_subsumes_drawable(region, &pixmap->drawable)) { - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); } else { sna_damage_add(&priv->gpu_damage, region); - sna_damage_reduce_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_reduce_all(&priv->gpu_damage, pixmap); } if (DAMAGE_IS_ALL(priv->gpu_damage)) sna_damage_destroy(&priv->cpu_damage); @@ -4603,9 +4563,7 @@ try_upload_tiled_x(PixmapPtr pixmap, RegionRec *region, sna_pixmap_free_gpu(sna, priv); ignore_cpu = priv->cpu_damage == NULL; if (priv->ptr) - sna_damage_all(&priv->cpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->cpu_damage, pixmap); } } @@ -4721,14 +4679,10 @@ try_upload_tiled_x(PixmapPtr pixmap, RegionRec *region, if (!DAMAGE_IS_ALL(priv->gpu_damage)) { assert(!priv->clear); if (replaces) { - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); } else { sna_damage_add(&priv->gpu_damage, region); - sna_damage_reduce_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_reduce_all(&priv->gpu_damage, pixmap); } if (DAMAGE_IS_ALL(priv->gpu_damage)) sna_damage_destroy(&priv->cpu_damage); @@ -5499,9 +5453,7 @@ sna_self_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, if (!DAMAGE_IS_ALL(priv->gpu_damage)) { assert(!priv->clear); if (priv->cpu_bo == NULL) { - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); } else { RegionTranslate(region, tx, ty); sna_damage_add(&priv->gpu_damage, region); @@ -6073,9 +6025,7 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, src_priv->clear_color)); dst_priv->clear = true; dst_priv->clear_color = color; - sna_damage_all(&dst_priv->gpu_damage, - dst_pixmap->drawable.width, - dst_pixmap->drawable.height); + sna_damage_all(&dst_priv->gpu_damage, dst_pixmap); sna_damage_destroy(&dst_priv->cpu_damage); list_del(&dst_priv->flush_list); return; @@ -6116,9 +6066,7 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, assert(src_pixmap->drawable.bitsPerPixel == dst_pixmap->drawable.bitsPerPixel); if (sna_pixmap_make_cow(sna, src_priv, dst_priv)) { assert(dst_priv->gpu_bo == src_priv->gpu_bo); - sna_damage_all(&dst_priv->gpu_damage, - dst_pixmap->drawable.width, - dst_pixmap->drawable.height); + sna_damage_all(&dst_priv->gpu_damage, dst_pixmap); sna_damage_destroy(&dst_priv->cpu_damage); list_del(&dst_priv->flush_list); if (dst_priv->shm) @@ -6386,9 +6334,7 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, assert(*damage == dst_priv->gpu_damage); if (replaces) { sna_damage_destroy(&dst_priv->cpu_damage); - sna_damage_all(&dst_priv->gpu_damage, - dst_pixmap->drawable.width, - dst_pixmap->drawable.height); + sna_damage_all(&dst_priv->gpu_damage, dst_pixmap); list_del(&dst_priv->flush_list); } else sna_damage_add(&dst_priv->gpu_damage, @@ -11374,11 +11320,9 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, if (damage) { assert_pixmap_contains_box(pixmap, &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 + r.y2 - r.y1 == pixmap->drawable.height) + sna_damage_all(damage, pixmap); + else sna_damage_add_box(damage, &r); } assert_pixmap_damage(pixmap); @@ -11389,9 +11333,7 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, struct sna_pixmap *priv = sna_pixmap(pixmap); if (bo == priv->gpu_bo) { assert(priv->gpu_bo->proxy == NULL); - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); sna_damage_destroy(&priv->cpu_damage); list_del(&priv->flush_list); priv->clear = true; @@ -14337,9 +14279,7 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) DBG(("%s: promoting to full GPU\n", __FUNCTION__)); assert(priv->gpu_bo->proxy == NULL); - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); } DBG(("%s: dropping last-cpu hint\n", __FUNCTION__)); priv->cpu = false; diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c index 070faf4b..8b4aa808 100644 --- a/src/sna/sna_composite.c +++ b/src/sna/sna_composite.c @@ -418,9 +418,12 @@ static void apply_damage(struct sna_composite_op *op, RegionPtr region) assert_pixmap_contains_box(op->dst.pixmap, RegionExtents(region)); if (region->data == NULL && region->extents.x2 - region->extents.x1 == op->dst.width && - region->extents.y2 - region->extents.y1 == op->dst.height) - sna_damage_all(op->damage, op->dst.width, op->dst.height); - else + region->extents.y2 - region->extents.y1 == op->dst.height) { + *op->damage = _sna_damage_all(*op->damage, + op->dst.width, + op->dst.height); + op->damage = NULL; + } else sna_damage_add(op->damage, region); } @@ -964,9 +967,7 @@ sna_composite_rectangles(CARD8 op, if (priv->gpu_bo && priv->cpu_damage == NULL) { DBG(("%s: promoting to full GPU\n", __FUNCTION__)); assert(priv->gpu_bo->proxy == NULL); - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); } } } @@ -1037,9 +1038,7 @@ sna_composite_rectangles(CARD8 op, */ if (region_subsumes_drawable(®ion, &pixmap->drawable)) { if (damage) { - sna_damage_all(damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(damage, pixmap); sna_damage_destroy(damage == &priv->gpu_damage ? &priv->cpu_damage : &priv->gpu_damage); } diff --git a/src/sna/sna_damage.h b/src/sna/sna_damage.h index 187d312d..42edb105 100644 --- a/src/sna/sna_damage.h +++ b/src/sna/sna_damage.h @@ -141,10 +141,12 @@ _sna_damage_all(struct sna_damage *damage, } static inline void sna_damage_all(struct sna_damage **damage, - int width, int height) + PixmapPtr pixmap) { if (!DAMAGE_IS_ALL(*damage)) - *damage = _sna_damage_all(*damage, width, height); + *damage = _sna_damage_all(*damage, + pixmap->drawable.width, + pixmap->drawable.height); } fastcall struct sna_damage *_sna_damage_subtract(struct sna_damage *damage, @@ -262,7 +264,7 @@ static inline void sna_damage_reduce(struct sna_damage **damage) } static inline void sna_damage_reduce_all(struct sna_damage **_damage, - int width, int height) + PixmapPtr pixmap) { struct sna_damage *damage = *_damage; @@ -274,8 +276,8 @@ static inline void sna_damage_reduce_all(struct sna_damage **_damage, if (damage->mode == DAMAGE_ADD) { if (damage->extents.x1 <= 0 && damage->extents.y1 <= 0 && - damage->extents.x2 >= width && - damage->extents.y2 >= height) { + damage->extents.x2 >= pixmap->drawable.width && + damage->extents.y2 >= pixmap->drawable.height) { if (damage->dirty) { damage = *_damage = _sna_damage_reduce(damage); if (damage == NULL) @@ -283,7 +285,9 @@ static inline void sna_damage_reduce_all(struct sna_damage **_damage, } if (damage->region.data == NULL) - *_damage = _sna_damage_all(damage, width, height); + *_damage = _sna_damage_all(damage, + pixmap->drawable.width, + pixmap->drawable.height); } } else *_damage = _sna_damage_reduce(damage); diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 470db869..46fc22c8 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -3306,10 +3306,7 @@ static void copy_front(struct sna *sna, PixmapPtr old, PixmapPtr new) } } - if (!DAMAGE_IS_ALL(new_priv->gpu_damage)) - sna_damage_all(&new_priv->gpu_damage, - new->drawable.width, - new->drawable.height); + sna_damage_all(&new_priv->gpu_damage, new); } static Bool diff --git a/src/sna/sna_dri3.c b/src/sna/sna_dri3.c index 0e58e790..5d51b41c 100644 --- a/src/sna/sna_dri3.c +++ b/src/sna/sna_dri3.c @@ -61,9 +61,7 @@ static void sna_sync_flush(struct sna *sna, struct sna_pixmap *priv) assert(priv->pinned & PIN_DRI3); DBG(("%s: flushing prime GPU bo, handle=%ld\n", __FUNCTION__, priv->gpu_bo->handle)); if (sna_pixmap_move_to_gpu(priv->pixmap, MOVE_READ | MOVE_WRITE | MOVE_ASYNC_HINT | __MOVE_FORCE)) { - sna_damage_all(&priv->gpu_damage, - priv->pixmap->drawable.width, - priv->pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, priv->pixmap); bo = priv->gpu_bo; } } else { @@ -313,9 +311,7 @@ static int sna_dri3_fd_from_pixmap(ScreenPtr screen, } else { priv = sna_pixmap_move_to_gpu(pixmap, MOVE_READ | MOVE_WRITE | MOVE_ASYNC_HINT | __MOVE_FORCE | __MOVE_DRI); if (priv != NULL) { - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); bo = priv->gpu_bo; } } diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c index 40663bb8..c11a1417 100644 --- a/src/sna/sna_trapezoids.c +++ b/src/sna/sna_trapezoids.c @@ -725,9 +725,7 @@ static void mark_damaged(PixmapPtr pixmap, struct sna_pixmap *priv, box->x2 >= pixmap->drawable.width && box->y2 >= pixmap->drawable.height) { sna_damage_destroy(&priv->cpu_damage); - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); list_del(&priv->flush_list); } else { sna_damage_add_box(&priv->gpu_damage, box); diff --git a/src/sna/sna_trapezoids_imprecise.c b/src/sna/sna_trapezoids_imprecise.c index a6da2d80..115d2b45 100644 --- a/src/sna/sna_trapezoids_imprecise.c +++ b/src/sna/sna_trapezoids_imprecise.c @@ -3395,9 +3395,7 @@ static void mark_damaged(PixmapPtr pixmap, struct sna_pixmap *priv, box->x2 >= pixmap->drawable.width && box->y2 >= pixmap->drawable.height) { sna_damage_destroy(&priv->cpu_damage); - sna_damage_all(&priv->gpu_damage, - pixmap->drawable.width, - pixmap->drawable.height); + sna_damage_all(&priv->gpu_damage, pixmap); list_del(&priv->flush_list); } else { sna_damage_add_box(&priv->gpu_damage, box); |