]> gitweb.michael.orlitzky.com - libsvgtiny.git/blobdiff - src/svgtiny_gradient.c
Update README to cover dependancies and core buildsystem
[libsvgtiny.git] / src / svgtiny_gradient.c
index 5361532e593b12f07ab461b8690cdb4d6eeb00b2..f5984ea313eeb5e4958653b2d3921a120a64a245 100644 (file)
@@ -31,7 +31,7 @@ static void svgtiny_invert_matrix(float *m, float *inv);
 void svgtiny_find_gradient(const char *id, struct svgtiny_parse_state *state)
 {
        dom_element *gradient;
-       dom_string *id_str;
+       dom_string *id_str, *name;
        dom_exception exc;
 
        #ifdef GRADIENT_DEBUG
@@ -59,35 +59,37 @@ void svgtiny_find_gradient(const char *id, struct svgtiny_parse_state *state)
        state->gradient_transform.e = 0;
        state->gradient_transform.f = 0;
        
-       exc = dom_string_create_interned((const uint8_t *) id, strlen(id),
-                                        &id_str);
+       exc = dom_string_create_interned((const uint8_t *) id,
+                       strlen(id), &id_str);
        if (exc != DOM_NO_ERR)
                return;
        
        exc = dom_document_get_element_by_id(state->document, id_str,
                                             &gradient);
        dom_string_unref(id_str);
-       if (exc != DOM_NO_ERR)
-               return;
-
-       if (gradient == NULL) {
+       if (exc != DOM_NO_ERR || gradient == NULL) {
                #ifdef GRADIENT_DEBUG
                fprintf(stderr, "gradient \"%s\" not found\n", id);
                #endif
                return;
        }
        
-       exc = dom_node_get_node_name(gradient, &id_str);
+       exc = dom_node_get_node_name(gradient, &name);
        if (exc != DOM_NO_ERR) {
                dom_node_unref(gradient);
                return;
        }
        
-       if (dom_string_isequal(id_str, state->interned_linearGradient))
+       if (dom_string_isequal(name, state->interned_linearGradient))
                svgtiny_parse_linear_gradient(gradient, state);
        
-       dom_string_unref(id_str);
        dom_node_unref(gradient);
+       dom_string_unref(name);
+
+       #ifdef GRADIENT_DEBUG
+       fprintf(stderr, "linear_gradient_stop_count %i\n",
+                       state->linear_gradient_stop_count);
+       #endif
 }
 
 
@@ -656,7 +658,7 @@ svgtiny_code svgtiny_add_path_linear_gradient(float *p, unsigned int n,
 
        /* render triangle vertices with r values for debugging */
        #ifdef GRADIENT_DEBUG
-       for (unsigned int i = 0; i != pts->size; i++) {
+       for (unsigned int i = 0; i != svgtiny_list_size(pts); i++) {
                struct grad_point *point = svgtiny_list_get(pts, i);
                struct svgtiny_shape *shape = svgtiny_add_shape(state);
                if (!shape)