diff options
-rw-r--r-- | src/cairo-meta-surface.c | 24 | ||||
-rw-r--r-- | src/cairo-pattern.c | 17 | ||||
-rw-r--r-- | src/cairoint.h | 3 |
3 files changed, 32 insertions, 12 deletions
diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c index d505adcf..9f60007a 100644 --- a/src/cairo-meta-surface.c +++ b/src/cairo-meta-surface.c @@ -134,31 +134,31 @@ _cairo_meta_surface_finish (void *abstract_surface) /* 5 basic drawing operations */ case CAIRO_COMMAND_PAINT: - _cairo_pattern_fini (&command->paint.source.base); + _cairo_pattern_fini_snapshot (&command->paint.source.base); free (command); break; case CAIRO_COMMAND_MASK: - _cairo_pattern_fini (&command->mask.source.base); - _cairo_pattern_fini (&command->mask.mask.base); + _cairo_pattern_fini_snapshot (&command->mask.source.base); + _cairo_pattern_fini_snapshot (&command->mask.mask.base); free (command); break; case CAIRO_COMMAND_STROKE: - _cairo_pattern_fini (&command->stroke.source.base); + _cairo_pattern_fini_snapshot (&command->stroke.source.base); _cairo_path_fixed_fini (&command->stroke.path); _cairo_stroke_style_fini (&command->stroke.style); free (command); break; case CAIRO_COMMAND_FILL: - _cairo_pattern_fini (&command->fill.source.base); + _cairo_pattern_fini_snapshot (&command->fill.source.base); _cairo_path_fixed_fini (&command->fill.path); free (command); break; case CAIRO_COMMAND_SHOW_TEXT_GLYPHS: - _cairo_pattern_fini (&command->show_text_glyphs.source.base); + _cairo_pattern_fini_snapshot (&command->show_text_glyphs.source.base); free (command->show_text_glyphs.utf8); free (command->show_text_glyphs.glyphs); free (command->show_text_glyphs.clusters); @@ -255,7 +255,7 @@ _cairo_meta_surface_paint (void *abstract_surface, return CAIRO_STATUS_SUCCESS; CLEANUP_SOURCE: - _cairo_pattern_fini (&command->source.base); + _cairo_pattern_fini_snapshot (&command->source.base); CLEANUP_COMMAND: free (command); return status; @@ -299,9 +299,9 @@ _cairo_meta_surface_mask (void *abstract_surface, return CAIRO_STATUS_SUCCESS; CLEANUP_MASK: - _cairo_pattern_fini (&command->mask.base); + _cairo_pattern_fini_snapshot (&command->mask.base); CLEANUP_SOURCE: - _cairo_pattern_fini (&command->source.base); + _cairo_pattern_fini_snapshot (&command->source.base); CLEANUP_COMMAND: free (command); return status; @@ -363,7 +363,7 @@ _cairo_meta_surface_stroke (void *abstract_surface, CLEANUP_PATH: _cairo_path_fixed_fini (&command->path); CLEANUP_SOURCE: - _cairo_pattern_fini (&command->source.base); + _cairo_pattern_fini_snapshot (&command->source.base); CLEANUP_COMMAND: free (command); return status; @@ -416,7 +416,7 @@ _cairo_meta_surface_fill (void *abstract_surface, CLEANUP_PATH: _cairo_path_fixed_fini (&command->path); CLEANUP_SOURCE: - _cairo_pattern_fini (&command->source.base); + _cairo_pattern_fini_snapshot (&command->source.base); CLEANUP_COMMAND: free (command); return status; @@ -511,7 +511,7 @@ _cairo_meta_surface_show_text_glyphs (void *abstract_surface, free (command->glyphs); free (command->clusters); - _cairo_pattern_fini (&command->source.base); + _cairo_pattern_fini_snapshot (&command->source.base); CLEANUP_COMMAND: free (command); return status; diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c index 38aa253c..38db9805 100644 --- a/src/cairo-pattern.c +++ b/src/cairo-pattern.c @@ -296,6 +296,23 @@ _cairo_pattern_fini (cairo_pattern_t *pattern) #endif } +void +_cairo_pattern_fini_snapshot (cairo_pattern_t *pattern) +{ + /* XXX this is quite ugly, but currently necessary to break the circular + * references with snapshot-cow and the meta-surface. + * This operation remains safe only whilst _cairo_surface_snapshot() is + * not public... + */ + if (pattern->type == CAIRO_PATTERN_TYPE_SURFACE) { + cairo_surface_pattern_t *spat = (cairo_surface_pattern_t *) pattern; + + cairo_surface_finish (spat->surface); + } + + _cairo_pattern_fini (pattern); +} + cairo_status_t _cairo_pattern_create_copy (cairo_pattern_t **pattern_out, const cairo_pattern_t *other) diff --git a/src/cairoint.h b/src/cairoint.h index f5968f3c..6b125946 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -2498,6 +2498,9 @@ _cairo_pattern_init_radial (cairo_radial_pattern_t *pattern, cairo_private void _cairo_pattern_fini (cairo_pattern_t *pattern); +cairo_private void +_cairo_pattern_fini_snapshot (cairo_pattern_t *pattern); + cairo_private cairo_pattern_t * _cairo_pattern_create_solid (const cairo_color_t *color, cairo_content_t content); |