diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c index f32d522..eedf19d 100644 --- a/src/cairo-svg-surface.c +++ b/src/cairo-svg-surface.c @@ -56,6 +56,7 @@ #include "cairo-paginated-private.h" #include "cairo-scaled-font-subsets-private.h" #include "cairo-surface-clipper-private.h" +#include "cairo-surface-snapshot-inline.h" #include "cairo-svg-surface-private.h" /** @@ -1552,20 +1553,34 @@ _cairo_svg_surface_emit_composite_pattern (cairo_output_stream_t *output, const cairo_matrix_t *parent_matrix, const char *extra_attributes) { + cairo_surface_t *orig_source = NULL; + cairo_status_t status; - if (_cairo_surface_is_recording (pattern->surface)) { - return _cairo_svg_surface_emit_composite_recording_pattern (output, surface, - op, pattern, - pattern_id, - parent_matrix, - extra_attributes); + if (_cairo_surface_is_snapshot (pattern->surface)) { + /* XXX: Is it a good idea to mess with the pattern? No, it isn't. (E.g. + * this is thread-unsafe, because other threads could be using the same + * pattern) + */ + orig_source = pattern->surface; + pattern->surface = _cairo_surface_snapshot_get_target (pattern->surface); } - return _cairo_svg_surface_emit_composite_surface_pattern (output, surface, - op, pattern, - pattern_id, - parent_matrix, - extra_attributes); + if (_cairo_surface_is_recording (pattern->surface)) { + status = _cairo_svg_surface_emit_composite_recording_pattern (output, surface, + op, pattern, + pattern_id, + parent_matrix, + extra_attributes); + } else { + status = _cairo_svg_surface_emit_composite_surface_pattern (output, surface, + op, pattern, + pattern_id, + parent_matrix, + extra_attributes); + } + if (orig_source) + pattern->surface = orig_source; + return status; } static cairo_status_t