Sergii Liebodkin
bad02c7de0
Added ability to draw solid strokes with dashes
...
[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);
//Test for Stroke Dash for Arc, Circle, Rect
auto shape = tvg::Shape::gen();
shape->appendArc(70, 600, 160, 10, 30, true);
shape->appendCircle(70, 700, 20, 60);
shape->appendRect(130, 710, 100, 40);
shape->strokeFill(255, 0, 0);
shape->strokeWidth(5);
shape->strokeJoin(tvg::StrokeJoin::Round);
shape->strokeCap(tvg::StrokeCap::Round);
float dashPattern[2] = {20, 10};
shape->strokeDash(dashPattern, 2);
if (canvas_wg->push(std::move(shape)) != tvg::Result::Success) return;
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-12-26 18:18:48 +09:00
Sergii Liebodkin
41ea198a5e
Added ability to draw solid strokes
...
[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);
//Test for Stroke Dash for Arc, Circle, Rect
auto shape = tvg::Shape::gen();
shape->appendArc(70, 600, 160, 10, 30, true);
shape->appendCircle(70, 700, 20, 60);
shape->appendRect(130, 710, 100, 40);
shape->strokeFill(255, 0, 0);
shape->strokeWidth(5);
shape->strokeJoin(tvg::StrokeJoin::Round);
shape->strokeCap(tvg::StrokeCap::Round);
if (canvas_wg->push(std::move(shape)) != tvg::Result::Success) return;
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-12-26 18:18:42 +09:00
Hermet Park
f5e6fce5c1
gif: corrected the wrong aspect ratio scaling.
2023-12-26 18:18:33 +09:00
Hermet Park
58311ee5c3
saver/gif: Fix a clipping issue.
...
The Lottie loader missed handling the base clipper resizing.
This patch addresses the issue.
2023-12-26 18:18:27 +09:00
Hermet Park
acb67dad8c
saver/gif: up to date the gif encoder.
...
this fixes the memory sanitizer report:
../src/savers/gif/gif.h:315:31: runtime error: index 255 out of bounds for type 'unsigned char [255]'
../src/savers/gif/gif.h:113:54: runtime error: index 255 out of bounds for type 'unsigned char [255]'
Issue: https://github.com/thorvg/thorvg/issues/1758
2023-12-26 18:18:21 +09:00
Hermet Park
875b623c95
binding/wasm: updated save features
...
- removed the compression option
- added an animation save function.
2023-12-26 18:17:41 +09:00
Hermet Park
3306f53a78
Update README.md
2023-12-26 18:17:41 +09:00
Hermet Park
f3a843f91d
Update README.md
2023-12-26 18:17:41 +09:00
Hermet Park
2c382e3d9b
doc: keep the style clean & neat
2023-12-26 18:17:41 +09:00
Hermet Park
40ff8592e5
binding/wasm: updated save features
...
- removed the compression option
- added an animation save function.
2023-12-26 18:17:41 +09:00
Hermet Park
ec958c5fec
Update README.md
2023-12-26 18:17:41 +09:00
Hermet Park
708e9a7c2a
tools/lottie2gif: introduce a new converter tool.
...
Usage:
lottie2gif [Lottie file] or [Lottie folder] [-r resolution] [-f fps]
Examples:
$ lottie2gif input.json
$ lottie2gif input.json -f 30
$ lottie2gif input.json -r 600x600 -f 30
$ lottie2gif lottiefolder
$ lottie2gif lottiefolder -r 600x600
$ lottie2gif lottiefolder -r 600x600 -f 30
2023-12-26 18:17:41 +09:00
Jinny You
059a950d42
docs: Remove all warnings from doxygen
2023-12-26 18:17:41 +09:00
RuiwenTang
f3a155bce8
gl_engine: fix memory out of bounds error in GlGpuBuffer
...
If buffer data is larger than memory alignment, need to make sure there
is enough memory in current stage buffer
2023-12-26 18:17:41 +09:00
Hermet Park
b9504ca9c2
renderer: maintain consistency in the logging domain.
2023-12-26 18:17:41 +09:00
Hermet Park
4dfb1a036e
Update AUTHORS
2023-12-26 18:17:41 +09:00
JunsuChoi
a20216045a
saver GifSaver: Introduce GifSaver for animation
...
Add save() API that takes tvg::Animation as a parameter.
This API uses gif.h to create each animation frame as a gif frame.
Gif creation do not support threads because they must be added sequentially.
Please see example/GifSaver.cpp
ex)
auto animation = tvg::Animation::gen();
auto picture = animation->picture();
picture->load(EXAMPLE_DIR"/walker.json");
auto saver = tvg::Saver::gen();
saver->save(std::move(animation), EXAMPLE_DIR"/test.gif");
saver->sync();
New API:
Result Saver::save(std::unique_ptr<Animation> animation, const std::string& path, uint32_t quality = 100, uint32_t fps = 0);
Issue: https://github.com/thorvg/thorvg/issues/1712
2023-12-26 18:17:38 +09:00
Hermet Park
43f0ba403c
loaders/png: fixed data conversion warnings on Windows
...
../src/loaders/external_png/tvgPngLoader.cpp(110): warning C4244: '=': conversion from 'float' to 'uint32_t', possible loss of data
../src/loaders/external_png/tvgPngLoader.cpp(111): warning C4244: '=': conversion from 'float' to 'uint32_t', possible loss of data
../src/loaders/external_png/tvgPngLoader.cpp(112): warning C4244: '=': conversion from 'float' to 'uint32_t', possible loss of data
2023-12-26 18:06:58 +09:00
Hermet Park
b21c7f8302
example/capi: remove saver test.
...
This generated tvg often make us confused
when Tvg example doesn't show it properly.
It's too small circle.
2023-12-26 18:06:50 +09:00
Jinny You
45dfab5ef5
examples: Support mac os to execute all
2023-12-26 18:06:15 +09:00
Hermet Park
fba98c8cbf
renderer: ++safety
...
these member values can be accesssed without update() call.
2023-12-26 18:06:07 +09:00
Hermet Park
22c36b7069
wasm: fix a regression bug.
...
The Animation::frame() method has been modified.
It will now return InsufficientCondition,
if the frame value is the same as the previous one.
In addition to this change, we have also updated its usage accordingly.
2023-12-26 18:05:58 +09:00
Hermet Park
37a01b8735
portability: addressed all compilation warnings from MSVC
2023-12-26 18:05:36 +09:00
Hermet Park
c3d88b18fe
lottie: fixed all memory access violations.
2023-12-26 18:05:28 +09:00
Hermet Park
c8a8bb5af4
renderer/paint: added a blend update flag.
...
Keep track of the update changes accurately.
We can utilize this value change in the backend engine.
2023-12-26 18:05:22 +09:00
Hermet Park
29590b373f
lottie/builder: enable layer blending
...
Issue: https://github.com/thorvg/thorvg/issues/1737
2023-12-26 18:02:12 +09:00
Hermet Park
c18643f9b6
renderer: revise the internal paints structure.
...
Get rid of the polymorphism function table,
use the switch directly instead.
We profiled, both binary & performance is better than before.
Tested on a local machine (single thread):
- Lottie: 2ms improved
- Binary: -0.5kb
2023-12-26 18:01:57 +09:00
Hermet Park
ab8dd8a9c2
lottie: ++optimization with a caching effect.
...
reuse clippers if they are available.
Binary: +132
2023-12-26 18:01:51 +09:00
Hermet Park
aa4c186cd2
lottie: introduced static layer cache.
...
lottie builder doesn't need to rebuild the layer object
if it has no any animation frame data.
That case, we can cache the layer scene in order to reuse it.
Tested on local machine (single thread):
- Lottie: appx. 2ms enhanced.
- Binary: +204
2023-12-26 18:01:30 +09:00
Hermet Park
37fdfaf3d9
renderer/shape: enable returning count values only
2023-12-26 17:53:37 +09:00
Hermet Park
fce2e404d3
lottie: clean up code
...
no logical changes, only code clean-up
2023-12-26 17:53:31 +09:00
Hermet Park
240d540091
canvas/paint: ++exception handling
...
enhanced reference count verification
to prevent unintentional deletion of used composition targets.
2023-12-26 17:53:25 +09:00
SergeyLebedkin
4f0fbc459c
wg_engine: Added a feature to draw multiple radial gradient filled shapes
2023-12-26 17:51:59 +09:00
Hermet Park
0832a188fe
animation/lottie: updated the frame count unit.
...
replace the frame count unit from the int32_t to float
since animations could smoothly interpolate key-frames.
This notificably improve the animation smoothness in Lottie
Beta API changes:
Result Animation::frame(uint32_t no) -> Result Animation::frame(float no)
uint32_t Animation::curFrame() const -> float Animation::curFrame() const
uint32_t Animation::totalFrame() const -> float Animation::totalFrame() const
2023-12-26 17:51:53 +09:00
RuiwenTang
2038818e16
gl_engine: use raw pointer to pass and hold GlRenderTask
2023-12-26 17:51:46 +09:00
Sergii Liebodkin
db1f171d2a
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-12-26 17:51:39 +09:00
Hermet Park
854ae10011
examples/lottie: added more show cases
2023-12-26 17:51:31 +09:00
Hermet Park
97ac3194b4
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-12-26 17:51:23 +09:00
Sergii Liebodkin
938b69688d
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-12-26 17:51:17 +09:00
Hermet Park
9cbf300b8e
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-12-26 17:51:11 +09:00
Hermet Park
43f45ebd65
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-12-26 17:51:04 +09:00
Hermet Park
6caf864064
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-12-26 17:50:58 +09:00
RuiwenTang
a46af19ccb
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-12-26 17:50:50 +09:00
Hermet Park
81e3025ad9
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-12-26 17:50:43 +09:00
Hermet Park
1b15233aeb
api: enhance the API usage.
...
Allow users to omit the default type casting for added convenience.
2023-12-26 17:50:36 +09:00
Sergii Liebodkin
da72a57f8a
capi: introduce missing blend functions in capi bindings
2023-12-26 17:50:22 +09:00
Hermet Park
059c6c5d85
Delete .gitmodules
...
no more used
2023-12-26 17:50:14 +09:00
Hermet Park
8af77ba5b1
lottie: Fixed trimpath to support simultaneous trimpath
...
The previous version omitted support for simultaneous trimpath,
but it is now working as intended.
2023-12-26 17:50:08 +09:00
Hermet Park
244e984df8
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-12-26 17:50:02 +09:00
JunsuChoi
17fa8a7412
renderer/initializer: Support for initializing SW and GL engines together
...
Initialize both renderers to allow init(SW | GL);
2023-12-26 17:49:51 +09:00