[cairo-commit] src/cairo-svg-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Jun 20 12:55:30 PDT 2013


 src/cairo-svg-surface.c |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

New commits:
commit 2bfb9e9001bceaedffb2303c062af8e42045931e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jun 20 20:47:18 2013 +0100

    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 at chris-wilson.co.uk>

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,


More information about the cairo-commit mailing list