[Spice-devel] [PATCH 23/30] Convert cairo canvas group_start/end to pixman

Alexander Larsson alexl at redhat.com
Thu Feb 18 12:58:49 PST 2010


---
 common/cairo_canvas.c |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/common/cairo_canvas.c b/common/cairo_canvas.c
index 198785e..73bd054 100644
--- a/common/cairo_canvas.c
+++ b/common/cairo_canvas.c
@@ -1966,26 +1966,30 @@ void canvas_read_bits(CairoCanvas *canvas, uint8_t *dest, int dest_stride, const
 
 void canvas_group_start(CairoCanvas *canvas, int n_clip_rects, SpiceRect *clip_rects)
 {
-    cairo_t *cairo = canvas->cairo;
+    pixman_region32_t dest_region;
 
-    cairo_save(cairo);
+    pixman_region32_fini (&canvas->canvas_region);
+    spice_pixman_region32_init_rects (&canvas->canvas_region,
+                                      clip_rects, n_clip_rects);
 
-    if (n_clip_rects) {
-        SpiceRect *end = clip_rects + n_clip_rects;
-        for (; clip_rects < end; clip_rects++) {
-            cairo_rectangle(cairo,
-                            clip_rects->left,
-                            clip_rects->top,
-                            clip_rects->right - clip_rects->left,
-                            clip_rects->bottom - clip_rects->top);
-        }
-        cairo_clip(cairo);
-    }
+    pixman_region32_init_rect (&dest_region,
+                               0, 0,
+                               pixman_image_get_width (canvas->image),
+                               pixman_image_get_height (canvas->image));
+
+    /* Make sure we always clip to canvas size */
+    pixman_region32_intersect (&canvas->canvas_region, &canvas->canvas_region, &dest_region);
+
+    pixman_region32_fini (&dest_region);
 }
 
 void canvas_group_end(CairoCanvas *canvas)
 {
-    cairo_restore(canvas->cairo);
+    pixman_region32_fini (&canvas->canvas_region);
+    pixman_region32_init_rect (&canvas->canvas_region,
+                               0, 0,
+                               pixman_image_get_width (canvas->image),
+                               pixman_image_get_height (canvas->image));
 }
 
 void canvas_clear(CairoCanvas *canvas)
-- 
1.6.6



More information about the Spice-devel mailing list