Commit graph

3685 commits

Author SHA1 Message Date
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
Hermet Park
a933465430 sw_engine: ++clean code 2025-02-13 12:53:44 +09:00
Sergii Liebodkin
37992b52c9 webgpu_gaussian_optimization
wg_engine: optimize gaussian blur effect for webgpu renderer

Issue: https://github.com/thorvg/thorvg/issues/3054
2025-02-13 12:52:40 +09:00
Mira Grudzinska
3035501579 jerryscript: fix warnings on masOS (intel)
warning: implicit conversion increases floating-point precision
2025-02-12 22:30:15 +09:00
Fabian Blatz
71bb4163ed common: fixed double-precision promotion compilation warnings
Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2025-02-12 20:23:34 +09:00
Hermet Park
d44f037bc0 lottie/expressions: force the precision down to single-precision floating point
This also removes some minor compiler warings with "Wdouble-promotion"

issue: https://github.com/thorvg/thorvg/issues/3136
2025-02-12 19:12:06 +09:00
Fabian Blatz
29b612237d infra: added double-precison promotion warning
Note that, for our dev-convenient, this option
is only toggled on when the logging is off.

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2025-02-12 19:12:06 +09:00
Hermet Park
c22af13027 lottie/jerryscript: removed dead code
This eliminates the jerryscript features
which are unlikely to be used by thorvg.

- JERRY_LINE_INFO
- JERRY_PROMISE_CALLBACK
- JERRY_FUNCTION_TO_STRING
- JERRY_MEM_GC_BEFORE_EACH_ALLOC
- JERRY_CPOINTER_32_BIT
- JERRY_REGEXP_STRICT_MODE
2025-02-12 15:50:18 +09:00
Hermet Park
eab9d68e67 api: remove SwCanvas::mempool()
We have improved the functionality to manage the memory pool safely,
by figuring out the current working threads. Users no longer need to
manually configure memory pool management, and the related APIs
have been removed.

API Removals:
- Result SwCanvas::mempool(MempoolPolicy policy)
- enum SwCanvas::MempoolPolicy

- Tvg_Result tvg_swcanvas_set_mempool(Tvg_Canvas* canvas,  Tvg_Mempool_Policy policy)
- enum Tvg_Mempool_Policy

issue: https://github.com/thorvg/thorvg/issues/3116
2025-02-12 13:19:12 +09:00
Mira Grudzinska
3ed357e17a renderer: fix trimmed stroke blinking
Bug introduced as part of a7e7bbc.
After recalculating begin and end to the 0-1 range, an extra
check was added to handle cases when begin is very close to end.
However, this was a bad approach since, even for very close values,
their relationship remains important. What should have been
done in the mentioned commit is properly handling  the case
begin == end, which was incorrectly treated as trimming from begin
to end. Instead, it should be handled as trimming from begin to
1.0 and from 0.0 to end.

@Issue: https://github.com/thorvg/thorvg/issues/3204
2025-02-12 11:36:57 +09:00
Hermet Park
cc4c18d6c6 renderer: revise the Shape rect/circle features
The path direction of shapes is now functional for path trimming.
Replace the main logic with Lottie's by default
to align the spec, migrate the original logic to svg loader side.

This revision helps to reduce the binary size by 2–3 KB for lottie loader.

API Modifications:

- Result Shape::appendRect(float x, float y, float w, float h, float rx = 0, float ry = 0)
 -> Result Shape::appendRect(float x, float y, float w, float h, float rx = 0, float ry = 0, bool cw = true)
- Result Shape::appendCircle(float cx, float cy, float rx, float ry)
 -> Result Shape::appendCircle(float cx, float cy, float rx, float ry, bool cw = true)
- TVG_API Tvg_Result tvg_shape_append_circle(Tvg_Paint* paint, float cx, float cy, float rx, float ry)
 -> TVG_API Tvg_Result tvg_shape_append_circle(Tvg_Paint* paint, float cx, float cy, float rx, float ry, bool cw)
- Tvg_Result tvg_shape_append_rect(Tvg_Paint* paint, float x, float y, float w, float h, float rx, float ry)
 -> Tvg_Result tvg_shape_append_rect(Tvg_Paint* paint, float x, float y, float w, float h, float rx, float ry, bool cw)

issue: https://github.com/thorvg/thorvg/issues/3179
2025-02-12 01:41:02 +09:00