diff options
author | JunsuChoi <jsuya.choi@samsung.com> | 2022-01-12 11:34:29 +0900 |
---|---|---|
committer | Hermet Park <chuneon.park@samsung.com> | 2022-01-12 11:34:29 +0900 |
commit | ef784708b9278b8ef7131b2ee751e8c737fd3fa3 (patch) | |
tree | 2ac2725ec5d93971ab109b4e68b182c4fef5a55c /src/static_libs | |
parent | 92f77c512305dde21e25ca92baab138cfc498054 (diff) | |
download | efl-ef784708b9278b8ef7131b2ee751e8c737fd3fa3.tar.gz |
evas_vg_load_svg: Fix colorstop offset parser
Summary:
Values different from numbers and percentages should be ignored
and the default values should be applied (zeros).
And set the min and max of the offset value to be 0, 1.
Also, this patch make that the offset is not input in the reverse order.
Test Plan:
Test SVG Image
```
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
<linearGradient id="grad" x1="0" y1="0" x2="1" y2="1">
<stop offset="10%" stop-color="white"/>
<stop offset="0.2" stop-color="red"/>
<stop offset="30% k" stop-color="blue"/>
<stop offset="40%" stop-color="yellow"/>
<stop offset="0.5m" stop-color="red"/>
<stop offset="0.6 " stop-color="green"/>
<stop offset="70%m" stop-color="black"/>
<stop offset="80%" stop-color="white"/>
</linearGradient>
<rect x="20" y="20" width="160" height="160" fill="url(#grad)"/>
</svg>
```
Result
{F4792365}
Reviewers: Hermet, raster, kimcinoo
Reviewed By: Hermet
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12318
Diffstat (limited to 'src/static_libs')
-rw-r--r-- | src/static_libs/vg_common/vg_common_svg.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/static_libs/vg_common/vg_common_svg.c b/src/static_libs/vg_common/vg_common_svg.c index 30fc0c0eb5..d75486ed58 100644 --- a/src/static_libs/vg_common/vg_common_svg.c +++ b/src/static_libs/vg_common/vg_common_svg.c @@ -696,6 +696,7 @@ _apply_gradient_property(Svg_Style_Gradient *g, Efl_VG *vg, Efl_VG *parent, Vg_F double fopacity = ((double) fill_opacity) / 255; //fill opacity if any exists. stops = calloc(stop_count, sizeof(Efl_Gfx_Gradient_Stop)); i = 0; + double prevOffset = 0; EINA_LIST_FOREACH(g->stops, l, stop) { // Use premultiplied color @@ -705,6 +706,16 @@ _apply_gradient_property(Svg_Style_Gradient *g, Efl_VG *vg, Efl_VG *parent, Vg_F stops[i].b = (stop->b * opacity); stops[i].a = (stop->a * fopacity); stops[i].offset = stop->offset; + //NOTE: check the offset corner cases - refer to: https://svgwg.org/svg2-draft/pservers.html#StopNotes + if (stop->offset < prevOffset) + { + stops[i].offset = prevOffset; + } + else if (stop->offset > 1) + { + stops[i].offset = 1; + } + prevOffset = stops[i].offset; i++; } efl_gfx_gradient_stop_set(grad_obj, stops, stop_count); |