summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitalii Vorobiov <vi.vorobiov@samsung.com>2017-02-07 18:59:03 +0200
committerJean-Philippe Andre <jp.andre@samsung.com>2017-11-07 11:54:09 +0900
commit532557cabdd6fd24e62c7756c927230f24ab6b89 (patch)
treeb4aad5c95cee1a23eb589fb1af10c4cb8ec565c0
parenta44daaa3946d1e55435b111065e0b121848a71ce (diff)
vg_loaders/svg: set up default focal values for radialGradient
Since when not specified, focal values same as center points fx = cx, fy = cy by default @fix
-rw-r--r--src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c31
1 files changed, 31 insertions, 0 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 7c19d75a47..4b4913b695 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
@@ -1560,28 +1560,52 @@ _parse_spread_value(const char *value)
1560 return spread; 1560 return spread;
1561} 1561}
1562 1562
1563
1564/**
1565 * Comment SVG_GRADIENT_FX_FY_PARSED
1566 *
1567 * if "fx" and "fy" is not specified then they are fx==cx and fy==cx
1568 * but we should also be careful when during the parsing it would be
1569 * something like <radialGradient fx="0" cx="100" cy="100">
1570 * so then fx is 0, but fy is 100
1571 *
1572 * So we need to check if focal was parsed, if not then set up same as center
1573 * point.
1574 *
1575 * It is required to set those public variables back to zero when parsing new
1576 * gradient.
1577 */
1578static Eina_Bool fx_parsed;
1579static Eina_Bool fy_parsed;
1580
1563static void 1581static void
1564_handle_radial_cx_attr(Svg_Radial_Gradient* radial, const char *value) 1582_handle_radial_cx_attr(Svg_Radial_Gradient* radial, const char *value)
1565{ 1583{
1566 radial->cx = _to_double(value); 1584 radial->cx = _to_double(value);
1585 if (!fx_parsed)
1586 radial->fx = radial->cx;
1567} 1587}
1568 1588
1569static void 1589static void
1570_handle_radial_cy_attr(Svg_Radial_Gradient* radial, const char *value) 1590_handle_radial_cy_attr(Svg_Radial_Gradient* radial, const char *value)
1571{ 1591{
1572 radial->cy = _to_double(value); 1592 radial->cy = _to_double(value);
1593 if (!fy_parsed)
1594 radial->fy = radial->cy;
1573} 1595}
1574 1596
1575static void 1597static void
1576_handle_radial_fx_attr(Svg_Radial_Gradient* radial, const char *value) 1598_handle_radial_fx_attr(Svg_Radial_Gradient* radial, const char *value)
1577{ 1599{
1578 radial->fx = _to_double(value); 1600 radial->fx = _to_double(value);
1601 fx_parsed = EINA_TRUE;
1579} 1602}
1580 1603
1581static void 1604static void
1582_handle_radial_fy_attr(Svg_Radial_Gradient* radial, const char *value) 1605_handle_radial_fy_attr(Svg_Radial_Gradient* radial, const char *value)
1583{ 1606{
1584 radial->fy = _to_double(value); 1607 radial->fy = _to_double(value);
1608 fy_parsed = EINA_TRUE;
1585} 1609}
1586 1610
1587static void 1611static void
@@ -1646,8 +1670,15 @@ _create_radialGradient(const char *buf, unsigned buflen)
1646 1670
1647 grad->type = SVG_RADIAL_GRADIENT; 1671 grad->type = SVG_RADIAL_GRADIENT;
1648 grad->radial = calloc(1, sizeof(Svg_Radial_Gradient)); 1672 grad->radial = calloc(1, sizeof(Svg_Radial_Gradient));
1673
1674 /**
1675 * Please see SVG_GRADIENT_FX_FY_PARSED comment for more info
1676 */
1677 fx_parsed = EINA_FALSE;
1678 fy_parsed = EINA_FALSE;
1649 eina_simple_xml_attributes_parse(buf, buflen, 1679 eina_simple_xml_attributes_parse(buf, buflen,
1650 _attr_parse_radial_gradient_node, grad); 1680 _attr_parse_radial_gradient_node, grad);
1681
1651 return grad; 1682 return grad;
1652 1683
1653} 1684}