Commit graph

2631 commits

Author SHA1 Message Date
Vincent Torri
2f196b514f [common] code clean up
use fmodf() instead of fmod()
2024-04-06 12:08:23 +09:00
vtorri
3640724b99 [common] code clean up
use MATH_PI and MATH_PI2 instead of M_PI and M_PI_2
2024-04-06 12:08:23 +09:00
Hermet Park
c73370a0ae ttf: ++uwp portability
use the preprocessor directives properly.
2024-04-06 12:08:23 +09:00
Jinny You
984eb2eff9 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-04-06 12:08:23 +09:00
Jinny You
62e7f0a7c6 test/lottie: added the slot resetting use case 2024-04-06 12:08:23 +09:00
Hermet Park
3cb8c4311d lottie/property: code refactoring
introduce the release() method for memory freeing.
This method can be used for any demands.
2024-04-06 12:08:23 +09:00
JunsuChoi
727b699223 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-04-06 12:08:23 +09:00
Jinny You
d5af1e3b67 lottie: Added gradient population preventing logic
`LottieGradient.populate` function checks whether the value has already been calculated and populated via the flag `populated`.
2024-04-06 12:08:23 +09:00
RuiwenTang
ed146ed162 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-04-06 12:08:22 +09:00
Hermet Park
a4d169d4af examples/lottie: do not scan samples recursively.
lottie/extensions will be only accessed by LottieExtension
2024-04-06 12:08:22 +09:00
Rafał Mikrut
71f596b173 Better regression testing 2024-04-06 12:08:22 +09:00
Hermet Park
2dd41e8632 examples: ++sample svg resource 2024-04-06 12:08:22 +09:00
JunsuChoi
4ec76144dc 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-04-06 12:08:22 +09:00
Sergii Liebodkin
4d2440cc70 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-04-06 12:08:22 +09:00
JunsuChoi
c4da341f4b 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-04-06 12:08:22 +09:00
Hermet Park
25645e087a 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-04-06 12:08:22 +09:00
Hermet Park
3dbe535f38 examples: refactored the examples directory
reorganized the resources folder,
distributing contents into categorized subfolders:
SVG, Lottie, Image, Font, and TVG.
2024-04-06 12:08:22 +09:00
Hermet Park
1008575932 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-04-06 12:08:21 +09:00
Jinny You
dee5a7294a lottie: Renamed function names with prefix
Fixed naming conflict in short names.

issue: #2062
2024-04-06 12:08:21 +09:00
Sergii Liebodkin
203cd4cd60 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-04-06 12:08:21 +09:00
Hermet Park
3a6ee664cc Update README.md 2024-04-06 12:08:21 +09:00
Hermet Park
b1ab52f89e 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-04-06 12:08:21 +09:00
JunsuChoi
fc4f452362 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-04-06 12:08:21 +09:00
Hermet Park
3c5e9e1e7c 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-04-06 12:08:21 +09:00
Hermet Park
5d10e514d7 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-04-06 12:08:21 +09:00
RuiwenTang
faff16e7d4 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-04-06 12:08:21 +09:00
Jinny You
7f2cd1090c 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-04-06 12:08:21 +09:00
Hermet Park
946d934827 png: corrected a wrong premultiplied option.
this is a regresion bug by 886b6b365b
2024-04-06 12:08:21 +09:00
Lorcán Mc Donagh
612b52a3e3 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-04-06 12:08:21 +09:00
Hermet Park
851f8eaabc lottie/slot: ++reliability 2024-04-06 12:08:21 +09:00
Hermet Park
d50eea2a2c lottie: fix potential memory leaks.
memory could be leaked during the slot property overriding.
2024-04-06 12:08:21 +09:00
Hermet Park
d816d8fb5b Update README.md 2024-04-06 12:08:21 +09:00
Sergii Liebodkin
80d454e2d6 wg_engine: fill spread
[issues 1479: LinearGradient, RadialGradient](#1479)

Introduced fill spreads: Pad, Reflect, Repeat

Pad:

Reflect:

Repeat:
2024-04-06 12:08:21 +09:00
Hermet Park
d966304803 Update README.md 2024-04-06 12:08:21 +09:00
Jinny You
fb20938b14 test: Added test code for the lottie slot
This patch adds the test case for the recently introduced lottie slot API.

@Issues: https://github.com/thorvg/thorvg/issues/2029
2024-04-06 12:08:21 +09:00
Hermet Park
c881fc71c2 Update README.md 2024-04-06 12:08:21 +09:00
Jinny You
725dc0d18e lottie/api: specify clear result for override API
In case the given JSON is invalid, it's more closed to `Result::InvalidArguments`.
2024-04-06 12:08:21 +09:00
RuiwenTang
5bf82bf142 gl_engine: remove unused alpha attribute
Since we choose MSAA, no need to calculate edge alpha during fragment
stage. So this commit removed the alpha attribute and related code:

* Remove the alpha attribute in vertex data.
* Change position type from `vec3` to `vec2` in all shader code.
* Remove alhpa multiplication in all fragment shaders
2024-04-06 12:08:21 +09:00
Hermet Park
fa393f1c52 renderer/loader: revamping the caching mechanism.
The previous loader cache mechanism encountered a problem
when the user changed the content of the cached data.

In such cases, a new request would not be processed
because the renderer would use the previously cached content.

So far, the TVG cache mechanism utilizes a pointer hash key
for the fastest hashing mechanism available.
One limitation is that it assumes the address is unique for the data.

To resolve this, we modified the caching policy.
Now, the renderer will not cache copied data;
it will only cache the given data when it is deemed shareable.

issue: https://github.com/thorvg/thorvg/issues/2020
2024-04-06 12:08:21 +09:00
Jinny You
6bfd11a80c capi: added missing lottie header
Currently, the Lottie Animation API is not working due to the missing header.
2024-04-06 12:08:21 +09:00
Sergii Liebodkin
850e6ef466 wg_engine: antialiasing
[issues 1479: antialiasing](#1479)

Anti-aliasing implementation
Implements antialiasing as a post process on cimpute shaders and original render target with scale of 2x.
Can be modified as an external settings
2024-04-06 12:08:21 +09:00
RuiwenTang
4459d23f28 gl_engine: use stencil and cover tessellator by default
Since we choose multisample antialiasing, use stencil then cover to
render polygon can get better performance.
Also the code is much easier to understand.
2024-04-06 12:08:21 +09:00
Hermet Park
7af0d6c0c1 Update CONTRIBUTING.md 2024-04-06 12:08:21 +09:00
Hermet Park
e5e703e5ba Update CODEOWNERS 2024-04-06 12:08:21 +09:00
Mira Grudzinska
203d892cbd sw_engine: fix a regression bug
After introducing the length measurement
of approximate and exact Bezier curves in
a8c0030d80
the calculation of the outline length still
used the approximate functions, while further
calculations took the exact value into account.
This discrepancy led to the creation of artifacts.

@Issue: https://github.com/thorvg/thorvg/issues/2021
2024-04-06 12:08:21 +09:00
Hermet Park
69f5f8bff4 Update README.md
added the opencollective badge
2024-04-06 12:08:21 +09:00
Hermet Park
2f2067531d infra: added open_collective fund account 2024-04-06 12:08:21 +09:00
Hermet Park
604c4dc0b0 sw_engine: fix a regression bug.
stroke line drawing has been broken at a certain case,
this reverts a part of change from the old optimization:

d81f5d29fb

note that this change wouldn't affect any performance.

issue: https://github.com/thorvg/thorvg/issues/2015
2024-04-06 12:08:21 +09:00
Hermet Park
3ed8309a11 lottie: code refactoring.
Maintains compact lines of code and functions without altering logic,
consistently prioritizing simplicity in software complexity metrics.
2024-04-06 12:08:21 +09:00
Hermet Park
2e7fc5ebcb lottie: copy the data only necessarily. 2024-04-06 12:08:21 +09:00