svg_parse: The percentage gradient value divide by view's size
authorJunsuChoi <jsuya.choi@samsung.com>
Wed, 10 Apr 2019 08:39:36 +0000 (17:39 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Wed, 17 Apr 2019 01:03:26 +0000 (10:03 +0900)
Summary:
The default unit of gradient value is percentage.
This can be a value from 0 to 1.
If svg use the '%' symbol, we must divide by 100.
And it must be calculated the same as any other case.

Test Plan: N/A

Reviewers: Hermet, smohanty

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8590

src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c

index 243eb54..c01ecd7 100644 (file)
@@ -144,13 +144,6 @@ _gradient_to_double(Evas_SVG_Parser *svg_parse, const char *str, SVG_Parser_Leng
    double parsed_value = strtod(str, &end);
    double max = 1;
 
-   /* unique case, if that is percentage, just return it */
-   if (strstr(str, "%"))
-     {
-        parsed_value = parsed_value / 100.0;
-        return parsed_value;
-     }
-
    /**
     * That is according to Units in here
     *
@@ -164,7 +157,9 @@ _gradient_to_double(Evas_SVG_Parser *svg_parse, const char *str, SVG_Parser_Leng
      max = sqrt(pow(svg_parse->global.height, 2) +
                 pow(svg_parse->global.width, 2)) / sqrt(2.0);
 
-   if (strstr(str, "cm"))
+   if (strstr(str, "%"))
+     parsed_value = parsed_value / 100.0;
+   else if (strstr(str, "cm"))
      parsed_value = parsed_value * 35.43307;
    else if (strstr(str, "mm"))
      parsed_value = parsed_value * 3.543307;