diff --git a/inc/thorvg.h b/inc/thorvg.h index 638481f0..8c5e3807 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -214,7 +214,8 @@ enum class BlendMethod : uint8_t Color, ///< Reserved. Not supported. Luminosity, ///< Reserved. Not supported. Add, ///< Simply adds pixel values of one layer with the other. (S + D) - HardMix ///< Reserved. Not supported. + HardMix, ///< Reserved. Not supported. + Composition = 255 ///< Used for intermediate composition. @since 1.0 }; diff --git a/src/bindings/capi/thorvg_capi.h b/src/bindings/capi/thorvg_capi.h index 4fc32a68..57b4b4fd 100644 --- a/src/bindings/capi/thorvg_capi.h +++ b/src/bindings/capi/thorvg_capi.h @@ -164,7 +164,8 @@ typedef enum { TVG_BLEND_METHOD_COLOR, ///< Reserved. Not supported. TVG_BLEND_METHOD_LUMINOSITY, ///< Reserved. Not supported. TVG_BLEND_METHOD_ADD, ///< Simply adds pixel values of one layer with the other. (S + D) - TVG_BLEND_METHOD_HARDMIX ///< Reserved. Not supported. + TVG_BLEND_METHOD_HARDMIX, ///< Reserved. Not supported. + TVG_BLEND_METHOD_COMPOSITION = 255 ///< Used for intermediate composition. @since 1.0 } Tvg_Blend_Method; diff --git a/src/renderer/sw_engine/tvgSwRenderer.cpp b/src/renderer/sw_engine/tvgSwRenderer.cpp index 162770b6..7e375b04 100644 --- a/src/renderer/sw_engine/tvgSwRenderer.cpp +++ b/src/renderer/sw_engine/tvgSwRenderer.cpp @@ -528,6 +528,7 @@ bool SwRenderer::blend(BlendMethod method) switch (method) { case BlendMethod::Normal: + case BlendMethod::Composition: surface->blender = nullptr; break; case BlendMethod::Multiply: diff --git a/src/renderer/tvgPaint.cpp b/src/renderer/tvgPaint.cpp index 23cd05b3..a3d5c6b7 100644 --- a/src/renderer/tvgPaint.cpp +++ b/src/renderer/tvgPaint.cpp @@ -429,11 +429,14 @@ uint8_t Paint::opacity() const noexcept Result Paint::blend(BlendMethod method) noexcept { - if (method > BlendMethod::HardMix) return Result::InvalidArguments; //TODO: Remove later if (method == BlendMethod::Hue || method == BlendMethod::Saturation || method == BlendMethod::Color || method == BlendMethod::Luminosity || method == BlendMethod::HardMix) return Result::NonSupport; - pImpl->blend(method); - return Result::Success; + + if (method == BlendMethod::Composition || method <= BlendMethod::HardMix) { + pImpl->blend(method); + return Result::Success; + } + return Result::InvalidArguments; }