[cairo-commit] src/cairo-svg-surface.c
Emmanuel Pacaud
emmanuel at kemper.freedesktop.org
Wed Feb 20 14:48:51 PST 2008
src/cairo-svg-surface.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
New commits:
commit 70b683363f6e37d8952c8f857dd687022a02ada5
Author: Emmanuel Pacaud <emmanuel.pacaud at free.fr>
Date: Wed Feb 20 23:46:27 2008 +0100
[SVG] Fix a8-mask test failure.
For A8 and A1 masks, the embedded mask image doesn't have an alpha channel.
In this case, the feColorMatrix should not be used, since it's goal is to
discard the color channels and to only keep the alpha one (which is what
we want when we have an ARGB32 mask image, since SVG uses all the channels
for the mask operation, where cairo only use the alpha channel).
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index fdd1c67..92aa5e9 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -2008,13 +2008,22 @@ _cairo_svg_surface_mask (void *abstract_surface,
cairo_svg_document_t *document = surface->document;
cairo_output_stream_t *mask_stream;
char buffer[64];
+ cairo_bool_t discard_filter = FALSE;
if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
return _cairo_svg_surface_analyze_operation (surface, op, source);
assert (_cairo_svg_surface_operation_supported (surface, op, source));
- _cairo_svg_surface_emit_alpha_filter (document);
+ if (cairo_pattern_get_type (mask) == CAIRO_PATTERN_TYPE_SURFACE) {
+ cairo_surface_pattern_t *surface_pattern = (cairo_surface_pattern_t*) mask;
+ cairo_content_t content = cairo_surface_get_content (surface_pattern->surface);
+ if (content == CAIRO_CONTENT_ALPHA)
+ discard_filter = TRUE;
+ }
+
+ if (!discard_filter)
+ _cairo_svg_surface_emit_alpha_filter (document);
/* _cairo_svg_surface_emit_paint() will output a pattern definition to
* document->xml_node_defs so we need to write the mask element to
@@ -2025,8 +2034,9 @@ _cairo_svg_surface_mask (void *abstract_surface,
_cairo_output_stream_printf (mask_stream,
"<mask id=\"mask%d\">\n"
- " <g filter=\"url(#alpha)\">\n",
- document->mask_id);
+ "%s",
+ document->mask_id,
+ discard_filter ? "" : " <g filter=\"url(#alpha)\">\n");
status = _cairo_svg_surface_emit_paint (mask_stream, surface, op, mask, NULL);
if (status) {
cairo_status_t ignore = _cairo_output_stream_destroy (mask_stream);
@@ -2035,8 +2045,9 @@ _cairo_svg_surface_mask (void *abstract_surface,
}
_cairo_output_stream_printf (mask_stream,
- " </g>\n"
- "</mask>\n");
+ "%s"
+ "</mask>\n",
+ discard_filter ? "" : " </g>\n");
_cairo_memory_stream_copy (mask_stream, document->xml_node_defs);
status = _cairo_output_stream_destroy (mask_stream);
More information about the cairo-commit
mailing list