[Spice-devel] [PATCH 09/30] Add possibility to not invert bitmask in canvas_get_mask()

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


This allows the pixman implementation to instead invert the (generally
smaller) region instead of duplicating the bitmap to invert it.
---
 common/cairo_canvas.c |    2 +-
 common/canvas_base.c  |   19 ++++++++++++-------
 common/gdi_canvas.c   |    2 +-
 common/gl_canvas.c    |    2 +-
 4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/common/cairo_canvas.c b/common/cairo_canvas.c
index 8f5e24b..a85677b 100644
--- a/common/cairo_canvas.c
+++ b/common/cairo_canvas.c
@@ -673,7 +673,7 @@ static cairo_pattern_t *canvas_get_mask_pattern(CairoCanvas *canvas, SpiceQMask
     cairo_pattern_t *pattern;
     cairo_matrix_t matrix;
 
-    if (!(surface = canvas_get_mask(&canvas->base, mask))) {
+    if (!(surface = canvas_get_mask(&canvas->base, mask, NULL))) {
         return NULL;
     }
     cairo_surface = surface_from_pixman_image (surface);
diff --git a/common/canvas_base.c b/common/canvas_base.c
index 2ea66a4..1971b4d 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -1134,7 +1134,7 @@ static inline pixman_image_t* canvas_handle_inverse_user_data(pixman_image_t* su
     return inv_surf;
 }
 
-static pixman_image_t *canvas_get_mask(CanvasBase *canvas, SpiceQMask *mask)
+static pixman_image_t *canvas_get_mask(CanvasBase *canvas, SpiceQMask *mask, int *needs_invert_out)
 {
     SpiceImageDescriptor *descriptor;
     pixman_image_t *surface;
@@ -1142,6 +1142,9 @@ static pixman_image_t *canvas_get_mask(CanvasBase *canvas, SpiceQMask *mask)
     int is_invers;
     int cache_me;
 
+    if (needs_invert_out)
+        *needs_invert_out = 0;
+
     if (!mask->bitmap) {
         return NULL;
     }
@@ -1180,12 +1183,14 @@ static pixman_image_t *canvas_get_mask(CanvasBase *canvas, SpiceQMask *mask)
     }
 
     if (need_invers && !is_invers) { // surface is in cache
-        pixman_image_t *inv_surf;
-
-        inv_surf = canvas_handle_inverse_user_data(surface);
-
-        pixman_image_unref(surface);
-        surface = inv_surf;
+        if (needs_invert_out != NULL)
+            *needs_invert_out = TRUE;
+        else {
+            pixman_image_t *inv_surf;
+            inv_surf = canvas_handle_inverse_user_data(surface);
+            pixman_image_unref(surface);
+            surface = inv_surf;
+        }
     }
 #endif
     return surface;
diff --git a/common/gdi_canvas.c b/common/gdi_canvas.c
index 7dda270..e9325d1 100644
--- a/common/gdi_canvas.c
+++ b/common/gdi_canvas.c
@@ -783,7 +783,7 @@ static struct BitmapData get_mask_bitmap(struct GdiCanvas *canvas, struct SpiceQ
     PixmanData *pixman_data;
 
     bitmap.hbitmap = NULL;
-    if (!(surface = canvas_get_mask(&canvas->base, mask))) {
+    if (!(surface = canvas_get_mask(&canvas->base, mask, NULL))) {
         return bitmap;
     }
 
diff --git a/common/gl_canvas.c b/common/gl_canvas.c
index 559566b..b8d4843 100644
--- a/common/gl_canvas.c
+++ b/common/gl_canvas.c
@@ -209,7 +209,7 @@ static void set_mask(GLCanvas *canvas, SpiceQMask *mask, int x, int y)
 {
     pixman_image_t *image;
 
-    if (!(image = canvas_get_mask(&canvas->base, mask))) {
+    if (!(image = canvas_get_mask(&canvas->base, mask, NULL))) {
         glc_clear_mask(canvas->glc, GLC_MASK_A);
         return;
     }
-- 
1.6.6



More information about the Spice-devel mailing list