Commit graph

2507 commits

Author SHA1 Message Date
Hermet Park
663d0abda4 lottie: fix potential memory leaks.
memory could be leaked during the slot property overriding.
2024-03-08 14:22:38 +09:00
Jinny You
881e1d08fe lottie/api: specify clear result for override API
In case the given JSON is invalid, it's more closed to `Result::InvalidArguments`.
2024-03-08 14:22:25 +09:00
Hermet Park
16215c16dc renderer/loader: revamping the caching mechanism.
The previous loader cache mechanism encountered a problem
when the user changed the content of the cached data.

In such cases, a new request would not be processed
because the renderer would use the previously cached content.

So far, the TVG cache mechanism utilizes a pointer hash key
for the fastest hashing mechanism available.
One limitation is that it assumes the address is unique for the data.

To resolve this, we modified the caching policy.
Now, the renderer will not cache copied data;
it will only cache the given data when it is deemed shareable.

issue: https://github.com/thorvg/thorvg/issues/2020
2024-03-08 14:21:58 +09:00
Jinny You
ecf030d650 capi: added missing lottie header
Currently, the Lottie Animation API is not working due to the missing header.
2024-03-08 14:20:04 +09:00
Mira Grudzinska
4c8ceb3e0f sw_engine: fix a regression bug
After introducing the length measurement
of approximate and exact Bezier curves in
a8c0030d80
the calculation of the outline length still
used the approximate functions, while further
calculations took the exact value into account.
This discrepancy led to the creation of artifacts.

@Issue: https://github.com/thorvg/thorvg/issues/2021
2024-03-08 14:19:52 +09:00
Hermet Park
e29ee085e9 sw_engine: fix a regression bug.
stroke line drawing has been broken at a certain case,
this reverts a part of change from the old optimization:

d81f5d29fb

note that this change wouldn't affect any performance.

issue: https://github.com/thorvg/thorvg/issues/2015
2024-03-08 14:19:41 +09:00
Hermet Park
f606903470 lottie: code refactoring.
Maintains compact lines of code and functions without altering logic,
consistently prioritizing simplicity in software complexity metrics.
2024-03-08 14:19:34 +09:00
Hermet Park
3b6b538a19 lottie: copy the data only necessarily. 2024-03-08 14:19:27 +09:00
Hermet Park
5abe777118 saver: ++robustness
do not delete the given picture if the reference counting is
more than 0.
2024-03-08 14:19:21 +09:00
Mira Grudzinska
b476cc712d common: Changing the rounded rect starting point
According to the SVG standard, drawing a rectangle
starts at (x+rx, y) point. Till now it was (x+w, y+ry).
The difference was visible only for dashed strokes.
2024-03-08 14:19:14 +09:00
Mira Grudzinska
d25c56eae8 common: Changing the circle/ellipse starting point
According to the SVG standard, drawing a circle/ellipse
should start at the '3 o'clock' position and proceed
in a clock-wise direction. Until now, this point was
set at '12 o'clock'.
The differences in the outcome were visible for dashed
strokes.

issue: https://github.com/thorvg/thorvg/issues/1686
2024-03-08 14:19:07 +09:00
Mira Grudzinska
fb721037b2 lottie: use internal append rect/ellipse func
The lottie format defines the starting point for
drawing rectangles and ellipses differently than
the API available in the TVG. In the case of using
dashes or trim paths, this leads to discrepancies.
Therefore, when using the lottie builder, internal
functions for appending rectangles and circles are
utilized.

@issue: https://github.com/thorvg/thorvg/issues/1997
2024-03-08 14:18:59 +09:00
Hermet Park
a9fe9082c9 binding/capi: support lottie extensions
these experimental apis are allowed to use
when the lottie loader is enabled.

APIs:
- Tvg_Animation* tvg_lottie_animation_new()
- Tvg_Result tvg_lottie_animation_override(Tvg_Animation* animation, const char* slot)
2024-03-08 14:18:50 +09:00
Hermet Park
db434a5632 lottie: clean up code and minor bugs by mistake. 2024-03-08 14:18:38 +09:00
Jinny You
ff8f280b43 examples: Added lottie advanced features example 2024-03-08 14:18:25 +09:00
Jinny You
ded1a08d02 lottie: Introduce the LottieAnimation class
This class extends the Animation and serves advanced Lottie features.
It's designed to separately have Lottie Animation's unique specs.

For now, this will have Slot overriding feature,
you can include <thorvg_lottie.h> for its extensive features.

@APIs:
- Result LottieAnimation::override(const char* slotJson) noexcept;
- static std::unique_ptr<LottieAnimation> LottieAnimation::gen() noexcept;

@Issue: https://github.com/thorvg/thorvg/issues/1808
2024-03-08 14:17:16 +09:00
Jinny You
59eecf5574 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-03-08 14:16:42 +09:00
Jinny You
e398dfd34d lottie: Revise the solid model
To ensure consistent properties, `LottieSolid` has been defined.

Both `LottieSolidStroke` and `LottieSolidFill` can be typecasted to the `LottieSolid`.
2024-03-08 14:14:03 +09:00
Jinny You
abf9cebe06 lottie: Revise the gradient model
Currently, the `LottieGradient` does not incorporate the `LottieObject` functionality.

It now inherits from the `LottieObject`.
2024-03-08 14:13:59 +09:00
Hermet Park
f63ce3ba3d lottie: introduced LottieProperty base class
this is useful for slot & expression type casting.
2024-03-08 14:13:52 +09:00
Hermet Park
cc57ffb974 common/array: code refactoring
Make the array interface pair begin()/end() for consistency.
2024-03-08 14:13:48 +09:00
Hermet Park
adbc929ced bump up version 0.12.6 2024-02-23 12:26:46 +09:00
Hermet Park
d9120b9dee examples: ++threading stability.
Ensure synchronous calls are made after updating the canvases.
2024-02-23 12:26:46 +09:00
Vincent Torri
c1ea9d4585 Lottie loader: fix compilation on windows
strlen() was used in tvgLottieModel.h without the inclusion of
cstring. This patch fixes this
2024-02-23 11:45:11 +09:00
JunsuChoi
a92633e1d8 svg: Improve valid check for url(#id)
Improve parenthesis checking and space checking.
 - There must be only one pair of parentheses.
 - There cannot be spaces(and ') between id strings.

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

Co-authored-by: Hermet Park <hermet@lottiefiles.com>
2024-02-23 11:45:05 +09:00
Mira Grudzinska
f14d4168e9 sw_engine: Increasing accuracy for dashed curves
Dashed curves require greater precision in calculating
their lengths and while splitting Bezier curves.
Otherwise, it results in visual discrepancies compared
to the expected outcomes.
Approximate functions 'bezLengthApprox' and 'bezAtApprox'
used for calculations in the lottie loader.

issue: https://github.com/thorvg/thorvg/issues/1686
2024-02-23 11:44:29 +09:00
Mira Grudzinska
cdc7fca9b5 sw_engine: fixing stroke outline
In the case of non-uniform scaling for
thick strokes, artifacts were visible.
The calculations took into account the angle
resulting from the already transformed points,
whereas the untransformed points should have
been considered - the transformation is taken
into account in the next step.

@issue: https://github.com/thorvg/thorvg/issues/1915
2024-02-23 11:44:22 +09:00
Hermet Park
5c130c6848 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-02-23 11:44:09 +09:00
Hermet Park
9e4331fe5c loader/webp: do not expose webp apis.
this reduces the bin size around -1.5kb
2024-02-23 11:40:33 +09:00
Hermet Park
1c4a25cb4a lottie: remove the duplicated binary search logic. 2024-02-23 11:40:24 +09:00
JunsuChoi
92200449e8 loader/svg: Fix empty id to null
empty id is invalid. Therefore, set it to null and make it is not used.

issue: https://github.com/thorvg/thorvg/issues/1977
2024-02-23 11:40:16 +09:00
Martin Capitanio
a5cc5a3894 Portability: Fix compiler shadowing warning 2024-02-23 11:39:47 +09:00
Hermet Park
9c8eeaab96 bump up version 0.12.5 2024-02-07 20:41:08 +09:00
Hermet Park
0fb1acdc70 webp: removed non-existing symbol methods. 2024-02-07 20:40:53 +09:00
Hermet Park
a39e70fb88 loaders: enhance decoding efficiency
enhance decoding efficiency by determining the desired canvas format
during image loading. This allows loaders to preemptively decode
the image in the specified format, to not convert the format again.
2024-02-07 20:40:53 +09:00
Hermet Park
886b6b365b loaders: decode the image with premultiplied alpha.
basically, the renderer requires images with premultiplied alpha.
2024-02-07 20:40:53 +09:00
Hermet Park
ccb5a5d1fb Revert "lottie: compatibility++"
This reverts commit c89f6253bf.

No more valid by 3f235d9e3f
2024-02-07 20:40:53 +09:00
Hermet Park
040de02cef renderer/loader: enhance picture format compatibility
Attempt to load a given file/data using candidate formats
when the desired loader fails. This approach will enhance
the compatibility with various file formats in unexpected scenarios.

Previously, we had removed this feature, but have since
recognized its necessity due to the impact on file data
in specific corner cases.
2024-02-07 20:40:53 +09:00
Junsu Choi
ce7f4cb7c3 loader/webp: Support static webp loader
Built to libwebp code in to support the static option of webp loader.
Code from :https://github.com/jacklicn/libwebp

This forking version only contains the minimal webp decoding feature.

Binary Size: +68kb

Co-authored-by: Hermet Park <hermet@lottiefiles.com>

issue: https://github.com/thorvg/thorvg/issues/1427
2024-02-07 20:40:50 +09:00
Hermet Park
27fa576884 sw_engine: Improve image up-scaler quality
Adjusted the sampling position basis by -0.5 pixel
to enhance edge line interpolation quality.

This change addresses an issue with the image up-scaling process,
resulting in clearer and more accurate visuals.

issue: https://github.com/thorvg/thorvg/issues/1949
2024-02-07 20:35:34 +09:00
Hermet Park
bf4654a991 renderer: ensure canvas rendering continues despite invalid scene parts
Previously, the logic was set to halt rendering when any part of the paints,
particularly bitmap-based images, failed to render.

This update modifies the behavior to continue drawing the scene,
allowing for the successful rendering of other elements.

issue: https://github.com/thorvg/thorvg/issues/1951
2024-02-07 20:35:26 +09:00
Hermet Park
331839d493 bump up version 0.12.4 2024-02-02 12:46:19 +09:00
Hermet Park
fc38a4cb24 lottie/parser: shutdown a compiler warning.
corrected a data type.
2024-02-02 12:46:19 +09:00
Hermet Park
4b33721738 examples: updated DirectUpdate sample
Properly guide a sample usage to guarantee the sync call.
2024-02-02 12:30:24 +09:00
Hermet Park
1748b59257 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-02-02 12:15:27 +09:00
Hermet Park
684a0140ba lottie: fix a simple mistake. 2024-02-02 12:15:27 +09:00
Hermet Park
6077e071d4 renderer: code refactoring.
removed unnused return value.
2024-02-02 12:15:27 +09:00
Hermet Park
f9316fac49 renderer: destroy engines safely.
Introduced a reference count to destroy it safely.
2024-02-02 12:15:27 +09:00
Hermet Park
c2fa4a728b renderer: revise the internal logic.
dispose of the resources at the end of the paint deletion.
This will help retain the resources of the retained paints
and reuse them after reconstructing the next scene.
2024-02-02 12:15:24 +09:00
Hermet Park
dd48a4155e renderer: code refactoring.
replaced references with pointers to ensure consistency.
no logical changes.
2024-02-02 11:56:58 +09:00