Commit graph

3558 commits

Author SHA1 Message Date
Hermet Park
3d6fe5ffae sw_engine: ++portability on macOS
fixed a runtime error report of the sanitizer
at data casting.

issue: https://github.com/thorvg/thorvg/issues/3102
2025-01-09 00:43:30 +09:00
Hermet Park
d72c740ac6 common: properly update the clamp()
A regression brokeage by da54c83b5f
2025-01-09 00:04:18 +09:00
Sergii Liebodkin
222e8a25a1 wg_engine: fix context handle passimg by ref
Use reference insted of value for context passing
2025-01-08 17:21:57 +09:00
Hermet Park
d2d93792df wg_engine: corrected ColorDodge, ColorBurn equation
issue: https://github.com/thorvg/thorvg/issues/3072
2025-01-08 13:54:09 +09:00
Hermet Park
084c7ff214 sw_engine: corrected blendings
corrected wrong ColorDodge, ColorBurn, Exclusion, SoftLight blendings

issue: https://github.com/thorvg/thorvg/issues/3072
2025-01-08 13:27:58 +09:00
Hermet Park
da54c83b5f common/math: revise clamp() aligning with the std style 2025-01-08 13:27:58 +09:00
Jinny You
2a6e3ca40a examples: add slot transform overriding samples 2025-01-07 16:03:37 +09:00
Jinny You
22872a7dd5 lottie/slot: Support transform slot overriding
issue: https://github.com/thorvg/thorvg/issues/2591
2025-01-07 16:03:37 +09:00
Hermet Park
3d999ca1db examples: revise the blending sample
Note that scene blending doesn't work properly
2025-01-07 12:16:07 +09:00
Mira Grudzinska
4818c70dd4 svg: specs ++
Completely remove an element if the applied clip/mask is empty.

@Issue: https://github.com/thorvg/thorvg/issues/3089
2025-01-07 11:05:33 +09:00
Hermet Park
a12accbc93 updated copyright 2025-01-03 14:32:31 +09:00
Mira Grudzinska
3643121956 lottie: enforce fill clipper over stroke clipper
After the stroke clipper is introduced, using clipping
requires ensuring that clipping is based on fill rather
than on stroke. Fixed now.

regression by: 324bff30d1
2025-01-03 11:52:38 +09:00
Mira Grudzinska
acc614ab2f sw_engine: prevent warning
Remove unused version of SUBPIXELS().
2025-01-03 10:24:46 +09:00
Mira Grudzinska
defec5e43b svg_loader: fix transformation order
If a clip was defined by a use node pointing
to a basic shape subject to transformation, and
the use node itself was translated, the order
of applying these transformations was incorrect.
2025-01-02 17:50:25 +09:00
Hermet Park
2fb925a2d7 sw_engine: corrected the rle cell building
Properly build the cell cover value
when a new cell value is just overlapped.

This fixes certain weird visual artifacts at a corner case.

issue: https://github.com/thorvg/thorvg/issues/2929
2025-01-02 17:49:28 +09:00
Hermet Park
47524300bb sw_engine: minor code clean up 2025-01-02 17:49:28 +09:00
RuiwenTang
3c6d686795 gl_engine: fix fbo and texture leak
GlRenderTarget contains framebuffer and render target objects,
these GPU resources need to be released before reusing the structure and calling init with the new size.
2024-12-31 16:25:11 +09:00
Hermet Park
12b3747d08 examples: updates svg resources 2024-12-31 14:02:26 +09:00
Hermet Park
7e810ce54d svg: fixed broken clip regression bugs
introduced by 8492a63

https://github.com/thorvg/thorvg/issues/3083
https://github.com/thorvg/thorvg/issues/3082
2024-12-31 12:36:04 +09:00
Hermet Park
5ea1db128e svg: remove styles from the clipPath
Main purpose clippath is to cutout the
drawing region with a path. Otherwise
we need to use MaskMethod.
2024-12-31 12:36:04 +09:00
Hermet Park
76203c3dbb gl_engine: ensure the gl context switching
This only covers emscripten environment,
need to cover other system.

issue: #3023

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2024-12-31 12:07:52 +09:00
Jinny You
596de01b12 gl_engine: revise target API for context managing
Issue: #3024
2024-12-31 12:07:52 +09:00
Hermet Park
1cbc11cadd renderer: revamped engine interfaces
Introduced updated pre/post calls
for proper preparation of the drawing process.
2024-12-31 12:07:52 +09:00
Hermet Park
ccf5a8158f gl_engine: ++binary optimization
- removed unique_ptr, shared_ptr
- replaced std::vector with tvg::Array
- reduced binary size by -10kb
2024-12-30 22:24:53 +09:00
Jinny You
38a4465656 lottie: fix viewport clipping issue when resize
After resizing an animation, the base clipper for the viewport of the root scene did not update accordingly. This caused the animation to always be clipped by its initial size.

Additionally, this issue introduced a regression in v1 when the `Result Picture::size(float w, float h)` function was called.

issue: https://github.com/thorvg/thorvg/issues/3039
2024-12-30 14:52:42 +09:00
Mira Grudzinska
82dc41479e sw_engine: fix clipping
A shape with both fill and stroke, where clipping left
only a fragment of one (either fill or stroke), was not
rendered at all. Now fixed.
2024-12-30 12:01:24 +09:00
Hermet Park
75a4c7f543 api: aligned enum values with the lottie spec
Please note that this could occur ABI break.
2024-12-27 21:16:27 +09:00
Hermet Park
0e9bc74603 api: renamed FillRule::Winding to NonZero
aligned the name with the web standard.
2024-12-27 21:16:27 +09:00
Marcin Baszczewski
f2883a31da gl_engine: Fix for rendering short paths
Ensure they do not terminate prematurely for paths
with a step of 0 or exceptionally small values
when a valid stroke-width is present.

In my opinion, the optimal approach was to separate vertex generation
into dedicated methods: strokeRoundPoint and strokeSquarePoint.

My update supports two different stroke-cap styles.
I have also tested it with various files (JSON, SVG)
as well as a small example application similar
to the one included in the previous pull request (#3066).

issue: https://github.com/thorvg/thorvg/issues/3065
2024-12-27 21:11:38 +09:00
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