Commit graph

34 commits

Author SHA1 Message Date
Hermet Park
3c884232fd gl_engine: rewrite the blending shader
Completely rewrite the GL backend shader to support advance blending and
correct the blending behavior.
Now the GL backend has the same blending result as SKIA and CanvasRenderingContext2D in browers did.

The formula is referenced from:
https://www.w3.org/TR/compositing-1/#porterduffcompositingoperators

issue: https://github.com/thorvg/thorvg/issues/2799
2025-05-12 13:27:14 +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
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
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
a12accbc93 updated copyright 2025-01-03 14:32:31 +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
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
RuiwenTang
76f98008e8 gl_engine: optimize off-screen rendering
Performing a full-screen RenderPass resolve is too expensive.
Because most composite cases only require a small area to be rendered off-screen.
To improve performance, use the bounds of the Geometry for off-screen rendering whenever possible
2024-07-04 11:44:02 +09:00
RuiwenTang
28331e9bf3 gl_engine: Fix memory leak caused by no deleted GlRenderTask 2024-06-25 00:15:01 +09:00
RuiwenTang
b71d9d563a gl_engine: Fix compile error if only has OpenGL library on MacOS
Since GLES headers and library can not be found on MacOS,
use macros to determin if link with OpenGL library.
2024-06-23 19:34:31 +09:00
RuiwenTang
f8626d13d1 gl_engine: fix clip path and bounds not correct
* Optimize clip logical, change to use GL_GRATER and keep incrace depth
  value, so no need to do depth clear after every clip draw.
* Correct geometry bounding box calculation, and make sure the bounds is
  larger than all vertices
* Limit drawing area for off-screen RenderPass with correct scissor box
2024-06-11 20:57:07 +09:00
RuiwenTang
9521e80e4c gl_engine: fix stencil logical not correct
Fix the stencil reference and compile function cause rendering not
correct
2024-05-06 11:02:35 +09:00
RuiwenTang
bb7f23da78 gl_engine: fix rendering error caused by viewport and stencil state
Fix some error:
* glViewport not controlled by framebuffer, and need to set manually when
target framebuffer is changed.
* change even-odd stencil operation, so no need to do third draw call to
  clear stencil buffer
* fix the missing `GlCanvas::update` calls in Lottoe and LottieExtension
2024-04-29 17:14:31 +09:00
RuiwenTang
da45fa6608 gl_engine: using depth buffer to support path clip
* Append depth buffer attachment in tvgGlRenderPass
* using depth test if Shape has path clip
2024-04-16 13:36:13 +09:00
RuiwenTang
bb793a2762 gl_engine: fix some typo inside GlRenderer
* Fix a typo error when prepare blit task
* Prevent repeated texture generation during task preparation
2024-04-15 11:05:34 +03:00
RuiwenTang
d9d677acc6 gl_engine: using normal texture rendering in final color blit
Since blit msaa framebuffer to another msaa framebuffer may generate
GLError in some platforms. Use normal texture rendering to blit the final
color buffer onto target framebuffer.
2024-04-15 00:44:53 +09:00
RuiwenTang
23386625fc gl_engine: make stencil task support other advance logical
* Support rendering Gradient in path Stroke mode
* Fix GlStencilCoverTask not support even-odd fill rule
* Make GlStencilCoverTask can discard overlapped area during stroke
  rendering
2024-03-21 11:50:13 +09:00
RuiwenTang
68f7e4c245 gl_engine: enable msaa resolve in GLRenderPass
* use GLRenderBuffer in color and stencil attachment, also use x4 sample
  count by default.
* add msaa resolve logical at the end of a ComposeTask, so the normal
  color texture can get the final rendering result.
2024-03-13 10:12:46 +02:00
RuiwenTang
be278dfc67 gl_engine: add stencil and cover render task
* add new render task to do stencil and cover rendering which is a
  fallback rendering method to handle cases that trianglation tessellation
  failed

* add a new tessellator to generate stencil and cover vertex mesh
2024-02-07 15:13:40 +09:00
RuiwenTang
c8e0c48636 gl_engine: append stencil attachment in GLRenderTarget
Plans to use stencil to test support for path clipping and complex path rendering
When the tessellation algorithm cannot handle it.
2024-01-18 21:11:58 +09:00
Jinny You
2c6c8d3b21
updated copyright date (#1866) 2023-12-28 10:43:25 +09:00
RuiwenTang
51a69880fd gl_engine: fix wrong scissor value cause content not fully rendered 2023-12-19 22:35:47 +09:00
Sergii Liebodkin
548962f5f8 apis/engines: Revise the clear() buffer behavior.
ThorVG has offered an option to clear the buffer since version 1.0.
This is essential when users utilize the canvas target buffer
with the main render target. They share the buffer
and need to draw contents onto the existing contents.

API:
Result Canvas::clear(bool free = true)
-> Result Canvas::clear(bool paints = true, bool buffer = true)

Tvg_Result tvg_canvas_clear(Tvg_Canvas* canvas, bool free);
-> Tvg_Result tvg_canvas_clear(Tvg_Canvas* canvas, bool paints, bool buffer);

Issue: https://github.com/thorvg/thorvg/issues/1779

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2023-11-20 18:23:00 +09:00
RuiwenTang
fea0d1bb77 gl_engine: use raw pointer to pass and hold GlRenderTask 2023-10-23 18:08:14 +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
RuiwenTang
4722550e06 gl_engine: support clip by using scissor and stencil 2023-10-12 23:18:12 +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
24711e485c infra: renames the source folders
lib -> renderer
bin -> tools
utils -> common
2023-08-28 13:11:24 +09:00
Renamed from src/lib/gl_engine/tvgGlRenderTask.cpp (Browse further)