[Spice-devel] [PATCH 14/30] Convert cairo canvas copy bits to pixman
Soeren Sandmann
sandmann at daimi.au.dk
Sun Feb 21 01:46:56 PST 2010
Alexander Larsson <alexl at redhat.com> writes:
> ---
> common/cairo_canvas.c | 254 ++++++++-----------------------------------------
> 1 files changed, 41 insertions(+), 213 deletions(-)
>
> diff --git a/common/cairo_canvas.c b/common/cairo_canvas.c
> index d0307d8..109a07c 100644
> --- a/common/cairo_canvas.c
> +++ b/common/cairo_canvas.c
> @@ -991,6 +991,33 @@ static void __draw_mask(void *data)
> cairo_mask(((DrawMaskData *)data)->cairo, ((DrawMaskData *)data)->mask);
> }
>
> +static void copy_region (CairoCanvas *canvas,
> + pixman_region32_t *dest_region,
> + int dx, int dy)
> +{
> + pixman_box32_t *dest_rects;
> + int n_rects;
> + int i;
> +
> + dest_rects = pixman_region32_rectangles (dest_region, &n_rects);
> +
> + if (dy > 0 || (dy == 0 && dx > 0)) {
> + for (i = n_rects - 1; i >= 0; i--)
> + spice_pixman_copy_rect (canvas->image,
> + dest_rects[i].x1 - dx, dest_rects[i].y1 - dy,
> + dest_rects[i].x2 - dest_rects[i].x1,
> + dest_rects[i].y2 - dest_rects[i].y1,
> + dest_rects[i].x1, dest_rects[i].y1);
> + } else {
> + for (i = 0; i < n_rects; i++)
> + spice_pixman_copy_rect (canvas->image,
> + dest_rects[i].x1 - dx, dest_rects[i].y1 - dy,
> + dest_rects[i].x2 - dest_rects[i].x1,
> + dest_rects[i].y2 - dest_rects[i].y1,
> + dest_rects[i].x1, dest_rects[i].y1);
> + }
> +}
Shouldn't there actually be four cases here: All combinations of
Up/down and left/right?
Suppose you are copying towards north-east. Then dy is negative and dx
is positive, which means you hit the second branch. But then the
copying of the first rectangle may overwrite the second one.
Or am I missing something?
Soren
More information about the Spice-devel
mailing list