Commit graph

3156 commits

Author SHA1 Message Date
Hermet Park
ad7c65d2ea 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-30 16:44:22 +09:00
RuiwenTang
cd4fecf84e 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-30 16:44:22 +09:00
Hermet Park
4378d8dc7c renderer: ++TODO for optimization 2024-09-30 16:44:22 +09:00
Mira Grudzinska
310183972e 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-30 16:44:22 +09:00
Hermet Park
5453e8d82b Update README.md 2024-09-30 16:44:22 +09:00
Mira Grudzinska
59ffd90758 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-30 16:44:22 +09:00
Mira Grudzinska
99153ef26e sw_engine: fix translucent grad rastering
8bit translucent gradient rle were missing AA. Fixed.
2024-09-30 16:44:22 +09:00
Mira Grudzinska
7e30bd850c tests: ++lcov 2024-09-30 16:44:22 +09:00
Mira Grudzinska
21dad77da6 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-30 16:44:22 +09:00
Mira Grudzinska
d240044aae 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-30 16:44:22 +09:00
Mira Grudzinska
b3b619349d wg_engine: fix stroke trimming
Prevent crash for begin == end;
2024-09-30 16:44:22 +09:00
Sergii Liebodkin
47d3d7e7d5 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-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
8510926bf7 infra: updated labeler 2024-09-30 16:44:22 +09:00
Hermet Park
03db2e31c3 Update README.md 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
Jinny You
27a1dae240 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-30 16:44:22 +09:00
JunsuChoi
2851d72adf 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-30 16:44:22 +09:00
Hermet Park
5f0e3ca5d3 Update README.md 2024-09-30 16:44:22 +09:00
Hermet Park
c92ae2c776 Update README.md 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
Sergii Liebodkin
1daf6a010c 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-30 16:44:22 +09:00
Hermet Park
79e5a0f3eb examples: updated a lottie sample 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
ab54345d9a test: replaced ClipPath with clip() 2024-09-30 16:44:22 +09:00
Hermet Park
8f8af68955 examples: replaced ClipPath with clip() 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
RuiwenTang
4bc1e60dfd gl_engine: implement advance blending
Implement some advance blending equation in GLEngine by using two
RenderPass.

* The first pass render the content into an off-screen framebuffer, also
blit the screen content to an off-screen Texture.

* The second pass renders the final blended color to the screen.
Also use a stencil test to prevent non-drawn areas from participating in the color blending calculation.

issue: https://github.com/thorvg/thorvg/issues/2435
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
Mira Grudzinska
8acb135cb0 wg_engine: fix vertices while line joining
Vertex ordering during line join needed adjustment.
Vertices were forming two partialy overlapping triangles
instead of a rectangle. The issue was rarely visible since
the resulting rectangle often overlapped significantly
with other rectangles.
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
24ed6656d0 renderer: hotfix a crash
prevent a nullptr memory access
regression by f5337015e9

issue: https://github.com/godotengine/godot/issues/97078
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
Hermet Park
0d028678dc Revert "examples: updated samples"
This reverts commit 1e72e8f3a3.
2024-09-30 16:44:22 +09:00
Hermet Park
7f6eace8e3 examples: updated samples 2024-09-30 16:44:22 +09:00
Sergii Liebodkin
02ebfc1332 wg_engine: wrong gradient transformation fixed
issue: https://github.com/thorvg/thorvg/issues/2620
2024-09-30 16:44:22 +09:00
Hermet Park
e2f00be400 Update README.md 2024-09-30 16:44:22 +09:00
Hermet Park
7d642a1da3 Update README.md 2024-09-30 16:44:22 +09:00
Hermet Park
6a4a4bba98 examples: updated lottie resources 2024-09-30 16:44:22 +09:00
Jinny You
d42919ac1d wg_engine: Enable premultiplied canvas on browser
Emscripten 3.1.66 includes support for WebGPU's premultiplied canvas.

Surface configurations have been updated with premultiplied alpha mode to support this feature.

see: c82a307c61
2024-09-30 16:44:22 +09:00
Hermet Park
197b98c9d2 sw_engine: clean up code 2024-09-30 16:44:22 +09:00
Hermet Park
9b65b67a86 sw_engine: rectified 8 grayscale drawing
8 bits matting images must be blended, not overwriting.

issue: https://github.com/thorvg/thorvg/issues/1767
2024-09-30 16:44:22 +09:00
Hermet Park
1aa5742feb sw_engine: Added missing matting and blending for direct images
issue: https://github.com/thorvg/thorvg/issues/1767
2024-09-30 16:44:22 +09:00
Hermet Park
cfc3c26e90 Update README.md 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
Hermet Park
5cfd541ea9 sw_engine: blending stabilization++
Currently, only blending might work.
Blending and composition must be handled together.
2024-09-30 16:44:22 +09:00