StopOpacity: Turn into a struct; put both the "kind" enum and the actual opacity value here

This makes the stop-opacity property be similar to the stop-color one.
parent 37479d8a
......@@ -297,15 +297,15 @@ rsvg_stop_set_atts (RsvgNode *node, gpointer impl, RsvgHandle *handle, RsvgPrope
}
if (state->has_stop_opacity) {
switch (state->stop_opacity_mode) {
switch (state->stop_opacity.kind) {
case STOP_OPACITY_SPECIFIED:
opacity = state->stop_opacity;
opacity = state->stop_opacity.opacity;
break;
case STOP_OPACITY_INHERIT:
switch (inherited_state->stop_opacity_mode) {
switch (inherited_state->stop_opacity.kind) {
case STOP_OPACITY_SPECIFIED:
opacity = inherited_state->stop_opacity;
opacity = inherited_state->stop_opacity.opacity;
break;
case STOP_OPACITY_INHERIT:
......
......@@ -113,7 +113,7 @@ rsvg_state_init (RsvgState * state)
*
*/
state->stop_color.kind = RSVG_CSS_COLOR_SPEC_INHERIT;
state->stop_opacity_mode = STOP_OPACITY_INHERIT;
state->stop_opacity.kind = STOP_OPACITY_INHERIT;
state->fill_rule = CAIRO_FILL_RULE_WINDING;
state->clip_rule = CAIRO_FILL_RULE_WINDING;
......@@ -352,9 +352,8 @@ rsvg_state_inherit_run (RsvgState * dst, const RsvgState * src,
}
}
if (function (dst->has_stop_opacity, src->has_stop_opacity)) {
if (dst->stop_opacity_mode == STOP_OPACITY_INHERIT) {
if (dst->stop_opacity.kind == 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))
......@@ -855,10 +854,10 @@ 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->stop_opacity_mode = STOP_OPACITY_INHERIT;
state->stop_opacity.kind = STOP_OPACITY_INHERIT;
} else {
state->stop_opacity = rsvg_css_parse_opacity (value);
state->stop_opacity_mode = STOP_OPACITY_SPECIFIED;
state->stop_opacity.kind = STOP_OPACITY_SPECIFIED;
state->stop_opacity.opacity = rsvg_css_parse_opacity (value);
}
} else if (g_str_equal (name, "marker-start")) {
g_free (state->startMarker);
......
......@@ -73,8 +73,13 @@ struct _RsvgVpathDash {
};
typedef enum {
STOP_OPACITY_SPECIFIED,
STOP_OPACITY_INHERIT
STOP_OPACITY_INHERIT,
STOP_OPACITY_SPECIFIED
} StopOpacityKind;
typedef struct {
StopOpacityKind kind;
guint8 opacity; /* 0..255; only valid if kind == STOP_OPACITY_SPECIFIED */
} StopOpacity;
/* end libart theft... */
......@@ -146,11 +151,11 @@ struct _RsvgState {
guint text_offset;
RsvgCssColorSpec stop_color; /* rgb */
RsvgCssColorSpec stop_color;
gboolean has_stop_color;
gint stop_opacity; /* 0..255 */
StopOpacity stop_opacity;
gboolean has_stop_opacity;
StopOpacity stop_opacity_mode;
gboolean visible;
gboolean has_visible;
......
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