summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorJunsuChoi <jsuya.choi@samsung.com>2019-07-15 21:22:03 +0900
committerHermet Park <hermetpark@gmail.com>2019-07-15 21:22:49 +0900
commit84fcc5d073c7be9ff4152745fcbc63383cb95dc3 (patch)
treee6e6271bd2d792371727ea7661dd67e01c766757 /src/modules
parent01d6683e3293c945840644ff9d5ebd44f286044f (diff)
evas_vg_load_svg: Prevent duplicate operations on radial gradient variables
Summary: This solves the problem of radial gradient being displayed abnormally when the radial gradient variables are 0 to 1. Test Plan: Sample SVG <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"> <defs id="defs11"> <linearGradient id="linearGradient1" x1="0" y1="0" x2="0.2" y2="0.2" spreadMethod="reflect"> <stop style="stop-color:#ff0000;stop-opacity:1;" offset="0"/> <stop style="stop-color:#0000ff;stop-opacity:1;" offset="1"/> </linearGradient> <radialGradient id="radialGradient222" r="0.2" cx="0.3" cy="0.3" spreadMethod="reflect"> <stop style="stop-color:#ffFF00;stop-opacity:1;" offset="0"/> <stop style="stop-color:#00FFff;stop-opacity:1;" offset="1"/> </radialGradient> </defs> <rect x="0" y="0" width="100" height="100" fill="url(#linearGradient1)"/> <rect x="50" y="50" width="50" height="50" fill="url(#radialGradient222)"/> </svg> Reviewers: Hermet, kimcinoo, smohanty Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9312
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c b/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
index 32bfb17d76..5bfdf41728 100644
--- a/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
+++ b/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
@@ -1758,15 +1758,63 @@ _handle_radial_r_attr(Evas_SVG_Loader *loader, Svg_Radial_Gradient* radial, cons
1758 radial->r = _gradient_to_double(loader->svg_parse, value, SVG_PARSER_LENGTH_OTHER); 1758 radial->r = _gradient_to_double(loader->svg_parse, value, SVG_PARSER_LENGTH_OTHER);
1759} 1759}
1760 1760
1761static void
1762_recalc_radial_cx_attr(Evas_SVG_Loader *loader, Svg_Radial_Gradient* radial, Eina_Bool user_space)
1763{
1764 if (!user_space)
1765 {
1766 radial->cx = radial->cx * loader->svg_parse->global.width;
1767 }
1768}
1769
1770static void
1771_recalc_radial_cy_attr(Evas_SVG_Loader *loader, Svg_Radial_Gradient* radial, Eina_Bool user_space)
1772{
1773 if (!user_space)
1774 {
1775 radial->cy = radial->cy * loader->svg_parse->global.height;
1776 }
1777}
1778
1779static void
1780_recalc_radial_fx_attr(Evas_SVG_Loader *loader, Svg_Radial_Gradient* radial, Eina_Bool user_space)
1781{
1782 if (!user_space)
1783 {
1784 radial->fx = radial->fx * loader->svg_parse->global.width;
1785 }
1786}
1787
1788static void
1789_recalc_radial_fy_attr(Evas_SVG_Loader *loader, Svg_Radial_Gradient* radial, Eina_Bool user_space)
1790{
1791 if (!user_space)
1792 {
1793 radial->fy = radial->fy * loader->svg_parse->global.height;
1794 }
1795}
1796
1797static void
1798_recalc_radial_r_attr(Evas_SVG_Loader *loader, Svg_Radial_Gradient* radial, Eina_Bool user_space)
1799{
1800 if (!user_space)
1801 {
1802 radial->r = radial->r * (sqrt(pow(loader->svg_parse->global.height, 2) + pow(loader->svg_parse->global.width, 2)) / sqrt(2.0));
1803 }
1804}
1805
1806
1761typedef void (*Radial_Method)(Evas_SVG_Loader *loader, Svg_Radial_Gradient *radial, const char *value); 1807typedef void (*Radial_Method)(Evas_SVG_Loader *loader, Svg_Radial_Gradient *radial, const char *value);
1808typedef void (*Radial_Method_Recalc)(Evas_SVG_Loader *loader, Svg_Radial_Gradient *radial, Eina_Bool user_space);
1762 1809
1763#define RADIAL_DEF(Name) \ 1810#define RADIAL_DEF(Name) \
1764 { #Name, sizeof (#Name), _handle_radial_##Name##_attr} 1811 { #Name, sizeof (#Name), _handle_radial_##Name##_attr, _recalc_radial_##Name##_attr}
1765 1812
1766static const struct { 1813static const struct {
1767 const char *tag; 1814 const char *tag;
1768 int sz; 1815 int sz;
1769 Radial_Method tag_handler;; 1816 Radial_Method tag_handler;;
1817 Radial_Method_Recalc tag_recalc;
1770} radial_tags[] = { 1818} radial_tags[] = {
1771 RADIAL_DEF(cx), 1819 RADIAL_DEF(cx),
1772 RADIAL_DEF(cy), 1820 RADIAL_DEF(cy),
@@ -1814,6 +1862,7 @@ _attr_parse_radial_gradient_node(void *data, const char *key, const char *value)
1814static Svg_Style_Gradient * 1862static Svg_Style_Gradient *
1815_create_radialGradient(Evas_SVG_Loader *loader, const char *buf, unsigned buflen) 1863_create_radialGradient(Evas_SVG_Loader *loader, const char *buf, unsigned buflen)
1816{ 1864{
1865 unsigned int i = 0;
1817 Svg_Style_Gradient *grad = calloc(1, sizeof(Svg_Style_Gradient)); 1866 Svg_Style_Gradient *grad = calloc(1, sizeof(Svg_Style_Gradient));
1818 loader->svg_parse->style_grad = grad; 1867 loader->svg_parse->style_grad = grad;
1819 1868
@@ -1834,6 +1883,11 @@ _create_radialGradient(Evas_SVG_Loader *loader, const char *buf, unsigned buflen
1834 eina_simple_xml_attributes_parse(buf, buflen, 1883 eina_simple_xml_attributes_parse(buf, buflen,
1835 _attr_parse_radial_gradient_node, loader); 1884 _attr_parse_radial_gradient_node, loader);
1836 1885
1886 for (i = 0; i < sizeof (radial_tags) / sizeof(radial_tags[0]); i++)
1887 radial_tags[i].tag_recalc(loader, grad->radial, grad->user_space);
1888
1889 grad->use_percentage = EINA_TRUE;
1890
1837 return loader->svg_parse->style_grad; 1891 return loader->svg_parse->style_grad;
1838} 1892}
1839 1893