mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-27 14:50:27 +01:00
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>
This commit is contained in:
parent
b7331f0c52
commit
2bfb9e9001
1 changed files with 14 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue