Commit graph

845 commits

Author SHA1 Message Date
Hermet Park
97240a893a lottie: clean up code and minor bugs by mistake. 2024-04-06 12:08:21 +09:00
Jinny You
c8a7e5b02e 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-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
Vincent Torri
da6199a2bd Lottie loader: fix compilation on windows
strlen() was used in tvgLottieModel.h without the inclusion of
cstring. This patch fixes this
2024-04-06 12:08:21 +09:00
Jinny You
447a3d8ad5 lottie: Revise the solid model
To ensure consistent properties, `LottieSolid` has been defined.

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

It now inherits from the `LottieObject`.
2024-04-06 12:08:21 +09:00
JunsuChoi
c6cf9cb2cf 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-04-06 12:08:21 +09:00
Hermet Park
fe6493351a lottie: introduced LottieProperty base class
this is useful for slot & expression type casting.
2024-04-06 12:08:21 +09:00
Hermet Park
c08c11db7d common: code refactoring
refactor common code to consolidate Bezier and line
function implementations into a single location.
2024-04-06 12:08:21 +09:00
Hermet Park
71c636e33c Revert "Revert "sw_engine: Increasing accuracy for dashed curves""
This reverts commit e49f9125b2.
2024-04-06 12:08:21 +09:00
Hermet Park
c01c8338d7 Revert "sw_engine: Increasing accuracy for dashed curves"
This reverts commit a8c0030d80.
2024-04-06 12:08:21 +09:00
Mira Grudzinska
d399ae922a 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-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
aa07e98c7b loader/webp: do not expose webp apis.
this reduces the bin size around -1.5kb
2024-04-06 12:08:21 +09:00
Hermet Park
e559388f63 lottie: remove the duplicated binary search logic. 2024-04-06 12:08:21 +09:00
JunsuChoi
b400512fda 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-04-06 12:08:21 +09:00
Hermet Park
baf04d1cde webp: removed non-existing symbol methods. 2024-04-06 12:08:21 +09:00
Hermet Park
c64ed2ec03 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-04-06 12:08:21 +09:00
Hermet Park
c4e6b03b84 loaders: decode the image with premultiplied alpha.
basically, the renderer requires images with premultiplied alpha.
2024-04-06 12:08:21 +09:00
Hermet Park
5d892c241c Revert "lottie: compatibility++"
This reverts commit c89f6253bf.

No more valid by 3f235d9e3f
2024-04-06 12:08:21 +09:00
Junsu Choi
e0eeaf54b0 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-04-06 12:08:18 +09:00
Hermet Park
6fa5a2a690 lottie/parser: shutdown a compiler warning.
corrected a data type.
2024-04-05 17:47:13 +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
7c46b09bae lottie: fix a simple mistake. 2024-04-05 17:47:00 +09:00
Hermet Park
025104b64d lottie: minor optimization.
remove an unnecessary scene in the lottie render tree.
2024-04-05 17:42:20 +09:00
Hermet Park
816afc6a27 lottie: compatibility++
retry image loading with the given candidates,
even if the suggested format is mismatched.
2024-04-05 17:42:12 +09:00
Hermet Park
2aa2ac7e5c lottie: corrected text height alignment issues.
enhanced support for a wider range of text use cases.
2024-04-05 17:41:37 +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
JunsuChoi
9371c046e6 loader/svg: Fix zero check of arc's rx and ry
Please refer to the specifications.
https://www.w3.org/TR/SVG/paths.html#ArcOutOfRangeParameters

If either rx or ry is 0, then this arc is treated as a straight line
segment(a "lineto") joining the endpoints.
2024-04-05 17:39:19 +09:00
JunsuChoi
ddfe877591 loader/svg: Apply specification of out-of-range elliptical arc parameters
The three specifications below apply.

Specification: https://www.w3.org/TR/SVG/paths.html#ArcOutOfRangeParameters

-
If the endpoint (x, y) of the segment is identical to the current point
(e.g., the endpoint of the previous segment),
then this is equivalent to omitting the elliptical arc segment entirely.

-
If either rx or ry is 0, then this arc is treated
as a straight line segment(a "lineto") joining the endpoints.

-
If either rx or ry have negative signs, these are dropped;
the absolute value is used instead.
2024-04-05 17:39:12 +09:00
Hermet Park
c01757fe17 lottie: rectified scene building Logic
resolved a corner case where assets were being attached
multiple times during scene building. This issue was causing
a significant performence drop in image animation
in certain scenarios.
2024-04-05 17:38:57 +09:00
Hermet Park
fbf1e97c27 lottie: fixed an issue with missing stroke drawing
Resolved a problem where the context was missing in scenarios
involving an overlapped stroke drawing.

issue: https://github.com/thorvg/thorvg/issues/1933
2024-04-05 17:38:45 +09:00
Hermet Park
9972fa9831 svg_loader: code refactoring
removed duplicate matrix multiply function.
2024-04-05 17:37:39 +09:00
Mew Pur Pur
d23e0fd22c svg_loader: Add missing implementation of skewX and skewY in transform-list 2024-04-05 17:37:33 +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
3c98cb5828 lottie: Fixed the issue with gradient filling.
Previously, multiple gradients within a single group
couldn't be accounted for during rendering.

This fix addresses the scenario by fragmenting the rendering context.
2024-04-05 17:28:08 +09:00
Hermet Park
5b89479963 lottie: properly capture the stroking context
Each group must determine the stroking rendering contexts
and assess whether context switching has occurred.

Migrate the sequence from the root layer to all groups.
2024-04-05 17:28:08 +09:00
Hermet Park
8b26f8b7ea lottie: Corrected the Time Remapping Range (#1907)
enable exceeding the range of normalized values in time remapping.

the issue came from a misunderstanding of the lottie spec.

issue: https://github.com/thorvg/thorvg/issues/1809
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
Hermet Park
a078f14bb3 loader: code refactoring
Ensure scene data is freed when it's dangled in the loader.
2024-04-05 17:21:18 +09:00
Hermet Park
29a0469e1c ttf: Fixed an invalid unicode encoding.
Ensured the data count is correctly multiplied by the data size.
2024-04-05 17:20:38 +09:00
JunsuChoi
7220ebba3c loader/svg: Skip check for quotes inside quotes
Single or double quotation marks that occur before
closing the quotation mark are ignored.
2024-04-05 17:20:32 +09:00
Hermet Park
cf76f2f604 ttf: removed the beta tag.
incorporate TTF support into the CI build tests.
2024-01-03 11:52:23 +09:00
Hermet Park
8c3c2ab652 ttf: fix the windows compilation errors. 2024-01-03 11:52:18 +09:00
Hermet Park
ab744fc164 svg: ensure that all allocated memory.
observed a memory leak at a corner case.
2024-01-02 20:34:12 +09:00
Hermet Park
38c625d070 renderer: enhanced shared surface handling with mutex implementation
Introduced a dedicated mutex for each surface instance
to ensure safe sharing between the loader, renderer, and engine.

This enhancement allows for secure modification and access to bitmap data,
addressing potential concurrency issues.

Multiple Picture instances can now safely share a single loader instance,
optimizing performance.

This change builds upon the previous Loader Cache improvements:
ff6ea4b6c4
2024-01-02 20:34:12 +09:00
Hermet Park
102414d56f lottie: resolve a thread sanitizer report.
Issue: https://github.com/thorvg/thorvg/issues/1874
2024-01-02 20:34:12 +09:00
Hermet Park
60282f51f8 renderer/loader: code refactoring.
Removed internal unique_ptr usage for a more compact size.
2024-01-02 20:34:12 +09:00
Hermet Park
4997f55e6c Revert "svg: removed an unnecessary nested scene."
A regression bug is occured.
clipper is also required to be transformed with loader->resize()...

This reverts commit e62a8668e7.
2024-01-02 20:34:12 +09:00