8aa464b
From 18ed71c29863580e960293ff67465aaed69be9bb Mon Sep 17 00:00:00 2001
8aa464b
From: Olivier Fourdan <ofourdan@redhat.com>
8aa464b
Date: Wed, 5 Oct 2016 08:36:21 +0200
8aa464b
Subject: [PATCH 2/7] glamor: Fix pixmap offset for bitplane in
8aa464b
 glamor_copy_fbo_cpu
8aa464b
MIME-Version: 1.0
8aa464b
Content-Type: text/plain; charset=UTF-8
8aa464b
Content-Transfer-Encoding: 8bit
8aa464b
8aa464b
Commit cba28d5 - "glamor: Handle bitplane in glamor_copy_fbo_cpu"
8aa464b
introduced a regression as the computed pixmap offset would not match
8aa464b
the actual coordinates and write data elsewhere in memory causing a
8aa464b
segfault in fbBltOne().
8aa464b
8aa464b
Translate the pixmap coordinates so that the data is read and written at
8aa464b
the correct location.
8aa464b
8aa464b
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97974
8aa464b
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
8aa464b
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
8aa464b
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
8aa464b
---
8aa464b
 glamor/glamor_copy.c | 18 ++++++++++--------
8aa464b
 1 file changed, 10 insertions(+), 8 deletions(-)
8aa464b
8aa464b
diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
8aa464b
index 8a329d2..3ca56fb 100644
8aa464b
--- a/glamor/glamor_copy.c
8aa464b
+++ b/glamor/glamor_copy.c
8aa464b
@@ -230,20 +230,22 @@ glamor_copy_cpu_fbo(DrawablePtr src,
8aa464b
             goto bail;
8aa464b
         }
8aa464b
 
8aa464b
+        src_pix->drawable.x = -dst->x;
8aa464b
+        src_pix->drawable.y = -dst->y;
8aa464b
+
8aa464b
         fbGetDrawable(&src_pix->drawable, src_bits, src_stride, src_bpp, src_xoff,
8aa464b
                       src_yoff);
8aa464b
 
8aa464b
         if (src->bitsPerPixel > 1)
8aa464b
-            fbCopyNto1(src, &src_pix->drawable, gc, box, nbox,
8aa464b
-                       dst_xoff + dx, dst_yoff + dy, reverse, upsidedown,
8aa464b
-                       bitplane, closure);
8aa464b
+            fbCopyNto1(src, &src_pix->drawable, gc, box, nbox, dx, dy,
8aa464b
+                       reverse, upsidedown, bitplane, closure);
8aa464b
         else
8aa464b
-            fbCopy1toN(src, &src_pix->drawable, gc, box, nbox,
8aa464b
-                       dst_xoff + dx, dst_yoff + dy, reverse, upsidedown,
8aa464b
-                       bitplane, closure);
8aa464b
+            fbCopy1toN(src, &src_pix->drawable, gc, box, nbox, dx, dy,
8aa464b
+                       reverse, upsidedown, bitplane, closure);
8aa464b
 
8aa464b
-        glamor_upload_boxes(dst_pixmap, box, nbox, 0, 0, 0, 0,
8aa464b
-                            (uint8_t *) src_bits, src_stride * sizeof(FbBits));
8aa464b
+        glamor_upload_boxes(dst_pixmap, box, nbox, src_xoff, src_yoff,
8aa464b
+                            dst_xoff, dst_yoff, (uint8_t *) src_bits,
8aa464b
+                            src_stride * sizeof(FbBits));
8aa464b
         fbDestroyPixmap(src_pix);
8aa464b
     } else {
8aa464b
         fbGetDrawable(src, src_bits, src_stride, src_bpp, src_xoff, src_yoff);
8aa464b
-- 
8aa464b
2.9.3
8aa464b