Hermet Park
d6fffd13c2
api: revise the engine initializer for the 1.0 release.
...
This change introduces the CanvasEngine::All type to automatically
initialize the engines available on the current system.
These revisions improve the usability of these APIs.
Addtions:
- enum class CanvasEngine::All
Modifications:
- Result Initializer::init(CanvasEngine engine, uint32_t threads) ->
Result Initializer::init(uint32_t threads, CanvasEngine engine = tvg::CanvasEngine::All)
2023-10-30 11:48:02 +09:00
Mira Grudzinska
25a1321243
common: stroke dash offset support with new apis.
...
This change just allows users to use the offset of the stroke dash.
Actually feature enhacement has been introduced by
478e45f9f3
.
@APIs:
uint32_t Shape::strokeDash(const float** dashPattern) ->
uint32_t Shape::strokeDash(const float** dashPattern, float* offset = nullptr)
Result Shape::strokeDash(const float* dashPattern, uint32_t cnt) ->
Result Shape::strokeDash(const float* dashPattern, uint32_t cnt, float offset = 0.0f)
Tvg_Result tvg_shape_set_stroke_dash(Tvg_Paint* paint, const float* dashPattern, uint32_t cnt) ->
Tvg_Result tvg_shape_set_stroke_dash(Tvg_Paint* paint, const float* dashPattern, uint32_t cnt, float offset)
Tvg_Result tvg_shape_get_stroke_dash(const Tvg_Paint* paint, const float** dashPattern, uint32_t* cnt) ->
Tvg_Result tvg_shape_get_stroke_dash(const Tvg_Paint* paint, const float** dashPattern, uint32_t* cnt, float* offset)
@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-10-30 11:47:51 +09:00
Hermet Park
f3a2d2a5a6
portability: addressed all compilation warnings from MSVC
2023-10-27 14:20:50 +09:00
Hermet Park
baee5ec767
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-10-27 12:13:00 +09:00
Hermet Park
db55481e97
renamed stroke apis family.
...
float Shape::stroke(float width) -> float Shape::strokeWidth(float width)
Result Shape::stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) -> Result Shape::strokeFill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
Result Shape::stroke(std::unique_ptr<Fill> f) -> Result Shape::strokeFill(std::unique_ptr<Fill> f)
Result Shape::stroke(const float* dashPattern, uint32_t cnt, float offset = 0.0f) -> Result Shape::strokeDash(const float* dashPattern, uint32_t cnt, float offset = 0.0f)
Result Shape::stroke(StrokeCap cap) -> Result Shape::strokeCap(StrokeCap cap)
Result Shape::stroke(StrokeJoin join) -> Result Shape::strokeJoin(StrokeJoin join)
Result Shape::strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const -> Result Shape::strokeFill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const
@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-10-27 11:46:51 +09:00
Hermet Park
989b995189
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-10-27 11:24:44 +09:00
Hermet Park
978f85c3ea
apis: optimize for compact data size.
...
Still it needs to size down of the PathCommand.
@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-10-26 15:11:31 +09:00
Hermet Park
21911fa1c8
apis: remove deprecated
...
- Result Picture::bounds(float* x, float* y, float* w, float* h) const
- Result Picture::load(const char* data, uint32_t size, bool copy = false)
- Result Canvas::reserve(uint32_t size)
- Result Scene::reserve(uint32_t size)
@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-10-26 15:03:13 +09:00
Hermet Park
b2499739ee
renderer/shape: enable returning count values only
2023-10-26 13:02:54 +09:00
Hermet Park
6e3674b904
canvas/paint: ++exception handling
...
enhanced reference count verification
to prevent unintentional deletion of used composition targets.
2023-10-26 11:22:39 +09:00
SergeyLebedkin
8200bc5fc3
wg_engine: Added a feature to draw multiple radial gradient filled shapes
2023-10-24 18:24:16 +09:00
Hermet Park
e570064eba
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-10-24 11:49:57 +09:00
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
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
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
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
RuiwenTang
4722550e06
gl_engine: support clip by using scissor and stencil
2023-10-12 23:18:12 +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
RuiwenTang
6a3a03f29f
gl_engine: support render image
2023-10-04 12:41:22 +09:00
Hermet Park
12260198d1
release: bump up version v0.11.0
2023-09-28 08:30:34 +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
Hermet Park
51c3a8912c
sw_engine: fix an invalid memory access.
...
the surface and mesh data can be missed by an invalid condition.
this fixes an invalid memory access problem.
Issue: https://github.com/thorvg/thorvg/issues/1671
2023-09-26 17:41:08 +09:00
Hermet Park
e4ade98e8c
sw_engine: fix a regression stroke bug
...
reverted changes that occurred this issue from d683d2e
Issue: https://github.com/thorvg/thorvg/issues/1670
2023-09-26 14:26:57 +09:00
Hermet Park
74b67919e0
tvg: support radial gradient focal properties
...
properly store/restore the radial gradient focal properties
from the tvg loader and saver
2023-09-26 13:05:27 +09:00
Hermet Park
ed23b432bb
tvg: support dash offset property
...
properly store/restore the dash offset property
from the tvg loader and saver
Issue: https://github.com/thorvg/thorvg/issues/1617
2023-09-26 13:05:27 +09:00
Hermet Park
1819fed033
renderer/paint: fixed a mismatched reference count.
...
This correction ensures a consistent use of 'ref' and 'unref' for paints to release memory properly.
The memory leak occurred when a picture was not pushed to a valid canvas.
This issue was reported by the unit-test memory sanitizer.
2023-09-26 10:48:33 +09:00
RuiwenTang
453cba7ddd
gl_engine: make GlRenderTask generic with uniform block
...
* Use uniform block to pack all color informations
* Move the actual gl draw call into GlRenderer::sync function, so all
data is been uploaded into GPU
* Make GlRenderTask simple and generic for direct gl draw
2023-09-21 22:24:07 +09:00
Hermet Park
9e3b74bac5
sw_engine fill: fixed radial fill focal issue.
...
This might be a workaround to correct the issue.
The threshold value comes from the mathematical inaccuracy.
@Issue:https://github.com/thorvg/thorvg/issues/1555
2023-09-21 22:19:42 +09:00
Hermet Park
edb156f4fc
sw_engine/shape: fix a dash-line infite-loop bug.
...
a regresion bug was introduced by d683d2e70d
2023-09-21 21:55:53 +09:00
Hermet Park
bd9d0cea6d
sw_engine: properly implemented the missing image composition.
...
The 8-bit masking target is the destination with a 32-bit source image and 8-bit composition.
2023-09-20 18:42:06 +09:00
Martin Capitanio
5ed7034c45
sw_engine: fix VS 2017 issues with Godot's NOMINMAX
...
Fixes #1661
2023-09-19 21:51:54 +09:00
Hermet Park
8aa12ca468
taskschduler: fix a regression deadlock issue
...
This fix introduces a workaround to enforce synchronous tasking on worker threads.
Sometimes, out of threads get stuck in a deadlock condition.
@Issue: https://github.com/thorvg/thorvg/issues/1636
2023-09-18 21:06:01 +09:00
Hermet Park
d683d2e70d
sw_engine: Do not handle exceptions for zero line length.
...
While it may represent a dot with a stroke width,
ignoring its length is not a good idea.
this also eliminates 0 size dash dots caused by unexpected empty lengths.
2023-09-15 11:16:38 +09:00
RuiwenTang
5298f338de
gl_engine: fix compilation erros due to redundant header inclusion
2023-09-14 19:49:35 +09:00
Hermet Park
ed1b4a4923
sw_engine: allow 8bit grayscale gradient filling
2023-09-14 01:03:22 +09:00
Hermet Park
e9490e375c
sw_engine: corrected a wrong blending equation at 8 bits grayscale rle.
2023-09-14 01:03:22 +09:00
Hermet Park
cea63125a4
sw_engine: fix a wrong compuation.
...
corrected a mistake caused by a dead brain.
2023-09-12 21:40:01 +09:00
Hermet Park
46d831ead7
sw_engine: skip the rendering if possible.
...
zero scale would not produce any visible artifacts.
we can skip the further processing sonner.
2023-09-12 20:52:33 +09:00
Hermet Park
2257211852
sw_engine: fix a regression bug by 0dafe9ff64
...
rectified the stroke scale factor acquisition.
2023-09-12 11:44:27 +09:00
Hermet Park
0dafe9ff64
sw_engine: revised code.
...
add a concrete logic for validating the stroke width
2023-09-05 18:41:20 +09:00
Hermet Park
78cb32794a
sw_engine: utilize the memory pool for dash stroking.
2023-09-05 12:38:57 +09:00
Hermet Park
64a444aeb6
loader/lottie: support focal property in the radial gradient
2023-09-05 10:29:12 +09:00
Hermet Park
fa134692b0
Revert "renderer taskscheduler: code refactoring."
...
This reverts commit 77de62068c
.
This fixes the sanitizer thread report (data race) issue.
@Issue: https://github.com/thorvg/thorvg/issues/1623
2023-09-05 10:22:53 +09:00