From a7ceb98ea1688f0de1613ee12bb78d246869242c Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 9 Feb 2010 17:02:36 +0100 Subject: Add possibility to not invert bitmask in canvas_get_mask() 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 | 20 +++++++++++++------- common/gdi_canvas.c | 2 +- common/gl_canvas.c | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/common/cairo_canvas.c b/common/cairo_canvas.c index 5ee7ccb3..433f3c94 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 f5a6d336..6659385a 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,10 @@ 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 +1184,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 66f8a02c..83c5f05d 100644 --- a/common/gdi_canvas.c +++ b/common/gdi_canvas.c @@ -784,7 +784,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 b6d584f1..8d152eee 100644 --- a/common/gl_canvas.c +++ b/common/gl_canvas.c @@ -210,7 +210,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; } -- cgit