Commit graph

3795 commits

Author SHA1 Message Date
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
01a4a4c806 examples: updated lottie samples 2025-02-25 23:00:10 +09:00
Mira Grudzinska
2bc6cb07b4 renderer: remove unused file
Should be removed while refactoring in 127738bb1d
2025-02-25 19:42:08 +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
eb4b286da5 renderer: migrated TrimPath as the integrated rendering method
TrimPath -> RenderTrimPath

Co-Authored-By: Mira Grudzinska <mira@lottiefiles.com>
2025-02-25 15:38:03 +09:00
Hermet Park
4316498b8b examples: allow the engine name from the test script
Usage:
all.sh [engine name] [interval]

Example:
$./all.sh gl 3
2025-02-25 12:52:13 +09:00
Hermet Park
70f0ec9ff2 examples: renamed StrokeTrim -> TrimPath 2025-02-25 12:46:54 +09:00
Mira Grudzinska
7275b77c22 gl/wg_engine: fix differences in dashing among engines
The differences resulted from discrepancies between
the engines in applying equality or inequality signs
and in using different precision levels when determining
the dash remainder when transitioning to a new path
command.

@Issue: https://github.com/thorvg/thorvg/issues/3265
2025-02-25 12:30:26 +09:00
Sergii Liebodkin
64ed756c2c wg_engine: Introduce drop shadow effect for webgpu renderer
Issue: https://github.com/thorvg/thorvg/issues/3054
Supported color, angle, distance, sigma, quality params
2025-02-25 11: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
8f9527ccf1 gl_engine: support trimmed fill
This commit changes the API behavior.

@Issue: https://github.com/thorvg/thorvg/issues/3118
2025-02-24 15:06:07 +09:00
Mira Grudzinska
05a5a7ea0b wg_engine: support trimmed fill
This commit changes the API behavior.

@Issue: https://github.com/thorvg/thorvg/issues/3118
2025-02-24 15:05:59 +09:00
Mira Grudzinska
c4747e6802 sw_engine: support trimmed fill
Until now, only stroke trimming was possible,
but the Lottie standard requires support for
trimming both (if present), stroke and fill.
This commit changes the API behavior.

@Issue: https://github.com/thorvg/thorvg/issues/3118
2025-02-24 15:05:49 +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
Hermet Park
02678b67f4 examples: unified samples and improved coverages
- Unify samples for simpler testing:
 - Masking + InvMasking
 - LumaMasking + InvLumaMasking

- Applied Dash for the Stroke Triming
2025-02-21 17:16:26 +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
Sergii Liebodkin
1416e99f34 example: fix types of drop shadows effect parameters (int to double) 2025-02-21 00:06:53 +09:00
Hermet Park
d50632d0d6 loader: fixed potential memory leaks in font handling
Simply loading a font doesn't mean it is in use.
Fixed the loader's reference count to prevent incorrect increments.
2025-02-21 00:05:36 +09:00
Hermet Park
a768276bb6 common: ++portablity
fix a error call of ambiguous overloaded ‘free(void*&)’
2025-02-20 23:16:27 +09:00
Hermet Park
8e1cd7b4c6 examples: added a default font for flawless test 2025-02-20 23:16:15 +09:00
Hermet Park
75c9028c19 gl_engine: code refactoring
- introduced GlGeometryBuffer that structure ensures the pairing of vertex and index data.
- improved for clean and neat code.
2025-02-20 21:41:29 +09:00
Jinny You
3737632e13 wasm: support default font initialization
Load default font data during initialization. This enables the web system to load when the system font cannot be used.

Added a binary-embeddable font file resource. This file has quite small size while containing essential glyphs.

- DM Sans: https://github.com/googlefonts/dm-fonts
2025-02-20 18:47:01 +09:00
Jinny You
646e35484f loaders: added lottie, svg font fallback mechanism
fallback for allowing any available fonts.

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2025-02-20 18:47:01 +09:00
Hermet Park
8e5ca40250 text: allow the unnamed font
If the font name is not specified,
ThorVG will select any available font candidate.

This could be useful for font fallback mechanism.
2025-02-20 18:47:01 +09:00
Hermet Park
bed38a4521 common: remove redundant lzw decoder 2025-02-20 16:41:14 +09:00
Jinny You
42457a25c9 wasm: fix ambigious symbols 2025-02-20 15:46:20 +09:00
pharuxtan
049f19313d sw_engine: fix internal types of rasterXYFlip
Before the C++ compiler couldn't decide the template of std::min (that happen if `int` type is not an `int32_t`), so explicitly changing all types to int32_t fixes this.
2025-02-19 11:00:58 +09:00
Mira Grudzinska
4e98f12743 wg_engine: fix stroke update
The stroke was not updated because the update function
handled flags related to the color/gradient only.
2025-02-18 21:10:10 +09:00
Jinny You
6c4a74e7f1 wg_engine: Fix undefined error in task scheduler usage 2025-02-18 19:16:37 +09:00
Hermet Park
b77f3ca024 common: introduced designated memory allocators
Support the bindings to be more integrable with a system's coherent memory management.

Pleaes note that thorvg now only allow the desinated memory allocators here:
malloc -> tvg::malloc
calloc -> tvg::calloc
realloc -> tvg::realloc
free -> tvg::free

issue: https://github.com/thorvg/thorvg/issues/2652
2025-02-18 17:20:31 +09:00
Hermet Park
424953ad7b examples: build LottieTweening only if enabled 2025-02-18 12:31:10 +09:00
Mira Grudzinska
96be683460 wg/gl_engine: standardize shapes closing precision
The sw_engine, when determining the outline, converts
floats to ints by multiplying them x64, resulting in
a comparison precision of 1/64 = 0.015625.
Both gl_engine and wg_engine operate on floats. Before
adding a closing point to a shape, they performed a comparison
to check if the point differed from the starting point:
- wg: with a precision of 1e-3 (using length2, i.e., eps = 1e-6
- gl: used direct == comparison.
Now, consistency has been ensured by introducing a comparison
precision of 1/64 in both wg_engine and gl_engine.

@issue: https://github.com/thorvg/thorvg/issues/2799
@issue: https://github.com/thorvg/thorvg/issues/3235
2025-02-18 11:26:30 +09:00
Hermet Park
65306d9b66 wg_engine: fix a memory violation by a mistake
regresion by ac08a9d6e7

issue: https://github.com/thorvg/thorvg/issues/3241
2025-02-18 00:52:32 +09:00
Hermet Park
457c44c922 gl_engine: fix a compiler warning
- comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’
2025-02-17 23:31:59 +09:00
Mira Grudzinska
acbc3b3ba9 gl_engine: add offset support in dashed strokes
Offset is correctly applied to dashed strokes,
properly shifting the dash pattern.

@Issue: https://github.com/thorvg/thorvg/issues/3217
@Issue: https://github.com/thorvg/thorvg/issues/3223
@Issue: https://github.com/thorvg/thorvg/issues/3191
2025-02-17 22:30:01 +09:00
Mira Grudzinska
95cd0863eb gl_engine: fix dashing
Incorrect condition for drawing segments in cubics;
missing checks.

@Issue: https://github.com/thorvg/thorvg/issues/2729
@Issue: https://github.com/thorvg/thorvg/issues/3222
2025-02-17 19:01:41 +09:00
Hermet Park
ac08a9d6e7 wg_engine: introduced global vertexbuffer mempool & ++thread safety
Manage the global buffer memory for vertex and indexed vertex buffers,
increase the memory size incrementally twice by default and reduce
the default buffer size, which is not suitable for typical scenarios.

This could reduce the a bit stack memory usage and improve
the portability across systems where has the stack memory
limitation and potentially gaining performance enhancement
by avoiding brutal stack memory usage at the many function calls.

added the internal functions:

- WgVertexBuffer* mpoolReqVertexBuffer(float scale = 1.0f);
- WgIndexedVertexBuffer* mpoolReqIndexedVertexBuffer(float scale = 1.0f);
- void mpoolRetVertexBuffer(WgVertexBuffer* buffer);
- void mpoolRetIndexedVertexBuffer(WgIndexedVertexBuffer* buffer);

issue: https://github.com/thorvg/thorvg/issues/3159
2025-02-17 18:56:31 +09:00
Hermet Park
07e567c026 updated CONTRIBUTORS 2025-02-17 16:09:41 +09:00
Jakub Marcowski
4042c7a6a7 Optimize all .png images using oxipng 2025-02-17 16:06:37 +09:00
Hermet Park
bdb71f18db sw_engine: properly set shared pool and don't flush memory pool 2025-02-17 15:05:57 +09:00
Jinny You
bb2cefe9bc wasm: optimize binary size
- Changed optimization flags to -Oz, reducing the binary size by 120KB.
- Applied wasm-opt convergence as a post-process to ensure the minimum possible size with the given optimization flag.
2025-02-17 15:05:10 +09:00
Mira Grudzinska
259e380733 sw_engine: fix update issue
In cases where the fill was changed while the stroke existed
but remained unchanged, the stroke would disappear because it
was being reset during the shape preparing (shapeReset).
Fixed by disabling the reset of stroke rle from shape reseting.

Also the shape should be prepared not only when the RenderUpdateFlag
is set to Color, but also when it is set to Gradient.

@Issue: https://github.com/thorvg/thorvg/issues/3237
2025-02-17 12:19:46 +09:00
Mira Grudzinska
ad261731b6
lottie: parsing embedded fonts data (#3220)
Only parsing and font loading is added with
a very basic text update while building the scene.

@Issue: https://github.com/thorvg/thorvg/issues/3184
2025-02-14 15:52:10 +01:00
Mira Grudzinska
f4c2d116d9 wg_engine: fix dash offset behavior
For an odd number of dash/gap segments, the offset was
handled incorrectly because the non-doubled count of
dashes and gaps was used.
Additionally, in ddcbbf7, an error was introduced by
overlooking the fact that the offset can shift the dash
pattern in such a way that the first segment of the dashed
line becomes a gap.
2025-02-13 19:48:25 +02:00
Hermet Park
6c0556d275 lottie: --casting compiler warnings 2025-02-14 02:02:42 +09:00
Hermet Park
a3481571c8 lottie: properly copy missing property values 2025-02-14 01:05:17 +09:00
Hermet Park
305da05b1b lottie: resolved minor memory leaks 2025-02-14 00:31:14 +09:00
Mira Grudzinska
ddcbbf771f wg_engine: handle properly odd numbers of dashes/gaps
If the provided list has an odd number of values, then it
should be repeated to yield an even number of values.

@Issue: https://github.com/thorvg/thorvg/issues/3205
2025-02-13 17:23:56 +02:00
Mira Grudzinska
391777091c lottie: ++ dashed stroke support
Until now lottie loader supported only a single
dash-gap pair, and only the case where only the dash
was provided was handled correctly. When both values
were provided, the gap was incorrectly increased by
the dash value. If more values were supplied, only
the last pair was considered.

@Issue: https://github.com/thorvg/thorvg/issues/3191
2025-02-13 23:37:32 +09:00