Commit graph

682 commits

Author SHA1 Message Date
Mira Grudzinska
d71e11495d 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-05-26 20:03:46 +02:00
Sergii Liebodkin
55847bdcb3 gl_engine: fix memoty leak on target resize
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
We must to remove offscreen render buffers during removing render target

https://github.com/thorvg/thorvg/issues/3210
2025-05-25 23:04:12 +09:00
Hermet Park
32c38041db sw_engine: added diagnostics for potential issues
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
2025-05-22 16:12:42 +09:00
Mira Grudzinska
1b72113fcc sw_engine: fix too small memory alloc for spans
In some clipping cases, the memory allocated for storing spans
was too small. As a result, the entire clipped area might not
have been rendered.
This has been resolved by adding an experimental factor to increase
the size of allocated memory.

@issue: https://github.com/thorvg/thorvg/issues/3461
2025-05-22 16:03:04 +09: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
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
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
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
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
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
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
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
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
af7fb159d1 wg_engine: ++safety 2025-04-18 13:26:08 +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
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
Benjamin
b38b6b659d common: fix incorrect aabb of scenes 2025-04-10 12:31:28 +09:00
Sergii Liebodkin
eb67549295 gl_engine: Introduce tritone effect for opengl renderer
issue: https://github.com/thorvg/thorvg/issues/3054
2025-04-10 11:36:47 +09:00
Sergii Liebodkin
95f1b84a56 gl_engine: Introduce tint effect for opengl renderer
issue: https://github.com/thorvg/thorvg/issues/3054
2025-04-10 11:36:47 +09:00
Sergii Liebodkin
85e215a294 gl_engine: Introduce fill effect for opengl renderer
issue: https://github.com/thorvg/thorvg/issues/3054
2025-04-10 11:36:47 +09:00
Sergii Liebodkin
595769257e gl_engine: Introduce gaussian blur effect
issue: https://github.com/thorvg/thorvg/issues/3054
2025-04-09 11:16:55 +09:00
Hermet Park
e002d68338 Revert "gl_engine: Introduce gauss blur effect for opengl renderer"
This reverts commit 131c194124.

note: Lottie animation is broken
2025-03-28 00:28:27 +09:00
Sergii Liebodkin
131c194124 gl_engine: Introduce gauss blur effect for opengl renderer
issue: https://github.com/thorvg/thorvg/issues/3054
2025-03-27 22:51:02 +09:00
Hermet Park
afd780bfa9 wg_engine: set default file permissions 644 for consistency 2025-03-27 22:19:36 +09:00
Hermet Park
bd520c1c69 ttf: ++thread safety
Properly allow the ttf loader sharable among threads.

issue: https://github.com/thorvg/thorvg/issues/3165
2025-03-25 17:02:58 +09:00
Hermet Park
756f866d54 renderer: safety++
introduced a threshold for the minimum dash size
to prevent excessive fragmentation.

issue: https://github.com/thorvg/thorvg/issues/3332
2025-03-24 23:50:57 +09:00
Hermet Park
be0cbc356a sw_engine: hotfix a out of bound image access.
this simply revert logic from the previous change:
https://github.com/thorvg/thorvg/pull/2552

issue: https://github.com/thorvg/thorvg/issues/3327
2025-03-24 22:22:13 +09:00
Hermet Park
56d5396b7a common: ++loader thread safety
fortitfy the thread safety
in multi-threaded resource loading.

issue: https://github.com/thorvg/thorvg/issues/3306
2025-03-24 18:18:30 +09:00
Sergii Liebodkin
a1ca566c48 gl_engine: luma visual differneces fix
https://github.com/thorvg/thorvg/issues/3045
2025-03-21 11:03:36 +09:00
Hermet Park
eddd8961f3 common: hotfix regression bugs during recent dev
- fixed Duplicate/Text samples broken
- fixed a Lottie TextPath memory leaks
- fixed a broken SVG gaussian blur
2025-03-20 22:33:36 +09:00
Hermet Park
333e65ef7a renderer: revise the Bounding Box Behavior
- modify the concept of AABB to apply only to transformed shapes.
- transform points before computing the bounding box min/max
  to obtain a more compact shape region.
- trimmming memory by removing the cached matrix, about 36kb
  of memory has been reduced per paint instance.
2025-03-20 13:26:25 +09:00
Sergii Liebodkin
a7efd0f199 wg_engine: crash for empty clips fix
issue: https://github.com/thorvg/thorvg/issues/3289
2025-03-20 11:58:47 +09:00
Jinny You
b350e45e1e wg_engine: remove unnecessary header
The Emscripten header was previously used because the WebGPU initialization logic was in WgContext::initialize.

Now, initialization occurs at the binding/application level.
2025-03-19 18:46:07 +09:00
Hermet Park
563f8b2f78 renderer: added parent scene query api
added 2 more APIs for user convenience to allow backtracking tree traversal.

API Additions:
- const Paint* Paint::scene() const
- const Tvg_Paint* tvg_paint_get_scene(const Tvg_Paint* paint)
2025-03-19 11:19:26 +09:00