Commit graph

2678 commits

Author SHA1 Message Date
Hermet Park
fc67a39c78 lottie/expressions: apply expressions to missing properites. 2024-05-10 11:12:12 +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
7bb8d60097 lottie/expressions: ++exceptional handling.
Add an exceptional handling if interpreting code is failed.
2024-05-10 11:12:12 +09:00
Hermet Park
6959523ee7 lottie/expressions: make it up the insufficient content() behavior
this is a follow-up fix for the initial expressions feature.
2024-05-10 11:12:12 +09:00
Hermet Park
34b2e3ba37 lottie: fix a logic by a mistake. 2024-05-10 11:12:12 +09:00
Vincent Torri
3eb3364c60 infra: fix build failure using c++17 (or later) with MSVC.
the WIN32_LEAN_AND_MEAN definition will remove the unused
features in windows.h that helps to improve the build-speed
as well as fixing the issue.

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

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2024-05-10 11:12:12 +09:00
Jinny You
51e3d25043 bindings/capi: Fix incompatible parameter
C API doesn't support default parameter, removed it.

Issue: #2228
2024-05-10 11:12:12 +09:00
Jinny You
4d7ff092a5 test/lottie: Add the segment use case 2024-05-10 11:12:09 +09:00
Hermet Park
4135f83026 doc: adds the api version history 2024-05-10 10:47:01 +09:00
Hermet Park
faa49ba2da lottie/jerryscript - size down the engine.
get rid of unused features in thorvg lottie.
2024-05-10 10:46:53 +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
87320436db lottie/model: Added some essential functions through expressions.
These internal methods have been introduced to search for content within
an object (parent) using a given parameter (name or index).

- LottieLayer* LottieGroup::asset(const char* name)
- LottieLayer* LottieComposition::asset(const char* name)
- LottieLayer* LottieComposition::layer(uint16_t id)
- LottieLayer* LottieComposition::layer(const char* name)

This converts the frame number to the corresponding time.
- float LottieComposition::timeAtFrame(float frameNo)
2024-05-10 10:42:12 +09:00
Hermet Park
5a8e15aebd lottie: ++binary search stability.
this ensures that the return value is not below 0,
when the frame count is just 2.
2024-05-10 10:42:05 +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
8488c629eb lottie: integrate JerryScript engine for expressions
introduced the JerryScript engine to interpret Lottie
expressions, enhancing the capability to support runtime
programmable animation logic within Lottie expressions
spec. This feature, based on js scripting, represents
the most complicated addition to the Lottie spec so far.

ThorVG probably could includes an option to toggle
this feature at build time, allowing for customizable user
configurations according to specific requirements.

removed unused features for the optimal size:
- DEBUGGER
- MEM_STATS
- SNAPSHOT
- BUILTIN_JSON
- BUILTIN_PROXY
- BUILTIN_REFLECT
- BUILTIN_ATOMICS
- PROMISE_CALLBACK
- MODULE_SYSTEM
- SYSTEM_PORT

This is an experimental version.
Please manually enable the 'lottie-expressions' in meson.build
when you wish to use it.

See: https://jerryscript.net/
2024-05-10 10:41:22 +09:00
Hermet Park
5237d0868e bump up version v0.13.2 2024-04-26 11:26:54 +09:00
Jinny You
dd121af20d lottie: correct the text alignment
When the Lottie Text Justify sets to center, text alignment should also be center.
2024-04-26 11:16:35 +09:00
JunsuChoi
535f2165a0 loader/svg: Check current graphics node that not closed
If any of the graphics nodes are not closed,
the graphics nodes between them are ignored.

related issue: https://github.com/thorvg/thorvg/issues/2210
2024-04-26 11:16:29 +09:00
JunsuChoi
7be6fe0c8e loader/svg: If link string is empty, not create picture object
An empty link causes the wrong loader to be found and causes various problems.

related issue : https://github.com/thorvg/thorvg/issues/2078#issuecomment-2067726046
2024-04-26 11:16:16 +09:00
Mira Grudzinska
5ba9f17a97 common: fix composition while masking
Using a mask (any type) with alpha set to less
than 255 through the fill(r, g, b, a) API resulted
in incorrect compositions of fill and stroke.
Incorrect results were also observed for luma masks,
as their alpha is calculated based on the other color
channels.

@issue: https://github.com/thorvg/thorvg/issues/1653
2024-04-26 11:16:10 +09:00
Mira Grudzinska
18a0c5e16e svg_loader: fix opacity cloning
The opacity value should be copied along
with other node properties.
2024-04-26 11:15:56 +09:00
Jinny You
243ff7b378 web: memory stability++
Call the explicit memory deletion—binded in function `delete()`, which is highly recommended by the Memory management in Emscripten guideline.

The function will guarantee that the WASM module is cleaned up from the memory.

see: https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html#memory-management

Additionally, WASM module's initialization part has been refactored to correspond to the change.
2024-04-26 11:15:39 +09:00
Mira Grudzinska
1b391180c7 svg_loader: copy display property
The display property was not copied along with other
node properties. This caused incorrect rendering
of an object with display=none if accessed through
a use tag.
2024-04-26 11:15:02 +09:00
Mira Grudzinska
abb10afc88 svg_loader: correct polygon's points loading
Only an even number of correctly read points defining
a polygon should be loaded and passed on for rendering.
Any remaining points should be ignored.
2024-04-26 11:14:55 +09:00
Hermet Park
f8fa48d798 bump up version v0.13.1 2024-04-19 11:00:29 +09:00
Mira Grudzinska
f87601db58 sw_engine: fix max length of trimmed strokes
The error was visible when multiple shapes were
simultaneously trimmed. The length of a single
shape was zeroed out only in selected cases,
which caused accumulation that could lead to
incorrect extension of the variable determining
the maximum length.

@issue: https://github.com/thorvg/thorvg/issues/2173
2024-04-19 11:00:29 +09:00
JunsuChoi
86c4b093b7 loader/svg: Add check to the limits of result of StrToFloat
The string passed to the svg parser is not guaranteed to always be a valid string.
Certain strings may have numbers that cannot be converted.
Therefore, make sure to check whether the converted value is in the appropriate range before returning.

related issue: https://github.com/thorvg/thorvg/issues/2078#issuecomment-2037495121
2024-04-19 11:00:29 +09:00
Hermet Park
a6eddcbfab lottie: code clean up 2024-04-19 11:00:29 +09:00
Mira Grudzinska
9fd34c8503 build: add missing ifdef
The thorvg_lottie.h file wasn’t accessible
if the lottie loader was not activated,
causing a compilation error.
2024-04-19 11:00:29 +09:00
Jinny You
bf89da204e lottie/loader: Fix crash when parsing error
When parsing error, lottie loader raises runtime crash.
Check whether the composition is nullptr.
2024-04-19 11:00:29 +09:00
JunsuChoi
4f4ff68896 loader/svg: Return actual decoded size
Returns the actual length of the decoded array.

related issue: https://github.com/thorvg/thorvg/issues/2156
2024-04-19 11:00:29 +09:00
Hermet Park
a5abc42ed5 lottie: ++stability
ensure that the loading has been completed before overriding.
2024-04-19 11:00:29 +09:00
Jinny You
2bd8e18f0d lottie/common: Fix typo in API documentation comment 2024-04-19 11:00:29 +09:00
JunsuChoi
730a88c42b loader/svg: Add null to the end of data
Because memcpy() is not guaranteed to copy null at the end of the data array,
it increase the size by 1 and add null
This prevents invalid access of string functions in parser.
2024-04-19 11:00:29 +09:00
Hermet Park
025e88fe25 lottie: code refactoring.
make it neat and clean.
2024-04-19 11:00:29 +09:00
Hermet Park
8502b41b99 common: code refactoring
introduced mathDeg2Rad() and mathRad2Deg() for a common implementation.
2024-04-19 11:00:29 +09:00
Hermet Park
4319d38de8 lottie: code refactoring.
keep the coding style.
2024-04-19 11:00:29 +09:00
Hermet Park
fc54db45a3 infra: revise the vector build script
Note that this change renames the Meson option from 'vector' to 'simd',
separates the NEON types into 'neon-arm' and 'neon-aarch',
and designates the 'mfpu' option solely for 'neon-arm'.
2024-04-19 11:00:29 +09:00
Jinny You
34105bd85a bindings/capi: Support lottie segment and marker
new experimental apis for animation segment and lottie marker.

APIs:
- TVG_API Tvg_Result tvg_animation_set_segment(Tvg_Animation* animation, float begin, float end)
- TVG_API Tvg_Result tvg_animation_get_segment(Tvg_Animation* animation, float* begin, float* end = nullptr)
- TVG_API Tvg_Result tvg_lottie_animation_set_marker(Tvg_Animation* animation, const char* marker)
- TVG_API Tvg_Result tvg_lottie_animation_get_marker_cnt(Tvg_Animation* animation, uint32_t* cnt)
- TVG_API Tvg_Result tvg_lottie_animation_get_marker(Tvg_Animation* animation, uint32_t idx, const char** name)
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
150c2c35a8 sw_engine : type cast compile error 2024-04-19 11:00:29 +09:00
7af258ddb7 sw_engine: Implement AVX and NEON optimizations for RasterGrayscale 2024-04-19 11:00:29 +09:00
JunsuChoi
c59f3dd435 loader/svg: Ignore unrecognized commands following 'z'
If the command after `m` is not recognized, it must be recognized as `l` or `L`.
However, if it is not recognized after ending with `z`, all commands after it are ignored.

```
<svg width="100" version="1.0" xmlns="http://www.w3.org/2000/svg" height="100" xmlns:xlink="http://www.w3.org/1999/xlink">

<path style="stroke:#F00" d="m 20,20 0,50 50 0 -50 -50 z  70,70 0,50 50 0 -50 -50 z  "/>

</svg>
```
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
1498ef83d0 lottie: rectify the frame updates.
Currently, tvg ignores the frame value if the difference
is less than 0.001. In most cases, updating the frames
when the change is less than 1ms is just an unnecessary
burden on the system.

Instead, this ensures that the perfect last frame is reached.

issue: https://github.com/thorvg/thorvg/issues/2147
2024-04-19 10:34:40 +09:00
Hermet Park
f12f8dca3c bump up version 0.13.0 2024-04-08 17:27:02 +09:00
Hermet Park
9ef6fcf3d1 tvg: updated binary resources to v0.13 2024-04-08 17:27:02 +09:00
Hermet Park
d4258c93ad svg: code refactoring
-- compiler warnings on msvc
2024-04-08 17:26:59 +09:00
Hermet Park
9374437115 example: fixed broken tvg saver resource pathes 2024-04-07 15:15:59 +09:00