Commit graph

3765 commits

Author SHA1 Message Date
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
Hermet Park
d6335015c4
Update README.md 2024-11-29 22:45:16 +09:00
RuiwenTang
08e88c8df1 gl_engine: Fix the wrong bounds cause composition not correct
The bounds should allow negative origins, only zero width or height bounds needs discard.
2024-11-29 19:32:15 +09:00
Sergii Liebodkin
18db3ab1fd wg_engine: refactor pipeline creation
Pipeline creation workflow redesigned. Make code more compact
No any public interfaces changed
2024-11-29 19:08:28 +09:00
Sergii Liebodkin
4a38a4d360 wg_engine: simplify shader types
Use universal vec4f type for blend settings and color to pass data as shader parameter
2024-11-29 19:01:47 +09:00
Sergii Liebodkin
163640b3e5 wg_engine: apply texture formats on creation (refactoring)
Apply texture color space on texture creation, instead of shader side
2024-11-29 18:57:57 +09:00
Sergii Liebodkin
13b976ee80 wg_engine: support resizing
Added abillity to resize target (surface)
In case of resizing only render targets handles recreated
Issue: https://github.com/thorvg/thorvg/issues/2985
2024-11-29 18:48:01 +09:00
Sergii Liebodkin
cf05128a96 wg_engine: revision of device creation policy
make valid device and instance as mandatory paramter for webgpu renderer
2024-11-29 18:48:01 +09:00
Sergii Liebodkin
77201546dd wg_engine: separate pipelines ans bind group layouts (refactoring)
The main reason of refactoring is to separate bind group sets and pipelines, and change owning of pipelines to compositor
2024-11-27 11:31:35 +02:00
Hermet Park
af7dbf2277 lottie: ++parser stability
fixed a parsing failure that occurred
when a desired single value was presented as part of an array.

issue: https://github.com/thorvg/thorvg/issues/2975
2024-11-27 16:54:33 +09:00
Jinny You
7e66bde4fb wasm: fix build error
Added missing parameter for `GlCanvas->target`
2024-11-27 16:48:26 +09:00
RuiwenTang
1a766ec00e gl_engine: correct the stroke alpha calculation
The wrong matrix scale factor value caused the stroke alpha to be zero
when the matrix contains rotation.
2024-11-27 12:37:47 +09:00
Hermet Park
968e438d25 portability: fixed a compile error on msys2 2024-11-26 22:00:08 +09:00
Hermet Park
08110da33b
Update README.md 2024-11-26 17:23:37 +09:00
RuiwenTang
af5e0e3ef9 gl_engine: support cross compile GL backend into WASM
Support cross compile the GL backend code into WASM.
The code needs WebGL 2.0 API so, the compile flags contains `MAX_WEBGL_VERSION` and `FULL_ES3`
Also add binding code to initialize the WebGL context and GLCanvas.
2024-11-26 17:12:49 +09:00