feat: add render context blend mode

This commit is contained in:
Nomango 2023-09-24 16:22:01 +08:00
parent be23fedc84
commit 494a4d05f9
3 changed files with 23 additions and 0 deletions

View File

@ -429,6 +429,12 @@ void RenderContextImpl::SetTransform(const Matrix3x2& matrix)
}
}
void RenderContextImpl::SetBlendMode(BlendMode blend)
{
KGE_ASSERT(render_ctx_ && "Render target has not been initialized!");
render_ctx_->SetPrimitiveBlend(D2D1_PRIMITIVE_BLEND(blend));
}
void RenderContextImpl::SetAntialiasMode(bool enabled)
{
KGE_ASSERT(render_ctx_ && "Render target has not been initialized!");

View File

@ -87,6 +87,8 @@ public:
void SetTransform(const Matrix3x2& matrix) override;
void SetBlendMode(BlendMode blend) override;
void SetAntialiasMode(bool enabled) override;
void SetTextAntialiasMode(TextAntialiasMode mode) override;

View File

@ -46,6 +46,17 @@ enum class TextAntialiasMode
None ///< 不启用抗锯齿
};
/// \~chinese
/// @brief »ìºÏģʽ
enum class BlendMode
{
SourceOver = 0,
Copy = 1,
Min = 2,
Add = 3,
Max = 4,
};
/// \~chinese
/// @brief 渲染上下文
/// @details 渲染上下文将完成基础图元的绘制,并将绘制结果输出到特定的平面中
@ -204,6 +215,10 @@ public:
/// @brief 设置当前使用的线条样式
virtual void SetCurrentStrokeStyle(StrokeStylePtr stroke);
/// \~chinese
/// @brief ÉèÖûìºÏģʽ
virtual void SetBlendMode(BlendMode blend) = 0;
/// \~chinese
/// @brief 设置抗锯齿模式
virtual void SetAntialiasMode(bool enabled) = 0;