mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-09 04:58:04 +02:00
[SVG] make backend handle new operators gracefully
Previously, the SVG backend would rash when new operators were added to cairo.h, now it returns UNSUPPORTED. Also unsupported operators can now be set as NULL, so image fallbacks can be used properly. Should use fallbacks instead of color-dodge for CAIRO_OPERATOR_STURATE?
This commit is contained in:
parent
fda80cc852
commit
57851464f9
1 changed files with 31 additions and 14 deletions
|
|
@ -766,6 +766,36 @@ _cairo_svg_document_emit_font_subsets (cairo_svg_document_t *document)
|
|||
return status;
|
||||
}
|
||||
|
||||
char const *_cairo_svg_surface_operators[] = {
|
||||
"clear",
|
||||
|
||||
"src", "src-over", "src-in",
|
||||
"src-out", "src-atop",
|
||||
|
||||
"dst", "dst-over", "dst-in",
|
||||
"dst-out", "dst-atop",
|
||||
|
||||
"xor", "plus",
|
||||
"color-dodge", /* FIXME: saturate ? */
|
||||
};
|
||||
|
||||
static cairo_bool_t cairo_svg_force_fallbacks = FALSE;
|
||||
|
||||
static cairo_bool_t
|
||||
_cairo_svg_surface_analyze_operator (cairo_svg_surface_t *surface,
|
||||
cairo_operator_t op)
|
||||
{
|
||||
/* guard against newly added operators */
|
||||
if (op >= ARRAY_LENGTH (_cairo_svg_surface_operators))
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
/* allow operators being NULL if they are unsupported */
|
||||
if (_cairo_svg_surface_operators[op] == NULL)
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_svg_surface_analyze_operation (cairo_svg_surface_t *surface,
|
||||
cairo_operator_t op,
|
||||
|
|
@ -782,7 +812,7 @@ _cairo_svg_surface_analyze_operation (cairo_svg_surface_t *surface,
|
|||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
if (document->svg_version >= CAIRO_SVG_VERSION_1_2)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
return _cairo_svg_surface_analyze_operator (surface, op);
|
||||
|
||||
if (op == CAIRO_OPERATOR_OVER)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
|
@ -965,19 +995,6 @@ _cairo_surface_base64_encode (cairo_surface_t *surface,
|
|||
return status;
|
||||
}
|
||||
|
||||
char const *_cairo_svg_surface_operators[] = {
|
||||
"clear",
|
||||
|
||||
"src", "src-over", "src-in",
|
||||
"src-out", "src-atop",
|
||||
|
||||
"dst", "dst-over", "dst-in",
|
||||
"dst-out", "dst-atop",
|
||||
|
||||
"xor", "plus",
|
||||
"color-dodge", /* FIXME: saturate ? */
|
||||
};
|
||||
|
||||
static void
|
||||
_cairo_svg_surface_emit_operator (cairo_output_stream_t *output,
|
||||
cairo_svg_surface_t *surface,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue