Commit graph

2556 commits

Author SHA1 Message Date
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
Hermet Park
56c4859138 saver: ++robustness
do not delete the given picture if the reference counting is
more than 0.
2024-04-06 12:08:21 +09:00
Mira Grudzinska
115c0242c3 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-04-06 12:08:21 +09:00
Mira Grudzinska
1b3505e74f 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-04-06 12:08:21 +09:00
Mira Grudzinska
a7bcc7b6d8 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-04-06 12:08:21 +09:00
Hermet Park
4dda73a8d2 Update README.md
Added an thorvg NPM link in the Lottie Player documentation.
2024-04-06 12:08:21 +09:00
Hermet Park
f03cff2353 examples: ++threading stability.
Ensure synchronous calls are made after updating the canvases.
2024-04-06 12:08:21 +09:00
Hermet Park
0f83850da6 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-04-06 12:08:21 +09:00
Hermet Park
97240a893a lottie: clean up code and minor bugs by mistake. 2024-04-06 12:08:21 +09:00
Jinny You
bafb8e2b86 examples: Added lottie advanced features example 2024-04-06 12:08:21 +09:00
Jinny You
c8a7e5b02e 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-04-06 12:08:21 +09:00
Jinny You
5ed068cec3 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-04-06 12:08:21 +09:00
Vincent Torri
da6199a2bd Lottie loader: fix compilation on windows
strlen() was used in tvgLottieModel.h without the inclusion of
cstring. This patch fixes this
2024-04-06 12:08:21 +09:00
Jinny You
447a3d8ad5 lottie: Revise the solid model
To ensure consistent properties, `LottieSolid` has been defined.

Both `LottieSolidStroke` and `LottieSolidFill` can be typecasted to the `LottieSolid`.
2024-04-06 12:08:21 +09:00
Jinny You
e333ca9515 lottie: Revise the gradient model
Currently, the `LottieGradient` does not incorporate the `LottieObject` functionality.

It now inherits from the `LottieObject`.
2024-04-06 12:08:21 +09:00
JunsuChoi
c6cf9cb2cf 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-04-06 12:08:21 +09:00
Hermet Park
2087db7ebf 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-04-06 12:08:21 +09:00
Hermet Park
fe6493351a lottie: introduced LottieProperty base class
this is useful for slot & expression type casting.
2024-04-06 12:08:21 +09:00
Hermet Park
c08c11db7d common: code refactoring
refactor common code to consolidate Bezier and line
function implementations into a single location.
2024-04-06 12:08:21 +09:00
Hermet Park
71c636e33c Revert "Revert "sw_engine: Increasing accuracy for dashed curves""
This reverts commit e49f9125b2.
2024-04-06 12:08:21 +09:00
Hermet Park
c01c8338d7 Revert "sw_engine: Increasing accuracy for dashed curves"
This reverts commit a8c0030d80.
2024-04-06 12:08:21 +09:00
Mira Grudzinska
d399ae922a sw_engine: Increasing accuracy for dashed curves
Dashed curves require greater precision in calculating
their lengths and while splitting Bezier curves.
Otherwise, it results in visual discrepancies compared
to the expected outcomes.
Approximate functions 'bezLengthApprox' and 'bezAtApprox'
used for calculations in the lottie loader.

issue: https://github.com/thorvg/thorvg/issues/1686
2024-04-06 12:08:21 +09:00
Mira Grudzinska
e718940f81 sw_engine: fixing stroke outline
In the case of non-uniform scaling for
thick strokes, artifacts were visible.
The calculations took into account the angle
resulting from the already transformed points,
whereas the untransformed points should have
been considered - the transformation is taken
into account in the next step.

@issue: https://github.com/thorvg/thorvg/issues/1915
2024-04-06 12:08:21 +09:00
Sergii Liebodkin
345753a397 wg_engine: meson script fixed
[issues 1991: Basic steps to compile for linux (wg_beta, examples)](#1991)
2024-04-06 12:08:21 +09:00
JunsuChoi
81fcca06bc examples/picture/svg: Adjust size ratio
Adjust the image size and position to fit the window size.
2024-04-06 12:08:21 +09:00
Hermet Park
6b63c85404 lottie/parser: clean up the exception handling mechanisms.
Since the parser has become stable enough,
remove the exceptions and instead rely on parser error handling.
2024-04-06 12:08:21 +09:00