[Spice-commits] common/canvas_base.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Thu Jan 25 22:28:53 UTC 2018


 common/canvas_base.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit fd0aba27507445851c1ed8a7603ba3ec6e6be6e7
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Jan 23 17:05:48 2018 +0000

    canvas: Fix some semi transparent drawing
    
    This is reproducible using desktop icons on Windows XP.
    
    These drawing are sent for the icons on the desktop.
    To get an extends.x1 >= 32 you have to move an icon out of the
    screen on the left side. Set the icon size to 72 as the icon has
    to be out of the screen quite a lot.
    Disable the grid alignment on the desktop and move an icon out of
    the screen. Select and unselect the icon.
    Using "/ 32" the icon will have a white background instead of a
    transparent one.
    Using a "/ 8" the icon is rendered correctly.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe de Dinechin <cdupontd at redhat.com>

diff --git a/common/canvas_base.c b/common/canvas_base.c
index 90d1d38..071999e 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -1943,8 +1943,16 @@ static void canvas_mask_pixman(CanvasBase *canvas,
     /* round down X to even 32 pixels (i.e. uint32_t) */
     extents.x1 = extents.x1 & ~(0x1f);
 
-    mask_data_src = (uint8_t *)mask_data + mask_stride * extents.y1 + extents.x1 / 32;
-    mask_data = SPICE_UNALIGNED_CAST(uint32_t *, mask_data_src);
+    /* mask_data_src is surely aligned to 4 bytes:
+     * - pixman requires mask_data (pixman_image_get_data) to be
+     *   aligned to 4 bytes;
+     * - pixman requires mask_stride (pixman_image_get_stride) to be
+     *   multiple of 4;
+     * - extents.x1 is multiple of 32 (see previous line) so
+     *   extents.x1 / 8 is multiple of 4.
+     */
+    mask_data_src = (uint8_t *)mask_data + mask_stride * extents.y1 + extents.x1 / 8;
+    mask_data = SPICE_ALIGNED_CAST(uint32_t *, mask_data_src);
 
     mask_x -= extents.x1;
     mask_y -= extents.y1;


More information about the Spice-commits mailing list