Commit graph

3579 commits

Author SHA1 Message Date
Hermet Park
b041bdab4a lottie: support stroke layer effect
issue: https://github.com/thorvg/thorvg/issues/2718
2024-12-26 18:40:40 +09:00
Hermet Park
713840eb42 lottie: Fixed a regression in masking logic
The scene tree should be arranged prior to appending the masking.
This was caused by 838785d75a
2024-12-26 18:13:10 +09:00
Hermet Park
5e102dfd25 API: enable users to use an accessor to traverse Scene
remove the restriction of targeting only Picture.
now, any kind of paints can be adaptable here.
2024-12-26 14:20:37 +09:00
Hermet Park
041ab1117b renderer: fixed a memory leak
This issue only valid on the main branch.

regression by 1806b32971

issue: https://github.com/thorvg/thorvg/issues/3070
2024-12-24 10:44:57 +09:00
Marcin Baszczewski
37c7e1efa6 Fix for Rendering Short Paths. 2024-12-23 18:56:56 +09:00
Mira Grudzinska
72482877e7 portability: fix file size check on Windows
Resolved an issue where parsing failed due to mismatch
between file size obtained via `ftell` and the actual
bytes read by `fread`. This occurred because newline
translation (`\r\n` to `\n`) in text mode altered the byte
count, leading to incorrect assumptions about the data size.
2024-12-23 01:09:00 +09:00
Hermet Park
285d1427ad common: refactored the scene effect tint
Pre-convert the data type from float to uint8_t
2024-12-20 12:10:11 +09:00
Hermet Park
0437d482bd example: updated with a stroknig clipper 2024-12-19 20:37:28 +09:00
Hermet Park
324bff30d1 sw_engine: allow the stroke clipper
clipping with a stroke is useful for various visual effects.
TVG can support this approach as it offers better efficiency
compared to alpha masking.

If a valid stroke is defined in the clipper shape,
the renderer prioritizes clipping with the stroke over
 the shape's fill.

issue: https://github.com/thorvg/thorvg/issues/3063
2024-12-19 20:37:28 +09:00
Mira Grudzinska
0f253aac27
renderer: fix dash offset
The dash offset value was not copied while
'=' opetator was applied.

@Issue: https://github.com/thorvg/thorvg/issues/1643
2024-12-19 11:40:20 +09:00
Hermet Park
838785d75a lottie: revise the masking logic
- Allow the masking data even though they were mask None mode.
  Those will be used by the layer stroke effect.
- Fixed masking Offset to apply to all masking chains.
- Optimized fast track masking with resolving the opaicty condition.
- Clean up the overall code.
2024-12-18 23:51:47 +09:00
Hermet Park
29bf244265 lottie: ++exception handling
dropshadow opacity range seems 0 ~ 256.
make it sure in 0 ~ 255.
2024-12-18 19:05:59 +09:00
Hermet Park
9b43b93d1c doc: updated effects 2024-12-18 14:37:34 +09:00
Hermet Park
17fd454459 lottie: support Tritone LayerEffect
issue: https://github.com/thorvg/thorvg/issues/2718
2024-12-18 14:37:30 +09:00
Hermet Park
8ec2eee6e3 example: added Tritone Scene Effect 2024-12-17 17:55:34 +09:00
Hermet Park
e9fb478471 renderer: support Trintone SceneEffect
The Tritone effect maps the scene's shadows, midtones, and highlights
to three specific colors, allowing for more complex and artistic color grading.

Applied Tritone Formula:
if (L < 0.5) Result = (1 - 2L) * Shadow + 2L * Midtone
else Result = (1 - 2(L - 0.5)) * Midtone + (2(L - 0.5)) * Highlight
Where the L is Luminance.

issue: https://github.com/thorvg/thorvg/issues/2718
2024-12-17 17:54:57 +09:00
Hermet Park
1eff126b40 lottie: support Tint LayerEffect
issue: https://github.com/thorvg/thorvg/issues/2718
2024-12-17 12:16:44 +09:00
Hermet Park
8e8611b608 examples: added tint scene effect
also, merged gausiaan, fill altogether in SceneEffects
2024-12-17 12:16:44 +09:00
Hermet Park
b778f98206 common: support Tint SceneEffect
The Tint effect in ThorVG is used to modify the overall color tone of a scene.
It works by blending a specified tint color with the existing colors of the scene.
This effect is useful for color grading, mood changes, or applying thematic filters
to vector graphics and animations.

Applied the equation is:
Result = (1 - L) * Black + L * White, where the L is Luminance.

issue: https://github.com/thorvg/thorvg/issues/2718
2024-12-17 12:16:40 +09:00
Hermet Park
1806b32971 common: optimization pImpl data structures
ThorVG pImpl idiom caused internal data to be scattered
across hierarchical classes. This refactoring consolidates
the data by inheriting pImpl internally, reducing memory
allocation counts and eliminating unnecessary strategy methods.
2024-12-14 12:24:57 +09:00
Hermet Park
01f4d6304a sw_engine: fixed a rendering bug when the invalid clipper is applied.
Shapes with boundaries outside the rendering area are ignored as non-visible.
The issue arises when such a shape serves as a clipper.
The expected behavior is for the entire clipee to be cut out,
but previously, the clipee remained fully visible as if no clip was applied.

The fix identifies these clippers and skips rendering clipees.

Please note that we can skip rendering at the Paint update stage
if the clipper's viewport is outside the canvas.
This optimization can improve performance, but only for this specific case.
The downside of the approach is that it disrupts multi-processing for clipper updates.
As a result, that approach was discarded.

issue: https://github.com/thorvg/thorvg/issues/3003
issue: https://github.com/thorvg/thorvg/issues/2684

Co-Authored-By: Mira Grudzinska <mira@lottiefiles.com>
2024-12-14 01:30:56 +09:00
Mira Grudzinska
e395961f3b sw_engine: remove redundant code
The only scenarios where 'check valid region' and
'check boundary' occur are when mathUpdateOutlineBBox()
returns true. This, in turn, happens only if mathClipBBox()
returns true. If that is the case, it means that just
before this return, exactly the same checks were performed.
2024-12-14 01:17:21 +09:00
RuiwenTang
b1b7a78dd7 gl_engine: Fix gradient color not correct when shape has opacity
When rendering gradient color, needs to take opacity value into
consider.
2024-12-13 23:44:03 +09:00
Jinny You
8237eea4e9 wasm: handle WebGPU initialization failure case 2024-12-13 14:53:55 +09:00
Jinny You
5d617c0821 wasm: remove ASYNCIFY to reduce binary size
The binary size recently increased due to the ASYNCIFY option, which was required for WebGPU initialization.

To prevent unnecessary binary size growth, ThorVG will no longer depend on asynchronous processes such as `emscripten_sleep` (ASYNCIFY or JSPI).

As a result, the combined WASM binary size has been significantly reduced to less than 1MB.

Size comparison: 1559KB → 998KB (-36%)
2024-12-13 14:53:55 +09:00
Mira Grudzinska
2e84315857 sw_engine: fix grad calculations
Added a term that was omitted during one of the refactorings.
2024-12-13 11:23:10 +09:00
Hermet Park
79cbc0ebbc infra: --meson deprecated usages
meson.source_root -> meson.project_source_root()
meson.build_root -> meson.project_build_root()
2024-12-13 01:20:25 +09:00
Hermet Park
70fe8f2f95 sw_engine: --compiler warnings on MSYS2
comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'long int' [-Wsign-compare]
2024-12-13 00:45:24 +09:00
Hermet Park
a0a7ec25a2 lottie: support Layer Effect Fill type
During the fill properties, only color/opacity is available.
Not support other properties since they are unclear spec now.

issue: https://github.com/thorvg/thorvg/issues/2718
2024-12-12 18:50:33 +09:00
Hermet Park
666dcbcb38 examples: add Fill SceneEffect sample 2024-12-12 18:50:33 +09:00
Hermet Park
d6c80f538c renderer: add a new scene effect type - Fill
Fill is used for overriding the scene content color
with a given fill information. It's yet an Experimental API.

issue: https://github.com/thorvg/thorvg/issues/2718
2024-12-12 18:50:33 +09:00
Hermet Park
e34ba91ff1 lottie: code refactoring
removed a unused parameter.
2024-12-12 13:38:55 +09:00
Jinny You
aaa5c05cd0 wasm: update canvas API usage from clear() to remove()
Following ThorVG API changes (#1372), updated the canvas handling:
- Replaced Canvas::clear() calls with Canvas::remove()
- Updated Canvas::draw() usage to handle buffer clearing
2024-12-11 14:19:53 +09:00
RuiwenTang
7e7747d645 gl_engine: Fix calculation error in path triming
Basically rewrite the PathTrim code, correct the Line and Bezier split
function calling.
Also the trim situation where start is greater than end can be handled correctly.
2024-12-11 12:23:02 +09:00
Sergii Liebodkin
482bd50157 wg_engine: Improve resizing mechanics
In case of resizing recreate only render targets, but not all compositor handles
2024-12-11 12:08:47 +09:00
Jinny You
f017bb84c1 wasm: reduce WebGPU stack size
Reduce stack size to 2MB for optimized memory usage
2024-12-10 21:11:06 +09:00
Hermet Park
6761c5c2a0 API: Replace the Canvas::clear() API with Canvas::remove() & draw()
Added a `clear` parameter to Canvas::draw(), allowing users to decide
whether to clear the target buffer before drawing.

To remove the paints from a canvas, please use Canvas::remove()

C++ API Removals:
- Result Canvas::clear(bool paints, bool buffer)

C++ API Modifications:
- Result Canvas::draw()
 -> Result Canvas::draw(bool clear)

C API Removals:
- Tvg_Result tvg_canvas_clear(bool paints, bool buffer)

C API Modifications:
- Tvg_Result tvg_canvas_draw(Tvg_Canvas* canvas)
 -> Tvg_Result tvg_canvas_draw(Tvg_Canvas* canvas, bool clear)

issue: https://github.com/thorvg/thorvg/issues/1372
2024-12-10 11:59:46 +09:00
Hermet Park
b24d196809 lottie: code clean up
- a file name (LottieCommon -> LottieData) was changed
- removed duplicate code
- removed dead code
2024-12-09 19:39:29 +09:00
Mira Grudzinska
6b416409c3 lottie: add TextCaps property support 2024-12-06 00:40:48 +09:00
Hermet Park
a2d2b3f07c example: update EffectGaussianBlur 2024-12-04 22:31:37 +09:00
Hermet Park
445000ba66 common: improve the rendering pipeline
enhanced the rendering composition target to better support features such as
alpha blending, blending, masking, post effects, and more.
This allows rasterizers to prepare the composition context with more precise control.

Additionally, resolved a crash in the software engine's post-effect process
caused by a buffer size mismatch during XY buffer flipping.

issue: https://github.com/thorvg/thorvg/issues/3009
issue: https://github.com/thorvg/thorvg/issues/2984
2024-12-04 22:31:37 +09:00
Jinny You
bb5ba81149 wasm: switch to Emscripten-specific WebGPU header
Use <emscripten/html5_webgpu.h> for browser-specific WebGPU support.
2024-12-04 19:00:18 +09:00
Hermet Park
0ebbc614be api: 1.0 specification revision
- Enhanced Scene management to provide users with more control.
- Scenes now support adding specific scenes at defined positions and removing them as needed.
- Ensure safe access to Canvas, Scene paints() by adding const specifiers.
- Removed virtual specifier for the canvas primitive apis.
- Introduced a nested scene in the canvas to remove logic duplication.

C++ API Modification:
- Result Scene::push(Paint* paint)
 -> Result Scene::push(Paint* target, Paint* at = nullptr)
- Result Scene::clear(bool free = true)
 -> Result Scene::remove(Paint* paint = nullptr)
- Result Canvas::push(Paint* paint)
 -> Result Canvas::push(Paint* target, Paint* at = nullptr)
- list<Paint*>& Scene::paints()
 -> const list<Paint*>& Scene::paints() const
- list<Paint*>& Canvas::paints()
 -> const list<Paint*>& Canvas::paints() const

C++ API Addition:
- Result Canvas::remove(Paint* paint = nullptr);

C API Modifications:
- Tvg_Result tvg_scene_clear(Tvg_Paint* scene, bool free)
 -> Tvg_Result tvg_scene_remove(Tvg_Paint* scene, Tvg_Paint* paint)

C API Addition:
- Tvg_Result tvg_scene_push_at(Tvg_Paint* scene, Tvg_Paint* target, Tvg_Paint* at)
- Tvg_Result tvg_canvas_push_at(Tvg_Canvas* canvas, Tvg_Paint* target, Tvg_Paint* at)
- Tvg_Result tvg_canvas_remove(Tvg_Canvas* canvas, Tvg_Paint* paint)

issue: https://github.com/thorvg/thorvg/issues/2957
issue: https://github.com/thorvg/thorvg/issues/1372
2024-12-04 11:44:58 +09:00
Sergii Liebodkin
07fbe56162 wg_engine: fixed scene blending equation and clear color rule
Issue: https://github.com/thorvg/thorvg/issues/2998
2024-12-04 11:39:57 +09:00
Dragoș Tiselice
8f13920b7a capi: removed default argument from C API.
C does not support default arguments. For thorvg_capi.h to maintain
C compatibility, default arguments must be omitted.
2024-12-04 00:27:17 +09:00
Dragoș Tiselice
8a5710b3c5 sw_engine: replaced longjmp with returns
Since longjmp is not yet fully supported on Wasm (emscripten uses
JS to make the jumps and requires slow jumps), but also because
longjmp is hard to reason about, this patch replaces it with
return values. The logic stays exactly the same.
2024-12-03 20:27:41 +09:00
Hermet Park
1d905e806b capi: maintain consistency in Doxygen formatting
- Standardized usage of "\" and "@" across the documentation.
- Aligned formatting with C++ Doxygen style guidelines.
2024-12-03 11:40:25 +09:00
Jinny You
7b9c58fec3 wasm: add gl option to combined binary 2024-12-02 17:06:29 +09:00
Hermet Park
f33b63abad common: inlist code refactoring
introduced INLIST_FOREACH() / INLIST_SAFE_FOREACH()
for common implementation
2024-12-02 15:15:35 +09:00
Hermet Park
1422c4ca5f renderer: make the file io configurable
certain systems, may not support file I/O operations.
ThorVG should provide users with an option to configure
builds according to their requirements.

This ensures that file I/O calls are avoided,
preventing potential crashes.

Please use the meson '-Dfile=true/false' option for this.

Please note that "THORVG_FILE_IO_SUPPORT" might be expected
for your thorvg manual build.

issue: https://github.com/thorvg/thorvg/issues/3008
2024-12-02 11:50:59 +09:00