Commit graph

639 commits

Author SHA1 Message Date
Mira Grudzinska
fe32ca8de7 sw_engine: fixing linear gradient rastering for shapes with composition
Masking and Inverse masking are for now rastered properly only for the linear
gradients without the opacity.
2021-04-01 11:51:08 +09:00
Patryk Kaczmarek
cd6fb4f483 gradients: paint linerar gradients properly with mask composition method
@Issues: 243

Change-Id: Ie26a0b903af94a46683348e3fb7d8b554576997c
2021-03-31 20:38:16 +09:00
Mira Grudzinska
f62ee4fc84 capi: changing function name
For uniformity of the functions naming the function name
tvg_shape_stroke_get_gradient changed to tvg_shape_get_stroke_gradient.
2021-03-31 16:42:29 +09:00
Hermet Park
c7f09bb333 doc: update sample images. 2021-03-26 19:38:34 +09:00
Hermet Park
bf6c0770dc
Update README.md 2021-03-26 19:35:26 +09:00
Hermet Park
4a19e5b9f6 common: fix wrong viewport region.
in the clip rect, viewport must be accumulated to the smaller one.
this patch improves that corner-case.
2021-03-26 17:24:43 +09:00
Hermet Park
f1fe36d8f6 common sw_engine: optimize single rectangle ClipPath.
If ClipPath is a singular rectangle,
we don't need to apply this to all children nodes to adjust rle span regions.

Rather than its regular sequence,
we can adjust render region as merging viewport that is introduced internally,

All in all,
If a Paint has a single ClipPath that is Rectangle,
it sets viewport with Rectangle area that viewport is applied to
raster engine to cut off the rendering boundary.

In the normal case it brings trivial effects.
but when use SVGs which has a viewbox, it could increase the performance
up to 10% (profiled with 200 svgs rendering at the same time)

Note that, this won't be applied if the Paint has affine or rotation transform.

@Issues: 294
2021-03-26 17:10:35 +09:00
Hermet Park
4a8f45577a
sw_engine: code refactoring
1. unified clip & bounding box in rle processing
2. unified outline boundingbox functions between shape & image.
2021-03-24 18:48:39 +09:00
Hermet Park
19fc4f4b37 examples: allow a desianted main thread capacity.
Maximum threads is not always peak the highest performance,
tvg examples guide user the proper threads count.
2021-03-24 14:19:01 +09:00
Hermet Park
aa68481fb7 common paint: fix memory leak case.
free the previous composition target if any,
before reset with the new one.
2021-03-23 16:35:22 +09:00
Hermet Park
1a7d41ce71 updated copyright 2021-03-23 14:31:58 +09:00
Hermet Park
e5381da223
common engines: code refactoring
Introduce RenderRegion structure for region data
to simplify the methods paratemers.

also depends on the NRVO for the return data.
2021-03-23 14:18:17 +09:00
Mira Grudzinska
234a9b2f93
svg_loader: ommiting xml entities in the svg file (#278)
SVG files created using 'sketch' may contain xml entities,
which are not understandable by the svg loader.
For now only '"' is ommited.
2021-03-23 09:22:46 +09:00
Hermet Park
79f1ba8516 loader svg: fix coding convention 2021-03-22 16:28:08 +09:00
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
699a751b1b updated AUTHORS 2021-03-09 20:20:43 +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
Hermet Park
7809ea4181
Update README.md 2021-03-07 12:05:58 +09:00
Hermet Park
1c1f185142
Update README.md
updated svg part.
2021-03-07 11:58:01 +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
Juyeong Lee
7147ebf21a Fix typo in CONTRIBUTING.md 2021-02-26 18:14:17 +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