From 338941eda3c7591a85b83000eafae0407d0d7cd0 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 25 Jan 2012 02:42:25 +0000 Subject: [PATCH] sna: Handle self-copies for CopyPlane Prepare the source first as this has the dual benefit of letting us decide how best to proceed with the op (on the CPU or GPU) and prevents modification of the damage after we have choosen our preferred path. Signed-off-by: Chris Wilson --- src/sna/sna_accel.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index f52766bc..03dceaf1 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -4827,8 +4827,6 @@ sna_copy_plane_blt(DrawablePtr source, DrawablePtr drawable, GCPtr gc, if (n == 0) return; - if (!sna_pixmap_move_to_cpu(src_pixmap, MOVE_READ)) - return; get_drawable_deltas(source, src_pixmap, &dx, &dy); sx += dx; sy += dy; @@ -5027,6 +5025,9 @@ sna_copy_plane(DrawablePtr src, DrawablePtr dst, GCPtr gc, DBG(("%s: src=(%d, %d), dst=(%d, %d), size=%dx%d\n", __FUNCTION__, src_x, src_y, dst_x, dst_y, w, h)); + if (gc->planemask == 0) + return NULL; + if (src->bitsPerPixel == 1 && (bit&1) == 0) return miHandleExposures(src, dst, gc, src_x, src_y, @@ -5068,6 +5069,17 @@ sna_copy_plane(DrawablePtr src, DrawablePtr dst, GCPtr gc, if (!RegionNotEmpty(®ion)) return NULL; + RegionTranslate(®ion, + src_x - dst_x - dst->x + src->x, + src_y - dst_y - dst->y + src->y); + + if (!sna_drawable_move_region_to_cpu(src, ®ion, MOVE_READ)) + goto out; + + RegionTranslate(®ion, + -(src_x - dst_x - dst->x + src->x), + -(src_y - dst_y - dst->y + src->y)); + if (FORCE_FALLBACK) goto fallback; @@ -5077,6 +5089,9 @@ sna_copy_plane(DrawablePtr src, DrawablePtr dst, GCPtr gc, if (wedged(sna)) goto fallback; + if (!PM_IS_SOLID(dst, gc->planemask)) + goto fallback; + if (sna_drawable_use_gpu_bo(dst, ®ion.extents, &damage)) { struct sna_pixmap *priv = sna_pixmap(pixmap); if (priv->gpu_bo->tiling != I915_TILING_Y || @@ -5096,17 +5111,10 @@ fallback: ret = NULL; if (!sna_gc_move_to_cpu(gc, dst)) goto out; - if (!sna_drawable_move_region_to_cpu(dst, ®ion, MOVE_READ | MOVE_WRITE)) goto out; - RegionTranslate(®ion, - src_x - dst_x - dst->x + src->x, - src_y - dst_y - dst->y + src->y); - if (!sna_drawable_move_region_to_cpu(src, ®ion, MOVE_READ)) - goto out; - DBG(("%s: fbCopyPlane(%d, %d, %d, %d, %d,%d) %x\n", __FUNCTION__, src_x, src_y, w, h, dst_x, dst_y, (unsigned)bit)); ret = fbCopyPlane(src, dst, gc, src_x, src_y, w, h, dst_x, dst_y, bit);