Remove redundant STOP_OPACITY_UNSPECIFIED

We use state->has_stop_opacity for that.

I am really not liking the way rsvg_state_inherit_run() has the logic
for whether a particular attribute is inherited or not.  This should be
at the "stop" element level --- the attributes *are* cascaded as
expected for other elements.
parent 863408e5
......@@ -296,22 +296,34 @@ rsvg_stop_set_atts (RsvgNode *node, gpointer impl, RsvgHandle *handle, RsvgPrope
color = 0;
}
switch (state->stop_opacity_mode) {
case STOP_OPACITY_UNSPECIFIED:
opacity = 0xff;
break;
if (state->has_stop_opacity) {
switch (state->stop_opacity_mode) {
case STOP_OPACITY_SPECIFIED:
opacity = state->stop_opacity;
break;
case STOP_OPACITY_INHERIT:
switch (inherited_state->stop_opacity_mode) {
case STOP_OPACITY_SPECIFIED:
opacity = inherited_state->stop_opacity;
break;
case STOP_OPACITY_SPECIFIED:
opacity = state->stop_opacity;
break;
case STOP_OPACITY_INHERIT:
opacity = 0xff;
break;
case STOP_OPACITY_INHERIT:
opacity = inherited_state->stop_opacity;
break;
default:
g_assert_not_reached ();
return;
}
break;
default:
g_assert_not_reached ();
opacity = 0;
default:
g_assert_not_reached ();
return;
}
} else {
opacity = 0xff;
}
stop->rgba = (color << 8) | opacity;
......
......@@ -104,8 +104,17 @@ rsvg_state_init (RsvgState * state)
state->miter_limit = 4;
state->cap = CAIRO_LINE_CAP_BUTT;
state->join = CAIRO_LINE_JOIN_MITER;
state->stop_opacity = 0xff;
state->stop_opacity_mode = STOP_OPACITY_UNSPECIFIED;
/* The following two start as INHERIT, even though has_stop_color and
* has_stop_opacity get initialized to FALSE below. This is so that the
* first pass of rsvg_state_inherit_run(), called from
* rsvg_state_reconstruct() from the "stop" element code, will correctly
* initialize the destination state from the toplevel element.
*
*/
state->stop_color.kind = RSVG_CSS_COLOR_SPEC_INHERIT;
state->stop_opacity_mode = STOP_OPACITY_INHERIT;
state->fill_rule = CAIRO_FILL_RULE_WINDING;
state->clip_rule = CAIRO_FILL_RULE_WINDING;
state->enable_background = RSVG_ENABLE_BACKGROUND_ACCUMULATE;
......@@ -343,8 +352,10 @@ rsvg_state_inherit_run (RsvgState * dst, const RsvgState * src,
}
}
if (function (dst->has_stop_opacity, src->has_stop_opacity)) {
dst->stop_opacity = src->stop_opacity;
dst->stop_opacity_mode = src->stop_opacity_mode;
if (dst->stop_opacity_mode == STOP_OPACITY_INHERIT) {
dst->stop_opacity = src->stop_opacity;
dst->stop_opacity_mode = src->stop_opacity_mode;
}
}
if (function (dst->has_cond, src->has_cond))
dst->cond_true = src->cond_true;
......@@ -844,7 +855,6 @@ rsvg_parse_style_pair (RsvgState * state,
} else if (g_str_equal (name, "stop-opacity")) {
state->has_stop_opacity = TRUE;
if (g_str_equal (value, "inherit")) {
state->has_stop_opacity = FALSE;
state->stop_opacity_mode = STOP_OPACITY_INHERIT;
} else {
state->stop_opacity = rsvg_css_parse_opacity (value);
......
......@@ -73,7 +73,6 @@ struct _RsvgVpathDash {
};
typedef enum {
STOP_OPACITY_UNSPECIFIED,
STOP_OPACITY_SPECIFIED,
STOP_OPACITY_INHERIT
} StopOpacity;
......
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