summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@gnome.org>2017-05-30 16:32:01 -0500
committerFederico Mena Quintero <federico@gnome.org>2017-05-30 16:32:01 -0500
commitd644712c05ee2320403ca7cf6e726438355b602e (patch)
tree6a611dcb9bdb96c3d3b7a78f95dbfb6046d4268d
parent37479d8adfee8675a0c308af6bf54260418b21b2 (diff)
downloadlibrsvg-d644712c05ee2320403ca7cf6e726438355b602e.tar.gz
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.
-rw-r--r--rsvg-paint-server.c8
-rw-r--r--rsvg-styles.c11
-rw-r--r--rsvg-styles.h15
3 files changed, 19 insertions, 15 deletions
diff --git a/rsvg-paint-server.c b/rsvg-paint-server.c
index 3609c770..c8c9e199 100644
--- a/rsvg-paint-server.c
+++ b/rsvg-paint-server.c
@@ -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:
diff --git a/rsvg-styles.c b/rsvg-styles.c
index dfe4b0d6..43cfa1e3 100644
--- a/rsvg-styles.c
+++ b/rsvg-styles.c
@@ -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);
diff --git a/rsvg-styles.h b/rsvg-styles.h
index 320d3834..3b62fa34 100644
--- a/rsvg-styles.h
+++ b/rsvg-styles.h
@@ -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;