summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-06-20 19:47:18 (GMT)
committerChris Wilson <chris@chris-wilson.co.uk>2013-06-20 19:47:18 (GMT)
commit2bfb9e9001bceaedffb2303c062af8e42045931e (patch)
treeb31dcfebb978896276951726f1bdaf375ebedb58
parentb7331f0c52cc64f2c224eac502afa6c50a1a8d8b (diff)
downloadcairo-2bfb9e9001bceaedffb2303c062af8e42045931e.tar.gz
cairo-2bfb9e9001bceaedffb2303c062af8e42045931e.tar.xz
svg: Unwrap recording surfaces
As a first step towards bring SVG uptodate with the various new patterns, first we need to prevent SVG crashing when it mishandles an unknown recording surface. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/cairo-svg-surface.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index f32d522..5ee2857 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"
/**
@@ -1487,6 +1488,17 @@ _cairo_svg_surface_emit_recording_surface (cairo_svg_document_t *document,
document, NULL);
}
+static cairo_recording_surface_t *
+to_recording_surface (const cairo_surface_pattern_t *pattern)
+{
+ cairo_surface_t *surface = pattern->surface;
+ if (_cairo_surface_is_paginated (surface))
+ surface = _cairo_paginated_surface_get_recording (surface);
+ if (_cairo_surface_is_snapshot (surface))
+ surface = _cairo_surface_snapshot_get_target (surface);
+ return (cairo_recording_surface_t *) surface;
+}
+
static cairo_status_t
_cairo_svg_surface_emit_composite_recording_pattern (cairo_output_stream_t *output,
cairo_svg_surface_t *surface,
@@ -1506,7 +1518,7 @@ _cairo_svg_surface_emit_composite_recording_pattern (cairo_output_stream_t *outp
/* cairo_pattern_set_matrix ensures the matrix is invertible */
assert (status == CAIRO_STATUS_SUCCESS);
- recording_surface = (cairo_recording_surface_t *) pattern->surface;
+ recording_surface = to_recording_surface (pattern);
status = _cairo_svg_surface_emit_recording_surface (document, recording_surface);
if (unlikely (status))
return status;
@@ -1553,7 +1565,7 @@ _cairo_svg_surface_emit_composite_pattern (cairo_output_stream_t *output,
const char *extra_attributes)
{
- if (_cairo_surface_is_recording (pattern->surface)) {
+ if (pattern->surface->type == CAIRO_SURFACE_TYPE_RECORDING) {
return _cairo_svg_surface_emit_composite_recording_pattern (output, surface,
op, pattern,
pattern_id,