Commit graph

2666 commits

Author SHA1 Message Date
Hermet Park
f733e42c95 portability: removed a compiler waring
D:\Projects\thorvg\src\loaders\lottie\tvgLottieParserHandler.h(52): warning C4083: expected ')'; found identifier 'effc'
[44/46] Compiling C++ object src/thorvg-0.dll.p/loaders_lottie_tvgLottieParserHandler.cpp.obj
D:\Projects\thorvg\src\loaders\lottie\tvgLottieParserHandler.h(52): warning C4083: expected ')'; found identifier 'effc'
[45/46] Compiling C++ object src/thorvg-0.dll.p/loaders_lottie_tvgLottieParser.cpp.obj
D:\Projects\thorvg\src\loaders\lottie\tvgLottieParserHandler.h(52): warning C4083: expected ')'; found identifier 'effc'

I'm not sure this option is really necessary.
2024-03-29 16:41:32 +09:00
Hermet Park
128923c05d lottie: polish up a comment. 2024-03-29 16:41:22 +09:00
Hermet Park
e69d63688b lottie: Removed redundant code.
The settings were incorrect;
'direction' and 'fillRule' do not have a relationship.
2024-03-29 13:45:19 +09:00
Hermet Park
a1463cdc3e lottie: optimize the rendering performance.
this optimization nicely merges shapes
when a child group has a only (transformed) pathes.

this also fixes the following compatibility issue nicely.

issue: https://github.com/thorvg/thorvg/issues/2061
2024-03-29 12:28:16 +09:00
Hermet Park
41ae563a84 lottie: optimize the rendering by preventing partial rendering branches.
this optimization is to figure out if this group is a simple path drawing.
In that case, the rendering context can be sharable with the parent's.
2024-03-29 12:28:16 +09:00
JunsuChoi
fdebb15dcb loader/svg: Check whether href id of use is parent or not
When finding the 'nodeFrom' referenced by `<use>`,
if it is the parent, it is not referenced.

https://www.w3.org/TR/SVG2/struct.html#UseElement
Specification:
If the referenced element is a (shadow-including) ancestor
of the ‘use’ element, then this is an invalid circular reference
and the ‘use’ element is in error.

related issue: https://github.com/thorvg/thorvg/issues/2078
SVG_FILE_65171.svg
SVG_FILE_65172.svg
2024-03-28 22:53:57 +09:00
JunsuChoi
46448a1520 loader/svg: Do recalc after gradient inheritance
Inherit gradientUnits and recalculate each element
radial(cx, cy, r,...), linear(x1, y1, x2, y2).

related issue: https://github.com/thorvg/thorvg/issues/2078
2024-03-28 22:52:45 +09:00
Hermet Park
d6504ed35d doc: List the parameters in their respective order. 2024-03-28 14:01:17 +09:00
Sergii Liebodkin
7a9b23fe71 wg_engine: render buffers usage refactorings
[issues 1479: strokes](#1479)

- update buffers via memory mapping
- refactoring of winding fill rule computation
2024-03-28 10:49:29 +09:00
Hermet Park
41f835598a lottie: code refactoring.
removed unused static condition.

static was prepared for optimization,
but not used at all.

we will revisit this later when time permits.

binary size: -6kb
2024-03-28 00:04:48 +09:00
Jinny You
ca7b59876a lottie: Fix crash from invalid masking method
This change is better for stability. Returns `None` if the `mode` attribute cannot be parsed.

related issue: #2072
2024-03-27 23:39:34 +09:00
Hermet Park
925009c4a5 sw_engine: stabilize the contour composition logic.
there has been a logical error that breaks the contour
composition context. This fixes it.

issue: https://github.com/thorvg/thorvg/issues/2093
2024-03-27 23:38:46 +09:00
Jinny You
0d0f6d4710 lottie: Fix crash when an invalid gradient is provided
When lottie is broken and provides invalid gradient, the program crashes in segmentation fault.

At that time, in the `populate` function, `ColorStop& color` doesn't have `input` but tries to use it.

Added checking nullptr logic. The function `populate` will not proceed and return 0 in that case.

related issue: #2072
2024-03-27 20:25:57 +09:00
Hermet Park
e4775727eb api: Promote experimental Animation APIs to official status.
These APIs have been thoroughly tested and verified.

New API:
- Result Animation::frame(float no)
- Picture* Animation::picture() const
- float Animation::curFrame() const
- float Animation::totalFrame() const
- float Animation::duration() const
- static Animation::std::unique_ptr<Animation> gen()

New CAPI:
- Tvg_Animation* tvg_animation_new()
- Tvg_Result tvg_animation_set_frame(Tvg_Animation* animation, float no)
- Tvg_Paint* tvg_animation_get_picture(Tvg_Animation* animation)
- Tvg_Result tvg_animation_get_frame(Tvg_Animation* animation, float* no)
- Tvg_Result tvg_animation_get_total_frame(Tvg_Animation* animation, float* cnt)
- Tvg_Result tvg_animation_get_duration(Tvg_Animation* animation, float* duration)
- Tvg_Result tvg_animation_del(Tvg_Animation* animation)

issue: https://github.com/thorvg/thorvg/issues/2067
2024-03-27 16:18:42 +09:00
Hermet Park
1f996c1382 sw_engine: rectify consecutive line drawings.
There are differences in behavior compared to the SVG spec,
especially when consecutive line drawings occur without a moveTo command
following a closePath command.

Actually, thorvg didn't care the behavior in that scenario,
this update ensures the scenario is handled correctly
to align with the SVG specification.

issue: https://github.com/thorvg/thorvg/issues/1487
2024-03-27 10:53:32 +09:00
Hermet Park
06cc9709e6 renderer: Fix a crash issue related to the clipper
Fixed a crash that occurred when a given clipper had no data.
Properly handle this exceptional case to prevent the crash.

issue: https://github.com/thorvg/thorvg/issues/2083
2024-03-26 09:41:24 +09:00
Jinny You
f48137505b lottie/slot: Fixed potential overriding bug
Slot overriding tries to set property via the `LottieObject`. It potentially causes unexpected changes.

Revised the `override` function. The purpose of this patch is to aim atomic property to be overriden.
2024-03-26 09:41:12 +09:00
Sergii Liebodkin
bcaa5db269 wg_engine: stroke trim
[issues 1479: strokes](#1479)

Introduced stroke trim setting

left: (0, 0.95)
middle: (0.15, 1)
right: (0.15, 0.95)
2024-03-25 12:34:24 +09:00
Vincent Torri
2ec9fdb932 [common] code clean up
use fmodf() instead of fmod()
2024-03-23 11:45:11 +09:00
vtorri
04977c43f1
[common] code clean up
use MATH_PI and MATH_PI2 instead of M_PI and M_PI_2
2024-03-22 23:48:25 +09:00
Hermet Park
832f22e915 ttf: ++uwp portability
use the preprocessor directives properly.
2024-03-22 15:31:32 +09:00
Jinny You
b3f09cab6b lottie: Support the slot reverting feature
Implemented the ability to revert Lottie slots by calling override with nullptr.
This functionality allows for the complete reversal of applied slots.

usage:
- `animation->override(nullptr)`

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2024-03-21 16:56:28 +09:00
Jinny You
48f58637e1 test/lottie: added the slot resetting use case 2024-03-21 16:56:28 +09:00
Hermet Park
b70520322f lottie/property: code refactoring
introduce the release() method for memory freeing.
This method can be used for any demands.
2024-03-21 16:56:28 +09:00
JunsuChoi
54f0ddcc2d loader/lottie: Prevent leak memory when image load fails
When image data fails to load or image parsing fails,
the id is leaked without being assigned to the name.
To prevent that, free id value when obj is nullptr.

related issue: https://github.com/thorvg/thorvg/issues/2072
BrokenLottie.7z/test3_IDX_130_RAND_18289244608080059871.json
BrokenLottie.7z/test3_IDX_131_RAND_7772102071213376276.json
BrokenLottie.7z/test3_IDX_132_RAND_3072617087893397532.json
BrokenLottie.7z/test3_IDX_134_RAND_17738488813555566674.json
BrokenLottie.7z/test3_IDX_137_RAND_13903188963759129023.json
BrokenLottie.7z/test3_IDX_138_RAND_1645404078965858130.json
2024-03-21 15:33:19 +09:00
Jinny You
dcdec440df lottie: Added gradient population preventing logic
`LottieGradient.populate` function checks whether the value has already been calculated and populated via the flag `populated`.
2024-03-21 12:00:41 +09:00
RuiwenTang
23386625fc gl_engine: make stencil task support other advance logical
* Support rendering Gradient in path Stroke mode
* Fix GlStencilCoverTask not support even-odd fill rule
* Make GlStencilCoverTask can discard overlapped area during stroke
  rendering
2024-03-21 11:50:13 +09:00
Hermet Park
54acc7c955 examples/lottie: do not scan samples recursively.
lottie/extensions will be only accessed by LottieExtension
2024-03-20 16:49:05 +09:00
Rafał Mikrut
25e6539ea7 Better regression testing 2024-03-20 12:09:48 +09:00
Hermet Park
22e16d560a examples: ++sample svg resource 2024-03-20 11:35:46 +09:00
JunsuChoi
c9e4feb9dc loader/svg: Remove duplicate if-check in pathAppendArcTo
The if-check to skip-rule when drawing an arc path is already checked in line 476.
In addition, since the float type equal check is performed in the range of 1/256,
unintentional skiped may occur. Therefore, remove duplicate code.
https://www.w3.org/TR/SVG2/paths.html#ArcOutOfRangeParameters

test file: SVG_FILE_147893.svg
related issue: https://github.com/thorvg/thorvg/issues/1255
2024-03-20 11:33:12 +09:00
Sergii Liebodkin
c6601d1eee wg_engine: stroke first
[issues 1479: strokes](#1479)

Introduced order setting

    auto star = tvg::Shape::gen();
    star->fill(80, 80, 80);
    star->moveTo(599, 34);
    star->lineTo(653, 143);
    star->lineTo(774, 160);
    star->lineTo(687, 244);
    star->lineTo(707, 365);
    star->lineTo(599, 309);
    star->lineTo(497, 365);
    star->lineTo(512, 245);
    star->lineTo(426, 161);
    star->lineTo(546, 143);
    star->close();
    star->strokeWidth(10);
    star->strokeJoin(tvg::StrokeJoin::Round);
    star->strokeFill(255, 255, 255);
    star->order(true); // stroke first
    if (canvas->push(std::move(star)) != tvg::Result::Success) return;
2024-03-19 13:11:56 +09:00
JunsuChoi
dd2e7b9b4e lottie: Prevent memory leak when file is invalid
When json file is invalid in the parser,
the LottieComposition object is not released and the parse() returns false.
To prevent memory leaks, free the memory before returning false.

related issue : https://github.com/thorvg/thorvg/issues/2070
2024-03-19 11:48:02 +09:00
Hermet Park
6120729554 renderer: ensure paints retain composition context
This commit addresses an issue where paints lost their
composition context when drawings occurred without any updates.

Now, paints will consistently retain the composition context,
ensuring accurate rendering.

Issue: https://github.com/thorvg/thorvg/issues/2058
2024-03-18 18:12:53 +09:00
Hermet Park
c79e8e6271 examples: refactored the examples directory
reorganized the resources folder,
distributing contents into categorized subfolders:
SVG, Lottie, Image, Font, and TVG.
2024-03-18 18:09:03 +09:00
Hermet Park
d9926edb2f ttf: enhance UWP portability with alternative file loading
Enhances the portability of the TTF loader on UWP platforms
by implementing an alternative file loading mechanism.

This is designed to support environments where the file mapping
feature is not available, ensuring wider compatibility and reliability
in file handling.

Issue: https://github.com/thorvg/thorvg/issues/1912
2024-03-18 11:02:40 +09:00
Jinny You
ba82ba08a8 lottie: Renamed function names with prefix
Fixed naming conflict in short names.

issue: #2062
2024-03-18 11:01:58 +09:00
Sergii Liebodkin
1a28f837a8 wg_engine: winding fill rule
[issues 1479: FillRule](#1479)

Introduced fill rule winding
This rule makes sense only if path have some self intersections.
In all other cases shapes are filled by even-odd behavor.
2024-03-16 15:11:42 +09:00
Hermet Park
fc1e1cee39
Update README.md 2024-03-16 02:08:40 +09:00
Hermet Park
211f0dc9b6 lottie: fixed a compiler warning:
error: storing the address of local variable 'context' in '*this.LottieParser::context' [-Werror=dangling-pointer=]
 1255 |     this->context = &context;

issue: https://github.com/thorvg/thorvg/issues/2051
2024-03-15 02:10:56 +09:00
JunsuChoi
93209232c3 loader/webp: Remove WEBP_FORCE_ALIGNED and use memcpy() instead
The google's libwebp source uses aligned memory access.
This patch is that applies the two commits below to our static lib code.

refer to:
[Remove WEBP_FORCE_ALIGNED and use memcpy() instead]
3884972e3f
[bit_reader.c: s/VP8L_USE_UNALIGNED_LOAD/VP8L_USE_FAST_LOAD/]
ac49e4e4dc
source :
https://chromium.googlesource.com/webm/libwebp/+/refs/heads/main/src/utils/bit_reader_inl_utils.h#80

related issue: https://github.com/thorvg/thorvg/issues/2006
2024-03-14 21:31:04 +09:00
Hermet Park
58eab98e20 capi: Add two additional ColorSpace options to align with C++ APIs.
APIs:
- Tvg_Colorspace::TVG_COLORSPACE_ABGR8888S
- Tvg_Colorspace::TVG_COLORSPACE_ARGB8888S

Issue: https://github.com/thorvg/thorvg/issues/2053
2024-03-14 14:45:38 +09:00
Hermet Park
754a4aeaea renderer/gl_engine: Refine GlCanvas Interface
Refactor the GlCanvas::target() interface to allow
passing the drawing target ID from the user side.

Previously, it performed the drawing on the currently set FBO target.

Beta API change:

Result GlCanvas::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h)
-> Result GlCanvas::target(int32_t id, uint32_t w, uint32_t h)
2024-03-13 10:13:02 +02:00
RuiwenTang
68f7e4c245 gl_engine: enable msaa resolve in GLRenderPass
* use GLRenderBuffer in color and stencil attachment, also use x4 sample
  count by default.
* add msaa resolve logical at the end of a ComposeTask, so the normal
  color texture can get the final rendering result.
2024-03-13 10:12:46 +02:00
Jinny You
8146a6ef25 lottie/slot: Support overriding plural sids
Previously, slot overriding only works in single sid, the others are ignored.

This patch enables slot overriding for all sids within a single slot.
2024-03-12 11:40:09 +09:00
Hermet Park
78e6606b05 png: corrected a wrong premultiplied option.
this is a regresion bug by 886b6b365b
2024-03-08 16:17:45 +09:00
Lorcán Mc Donagh
cea221e2d5 sw_engine: fix radial gradient when focal point is outside circle on ARM/Apple Silicon
sw_engine: radial gradient
[issues 2014: radial gradient](#2014)

Radial gradient results in a corrupted image when the focal point is outside the circle on Apple Silicon.
This happens because some compilers use FMA to optimize the a = dr² - dx² - dy² calculation,
which cause loss of precision.

We rely on temporary variables to prevent FMA.
We could also use compiler specific float contraction control pragmas to avoid this if this doesn't work in the future
2024-03-08 01:36:44 +09:00
Hermet Park
5b76206540 lottie/slot: ++reliability 2024-03-07 13:26:18 +09:00
Hermet Park
60eec8353b lottie: fix potential memory leaks.
memory could be leaked during the slot property overriding.
2024-03-07 13:26:18 +09:00
Hermet Park
50ff56da9a
Update README.md 2024-03-07 12:13:23 +09:00