Commit graph

3250 commits

Author SHA1 Message Date
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
Sergii Liebodkin
9efab30b00 webgpu: shaders refactoring
Deep shader refactoring for the following purposes:
* used pre-calculated gradient texture instead of per-pixel gradient map computation
* used HW wrap samples for fill spread setting
* unified gradient shader types
* used single shader module for composition instead of signle module per composition type
* used single shader module for blending for each of fill type (solid, gradient, image) instaed of signle module per blend type
* much easier add new composition and blend equations
* get rided std::string uasge
* shaders code is more readable
2024-09-30 16:44:21 +09:00
Hermet Park
a25366b283 common: spec out Scene Clipper
Scene Clipper is an unusual feature
that is too unstable and ambiguous in ThorVG.

Users can achieve the same functionality
with multiple composed shapes instead of scene clipping.

size: -2.5kb

issues:
- https://github.com/thorvg/thorvg/issues/1548
- https://github.com/thorvg/thorvg/issues/1549
- https://github.com/thorvg/thorvg/issues/1573
2024-09-30 16:44:21 +09:00
Hermet Park
05d4d05f59 examples/text: hotfix
corrected wrong arguments.
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
ec6e8a6e94 wasm: thorvg canvas resize problem.
The canvas syncs before changing a target buffer.

issue: https://github.com/thorvg/thorvg/issues/2580
2024-09-30 15:53:39 +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
Hermet Park
9f5a83f067 lottie: ++scene rendering optimization
Apply LottieRenderPooler to maskings.
2024-09-30 15:53:02 +09:00
Mira Grudzinska
49f586b3e7 lottie: handle rounded polygons
The implementation of rounded polygons was
mistakenly omitted, now has been added.

@Issue: https://github.com/thorvg/thorvg/issues/2624
2024-09-30 15:52:55 +09:00
Sergii Liebodkin
55d248a31d webgpu: light/dark mask mode support
[issues 2608: light/dark mask](#2608)

* CompositeMethod::LightMask
* CompositeMethod::DarkMask
2024-09-30 15:52:50 +09:00
Sergii Liebodkin
f281cc9e92 wg_engine: composition and blend optimization
* bind groups creation in real time removed - performance boost
* blend and composition shaders decomposed - performance boost
* shader modules and pipeline layouts generalized - less memory usage
* shared single stencil buffer used - less memory usage
* bind groups usage simplified
* general context API simplified and generalized
* all rendering logic moved into new composition class
* ready for hardware MSAA (in next steps)
* ready for direct mask applience (in next steps)
2024-09-30 15:52:44 +09:00
Mira Grudzinska
997093be96 common: fix arg name
For Bezier curves, we typically use 't' as a parameter
within the 0-1 range, while 'at' is used for the parameter
scaled by the curve's length. In one of the functions,
an incorrect name was used, which could be confusing.
No logical changes.
2024-09-30 15:52:37 +09:00
Mira Grudzinska
4227192193 common: add missing consts
Adding const was necessary to allow calling
the functions on constant objects.
2024-09-30 15:52:25 +09:00
Mira Grudzinska
e9fcd40099 common: increase precision for bezier calculations
The epsilon value currently used for the precision
of Beziers calculations is sufficient for comparing
curve lengths. However, for the parameter t, which
ranges from 0 to 1, an accuracy of 1% can introduce
errors.
The solution is to increase the precision for the t
parameter while keeping the rest of the calculations
at the previously used epsilon value.

@Issue: https://github.com/thorvg/thorvg/issues/2619
2024-09-30 15:52:20 +09:00
Hermet Park
6fd00329aa infra: switch the optimization option to level 3
In case of modern systems, size is not a big problem,
so we turn the optimization option to default
for better performance.

FPS: ~20% enhanced
Size: ~25% increased

Note that this doesn't affect to the web player.
2024-09-30 15:52:16 +09:00
Hermet Park
d732030bef renderer: rectified the bounds() behavior
Text fill is broken by 43c87b4eb5
2024-09-30 15:49:57 +09:00
Hermet Park
1317b1690f lottie: support matte+masking combination
introduced an intermediate scene for embracing
the matte and maskings
2024-09-30 15:49:52 +09:00
Hermet Park
e2b99ec308 lottie/expressions: rectified fill color support
Assign the fill color value properly.
2024-09-30 15:49:44 +09:00
Hermet Park
fb6635713e lottie: code refactoring
Moved common data declarations to tvgLottieCommon.h.
2024-09-30 15:49:34 +09:00
Hermet Park
cd1ed24bbe lottie/expressions: revised exception handlings 2024-09-30 15:49:26 +09:00
Hermet Park
b82488a27d lottie/model: implement the missing property() interface 2024-09-30 15:49:20 +09:00
Hermet Park
2942e76bae test: coverage enhancement
+ Accessor::id()
+ Picture::paint()
2024-09-30 15:49:14 +09:00
Hermet Park
8de23876d5 examples: added Interaction sample
The Interaction sample demonstrates
how to handle user input with ThorVG Animation.
2024-09-30 15:48:50 +09:00
Hermet Park
730b0d23f0 renderer/paint: revise the Paint::bounds() behavior
The current Paint::bounds(transform=true) returns the coordinates
of the paint in its local coordinates after transformation.

However, it did not convert the origin to the world coordinate.

This is problematic when the user wants to determine
the paint's position and size with the origin being the canvas.
Specifically, this matters that when the paint is belonged
to a certain scene.

Now, the bounds() method returns the coordinates
of the paint's bounding box with the corrected world space.
User can figure out the actual boundary within the painted result.

Remark that, this may break the functional behavior compatibility.
2024-09-30 15:48:18 +09:00
Hermet Park
d1664a162e renderer/picture: added a method to search for a paint object
This utility method allows access to a specific paint instance
by its unique identifier.

Experimental API:
- const Paint* Picture::paint(uint32_t id)
- const Tvg_Paint* tvg_picture_get_paint(Tvg_Paint* paint, uint32_t id)
2024-09-30 15:48:18 +09:00
Hermet Park
32c4e1d815 renderer/accessor: added the id generator.
This function computes a unique identifier value based on the provided string.
You can use this to assign a unique ID to the Paint object.

Experimental APIs:
- uint32_t Accessorr::id(const char* name)
- uint32_t tvg_accessor_id(const char* name)
2024-09-30 15:48:18 +09:00
Hermet Park
6456252b43 API: introduce a Paint ID member as a reserved field
The "id" is a reserved field to specify a paint instance in a scene.
in this change, it assigns the layer id to the lottie scene as well.
2024-09-30 15:48:18 +09:00
Hermet Park
21d3cc4eb9 renderer/accessor: revise set() api for animation support
before:
unique_ptr<Picture> Accessor::set(unique_ptr<Picture> picture, function<bool(const Paint* paint)> func)

after:
Result Accessor::set(const Picture* picture, std::function<bool(const Paint* paint, void* data)> func, void* data)
2024-09-30 15:48:18 +09:00
Hermet Park
52a69b9a93 examples: added Lighten/Darken options in MaskingMethods 2024-09-30 15:48:18 +09:00
Hermet Park
abf3e2d6ae renderer: newly support the Lighten/Darken Masking options
Lighten is applied, where multiple masks intersect,
the highest transparency value is used.

Darken is applied, where multiple masks intersect,
the lowest transparency value is used.

Experimental API:
- CompositeMethod::LightenMask
- CompositeMethod::DarkenMask

issue: https://github.com/thorvg/thorvg/issues/2608
2024-09-30 15:48:18 +09:00
Hermet Park
90b40912d9 examples/lottie: updated a resource.
polished up for the animation smoothness.
2024-09-30 15:48:18 +09:00
Stephan T. Lavavej
4d3bdf00af Revert "common: fix a crash on CI windows test."
This reverts commit e51dfb068a.
2024-09-30 15:48:18 +09:00
Hermet Park
439124d670 lottie/expressions: add missing expressions property updates
apply expressions to separate x/y transform coordinates.
2024-09-30 15:48:18 +09:00
Mira Grudzinska
1fdfe8a3b8 sw_engine: handle grad edge cases
For a linear gradient defined by identical start and end
points, and for a radial gradient with a radius of 0,
the rendered shape should have the color of the last
specified color stop.
The documentation has been updated accordingly.

@Issue: https://github.com/thorvg/thorvg/issues/2582
2024-09-30 15:48:18 +09:00
Sergii Liebodkin
cff78dc067 wg_engine: emscripten and browser support
[issues 2410: emscripten support](https://github.com/thorvg/thorvg/issues/2410)
- Research and prototype the Emscripten build with WebGPU.

meson setup script:
   meson setup builddir -Ddefault_library=static -Dloaders=all -Dsavers="all" -Dbindings="wasm_beta" -Dengines="wg_beta" --cross-file ./cross/wasm_webgpu.txt
2024-09-30 15:48:18 +09:00
Hermet Park
17e628d8f7 lottie: remove useless condition check.
lottie is always animatable.
2024-09-30 15:48:18 +09:00
Sergii Liebodkin
0004887225 wg_engine: introduce simultaneous flag support for strokes trimming
https://github.com/thorvg/thorvg/issues/2435
2024-09-30 15:48:18 +09:00
Mira Grudzinska
e21c225b7f common: fix trimming
By mistake > was used instead of >=.
The issue was observed for trim when
the trim length was exactly zero.
2024-09-30 15:48:18 +09:00
Mira Grudzinska
d29a3d754b common: move&fix trimming wrapping logic
The logic of interpretation of trimming start and
end values has been moved to the sw_engine,
so the values provided by the user are not modified.
No logical changes in the interpretation alg.

For pairs of trim's start/end values where the distance
between begin and end is >= 1, the entire stroke should
be drawn, but instead, nothing or only part is drawn. Fixed.

Stroke trim docs fixed.
2024-09-30 15:48:18 +09:00
Hermet Park
c9ad7289a6 lottie/expressions: feature enhancement
added groupIndex() support
added property (ix) value support
2024-09-30 15:48:18 +09:00
Hermet Park
fc61fc42c2 lottie: code refactoring
Access its type from a property instance,
through coherent data structure.
2024-09-30 15:48:18 +09:00
Łukasz Pomietło
2b3930b46d ttf_loader: Basic support for composite glyphs loading (#2600)
Adds the ability to load some composite glyphs and prevents an error when a composite glyph is used.

Implementation based on ttf glyf table documentation: https://learn.microsoft.com/en-us/typography/opentype/spec/glyf

There are still some missing features like scaling, parent glyph point based positioning etc. I think this is a topic for future work. Howerever, it looks like implemented features are enough for utf-8 latin subset in major fonts.

issue: #2599
2024-09-30 15:48:13 +09:00
Hermet Park
ecabdc5ebc renderer: code refactoring
Replaced the transformation with
a strong associated data field.

This helps to reduce the binary size (-1k).
2024-09-30 15:39:52 +09:00
Hermet Park
157e873e83 common: code refactoring
Trimming the transform data pass,
from RenderTransform to Matrix.

No logical changes.
2024-09-30 15:39:46 +09:00
Hermet Park
dac36f490f Update CODEOWNERS 2024-09-30 15:39:41 +09:00
Hermet Park
a801ad7e25 Update CODEOWNERS 2024-09-30 15:39:36 +09:00
Mira Grudzinska
7274b3d601 sw_engine: fix radial coefficients calculations
In the Taylor series expansion, there was a missing
division by 2! in the term with the second derivative.

@Issue: https://github.com/thorvg/thorvg/issues/2530
2024-09-30 15:39:20 +09:00
Hermet Park
4ed9ada00e lottie/expressions: hotfix
- fixed a memory leak.
- corrected loopIn key value.
2024-09-30 15:38:32 +09:00
Hermet Park
dfc6e67c6b sw_engine: rectified the image raster return value.
Return the raster image as a success unless
it fails due to any problematic condition.

The changed cases are just invisible condition
of the images.
2024-09-30 15:38:23 +09:00