[Spice-devel] [PATCH spice-common] canvas: Fix some semi transparent drawing

Frediano Ziglio fziglio at redhat.com
Wed Jan 24 09:05:17 UTC 2018


> 
> 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 right side. Set the icon size to 72 as the icon has

Here is "left side", not left.

> 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>
> ---
>  common/canvas_base.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/common/canvas_base.c b/common/canvas_base.c
> index 42f0eea..f0f6bbf 100644
> --- a/common/canvas_base.c
> +++ b/common/canvas_base.c
> @@ -1941,8 +1941,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;

Frediano


More information about the Spice-devel mailing list