internal/graphicsdriver: rename constants

This commit is contained in:
Hajime Hoshi 2022-10-15 21:14:59 +09:00
parent 272d0c6a3f
commit 1d9f1474e9
4 changed files with 30 additions and 30 deletions

View File

@ -45,17 +45,17 @@ type BlendFactor int
const (
BlendFactorZero BlendFactor = iota
BlendFactorOne
BlendFactorSrcAlpha
BlendFactorDstAlpha
BlendFactorOneMinusSrcAlpha
BlendFactorOneMinusDstAlpha
BlendFactorDstColor
BlendFactorSourceAlpha
BlendFactorDestinationAlpha
BlendFactorOneMinusSourceAlpha
BlendFactorOneMinusDestinationAlpha
BlendFactorDestinationColor
)
func (c CompositeMode) BlendFactors() (src BlendFactor, dst BlendFactor) {
switch c {
case CompositeModeSourceOver:
return BlendFactorOne, BlendFactorOneMinusSrcAlpha
return BlendFactorOne, BlendFactorOneMinusSourceAlpha
case CompositeModeClear:
return BlendFactorZero, BlendFactorZero
case CompositeModeCopy:
@ -63,25 +63,25 @@ func (c CompositeMode) BlendFactors() (src BlendFactor, dst BlendFactor) {
case CompositeModeDestination:
return BlendFactorZero, BlendFactorOne
case CompositeModeDestinationOver:
return BlendFactorOneMinusDstAlpha, BlendFactorOne
return BlendFactorOneMinusDestinationAlpha, BlendFactorOne
case CompositeModeSourceIn:
return BlendFactorDstAlpha, BlendFactorZero
return BlendFactorDestinationAlpha, BlendFactorZero
case CompositeModeDestinationIn:
return BlendFactorZero, BlendFactorSrcAlpha
return BlendFactorZero, BlendFactorSourceAlpha
case CompositeModeSourceOut:
return BlendFactorOneMinusDstAlpha, BlendFactorZero
return BlendFactorOneMinusDestinationAlpha, BlendFactorZero
case CompositeModeDestinationOut:
return BlendFactorZero, BlendFactorOneMinusSrcAlpha
return BlendFactorZero, BlendFactorOneMinusSourceAlpha
case CompositeModeSourceAtop:
return BlendFactorDstAlpha, BlendFactorOneMinusSrcAlpha
return BlendFactorDestinationAlpha, BlendFactorOneMinusSourceAlpha
case CompositeModeDestinationAtop:
return BlendFactorOneMinusDstAlpha, BlendFactorSrcAlpha
return BlendFactorOneMinusDestinationAlpha, BlendFactorSourceAlpha
case CompositeModeXor:
return BlendFactorOneMinusDstAlpha, BlendFactorOneMinusSrcAlpha
return BlendFactorOneMinusDestinationAlpha, BlendFactorOneMinusSourceAlpha
case CompositeModeLighter:
return BlendFactorOne, BlendFactorOne
case CompositeModeMultiply:
return BlendFactorDstColor, BlendFactorZero
return BlendFactorDestinationColor, BlendFactorZero
default:
panic(fmt.Sprintf("graphicsdriver: invalid composite mode: %d", c))
}

View File

@ -31,15 +31,15 @@ func blendFactorToBlend(c graphicsdriver.BlendFactor, alpha bool) _D3D12_BLEND {
return _D3D12_BLEND_ZERO
case graphicsdriver.BlendFactorOne:
return _D3D12_BLEND_ONE
case graphicsdriver.BlendFactorSrcAlpha:
case graphicsdriver.BlendFactorSourceAlpha:
return _D3D12_BLEND_SRC_ALPHA
case graphicsdriver.BlendFactorDstAlpha:
case graphicsdriver.BlendFactorDestinationAlpha:
return _D3D12_BLEND_DEST_ALPHA
case graphicsdriver.BlendFactorOneMinusSrcAlpha:
case graphicsdriver.BlendFactorOneMinusSourceAlpha:
return _D3D12_BLEND_INV_SRC_ALPHA
case graphicsdriver.BlendFactorOneMinusDstAlpha:
case graphicsdriver.BlendFactorOneMinusDestinationAlpha:
return _D3D12_BLEND_INV_DEST_ALPHA
case graphicsdriver.BlendFactorDstColor:
case graphicsdriver.BlendFactorDestinationColor:
if alpha {
return _D3D12_BLEND_DEST_ALPHA
}

View File

@ -306,15 +306,15 @@ func blendFactorToMetalBlendFactor(c graphicsdriver.BlendFactor) mtl.BlendFactor
return mtl.BlendFactorZero
case graphicsdriver.BlendFactorOne:
return mtl.BlendFactorOne
case graphicsdriver.BlendFactorSrcAlpha:
case graphicsdriver.BlendFactorSourceAlpha:
return mtl.BlendFactorSourceAlpha
case graphicsdriver.BlendFactorDstAlpha:
case graphicsdriver.BlendFactorDestinationAlpha:
return mtl.BlendFactorDestinationAlpha
case graphicsdriver.BlendFactorOneMinusSrcAlpha:
case graphicsdriver.BlendFactorOneMinusSourceAlpha:
return mtl.BlendFactorOneMinusSourceAlpha
case graphicsdriver.BlendFactorOneMinusDstAlpha:
case graphicsdriver.BlendFactorOneMinusDestinationAlpha:
return mtl.BlendFactorOneMinusDestinationAlpha
case graphicsdriver.BlendFactorDstColor:
case graphicsdriver.BlendFactorDestinationColor:
return mtl.BlendFactorDestinationColor
default:
panic(fmt.Sprintf("metal: invalid operation: %d", c))

View File

@ -29,15 +29,15 @@ func convertBlendFactor(op graphicsdriver.BlendFactor) blendFactor {
return zero
case graphicsdriver.BlendFactorOne:
return one
case graphicsdriver.BlendFactorSrcAlpha:
case graphicsdriver.BlendFactorSourceAlpha:
return srcAlpha
case graphicsdriver.BlendFactorDstAlpha:
case graphicsdriver.BlendFactorDestinationAlpha:
return dstAlpha
case graphicsdriver.BlendFactorOneMinusSrcAlpha:
case graphicsdriver.BlendFactorOneMinusSourceAlpha:
return oneMinusSrcAlpha
case graphicsdriver.BlendFactorOneMinusDstAlpha:
case graphicsdriver.BlendFactorOneMinusDestinationAlpha:
return oneMinusDstAlpha
case graphicsdriver.BlendFactorDstColor:
case graphicsdriver.BlendFactorDestinationColor:
return dstColor
default:
panic(fmt.Sprintf("opengl: invalid blend factor %d at convertBlendFactor", op))