2018-10-28 12:42:57 +01:00
|
|
|
// Copyright 2018 The Ebiten Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2022-02-06 12:41:32 +01:00
|
|
|
package graphicsdriver
|
2018-10-28 12:42:57 +01:00
|
|
|
|
2019-02-07 09:19:24 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2018-10-28 12:42:57 +01:00
|
|
|
type CompositeMode int
|
|
|
|
|
|
|
|
const (
|
2019-07-19 16:18:07 +02:00
|
|
|
CompositeModeUnknown CompositeMode = iota - 1
|
|
|
|
CompositeModeSourceOver // This value must be 0 (= initial value)
|
2018-10-28 12:42:57 +01:00
|
|
|
CompositeModeClear
|
|
|
|
CompositeModeCopy
|
|
|
|
CompositeModeDestination
|
|
|
|
CompositeModeDestinationOver
|
|
|
|
CompositeModeSourceIn
|
|
|
|
CompositeModeDestinationIn
|
|
|
|
CompositeModeSourceOut
|
|
|
|
CompositeModeDestinationOut
|
|
|
|
CompositeModeSourceAtop
|
|
|
|
CompositeModeDestinationAtop
|
|
|
|
CompositeModeXor
|
|
|
|
CompositeModeLighter
|
2020-07-18 14:37:17 +02:00
|
|
|
CompositeModeMultiply
|
2018-11-12 16:00:10 +01:00
|
|
|
|
2020-07-18 14:37:17 +02:00
|
|
|
CompositeModeMax = CompositeModeMultiply
|
2018-10-28 12:42:57 +01:00
|
|
|
)
|
|
|
|
|
2022-10-15 10:27:29 +02:00
|
|
|
type BlendFactor int
|
2018-10-28 12:42:57 +01:00
|
|
|
|
|
|
|
const (
|
2022-10-15 10:27:29 +02:00
|
|
|
BlendFactorZero BlendFactor = iota
|
|
|
|
BlendFactorOne
|
2022-10-15 14:14:59 +02:00
|
|
|
BlendFactorSourceAlpha
|
|
|
|
BlendFactorDestinationAlpha
|
|
|
|
BlendFactorOneMinusSourceAlpha
|
|
|
|
BlendFactorOneMinusDestinationAlpha
|
|
|
|
BlendFactorDestinationColor
|
2018-10-28 12:42:57 +01:00
|
|
|
)
|
|
|
|
|
2022-10-15 10:27:29 +02:00
|
|
|
func (c CompositeMode) BlendFactors() (src BlendFactor, dst BlendFactor) {
|
2018-10-28 12:42:57 +01:00
|
|
|
switch c {
|
|
|
|
case CompositeModeSourceOver:
|
2022-10-15 14:14:59 +02:00
|
|
|
return BlendFactorOne, BlendFactorOneMinusSourceAlpha
|
2018-10-28 12:42:57 +01:00
|
|
|
case CompositeModeClear:
|
2022-10-15 10:27:29 +02:00
|
|
|
return BlendFactorZero, BlendFactorZero
|
2018-10-28 12:42:57 +01:00
|
|
|
case CompositeModeCopy:
|
2022-10-15 10:27:29 +02:00
|
|
|
return BlendFactorOne, BlendFactorZero
|
2018-10-28 12:42:57 +01:00
|
|
|
case CompositeModeDestination:
|
2022-10-15 10:27:29 +02:00
|
|
|
return BlendFactorZero, BlendFactorOne
|
2018-10-28 12:42:57 +01:00
|
|
|
case CompositeModeDestinationOver:
|
2022-10-15 14:14:59 +02:00
|
|
|
return BlendFactorOneMinusDestinationAlpha, BlendFactorOne
|
2018-10-28 12:42:57 +01:00
|
|
|
case CompositeModeSourceIn:
|
2022-10-15 14:14:59 +02:00
|
|
|
return BlendFactorDestinationAlpha, BlendFactorZero
|
2018-10-28 12:42:57 +01:00
|
|
|
case CompositeModeDestinationIn:
|
2022-10-15 14:14:59 +02:00
|
|
|
return BlendFactorZero, BlendFactorSourceAlpha
|
2018-10-28 12:42:57 +01:00
|
|
|
case CompositeModeSourceOut:
|
2022-10-15 14:14:59 +02:00
|
|
|
return BlendFactorOneMinusDestinationAlpha, BlendFactorZero
|
2018-10-28 12:42:57 +01:00
|
|
|
case CompositeModeDestinationOut:
|
2022-10-15 14:14:59 +02:00
|
|
|
return BlendFactorZero, BlendFactorOneMinusSourceAlpha
|
2018-10-28 12:42:57 +01:00
|
|
|
case CompositeModeSourceAtop:
|
2022-10-15 14:14:59 +02:00
|
|
|
return BlendFactorDestinationAlpha, BlendFactorOneMinusSourceAlpha
|
2018-10-28 12:42:57 +01:00
|
|
|
case CompositeModeDestinationAtop:
|
2022-10-15 14:14:59 +02:00
|
|
|
return BlendFactorOneMinusDestinationAlpha, BlendFactorSourceAlpha
|
2018-10-28 12:42:57 +01:00
|
|
|
case CompositeModeXor:
|
2022-10-15 14:14:59 +02:00
|
|
|
return BlendFactorOneMinusDestinationAlpha, BlendFactorOneMinusSourceAlpha
|
2018-10-28 12:42:57 +01:00
|
|
|
case CompositeModeLighter:
|
2022-10-15 10:27:29 +02:00
|
|
|
return BlendFactorOne, BlendFactorOne
|
2020-07-18 14:37:17 +02:00
|
|
|
case CompositeModeMultiply:
|
2022-10-15 14:14:59 +02:00
|
|
|
return BlendFactorDestinationColor, BlendFactorZero
|
2018-10-28 12:42:57 +01:00
|
|
|
default:
|
2022-10-15 10:27:29 +02:00
|
|
|
panic(fmt.Sprintf("graphicsdriver: invalid composite mode: %d", c))
|
2018-10-28 12:42:57 +01:00
|
|
|
}
|
|
|
|
}
|