mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00
api: removed redundant CompisiteMethod::ClipPath
issue: https://github.com/thorvg/thorvg/issues/1372
This commit is contained in:
parent
9bc900206b
commit
367ac5f331
10 changed files with 18 additions and 38 deletions
|
@ -171,7 +171,6 @@ enum class FillRule : uint8_t
|
||||||
enum class CompositeMethod : uint8_t
|
enum class CompositeMethod : uint8_t
|
||||||
{
|
{
|
||||||
None = 0, ///< No composition is applied.
|
None = 0, ///< No composition is applied.
|
||||||
ClipPath, ///< The intersection of the source and the target is determined and only the resulting pixels from the source are rendered. Note that ClipPath only supports the Shape type. @deprecated Use Paint::clip() instead.
|
|
||||||
AlphaMask, ///< Alpha Masking using the compositing target's pixels as an alpha value.
|
AlphaMask, ///< Alpha Masking using the compositing target's pixels as an alpha value.
|
||||||
InvAlphaMask, ///< Alpha Masking using the complement to the compositing target's pixels as an alpha value.
|
InvAlphaMask, ///< Alpha Masking using the complement to the compositing target's pixels as an alpha value.
|
||||||
LumaMask, ///< Alpha Masking using the grayscale (0.2125R + 0.7154G + 0.0721*B) of the compositing target's pixels. @since 0.9
|
LumaMask, ///< Alpha Masking using the grayscale (0.2125R + 0.7154G + 0.0721*B) of the compositing target's pixels. @since 0.9
|
||||||
|
|
|
@ -138,7 +138,6 @@ typedef enum {
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TVG_COMPOSITE_METHOD_NONE = 0, ///< No composition is applied.
|
TVG_COMPOSITE_METHOD_NONE = 0, ///< No composition is applied.
|
||||||
TVG_COMPOSITE_METHOD_CLIP_PATH, ///< The intersection of the source and the target is determined and only the resulting pixels from the source are rendered. Note that ClipPath only supports the Shape type. @deprecated Use Paint::clip() instead.
|
|
||||||
TVG_COMPOSITE_METHOD_ALPHA_MASK, ///< The pixels of the source and the target are alpha blended. As a result, only the part of the source, which intersects with the target is visible.
|
TVG_COMPOSITE_METHOD_ALPHA_MASK, ///< The pixels of the source and the target are alpha blended. As a result, only the part of the source, which intersects with the target is visible.
|
||||||
TVG_COMPOSITE_METHOD_INVERSE_ALPHA_MASK, ///< The pixels of the source and the complement to the target's pixels are alpha blended. As a result, only the part of the source which is not covered by the target is visible.
|
TVG_COMPOSITE_METHOD_INVERSE_ALPHA_MASK, ///< The pixels of the source and the complement to the target's pixels are alpha blended. As a result, only the part of the source which is not covered by the target is visible.
|
||||||
TVG_COMPOSITE_METHOD_LUMA_MASK, ///< The source pixels are converted to grayscale (luma value) and alpha blended with the target. As a result, only the part of the source which intersects with the target is visible. \since 0.9
|
TVG_COMPOSITE_METHOD_LUMA_MASK, ///< The source pixels are converted to grayscale (luma value) and alpha blended with the target. As a result, only the part of the source which intersects with the target is visible. \since 0.9
|
||||||
|
|
|
@ -250,7 +250,7 @@ struct SwSurface : RenderSurface
|
||||||
|
|
||||||
SwAlpha alpha(CompositeMethod method)
|
SwAlpha alpha(CompositeMethod method)
|
||||||
{
|
{
|
||||||
auto idx = (int)(method) - 2; //0: None, 1: ClipPath
|
auto idx = (int)(method) - 1; //-1 for None
|
||||||
return alphas[idx > 3 ? 0 : idx]; //CompositeMethod has only four Matting methods.
|
return alphas[idx > 3 ? 0 : idx]; //CompositeMethod has only four Matting methods.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ static inline bool _blending(const SwSurface* surface)
|
||||||
This would help to enhance the performance by avoiding the unnecessary matting from the composition */
|
This would help to enhance the performance by avoiding the unnecessary matting from the composition */
|
||||||
static inline bool _compositing(const SwSurface* surface)
|
static inline bool _compositing(const SwSurface* surface)
|
||||||
{
|
{
|
||||||
if (!surface->compositor || (int)surface->compositor->method <= (int)CompositeMethod::ClipPath) return false;
|
if (!surface->compositor || surface->compositor->method == CompositeMethod::None) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -457,9 +457,6 @@ Result Paint::clip(std::unique_ptr<Paint> clipper) noexcept
|
||||||
|
|
||||||
Result Paint::composite(std::unique_ptr<Paint> target, CompositeMethod method) noexcept
|
Result Paint::composite(std::unique_ptr<Paint> target, CompositeMethod method) noexcept
|
||||||
{
|
{
|
||||||
//TODO: remove. Keep this for the backward compatibility
|
|
||||||
if (target && method == CompositeMethod::ClipPath) return clip(std::move(target));
|
|
||||||
|
|
||||||
auto p = target.release();
|
auto p = target.release();
|
||||||
if (pImpl->composite(this, p, method)) return Result::Success;
|
if (pImpl->composite(this, p, method)) return Result::Success;
|
||||||
|
|
||||||
|
@ -474,11 +471,6 @@ CompositeMethod Paint::composite(const Paint** target) const noexcept
|
||||||
if (target) *target = pImpl->compData->target;
|
if (target) *target = pImpl->compData->target;
|
||||||
return pImpl->compData->method;
|
return pImpl->compData->method;
|
||||||
} else {
|
} else {
|
||||||
//TODO: remove. Keep this for the backward compatibility
|
|
||||||
if (pImpl->clipper) {
|
|
||||||
if (target) *target = pImpl->clipper;
|
|
||||||
return CompositeMethod::ClipPath;
|
|
||||||
}
|
|
||||||
if (target) *target = nullptr;
|
if (target) *target = nullptr;
|
||||||
return CompositeMethod::None;
|
return CompositeMethod::None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,10 +63,8 @@ bool Picture::Impl::needComposition(uint8_t opacity)
|
||||||
|
|
||||||
//Composition test
|
//Composition test
|
||||||
const Paint* target;
|
const Paint* target;
|
||||||
auto method = picture->composite(&target);
|
picture->composite(&target);
|
||||||
if (!target || method == tvg::CompositeMethod::ClipPath) return false;
|
if (!target || target->pImpl->opacity == 255 || target->pImpl->opacity == 0) return false;
|
||||||
if (target->pImpl->opacity == 255 || target->pImpl->opacity == 0) return false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,11 +89,8 @@ struct Scene::Impl
|
||||||
//post effects requires composition
|
//post effects requires composition
|
||||||
if (effects) return true;
|
if (effects) return true;
|
||||||
|
|
||||||
//Masking may require composition (even if opacity == 255)
|
//Masking / Blending may require composition (even if opacity == 255)
|
||||||
auto compMethod = scene->composite(nullptr);
|
if (scene->composite(nullptr) != CompositeMethod::None) return true;
|
||||||
if (compMethod != CompositeMethod::None && compMethod != CompositeMethod::ClipPath) return true;
|
|
||||||
|
|
||||||
//Blending may require composition (even if opacity == 255)
|
|
||||||
if (PP(scene)->blendMethod != BlendMethod::Normal) return true;
|
if (PP(scene)->blendMethod != BlendMethod::Normal) return true;
|
||||||
|
|
||||||
//Half translucent requires intermediate composition.
|
//Half translucent requires intermediate composition.
|
||||||
|
|
|
@ -81,18 +81,17 @@ struct Shape::Impl
|
||||||
//Composition test
|
//Composition test
|
||||||
const Paint* target;
|
const Paint* target;
|
||||||
auto method = shape->composite(&target);
|
auto method = shape->composite(&target);
|
||||||
if (!target || method == CompositeMethod::ClipPath) return false;
|
if (!target) return false;
|
||||||
if (target->pImpl->opacity == 255 || target->pImpl->opacity == 0) {
|
|
||||||
if (target->type() == Type::Shape) {
|
if ((target->pImpl->opacity == 255 || target->pImpl->opacity == 0) && target->type() == Type::Shape) {
|
||||||
auto shape = static_cast<const Shape*>(target);
|
auto shape = static_cast<const Shape*>(target);
|
||||||
if (!shape->fill()) {
|
if (!shape->fill()) {
|
||||||
uint8_t r, g, b, a;
|
uint8_t r, g, b, a;
|
||||||
shape->fillColor(&r, &g, &b, &a);
|
shape->fillColor(&r, &g, &b, &a);
|
||||||
if (a == 0 || a == 255) {
|
if (a == 0 || a == 255) {
|
||||||
if (method == CompositeMethod::LumaMask || method == CompositeMethod::InvLumaMask) {
|
if (method == CompositeMethod::LumaMask || method == CompositeMethod::InvLumaMask) {
|
||||||
if ((r == 255 && g == 255 && b == 255) || (r == 0 && g == 0 && b == 0)) return false;
|
if ((r == 255 && g == 255 && b == 255) || (r == 0 && g == 0 && b == 0)) return false;
|
||||||
} else return false;
|
} else return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,11 +343,9 @@ void WgPipelines::initialize(WgContext& context)
|
||||||
WGPUCompareFunction_Always, WGPUStencilOperation_Zero,
|
WGPUCompareFunction_Always, WGPUStencilOperation_Zero,
|
||||||
primitiveState, multisampleState, blendStateNrm);
|
primitiveState, multisampleState, blendStateNrm);
|
||||||
|
|
||||||
// TODO: remove fs_main_ClipPath shader from list after removing CompositeMethod::ClipPath value
|
|
||||||
// compose shader names
|
// compose shader names
|
||||||
const char* shaderComposeNames[] {
|
const char* shaderComposeNames[] {
|
||||||
"fs_main_None",
|
"fs_main_None",
|
||||||
"fs_main_ClipPath", // TODO: remove after CompositeMethod updated
|
|
||||||
"fs_main_AlphaMask",
|
"fs_main_AlphaMask",
|
||||||
"fs_main_InvAlphaMask",
|
"fs_main_InvAlphaMask",
|
||||||
"fs_main_LumaMask",
|
"fs_main_LumaMask",
|
||||||
|
@ -360,11 +358,9 @@ void WgPipelines::initialize(WgContext& context)
|
||||||
"fs_main_DarkenMask"
|
"fs_main_DarkenMask"
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: remove fs_main_ClipPath shader from list after removing CompositeMethod::ClipPath value
|
|
||||||
// compose shader blend states
|
// compose shader blend states
|
||||||
const WGPUBlendState composeBlends[] {
|
const WGPUBlendState composeBlends[] {
|
||||||
blendStateNrm, // None
|
blendStateNrm, // None
|
||||||
blendStateNrm, // ClipPath // TODO: remove after CompositeMethod updated
|
|
||||||
blendStateNrm, // AlphaMask
|
blendStateNrm, // AlphaMask
|
||||||
blendStateNrm, // InvAlphaMask
|
blendStateNrm, // InvAlphaMask
|
||||||
blendStateNrm, // LumaMask
|
blendStateNrm, // LumaMask
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
WGPURenderPipeline linear[2]{};
|
WGPURenderPipeline linear[2]{};
|
||||||
WGPURenderPipeline image[2]{};
|
WGPURenderPipeline image[2]{};
|
||||||
WGPURenderPipeline sceneClip;
|
WGPURenderPipeline sceneClip;
|
||||||
WGPURenderPipeline sceneComp[12]; // TODO: update to 11 after removing CompositeMethod::ClipPath enum value
|
WGPURenderPipeline sceneComp[11];
|
||||||
WGPURenderPipeline sceneBlend;
|
WGPURenderPipeline sceneBlend;
|
||||||
WGPURenderPipeline blit{};
|
WGPURenderPipeline blit{};
|
||||||
WGPURenderPipeline clipPath{};
|
WGPURenderPipeline clipPath{};
|
||||||
|
|
Loading…
Add table
Reference in a new issue