[librsvg/rustification] Do not inherit gradient stop color and opacity from the gradient's parent object
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustification] Do not inherit gradient stop color and opacity from the gradient's parent object
- Date: Fri, 11 Nov 2016 23:20:09 +0000 (UTC)
commit e28afe422968f8a5bdc57ce29b46b196e0a7ead7
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Nov 11 17:02:37 2016 -0600
Do not inherit gradient stop color and opacity from the gradient's parent object
Per the spec, stop-color and stop-opacity don't inherit from the
parent object of a gradient, unless explicitly requested.
This makes the test pservers-grad-18-b.svg pass.
rsvg-paint-server.c | 35 +++++++++++++++++---
.../reftests/svg1.1/pservers-grad-18-b-ref.png | Bin 5654 -> 4783 bytes
2 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/rsvg-paint-server.c b/rsvg-paint-server.c
index e03040f..fe070c6 100644
--- a/rsvg-paint-server.c
+++ b/rsvg-paint-server.c
@@ -149,10 +149,14 @@ rsvg_paint_server_unref (RsvgPaintServer * ps)
static void
rsvg_stop_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
{
+ gboolean has_stop_color = FALSE;
+ gboolean has_stop_opacity = FALSE;
gboolean is_current_color = FALSE;
const char *value;
RsvgGradientStop *stop;
RsvgState *state;
+ int opacity;
+ guint32 color;
stop = (RsvgGradientStop *) self;
@@ -181,9 +185,16 @@ rsvg_stop_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
if ((value = rsvg_property_bag_lookup (atts, "style")))
rsvg_parse_style (ctx, self->state, value);
- if ((value = rsvg_property_bag_lookup (atts, "stop-color")))
+ if ((value = rsvg_property_bag_lookup (atts, "stop-color"))) {
+ has_stop_color = TRUE;
+
if (!strcmp (value, "currentColor"))
is_current_color = TRUE;
+ }
+
+ if ((value = rsvg_property_bag_lookup (atts, "stop-opacity"))) {
+ has_stop_opacity = TRUE;
+ }
rsvg_parse_style_pairs (ctx, self->state, atts);
}
@@ -192,9 +203,23 @@ rsvg_stop_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
state = rsvg_state_new ();
rsvg_state_reconstruct (state, self);
- if (is_current_color)
- state->stop_color = state->current_color;
- stop->rgba = (state->stop_color << 8) | state->stop_opacity;
+ if (has_stop_color) {
+ if (is_current_color)
+ color = state->current_color;
+ else {
+ color = state->stop_color & 0x00ffffff;
+ }
+ } else {
+ color = 0x0;
+ }
+
+ if (has_stop_opacity) {
+ opacity = state->stop_opacity;
+ } else {
+ opacity = 0xff;
+ }
+
+ stop->rgba = (color << 8) | opacity;
rsvg_state_free (state);
}
@@ -206,7 +231,7 @@ rsvg_new_stop (void)
_rsvg_node_init (&stop->super, RSVG_NODE_TYPE_STOP);
stop->super.set_atts = rsvg_stop_set_atts;
stop->offset = 0;
- stop->rgba = 0;
+ stop->rgba = 0xff000000;
stop->is_valid = FALSE;
return &stop->super;
}
diff --git a/tests/fixtures/reftests/svg1.1/pservers-grad-18-b-ref.png
b/tests/fixtures/reftests/svg1.1/pservers-grad-18-b-ref.png
index b288dc7..704ae63 100644
Binary files a/tests/fixtures/reftests/svg1.1/pservers-grad-18-b-ref.png and
b/tests/fixtures/reftests/svg1.1/pservers-grad-18-b-ref.png differ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]