[librsvg: 87/95] rsvg_filter_primitive_specular_lighting_set_atts(): Parse attributes with the PHF



commit c8ef2289e8537135c707c264b02314136fa7461f
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Feb 21 17:41:41 2018 -0600

    rsvg_filter_primitive_specular_lighting_set_atts(): Parse attributes with the PHF

 rsvg-filter.c | 79 +++++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 52 insertions(+), 27 deletions(-)
---
diff --git a/rsvg-filter.c b/rsvg-filter.c
index 9da891f3..28ef29ed 100644
--- a/rsvg-filter.c
+++ b/rsvg-filter.c
@@ -5236,51 +5236,76 @@ static void
 rsvg_filter_primitive_specular_lighting_set_atts (RsvgNode *node, gpointer impl, RsvgHandle *handle, 
RsvgPropertyBag atts)
 {
     RsvgFilterPrimitiveSpecularLighting *filter = impl;
+    RsvgPropertyBagIter *iter;
+    const char *key;
+    RsvgAttribute attr;
     const char *value;
 
-    if ((value = rsvg_property_bag_lookup (atts, "in")))
-        g_string_assign (filter->super.in, value);
-    if ((value = rsvg_property_bag_lookup (atts, "result")))
-        g_string_assign (filter->super.result, value);
-
     filter_primitive_set_x_y_width_height_atts ((RsvgFilterPrimitive *) filter, atts);
 
-    if ((value = rsvg_property_bag_lookup (atts, "lighting-color"))) {
-        RsvgCssColorSpec spec;
-        RsvgState *state;
+    iter = rsvg_property_bag_iter_begin (atts);
+
+    while (rsvg_property_bag_iter_next (iter, &key, &attr, &value)) {
+        switch (attr) {
+        case RSVG_ATTRIBUTE_IN:
+            g_string_assign (filter->super.in, value);
+            break;
+
+        case RSVG_ATTRIBUTE_RESULT:
+            g_string_assign (filter->super.result, value);
+            break;
+
+        case RSVG_ATTRIBUTE_LIGHTING_COLOR: {
+            RsvgCssColorSpec spec;
+            RsvgState *state;
+
+            spec = rsvg_css_parse_color (value, ALLOW_INHERIT_YES, ALLOW_CURRENT_COLOR_YES);
+
+            switch (spec.kind) {
+            case RSVG_CSS_COLOR_SPEC_INHERIT:
+                /* FIXME: we should inherit; see how stop-color is handled in rsvg-styles.c */
+                break;
+
+            case RSVG_CSS_COLOR_SPEC_CURRENT_COLOR:
+                state = rsvg_state_new ();
+                rsvg_state_reconstruct (state, node);
+                filter->lightingcolor = state->current_color;
+                break;
 
-        spec = rsvg_css_parse_color (value, ALLOW_INHERIT_YES, ALLOW_CURRENT_COLOR_YES);
+            case RSVG_CSS_COLOR_SPEC_ARGB:
+                filter->lightingcolor = spec.argb;
+                break;
+
+            case RSVG_CSS_COLOR_PARSE_ERROR:
+                rsvg_node_set_attribute_parse_error (node, "lighting-color", "Invalid color");
+                goto out;
+
+            default:
+                g_assert_not_reached ();
+            }
 
-        switch (spec.kind) {
-        case RSVG_CSS_COLOR_SPEC_INHERIT:
-            /* FIXME: we should inherit; see how stop-color is handled in rsvg-styles.c */
             break;
+        }
 
-        case RSVG_CSS_COLOR_SPEC_CURRENT_COLOR:
-            state = rsvg_state_new ();
-            rsvg_state_reconstruct (state, node);
-            filter->lightingcolor = state->current_color;
+        case RSVG_ATTRIBUTE_SPECULAR_CONSTANT:
+            filter->specularConstant = g_ascii_strtod (value, NULL);
             break;
 
-        case RSVG_CSS_COLOR_SPEC_ARGB:
-            filter->lightingcolor = spec.argb;
+        case RSVG_ATTRIBUTE_SPECULAR_EXPONENT:
+            filter->specularExponent = g_ascii_strtod (value, NULL);
             break;
 
-        case RSVG_CSS_COLOR_PARSE_ERROR:
-            rsvg_node_set_attribute_parse_error (node, "lighting-color", "Invalid color");
+        case RSVG_ATTRIBUTE_SURFACE_SCALE:
+            filter->surfaceScale = g_ascii_strtod (value, NULL);
             break;
 
         default:
-            g_assert_not_reached ();
+            break;
         }
     }
 
-    if ((value = rsvg_property_bag_lookup (atts, "specularConstant")))
-        filter->specularConstant = g_ascii_strtod (value, NULL);
-    if ((value = rsvg_property_bag_lookup (atts, "specularExponent")))
-        filter->specularExponent = g_ascii_strtod (value, NULL);
-    if ((value = rsvg_property_bag_lookup (atts, "surfaceScale")))
-        filter->surfaceScale = g_ascii_strtod (value, NULL);
+out:
+    rsvg_property_bag_iter_end (iter);
 }
 
 RsvgNode *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]