Commit graph

921 commits

Author SHA1 Message Date
Hermet Park
9f5a83f067 lottie: ++scene rendering optimization
Apply LottieRenderPooler to maskings.
2024-09-30 15:53:02 +09:00
Mira Grudzinska
49f586b3e7 lottie: handle rounded polygons
The implementation of rounded polygons was
mistakenly omitted, now has been added.

@Issue: https://github.com/thorvg/thorvg/issues/2624
2024-09-30 15:52:55 +09:00
Hermet Park
1317b1690f lottie: support matte+masking combination
introduced an intermediate scene for embracing
the matte and maskings
2024-09-30 15:49:52 +09:00
Hermet Park
e2b99ec308 lottie/expressions: rectified fill color support
Assign the fill color value properly.
2024-09-30 15:49:44 +09:00
Hermet Park
fb6635713e lottie: code refactoring
Moved common data declarations to tvgLottieCommon.h.
2024-09-30 15:49:34 +09:00
Hermet Park
cd1ed24bbe lottie/expressions: revised exception handlings 2024-09-30 15:49:26 +09:00
Hermet Park
b82488a27d lottie/model: implement the missing property() interface 2024-09-30 15:49:20 +09:00
Hermet Park
d1664a162e renderer/picture: added a method to search for a paint object
This utility method allows access to a specific paint instance
by its unique identifier.

Experimental API:
- const Paint* Picture::paint(uint32_t id)
- const Tvg_Paint* tvg_picture_get_paint(Tvg_Paint* paint, uint32_t id)
2024-09-30 15:48:18 +09:00
Hermet Park
6456252b43 API: introduce a Paint ID member as a reserved field
The "id" is a reserved field to specify a paint instance in a scene.
in this change, it assigns the layer id to the lottie scene as well.
2024-09-30 15:48:18 +09:00
Hermet Park
abf3e2d6ae renderer: newly support the Lighten/Darken Masking options
Lighten is applied, where multiple masks intersect,
the highest transparency value is used.

Darken is applied, where multiple masks intersect,
the lowest transparency value is used.

Experimental API:
- CompositeMethod::LightenMask
- CompositeMethod::DarkenMask

issue: https://github.com/thorvg/thorvg/issues/2608
2024-09-30 15:48:18 +09:00
Hermet Park
439124d670 lottie/expressions: add missing expressions property updates
apply expressions to separate x/y transform coordinates.
2024-09-30 15:48:18 +09:00
Hermet Park
17e628d8f7 lottie: remove useless condition check.
lottie is always animatable.
2024-09-30 15:48:18 +09:00
Hermet Park
c9ad7289a6 lottie/expressions: feature enhancement
added groupIndex() support
added property (ix) value support
2024-09-30 15:48:18 +09:00
Hermet Park
fc61fc42c2 lottie: code refactoring
Access its type from a property instance,
through coherent data structure.
2024-09-30 15:48:18 +09:00
Łukasz Pomietło
2b3930b46d ttf_loader: Basic support for composite glyphs loading (#2600)
Adds the ability to load some composite glyphs and prevents an error when a composite glyph is used.

Implementation based on ttf glyf table documentation: https://learn.microsoft.com/en-us/typography/opentype/spec/glyf

There are still some missing features like scaling, parent glyph point based positioning etc. I think this is a topic for future work. Howerever, it looks like implemented features are enough for utf-8 latin subset in major fonts.

issue: #2599
2024-09-30 15:48:13 +09:00
Hermet Park
ecabdc5ebc renderer: code refactoring
Replaced the transformation with
a strong associated data field.

This helps to reduce the binary size (-1k).
2024-09-30 15:39:52 +09:00
Hermet Park
4ed9ada00e lottie/expressions: hotfix
- fixed a memory leak.
- corrected loopIn key value.
2024-09-30 15:38:32 +09:00
Hermet Park
2478a5f65a lottie/expressions: feature support enhancement
- revised the transformation building logic.
- rectified to properly search "this" composition layers.
- rectified the linear interpolation implementation.
- added "pingpong" looping attributes.
2024-09-30 15:38:05 +09:00
Hermet Park
4e3d027fa7 lottie: code refactoring
- removed unnecessary variables.
- migrated the composition methods to the precomp layer.
2024-09-30 15:38:00 +09:00
Hermet Park
7bb4eda3a3 svg: resolve compiler warnings.
../src/loaders/svg/tvgSvgLoader.cpp: In function ‘bool _toColor(const char*, uint8_t*, uint8_t*, uint8_t*, char**)’:
../src/loaders/svg/tvgSvgLoader.cpp:108:17: warning: ‘hue’ may be used uninitialized [-Wmaybe-uninitialized]
  108 |     const char* _end = end ? *end : nullptr;
      |                 ^~~~
../src/loaders/svg/tvgSvgLoader.cpp:713:31: note: ‘hue’ was declared here
  713 |         const char *content, *hue, *saturation, *brightness;
      |                               ^~~
../src/loaders/svg/tvgSvgLoader.cpp:108:17: warning: ‘saturation’ may be used uninitialized [-Wmaybe-uninitialized]
  108 |     const char* _end = end ? *end : nullptr;
      |                 ^~~~
../src/loaders/svg/tvgSvgLoader.cpp:713:37: note: ‘saturation’ was declared here
  713 |         const char *content, *hue, *saturation, *brightness;
      |                                     ^~~~~~~~~~
../src/loaders/svg/tvgSvgLoader.cpp:108:17: warning: ‘brightness’ may be used uninitialized [-Wmaybe-uninitialized]
  108 |     const char* _end = end ? *end : nullptr;
      |                 ^~~~
../src/loaders/svg/tvgSvgLoader.cpp:713:50: note: ‘brightness’ was declared here
  713 |         const char *content, *hue, *saturation, *brightness;
      |                                                  ^~~~~~~~~~
2024-09-30 15:37:52 +09:00
Hermet Park
d7e4fc7d6a lottie: ++optimization with object culling
More precisely, culling the render objects by
determining if the group has no renderable objects.

Additionally, check opacity to quickly return
in the rendering process.
2024-09-30 15:37:40 +09:00
Hermet Park
935d3d83ae lottie: hotfix with an intermediate patch merge. 2024-09-30 15:37:32 +09:00
Hermet Park
7a6d2e0c5a lottie: ++scene rendering optimization
Apply LottieRenderPooler to texts.
2024-09-30 15:37:26 +09:00
Hermet Park
d671f8637b lottie/expressions: ++coverage enhancement
Allow to access layer index globally.
2024-09-30 15:36:24 +09:00
Hermet Park
0b66cd422e lottie/expressions: added a missing polystar property build. 2024-09-30 15:35:59 +09:00
Hermet Park
699063625b lottie: ++scene rendering optimization
Apply LottieRenderPooler to path/rect/ellipse/polystar.

This enhances the animation performance: ~10%
2024-09-30 15:34:57 +09:00
Hermet Park
ba3d2b77a1 lottie: introduced LottieRenderPooler
LottieRenderPooler is designed to manages rendering
instances(paints) efficiently through a simple pooling
mechanism to resuse among the animations

This replaces the previous individusal paints implemenations
among solidfill, precomp vierport and pictures,
also fix a potential paints corruption problems.
2024-09-30 15:33:49 +09:00
Hermet Park
e27b8ddf25 lottie/parser: tiny binary size reduction 2024-09-30 15:30:47 +09:00
Mira Grudzinska
774e4f5156 lottie: support 'direction' in ellipses 2024-09-30 15:30:29 +09:00
Mira Grudzinska
177bae539c lottie: remove unnecessary cast 2024-09-30 15:30:18 +09:00
Hermet Park
12b7c634f7 lottie: clarify shape direction.
There are only two options clockwise or counter-clockwise.
2024-09-30 15:29:22 +09:00
Mira Grudzinska
bba48a8084 lottie: apply direction to rect 2024-09-30 15:29:22 +09:00
Hermet Park
43a5bf2fce lottie: ++ scene composing optimization
retain resuable layer solid paint during animation.
2024-09-30 15:29:22 +09:00
Hermet Park
3adee7238c lottie: ++ scene composing optimization
retain reusable precomp clipper shapes during animation.
2024-09-30 15:29:22 +09:00
Hermet Park
192135835f lottie: ++memory access stability
Internal matrix can be null.
This update prevents such cases by using a safer API.
2024-09-30 15:29:07 +09:00
Jinny You
0953d000c1 lottie/text: Support text range selector (Phase 1)
This patch provides initial support for the text range selector. Full support will be added gradually in subsequent steps. This is the first step.

Text range selector with following properties:
1. Text Range Selector (Units)
2. Text Style
- Fill Color
- Fill Opacity
- Stroke Color
- Stroke Width
- Stroke Opacity
- Opacity
- Rotation
- Position
- Scale
2024-09-30 15:28:24 +09:00
Hermet Park
12d0504a23 common: replace the round() with nearbyint()
nearbyint() is 2x faster than round() in our local test.
2024-09-30 15:24:39 +09:00
Mira Grudzinska
8e78745e2e lottie: improvement 3d rotation
For rotation around the X and Y axes, the transformation
matrix was incorrectly created - elements e12 and e21
were omitted. Now fixed.
2024-09-30 15:23:08 +09:00
Hermet Park
4f58124754 common/math: code refactoring
- migrate tvgLine to tvgMath
- associate line functions with classes.
2024-09-30 15:22:46 +09:00
Hermet Park
c9d1df3957 common/math: code refactoring
Replaced the prefix "math" with "tvg" namespace.
2024-09-30 15:22:38 +09:00
Hermet Park
d3a900701f common/math: introduced custom atan2()
the custom atan2 algorithm by Remez.
see: https://en.wikipedia.org/wiki/Remez_algorithm

This improved the Lottie example by ~2ms.
Total atan2 performance time was reduced by 43%
2024-09-30 15:21:27 +09:00
Hermet Park
aff7f61819 lottie: code refactoring
- _draw() returns boolean whether merging shape is allowed or not.
- renamed some internal variables.
2024-09-30 15:20:54 +09:00
Mira Grudzinska
c64923336d lottie: enhance support for ao: 1
Adding support for auto-orient=true for frames <= first
and >= last, as well as for positions specified without
outer and inner tangent.
2024-09-30 15:20:46 +09:00
Mira Grudzinska
5276663c45 lottie: add support for image size
The width and height of the image must
be specified in the Lottie file and must
be taken into account during rendering.
2024-09-30 15:11:34 +09:00
Hermet Park
69d1d8dcd5 lottie: ++thread safety.
comp pointer is used for checking if the header is ready.
It can be written in a worker thread and needs a critical
section on the reader side.

This also potentally improve the thread efficiency
from the segment() / marker() function calls.
2024-09-30 12:57:08 +09:00
JunsuChoi
3971094377 svg_loader: Fix incorrect stack.pop() call in loader
loader->stack.pop() at line 3271 is called to remove
the defs node added to the stack due to nested graphics elements.
However, it is called in an inappropriate situation and the loader's node tree is damaged.
Fixes an error where the close tag is recognized as a `line` of the graphics tag when it is `linearGradient`.
ex)
```
    <defs id="def">
        <linearGradient x1="1" y1="2" x2="3" y2="4" id="l"/>
        </linearGradient>
        <rect x="10" y="10" width="10" height="10"  fill="blue" id="r2"/>
    </defs>
```

related issue: https://github.com/thorvg/thorvg/issues/2518
2024-09-30 12:56:57 +09:00
Hermet Park
ce50165103 common: Fix a compilation failure on VS 2017
issue: https://github.com/thorvg/thorvg/issues/2512
2024-09-30 12:49:06 +09:00
Hermet Park
359ad22b3a lottie: fix a regression bug of masking
InverseAlphaMasking should be applied as intended,
but it was mistakenly reverted to alpha.

regression in v0.14.0 by: 2c7a83406e
2024-09-30 12:48:50 +09:00
Hermet Park
dd0705eef9 lottie: allow image asset sharing among LottiePicture instances
Previously, the Lottie builder didn't account for image asset sharing
among multiple layers. This update rectifies the situation.

issue: https://github.com/thorvg/thorvg/issues/2428
2024-09-30 12:48:08 +09:00
Hermet Park
98e613e3f0 lottie/parser: optimization++
Skip the data constructuion if the mask mode
is none. it's not used at all.
2024-09-30 12:46:49 +09:00