Commit graph

845 commits

Author SHA1 Message Date
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
Hermet Park
b94c30675c lottie/builder: revise the masking update.
Append the mask shape to the previous one, instead of composition,
when it's able by the condition.

issue: https://github.com/thorvg/thorvg/issues/2426
2024-09-30 12:46:40 +09:00
Hermet Park
74cd0ba0e7 common: code refactoring
replaced min/max with the standard library
2024-09-30 12:45:14 +09:00
Hermet Park
fad80deceb lottie: remove exception handling
don't stop the parsing when the data type is incorrect.
just let it slide.

issue: https://github.com/thorvg/thorvg/issues/2389
2024-09-30 12:42:17 +09:00
Hermet Park
dfa2b78ad8 lottie/rapidjson: --assert
Save binary size about 0.8kb
2024-09-30 12:42:10 +09:00
Josh Soref
e3c66db301 common: fix 178+ spelling errors 2024-09-30 12:41:38 +09:00
Vincent Torri
ab7ff34674 json loader: fix warnings in jerryscript on Windows 2024-09-30 12:37:03 +09:00
Hermet Park
f3469350b9 lottie: fix a data-race problem
make it sync call before accessing the composition data
from marker and segments.

issue: https://github.com/thorvg/thorvg/issues/2462
2024-06-27 14:42:27 +09:00
Hermet Park
933176e309 lottie: hotfix for preventing a crash.
MaskMode=None is not properly addressed,
Prevent the crash from the use-case.

issue: https://github.com/thorvg/thorvg/issues/2426
2024-06-27 14:42:27 +09:00
Hermet Park
a0c6025132 lottie: fix a compile error on MSC with clang.
issue: https://github.com/thorvg/thorvg/issues/2347
2024-06-27 14:42:27 +09:00
Mira Grudzinska
d9326921fa lottie: fix repeater order
Assigning numbers 1 or 2 to a bool always
resulted in true. Now fixed and repeated
shapes are drawn in the proper order.
If the repeater had no elements, iterating
shapes from the end would result in a segf.
This issue is now fixed.
2024-06-24 14:56:31 +09:00
Mira Grudzinska
ec77d8bd89 ttf_loader: support loading from memory
New text API for loading fonts from memory
is introduced. This is necessary to enable
embedded fonts support.
2024-06-24 14:50:13 +09:00
Mira Grudzinska
70c2260cfb svg_loader: handle text node
The text node is handled, but default values
of the font-family and font-size as used in
the user's system are not.
For now font has to be loaded by the user.

@Issue: https://github.com/thorvg/thorvg/issues/2350
2024-06-24 14:44:52 +09:00
Jinny You
8a1a3e54ee lottie: Add exception for lottie doesn't have exported glyph
Added handling logic for missing characters to prevent program hang.
2024-06-24 14:42:33 +09:00
Jinny You
2f26dc33a9 lottie: Fix invalid font match
When Lottie has similar font names, it incorrectly matches fonts due to a logic bug.

This error causes an infinite loop when searching for glyphs.
2024-06-24 14:42:19 +09:00
Mira Grudzinska
e6f4b5a2a8 common: strokeTrim api introduced
New api sets/gets the trim of the stroke
along the defined path segment, allowing
control over which part of the stroke is
visible.

@issue: https://github.com/thorvg/thorvg/issues/2190
2024-06-24 14:37:53 +09:00
Mira Grudzinska
bdd506bbb8 lottie: fix matte layer finding
Layer identifiers do not have to be unique within
the entire file - they are unique within a given
group. Searching the entire composition to find
the referenced matte was an incorrect approach.

Error introduced by 1ee79a6c2a

@Issue: https://github.com/thorvg/thorvg/issues/2349
2024-06-24 14:37:29 +09:00
Martin Capitanio
839ffe40c6 svg_loader: Add embedded webp mime type
Fixes loading _webp_ images embedded in SVG.
2024-06-24 14:37:09 +09:00
Mira Grudzinska
f14be7c33b common: fix typos & remove unused var 2024-06-24 14:36:43 +09:00
Mira Grudzinska
5e9b07ea54 lottie: parsing obj property inside this obj
Shape's property 'direction' should be parsed
together with other properties specific for
the shape. This solves the issue with direction-
it wasn't working.
2024-06-24 14:36:36 +09:00
Hermet Park
d8888923d1 lottie/builder: revise the layer build logic
Promote the text/image updates to the layer level.
2024-06-24 14:36:05 +09:00
Hermet Park
53f2a3f10b lottie: try packing data compactly. 2024-06-24 14:35:40 +09:00
Hermet Park
33883f302d lottie: optimize the internal data
encode the object name with the hash value
to save memory and enable fast data comparison.
2024-06-24 14:35:34 +09:00
Hermet Park
2cc522d9e9 lottie: code refactoring & size reduction
- introduced a pasing logic for duplicates.
- renamed internal varaible, no logical changes.
- removed null checks after memory alloc fails.
- reduced 1kb size.
2024-06-24 14:35:26 +09:00
Hermet Park
37f38c788f lottie: hotfix memory leaks by a regression
A regression bug by a recent change:
1ee79a6c2a
2024-06-24 14:35:09 +09:00
Mira Grudzinska
0e59daafc7 lottie: repeater transformation fix
In the case of a transformation (denoted as T1)
appearing after the repeater, but at the same
level of nesting, the objects to which the repeater
is applied should not consider T1. However,
the transformation of the repeater itself should
take T1 into account.
Also, it is possible to have several consecutive
repeaters, and all of them should be taken into
account. Until now, the last one was overwriting
the previous one.
2024-06-24 14:34:42 +09:00
Mira Grudzinska
b812277a06 lottie: add 'tp' tag support
So far it hasn't been possible to specify
a matte layer - by default, it was the layer
above the calling layer. The 'tp' tag support
has been introduced, enabling referencing any
layer by its index.
In cases where the layer referencing the matte
was the first one, a segmentation fault was
observed. This issue has now been resolved.

@Issue: https://github.com/thorvg/thorvg/issues/2325
2024-06-24 14:34:34 +09:00