Commit graph

61 commits

Author SHA1 Message Date
Mira Grudzinska
ae90a9f18b 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-07 10:43:17 +09:00
Hermet Park
1823305ea3 lottie: try packing data compactly. 2024-05-31 11:01:29 +09:00
Hermet Park
71e3124469 lottie: optimize the internal data
encode the object name with the hash value
to save memory and enable fast data comparison.
2024-05-31 11:01:23 +09:00
Hermet Park
53818b41f2 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-05-31 11:01:17 +09:00
Mira Grudzinska
e69cc2b936 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-05-31 11:00:33 +09:00
Mira Grudzinska
dfe8570830 lottie: implement skew transformation
Added support for skew transformation by
a specified angle around a specified axis.
Applied to layers and shapes, not to repeaters.

@Issue: https://github.com/thorvg/thorvg/issues/2262
2024-05-17 11:05:51 +09:00
Jinny You
3fdd699a76 lottie/text: Support text tracking
Text Tracking value("tr") is parsed and never used.

Calculate text spacing size via the tracking offset.

Issue: #2254
2024-05-10 11:16:21 +09:00
Hermet Park
25c0f32e8a lottie/expressions: enhance stability
When the system fails to interpret the expression code,
it forcibly disables the feature per property.

This improvement enhances stability and performance
by avoiding reckless attempts to interpret JavaScript code.

When we confirm the full stability with expressions,
we can revert this code.
2024-05-10 11:12:12 +09:00
Hermet Park
289aada0fd lottie: support the expression feature
The current development of the expression engine is experimental.
It does not support multi-threading.

Therefore, when tvg::Initializer::init() is configured
with more than one thread, expressions will be automatically disabled.

issue: https://github.com/thorvg/thorvg/issues/1640
2024-05-10 10:46:21 +09:00
Hermet Park
9e6a837125 lottie: specify the explicit parsing type.
these explicit type values are expected
to be referenced by the expressions.
2024-05-10 10:41:59 +09:00
Hermet Park
1ccf14808b lottie: generalize parent context access in parsing.
ensure parent context is generally accessible,
not limited to gradients.
2024-05-10 10:41:53 +09:00
Hermet Park
025e88fe25 lottie: code refactoring.
make it neat and clean.
2024-04-19 11:00:29 +09:00
Lucas Niu
5992a28e47 lottie: Support the Animation Segment(Marker)
A single animation might have a desinated markers with naming: 0 ~ 0.5 (sector A), 0.5 ~ 1.0  (sector B). Selecting one of them using a marker name(sector A) and could play only that part with animation controllers.

usage:
- `animation->segment("sectionA") // Named segment(Marker)`
- `auto cnt = animation->markerCnt()`
- `auto name = animation->markers(index)`
- `animation->segment(0, 0.5) // Segment`
- `animation->segment(&begin, &end)`

Co-authored-by: Jinny You <jinny@lottiefiles.com>
2024-04-19 11:00:29 +09:00
Hermet Park
d54a23dd7f lottie: corrected the comp/layer size data type.
Actually, the these size is expected to be a floating-point value.
This correction addresses a parsing error.

issue: https://github.com/thorvg/thorvg/issues/2153
2024-04-19 10:34:48 +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
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
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
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
b1ab52f89e lottie: fixed a compiler warning:
error: storing the address of local variable 'context' in '*this.LottieParser::context' [-Werror=dangling-pointer=]
 1255 |     this->context = &context;

issue: https://github.com/thorvg/thorvg/issues/2051
2024-04-06 12:08:21 +09:00
Jinny You
7f2cd1090c lottie/slot: Support overriding plural sids
Previously, slot overriding only works in single sid, the others are ignored.

This patch enables slot overriding for all sids within a single slot.
2024-04-06 12:08:21 +09:00
Jinny You
5ed068cec3 lottie: Support the slot overriding feature
Internal model and parser modifications have been made
to parse "sid" and retrieve their data into the LottieComposition.
This will enable dynamic changes to the following Lottie objects:

The slot feature will encompass these properties:

- LottieSolidStroke
- LottieSolidFill
- LottieGradientStroke
- LottieGradientFill
- LottieTextDoc"

Issue: https://github.com/thorvg/thorvg/issues/1808

Co-authored-by: Hermet Park <hermet@lottiefiles.com>
2024-04-06 12:08:21 +09:00
Hermet Park
6b63c85404 lottie/parser: clean up the exception handling mechanisms.
Since the parser has become stable enough,
remove the exceptions and instead rely on parser error handling.
2024-04-06 12:08:21 +09:00
Hermet Park
b0540929e5 common/array: code refactoring
Make the array interface pair begin()/end() for consistency.
2024-04-06 12:08:21 +09:00
Hermet Park
ce8c5c0038 lottie: fixed a parsing error in assets
An unused key in assets parsing corrupted the sequence.
This change now ensures they are tightly ignored.
2024-04-05 17:47:06 +09:00
Hermet Park
bed2749c18 lottie: Fixed a font/glyph parsing error.
Previously, the Lottie parser expected a specific parsing order:
font followed by glyph, for optimal data processing.

However, since this order is not guaranteed,
we have revised the parsing logic to accommodate any order.
2024-04-05 17:41:32 +09:00
Hermet Park
27d85f5861 lottie: Improve feature coverage by correctly handling XOR shapes
XOR when the shape's direction property is set to a value of 2.
Currently, the direction property is expected to have
either 1 for clockwise or 3 for counterclockwise orientation.

Just found out the number 2 use-case...
2024-04-05 17:28:08 +09:00
Hermet Park
388631be68 lottie: Newly added support for the text feature.
This enhancement enables embedded glyphs rendering.
The 'fonts' and 'chars' properties are now supported.
2024-04-05 17:28:05 +09:00
Jinny You
92288c8291 updated copyright date (#1866) 2024-01-02 20:34:12 +09:00
Hermet Park
bbf3cec2cc common/array: code refactoring.
Use a default constructor with reservation.
2024-01-02 20:34:10 +09:00
Jinny You
118516f015 lottie/builder: fix crash by null reference 2024-01-02 20:34:10 +09:00
Hermet Park
b87bb2b1a0 lottie/parser: Fix the shapes parsing logic.
Currently, it assumes "ty":"gr" for the related shapes children,
which can be skipped since the children will be in the "it" scope.

Some Lottie data is missing the "ty":"gr" field,
and ThorVG couldn't display the content properly.
It can ignore it with the context understanding.
2023-12-26 18:36:38 +09:00
Hermet Park
5129b05023 lottie/parser: ++ blending options
thorvg blending is quite buggy,
the feature needs a verification.
2023-12-26 18:24:21 +09:00
Hermet Park
aa4c186cd2 lottie: introduced static layer cache.
lottie builder doesn't need to rebuild the layer object
if it has no any animation frame data.

That case, we can cache the layer scene in order to reuse it.

Tested on local machine (single thread):
- Lottie: appx. 2ms enhanced.
- Binary: +204
2023-12-26 18:01:30 +09:00
Hermet Park
fce2e404d3 lottie: clean up code
no logical changes, only code clean-up
2023-12-26 17:53:31 +09:00
Hermet Park
0832a188fe animation/lottie: updated the frame count unit.
replace the frame count unit from the int32_t to float
since animations could smoothly interpolate key-frames.

This notificably improve the animation smoothness in Lottie

Beta API changes:
Result Animation::frame(uint32_t no) -> Result Animation::frame(float no)
uint32_t Animation::curFrame() const -> float Animation::curFrame() const
uint32_t Animation::totalFrame() const -> float Animation::totalFrame() const
2023-12-26 17:51:53 +09:00
Hermet Park
ec5a32bb73 lottie: enhanced the colorstop feature.
Lottie ColorStop RGB / Alpha can be dealt with individually.
Since thorvg handles this one unified set,
lottie model need to merge the data into one structure.
2023-09-21 22:11:31 +09:00
Hermet Park
549f4b1308 loader/lottie: properly handle graident opacity attributes.
That property has been missed in the implementation.
2023-09-19 10:33:22 +09:00
Hermet Park
1bcbac71ab loader/lottie: fix a invalid matte source access.
parser ignored a matte source has no target.
this fixes the corner case.
2023-09-13 13:16:13 +09:00
Hermet Park
e14e108d4a loader/lotte: ++clean code 2023-09-08 15:01:28 +09:00
Hermet Park
516e8bf042 loader/lottie: minimum support for 3D transform
It lacks perspective projection information,
so it transforms 3D axes with orthogonal projection.
2023-09-07 17:59:52 +09:00
Hermet Park
a49ac81543 loader/lottie: support the repeater property 2023-09-07 12:17:16 +09:00
Hermet Park
dae6636d29 loader/lottie: filled a missing gradient stroke dash body. 2023-09-05 18:41:20 +09:00
Hermet Park
ac8f3b8be6 loader/lottie: support hold interpolation. 2023-09-04 11:16:01 +09:00
Hermet Park
ad9d9d0ecd loader/lottie: support trimpath feature 2023-09-01 13:16:18 +09:00
Hermet Park
7c669f622f loader/lottie: enhanced the coverage of the rounded corner feature.
Rounded corners should now be applied not only to rectangles
but also to path strokes. This enhancement changes the stroke join style
to round when a rounded corner is present.

Indeed, rounded corners ensure the accurate calculation of roundness based on the join style.
However, this patch has not yet been designed to handle it.
2023-09-01 13:16:18 +09:00
Hermet Park
c23c556f61 loader/lottie: fix a default color of the solid layer.
we assume the default color is black.
before this fix, the value is not designated properly.
2023-08-30 17:46:32 +09:00
Hermet Park
ce5ac1c114 loader/lottie: fix a crash issue caused by incorrect gradient alpha handling.
This fix addresses the interpretation of gradient alpha values,
preventing a potential crash due to invalid memory access.
2023-08-30 17:46:27 +09:00
Hermet Park
7b40c741ac loader/lottie: correct a polystar transform.
Properly propagate the transform information to the merged shapes.
This corrects the incorrect transformation applied to the subsequent shapes.
2023-08-24 10:57:38 +09:00
Hermet Park
994c1b99a5 lottie/loader: support the masking features.
Enhancing the basic masking options by providing additional support.
2023-08-17 23:03:37 +09:00