Commit graph

2403 commits

Author SHA1 Message Date
RuiwenTang
fea0d1bb77 gl_engine: use raw pointer to pass and hold GlRenderTask 2023-10-23 18:08:14 +09:00
Sergii Liebodkin
94eabc609c wg_engine: Added ability to draw multiple linear gradient filled shapes
[issues 1479: LinearGradient](thorvg#1479)

In order to build you need third party libraries. Before you start please read this: [LearnWebGPU](https://eliemichel.github.io/LearnWebGPU/getting-started/hello-webgpu.html)

Usage example:

    // init glfw
    glfwInit();

    // create a windowed mode window and its opengl context
    glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
    GLFWwindow* window = glfwCreateWindow(800, 800, "WebGPU base app", nullptr, nullptr);

    // get window size
    int width{}, height{};
    glfwGetWindowSize(window, &width, &height);

    // init engine webgpu
    tvg::Initializer::init(tvg::CanvasEngine::Wg, 0);

    // create wg canvas
    auto canvasWg = tvg::WgCanvas::gen();
    canvas_wg->target(glfwGetWin32Window(window), width, height);

    // gradient color stops
    tvg::Fill::ColorStop colorStops[2];
    colorStops[0] = {0, 0, 0, 0, 255};
    colorStops[1] = {1, 255, 255, 255, 255};
    // linear gradient
    auto fill = tvg::LinearGradient::gen();
    fill->linear(0, 0, 400, 400);
    fill->colorStops(colorStops, 2);
    // prepare rectangle
    auto shape1 = tvg::Shape::gen();
    shape1->appendRect(0, 0, 400, 400); //x, y, w, h
    shape1->fill(std::move(fill));
    canvas_wg->push(std::move(shape1));

    // gradient color stops
    tvg::Fill::ColorStop colorStops2[3];
    colorStops2[0] = { 0, 255, 0, 0, 255 };
    colorStops2[1] = { 0.5, 255, 255, 0, 255 };
    colorStops2[2] = { 1, 255, 255, 255, 255 };
    // linear gradient
    auto fill2 = tvg::LinearGradient::gen();
    fill2->linear(400, 200, 400, 600);
    fill2->colorStops(colorStops2, 3);
    // prepare circle
    auto shape2 = tvg::Shape::gen();
    shape2->appendCircle(400, 400, 200, 200); //cx, cy, radiusW, radiusH
    shape2->fill(std::move(fill2));
    canvas_wg->push(std::move(shape2));

    // gradient color stops
    tvg::Fill::ColorStop colorStops3[4];
    colorStops3[0] = { 0, 0, 127, 0, 127 };
    colorStops3[1] = { 0.25, 0, 170, 170, 170 };
    colorStops3[2] = { 0.5, 200, 0, 200, 200 };
    colorStops3[3] = { 1, 255, 255, 255, 255 };
    // linear gradient
    auto fill3 = tvg::LinearGradient::gen();
    fill3->linear(450, 600, 750, 600);
    fill3->colorStops(colorStops3, 4);
    // prepare ellipse
    auto shape3 = tvg::Shape::gen();
    shape3->appendCircle(600, 600, 150, 100); //cx, cy, radiusW, radiusH
    shape3->fill(std::move(fill3));
    canvas_wg->push(std::move(shape3));

    while (!glfwWindowShouldClose(window)) {
        // webgpu
        canvas_wg->draw();
        canvas_wg->sync();

        // pull events
        glfwPollEvents();
    }

    // terminate engine and window
    tvg::Initializer::term(tvg::CanvasEngine::Wg);
    glfwDestroyWindow(window);
    glfwTerminate();
2023-10-23 18:05:56 +09:00
Hermet Park
891c7d1139 examples/lottie: added more show cases 2023-10-23 14:19:05 +09:00
Hermet Park
6a18e694d1 sw_engine/raster: optimized the scaled image rasterization
Unified common logic for scaled image raster operations,
Avoid on-spot pixel computation as possible.

Tested on local machine (single thread)

Lottie: 0.057s -> 0.053s (-0.004s)
2023-10-23 11:02:10 +09:00
Sergii Liebodkin
14b2508cd1 wg_engine: Added ability to draw multiple solid color filled shapes
[issues 1479: Shape](https://github.com/thorvg/thorvg/issues/1479)

In order to build you need third party libraries. Before you start please read this: [LearnWebGPU](https://eliemichel.github.io/LearnWebGPU/getting-started/hello-webgpu.html)

Usage example:

    // init glfw
    glfwInit();

    // create a windowed mode window and its opengl context
    glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
    GLFWwindow* window = glfwCreateWindow(800, 800, "WebGPU base app", nullptr, nullptr);

    // get window size
    int width{}, height{};
    glfwGetWindowSize(window, &width, &height);

    // init engine webgpu
    tvg::Initializer::init(tvg::CanvasEngine::Wg, 0);

    // create wg canvas
    auto canvasWg = tvg::WgCanvas::gen();
    canvas_wg->target(glfwGetWin32Window(window), width, height);

    // prepare a shape (Rectangle + Rectangle + Circle + Circle)
    auto shape1 = tvg::Shape::gen();
    shape1->appendRect(0, 0, 200, 200);                //x, y, w, h
    shape1->appendRect(100, 100, 300, 300, 100, 100);  //x, y, w, h, rx, ry
    shape1->appendCircle(400, 400, 100, 100);          //cx, cy, radiusW, radiusH
    shape1->appendCircle(400, 500, 170, 100);          //cx, cy, radiusW, radiusH
    shape1->fill(255, 255, 0);                         //r, g, b

    canvas_wg->push(std::move(shape1));

    while (!glfwWindowShouldClose(window)) {
        // webgpu
        canvas_wg->draw();
        canvas_wg->sync();

        // pull events
        glfwPollEvents();
    }

    // terminate engine and window
    tvg::Initializer::term(tvg::CanvasEngine::Wg);
    glfwDestroyWindow(window);
    glfwTerminate();
2023-10-20 18:37:52 +09:00
Hermet Park
61081c02af sw_engine raster: fixed a default alpha blending bug.
alpha value has been missed by a mistake,
a regression by c50d2fd

Issue: https://github.com/thorvg/thorvg/issues/1716
2023-10-20 13:27:17 +09:00
Hermet Park
d81f5d29fb sw_engine/math: fine-tuning optimization
Try to minimize the use of sqrt() and arctan() calls
when possible. These calls can be relatively expensive
when accumulated within a single frame.

Also repalce the division with shift operation.
since split cubic function is one of the significant hot-spots
in the data processing, we could earn a noticable enhancement.

Tested on single thread local machine:

Lottie: 0.080 -> 0.052s (-0.028s)
Performance: 0.023 -> 0.022 (-0.001s)
Binary: +34
2023-10-20 13:18:28 +09:00
Hermet Park
3ef740145f gl_engine: fix a compiler warning.
../src/renderer/gl_engine/tvgGlRenderPass.cpp:37:29: warning: macro expands to multiple statements [-Wmultistatement-macros]
   37 |     if (mColorTex) GL_CHECK(glDeleteTextures(1, &mColorTex));
2023-10-20 11:26:10 +09:00
RuiwenTang
6a2b34df73 gl_engine: support basic alpha composite
* introduce a new class GlRenderPass to hold off-screen rendering result
* add basic alpha composite support with begin/end render-pass
2023-10-20 10:51:04 +09:00
Hermet Park
4de2b953d1 sw_engine/math: Enhance trigonometric functions.
Streamlining computations with floating-point operations in rotation
thereby improving 'thorvg' speed.

Also use the well-optimized posix math functions instead of
custom math.

Test on my local machine.

Lottie: -0.008s (0.073 -> 0.065)
Performance: -0.0013s (0.0154 -> 0.0141)
Binary: -323
2023-10-19 10:39:50 +09:00
Hermet Park
a6d7a19047 api: enhance the API usage.
Allow users to omit the default type casting for added convenience.
2023-10-18 14:35:57 +09:00
Sergii Liebodkin
ce2a3f6040 capi: introduce missing blend functions in capi bindings 2023-10-18 10:39:45 +09:00
Hermet Park
171a21c0d7
Delete .gitmodules
no more used
2023-10-18 01:20:43 +09:00
Hermet Park
3123e184c8 lottie: Fixed trimpath to support simultaneous trimpath
The previous version omitted support for simultaneous trimpath,
but it is now working as intended.
2023-10-17 21:13:38 +09:00
Hermet Park
625c2405fc lottie/builder: Fix overlapped stroking outlines.
Previously, the builder accumulated the outlines and fills
in one paint to reduce the rendering context.

However, this approach won't work for Lottie
if the resource contains multiple strokes with branched groups.

We should apply the optimization
only when the specified condition is satisfied.
2023-10-17 21:13:38 +09:00
JunsuChoi
fdb2a17504 renderer/initializer: Support for initializing SW and GL engines together
Initialize both renderers to allow init(SW | GL);
2023-10-16 11:04:45 +09:00
Martin Capitanio
e3a3acb6b0 loader/jpg: Fix a regression bug.
Fixes #1705
2023-10-15 11:01:09 +09:00
Hermet Park
f271eca76d
Update AUTHORS 2023-10-13 23:03:55 +09:00
SergeyLebedkin
8d5c728119
wg_engine: introduce a webgpu canvas(engine)
WebGPU is a Render Hardware Interface built on top of the various APIs 
provided by the driver/OS depending on your platform. 

WebGPU exposes an API for performing operations, 
such as rendering and computation, on a Graphics Processing Unit.

WebGPU official documentation: https://www.w3.org/TR/webgpu/

The new engine type introduced: tvg::CanvasEngine::Wg

The new canvas type introduced: tvg::WgCanvas

Example:
$meson setup build -Dengines=wg_beta

`
    // init engine webgpu
    tvg::Initializer::init(tvg::CanvasEngine::Wg, 0);

    // create wg canvas
    auto canvasWg = tvg::WgCanvas::gen();
    canvas_wg->target(glfwGetWin32Window(window), width, height);

    // ...

    // terminate engine and window
    tvg::Initializer::term(tvg::CanvasEngine::Wg);
`
Still this feature is under the beta

Issue: https://github.com/thorvg/thorvg/issues/1479
2023-10-13 22:59:32 +09:00
Nattu Adnan
9659f6e1b0 Enhance README image responsiveness 2023-10-13 16:23:39 +09:00
Hermet Park
3a2de2bc6a lottie/builder: fix a regression bug.
currently thorvg doesn't support full 3d transformation.
orthogonal projection is mandatory.

Issue: https://github.com/thorvg/thorvg/issues/1698
2023-10-13 14:26:59 +09:00
Hermet Park
f6261205d4 examples: add svg samples. 2023-10-13 11:59:15 +09:00
Hermet Park
4a9b008b83 examples: allow gl test 2023-10-13 11:59:04 +09:00
RuiwenTang
4722550e06 gl_engine: support clip by using scissor and stencil 2023-10-12 23:18:12 +09:00
Martin Capitanio
133662c8e9 loader/svg: Fix maskContentUnits userSpaceOnUse/objectBoundingBox
Fixes #1694
2023-10-12 15:05:40 +09:00
Hermet Park
d304e1c902
Update README.md 2023-10-09 20:24:41 +09:00
Hermet Park
8a5418ed8b infra: add android CI build test with necessary cross build config. 2023-10-09 20:24:07 +09:00
Hermet Park
2dbecdfbb2
Update CONTRIBUTING.md 2023-10-09 18:16:54 +09:00
Hermet Park
b69c3b1af3 infra/gitaction: fix a broken macos/ios CI build. 2023-10-09 15:39:59 +09:00
Hermet Park
4c3cdb38b5 infra: migrate cross files into one folder. 2023-10-09 15:39:59 +09:00
Hermet Park
eba7f2f0d7 lottie/builder: revise the render context for saving memory.
Allocate repeater context only when it's valid.
2023-10-09 11:00:33 +09:00
Hermet Park
57038df21f Lottie: Fixed handling of multiple strokes in one layer.
Revised the rendering logic of Lottie by creating a new rendering context
using a queue when multiple strokes are requested.

Issue: https://github.com/thorvg/thorvg/issues/1642
2023-10-09 11:00:33 +09:00
Hermet Park
32b825c6d7
Update CONTRIBUTING.md 2023-10-05 18:43:28 +09:00
Hermet Park
0cc6cfffef sw_engine/stroke: enhanced the quality of the dash line corners.
Previously, the engine didn't properly cover the dash line corner styles
because it considered a new line to start at the corner.

This update modifies the logic to recognize curved lines
as a single line, including the corners.

There may still be some quality issues,
but it's an improvement over the previous version.

@Issue: https://github.com/thorvg/thorvg/issues/121
2023-10-05 14:30:10 +09:00
Hermet Park
7ccd287e59
Update CONTRIBUTING.md 2023-10-05 14:14:13 +09:00
Hermet Park
7c394fa682
Update CODEOWNERS 2023-10-05 14:08:05 +09:00
Hermet Park
a567775251
Update CODEOWNERS 2023-10-04 12:47:43 +09:00
Hermet Park
e6d0b46d35
Update CODEOWNERS 2023-10-04 12:45:35 +09:00
RuiwenTang
6a3a03f29f gl_engine: support render image 2023-10-04 12:41:22 +09:00
Hermet Park
3cee0ec761
Update README.md 2023-10-04 12:26:25 +09:00
Hermet Park
aa83ed46e4 infra/gitaction: corrected meson build commands
meson "setup" is a mandatory command. skipping has been deprecated.
2023-10-04 12:24:42 +09:00
Hermet Park
4dfee84148 infra/ios: added basic CI git action workflow. 2023-10-04 12:24:42 +09:00
Hermet Park
f9f1e9932c infra: added ios cross compile scripts.
meson setup builddir --cross-file ./ios_x86_64_cross.txt ...
2023-10-04 12:24:42 +09:00
Hermet Park
3fabf9f19d infra: changed to dev mode 2023-09-28 08:36:54 +09:00
Hermet Park
12260198d1 release: bump up version v0.11.0 2023-09-28 08:30:34 +09:00
Hermet Park
b0f6640bca docs: updated to v0.11
In this update, we have chosen not to include CAPIs.
This decision was made due to the mixture of C++ and C languages
in a single documentation category, which resulted in a messy presentation.

Also, In this update, we have removed 'doxygen-awesome-css'
and introduced our own designated styles located in the 'style' folder.
After generating the Doxyfiles, we can overwrite the styles with these new ones.
2023-09-27 11:18:25 +09:00
Hermet Park
ba84771cce
Update README.md 2023-09-26 22:46:26 +09:00
Hermet Park
0e3b3d3095
Update README.md 2023-09-26 22:43:38 +09:00
Hermet Park
2b7c47f2b5
doc/capi: updated 2023-09-26 19:06:57 +09:00
Hermet Park
5ecd3fb479 sw_engine: Correct the color conversion condition.
The color conversion is supposed to take into account the differences between
straight alpha premultiplied color and pre-multiplied alpha color.

The previous logic does not perfectly cover these conditions.

The problem was occured in the thorvg viewer with a jpeg bgra format.
2023-09-26 18:57:34 +09:00