Commit graph

3305 commits

Author SHA1 Message Date
Hermet Park
173edf62a1 portability: added cstdint header properly.
gcc15 is more strict at the header inclusion,
thorvg header should specify it since it reply on it.

issue: https://github.com/godotengine/godot/pull/102022#discussion_r1929547647
2025-01-30 20:37:01 +09:00
Hermet Park
09ebf10432 lottie: revise the effect parsing logic
Unify the common parts of the parsing logic
by applying a strategy pattern,
allowing the behavior to vary based on the effect type.

This helps to reduce the size and improved the parsing safety.
2025-01-30 20:36:02 +09:00
Mira Grudzinska
8f7103e109 gl_engine: add support for stroke/fill ordering 2025-01-30 20:32:45 +09:00
Hermet Park
89e98b6fcb sw_engine: Improved the blur performance by 12%
Applied the compromised approach for the gaussian blur
since the effect is a bit burdensome for cpu processing
as animatable effects.

- Optimized performance and quality with negligible observable differences.
- Disabled the border option until specific use cases are identified.
2025-01-30 20:24:20 +09:00
Hermet Park
819b93a9a4 renderer: improved engine for scalable effects
RenderMethod effects methods would have changes:
 + update()               //update the effects if any
 - prepare() -> region()  //update the effect drawing region
 - effect() -> render()   //draw the effect
2025-01-30 20:23:39 +09:00
Hermet Park
6c0c8865cd lottie/expressions: ++safety
Prevent segfault in case of the omitted name json data
2025-01-30 20:21:09 +09:00
Mira Grudzinska
825c1ab959 bump up version v0.15.9 2025-01-16 23:39:58 +01:00
Jinny You
c64624c8c8 sw_engine: Fix buffer overflow in texture mapping rasterizer
Fix heap buffer overflow in texture mapping rasterizer by adding proper
bounds checking for texture coordinates. This prevents accessing memory
outside of the allocated image buffer during texture sampling and
interpolation.

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>

issue: https://github.com/thorvg/thorvg/issues/3102
2025-01-16 18:50:32 +01:00
Mira Grudzinska
12b9c5fc53 lottie: fix text stroke's 'of' property
The text stroke's 'of' property determines whether
the stroke appears above (true) or below (false)
the fill.
Previously, it was incorrectly used to decide whether
the stroke would render.

@Issue: https://github.com/thorvg/thorvg/issues/3126
2025-01-16 18:49:49 +01:00
Hermet Park
c460591b39 gl_engine: corrected ColorDodge, ColorBurn equation
issue: https://github.com/thorvg/thorvg/issues/3072
2025-01-16 18:44:41 +01:00
Hermet Park
e815fd25e4 sw_engine: assign the stride omitted
This fixes a wrong compositor access
during the rasterization

issue: https://github.com/orgs/thorvg/discussions/3109
2025-01-16 18:41:19 +01:00
faxe1008
6489e65064 common: Use explicit floating-point value types.
Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2025-01-16 18:34:12 +01:00
faxe1008
14ea212535 drenderer: include alloca.h for Zephyr
Changes the conditional for to also include the alloca.h header in case
it is build for the zephyr rtos.
2025-01-16 18:30:36 +01:00
Hermet Park
d7ad915647 webp: --compiler warning
warning: writing 4 bytes into a region of size 0 [-Wstringop-overflow=]
2025-01-16 18:30:19 +01:00
Hermet Park
949c918af9 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-16 18:29:31 +01:00
Hermet Park
3831a90a7d sw_engine: corrected blendings
corrected wrong ColorDodge, ColorBurn, Exclusion, SoftLight blendings

issue: https://github.com/thorvg/thorvg/issues/3072
2025-01-16 18:22:17 +01:00
Jinny You
1ae817b634 lottie/slot: Support transform slot overriding
issue: https://github.com/thorvg/thorvg/issues/2591
2025-01-16 16:11:55 +01:00
Mira Grudzinska
bd8c2fca76 bump up version v0.15.8 2025-01-02 23:59:57 +01:00
Mira Grudzinska
e293d73f11 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 15:10:04 +01:00
Hermet Park
cb0691fee0 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 15:08:43 +01:00
Marcin Baszczewski
978464d87c 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
2025-01-02 15:04:41 +01:00
Hermet Park
d00b727cd4 lottie: support stroke layer effect
issue: https://github.com/thorvg/thorvg/issues/2718
2025-01-02 14:52:36 +01:00
Hermet Park
e0588d39f0 lottie: Fixed a regression in masking logic
The scene tree should be arranged prior to appending the masking.
This was caused by 838785d75a
2025-01-02 14:49:43 +01:00
Hermet Park
b59c7a0bee 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.
2025-01-02 14:48:30 +01:00
Marcin Baszczewski
a5f67ee92c Fix for Rendering Short Paths. 2025-01-02 13:11:21 +01:00
Mira Grudzinska
0fc2e6adcb 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.
2025-01-02 13:11:05 +01:00
Hermet Park
bed521a08c common: refactored the scene effect tint
Pre-convert the data type from float to uint8_t
2025-01-02 13:10:31 +01:00
Mira Grudzinska
4e46f56a80 bump up version v0.15.7 2024-12-20 00:38:19 +01:00
Mira Grudzinska
9b8ff114eb 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-20 00:38:19 +01:00
Hermet Park
00324f5e19 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-20 00:38:19 +01:00
Hermet Park
2eed9f9024 lottie: ++exception handling
dropshadow opacity range seems 0 ~ 256.
make it sure in 0 ~ 255.
2024-12-20 00:38:19 +01:00
Hermet Park
64a5bd039d lottie: support Tritone LayerEffect
issue: https://github.com/thorvg/thorvg/issues/2718
2024-12-20 00:38:19 +01:00
Hermet Park
5131a8ba92 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-20 00:38:15 +01:00
Hermet Park
a69bad43fe lottie: support Tint LayerEffect
issue: https://github.com/thorvg/thorvg/issues/2718
2024-12-20 00:36:26 +01:00
Hermet Park
4050d86f2e 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-20 00:35:40 +01:00
Hermet Park
8585b27abf 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-19 16:29:21 +01:00
RuiwenTang
7031d7fc50 gl_engine: Fix gradient color not correct when shape has opacity
When rendering gradient color, needs to take opacity value into
consider.
2024-12-19 16:27:18 +01:00
Mira Grudzinska
9e4037b4db sw_engine: fix grad calculations
Added a term that was omitted during one of the refactorings.
2024-12-19 16:19:53 +01:00
Hermet Park
0efbc3cce9 infra: --meson deprecated usages
meson.source_root -> meson.project_source_root()
meson.build_root -> meson.project_build_root()
2024-12-19 16:18:49 +01:00
Hermet Park
adf32b5628 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-19 16:18:49 +01:00
Hermet Park
7b8ebcea10 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-19 16:18:44 +01:00
Hermet Park
5c129472ff 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-19 16:12:28 +01:00
RuiwenTang
be538bacf7 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-19 13:27:23 +01:00
Mira Grudzinska
babff908cd bump up version v0.15.6 2024-12-05 21:30:34 +01:00
Mira Grudzinska
f3cc245b37 lottie: add TextCaps property support 2024-12-05 16:45:02 +01:00
Hermet Park
36e5f68222 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-05 13:13:42 +01:00
Dragoș Tiselice
c5a7d76109 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-05 12:20:12 +01:00
Hermet Park
52cf31a79d 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 12:03:15 +09:00
RuiwenTang
c0aab8c738 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-12-02 11:56:00 +09:00
Hermet Park
89ab573acb bump up version v0.15.5 2024-11-27 19:17:23 +09:00