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.
This commit is contained in:
Alexander Larsson 2010-02-09 17:02:36 +01:00 committed by Marc-André Lureau
parent f4b7a9d004
commit 5784e86202
4 changed files with 16 additions and 10 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}