Commit graph

998 commits

Author SHA1 Message Date
Hermet Park
e4a28869d1
examples: revise StrokeGradient
renamed GradientStroke & repositioned visuals.
2021-03-22 13:52:43 +09:00
Mira Grudzinska
f0540d753a svg_loader: applying AlphaMask during scene building
The AlphaMask composition case was omitted in the _sceneBuilderHelper().
2021-03-22 10:45:14 +09:00
Hermet Park
e8cf21a3c9 initializer: add reference counting for the engines initialization.
Introduced the reference counting for the backend engines so that
tvg prevents unpaired engine initialization/termination calls by user mistake.

@Issues: 296
2021-03-19 19:45:39 +09:00
Hermet Park
53d23e9862
common picture: fix crash at picture duplication.
A duplicated picture needs to access internal picture loader data
to get its properties while rasterizing.

But it missed the loader since it's not copied from origin.

Thus, we fix this by sharing the internal loader among the duplications and origin.

@Examples: Duplicate
2021-03-19 19:41:18 +09:00
Mira Grudzinska
95c022da1f paint: clip was substracted from the array for any composite method
Only ClipPath composite method should cause clips subtraction.
2021-03-18 21:51:01 +09:00
Michal Szczecinski
623a90de7b common shape: Fixed appendArc for negative values.
Description:
Fixed appendArc API for -90 angles. In that case it was drawn in wrong
direction.

@Examples

```cpp
  float x = 40.0, y = 40.0;
  auto shape1 = tvg::Shape::gen();

  //OK
  shape1->appendArc(x + 50, y, 25, 0, -91, false);
  //NOK
  shape1->appendArc(x + 100, y, 25, 0, -90, false);
  //OK
  shape1->appendArc(x + 150, y, 25, 0, -89, false);
```
2021-03-17 15:54:11 +09:00
Hermet Park
c40823d70e loaders svg: remove unnecessary move call, move is guaranteed at the return value.
warning: moving a temporary object prevents copy elision [-Wpessimizing-move]
2021-03-16 13:29:16 +09:00
Hermet Park
105a59b5b3
sw_engine: optimize rle clipping
We don't need to copy the rle data unecessarily,
we can just replace the completed clip rle.
2021-03-16 10:23:11 +09:00
Hermet Park
0faea8a9ab examples: clean up mask resources.
These are not proper for our svg examples.
2021-03-15 19:19:54 +09:00
JunsuChoi
ac1434bb74 sw_engine rleClipPath: Modify clippath spans creation size.
When updating rle for clipped area, realloc size should be larger than spans size.
so this patch prevents the problem while realloc.
2021-03-15 17:12:21 +09:00
JunsuChoi
631c1e5651 loader SvgSceneBuilder: Add root node to clipping viewBox.
If the boundary of scene created through the scenebuilder is larger than the viewbox,
scene(SVG's root) should be clipped to the size of the viewbox.
So, if scene need a clip, add a parent root and add clippath composition to that root.
2021-03-15 15:24:10 +09:00
Hermet Park
8ff1405050 common shape: revise Shape::reset() api.
reset Path is useful rather than reset all properties.
2021-03-12 18:27:14 +09:00
Hermet Park
9f0fafa5df This is too untable.... Stress in example is crashed by this.
Revert "svg_loader: limiting the ploted area of svg to viewBox"

This reverts commit 2bb108b2f1.
2021-03-12 18:10:26 +09:00
Hermet Park
efd4741a78 common canvas: initialize member variable.
to shutdown the static code analizer report.
2021-03-12 11:50:46 +09:00
Mira Grudzinska
2bb108b2f1 svg_loader: limiting the ploted area of svg to viewBox
The 'viewBox' element given in the svg file determines
the coordinates of the plotted area. ClipPath used in Svg loader.
2021-03-12 10:54:38 +09:00
Hermet Park
0984241954 sw_engine fill: correct value loss by data conversion. 2021-03-11 20:10:11 +09:00
Mira Grudzinska
ecf47fcec8 example: Duplicate.cpp modified
Duplication of the Picture with a raw image is added
2021-03-11 10:42:28 +09:00
Hermet Park
5e01fd8b4b Revert "sw_engine shape/image: substituting logical 'and' with 'or'"
This reverts commit 74b27c74af.

This patch breaks Stroke example. 1 line drawings...

There is a possibility that less 1 (i.e: 0.5) width axis-aligned line drawings...

So logically "&&" is correct.
2021-03-09 20:13:44 +09:00
Mira Grudzinska
b5bc73849c sw_engine raster: functions optimization in the image block
The alpha value calculation pulled out outside the inner loop
to reduce the number of unnecessary operations.
Added local variables to reduce the number of costly
multiplications performed in a loop.
2021-03-09 19:47:50 +09:00
Mira Grudzinska
74b27c74af sw_engine shape/image: substituting logical 'and' with 'or'
In the case when the height or width of the bounding box is 0
it is not necessary to calculate Rle.
2021-03-09 19:44:29 +09:00
Patryk Kaczmarek
6e59116137 example: AnimateMask images change
Change-Id: Iacd407c3e186f1f91c2bcbd9099f0b83a9dba264
2021-03-09 14:39:56 +09:00
JunsuChoi
355cc8c253 svg_loader SvgPath: Remove unnecessary optimization code
This condition(optimization) is not a step suggested by arc implementation.
https://www.w3.org/TR/SVG11/implnote.html#ArcCorrectionOutOfRangeRadii (Step2)
This code is useful if the arc is too small to represent.
However, scaling often occurs in vectors, which can create unnecessary problems.

example path
<path d="M32.41,20.49a.41.41,0,1,1-.41-.42A.41.41,0,0,1,32.41,20.49Z" transform="translate(0)" fill="#020202"/>
2021-03-05 16:39:16 +09:00
JunsuChoi
f590571e3a svg_loader SvgLoader: Fix copy conditions for stop of gradient
When getting a linked stop list, if there is no existing stop list
in current gradient, it is copied.
2021-03-04 18:43:58 +09:00
Mira Grudzinska
a173b16ed5 svgloader: fixing linear gradient transformation
Gradient stop points were incorrectly transformed when building
the scene in the SVG loader.
2021-03-03 19:48:26 -08:00
Hermet Park
cb425fa4bb capi: fix incorrect composite api.
Api prototype is completely wrong, now it's corrected.
2021-03-04 11:33:24 +09:00
Mira Grudzinska
a72be6159d svgloader: fixing SVG image display when viewBox size is not given
When viewBox is not given its dimensions should be determined
by the height and width parameters
2021-03-03 18:02:36 -08:00
Mira Grudzinska
07e6c476a8 sw_engine fill: fixing the infinite loop condition
Fixed in the fillFetchLinear() function.
2021-03-03 17:46:33 +09:00
Mira Grudzinska
d03db583e5 svgloader: fillRule value passed to the shape
The value was loadeed but not set to the shape.
2021-03-02 18:05:54 -08:00
Mira Grudzinska
692e100f9a canvas: replacement of the bitwise OR operator with the logical one
Bitwise logical operators do not perform short-circuiting.
2021-03-03 10:54:27 +09:00
Hermet Park
d522c9d45e
sw_engine fill: fix wrong gradient transformation
There transformation logic was not identical between shape & gradient

gradient transform was applied into center of gradient world,
while shape wasn't. So... we correct gradient transform metric to shape like.

@Issues: 255
2021-03-03 10:53:32 +09:00
Hermet Park
e64ff980b0 examples images: correct file change mode.
For consistency, thorvg keeps file chmod => 664.
2021-02-25 19:14:23 +09:00
Hermet Park
6cd587ba5f scene: fix a composition regression bug.
Pre-condition is broken when this commit come - b60a773d12

Both condition should be identitcal so that comp logic is perfectly performed.
2021-02-25 18:06:56 +09:00
Hermet Park
b60a773d12
common: optimize scene composition
Scene could avoid composition if its children is only child (non scene)

This patch bring it conditionally check so as to avoid unnecesary expensive job.

@Issues: 254
2021-02-25 12:38:39 +09:00
Patryk Kaczmarek
03d48159e3 examples: new AnimateMask example and svg images with masks
Change-Id: I609597a5ecb710e9af9939a3028eeef691b66188
2021-02-25 12:24:19 +09:00
Hermet Park
c0362cb69c sw_engine: fix a composition crash issue.
Added an exceptional handling for out of buffer boundary.
2021-02-24 20:02:10 +09:00
Hermet Park
69ff5a484b canvas: fix crash issue.
When canvas target size is changed, it need to update all retained paints again
so that they cannot redraw onto out of buffer boundary.
2021-02-24 19:58:44 +09:00
Hermet Park
197879f2ef fixed all wasm build breaks. 2021-02-23 10:47:46 +09:00
Michal Szczecinski
d6d65c3bd6
Issue 180 example (#212)
* examples: Added resize_cb to Capi example.

resize_cb in capi example is used to verify crash on reize described
in @180 issue.

* examples capi: Fixed file type from dos to unix.

Use the same code style as it is used in other examples.
2021-02-22 13:30:05 +09:00
Michal Szczecinski
f0ab7f4002 sw common: Fixed crash in rasterRGBA32
Description:
Crash was observed in examples when composite object was used.
It was caused because __m256i object was used on non aligned
memory to 32bit. Algorithm in this function was changed to use
unaligned __m256i_u object. Code was also simplified.
2021-02-22 13:26:41 +09:00
Mira Grudzinska
5e1d3772ca sw_engine raster: fixing rasterization of an image with InvMask
In case of the image rasterization with an inverse mask the opacity
was omitted and the alpha value instead of the inverse alpha value was used.
2021-02-22 13:02:04 +09:00
Hermet Park
028e1fa251 sw_engine: enhance log message.
more informational log is better.
2021-02-22 12:53:56 +09:00
Mira Grudzinska
229a013fcd sw_engine math: fixing matrix transformation
Unnecessary rounding during matrix transformation has been removed.
The problem occured when scaling a shape with a dashed stroke.
2021-02-22 11:15:11 +09:00
JunsuChoi
6db7f85ffb common Scene: Fix translucent composition condition
If a scene has another scene as a child and
the number of children is 1, the composition of the child does not work.
Therefore, fix that composition works as long as the number of children is not 0.
2021-02-22 11:00:20 +09:00
Patryk Kaczmarek
795121fa67 SvgLoader: Mask style implementation
Supprot case when style is defined as <mask> attribute.

[Example SVG file]
```html
<svg version="1.1" id="Layer_1" viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve"
  xmlns="http://www.w3.org/2000/svg">
  <defs>
    <mask id="myMask">
      <circle id="maskID" cx="40" cy="40" r="10" fill="white" fill-opacity="1" />
    </mask>
  </defs>
  <rect x="0" y="0" width="64" height="64" style="fill: skyblue; mask=url(#myMask);"/>
</svg>
```

Change-Id: I3b856db85204bf7c503a20e4023417ca79aa930c
2021-02-19 18:23:47 +09:00
JunsuChoi
70e1e7f1c6 sw_engine Renderer: Fix build problem caused by merge conflict. 2021-02-19 17:33:15 +09:00
Mira Grudzinska
d86032df36
sw_engine: adding a gradient as a stroke feature
* sw_engine: adding a gradient as a stroke feature

Similarly as a shape may have a gradient fill so can the stroke.

* Capi: adding APIs for a gradient stroke

Co-authored-by: Hermet Park <hermetpark@gmail.com>
2021-02-19 17:16:10 +09:00
Mira Grudzinska
20324dc48e example StrokeGradient
Example showing a gradient usage for a stroke.
2021-02-19 17:14:12 +09:00
JunsuChoi
415fca577e common: TVG_UNUSED marking on unused parameter 2021-02-19 16:51:50 +09:00
JunsuChoi
69f02d803b shape: Refactoring to use initialize list
Member data should be initialized in-class or in a constructor initialization list
2021-02-19 16:51:50 +09:00
JunsuChoi
c819754056 common: Refactoring incorrectly declared loop variable
Loop variables should be declared in the minimal possible scope
thorvg prefers to declare when using local variables.
2021-02-19 16:51:50 +09:00