Commit graph

3203 commits

Author SHA1 Message Date
Mira Grudzinska
3c74e90b76 sw_engine: ignore small cubics
During the stroke's outline calculation, the function
handling small cubics set all angles to zero. When
the cubic was small but not zero, this resulted in
incorrect outlines. Now such curves are ignored.

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

Issue: https://github.com/thorvg/thorvg/issues/2776
Issue: https://github.com/thorvg/thorvg/issues/2712
2024-10-03 21:31:07 +09:00
Hermet Park
827247181a test: shutdown the false alram of the valgrind
- Conditional jump or move depends on uninitialised value(s)
2024-10-03 18:56:26 +09:00
Hermet Park
08e6b8333f renderer/compressor: corrected base64 decoded data size
issue: https://github.com/thorvg/thorvg/issues/2794
2024-10-03 18:56:26 +09:00
Hermet Park
b868503033 sw_engine: ++stability
cut the Bezier curve based on the number of points
and transform it into a straight line when it's very small.

issue: https://github.com/thorvg/thorvg/issues/2759
2024-10-03 18:54:14 +09:00
Hermet Park
d3af7a5cb0 sw_engine: fixed an uninitialized data access 2024-10-03 18:20:47 +09:00
Mira Grudzinska
a80beff714 examples: fix mingw build error
M_PI was not declared error solved
2024-10-03 16:39:18 +09:00
Hermet Park
d8f6710c73 lottie: hotfix layer effect parsing
fixed a break in expressions/driving.json
2024-10-03 13:53:45 +09:00
Hermet Park
5dabcbac0b 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 13:31:19 +09:00
Mira Grudzinska
38f4d17eac 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:32:48 +09:00
Hermet Park
132213110c wasm: fix a build break 2024-10-01 17:11:28 +09:00
Hermet Park
13110fbec7 lottie: portability++
issue: https://github.com/thorvg/thorvg/issues/2764
2024-10-01 14:08:08 +09:00
Hermet Park
ad6f2070fe examples/tvg: updated samples 2024-10-01 12:17:32 +09:00
Hermet Park
d038518e6d lottie: ++safety 2024-10-01 11:23:12 +09:00
Hermet Park
ceb07c61df test: fix a memory leak 2024-09-30 23:52:57 +09:00
RuiwenTang
894ecd7461 gl_engine: implement darken and lighten mask method
Add new shader to support darken and lighten mask method.
2024-09-30 23:17:33 +09:00
Mira Grudzinska
2238109ada 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 22:18:51 +09:00
Hermet Park
b995c33ac7 hotfix: backward compatibility++ 2024-09-30 18:02:19 +09:00
Sergii Liebodkin
08c333acd9 CompositeMethod::ClipPath will be replaced with the Scene::clip()
wg_engine needs to refactor to remove the enum value usage before proceeding with its removal
2024-09-30 17:44:42 +09:00
Hermet Park
4bb0a369e5 examples: fixed an incorrect buffer size.
adjusted the size according to the offsets.
2024-09-30 17:09:21 +09:00
Hermet Park
155d4a2aa2 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 12:29:54 +09:00
Hermet Park
639df7e3cf gl_engine: --deprecation references. 2024-09-29 21:52:32 +09:00
Hermet Park
bbe69578a5 renderer/scene: rectify the render region elaboration
Properly clip the render region to the current viewport.
2024-09-29 15:04:22 +09:00
Hermet Park
27f173faa3 sw_engine: applied OpenMP to improve post-processing performance.
- OpenMp threads will be allocated alongside the TaskSculeduler::threads()
- Performance improved by 2x in a specific animation.
- Disable the thread feature in the Android build test due to system issues with OpenMP compilation.
2024-09-29 15:04:22 +09:00
Hermet Park
f08d7aa037 lottie: support layer effect & gaussian blur
issue: https://github.com/thorvg/thorvg/issues/2718
2024-09-29 15:04:22 +09:00
Hermet Park
ba7761c105 examples: added SceneEffect
added a showcase with a gaussian blur effect
2024-09-29 15:04:22 +09:00
Hermet Park
2558e5dc10 renderer: introduced SceneEffect feature
Scene effects are typically applied to modify
the final appearance of a rendered scene,
such as adding a blur effect.

Each effect would have a different number of parameters
to control its visual properties. The Scene::push() interface
 uses variadic arguments to accommodate various cases.

Users should refer to the SceneEffect API documentation
and pass the parameters exactly as required for the specific
effect type. For instance, GaussianBlur expects 3 parameters
which are:

- sigma(float)[greater than 0]
- direction(int)[both: 0 / horizontal: 1 / vertical: 2]
- border(int)[extend: 0 / wrap: 1]
- quality(int)[0 ~ 100]

and, scene->push(SceneEffect::GaussianBlur, 5.0f, 0, 0, 100);

New Experimental APIs:
- SceneEffect::ClearAll
- SceneEffect::GaussianBlur
- Result Scene::push(SceneEffect effect, ...);

Example:
- examples/SceneEffect

issue: https://github.com/thorvg/thorvg/issues/374
2024-09-29 15:04:22 +09:00
RuiwenTang
64df0791df example: MultiCanvas show case with GL backend
Change the MultiCanvas code to show how to render the content of
GlCanvas to a given off-screen framebuffer.

issue: https://github.com/thorvg/thorvg/issues/2746
2024-09-29 11:57:27 +09:00
Hermet Park
e59c6046ec renderer: ++TODO for optimization 2024-09-28 19:46:31 +09:00
Mira Grudzinska
c6384c3b8f renderer: fix clipped clippers
Fast track was applied for clippers even if they
were also clipped. As a result their clips were
omitted.

@Issue: https://github.com/thorvg/thorvg/issues/2777
2024-09-28 19:40:09 +09:00
Hermet Park
465f2345d1
Update README.md 2024-09-27 19:55:19 +09:00
Mira Grudzinska
edf1cfe927 sw_engine: add support for 8bits gradient rectangles
Rastering for 32bits dst buffer was implemented,
but 8bits dst were not supported.

@Issue: https://github.com/thorvg/thorvg/issues/2765
2024-09-27 18:27:31 +09:00
Mira Grudzinska
932f55070d sw_engine: fix translucent grad rastering
8bit translucent gradient rle were missing AA. Fixed.
2024-09-27 12:57:54 +09:00
Mira Grudzinska
1a1d00ea71 tests: ++lcov 2024-09-27 07:07:50 +09:00
Mira Grudzinska
dc754833bc wg_engine: prevent adding duplicate points while trimming
In cases where the distance between points is 0, further
processing of the points results in division by zero.
To avoid this check, we ensure that duplicate points are
not added during trimming.
2024-09-26 16:13:05 +09:00
Mira Grudzinska
2fc0aad2d1 wg_engine: fix stroke trimming
Fix cases when begin < 0 - this require handling the stroke
in two parts: begin - 0 and 0 - end.
Improve trimming for simultaneous=true.
2024-09-26 16:13:05 +09:00
Mira Grudzinska
fa17fcde81 wg_engine: fix stroke trimming
Prevent crash for begin == end;
2024-09-25 23:45:38 +09:00
Sergii Liebodkin
ee6a7214d4 wg_engine: geometry generating optimization
Streaming model for massive vertex and index creations: minimize memory allocations, range checks and other conditions
Reduce number of segments length calculations (sqrt) and bbox (min and max).
Update distances and bboxes on a whole buffer and only if necessary. For shapes without strokes compute distances not necessary at all. bbox can be updated only on the final stage of geometry workflow, but not on the each stage.
Using stack memory instead of heap. its more cache friendly and did not fragment memory, faster memory allocations (weak place of realization)
Using cache for points distances and whole path length. Updates only if necessary
Validation of geometry consistency executes only on the final stage of path life cicle. It more friendly for data streaming: no any conditions and branches.
Using binary search for strokes trimming
Pre-cached circles geometry for caps and joints
Refactored strokes elements generation functions. Code is more readable and modifiable in general. Can be easily fixed if some geometry issues will be finded
2024-09-25 17:09:29 +09:00
Hermet Park
06441437c0 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-25 12:20:55 +09:00
Mira Grudzinska
ec25ce9362 svg_loader: fix circle radius if in percentages 2024-09-24 14:33:15 +09:00
Hermet Park
e40e4541a6 infra: updated labeler 2024-09-24 14:32:49 +09:00
Hermet Park
b84c71431b
Update README.md 2024-09-24 01:51:55 +09:00
Hermet Park
76fb3f3cd9 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-23 21:53:50 +09:00
Jinny You
7ec697aa77 wasm: Handle WebGPU part for integration
Updated the WebGPU engine API to align with the latest interface.

Static/Single instance, adapter and device to support multiple canvases on the browser.

Moved the WGPU request part to `initWGInstance` helper function. This must only be called once even, when multiple players are involved.

Issue: #2695
2024-09-23 17:12:30 +09:00
JunsuChoi
7e4a568ec2 infra: Add PR labeler
Add a labeler that automatically creates labels when a pull request is created.
(You can edit the labeler by modifying ./.github/labeler.yml.)

https://github.com/thorvg/thorvg/issues/labels
2024-09-23 13:24:48 +09:00
Hermet Park
e0dd730f75
Update README.md 2024-09-22 01:40:21 +09:00
Hermet Park
2e9641d061
Update README.md 2024-09-22 01:36:28 +09:00
Hermet Park
0e2d1dfcfa common: code refactoring
Properly renamed internal interfaces.
No logical changes.

- Compositor -> RenderCompositor
- Surface -> RenderSurface
2024-09-21 16:37:37 +09:00
JunsuChoi
853d701d27 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-20 21:29:36 +09:00
Hermet Park
6712861154 lottie: --type casting warning in MSVC 2024-09-19 23:23:29 +09:00
Sergii Liebodkin
79d4d64e4a wg_engine: fix strokes triangulation artifacts
Fixed detection of close vertices using comparison with epsilon and related artifacts in stencil buffer as extra pixels.
Fixed incorrect tessellation of curves using scaling.
2024-09-19 16:51:41 +09:00