Commit graph

2518 commits

Author SHA1 Message Date
Hermet Park
d47838a7a9 ttf: enhance UWP portability with alternative file loading
Enhances the portability of the TTF loader on UWP platforms
by implementing an alternative file loading mechanism.

This is designed to support environments where the file mapping
feature is not available, ensuring wider compatibility and reliability
in file handling.

Issue: https://github.com/thorvg/thorvg/issues/1912
2024-03-21 17:05:25 +09:00
Jinny You
4a0ba170e4 lottie: Renamed function names with prefix
Fixed naming conflict in short names.

issue: #2062
2024-03-21 17:05:14 +09:00
Hermet Park
8545cf5ab8 bump up version 0.12.8 2024-03-15 11:29:31 +09:00
Hermet Park
37fbe9dad1 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-03-15 11:28:06 +09:00
JunsuChoi
78dd7a41e6 loader/webp: Remove WEBP_FORCE_ALIGNED and use memcpy() instead
The google's libwebp source uses aligned memory access.
This patch is that applies the two commits below to our static lib code.

refer to:
[Remove WEBP_FORCE_ALIGNED and use memcpy() instead]
3884972e3f
[bit_reader.c: s/VP8L_USE_UNALIGNED_LOAD/VP8L_USE_FAST_LOAD/]
ac49e4e4dc
source :
https://chromium.googlesource.com/webm/libwebp/+/refs/heads/main/src/utils/bit_reader_inl_utils.h#80

related issue: https://github.com/thorvg/thorvg/issues/2006
2024-03-15 11:27:57 +09:00
Hermet Park
f88d9a6d5f capi: Add two additional ColorSpace options to align with C++ APIs.
APIs:
- Tvg_Colorspace::TVG_COLORSPACE_ABGR8888S
- Tvg_Colorspace::TVG_COLORSPACE_ARGB8888S

Issue: https://github.com/thorvg/thorvg/issues/2053
2024-03-15 11:27:51 +09:00
Jinny You
3182a8af2c 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-03-15 11:27:41 +09:00
Hermet Park
cddae9966c bump up version 0.12.7 2024-03-08 15:47:35 +09:00
Hermet Park
a25496fb36 png: corrected a wrong premultiplied option.
this is a regresion bug by 886b6b365b
2024-03-08 15:47:35 +09:00
Lorcán Mc Donagh
2854cbbcf9 sw_engine: fix radial gradient when focal point is outside circle on ARM/Apple Silicon
sw_engine: radial gradient
[issues 2014: radial gradient](#2014)

Radial gradient results in a corrupted image when the focal point is outside the circle on Apple Silicon.
This happens because some compilers use FMA to optimize the a = dr² - dx² - dy² calculation,
which cause loss of precision.

We rely on temporary variables to prevent FMA.
We could also use compiler specific float contraction control pragmas to avoid this if this doesn't work in the future
2024-03-08 14:23:51 +09:00
Hermet Park
d46ddf43cd lottie/slot: ++reliability 2024-03-08 14:22:47 +09:00
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