Commit graph

2764 commits

Author SHA1 Message Date
Hermet Park
1632ad9ee5 lottie: removed unused code.
Currently, thorvg has no plan to support dotlottie format.
2024-04-06 12:48:30 +09:00
Sergii Liebodkin
7d8a261a83 wg_engine: Blending optimization
[issues 1479: lottie](#1479)

To optimize bled operations hardware pipeline blend stage are used for some blend methods:
	BlendMethod::SrcOver
    BlendMethod::Normal
    BlendMethod::Add
    BlendMethod::Multiply
    BlendMethod::Darken
    BlendMethod::Lighten

Other types compute shaders used
2024-04-06 12:48:30 +09:00
Hermet Park
ef03e5b006 lottie: hotfix memory corruption.
revise the fix that occured a side effect by:
287e6d33d2
2024-04-06 12:48:30 +09:00
Hermet Park
043b14d681 sw_engine/stroke: hotfix the memory access violation
ensure that the number of contour/close data is properly paired.

issue: https://github.com/thorvg/thorvg/issues/2129
2024-04-06 12:48:30 +09:00
Jinny You
f54f22ae78 lottie: Fix heap-buffer-overflow in gradient populate 2024-04-06 12:48:30 +09:00
JunsuChoi
349fd266b9 loader/svg: Check invalid color
Checks whether the string that can be specified in Color is valid.

example)
```
     style="stroke:asdasd"
```

related issue: https://github.com/thorvg/thorvg/issues/1255
2024-04-06 12:48:30 +09:00
Hermet Park
ecee01ebd6 lottie: Properly handle the TrimPath mode.
This correction addresses the drawing order of
objects when a group contains a TrimPath and
is merging shapes.

Additionally, the TrimPath method is can applied
to the engine to control the drawing behavior by
7f3dc541d6b7abcdc03facd884489f37c327fd98

issue: https://github.com/thorvg/thorvg/issues/2047
2024-04-06 12:48:30 +09:00
Hermet Park
6688f03396 sw_engine: revised the trimpath dash line logic
Support the TrimPath modes (individual/simultaneous)
internally in the engine to handle them efficiently.
2024-04-06 12:48:30 +09:00
Hermet Park
8be41faa26 Update README.md 2024-04-06 12:48:30 +09:00
JunsuChoi
0c6395cbea loader/svg: Support hsl color format
Support parsing of hsl(hue, saturation, brightness) color type
and conversion to rgb color.
2024-04-06 12:48:30 +09:00
Sergii Liebodkin
4f204b5e13 wg_engine: Lottie extensions
[issues 1479: LottieExtensions](#1479)

LottieExtensions example supports
Supports multiple color stops for gradient fill (redial and linear)
2024-04-06 12:48:30 +09:00
Jinny You
9a3c673f11 lottie: Fix buffer-overflow in base64 decode 2024-04-06 12:48:30 +09:00
Hermet Park
e4f7fffacc sw_engine: hotfix a regression bug of line drawing.
fixed one more corner case problem, just observed.
it's a side effect by 925009c4a5
2024-04-06 12:48:30 +09:00
Hermet Park
26e04611e6 infra: move the examples folder outside of the source directory.
examples are not considered a feature of ThorVG;
hence, they are excluded from the src directory.

This change allows developers to concentrate more effectively
on the core ThorVG sources for practical usages.
2024-04-06 12:48:27 +09:00
Hermet Park
c943b6caa9 Update README.md 2024-04-06 12:08:23 +09:00
Vincent Torri
3981b58f73 README.MD: add instructions to install and update thorVG with MSYS2 2024-04-06 12:08:23 +09:00
Hermet Park
f7bfc57f23 portability: removed a compiler waring
D:\Projects\thorvg\src\loaders\lottie\tvgLottieParserHandler.h(52): warning C4083: expected ')'; found identifier 'effc'
[44/46] Compiling C++ object src/thorvg-0.dll.p/loaders_lottie_tvgLottieParserHandler.cpp.obj
D:\Projects\thorvg\src\loaders\lottie\tvgLottieParserHandler.h(52): warning C4083: expected ')'; found identifier 'effc'
[45/46] Compiling C++ object src/thorvg-0.dll.p/loaders_lottie_tvgLottieParser.cpp.obj
D:\Projects\thorvg\src\loaders\lottie\tvgLottieParserHandler.h(52): warning C4083: expected ')'; found identifier 'effc'

I'm not sure this option is really necessary.
2024-04-06 12:08:23 +09:00
Hermet Park
d883cc23cf lottie: polish up a comment. 2024-04-06 12:08:23 +09:00
Hermet Park
1f04df60dd lottie: Removed redundant code.
The settings were incorrect;
'direction' and 'fillRule' do not have a relationship.
2024-04-06 12:08:23 +09:00
Hermet Park
f6170a224a lottie: optimize the rendering performance.
this optimization nicely merges shapes
when a child group has a only (transformed) pathes.

this also fixes the following compatibility issue nicely.

issue: https://github.com/thorvg/thorvg/issues/2061
2024-04-06 12:08:23 +09:00
Hermet Park
40647d5882 lottie: optimize the rendering by preventing partial rendering branches.
this optimization is to figure out if this group is a simple path drawing.
In that case, the rendering context can be sharable with the parent's.
2024-04-06 12:08:23 +09:00
JunsuChoi
f0527a2304 loader/svg: Check whether href id of use is parent or not
When finding the 'nodeFrom' referenced by `<use>`,
if it is the parent, it is not referenced.

https://www.w3.org/TR/SVG2/struct.html#UseElement
Specification:
If the referenced element is a (shadow-including) ancestor
of the ‘use’ element, then this is an invalid circular reference
and the ‘use’ element is in error.

related issue: https://github.com/thorvg/thorvg/issues/2078
SVG_FILE_65171.svg
SVG_FILE_65172.svg
2024-04-06 12:08:23 +09:00
JunsuChoi
b408178ca6 loader/svg: Do recalc after gradient inheritance
Inherit gradientUnits and recalculate each element
radial(cx, cy, r,...), linear(x1, y1, x2, y2).

related issue: https://github.com/thorvg/thorvg/issues/2078
2024-04-06 12:08:23 +09:00
Sergii Liebodkin
fafec9fa46 wg_engine: render buffers usage refactorings
[issues 1479: strokes](#1479)

- update buffers via memory mapping
- refactoring of winding fill rule computation
2024-04-06 12:08:23 +09:00
Hermet Park
736a79674b lottie: code refactoring.
removed unused static condition.

static was prepared for optimization,
but not used at all.

we will revisit this later when time permits.

binary size: -6kb
2024-04-06 12:08:23 +09:00
Jinny You
7ec7a4c08c lottie: Fix crash from invalid masking method
This change is better for stability. Returns `None` if the `mode` attribute cannot be parsed.

related issue: #2072
2024-04-06 12:08:23 +09:00
Hermet Park
68e4d35f7b sw_engine: stabilize the contour composition logic.
there has been a logical error that breaks the contour
composition context. This fixes it.

issue: https://github.com/thorvg/thorvg/issues/2093
2024-04-06 12:08:23 +09:00
Jinny You
c8ddc316db lottie: Fix crash when an invalid gradient is provided
When lottie is broken and provides invalid gradient, the program crashes in segmentation fault.

At that time, in the `populate` function, `ColorStop& color` doesn't have `input` but tries to use it.

Added checking nullptr logic. The function `populate` will not proceed and return 0 in that case.

related issue: #2072
2024-04-06 12:08:23 +09:00
Hermet Park
04b5525db4 api: Promote experimental Animation APIs to official status.
These APIs have been thoroughly tested and verified.

New API:
- Result Animation::frame(float no)
- Picture* Animation::picture() const
- float Animation::curFrame() const
- float Animation::totalFrame() const
- float Animation::duration() const
- static Animation::std::unique_ptr<Animation> gen()

New CAPI:
- Tvg_Animation* tvg_animation_new()
- Tvg_Result tvg_animation_set_frame(Tvg_Animation* animation, float no)
- Tvg_Paint* tvg_animation_get_picture(Tvg_Animation* animation)
- Tvg_Result tvg_animation_get_frame(Tvg_Animation* animation, float* no)
- Tvg_Result tvg_animation_get_total_frame(Tvg_Animation* animation, float* cnt)
- Tvg_Result tvg_animation_get_duration(Tvg_Animation* animation, float* duration)
- Tvg_Result tvg_animation_del(Tvg_Animation* animation)

issue: https://github.com/thorvg/thorvg/issues/2067
2024-04-06 12:08:23 +09:00
Hermet Park
051969c61c sw_engine: rectify consecutive line drawings.
There are differences in behavior compared to the SVG spec,
especially when consecutive line drawings occur without a moveTo command
following a closePath command.

Actually, thorvg didn't care the behavior in that scenario,
this update ensures the scenario is handled correctly
to align with the SVG specification.

issue: https://github.com/thorvg/thorvg/issues/1487
2024-04-06 12:08:23 +09:00
Hermet Park
2b2d41221f renderer: Fix a crash issue related to the clipper
Fixed a crash that occurred when a given clipper had no data.
Properly handle this exceptional case to prevent the crash.

issue: https://github.com/thorvg/thorvg/issues/2083
2024-04-06 12:08:23 +09:00
Jinny You
9d040f9042 lottie/slot: Fixed potential overriding bug
Slot overriding tries to set property via the `LottieObject`. It potentially causes unexpected changes.

Revised the `override` function. The purpose of this patch is to aim atomic property to be overriden.
2024-04-06 12:08:23 +09:00
Sergii Liebodkin
98b30c72ef wg_engine: stroke trim
[issues 1479: strokes](#1479)

Introduced stroke trim setting

left: (0, 0.95)
middle: (0.15, 1)
right: (0.15, 0.95)
2024-04-06 12:08:23 +09:00
Vincent Torri
2f196b514f [common] code clean up
use fmodf() instead of fmod()
2024-04-06 12:08:23 +09:00
vtorri
3640724b99 [common] code clean up
use MATH_PI and MATH_PI2 instead of M_PI and M_PI_2
2024-04-06 12:08:23 +09:00
Hermet Park
c73370a0ae ttf: ++uwp portability
use the preprocessor directives properly.
2024-04-06 12:08:23 +09:00
Jinny You
984eb2eff9 lottie: Support the slot reverting feature
Implemented the ability to revert Lottie slots by calling override with nullptr.
This functionality allows for the complete reversal of applied slots.

usage:
- `animation->override(nullptr)`

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2024-04-06 12:08:23 +09:00
Jinny You
62e7f0a7c6 test/lottie: added the slot resetting use case 2024-04-06 12:08:23 +09:00
Hermet Park
3cb8c4311d lottie/property: code refactoring
introduce the release() method for memory freeing.
This method can be used for any demands.
2024-04-06 12:08:23 +09:00
JunsuChoi
727b699223 loader/lottie: Prevent leak memory when image load fails
When image data fails to load or image parsing fails,
the id is leaked without being assigned to the name.
To prevent that, free id value when obj is nullptr.

related issue: https://github.com/thorvg/thorvg/issues/2072
BrokenLottie.7z/test3_IDX_130_RAND_18289244608080059871.json
BrokenLottie.7z/test3_IDX_131_RAND_7772102071213376276.json
BrokenLottie.7z/test3_IDX_132_RAND_3072617087893397532.json
BrokenLottie.7z/test3_IDX_134_RAND_17738488813555566674.json
BrokenLottie.7z/test3_IDX_137_RAND_13903188963759129023.json
BrokenLottie.7z/test3_IDX_138_RAND_1645404078965858130.json
2024-04-06 12:08:23 +09:00
Jinny You
d5af1e3b67 lottie: Added gradient population preventing logic
`LottieGradient.populate` function checks whether the value has already been calculated and populated via the flag `populated`.
2024-04-06 12:08:23 +09:00
RuiwenTang
ed146ed162 gl_engine: make stencil task support other advance logical
* Support rendering Gradient in path Stroke mode
* Fix GlStencilCoverTask not support even-odd fill rule
* Make GlStencilCoverTask can discard overlapped area during stroke
  rendering
2024-04-06 12:08:22 +09:00
Hermet Park
a4d169d4af examples/lottie: do not scan samples recursively.
lottie/extensions will be only accessed by LottieExtension
2024-04-06 12:08:22 +09:00
Rafał Mikrut
71f596b173 Better regression testing 2024-04-06 12:08:22 +09:00
Hermet Park
2dd41e8632 examples: ++sample svg resource 2024-04-06 12:08:22 +09:00
JunsuChoi
4ec76144dc loader/svg: Remove duplicate if-check in pathAppendArcTo
The if-check to skip-rule when drawing an arc path is already checked in line 476.
In addition, since the float type equal check is performed in the range of 1/256,
unintentional skiped may occur. Therefore, remove duplicate code.
https://www.w3.org/TR/SVG2/paths.html#ArcOutOfRangeParameters

test file: SVG_FILE_147893.svg
related issue: https://github.com/thorvg/thorvg/issues/1255
2024-04-06 12:08:22 +09:00
Sergii Liebodkin
4d2440cc70 wg_engine: stroke first
[issues 1479: strokes](#1479)

Introduced order setting

    auto star = tvg::Shape::gen();
    star->fill(80, 80, 80);
    star->moveTo(599, 34);
    star->lineTo(653, 143);
    star->lineTo(774, 160);
    star->lineTo(687, 244);
    star->lineTo(707, 365);
    star->lineTo(599, 309);
    star->lineTo(497, 365);
    star->lineTo(512, 245);
    star->lineTo(426, 161);
    star->lineTo(546, 143);
    star->close();
    star->strokeWidth(10);
    star->strokeJoin(tvg::StrokeJoin::Round);
    star->strokeFill(255, 255, 255);
    star->order(true); // stroke first
    if (canvas->push(std::move(star)) != tvg::Result::Success) return;
2024-04-06 12:08:22 +09:00
JunsuChoi
c4da341f4b lottie: Prevent memory leak when file is invalid
When json file is invalid in the parser,
the LottieComposition object is not released and the parse() returns false.
To prevent memory leaks, free the memory before returning false.

related issue : https://github.com/thorvg/thorvg/issues/2070
2024-04-06 12:08:22 +09:00
Hermet Park
25645e087a renderer: ensure paints retain composition context
This commit addresses an issue where paints lost their
composition context when drawings occurred without any updates.

Now, paints will consistently retain the composition context,
ensuring accurate rendering.

Issue: https://github.com/thorvg/thorvg/issues/2058
2024-04-06 12:08:22 +09:00
Hermet Park
3dbe535f38 examples: refactored the examples directory
reorganized the resources folder,
distributing contents into categorized subfolders:
SVG, Lottie, Image, Font, and TVG.
2024-04-06 12:08:22 +09:00