Commit graph

3328 commits

Author SHA1 Message Date
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
Hermet Park
03dbb7a8e1 examples: updated a lottie sample 2024-09-19 15:30:40 +09:00
Jinny You
d70ddcd67c 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-19 15:29:38 +09:00
Hermet Park
d70aa68dcc test: replaced ClipPath with clip() 2024-09-19 14:46:05 +09:00
Hermet Park
ece1537271 examples: replaced ClipPath with clip() 2024-09-19 14:46:05 +09:00
Hermet Park
b0683a26ec 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-19 14:46:05 +09:00
Jinny You
b9b1336817 lottie/text: hotfix for parsing text range issue
If randomize is not enabled, "rn" prop falls into skip()
2024-09-19 14:41:37 +09:00
RuiwenTang
1fe9f269b1 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-19 11:58:38 +09:00
Jinny You
9c5933a4e5 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-19 11:05:24 +09:00
Mira Grudzinska
84ba907b70 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-18 18:23:37 +09:00
Hermet Park
ae6faf56c5 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-17 21:13:59 +09:00
Hermet Park
5fc52ea6b0 renderer: hotfix a crash
prevent a nullptr memory access
regression by f5337015e9

issue: https://github.com/godotengine/godot/issues/97078
2024-09-17 11:53:01 +09:00
Hermet Park
a633322b8b lottie: ++expressions coverage
added missing velocityAtTime() for float types.

issue: https://github.com/thorvg/thorvg/issues/2724
2024-09-15 17:04:27 +09:00
Hermet Park
0e06413749 Revert "examples: updated samples"
This reverts commit 1e72e8f3a3.
2024-09-15 15:24:36 +09:00
Hermet Park
1e72e8f3a3 examples: updated samples 2024-09-15 00:19:33 +09:00
Hermet Park
68fff066fc lottie: fixed memory violation.
set the dirName as the current location by default.

issue: https://github.com/thorvg/thorvg/issues/2733
2024-09-14 15:33:15 +09:00
Sergii Liebodkin
7a6a89cf26
wg_engine: wrong gradient transformation fixed
issue: https://github.com/thorvg/thorvg/issues/2620
2024-09-13 13:36:21 +09:00
Hermet Park
91a538d1f2
Update README.md 2024-09-13 13:03:18 +09:00
Hermet Park
4f9540dd30
Update README.md 2024-09-13 13:02:28 +09:00
Hermet Park
c562d63487 examples: updated lottie resources 2024-09-13 11:03:41 +09:00
Jinny You
fbe6d59c04 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-12 22:01:26 +09:00
Hermet Park
9f43039403 sw_engine: clean up code 2024-09-12 21:57:26 +09:00
Hermet Park
7aacae170f 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-12 21:57:26 +09:00
Hermet Park
c974940016 sw_engine: Added missing matting and blending for direct images
issue: https://github.com/thorvg/thorvg/issues/1767
2024-09-12 21:57:26 +09:00
Hermet Park
0962c55c82
Update README.md 2024-09-12 12:56:51 +09:00
Mira Grudzinska
bf9f5ab1c5 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-10 19:02:24 +09:00