-
-
Notifications
You must be signed in to change notification settings - Fork 159
api: Add Composition blend mode #3621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new Composition blend mode to the ThorVG API that enables intermediate blending by generating an intermediate buffer to render scenes before blending with the canvas. This feature is intended for special composition cases but comes with a performance cost.
- Adds
BlendMethod::Compositionto the C++ API andTVG_BLEND_METHOD_COMPOSITIONto the C API - Updates blend method validation logic to accept the new composition mode
- Configures the software renderer to handle composition mode similarly to normal blending
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| inc/thorvg.h | Adds Composition enum value to BlendMethod with value 255 |
| src/bindings/capi/thorvg_capi.h | Adds TVG_BLEND_METHOD_COMPOSITION to C API enum |
| src/renderer/tvgPaint.cpp | Updates blend method validation to accept Composition mode |
| src/renderer/sw_engine/tvgSwRenderer.cpp | Adds Composition case to blend method switch statement |
|
+ @SergeyLebedkin gl/wgpu also need to support Composition |
The composition mode enables intermediate blending. When a scene uses Composition mode, it generates an intermediate buffer to render the scene image first. This image can then be blended with the canvas afterward. Please avoid to use this, unless you really need to composite the precomposite scene. This feature is relatively expensive at performance. C++ API: +BlendMethod::Composition C API: +Tvg_Blend_Method::TVG_BLEND_METHOD_COMPOSITION
Set the scene to use Composition mode so that it generates a pre-composition image, and then normal blend with destination. #3621
Set the scene to use Composition mode so that it generates a pre-composition image, and then normal blend with destination. see also: #3621
Set the scene to use Composition mode so that it generates a pre-composition image, and then normal blend with destination. see also: #3621
The composition mode enables intermediate blending. When a scene
uses Composition mode, it generates an intermediate buffer to
render the scene image first. This image can then be blended with the canvas afterward.
Please avoid to use this, unless you really need to composite the precomposite scene. This feature is relatively expensive at performance.
C++ API:
+BlendMethod::Composition
C API:
+Tvg_Blend_Method::TVG_BLEND_METHOD_COMPOSITION
Example:
