Commit graph

1102 commits

Author SHA1 Message Date
Hermet Park
d3afebfdec lottie: add custom layer effect with expressions support
effect(name) / effect(index)

effects finds the effect by its name in the Effect Controls panel.
The name can be the default name or a user-defined name.
If multiple effects have the same name,
the effect closest to the top of the Effect Controls panel is used.

example:
- effect("Fast Blur")("Blurriness")

issue: https://github.com/thorvg/thorvg/issues/3115
2025-04-08 15:35:36 +09:00
Jinny You
fbe10255d7 lottie/text: added range selector flags
Duplicated text document properties (fill color, stroke color, and stroke width) to the text range.

If these properties are not defined in the range selector, ThorVG incorrectly overrides them with default values.

The correct behavior is to preserve the original values. The added flags address this issue.

Co-Authored-By: Hermet Park<hermet@lottiefiles.com>
2025-04-07 17:34:52 +09:00
Jinny You
2b3cdb0d97 lottie: simplify text layout calculation 2025-04-05 02:35:11 +09:00
Mira Grudzinska
9bc3d5e3b7 lottie: fix stroke cap/join values
ThorVG cap/join enums and lottie specs were not aligned.
Problem was observed for StrokeCap::Square and StrokeJoin::Bevel.

Note: this change breaks backward comatibility.
2025-04-03 00:29:31 +09:00
Hermet Park
34d731fa94 lottie: minor code change of template mismatch
subsequent change by a9cd630dfd
2025-04-02 15:44:21 +09:00
Hermet Park
321305ff0b loaders: ++static loader thread safty
make it sync before deleting the loaders.
2025-04-02 14:40:54 +09:00
Hermet Park
a9cd630dfd lottie: code refactoring
- aligned the property types with the class types.
- removed tempaltes, since property types are deterministic.
2025-04-02 00:40:03 +09:00
Hermet Park
8ec3c841f6 lottie/expressions: add temporalWiggle() support
usage) temporalWiggle(freq, amp, octaves=1, amp_mult=.5, t=time)

Samples the property at a wiggled time. The freq value is the frequency
in wiggles per second, amp is the amplitude in units of the property
to which it is applied, octaves is the number of octaves of noise
to add together, amp_mult is the amount that amp is multiplied by
for each octave, and t is the base start time. For this function
to be meaningful, the property it samples must be animated,
because the function alters only the time of sampling, not the value.

Note: need to verify this with a practical samples.

issue: https://github.com/thorvg/thorvg/issues/1640
2025-03-30 13:11:02 +09:00
Hermet Park
11f59c03ae lottie/expressions: support wiggle effect
usage: wiggle(freq, amp, octaves=1, amp_mult=.5, t=time)

issue: https://github.com/thorvg/thorvg/issues/1640
2025-03-28 13:41:48 +09:00
Hermet Park
1e1be53136 lottie: --compiler warnings on clang
removed uninitialized value and override marks
2025-03-28 01:33:57 +09:00
Hermet Park
786d0b2d02 lottie/expressions: code clean up 2025-03-27 22:19:31 +09:00
Hermet Park
93cb33fb8e lottie: improve the compatiblity
merge the scene with more accurate condition to allow
the evenodd pathes among the lottie render tree.
2025-03-27 14:06:19 +09:00
Hermet Park
e5d55d0651 lottie: safety++
Don't apply matte — it's already been pushed into the scene.
This is a corner-case bug that occurs when the Lottie data
violates the specification.
2025-03-27 12:43:17 +09:00
Hermet Park
fba861cb4f lottie: fixed a regression bug
reverted stroke optimization from the previous cullting stragtegy.
introduced by d386a5654a
2025-03-27 12:43:11 +09:00
Hermet Park
3136cac6e4 Revert "lottie: minor optimization"
This reverts commit 51bc7e81f8.

note: side effect!
2025-03-26 20:56:24 +09:00
Hermet Park
745b4f4628 loaders: ++chores 2025-03-26 17:27:14 +09:00
Jinny You
6ee410e042 lottie/expressions: text document support
- Handle text value of text document.
- Expand `add()` for string concatenation.
- Restore jerry_value_is_string()
2025-03-26 12:19:41 +09:00
Hermet Park
ffdb30cba2 lottie: don't evaluate local font text again 2025-03-26 12:19:32 +09:00
Hermet Park
51bc7e81f8 lottie: minor optimization
trim out a group when it has only one child.
2025-03-26 00:28:20 +09:00
Hermet Park
bd520c1c69 ttf: ++thread safety
Properly allow the ttf loader sharable among threads.

issue: https://github.com/thorvg/thorvg/issues/3165
2025-03-25 17:02:58 +09:00
Hermet Park
56d5396b7a common: ++loader thread safety
fortitfy the thread safety
in multi-threaded resource loading.

issue: https://github.com/thorvg/thorvg/issues/3306
2025-03-24 18:18:30 +09:00
Hermet Park
5de098f128 lottie: suppport writable expressions
This function sets the value of a specified expression variable within a particular layer.
It is useful for dynamically changing the properties of a layer at runtime.

Experimental API
- Result LottieAnimation::assign(const char* layer, uint32_t ix, const char* variable, float value)
- Tvg_Result tvg_lottie_animation_assign(Tvg_Animation* animation, const char* layer, uint32_t ix, const char* var, float val)
2025-03-24 12:11:15 +09:00
Hermet Park
eddd8961f3 common: hotfix regression bugs during recent dev
- fixed Duplicate/Text samples broken
- fixed a Lottie TextPath memory leaks
- fixed a broken SVG gaussian blur
2025-03-20 22:33:36 +09:00
Hermet Park
333e65ef7a renderer: revise the Bounding Box Behavior
- modify the concept of AABB to apply only to transformed shapes.
- transform points before computing the bounding box min/max
  to obtain a more compact shape region.
- trimmming memory by removing the cached matrix, about 36kb
  of memory has been reduced per paint instance.
2025-03-20 13:26:25 +09:00
Hermet Park
ad888019e9 svg: clean & neat code++
no logical changes
2025-03-18 13:22:42 +09:00
Mira Grudzinska
468a1db1fa svg_loader: handle embedded fonts
It is possible to embed fonts directly into an SVG file.
Support for parsing and loading embedded fonts has been added.

@Issue: https://github.com/thorvg/thorvg/issues/1897
2025-03-17 17:31:45 +09:00
Jinny You
02a28bf9c3 lottie/slot: fix image deep copy logic
When the datas are copied with deep copy, memory issue caused (SEGV on unknown address) due to these reasons:

1. `mimeType` is nullptr when it's not embedded(base64) data

2. datas(b64Data, mimeType) should not be clear, it's used for next slot copy in same pair.
2025-03-17 12:42:13 +09:00
Mira Grudzinska
be32e97d96 svg: fix incorrect assignment of <stop> elements
If the svg contained an unsupported element with <stop> elements,
they were incorrectly assigned to the last loaded gradient. Now fixed.

@Issue: https://github.com/thorvg/thorvg/issues/3321
2025-03-12 15:02:25 +09:00
Mira Grudzinska
ac080ffabc lottie: add support for text follow path
Added support for cases without text grouping and range selector.

Co-Authored-By: Hemet Park <hermet@lottiefiles.com>

@Issue: https://github.com/thorvg/thorvg/issues/2888
2025-03-12 13:08:26 +09:00
Jinny You
e4834e9190
lottie/text: render carriage return with local font (#3310)
Added missing carriage return support in local font case.

issue: #3301
2025-03-11 13:39:55 +09:00
Hermet Park
488fd88ce1 lottie: --compiler warnings
In member function ‘constexpr LottieGenericProperty<LottieScalarFrame<float>, float>& LottieGenericProperty<LottieScalarFrame<float>, float>::ope>    inlined from ‘LottieFloat& LottieStroke::dashValue()’ at ../src/loaders/lottie/tvgLottieModel.h:60:104,
    inlined from ‘void LottieParser::parseStrokeDash(LottieStroke*)’ at ../src/loaders/lottie/tvgLottieParser.cpp:623:82:
../src/loaders/lottie/tvgLottieProperty.h:297:8: warning: ‘<anonymous>.LottieGenericProperty<LottieScalarFrame<float>, float>::value’ may be used>  297 | struct LottieGenericProperty : LottieProperty
      |        ^~~~~~~~~~~~~~~~~~~~~
../src/loaders/lottie/tvgLottieModel.h: In member function ‘void LottieParser::parseStrokeDash(LottieStroke*)’:
../src/loaders/lottie/tvgLottieModel.h:60:104: note: ‘<anonymous>’ declared here
   60 |             for (uint8_t i = 0; i < dashattr->size; ++i) newValues[i] = LottieFloat(dashattr->values[i]);
      |
2025-03-10 14:28:04 +09:00
Jinny You
0e76ba3e47 lottie/slot: Support expressions overriding
issue: #3168

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2025-03-10 12:42:12 +09:00
Thaddeus Crews
e235eb8152 common: support c++20 builds 2025-03-10 09:45:19 +09:00
Hermet Park
9e6a514022 common: ++stability of the font cache
Use the font name as the cache key for
precise comparison instead of the file path.
2025-03-06 19:00:06 +09:00
Jinny You
384fa7f2cb lottie/slot: fix potential memory leak when overriding twice
Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2025-03-06 12:40:15 +09:00
Hermet Park
96dc3d6697 common: str refactoring
renamed the prefix to be slimmer and more compact.
2025-03-06 12:18:24 +09:00
Hermet Park
67098793f0 renderer: revise the paint bounding box api
C++ API Modificaiton:
 - Result Paint::bounds(float* x, float* y, float* w, float* h, bool transform = false) const
  -> Result Paint::bounds(float* x, float* y, float* w, float* h) const

C++ API Addition:
 - Result Paint::bounds(Point* pt4) const

C API Modification:
- Tvg_Result tvg_paint_get_bounds(const Tvg_Paint* paint, float* x, float* y, float* w, float* h, bool transformed);
 -> Tvg_Result tvg_paint_get_aabb(const Tvg_Paint* paint, float* x, float* y, float* w, float* h);

C API Addition:
- Tvg_Result tvg_paint_get_obb(const Tvg_Paint* paint, Tvg_Point* pt4);

issue: https://github.com/thorvg/thorvg/issues/3290
2025-03-05 14:46:55 +09:00
Hermet Park
3c836b1b2a lottie: revise the text justify logic
removed the duplicate logic,
improved for neat and easy maintainance
2025-03-04 15:15:06 +09:00
Jinny You
716311f44f lottie/text: fix justification in embedded font rendering
issue: #3266
2025-03-04 15:01:35 +09:00
Hermet Park
82a9a05405 common: replace the strdup() with strDuplicate()
tvg expects the coherent memory allocator usage,
while strdup() is out of the control. so replaced it.
2025-02-28 12:04:53 +09:00
Hermet Park
d386a5654a Lottie: optimize rendering performance
implemented an aggressive culling strategy to eliminate
unnecessary renderings if the rendering visuals were hidden
by other overlaid opaque fills or strokes

this pretty improves the performance for those scenarios
when rendering sequences are fragmented by fills/strokes.

Performance has been improved ~7% with those cases
2025-02-27 19:05:41 +09:00
Jinny You
bf5cea982c common: Support .lot extension
Add support for the .lot extension to recognize Lottie animation files, as this introduces an additional extension for Lottie.

issue: #3248
2025-02-27 16:46:30 +09:00
Mira Grudzinska
47130ea911 ttf_loader: handling contours starting with OFF_CURVE
It might happen that the first point doesn't belong
to the contour - such cases were observed as artifacts
till now.

@Issue: https://github.com/thorvg/thorvg/issues/3268
2025-02-27 12:27:55 +09:00
Hermet Park
9a79dd0267 lottie: code clean up++ 2025-02-26 19:00:16 +09:00
Hermet Park
7ef3352efa lottie: more precise culling for inverse mattes
don't do rendering further when the inverse mattes has
a fully translucent. This could improve rendering performance
in that case.
2025-02-26 12:55:47 +09:00
Hermet Park
c5ca7b4b12 lottie: hotfix a regression
a regression by the code refactoring:
5b30e2ad65
2025-02-25 18:54:04 +09:00
Hermet Park
66a30b2c50 lottie: fixed a regression bug of a weird artififact observation
this reverts a logic that was introduced by
https://github.com/thorvg/thorvg/pull/3167

this logic change was not necessary thus revert it.
2025-02-24 15:47:09 +09:00
Mira Grudzinska
5b30e2ad65 lottie: prevent trimming in masks
Until now the fill's trimming was not supported,
which allowed masks to function correctly. Introducing
trimming for the entire shape caused the mask to be trimmed
as well, leading to incorrect results.

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2025-02-24 15:06:16 +09:00
Mira Grudzinska
b939a60bfa api: change api name strokeTrim() -> trimpath()
No changes in behaviour so far.
2025-02-24 15:05:38 +09:00
Jinny You
151284c3cc lottie/expressions: Fix incorrect evaluation result check condition
A JavaScript code line may return undefined, but this should not be treated as an error.

For example, consider the following two lines of code:
- `var $bm_rt = 30` (Statement) → result: `undefined`
- `$bm_rt = 30` (Expression) → result: `30`

Both lines execute the same operation, but the JavaScript interpreter (REPL JS) evaluates them differently.

Therefore, an evaluation result of undefined should not be blocked, as it does not indicate a failed code execution.
2025-02-21 11:22:55 +09:00