Commit graph

714 commits

Author SHA1 Message Date
Mira Grudzinska
30ee03002b sw_engine: fixing stroke gradient
Instead of checking the stroke's fill, the shape's fill was checked.
As a result the improper rastering function was called (or none).
2021-04-09 13:18:52 +02:00
Hermet Park
35fdc9a278 loaders svg: set default color for composition paint.
not only clippath but alpha compositions might also have any valid color.
Set it default and let it override values while appending shapes if it's necessary.
2021-04-09 17:10:20 +09:00
Hermet Park
903df3da6a loaders svg: prevent composition setting if the result shape is invalid.
Current loader could return invalid shapes -default, from _appendShape()-
by a certain interpretation result,

Though it's a wrong or exception case, we can prevent worse case by avoiding it.
2021-04-09 16:51:05 +09:00
Hermet Park
e1eb98af79 loaders svg: code refactoring
clean up code and remove unnecessary internal class.

this also helps to reduce binary size by 5.5kb

no logical changes.
2021-04-09 15:57:23 +09:00
Hermet Park
adf1312a5e loaders svg: ++ log info for wrong situation.
if either log is printed, we need to improve the composition method.
2021-04-09 11:02:35 +09:00
Hermet Park
605a3bf175 loaders svg: code refactoring
++ clean code.
2021-04-09 10:55:09 +09:00
Hermet Park
6239eca92f loaders svg: fix invalid clip path result.
tvg engine expects the valid clippath with valid colors,
loaders set any colors values to enable it.

this fixes invalid clippath behavior.
2021-04-08 17:54:25 +09:00
Hermet Park
818d24fc70 sw_engine: fix GradientStroke crash
++ strict null check.
2021-04-08 14:15:23 +09:00
Mira Grudzinska
fcad63ec1f sw_engine raster: adding antialiasing to the gradient rastering functions
The gradient rastering functions with composition did not take
antialiasing into account. The missing part has been added.
2021-04-08 13:54:38 +09:00
Mira Grudzinska
9d7a264610 sw_engine raster: refactoring the gradient rastering functions
The gradient rastering functions have been splitted into translucent
and opaque.
2021-04-08 13:54:38 +09:00
Mira Grudzinska
6b5db72f67 sw_engine: rastering the opaque radial gradient with masking
In the radial gradient rastering functions, the part supporting
the (inverse) masking was added.
2021-04-08 13:54:38 +09:00
Mira Grudzinska
8284b3fdfc sw_engine: removed unnecessary function parameter
In the fillFetchLinear function the offset parameter was removed.
The destination address may be shifted directly in the dst parameter,
it doesn't need to be passed separately.
2021-04-08 13:54:38 +09:00
Hermet Park
4557ed6c4b binary optimization
remove inlining to reduce size by 22kb.
2021-04-07 21:27:21 +09:00
Hermet Park
6388a6a9dd common paint: fix wrong fast clippath logic.
it missed to check clippath's transform in fasttrack logic.
now it additionally check it...
2021-04-06 22:28:38 +09:00
Hermet Park
34bce8d371
Update README.md 2021-04-05 22:33:05 +09:00
Hermet Park
9a40b64261 sw_engine raster: ++ precise alpha multiplying
previously alpha multiplying operation doesn't have perfect precision,
could loss 1 pixel since it divides 255 values by 256.

This improved operation comply with both precision & performance.
2021-04-05 12:04:25 +02:00
Hermet Park
9a1d7ec841
Update CONTRIBUTING.md 2021-04-02 13:30:53 +09:00
Hermet Park
cd0c7486f3 loader png: code refactoring
Seperate behaviors open/read/close,
free/close pngimage properly,
add copyright for files.

There still left one optimization point by applying Task.
2021-04-02 12:50:38 +09:00
Hermet Park
9e725226da
meson: revise png loader meson script.
We hate spagettie code, not even build script.
this revise it to keep the build script consistency.
2021-04-02 12:49:18 +09:00
Mira Grudzinska
44f10698ed sw_engine: unnecessary memory allocation and variables has been removed 2021-04-01 21:19:14 +09:00
Hermet Park
fdd14a51a7 loader loaderMgr: add a useful debug message.
Print info if file format is not supported.
2021-04-01 21:12:49 +09:00
Hermet Park
6cc7dfdc56 examples: revise picture sample code. 2021-04-01 20:05:07 +09:00
Mateusz Palkowski
ac3e848cfe minor fixes 2021-04-01 19:38:30 +09:00
Mateusz Palkowski
1046ed2c40 Added png loading example 2021-04-01 19:38:30 +09:00
Mateusz Palkowski
832568e07a Added libpng based png loading 2021-04-01 19:38:00 +09:00
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