Commit graph

1142 commits

Author SHA1 Message Date
Mira Grudzinska
266f988835 api: handling values <= 0 in strokeDash() api
The API allows now values <= 0 for dashes and gaps. Negative values
are treated as zero. The exception is when all provided values
are <= 0, in which case the dash is ignored.
This fixes the issue when dash = 0 was provided for strokes with round
or butt caps - the dot was not drawn, even though it should have been.

docs: the strokeDash API behavior's clarification for odd numbers
of values in dashPattern and refinement of the accepted values.
2025-06-23 11:44:13 +02:00
Hermet Park
2aabddd5a5 common: support static scene mode (internal)
This adds support for a static scene mode,
allowing a scene to be treated as a static image.

In this mode, partial rendering for the inner
drawable components is skipped. This is especially
useful for scenes designed to be fully updated as a whole,
such as those used in fully dynamic Lottie contents.

issue: https://github.com/thorvg/thorvg/issues/1747
2025-06-23 16:04:48 +09:00
Mira Grudzinska
2679880bc3 lottie: ensure proper shape closure
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
- Ensured proper closure of star and polygon shapes.
The start and end points now match - in cases with
degenerate bezier curves, the second-to-last point
is also aligned.
Proper shape closure is necessary for modifiers like
offset (future pucker bloat). If the start and end
points aren’t equal (within the comparison function’s
precision), the shape will be closed with a straight
line - and during offsetting, that line will become
visible, even though it’s not intended.

- Use of the internal _zero() function for point equality check
in modifiers algs led to incorrect results when p2.x or p2.y
was zero (division by zero).
The intent was to treat nearly identical points as equal, but
this approach was flawed - at the modifier stage, it’s no longer
possible to tell if small gaps are intentional or just due to
limited numerical precision (as seen for example in the difference
between the start and end points of star/polygon shapes).
2025-06-20 10:39:12 +09:00
Artem Umerov
666a8b7682 Fix identity namespace 2025-06-18 18:41:01 +09:00
JunsuChoi
d5416de8ac loader/jpg: Fix uninitialized warning
../src/loaders/jpg/tvgJpgd.cpp:670:10: note: ‘padding_flag’ was declared here
  670 |     bool padding_flag;
      |          ^~~~~~~~~~~~
../src/loaders/jpg/tvgJpgd.cpp:674:9: warning: ‘padding_flag’ may be used uninitialized [-Wmaybe-uninitialized]
  674 |         if (padding_flag) return 0xFF;
      |         ^~
2025-06-18 16:28:40 +09:00
Hermet Park
0c0c30bd36 renderer: clean up the base render flow
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
- Clear out the render update flag to skip any unnecessary update situation.
- Consolidate the composition flags update.
2025-06-16 18:00:30 +09:00
Hermet Park
f606d58dfb lottie: chores++
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
2025-06-15 14:52:58 +09:00
Mira Grudzinska
27e78095ff lottie: fix offset with miter join
One point was skipped during the creation of the offset
corner. The error was not visible because the point lies
on the line, but it will become apparent if further
modifiers are applied to the object (not supported now).
2025-06-13 11:36:22 +09:00
Mira Grudzinska
4c3c5d9d06 lottie: readability++
Introduce the _colinear function - checks if a Bezier curve
is degenerated to a line.
2025-06-12 18:48:07 +09:00
Hermet Park
3eaf110e0a sw_engine: revised the texture clipping
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
previous logic doesn't work if the clipping shape
has any inner corners. replace the logic
with a intermediate composition approach for
stability.

- performance can be drop at texture clipping by ~11%
- size is reduced by -0.5kb

issue: https://github.com/thorvg/thorvg/issues/3520
2025-06-11 22:35:54 +09:00
Hermet Park
b3d73e1568 lottie: do not try matting if the layer has no contents
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
2025-06-09 22:33:25 +09:00
Hermet Park
a2665cbab7 lottie: fixed a repeater opacity logic
preserve the target opacity by multiplying,
do not overwrite it.
2025-06-09 18:52:05 +09:00
Hermet Park
eb76769dcf jpg: removed setjmp usage which is not portable with rust 2025-06-08 11:54:08 +09:00
Mira Grudzinska
211fee73e2 lottie: fix precomposition with masking
Some checks failed
Android / build_x86_64 (push) Has been cancelled
Android / build_aarch64 (push) Has been cancelled
iOS / build_x86_64 (push) Has been cancelled
iOS / build_arm64 (push) Has been cancelled
macOS / build (push) Has been cancelled
macOS / compact_test (push) Has been cancelled
macOS / unit_test (push) Has been cancelled
Ubuntu / build (push) Has been cancelled
Ubuntu / compact_test (push) Has been cancelled
Ubuntu / unit_test (push) Has been cancelled
Windows / build (push) Has been cancelled
Windows / compact_test (push) Has been cancelled
Windows / unit_test (push) Has been cancelled
A precomposition layer is clipped to its viewport.
If the same layer also had a mask that was optimized
using clipping, this clip was unintentionally overridden
by the viewport clipping. This conflict is now fixed.
2025-05-26 19:26:45 +09:00
JunsuChoi
c41b2c2a1c svg_loader: Fix <stop> being registered in closed latestGradient
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
If stop is declared immediately after Gradient is closed, the stop is registered in latestGradient.
Change latestGradient to a Stack and add a stop only to the last added gradient.
When that gradient is closed, no more stops should be registered for that gradient.
And gradients do not allow nested declarations, so only the earliest declared Gradient is valid.
2025-05-21 11:41:03 +09:00
Hermet Park
bace6b9e52 lottie: removed undesired embedded option.
Use local font by default and fall back if no glyphs exist.

Co-Authored-By: Mira Grudzinska <mira@lottiefiles.com>
2025-05-15 19:21:24 +09:00
Jinny You
1e692f223c lottie: handle time remapping with zero value correctly
The time remapping logic had an issue where animations with zero value "tm"(Time Remap) were not being processed correctly.

This was happening because the previous implementation only applied time remapping when the value was non-zero. (A zero-value Time Remap should be applied, but is ignored)

The fix changes the default time remap value to `-1.0` (since frame values cannot be negative) and applies time remapping when the value is 0.0 or greater. This ensures that zero value time remapping is properly processed.
2025-05-14 21:53:32 +09:00
Mira Grudzinska
6e41b44ea1 lottie: fix points calculation for rounded polygon
Added missing factor.

issue: https://github.com/thorvg/thorvg/issues/2629
2025-05-14 21:53:32 +09:00
Mira Grudzinska
97817bedfe lottie: support for firstMargin < 0 in text follow path
The first margin value shifts the starting point where the text
begins along the path. Now cases where firstMargin < 0 are handled,
for both closed and open paths.
2025-05-12 15:32:32 +09:00
Mira Grudzinska
2e03fbd630 lottie: enhance parsing of position's SeparateCoords
The "s" key does not have to appear at the beginning
of the position block. Previously, such cases would
result in a parsing error — now they are handled correctly.
2025-05-08 19:30:08 +09:00
Hermet Park
57adfbd499 lottie/parser: revise logic to handle exceptional cases more gracefully
- prioritize valid (positive) cases first
- continue parsing even when encountering parsing errors

Co-Authored-By: Mira Grudzinska <mira@lottiefiles.com>
2025-05-07 13:07:30 +02:00
Mira Grudzinska
24fba7cfae lottie: add missing delimiter
\u0003 (\3) can be used as delimiter. Now handled correctly.
2025-05-07 10:53:32 +09:00
Mira Grudzinska
7d4a5215dd lottie: fix stroke join for offset path
The incorrect line join used for OffsetPath was caused
by changes to the StrokeJoin enum values in commit
34d731fa94. During those
changes, the line join value for OffsetPath was mistakenly
not updated.
2025-05-02 14:19:04 +09:00
Mira Grudzinska
65c4e27437 svg_loader: fix clipping in use/symbol nodes
Clipping for the <use> node when a <symbol> was used,
was being overridden when 'overflowVisible' was 'true'
(the default value), which caused the 'clip-path' applied
to the <use> node to have no visible effect.
The clipping for the <use> node (without <symbol> node) was
transformed in an incorrect order, resulting in a visually
incorrect results.

@Issue: https://github.com/thorvg/thorvg/issues/3392
2025-04-23 15:59:51 +09:00
Hermet Park
1a332acd37 renderer: revise the pImpl design with a better efficiency
The following is a redesign that extends the class internally.

The main goal is to preserve the characteristics of the pImpl idiom
for data encapsulation, while simultaneously reducing the memory
allocation overhead typically associated with pImpl.

The stragegy is here:
Rather than alloc the impl memory inside of the thorvg engine,
impl extends the API classes in order to consolidate the memory.

size has been decreased by -4kb with optimization=s

issue: https://github.com/thorvg/thorvg/issues/3214
2025-04-20 00:07:50 +09:00
Hermet Park
7feb43201b svg: fixed invalid memory access
Added "Filter" and "GaussianBlur" to the list of node type strings
to ensure the array fully covers the SvgNodeType enum values.
2025-04-18 13:27:06 +09:00
Hermet Park
e692a59ff9 lottie/expressions: --memory leak 2025-04-18 13:18:17 +09:00
Hermet Park
5ce6fca802 api: fixed a build linking issue on lottie
- something wrong with typeinfo missing in destructor
(don't know reason) and this resolves the problem.

- added override specifier for destructors
2025-04-17 15:38:15 +09:00
Hermet Park
fa0a1b7e60 lottie: fixed a invalid memory access
looping doesn't make sense if the animation
doesn't have frames. use the current frame number.
2025-04-17 00:05:14 +09:00
Hermet Park
5c27fefef8 lottie/expressions: minor updates
- added toComp() initial ver.
- added mn property for effects

issue: https://github.com/thorvg/thorvg/issues/2233
2025-04-14 16:07:35 +09:00
Hermet Park
d0f33a1bc5 lottie/expressions: hotfix
issue: https://github.com/thorvg/thorvg/issues/3400
2025-04-12 15:22:51 +09:00
Mira Grudzinska
934a6e5418 ttf: prevent crash while converting utf8 to unicode
If wrong utf8 sequence if given as an input, decoding
return nullptr and it has to be handled correctly.
2025-04-11 19:18:04 +09:00
Mira Grudzinska
54b33fcd28 lottie: safety++
Prevents a crash when the font family in the text document
does not match any font in the provided font list.
2025-04-11 19:17:50 +09:00
Hermet Park
8c4f3e7eec loaders: explicit variable scope to improve portability
issue: https://github.com/godotengine/godot/pull/105093
2025-04-11 12:56:10 +09:00
Hermet Park
4bc73c8a09 lottie: --compiler warnings on msvc 2025-04-10 22:09:33 +09:00
Hermet Park
ea54154906 lottie/expressions: tiny optimization
reuse the user callback data by the reference count.
2025-04-10 15:10:33 +09:00
Hermet Park
e308d3416a lottie: code refactoring
align the internal naming for lottie "ix" properites and its variables
2025-04-10 15:10:33 +09:00
Hermet Park
882cb316c4 lottie: allow custom effects to use nm/mn both identifiers 2025-04-10 15:10:33 +09:00
Mira Grudzinska
f8c5f3a69c
lottie: follow path stabilization++
* lottie: fixes in follow path

Each time the 'updateText' was called, the mask
path (if the follow path existed) was appended
to the previous one, causing it to grow infinitely.
A 'clear' call on the existing path was missing.

The positions on the follow path for distances larger
than 2 x mask path length were not correctly calculated.

* lottie: fix crash on follow path

It could happen that the searched text position
(distance from the start pointt) on the follow path
was exactly equal to the path length. In such a case,
the cmds pointer pointed to the last element, and in
the next iteration, this caused a crash.
2025-04-10 12:13:52 +09:00
Mira Grudzinska
b304448ef7 lottie: revert "lottie: more precise culling for inverse mattes"
This reverts commit 7ef3352efa.

For mattes of type 'InvAlpha' or 'InvLuma', the matted layer
can still be visible regardless of the matte's opacity (unlike
'Alpha' and 'Luma' masks, which cut out the entire layer when
opacity = 0). The previously introduced optimization incorrectly
assumed that with opacity = 255, the image would not be visible.

@Issue: https://github.com/thorvg/thorvg/issues/3375
@Issue: https://github.com/thorvg/thorvg/issues/3380
@Issue: https://github.com/thorvg/thorvg/issues/3381
@Issue: https://github.com/thorvg/thorvg/issues/3382
2025-04-09 11:21:36 +09:00
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