Commit graph

111 commits

Author SHA1 Message Date
Sergii Liebodkin
d0be8cd2bd gl_engine: fix compilation warning with RenderRegion data type 2025-05-28 19:20:47 +09:00
Hermet Park
8a35f02105 renderer/engines: redesigned RenderRegion property layout
redefiend properties so that min/max are prioritized,
as they are accessed more frequently than pos/size
during rendering calculations.

also introduced miscellaneous functions to improve usability.
2025-05-28 11:41:52 +09:00
Sergii Liebodkin
55847bdcb3 gl_engine: fix memoty leak on target resize
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
We must to remove offscreen render buffers during removing render target

https://github.com/thorvg/thorvg/issues/3210
2025-05-25 23:04:12 +09:00
Hermet Park
3fbb55440a renderer: ++engines safety
Added drawing exceptions when target is not properly ready.

Now, Canvas::update() Canvas::draw() will return InsufficientCondition
if the target has not been set beforehand.
2025-05-12 12:49:10 +09:00
Hermet Park
457b019ab4 gl_engine: --compiler warning on emsdk.
warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
2025-05-08 15:07:17 +09:00
RuiwenTang
ec26784266 gl_engine: dynamic load gl functions
no any 3rd-party libs, such as glfw or glad did not used
support windows, linux, macos and emsdk
only the actually used set of functions are loaded

Co-Authored-By: Sergii Liebodkin <sergii@lottiefiles.com>
Co-Authored-BY: Hermet Park <hermet@lottiefiles.com>

issue: https://github.com/thorvg/thorvg/issues/2453
2025-05-08 14:58:13 +09:00
Jinny You
7bcee79077 gl_engine: replace std::string with C-style strings for portability
- C-style strings provide consistent binary interface for FFI
- Reduces potential issues where standard library is limited (e.g., WebAssembly, embedded systems)
2025-05-02 17:43:25 +09:00
Hermet Park
53e5e783b7 api: revise engine initialization and termination
Simplified parameters and ensured proper backend engine
initialization by using reference checking through canvas
instances.

C++ API Modification:
- Result Initializer::init(uint32_t threads, CanvasEngine engine)
 -> Result Initializer::init(uint32_t threads)
- Result Initializer::term(CanvasEngine engine)
 -> Result Initializer::term()

C API Modification:
- Tvg_Result tvg_engine_init(Tvg_Engine engine_method, unsigned threads)
 -> Tvg_Result tvg_engine_init(unsigned threads);
- Tvg_Result tvg_engine_term(Tvg_Engine engine_method)
 ->  Tvg_Result tvg_engine_term()

issue: https://github.com/thorvg/thorvg/issues/3116
2025-04-23 15:46:49 +09:00
Hermet Park
4cf68b75e5 renderer: code clean++ 2025-04-22 00:13:40 +09:00
Hermet Park
1a332acd37 renderer: revise the pImpl design with a better efficiency
The following is a redesign that extends the class internally.

The main goal is to preserve the characteristics of the pImpl idiom
for data encapsulation, while simultaneously reducing the memory
allocation overhead typically associated with pImpl.

The stragegy is here:
Rather than alloc the impl memory inside of the thorvg engine,
impl extends the API classes in order to consolidate the memory.

size has been decreased by -4kb with optimization=s

issue: https://github.com/thorvg/thorvg/issues/3214
2025-04-20 00:07:50 +09:00
Mira Grudzinska
3b634064c9 gl_engine: fix drop shadow blended color
The shadow color produced incorrect results after
blending with the texture color. This was caused
by not taking the alpha value into account in the
specified shadow color (with OpenGL blending disabled).
2025-04-17 11:18:47 +09:00
Sergii Liebodkin
6c3fee84ec gl_engine: introduce dropshadow effect for opengl renderer
issue: https://github.com/thorvg/thorvg/issues/3054
2025-04-15 11:43:32 +09:00
Sergii Liebodkin
eb67549295 gl_engine: Introduce tritone effect for opengl renderer
issue: https://github.com/thorvg/thorvg/issues/3054
2025-04-10 11:36:47 +09:00
Sergii Liebodkin
95f1b84a56 gl_engine: Introduce tint effect for opengl renderer
issue: https://github.com/thorvg/thorvg/issues/3054
2025-04-10 11:36:47 +09:00
Sergii Liebodkin
85e215a294 gl_engine: Introduce fill effect for opengl renderer
issue: https://github.com/thorvg/thorvg/issues/3054
2025-04-10 11:36:47 +09:00
Sergii Liebodkin
595769257e gl_engine: Introduce gaussian blur effect
issue: https://github.com/thorvg/thorvg/issues/3054
2025-04-09 11:16:55 +09:00
Hermet Park
e002d68338 Revert "gl_engine: Introduce gauss blur effect for opengl renderer"
This reverts commit 131c194124.

note: Lottie animation is broken
2025-03-28 00:28:27 +09:00
Sergii Liebodkin
131c194124 gl_engine: Introduce gauss blur effect for opengl renderer
issue: https://github.com/thorvg/thorvg/issues/3054
2025-03-27 22:51:02 +09:00
Sergii Liebodkin
b43177639c gl_engine: introduce the stroke clipper
See Clipping example
Issue: https://github.com/thorvg/thorvg/issues/3063
2025-03-04 18:37:53 +09:00
Hermet Park
75c9028c19 gl_engine: code refactoring
- introduced GlGeometryBuffer that structure ensures the pairing of vertex and index data.
- improved for clean and neat code.
2025-02-20 21:41:29 +09:00
Hermet Park
3c25623ee9 sw/gl/wg: ++threads safety
Considered global engine initialization and termination.
Engines could be used among multiple worker threads.
2025-02-11 19:03:50 +09:00
Sergii Liebodkin
0ecd2c0fd4 engine: introduce scene effect dispose render method
to correctly remove RenderDate from effects it must be removed in the renderer
a new method has been added to the RenderMethod interface
2025-01-26 10:13:28 +09:00
Mira Grudzinska
758aa932d7 gl_engine: add support for stroke/fill ordering 2025-01-22 16:24:29 +09:00
Hermet Park
b79d12a04d gl_engine: hotfix memory leak
issue: https://github.com/thorvg/thorvg/issues/3140
2025-01-20 21:27:06 +09:00
Hermet Park
df0658e2da renderer: improved engine for scalable effects
RenderMethod effects methods would have changes:
 + update()               //update the effects if any
 - prepare() -> region()  //update the effect drawing region
 - effect() -> render()   //draw the effect
2025-01-17 16:11:29 +09:00
Jinny You
4aba0caaad wasm: fix build issue in sw/wg build only case
- resolved EMSCRIPTEN_WEBGL_CONTEXT_HANDLE declaration problem.
- currentContext() should be also called after `mContext` is initialized.
2025-01-15 21:27:00 +09:00
Hermet Park
07e73a9e6f common: code refactoring
use ARRAY_FOREACH() for neat code and
accessing the memory efficiently than normal indexing.
2025-01-15 18:03:46 +09:00
Hermet Park
8f98681ea7 renderer: minor code clean++ 2025-01-15 12:24:32 +09:00
Hermet Park
a12accbc93 updated copyright 2025-01-03 14:32:31 +09:00
RuiwenTang
3c6d686795 gl_engine: fix fbo and texture leak
GlRenderTarget contains framebuffer and render target objects,
these GPU resources need to be released before reusing the structure and calling init with the new size.
2024-12-31 16:25:11 +09:00
Hermet Park
76203c3dbb gl_engine: ensure the gl context switching
This only covers emscripten environment,
need to cover other system.

issue: #3023

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2024-12-31 12:07:52 +09:00
Hermet Park
1cbc11cadd renderer: revamped engine interfaces
Introduced updated pre/post calls
for proper preparation of the drawing process.
2024-12-31 12:07:52 +09:00
Hermet Park
ccf5a8158f gl_engine: ++binary optimization
- removed unique_ptr, shared_ptr
- replaced std::vector with tvg::Array
- reduced binary size by -10kb
2024-12-30 22:24:53 +09:00
Hermet Park
1806b32971 common: optimization pImpl data structures
ThorVG pImpl idiom caused internal data to be scattered
across hierarchical classes. This refactoring consolidates
the data by inheriting pImpl internally, reducing memory
allocation counts and eliminating unnecessary strategy methods.
2024-12-14 12:24:57 +09:00
RuiwenTang
b1b7a78dd7 gl_engine: Fix gradient color not correct when shape has opacity
When rendering gradient color, needs to take opacity value into
consider.
2024-12-13 23:44:03 +09:00
Hermet Park
d6c80f538c renderer: add a new scene effect type - Fill
Fill is used for overriding the scene content color
with a given fill information. It's yet an Experimental API.

issue: https://github.com/thorvg/thorvg/issues/2718
2024-12-12 18:50:33 +09:00
Hermet Park
445000ba66 common: improve the rendering pipeline
enhanced the rendering composition target to better support features such as
alpha blending, blending, masking, post effects, and more.
This allows rasterizers to prepare the composition context with more precise control.

Additionally, resolved a crash in the software engine's post-effect process
caused by a buffer size mismatch during XY buffer flipping.

issue: https://github.com/thorvg/thorvg/issues/3009
issue: https://github.com/thorvg/thorvg/issues/2984
2024-12-04 22:31:37 +09:00
RuiwenTang
1a766ec00e gl_engine: correct the stroke alpha calculation
The wrong matrix scale factor value caused the stroke alpha to be zero
when the matrix contains rotation.
2024-11-27 12:37:47 +09:00
Hermet Park
877c524e5e renderer/sw_engine: fix omitted alpha multiplication in the dropshadow effect
When a scene has a valid opacity, it must be multiplied with the
direct dropshadow image to ensure correct rendering.
2024-11-23 01:03:39 +09:00
Hermet Park
ccaf44e80e gl_engine: fix a regression by a mistake
introduced by d3d085de15
2024-11-22 00:38:03 +09:00
Hermet Park
d3d085de15 renderer: code refactoring
- introduced RenderColor
- internal name changes to avoid conflicts
2024-11-20 22:13:27 +09:00
RuiwenTang
b9cbd74fc6 gl_engine: Fix repeated clip drawing causes performance degradation
The clips need to be cleared every time when shape update.
Otherwise, the increasing number of clips will hurt the performance.
2024-11-11 22:08:04 +09:00
RuiwenTang
0bb419c0b0 gl_engine: Support new radial gradient data struct and calculation
Change the shader and uniform struct to support new radial gradient.
The mathematical calculation comes from https://skia.org/docs/dev/design/conical/
2024-11-08 19:15:48 +09:00
RuiwenTang
95d99ee74b gl_engine: Fix memory leak in the IndexBuffer object
The CPU buffer cache in the IndexBuffer object needs to be cleared, otherwise it will cause memory leaks and reduce performance per frame
2024-11-08 18:38:15 +09:00
Hermet Park
e0365142a7 renderer: support SceneEffect DropShadow
Apply a drop shadow effect with a Gaussian Blur filter.

API Addition:
 - enum class SceneEffect::DropShadow

Parameters:
 - color_R(int)[0 - 255]
 - color_G(int)[0 - 255]
 - color_B(int)[0 - 255]
 - opacity(int)[0 - 255]
 - angle(float)[0 - 360]
 - distance(float)
 - blur_sigma(float)[> 0]
 - quality(int)[0 - 100]

issue: https://github.com/thorvg/thorvg/issues/2718
2024-11-06 00:56:11 +09:00
RuiwenTang
a855666e41 gl_engine: seperate the index buffer from vertex buffer
WebGL has a strict rule that does not allow the same GLBuffer
to be bound to both ARRAY_BUFFER and ELEMENT_ARRAY_BUFFER at the same time.
(https://registry.khronos.org/webgl/specs/latest/1.0/#5.14.5)

To support WebGL in the future, a separate GLBuffer is used to store index data.
2024-10-29 00:00:19 +09:00
Hermet Park
b4304b6d1f gl_engine: code refactoring
- clean up code
- resolve some data casting compiler warnings
2024-10-18 13:40:34 +09:00
Hermet Park
0a16152d75 api: renamed the composite with mask.
Since we've separated ClipPath and Masking,
Masking now has a distinct and independent purpose.

API Modification:
 - enum class CompositeMethod -> enum class MaskMethod
 - Result Paint::composite(std::unique_ptr<Paint> target, CompositeMethod method) -> Result Paint::mask(std::unique_ptr<Paint> target, MaskMethod method)
 - CompositeMethod Paint::mask(const Paint** target) const -> MaskMethod Paint::mask(const Paint** target) const

issue: https://github.com/thorvg/thorvg/issues/1372
2024-10-16 14:41:26 +09:00
Hermet Park
630cbc48ae api: revise the api for v1.0
- refactored the Fill matrix to hold internal data statically.
- refactored for clean & neat the raster engine / svg loader logic.

API Modification:
 - Matrix Fill::transform() const -> Matrix& Fill::transform() const

issue: https://github.com/thorvg/thorvg/issues/1372
2024-10-14 23:32:55 +09:00
Hermet Park
9bc900206b api: polish the thorvg API usages.
API Modification:
- SwCanvas::Colorspace -> ColorSpace

API Addition:
- ColorSpace::Unknown

issue: https://github.com/thorvg/thorvg/issues/1372
2024-10-12 15:38:03 +09:00