Commit graph

921 commits

Author SHA1 Message Date
Mira Grudzinska
661bdeb9b7 lottie: add support for mask expansion
Implemented the mask attribute 'x' - expand mask.
Enforced rounded lines join according to tests in AE.

@Issue: https://github.com/thorvg/thorvg/issues/2832
2024-10-22 00:39:21 +09:00
Hermet Park
43cdd4c7ec lottie: Fine-tune for post-processing effect.
reduce quality for the post-processing effect to
improve general performance, while fine-tuning the quality
for lower resolutions.
2024-10-22 00:39:06 +09:00
Hermet Park
066160a82a lottie: hotfix a crash
Fixed a mistake during the code merge.

issue: https://github.com/thorvg/thorvg/issues/2733
2024-10-12 12:41:15 +09:00
Hermet Park
38f6ff4380 lottie: hotfix layer effect parsing
fixed a break in expressions/driving.json
2024-10-03 16:33:26 +09:00
Hermet Park
2b3a2e5ddf lottie: fixed a corrupted colorstop population
the color stop number should be retained during
the population of frames

issue: https://github.com/thorvg/thorvg/issues/2765
2024-10-03 16:33:16 +09:00
Mira Grudzinska
1c48cd3cdc lottie: fix gradient populating
When populating the gradient, the color/alpha should
be assigned the first possible value from the provided
ones, rather than the default value of 255.
2024-10-03 12:39:46 +09:00
Hermet Park
6f7ec5165a lottie: portability++
issue: https://github.com/thorvg/thorvg/issues/2764
2024-10-01 14:08:40 +09:00
Hermet Park
124dd4b629 lottie: ++safety 2024-10-01 12:58:13 +09:00
Mira Grudzinska
80a977f07e lottie: fix mem leak
Mem leak was observed in a case the end values
(deprecated feature) were provided for the gradient.

@Issue: https://github.com/thorvg/thorvg/issues/2667
2024-09-30 23:24:24 +09:00
Hermet Park
1a795e2ed4 lottie: optimization++
Use a clipper instead of masking when the condition is satisfied.
Generally, clipping is cheaper than masking in fps & memory usage.

issue: https://github.com/thorvg/thorvg/issues/2647
2024-09-30 16:44:22 +09:00
Hermet Park
ab8b4ef73e lottie: support layer effect & gaussian blur
issue: https://github.com/thorvg/thorvg/issues/2718
2024-09-30 16:44:22 +09:00
Hermet Park
8b01f92c57 loader/jpg: --compiler warnings
../src/loaders/jpg/tvgJpgd.cpp:867:36: warning: ‘*&P.DCT_Upsample::Matrix44::v[0][0]’ may be used uninitialized [-Wmaybe-uninitialized]

https://github.com/thorvg/thorvg/issues/2639
2024-09-30 16:44:22 +09:00
Mira Grudzinska
45a35fd65b svg_loader: fix circle radius if in percentages 2024-09-30 16:44:22 +09:00
Hermet Park
d3edc0c5f7 api: clean up
promoted offical c++ apis (v0.15)
 - enum class BlendMethod
 - enum class CanvasEngine::Wg
 - virtual Result Canvas::viewport(int32_t x, int32_t y, int32_t w, int32_t h);
 - class Text
 - Result Text::fill(uint8_t r, uint8_t g, uint8_t b)
 - Result Text::fill(std::unique_ptr<Fill> f)
 - static Result Text::unload(const std::string& path)
 - static Result Text::load(const std::string& path)
 - static Result Text::load(const char* name, const char* data, uint32_t size, const std::string& mimeType = "ttf", bool copy = false)
 - static std::unique_ptr<Text> Text::gen()
 - class WgCanvas
 - static std::unique_ptr<WgCanvas> WgCanvas::gen()
 - static const char* Initializer::version(uint32_t* major, uint32_t* minor, uint32_t* micro)
 - class LottieAnimation

promoted official c apis (v0.15)
 - Tvg_Blend_Method
 - Tvg_Result tvg_engine_version(uint32_t* major, uint32_t* minor, uint32_t* micro, const char** version)
 - Tvg_Result tvg_canvas_set_viewport(Tvg_Canvas* canvas, int32_t x, int32_t y, int32_t w, int32_t h)
 - Tvg_Result tvg_paint_set_blend_method(Tvg_Paint* paint, Tvg_Blend_Method method)
 - Tvg_Paint* tvg_text_new(void)
 - Tvg_Result tvg_text_set_fill_color(Tvg_Paint* paint, uint8_t r, uint8_t g, uint8_t b)
 - Tvg_Result tvg_text_set_gradient(Tvg_Paint* paint, Tvg_Gradient* gradient)
 - Tvg_Result tvg_font_load(const char* path)
 - Tvg_Result tvg_font_load_data(const char* name, const char* data, uint32_t size, const char *mimetype, bool copy)
 - Tvg_Result tvg_font_unload(const char* path)
 - Tvg_Animation* tvg_lottie_animation_new(void)

removed experimental apis
 - BlendMethod paint::blend() const
 - bool Shape::strokeTrim(float* begin, float* end) const
 - Tvg_Result tvg_paint_get_blend_method(const Tvg_Paint* paint, Tvg_Blend_Method* method)
 - Tvg_Result tvg_shape_get_stroke_trim(Tvg_Paint* paint, float* begin, float* end, bool* simultaneous)
 - tvg_text_set_linear_gradient(Paint* paint, Tvg_Gradient* gradient)
 - tvg_text_set_radial_gradient(Paint* paint, Tvg_Gradient* gradient)

issue: https://github.com/thorvg/thorvg/issues/1372
2024-09-30 16:44:22 +09:00
Hermet Park
319b3843a5 common: code refactoring
Properly renamed internal interfaces.
No logical changes.

- Compositor -> RenderCompositor
- Surface -> RenderSurface
2024-09-30 16:44:22 +09:00
JunsuChoi
54ea7ab33b svg_loader: Fix calculation when stroke-width unit is percentage
When stroke-width unit is percentage, loader refer to the normalized diagonal of viewport.
+) Add Diagonal type so as not to affect existing types.

https://svgwg.org/svg2-draft/painting.html#StrokeWidth
https://svgwg.org/svg2-draft/coords.html#Units

example)
```
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg">
   <rect x="15" y="15" width="70" height="20" fill="none" stroke="#F00" stroke-width="10%"/>
   <rect x="15" y="15" width="70" height="20" fill="none" stroke="#00F" stroke-opacity=".3" stroke-width="10"/>
</svg>

```

related issue: https://github.com/thorvg/thorvg/issues/2131
2024-09-30 16:44:22 +09:00
Hermet Park
d2c89a5f2d lottie: --type casting warning in MSVC 2024-09-30 16:44:22 +09:00
Jinny You
e8665840db lottie/text: Fix incorrect text range without end condition
Improving text render compatibility by fixing wrong Text Range.

When lottie doesn't have `end` prop in the range, system must ignore condition regarding to `end`.

The original logic unintentionally swaps `start` and `end` prop, because `end` is the zero in this case. Then the text range animation behaves the opposite.
2024-09-30 16:44:22 +09:00
Hermet Park
7a0c12ed8b api: Introduced Paint::clip() API
Separate clip function from the Composite()
clipping and composition can be used together.

This helps avoid the introduction of nested scenes
when composition and clipping overlap.

Deprecated:
- enum class CompositeMethod::ClipPath
- enum Tvg_Composite_Method::TVG_COMPOSITE_METHOD_CLIP_PATH

Experimental API:
- Result Paint::clip(std::unique_ptr<Paint> clipper)
- Tvg_Result tvg_paint_set_clip(Tvg_Paint* paint, Tvg_Paint* clipper)

Issue: https://github.com/thorvg/thorvg/issues/1496
2024-09-30 16:44:22 +09:00
Jinny You
82d4725c3e lottie/text: hotfix for parsing text range issue
If randomize is not enabled, "rn" prop falls into skip()
2024-09-30 16:44:22 +09:00
Jinny You
c10c713c05 lottie/text: applied Text Range randomization.
on each parse, if the `randomize` is enabled,
the start and end of the Text Range are redefined
with the same gap as the original range.

issue: https://github.com/thorvg/thorvg/issues/2178
2024-09-30 16:44:22 +09:00
Hermet Park
915acd2ec3 lottie/expressions: ++coverage
Allow direct key[0]/key[1] access for key.value in expression

issue: https://github.com/thorvg/thorvg/issues/2722
2024-09-30 16:44:22 +09:00
Hermet Park
c80b21c1f7 lottie: ++expressions coverage
added missing velocityAtTime() for float types.

issue: https://github.com/thorvg/thorvg/issues/2724
2024-09-30 16:44:22 +09:00
Mira Grudzinska
c37e4056ac svg_loader: append text to the SvgTextNode
Text can be added in parts due to the presence
of the <tspan> tag. This requires that each
subsequent piece of text is appended rather than
overwriting the previous one.
2024-09-30 16:44:22 +09:00
Jinny You
bf3e861b5a lottie/text: Support line spacing
Compute line spacing based on the text range selector, applying the maximum spacing value for each line.
issue: https://github.com/thorvg/thorvg/issues/2178
2024-09-30 16:44:22 +09:00
Hermet Park
371139e220 renderer: blending refactoring++
- reordered the blending types to align with lottie spec.
- removed source over.
2024-09-30 16:44:22 +09:00
Jinny You
a7aac95b03 lottie/text: Support Text Based
Added support for Text Based of Text Range Selector, by processing further properties:
2. Character Excluding Spaces
3. Words
4. Lines

see: https://github.com/thorvg/thorvg/issues/2178
2024-09-30 16:44:22 +09:00
Mira Grudzinska
e271485607 svg_loader: fix text nodes issue
Since the text node wasn't pushed onto the loader's stack,
closing the text node incorrectly caused an element to be
popped from the stack (if one was present).
This could result in elements that were supposed to have
that element as a parent being rendered incorrectly or not
being rendered at all.
Now, the text node is correctly pushed onto the stack.

@Issue: https://github.com/thorvg/thorvg/issues/2706
2024-09-30 16:44:22 +09:00
Hermet Park
c4678eb420 lottie/parser: ++ null value handling
Note that, only dealt with a obivous case in practice.

issue: https://github.com/thorvg/thorvg/issues/2703
2024-09-30 16:44:22 +09:00
Łukasz Pomietło
3c5cf13eb5 loader/ttf: Spaces and invalid glyphs rendering fix
If for any reason an invalid glyph is found in text, 
it will now be skipped when rendering 
(instead of increasing offset by last valid glyph advance).

Issue: #2687
2024-09-30 16:44:22 +09:00
Mira Grudzinska
ec4b08245c lottie: handle trim path edge cases
According to the definition of trim path elements,
the begin and end values are specified as percentages
in the range of 0-100% (this is also confirmed by AE,
where it's not possible to exceed this range).
Added clamping to align with spec.
2024-09-30 16:44:22 +09:00
Hermet Park
82f2ce4bd4 lottie/expressions: rectified $bm_sum()
Added only a single element to x.
2024-09-30 16:44:22 +09:00
Hermet Park
b660a99bca lottie/expressions: hotfix a crash
Stabilized $bm_sum(), by allowing the different dimensional
arguments.

issue: https://github.com/thorvg/thorvg/issues/2664
2024-09-30 16:44:22 +09:00
JunsuChoi
faec19bff6 svg_loader: Adjust hsl values out of range
The range of saturation and brightness values is 0 ~ 100% and range of hue is 0 ~ 360.
If a value greater than 100% is loaded, it will be modified to be 100%.

issue: https://github.com/thorvg/thorvg/issues/2678
2024-09-30 16:44:22 +09:00
Mira Grudzinska
d7405e7be8 lottie: fix trim
The bug caused the trim path to not be applied
when it appeared in a group between different
shapes.
2024-09-30 16:44:22 +09:00
Mira Grudzinska
362b51028d lottie: fix trim path regression
To avoid editing the trim path values provided
by the user, the logic for their interpretation
was moved from the API to the renderer (7c87d8e).
This caused an issue in the lottie animations when
the trim path is applied more than once. Now fixed.

@issue: https://github.com/thorvg/thorvg/issues/2670
2024-09-30 16:44:22 +09:00
Łukasz Pomietło
cde6a24b1b renderer/text: fix a missing text update
previously font size & italic style had been ignored
even if its attributes are changed.

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

issue: https://github.com/thorvg/thorvg/issues/2676
2024-09-30 16:44:22 +09:00
Hermet Park
89031244cd lottie/parser: enable logs to notify missing features 2024-09-30 16:44:21 +09:00
Hermet Park
446d93805e lottie/expressions: Improve safety
- Prevent expression processing if a property fails to parse.
- Fixed an incorrect usage of JerryScript.

This is a hotfix to address expression-related crashes.
2024-09-30 16:44:21 +09:00
Hermet Park
34d0309fcc lottie/jerryscript: ++build reliance 2024-09-30 16:44:21 +09:00
Mira Grudzinska
90e7a50c8e lottie: add offsetPath support
Due to the lack of an analytical solution for Bezier
curves offsetting, a simple and computationally cheap
approximation has been implemented. The algorithm shifts
the segments connecting control points and determines
new points based on their intersections.

@issue: https://github.com/thorvg/thorvg/issues/2230
2024-09-30 16:44:21 +09:00
Mira Grudzinska
448d84ffb7 lottie: roundness refactored based on #2295 2024-09-30 16:44:21 +09:00
Mira Grudzinska
b8e4abd243 lottie: fix text update
The occurrence of a 'carriage return' (13) or 'end of text' (3)
caused the skipping of the next character check, immediately
searching for it in the list of available characters.
If the next character was also 13 or 3, it led to incorrect
interpretation; however, if it was the last character in the
sequence, a crash occurred.
2024-09-30 16:44:21 +09:00
Hermet Park
0f17f6c69a common: spec out TexMap
Spec out this incomplete experimental feature,
this is a still promising one, we will reintroduce
this officially after 1.0 release

size: -2kb

issue: https://github.com/thorvg/thorvg/issues/1372
2024-09-30 16:44:21 +09:00
Elliott Sales de Andrade
ee19753f36 build: Remove redundant comparisons
If a Meson option is typed as `boolean`, the `get_option` returns a
boolean, and comparing it with `true` is redundant. Meson also errors if
you try to compare across types, so it couldn't _not_ be a boolean.

Also, Meson is not C, so no need for parentheses around `if` conditions.
2024-09-30 16:44:21 +09:00
Hermet Park
738f8f745a lottie: ensure a null terminator at the end of the copied data
In certain cases, the user might want to set mapped memory directly.
This update ensures that a null terminator is appended to the string data.

Co-Authored-By: Mira Grudzinska <mira@lottiefiles.com>

Issue: https://github.com/thorvg/thorvg/issues/2642
2024-09-30 16:44:21 +09:00
Mira Grudzinska
0857f2b10d lottie: prioritization of roundness in rectangles
Added prioritization of rectangle roundness over
rounded corners, in line with AE results.
2024-09-30 16:44:21 +09:00
Mira Grudzinska
2141f14e27 lottie: handle edge case for rounded rect
For rounded rectangles the roundness value should
be determined using to the formula:
r = min(r, max(size.x, size.y)/2)
rather than the previous method:
r = min(size.x/2, size.y/2, r)
2024-09-30 15:53:45 +09:00
Hermet Park
bc77c0ee74 lottie: code refactoring
getting too many parameters,
migrated static functions to class member functions,
reducing the binary size by 2KB

no logical changes
2024-09-30 15:53:18 +09:00
Hermet Park
dcf051346c lottie: ++scene rendering optimization
Apply LottieRenderPooler to RenderContext propagators.
2024-09-30 15:53:09 +09:00