ebiten: add a faster way for common blends

Updates #2601
This commit is contained in:
Hajime Hoshi 2023-08-20 16:19:04 +09:00
parent c00795416a
commit bcc2ead670

View File

@ -59,7 +59,22 @@ type Blend struct {
BlendOperationAlpha BlendOperation BlendOperationAlpha BlendOperation
} }
var (
defaultBlendInternalBlend = graphicsdriver.Blend{
BlendFactorSourceRGB: BlendFactorDefault.internalBlendFactor(true),
BlendFactorSourceAlpha: BlendFactorDefault.internalBlendFactor(true),
BlendFactorDestinationRGB: BlendFactorDefault.internalBlendFactor(false),
BlendFactorDestinationAlpha: BlendFactorDefault.internalBlendFactor(false),
BlendOperationRGB: BlendOperationAdd.internalBlendOperation(),
BlendOperationAlpha: BlendOperationAdd.internalBlendOperation(),
}
)
func (b Blend) internalBlend() graphicsdriver.Blend { func (b Blend) internalBlend() graphicsdriver.Blend {
// A shortcut for the most common blend.
if b == (Blend{}) {
return defaultBlendInternalBlend
}
return graphicsdriver.Blend{ return graphicsdriver.Blend{
BlendFactorSourceRGB: b.BlendFactorSourceRGB.internalBlendFactor(true), BlendFactorSourceRGB: b.BlendFactorSourceRGB.internalBlendFactor(true),
BlendFactorSourceAlpha: b.BlendFactorSourceAlpha.internalBlendFactor(true), BlendFactorSourceAlpha: b.BlendFactorSourceAlpha.internalBlendFactor(true),