Commit graph

998 commits

Author SHA1 Message Date
Vincent Torri
5a85b40f6c fix compilation on Windows 2020-11-06 11:28:54 +09:00
Vincent Torri
8243b3a1f5 fix compilation on Windows 2020-11-06 11:28:54 +09:00
Hermet Park
006e6e0920 sw_engine rle: performance optimization.
Tis is a subsequential trial of 1b8188ee67
for opimizing memory alloc count.

In this time, it concentrates on rle span.

@Issues: 75
2020-11-05 17:32:42 +09:00
Hermet Park
1d3c56e487 sw_engine mempool: performance optimization.
This is a subsequential trial of 1b8188ee67
for opimizing memory alloc count.

In this time, it concentrates on stroke outline.

@Issues: 75
2020-11-04 20:42:01 +09:00
Hermet Park
410fa6c115 sw_engine mempool: changed caching policy.
for smart usage, clear memory only when engine is terminated.
2020-11-04 19:20:29 +09:00
Hermet Park
3ab1194773 common sw_engine: code refactoring
replaced names and fixed out of coding convention.
2020-11-04 19:18:59 +09:00
Hermet Park
9bb1972ef9 examples: revise example code.
Move the Clear call to the end of drawing those scenarios doesn't need to retain paints resources.

We should show the examples as the best usage.

@Issues: 75
2020-11-04 19:05:11 +09:00
Hermet Park
1b8188ee67
sw_engine shape: performance optimization.
we introduced shared memory pool for avoiding reallocate memory
while it process the stroke outlines, It experimentally increase
the outline data if we use the allocated memory for multiples shape strokes,
we don't need to alloc/free memory during the process.

This shared outline memory is allocated for threads count
so that we don't interrupt memory access during the tasks.

@Issues: 75
2020-11-04 16:28:47 +09:00
Michal Szczecinski
882188c752 common capi: Added opacity C bindings.
Added opacity setter/getter to CAPI. They will be useful to simplify
code responsible for set visiblility of paint.

@API Additions:
Tvg_Result tvg_paint_set_opacity(Tvg_Paint* paint, uint8_t opacity)
Tvg_Result tvg_paint_get_opacity(Tvg_Paint* paint, uint8_t* opacity)
2020-11-04 10:37:55 +09:00
Hermet Park
200016fea0 common LoaderMgr: code refactoring
keep clean & neat thorvg coding style.
2020-11-03 14:21:19 +09:00
JunsuChoi
af85eb22ad svg_loader LoaderMgr: Delegates file validation check to LoaderMgr.
Delegates extension string check and header(open) check
for file to LoaderMgr.
This makes it easy to add a loader afterwards.
2020-11-03 12:15:12 +09:00
Hermet Park
627579522d sw_engine shape: code refactoring.
thorvg always prefer simpler code, less LOC.
2020-11-02 19:25:36 +09:00
Mira Grudzinska
a96037cd57 sw_engine shape: change of the rectangle fast tracking algorithm
The algorithm erroneously treated some shapes (like isosceles trapezoids
and specifically arranged zero width parallelograms) as rectangles,
which causes the whole bbox to be filled.
2020-11-02 19:23:44 +09:00
JunsuChoi
dc822174e8 svg_loader: Fixed a typo
lenght ->length
2020-11-02 14:16:13 +09:00
JunsuChoi
d4e9450ec1 common lib/loaders: Fix missing space for coding convention
Correct missing or incorrect spaces according to coding convention.
2020-11-02 14:15:05 +09:00
JunsuChoi
1bf123ff46 svg_loader SvgLoader: Fix wrong indentation
indent 3 -> 4
2020-11-02 14:14:36 +09:00
JunsuChoi
6cf2d89571 svg_loader SvgLoader: Prevent memory overflow for tagName
When copying tagName, if length of referenced string is longer
than general case, it is not used as tagName.
2020-10-30 17:06:06 +09:00
Hermet Park
0399d84478 common paint: introduce opacity() method.
We introduced separate opacity interface to adjust alpha value by paint.
This opacity will affect to whole paint image if paint is a group of paints.

Also, this opacity is to multipy with fill/stroke alpha values.
This means if the opacity is valid, the paint might deal with a composition step,
which is very expensive due to additional rendering step.

One tip is, if you want to toggle on/off for a certian paint,
you can set opacity to 255 or 0.

@API Additions:

Result Paint::opacity(uint8_t o) noexcept;
uint8_t Paint::opacity() const noexcept;

@Examples: examples/Opacity

@Issues: 94
2020-10-26 19:23:54 +09:00
Hermet Park
da4b57e763 examples fillrule: revise code.
just adjusted start points for better visual.
2020-10-26 17:13:02 +09:00
Hermet Park
73c7782749 examples svgs: replace logo design resource.
White background is our official thorvg logo,
cyan is for Tizen customed.
2020-10-26 16:52:52 +09:00
Mira Grudzinska
34a832d033 sw_engine shape: adding a dash pattern switch condition
Preventing switching to the next dash pattern for a line with a length of zero.
2020-10-26 16:40:42 +09:00
Mira Grudzinska
4b58c5a5de common shape: handling dash patterns < 1
For the dash pattern values (both, length and gap) < 1 the program crashed.
curLen - variable type changed from int to float.
2020-10-23 17:42:13 +09:00
Hermet Park
0b767750e6 common api: interface refactoring
returning color fill() method renamed to fillColor() as like others-strokeXXX, fillRule- do.

This change is for naming consistency.
2020-10-23 12:23:59 +09:00
Hermet Park
65cbbcf724 sw_engine shape: support fillRule method
this change supports EvenOdd fillrule in shape rendering

@Examples: examples/FillRule.cpp

@Isuses: 97
2020-10-22 17:29:39 +09:00
Hermet Park
46bd78a7c3 sw_engine renderer: fix aliasing shape outline result.
There a scenario detected that stroke 2 is not enough to cover
shape outlines. So make it bigger size.
2020-10-22 15:02:57 +09:00
Hermet Park
c807010554 examples FillRule: added shape::fillRule() example
one shape shows Winding, the other one shows EvenOdd.
2020-10-22 13:50:04 +09:00
Hermet Park
04aa038339 common fill: add fill-rule interface.
Fill rule is used to select how paths are filled.

For both fill rules, wheter or not a point is included in the fill is determined by taking a ray
from that point to infinity and looking at intersections with the path. The ray can be in any
direction, as long as it doens't pass through the end point of a segment or have a tricky
intersection such as intersecting tangent to the path.

@API Addtions:

enum class TVG_EXPORT FillRule { Winding = 0, EvenOdd };
Result Fill::rule(FillRule r) noexcept;
FillRule Fill::rule() const noexcept;

@Examples:

shape->rule(FillRule::EvenOdd);

@issue: 97
2020-10-20 20:10:59 +09:00
Mira Grudzinska
380450c95b Bezier curve: introducing BEZIER_EPSILON
BEZIER_EPSILON is used instead of EPSILON_FLT, because its
value was to small causing in some cases an infinite loop.
2020-10-20 16:12:59 +09:00
Hermet Park
389b028be4 svg_loader XmlParser: just renamed file name to simplify.
XmlParser without "Simple" is enough to address itself.
2020-10-15 20:44:53 +09:00
Shinwoo Kim
cc81e46343 thorvg viewer: fix scale problem
If viewer calls load() with a data which does not have size changes of both
viewbox and canvas, then load() does not set a scale value.
This makes incorrect result on viewer side.

So thorvg wasm should set a scale value, whenever load() is called.
2020-10-15 10:19:20 +09:00
Shinwoo Kim
acac884257 thorvg viewer: add getDefualtData interface
The 'getDefaultData' interface will be used when the svg data area
of thorvg viewer does not have any value.
2020-10-14 19:22:13 +09:00
Hermet Park
a4b828c556 svg_loader: fix wasm data type compile error. 2020-10-14 17:51:59 +09:00
Hermet Park
3e5d3b06c3 improve svg logo design quality. 2020-10-14 17:51:33 +09:00
Shinwoo Kim
0c68c45ef7 thorvg viewer: introduce thorvg viewer
Support Emscripten wasm build for thorvg viewer
2020-10-13 19:04:46 +09:00
Hermet Park
32f40bf7b0 re-tourched logo design for better quality. 2020-10-13 17:23:11 +09:00
Hermet Park
2a239714af sw_engine: fix missing shape update issue.
It missed to update shape data if visilibity is changed from false to true by alpha.

Also, it needs to update engine shape data for every requests.

There scenario can be allowed,

1. update shape
2. change shape property
3. update shape
4. draw

previously engine could skip step 3, its result was not properly expected.

@fix #84
2020-10-13 17:07:54 +09:00
JunsuChoi
77ccbcc6fe
tvgSvgLoader: Add points copy of missing polygon/polyline
When using <use> node, do atrribute copy.
At that time, when target(url) is polygon or polyline,
points array is not copied, causing a problem in output.
So, add missing array copy.
2020-10-13 13:45:40 +09:00
JunsuChoi
098c94819c tvgSvgLoader: Fix wrong bracket 2020-10-13 13:43:54 +09:00
JunsuChoi
e73cf7db60 tvgSvgLoader: Add "clip-path" attribute
Below node types support clip-path.
<circle>
<ellipse>
<g>
<path>
<polygon>
<polyline>
<rect>
2020-10-13 13:43:54 +09:00
JunsuChoi
ea0ce1f496 SvgLoader: Implement ClipPath style
Supports case of using style attribute for defined <clipPath>.
In SVG, <clipPath> can be used as a "clipPath" attribute or a style "clip-path".
This patch only supports "clip-path" of style is declared.
The remaining features will be added later.

[Example SVG case]

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve">
 <defs>
      <clipPath id="clipPath">
          <rect x="15" y="15" width="40" height="40" fill="#F00" />
          <circle cx="20" cy="20" r="10" fill="#F00" />
      </clipPath>
  </defs>

  <circle cx="25" cy="25" r="20"
          style="fill: #0000ff; clip-path: url(#clipPath); " />
</svg>
2020-10-13 13:43:54 +09:00
Hermet Park
31725b8d33 examples: update DirectUpdate
Shape::clear() method is changed.
Now it clear all properties, the examples must be updated.
2020-10-13 13:34:10 +09:00
Hermet Park
a8124f6782 Added thorvg logo svg resources,
Also replaced svg examples to use them.
2020-10-13 12:07:47 +09:00
Hermet Park
36df183e12 svg_loader: use designated fabsf() for float values.
fabs() is designed for double type,
but here it uses float type.
2020-10-13 09:55:40 +09:00
Hermet Park
db367d0c14
common shape: fix reset() bug. (#99)
Previous reset() doesn't implemented properly.
It resets only path data.

Now Shape resets all drawing properties.
2020-10-08 16:37:39 +09:00
Hermet Park
24a0a2554d
examples: add stacking example
This example shows how to restack paints node
2020-10-08 15:57:01 +09:00
Hermet Park
8422e8c62b common canvas: revise clear method.
Canvas::clear() introduces a new argument "free" that deterimes freeing the retained paints.

If free is true, Canvas won't delete the retained paints so that user keep paints valid.

In this scenario, user must have paints pointers, free them manually or push them again to the canvas.

This scenario is useful if user wants to re-organize paints order in the list or reuse them.
2020-10-08 12:07:27 +09:00
Hermet Park
a200c6d4e2
common: code refactoring
renamed the enum CompMethod -> CompositionMethod

added FIXME comment
also clean up internals for less code.
2020-10-07 16:25:09 +09:00
Hermet Park
c6b3f78eca common bezier: code refactoring.
use a zero ranged macro.
2020-10-07 14:33:17 +09:00
Hermet Park
e358675d61
Bezier curve: improvement of the curve splitting algorithm (#86)
bezAt() function needed to be fixed.
Also the convergence in the while loop was sped up and
the break condition was changed.
2020-10-07 14:30:13 +09:00
Hermet Park
b5c301ba2d examples: add missing files. 2020-10-07 14:28:11 +09:00