Commit graph

2781 commits

Author SHA1 Message Date
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
Sergii Liebodkin
4b2f5ca510 wg_engine: fill spread
[issues 1479: LinearGradient, RadialGradient](#1479)

Introduced fill spreads: Pad, Reflect, Repeat

Pad:

Reflect:

Repeat:
2024-03-07 11:45:23 +09:00
Hermet Park
44da074d58 Update README.md 2024-03-07 00:36:30 +09:00
Jinny You
5695f84307 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-03-06 19:51:57 +09:00
Hermet Park
118a82df54 Update README.md 2024-03-06 17:32:15 +09:00
Jinny You
449cee7cf0 lottie/api: specify clear result for override API
In case the given JSON is invalid, it's more closed to `Result::InvalidArguments`.
2024-03-06 17:32:02 +09:00
RuiwenTang
cc2fa23359 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-03-06 16:56:32 +09:00
Hermet Park
1e4bf308da 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-03-06 14:34:58 +09:00
Jinny You
bd1fec2dca capi: added missing lottie header
Currently, the Lottie Animation API is not working due to the missing header.
2024-03-06 11:51:13 +09:00
Sergii Liebodkin
1794ec0924 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-03-04 19:33:34 +09:00
RuiwenTang
7cf4bd932f 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-03-04 17:38:11 +09:00
Hermet Park
199fac9b63
Update CONTRIBUTING.md 2024-03-04 15:14:03 +09:00
Hermet Park
8f28181699
Update CODEOWNERS 2024-03-04 15:11:08 +09:00
Mira Grudzinska
f535a6e139 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-03-04 11:20:21 +09:00
Hermet Park
b95cb0441d
Update README.md
added the opencollective badge
2024-03-03 20:03:55 +09:00
Hermet Park
f10283a905 infra: added open_collective fund account 2024-03-03 19:54:20 +09:00
Hermet Park
32c16e3a6f 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-03-03 16:17:23 +09:00
Hermet Park
103252642e lottie: code refactoring.
Maintains compact lines of code and functions without altering logic,
consistently prioritizing simplicity in software complexity metrics.
2024-03-03 14:04:34 +09:00
Hermet Park
a1dea56690 lottie: copy the data only necessarily. 2024-03-03 13:12:29 +09:00
Hermet Park
a741778dab saver: ++robustness
do not delete the given picture if the reference counting is
more than 0.
2024-03-03 12:56:33 +09:00
Mira Grudzinska
0c602291cb common: Changing the rounded rect starting point
According to the SVG standard, drawing a rectangle
starts at (x+rx, y) point. Till now it was (x+w, y+ry).
The difference was visible only for dashed strokes.
2024-03-03 12:54:56 +09:00
Mira Grudzinska
6ec88ed486 common: Changing the circle/ellipse starting point
According to the SVG standard, drawing a circle/ellipse
should start at the '3 o'clock' position and proceed
in a clock-wise direction. Until now, this point was
set at '12 o'clock'.
The differences in the outcome were visible for dashed
strokes.

issue: https://github.com/thorvg/thorvg/issues/1686
2024-03-03 12:53:10 +09:00
Mira Grudzinska
8b2ddf7377 lottie: use internal append rect/ellipse func
The lottie format defines the starting point for
drawing rectangles and ellipses differently than
the API available in the TVG. In the case of using
dashes or trim paths, this leads to discrepancies.
Therefore, when using the lottie builder, internal
functions for appending rectangles and circles are
utilized.

@issue: https://github.com/thorvg/thorvg/issues/1997
2024-03-03 12:52:39 +09:00
Hermet Park
651979b68d Update README.md
Added an thorvg NPM link in the Lottie Player documentation.
2024-02-29 11:36:45 +09:00
Hermet Park
faa3c6f392 examples: ++threading stability.
Ensure synchronous calls are made after updating the canvases.
2024-02-24 11:16:49 +09:00
Hermet Park
71a5c3ad02 binding/capi: support lottie extensions
these experimental apis are allowed to use
when the lottie loader is enabled.

APIs:
- Tvg_Animation* tvg_lottie_animation_new()
- Tvg_Result tvg_lottie_animation_override(Tvg_Animation* animation, const char* slot)
2024-02-24 01:57:35 +09:00
Hermet Park
65e8fe2791 lottie: clean up code and minor bugs by mistake. 2024-02-23 16:18:40 +09:00
Jinny You
625146853e examples: Added lottie advanced features example 2024-02-23 15:05:15 +09:00
Jinny You
53878919b5 lottie: Introduce the LottieAnimation class
This class extends the Animation and serves advanced Lottie features.
It's designed to separately have Lottie Animation's unique specs.

For now, this will have Slot overriding feature,
you can include <thorvg_lottie.h> for its extensive features.

@APIs:
- Result LottieAnimation::override(const char* slotJson) noexcept;
- static std::unique_ptr<LottieAnimation> LottieAnimation::gen() noexcept;

@Issue: https://github.com/thorvg/thorvg/issues/1808
2024-02-23 15:05:15 +09:00
Jinny You
362e6faacb lottie: Support the slot overriding feature
Internal model and parser modifications have been made
to parse "sid" and retrieve their data into the LottieComposition.
This will enable dynamic changes to the following Lottie objects:

The slot feature will encompass these properties:

- LottieSolidStroke
- LottieSolidFill
- LottieGradientStroke
- LottieGradientFill
- LottieTextDoc"

Issue: https://github.com/thorvg/thorvg/issues/1808

Co-authored-by: Hermet Park <hermet@lottiefiles.com>
2024-02-23 15:05:15 +09:00
Vincent Torri
a361924887 Lottie loader: fix compilation on windows
strlen() was used in tvgLottieModel.h without the inclusion of
cstring. This patch fixes this
2024-02-23 11:27:12 +09:00
Jinny You
4613d98d98 lottie: Revise the solid model
To ensure consistent properties, `LottieSolid` has been defined.

Both `LottieSolidStroke` and `LottieSolidFill` can be typecasted to the `LottieSolid`.
2024-02-22 22:17:11 +09:00
Jinny You
317843927f lottie: Revise the gradient model
Currently, the `LottieGradient` does not incorporate the `LottieObject` functionality.

It now inherits from the `LottieObject`.
2024-02-22 22:17:06 +09:00
JunsuChoi
d32c90cbbf svg: Improve valid check for url(#id)
Improve parenthesis checking and space checking.
 - There must be only one pair of parentheses.
 - There cannot be spaces(and ') between id strings.

Issue: https://github.com/thorvg/thorvg/issues/1983

Co-authored-by: Hermet Park <hermet@lottiefiles.com>
2024-02-22 21:51:19 +09:00
Hermet Park
27972ceaa7 gl_engine: fix a compile warnings, errors.
../src/renderer/gl_engine/tvgGlRenderPass.cpp:35:34: warning: macro expands to multiple statements [-Wmultistatement-macros]
   35 |     if (mColorTex != 0) GL_CHECK(glDeleteTextures(1, &mColorTex));
      |                                  ^~~~~~~~~~~~~~~~
../src/renderer/gl_engine/tvgGlCommon.h:33:9: note: in definition of macro ‘GL_CHECK’
   33 |         x; \
      |         ^
2024-02-22 13:09:00 +09:00
Hermet Park
4467ce7bd5 lottie: introduced LottieProperty base class
this is useful for slot & expression type casting.
2024-02-21 20:57:07 +09:00