[librsvg] Make RsvgState.stop_color be an RsvgCssColorSpec; don't have an auxiliary StopColorMode anymore
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Make RsvgState.stop_color be an RsvgCssColorSpec; don't have an auxiliary StopColorMode anymore
- Date: Tue, 23 May 2017 00:59:47 +0000 (UTC)
commit 765512f7d8a456e6874092b86ef3df1219be8cd8
Author: Federico Mena Quintero <federico gnome org>
Date: Mon May 22 19:58:14 2017 -0500
Make RsvgState.stop_color be an RsvgCssColorSpec; don't have an auxiliary StopColorMode anymore
rsvg-paint-server.c | 54 ++++++++++++++++++++++++++++++++++++--------------
rsvg-styles.c | 37 ++++------------------------------
rsvg-styles.h | 5 +--
3 files changed, 46 insertions(+), 50 deletions(-)
---
diff --git a/rsvg-paint-server.c b/rsvg-paint-server.c
index a92f6d1..8570866 100644
--- a/rsvg-paint-server.c
+++ b/rsvg-paint-server.c
@@ -250,25 +250,49 @@ rsvg_stop_set_atts (RsvgNode *node, gpointer impl, RsvgHandle *handle, RsvgPrope
inherited_state = rsvg_state_new ();
rsvg_state_reconstruct (inherited_state, node);
- switch (state->stop_color_mode) {
- case STOP_COLOR_UNSPECIFIED:
- color = 0x0;
- break;
+ if (state->has_stop_color) {
+ switch (state->stop_color.kind) {
+ case RSVG_CSS_COLOR_SPEC_INHERIT:
+ switch (inherited_state->stop_color.kind) {
+ case RSVG_CSS_COLOR_SPEC_INHERIT:
+ color = 0;
+ break;
- case STOP_COLOR_SPECIFIED:
- color = state->stop_color & 0x00ffffff;
- break;
+ case RSVG_CSS_COLOR_SPEC_CURRENT_COLOR:
+ color = inherited_state->current_color;
+ break;
- case STOP_COLOR_INHERIT:
- color = inherited_state->stop_color;
- break;
+ case RSVG_CSS_COLOR_SPEC_ARGB:
+ color = inherited_state->stop_color.argb;
+ break;
- case STOP_COLOR_CURRENT_COLOR:
- color = inherited_state->current_color;
- break;
+ case RSVG_CSS_COLOR_PARSE_ERROR:
+ color = 0;
+ break;
- default:
- g_assert_not_reached ();
+ default:
+ g_assert_not_reached ();
+ return;
+ }
+ break;
+
+ case RSVG_CSS_COLOR_SPEC_CURRENT_COLOR:
+ color = inherited_state->current_color;
+ break;
+
+ case RSVG_CSS_COLOR_SPEC_ARGB:
+ color = state->stop_color.argb & 0x00ffffff;
+ break;
+
+ case RSVG_CSS_COLOR_PARSE_ERROR:
+ color = 0;
+ break;
+
+ default:
+ g_assert_not_reached ();
+ return;
+ }
+ } else {
color = 0;
}
diff --git a/rsvg-styles.c b/rsvg-styles.c
index 00a500d..8aef422 100644
--- a/rsvg-styles.c
+++ b/rsvg-styles.c
@@ -104,8 +104,6 @@ rsvg_state_init (RsvgState * state)
state->miter_limit = 4;
state->cap = CAIRO_LINE_CAP_BUTT;
state->join = CAIRO_LINE_JOIN_MITER;
- state->stop_color = 0x00;
- state->stop_color_mode = STOP_COLOR_UNSPECIFIED;
state->stop_opacity = 0xff;
state->stop_opacity_mode = STOP_OPACITY_UNSPECIFIED;
state->fill_rule = CAIRO_FILL_RULE_WINDING;
@@ -340,8 +338,9 @@ rsvg_state_inherit_run (RsvgState * dst, const RsvgState * src,
if (function (dst->has_join, src->has_join))
dst->join = src->join;
if (function (dst->has_stop_color, src->has_stop_color)) {
- dst->stop_color = src->stop_color;
- dst->stop_color_mode = src->stop_color_mode;
+ if (dst->stop_color.kind == RSVG_CSS_COLOR_SPEC_INHERIT) {
+ dst->stop_color = src->stop_color;
+ }
}
if (function (dst->has_stop_opacity, src->has_stop_opacity)) {
dst->stop_opacity = src->stop_opacity;
@@ -840,34 +839,8 @@ rsvg_parse_style_pair (RsvgState * state,
state->has_letter_spacing = TRUE;
state->letter_spacing = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
} else if (g_str_equal (name, "stop-color")) {
- RsvgCssColorSpec spec;
-
- spec = rsvg_css_parse_color (value, ALLOW_INHERIT_YES, ALLOW_CURRENT_COLOR_YES);
- switch (spec.kind) {
- case RSVG_CSS_COLOR_SPEC_INHERIT:
- state->stop_color_mode = STOP_COLOR_INHERIT;
- state->has_stop_color = FALSE;
- break;
-
- case RSVG_CSS_COLOR_SPEC_CURRENT_COLOR:
- state->stop_color_mode= STOP_COLOR_CURRENT_COLOR;
- state->has_flood_color = TRUE;
- break;
-
- case RSVG_CSS_COLOR_SPEC_ARGB:
- state->stop_color = spec.argb;
- state->stop_color_mode = STOP_COLOR_SPECIFIED;
- state->has_stop_color = TRUE;
- break;
-
- case RSVG_CSS_COLOR_PARSE_ERROR:
- /* FIXME: no error handling */
- state->has_stop_color = FALSE;
- break;
-
- default:
- g_assert_not_reached ();
- }
+ state->has_stop_color = TRUE;
+ state->stop_color = rsvg_css_parse_color (value, ALLOW_INHERIT_YES, ALLOW_CURRENT_COLOR_YES);
} else if (g_str_equal (name, "stop-opacity")) {
state->has_stop_opacity = TRUE;
if (g_str_equal (value, "inherit")) {
diff --git a/rsvg-styles.h b/rsvg-styles.h
index a52e8b5..201d734 100644
--- a/rsvg-styles.h
+++ b/rsvg-styles.h
@@ -29,10 +29,10 @@
#include <cairo.h>
#include "rsvg.h"
+#include "rsvg-css.h"
#include "rsvg-paint-server.h"
#include <libxml/SAX.h>
-#include <pango/pango.h>
G_BEGIN_DECLS
@@ -154,9 +154,8 @@ struct _RsvgState {
guint text_offset;
- guint32 stop_color; /* rgb */
+ RsvgCssColorSpec stop_color; /* rgb */
gboolean has_stop_color;
- StopColor stop_color_mode;
gint stop_opacity; /* 0..255 */
gboolean has_stop_opacity;
StopOpacity stop_opacity_mode;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]