Commit graph

3554 commits

Author SHA1 Message Date
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
Mira Grudzinska
5c950b783c renderer: handle edge cases for trimming with dashing
- In cases where the begin and end values of trimming did not
result in trimming (end - begin > 1), trimming was ignored.
However, when the stroke is also dashed, this case affects
the shift of the point where the first dash becomes visible.

- Trimming that passes through the curve's start point (like -0.1:0.1)
requires passing through the curve twice. The points obtained from
both passes must be joined - visible when dashing
Cases for simultaneous = true have been handled.

@Issue: https://github.com/thorvg/thorvg/issues/3192
2025-02-11 19:46:13 +09:00
Hermet Park
3c25623ee9 sw/gl/wg: ++threads safety
Considered global engine initialization and termination.
Engines could be used among multiple worker threads.
2025-02-11 19:03:50 +09:00
Hermet Park
f64fb088b4 doc: updated supported platforms 2025-02-10 01:35:50 +09:00
Hermet Park
7c3015ba28 infra: sync up the github labeler 2025-02-07 23:58:35 +09:00
Hermet Park
ab950b6321 sw_engine: fixed a broken dropshadow
corrected a mismatched stride value of the
direct drawing target buffer.

issue: https://github.com/thorvg/thorvg/issues/3146
2025-02-07 23:46:40 +09:00
Hermet Park
c1290a8205 doc: up-to-date CONTRIBUTION guide 2025-02-07 13:04:19 +09:00
Mira Grudzinska
d5125bd839 common: add missing condition while trimming
The idea of introducing epsilon during trimming was to
eliminate the occurrence of short segments whose length
would be zero when higher computational accuracy was used.
By mistake, during the refactor of 8ed4c2f302,
one of the conditions was lost. Fixed.

@Issue: https://github.com/thorvg/thorvg/issues/3053
2025-02-07 12:43:38 +09:00
Hermet Park
37c4ace685 infra: rectify the meson build command to meet the standard. 2025-02-07 12:35:24 +09:00
Mira Grudzinska
3a0e1eadae gl_engine: apply common trimming logic
The trim-related implementation has been removed
and replaced with the one available in common.
The trimPath get() fun changed to be internal.

@Issue: https://github.com/thorvg/thorvg/issues/2854
@Issue: https://github.com/thorvg/thorvg/issues/3053
2025-02-06 22:39:11 +09:00
Mira Grudzinska
cb8cadfbba wg_engine: apply common trimming logic
The trim-related implementation has been removed
and replaced with the one available in common.

@Issue: https://github.com/thorvg/thorvg/issues/2854
2025-02-06 22:39:11 +09:00
Mira Grudzinska
8ed4c2f302 sw_engine: move trimming logic to TrimPath
The trim handling from sw_engine has been removed.
Instead the common logic from the TrimPath structure
is used.
On the sw_engine side, the dashed outline is now
used for both: dashed and/or trimmed strokes.

@Issue: https://github.com/thorvg/thorvg/issues/2854
2025-02-06 22:39:11 +09:00
Mira Grudzinska
669d6dc580 common: introduce TrimPath struct
The first step towards unifying trimming across engines.

@Issue: https://github.com/thorvg/thorvg/issues/2854
2025-02-06 22:39:11 +09:00
Hermet Park
4f0f2e4c08 example: removed interaction sample
LottieTweening is replaced with it.
2025-02-06 19:09:27 +09:00
Hermet Park
be0949339c example: added lottie tweening sample 2025-02-06 19:09:27 +09:00
Hermet Park
78cfc33f4c lottie: support frame tweening feature
frame tweening allows user to interpolate two frames
over a speicified duration. This Tweening functionality
can be particularly powerful when combined with state-based
(a.k.a. Marker) animation playback in Lottie.

For example, apps support state machine based animations,
where the transition sequences between states are not linear
and can occur in highly irregular directions.

Experimental APIs:
- Result LottieAnimation::tween(float from, float to, float progress)
- Tvg_Result tvg_lottie_animation_tween(Tvg_Animation* animation, float from, float to, float progress)
2025-02-06 19:09:27 +09:00
Hermet Park
0dd0a3b45c common: neat code++
introduced common BBox structure
2025-02-06 15:40:32 +09:00
Sergii Liebodkin
857f1404e1 wg_engine: gaussian blur basic implementation
Introduce blur effect for webgpu renderer
Issue: https://github.com/thorvg/thorvg/issues/3054
2025-02-06 14:44:08 +09:00
Hermet Park
04530ab6c2 doc: updated svg sample image 2025-02-06 13:53:16 +09:00
Hermet Park
1d90608edc lottie: chores++ 2025-02-06 12:21:16 +09:00
Hermet Park
2a4dfcd10e lottie: revised the shape modifiers
- use a decoration style for path-modification chaining.
- use a reusable buffer for intermediate path generation.
2025-02-06 12:21:16 +09:00
Hermet Park
f4a2c922be lottie: minor optimization
use a reusable buffer for intermediate path generation.
2025-02-06 12:21:16 +09:00
Hermet Park
4edaf311c6 lottie: ++compact & neat code
introduced RenderPath to minimize the path parameters.
2025-02-05 19:55:12 +09:00
Hermet Park
35dac266dd lottie: neat code++ 2025-02-05 15:15:01 +09:00
Hermet Park
8add23dd3a lottie: allow expressions for the text properties 2025-02-05 14:26:44 +09:00
Hermet Park
3e337083e8 lottie: compact code & size++ 2025-02-04 23:07:56 +09:00
Hermet Park
8833cc8521 commmon: ++neat code
introduced ARRAY_REVERSE_FOREACH() macro.
2025-02-03 21:47:43 +09:00
Mira Grudzinska
580019b64b gl_engine: fix color burn/dodge edge cases
Aligned with sw_engine implementation.
2025-02-03 15:06:39 +09:00
Mira Grudzinska
e7e168a28b wg_engine: fix color burn/dodge edge cases
Aligned with sw_engine implementation.
2025-02-03 15:06:39 +09:00
Mira Grudzinska
41f10b9702 sw_engine: fix color burn/dodge edge cases
Dodge d / (1 - s):
- handle d = 0 first to avoid 0/0 when s = 1
- for d != 0 and s = 1, the formula results in d/0 (infinity),
  which maps to 1 in the 0-1 range (or 255 in the 0-255 range)

Burn 1 - (1 - d) / s:
- handle d = 1 first to avoid 0/0 when s = 0
- for d != 1 and s = 0, the formula results in  1 - 0/0 -> 1 - inf = -inf
  Negative infinity in the 0-1 range corresponds to the minimum possible
  value, which is 0 (255 if we operate in 0-255 range).
2025-02-03 15:06:39 +09:00
Mira Grudzinska
9c864f3e99 common: more accurate clipped viewport rounding
Replaced ceil and direct casts with nearbyint to improve
viewport size calculation. This ensures consistent
approach with the fastTrack case in sw_engine.

@Issue: https://github.com/thorvg/thorvg/issues/3148
2025-02-03 14:54:03 +09:00
Popolon
02be99185e include <cstring> in examples/Example.h 2025-02-03 11:23:34 +09:00