Commit d1c91919 authored by Benjamin Otte's avatar Benjamin Otte

state: Store mask as reference

Instead of immediately looking up the mask, store the reference and look
it up on use.
parent a6466fa5
......@@ -834,7 +834,11 @@ rsvg_cairo_pop_render_stack (RsvgDrawingCtx * ctx)
cairo_set_operator (render->cr, state->comp_op);
if (state->mask) {
rsvg_cairo_generate_mask (render->cr, state->mask, ctx, &render->bbox);
RsvgNode *mask;
mask = rsvg_defs_lookup (ctx->defs, state->mask);
if (mask && RSVG_NODE_TYPE (mask) == RSVG_NODE_TYPE_MASK)
rsvg_cairo_generate_mask (render->cr, (RsvgMask *) mask, ctx, &render->bbox);
} else if (state->opacity != 0xFF)
cairo_paint_with_alpha (render->cr, (double) state->opacity / 255.0);
else
......
......@@ -102,23 +102,6 @@ rsvg_get_url_string (const char *str)
return NULL;
}
RsvgNode *
rsvg_mask_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_MASK)
return val;
}
return NULL;
}
RsvgNode *
rsvg_clip_path_parse (const RsvgDefs * defs, const char *str)
{
......
......@@ -48,8 +48,6 @@ struct _RsvgMask {
G_GNUC_INTERNAL
RsvgNode *rsvg_new_mask (void);
G_GNUC_INTERNAL
RsvgNode *rsvg_mask_parse (const RsvgDefs * defs, const char *str);
typedef struct _RsvgClipPath RsvgClipPath;
......
......@@ -221,6 +221,7 @@ rsvg_state_clone (RsvgState * dst, const RsvgState * src)
*dst = *src;
dst->parent = parent;
dst->mask = g_strdup (src->mask);
dst->font_family = g_strdup (src->font_family);
dst->lang = g_strdup (src->lang);
rsvg_paint_server_ref (dst->fill);
......@@ -356,7 +357,8 @@ rsvg_state_inherit_run (RsvgState * dst, const RsvgState * src,
if (inherituninheritables) {
dst->clip_path_ref = src->clip_path_ref;
dst->mask = src->mask;
g_free (dst->mask);
dst->mask = g_strdup (src->mask);
dst->enable_background = src->enable_background;
dst->adobe_blend = src->adobe_blend;
dst->opacity = src->opacity;
......@@ -444,6 +446,7 @@ rsvg_state_inherit (RsvgState * dst, const RsvgState * src)
void
rsvg_state_finalize (RsvgState * state)
{
g_free (state->mask);
g_free (state->font_family);
g_free (state->lang);
rsvg_paint_server_unref (state->fill);
......@@ -517,9 +520,10 @@ rsvg_parse_style_pair (RsvgHandle * ctx,
state->adobe_blend = 11;
else
state->adobe_blend = 0;
} else if (g_str_equal (name, "mask"))
state->mask = rsvg_mask_parse (ctx->priv->defs, value);
else if (g_str_equal (name, "clip-path")) {
} else if (g_str_equal (name, "mask")) {
g_free (state->mask);
state->mask = rsvg_get_url_string (value);
} else if (g_str_equal (name, "clip-path")) {
state->clip_path_ref = rsvg_clip_path_parse (ctx->priv->defs, value);
} else if (g_str_equal (name, "overflow")) {
if (!g_str_equal (value, "inherit")) {
......
......@@ -80,7 +80,7 @@ struct _RsvgState {
cairo_matrix_t personal_affine;
RsvgFilter *filter;
void *mask;
char *mask;
void *clip_path_ref;
guint8 adobe_blend; /* 0..11 */
guint8 opacity; /* 0..255 */
......
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