Commit graph

2875 commits

Author SHA1 Message Date
Mira Grudzinska
708b24b589 ttf/api: add metrics() api
Introduced the GlyphMetrics struct and the API:
  Result metrics(GlyphMetrics** metrics, uint32_t* size)
This allows retrieving glyph metrics for a given Text object.
The font and utf8 content must be set beforehand using
the font() and text() apis.

Memory for the metrics array is allocated internally by the API.
It is the user's responsibility to free it by calling the same API
with a valid metrics pointer and a nullptr passed as size.

@Issue: https://github.com/thorvg/thorvg/issues/3397
2025-05-22 00:17:39 +02:00
Hermet Park
e01ccb5db9 sw_engine: handle an exception ASAP
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-05-21 17:30:32 +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
e98b87892b gl_engine: revert some wrong change
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
my fault. signed value should be respected
from cd12618529
2025-05-16 02:08:25 +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
Hermet Park
cd12618529 common/array: ++neat code
no logical changes
2025-05-14 21:53:32 +09:00
Hermet Park
7e8743e8fe wg_engine: ++exception handling 2025-05-13 16:28:01 +09:00
Hermet Park
5154e491cc wg_engine: ++optimal logic
avoid using initializer here.
2025-05-13 14:47:40 +09:00
Hermet Park
5ed719dcec sw_engine: code clean up
removed unnecesary parameters
2025-05-12 17:37:40 +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
Hermet Park
3fbb55440a renderer: ++engines safety
Added drawing exceptions when target is not properly ready.

Now, Canvas::update() Canvas::draw() will return InsufficientCondition
if the target has not been set beforehand.
2025-05-12 12:49:10 +09:00
Hermet Park
007879af02 gl_engine: code clean up++ 2025-05-08 22:56:16 +09:00
Hermet Park
df8d327ebb sw_engine: fixed a a regression bug during main dev
borker by 176573ff25
2025-05-08 22:56:16 +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
0b77659136 infra: added opengl_es extra option for explicit selection
usages:
meson setup build -Dengines="gl"  //opengl
meson setup build -Dengines="gl" -Dextra="opengl_es"  //opengl es
2025-05-08 12:00:22 +03:00
Hermet Park
457b019ab4 gl_engine: --compiler warning on emsdk.
warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
2025-05-08 15:07:17 +09:00
RuiwenTang
ec26784266 gl_engine: dynamic load gl functions
no any 3rd-party libs, such as glfw or glad did not used
support windows, linux, macos and emsdk
only the actually used set of functions are loaded

Co-Authored-By: Sergii Liebodkin <sergii@lottiefiles.com>
Co-Authored-BY: Hermet Park <hermet@lottiefiles.com>

issue: https://github.com/thorvg/thorvg/issues/2453
2025-05-08 14:58:13 +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
Hermet Park
ae84708f9b sw_engine: fix regression in alpha handling
revert the alpha skip condition introduced in
commit 2990e72b23.

color values with alpha = 0 must be transformed to 0
to ensure correct intermediate composition results.
2025-05-07 10:54:08 +09: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
Benjamin
607c338799 capi: added missing mask methods
Adds missing mask methods to the capi
2025-05-07 10:44:06 +09:00
Benjamin
7c9bead192
wg_engine: fixed target surface update
Allows the target surface to be updated without forcing the size to changed.
2025-05-06 23:54:50 +09:00
Benjamin
2990e72b23 sw_engine: ++raster color accuracy
Improves the color accuracy of rasterized images by skipping the pre-multiply step when the alpha is full opaque or fully transparent.

fixes: #3429
2025-05-05 15:23:30 +09:00
Jinny You
7bcee79077 gl_engine: replace std::string with C-style strings for portability
- C-style strings provide consistent binary interface for FFI
- Reduces potential issues where standard library is limited (e.g., WebAssembly, embedded systems)
2025-05-02 17:43:25 +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
Benjamin
40453a4986 wg_engine: fixed target texture update
Allows the target texture to be updated without forcing the size to changed.
2025-05-01 10:56:15 +03:00
Sergii Liebodkin
37cffba620 wasm: fix thorvg wasm binding
Fixed initialization and termination of the engine in wasm binding
2025-04-24 22:28:37 +09:00
Sergii Liebodkin
e24c743ab3 wasm binding fixed for wg engine
fixed wrong logic in wg engine initialization process, where initializer return seccuss status in any case
2025-04-23 21:20:47 +09:00
Sergii Liebodkin
c77b6ec8db wg_engine: sync up to update the engine work to webgpu_native v22
Only minor changes required
Keeped compatibility with emsdk

issue: https://github.com/thorvg/thorvg/issues/2909
2025-04-23 21:20:47 +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
53e5e783b7 api: revise engine initialization and termination
Simplified parameters and ensured proper backend engine
initialization by using reference checking through canvas
instances.

C++ API Modification:
- Result Initializer::init(uint32_t threads, CanvasEngine engine)
 -> Result Initializer::init(uint32_t threads)
- Result Initializer::term(CanvasEngine engine)
 -> Result Initializer::term()

C API Modification:
- Tvg_Result tvg_engine_init(Tvg_Engine engine_method, unsigned threads)
 -> Tvg_Result tvg_engine_init(unsigned threads);
- Tvg_Result tvg_engine_term(Tvg_Engine engine_method)
 ->  Tvg_Result tvg_engine_term()

issue: https://github.com/thorvg/thorvg/issues/3116
2025-04-23 15:46:49 +09:00
Hermet Park
4cf68b75e5 renderer: code clean++ 2025-04-22 00:13:40 +09:00
Hermet Park
4c3beb1cb1 sw_engine: --size reduction
basically, sw engine aims for 32bits, it reduces
the bundle size by 1kb.

Need to carefully see any side effect in practice.
2025-04-21 17:52:28 +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
af7fb159d1 wg_engine: ++safety 2025-04-18 13:26:08 +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
Sergii Liebodkin
858205a132 webgpu: replace readonly strorages to texture2d (v24 migration)
https://github.com/thorvg/thorvg/issues/2909
2025-04-17 11:25:04 +09:00
Mira Grudzinska
a2f9b6da21 wg_engine: fix drop shadow blended color
The shadow color must be premultiplied. To avoid
repeating this operation in the fragment shader,
the passed shadow color is already premultiplied.
2025-04-17 11:18:47 +09:00
Mira Grudzinska
3b634064c9 gl_engine: fix drop shadow blended color
The shadow color produced incorrect results after
blending with the texture color. This was caused
by not taking the alpha value into account in the
specified shadow color (with OpenGL blending disabled).
2025-04-17 11:18:47 +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
Mira Grudzinska
3fbc36629f renderer: add missing RenderUpdateFlag
Flag was missing in the appendRect().
2025-04-16 18:38:51 +09:00
Hermet Park
176573ff25 renderer: fixed a clippging update isssue
ThorVG did not consider updates to the clipping path
when a paint object was modified after being added to the scene.

This fix ensures that any updates to clipping are correctly
reflected during rendering.

issue: https://github.com/thorvg/thorvg/issues/3403
2025-04-16 18:37:56 +09:00
lpogic
feda6bcbc2 Added null check in Paint::Impl:clip
issue: https://github.com/thorvg/thorvg/issues/3404
2025-04-16 11:23:14 +09:00
Sergii Liebodkin
6c3fee84ec gl_engine: introduce dropshadow effect for opengl renderer
issue: https://github.com/thorvg/thorvg/issues/3054
2025-04-15 11:43:32 +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