+
Skip to content

Conversation

hermet
Copy link
Member

@hermet hermet commented Jul 17, 2025

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:
image

@hermet hermet requested a review from mgrudzinska as a code owner July 17, 2025 02:57
@hermet hermet requested review from Copilot and removed request for mgrudzinska July 17, 2025 02:57
@hermet hermet self-assigned this Jul 17, 2025
@github-actions github-actions bot added APIs Update / Revise APIs cpu Software render backend renderer Core rendering binding CAPI / Wasm labels Jul 17, 2025
@hermet hermet added enhancement Improve features and removed APIs Update / Revise APIs cpu Software render backend renderer Core rendering binding CAPI / Wasm labels Jul 17, 2025
Copy link

@Copilot Copilot AI left a 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::Composition to the C++ API and TVG_BLEND_METHOD_COMPOSITION to 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

@hermet
Copy link
Member Author

hermet commented Jul 17, 2025

+ @SergeyLebedkin gl/wgpu also need to support Composition

@github-actions github-actions bot added APIs Update / Revise APIs cpu Software render backend renderer Core rendering binding CAPI / Wasm labels Jul 17, 2025
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
@hermet hermet merged commit 930de44 into main Jul 21, 2025
15 checks passed
@hermet hermet deleted the hermet/api branch July 21, 2025 02:23
SergeyLebedkin added a commit that referenced this pull request Jul 24, 2025
Set the scene to use Composition mode so that it generates a pre-composition image, and then normal blend with destination.

#3621
hermet pushed a commit that referenced this pull request Jul 25, 2025
Set the scene to use Composition mode so that it generates
a pre-composition image, and then normal blend with
destination.

see also: #3621
hermet pushed a commit that referenced this pull request Jul 25, 2025
Set the scene to use Composition mode so that it generates
a pre-composition image, and then normal blend with
destination.

see also: #3621
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

APIs Update / Revise APIs binding CAPI / Wasm cpu Software render backend enhancement Improve features renderer Core rendering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载