Commit 9fc56102 authored by Benjamin Otte's avatar Benjamin Otte

state: Resolve filters lazily

We're almost there resolving everything lazily...
parent 1c68e4f2
......@@ -827,17 +827,22 @@ rsvg_cairo_pop_render_stack (RsvgDrawingCtx * ctx)
&& (state->enable_background == RSVG_ENABLE_BACKGROUND_ACCUMULATE))
return;
surface = cairo_get_target (child_cr);
if (state->filter) {
RsvgNode *filter;
cairo_surface_t *output;
output = render->surfaces_stack->data;
render->surfaces_stack = g_list_delete_link (render->surfaces_stack, render->surfaces_stack);
filter = rsvg_acquire_node (ctx, state->filter);
if (filter && RSVG_NODE_TYPE (filter) == RSVG_NODE_TYPE_FILTER) {
output = render->surfaces_stack->data;
render->surfaces_stack = g_list_delete_link (render->surfaces_stack, render->surfaces_stack);
surface = rsvg_filter_render (state->filter, output, ctx, &render->bbox, "2103");
surface = rsvg_filter_render ((RsvgFilter *) filter, output, ctx, &render->bbox, "2103");
/* Don't destroy the output surface, it's owned by child_cr */
}
/* Don't destroy the output surface, it's owned by child_cr */
} else {
surface = cairo_get_target (child_cr);
rsvg_release_node (ctx, filter);
}
render->cr = (cairo_t *) render->cr_stack->data;
......
......@@ -720,33 +720,6 @@ rsvg_filter_get_in (GString * name, RsvgFilterContext * ctx)
return rsvg_filter_get_result (name, ctx).surface;
}
/**
* rsvg_filter_parse:
* @defs: a pointer to the hash of definitions
* @str: a string with the name of the filter to be looked up
*
* Looks up an allready created filter.
*
* Returns: (nullable): a pointer to the filter that the name refers to, or %NULL
* if none was found
**/
RsvgFilter *
rsvg_filter_parse (const RsvgDefs * defs, const char *str)
{
char *name;
name = rsvg_get_url_string (str);
if (name) {
RsvgNode *val;
val = rsvg_defs_lookup (defs, name);
g_free (name);
if (val && RSVG_NODE_TYPE (val) == RSVG_NODE_TYPE_FILTER)
return (RsvgFilter *) val;
}
return NULL;
}
static void
rsvg_filter_set_args (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
{
......
......@@ -54,8 +54,6 @@ cairo_surface_t *rsvg_filter_render (RsvgFilter *self,
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter (void);
G_GNUC_INTERNAL
RsvgFilter *rsvg_filter_parse (const RsvgDefs * defs, const char *str);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_blend (void);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_convolve_matrix (void);
......
......@@ -221,6 +221,7 @@ rsvg_state_clone (RsvgState * dst, const RsvgState * src)
*dst = *src;
dst->parent = parent;
dst->filter = g_strdup (src->filter);
dst->mask = g_strdup (src->mask);
dst->clip_path = g_strdup (src->clip_path);
dst->font_family = g_strdup (src->font_family);
......@@ -361,10 +362,11 @@ rsvg_state_inherit_run (RsvgState * dst, const RsvgState * src,
dst->clip_path = g_strdup (src->clip_path);
g_free (dst->mask);
dst->mask = g_strdup (src->mask);
g_free (dst->filter);
dst->filter = g_strdup (src->filter);
dst->enable_background = src->enable_background;
dst->adobe_blend = src->adobe_blend;
dst->opacity = src->opacity;
dst->filter = src->filter;
dst->comp_op = src->comp_op;
}
}
......@@ -448,6 +450,7 @@ rsvg_state_inherit (RsvgState * dst, const RsvgState * src)
void
rsvg_state_finalize (RsvgState * state)
{
g_free (state->filter);
g_free (state->mask);
g_free (state->clip_path);
g_free (state->font_family);
......@@ -494,9 +497,10 @@ rsvg_parse_style_pair (RsvgHandle * ctx,
else if (g_str_equal (name, "flood-opacity")) {
state->flood_opacity = rsvg_css_parse_opacity (value);
state->has_flood_opacity = TRUE;
} else if (g_str_equal (name, "filter"))
state->filter = rsvg_filter_parse (ctx->priv->defs, value);
else if (g_str_equal (name, "a:adobe-blending-mode")) {
} else if (g_str_equal (name, "filter")) {
g_free (state->filter);
state->filter = rsvg_get_url_string (value);
} else if (g_str_equal (name, "a:adobe-blending-mode")) {
if (g_str_equal (value, "normal"))
state->adobe_blend = 0;
else if (g_str_equal (value, "multiply"))
......
......@@ -79,7 +79,7 @@ struct _RsvgState {
cairo_matrix_t affine;
cairo_matrix_t personal_affine;
RsvgFilter *filter;
char *filter;
char *mask;
char *clip_path;
guint8 adobe_blend; /* 0..11 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment