[Spice-devel] [PATCH 14/30] Convert cairo canvas copy bits to pixman

Alexander Larsson alexl at redhat.com
Mon Feb 22 07:14:37 PST 2010


On Sun, 2010-02-21 at 10:46 +0100, Soeren Sandmann wrote:
> 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?

No, you're right. Fixed locally.


-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
       alexl at redhat.com            alexander.larsson at gmail.com 
He's a genetically engineered gay gentleman spy on the edge. She's a 
man-hating motormouth detective from a different time and place. They fight 
crime! 



More information about the Spice-devel mailing list