Commit Graph

30 Commits

Author SHA1 Message Date
junsu choi ef784708b9 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
2022-01-12 11:34:29 +09:00
junsu choi 3274390f73 vg_load_svg: Implement ClipPath feature
Summary:
Supports case of using style attribute for defined <clipPath> and node.
In SVG, <clipPath> can be used as a "clipPath" attribute or a style "clip-path".
If there is a clip-path node, save it as a composition node and
use composition method(matte_alpha) to compose it.

Below node types support clip-path.
<circle>
<ellipse>
<g>
<path>
<polygon>
<polyline>
<rect>

Test Plan:
Please see attached svg files
{F4026162}

Reviewers: Hermet, smohanty

Reviewed By: Hermet

Subscribers: #reviewers, #committers, cedric, herb, kimcinoo

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D12179
2020-10-14 19:16:53 +09:00
junsu choi 35f17a13fa vg_load_svg: Support dasharray attribute for stroke
Summary:
It supports stroke-dasharray, one of the stroke properties of svg.
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray

Test Plan:
[Test SVG]
<svg viewBox="0 0 30 10" xmlns="http://www.w3.org/2000/svg">
  <!-- No dashes nor gaps -->
  <line x1="0" y1="1" x2="30" y2="1" stroke="black" />

  <!-- Dashes and gaps of the same size -->
  <line x1="0" y1="3" x2="30" y2="3" stroke="black"
          stroke-dasharray="4" />

  <!-- Dashes and gaps of different sizes -->
  <line x1="0" y1="5" x2="30" y2="5" stroke="black"
          stroke-dasharray="4 1" />

  <!-- Dashes and gaps of various sizes with an odd number of values -->
  <line x1="0" y1="7" x2="30" y2="7" stroke="black"
          stroke-dasharray="4 1 2" />

  <!-- Dashes and gaps of various sizes with an even number of values -->
  <line x1="0" y1="9" x2="30" y2="9" stroke="black"
          stroke-dasharray="4 1 2 3" />
</svg>

Reviewers: Hermet, smohanty

Reviewed By: Hermet

Subscribers: kimcinoo, herb, cedric, #committers, #reviewers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D12146
2020-09-15 12:11:49 +09:00
Hermet Park 9d1423f203 canvas svg: fix missing break. 2020-06-02 13:18:17 +09:00
Subhransu Mohanty 161e411d18 svg/loader: Fix memory leak
Reviewers: Hermet

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11908
2020-06-01 18:53:36 +09:00
Hermet Park 989570b133 canvas svg: fix memory leak.
free svg node commands & points data after usage.

@fix
2020-04-17 18:16:03 +09:00
Hermet Park 29892a26f8 vector svg: apply fill-opacity to graidents fill objects.
If node has a fill-opacity attirbute it must propagtes it to
its fill objects.

Previous our implementation missed this behavior.

@fix
2019-11-19 13:26:43 +09:00
junsu choi 74e2c80b6e vg_common_svg: Support opacity attribute of <g> element
Summary:
The <g> element can have an opacity.
Therefore, if node type is SVG_NODE_G, set color.

Test Plan: N/A

Reviewers: Hermet, smohanty, kimcinoo

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10371
2019-10-15 14:53:25 +09:00
junsu choi 405822a314 vg_common_svg : Initialize "display" attribute
Summary:
In e850e3e, the code to initialize this property is missing.
That makes the object invisible when printing svg through edje.
This is a patch to fix it.
@fix

Test Plan: N/A

Reviewers: Hermet, smohanty, kimcinoo

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9833
2019-09-04 12:08:56 +09:00
junsu choi e850e3e5dc evas_vg_load_svg: Support "display" attribute.
Summary:
If the display attribute is "none", VG object is not show.
The default is "inline" which means visible and "none" means invisible.

Depending on the type of node, additional functionality may be required.
refer to https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/display

Test Plan:
[SVG]
<svg viewBox="0 0 220 100" xmlns="http://www.w3.org/2000/svg">
  <!-- Here the yellow rectangle is displayed -->
  <g display="none">
    <rect x="0" y="0" width="100" height="100" fill="skyblue"></rect>
  </g>
  <rect x="20" y="20" width="60" height="60" fill="yellow"></rect>

  <!-- Here the yellow rectangle is not displayed -->
  <rect x="120" y="0" width="100" height="100" fill="skyblue"></rect>
  <rect x="140" y="20" width="60" height="60" fill="yellow" display="none"></rect>
</svg>

[C CODE]
int main(int argc, char **argv)
{
   setenv("ECTOR_BACKEND", "default", 1);
   elm_init(argc, argv);

   Evas_Object *win = elm_win_util_standard_add(NULL, "test");
   evas_object_smart_callback_add(win, "delete,request", win_del, 0);
   elm_win_autodel_set(win, 1);

   Evas *evas = evas_object_evas_get(win);

   Evas_Object *vg = evas_object_vg_add(evas);
   evas_object_show(vg);
   Evas_Object *container = evas_vg_container_add(vg);
   evas_object_vg_root_node_set(vg, container);

   Evas_Object *svg = efl_add(EFL_CANVAS_VG_OBJECT_CLASS, container);
   efl_file_simple_load(svg, "./test.svg", NULL);
   efl_gfx_entity_size_set(svg, EINA_SIZE2D(600, 600));
   efl_gfx_entity_visible_set(svg, EINA_TRUE);
   evas_object_size_hint_weight_set(svg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(svg, EVAS_HINT_FILL, EVAS_HINT_FILL);

   elm_win_resize_object_add(win, vg);
   evas_object_resize(win, WIDTH, HEIGHT);
   evas_object_show(win);
   elm_run();
   elm_shutdown();
   return 0;
}

Reviewers: Hermet, smohanty, kimcinoo

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9640
2019-08-20 20:32:15 +09:00
Hermet Park 5c39e68d2b canvas svg: fix to apply premultipled color.
fill colors should be premultiplied with fill opcaity.
2019-08-20 11:25:44 +09:00
junsu choi 8f440cdedc vg_common_svg: Apply node opacity to stroke color
Summary:
  When an object to be converted to a stroke or
  path uses "opacity" attribute, opacity is also applied.

Test Plan:
[SVG]
<?xml version="1.0" encoding="UTF-8"?>
<svg width="40px" height="40px" viewBox="0 0 40 40" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <!-- Generator: Sketch 52.6 (67491) - http://www.bohemiancoding.com/sketch -->
        <rect fill="#FF0000" opacity="0" x="0" y="0" width="40" height="40"></rect>
        <path d="M12,20 L25,8 L12,20 Z M12,20 L25,32 L12,20 Z"
              id="Combined-Shape"
              stroke="#FFFFFF"
              stroke-width="2"
              opacity="0.12"
              stroke-linecap="round"
              stroke-linejoin="round" fill-rule="nonzero"></path>
</svg>

[Code]
int main(int argc, char **argv)
{
   setenv("ECTOR_BACKEND", "default", 1);
   elm_init(argc, argv);

   Evas_Object *win = elm_win_util_standard_add(NULL, "test");
   evas_object_smart_callback_add(win, "delete,request", win_del, 0);
   elm_win_autodel_set(win, 1);

   Evas *evas = evas_object_evas_get(win);
   Evas_Object *vg = evas_object_vg_add(evas);
   evas_object_show(vg);
   Evas_Object *container = evas_vg_container_add(vg);
   evas_object_vg_root_node_set(vg, container);

   Evas_Object *svg = efl_add(EFL_CANVAS_VG_OBJECT_CLASS, container);
   efl_file_simple_load(svg, "./i_arrow_l_disable.svg", NULL);
   efl_gfx_entity_size_set(svg, EINA_SIZE2D(600, 600));
   efl_gfx_entity_visible_set(svg, EINA_TRUE);
   evas_object_size_hint_weight_set(svg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(svg, EVAS_HINT_FILL, EVAS_HINT_FILL);

   elm_win_resize_object_add(win, vg);
   evas_object_resize(win, 600, 600);
   evas_object_show(win);
   elm_run();
   elm_shutdown();

   return 0;
}

Reviewers: Hermet, smohanty, kimcinoo

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9620
2019-08-19 19:46:02 +09:00
junsu choi baf1fcdb91 vg_common_svg: Gradient stop color use premultiplied color.
Summary:
The parsed color is straight color.
evas use premultiplied color.

Test Plan:
Sample SVG
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
  <defs>
    <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:0.1;" offset="0"/>
      <stop style="stop-color:#00FFff;stop-opacity:1;"   offset="1"/>
    </radialGradient>
    <radialGradient id="radialGradient333" r="0.2" cx="0.3" cy="0.3" spreadMethod="reflect">
      <stop style="stop-color:#00FF00;stop-opacity:0.1;" offset="0"/>
      <stop style="stop-color:#FF00ff;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)"/>
  <rect x="0" y="0" width="50" height="50" fill="url(#radialGradient333)"/>
</svg>

Reviewers: Hermet, kimcinoo, smohanty

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9338
2019-07-17 17:15:23 +09:00
junsu choi 84fcc5d073 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
2019-07-15 21:22:49 +09:00
Hermet Park 7fcf887b63 evas svg: fix missing node opacity attribute.
Any svg node could have its opacity value, we missed implementing it.

If a node have a opacity, it's opacity could be multiply with fill and stroke colors.

@fix
2019-06-27 13:18:28 +09:00
Christopher Michael af4c6df7bb Revert "static_libs/vg_common: Fix resource leak"
Revert this as it causes edje_cc to segfault.

This reverts commit 2a4c87bb11.
2019-04-24 09:35:58 -04:00
Christopher Michael 1799f79c54 static_libs/vg_common: Remove extra blank lines
NB: No functional changes
2019-04-24 08:58:57 -04:00
Christopher Michael 2a4c87bb11 static_libs/vg_common: Fix resource leak
Coverity reports a resource leak here. The function _create_node
returns allocated storage which should be freed when we are finished
with it.

Fixes CID1382215

@fix
2019-04-24 08:56:00 -04:00
Hermet Park 29b65ccf88 evas svg: code refactoring.
reorder data fields to packing memory fit.
2019-04-19 15:21:07 +09:00
junsu choi 41152dc29e vg_common_svg : Implement gradientTransform property of linearGradient
Summary:
Svg parser gets transformation matrix information from svg.
If there is a matrix, calculate matrix operations
on the start and end points of the gradient.

TODO: We should implement gradientTransform of radialGradient.

Test Plan: N/A

Reviewers: Hermet, smohanty

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8663
2019-04-19 15:07:12 +09:00
junsu choi 5403af9629 vg_common_svg: Prevent duplicate operations for percentage value
Summary:
x1, y1, x2 and y2 of Svg_Linear_Gradient structure must be a percentage value.(0 ~ 1)
but these variables are reused with efl_gfx_gradient_linear_start/end_set/get
and duplicate operations occur.

Test Plan: N/A

Reviewers: Hermet, smohanty

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8662
2019-04-19 13:56:49 +09:00
junsu choi b736697ec7 vg_common_svg : Add missing eet data descriptor
Summary:
Add descriptor to get the value of user_space,
which is a member of Svg_Style_Gradient.

Test Plan: N/A

Reviewers: Hermet, smohanty

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8594
2019-04-11 14:48:05 +09:00
Hermet Park 2fdbc21c03 evas svg: replace internal vg legacy calls with interfaces. 2019-03-11 16:27:19 +09:00
Hermet Park 7c8210d8a6 evas vg: don't access a dangling pointer. 2019-02-27 19:13:18 +09:00
Hermet Park 9a5dacdb36 evas vg: check for OOM when calloc() 2019-02-21 10:36:49 +09:00
Hermet Park 0a47a0ef32 evas vg: check for OOM when calloc() 2019-02-21 10:36:49 +09:00
Hermet Park a921040743 evas vg: check for OOM when calloc() 2019-02-21 10:36:49 +09:00
Hermet Park 1442690680 evas vg: check for OOM when calloc() 2019-02-21 10:36:49 +09:00
Hermet Park 63e11e1b18 evas vg: avoid integral division not to loss precision. 2019-02-21 10:36:49 +09:00
Hermet Park 07521f5e07 evas vg: refactor internal function name.
Specify explict svg name in vg common function
since the function totally depends on svg spec.

No logic changes.
2019-01-09 14:59:01 +09:00