mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
restorable: Remove graphics.Image.Fill usage
This commit is contained in:
parent
2ba89591db
commit
fe7aae32a0
@ -145,6 +145,15 @@ func (i *Image) makeStale() {
|
||||
i.stale = true
|
||||
}
|
||||
|
||||
var (
|
||||
dummyImage = graphics.NewImage(16, 16)
|
||||
clearColorM = &affine.ColorM{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
clearColorM.Scale(0, 0, 0, 0)
|
||||
}
|
||||
|
||||
// clearIfVolatile clears the image if the image is volatile.
|
||||
func (i *Image) clearIfVolatile() {
|
||||
if !i.volatile {
|
||||
@ -156,7 +165,17 @@ func (i *Image) clearIfVolatile() {
|
||||
if i.image == nil {
|
||||
panic("not reached")
|
||||
}
|
||||
i.image.Fill(0, 0, 0, 0)
|
||||
|
||||
w, h := i.image.Size()
|
||||
wf, hf := float32(w), float32(h)
|
||||
// For the rule of values, see vertices.go.
|
||||
clearVertices := []float32{
|
||||
0, 0, 0, 0, 1, 1,
|
||||
wf, 0, 1, 0, 0, 1,
|
||||
0, hf, 0, 1, 1, 0,
|
||||
wf, hf, 1, 1, 0, 0,
|
||||
}
|
||||
i.image.DrawImage(dummyImage, clearVertices, clearColorM, opengl.CompositeModeCopy, graphics.FilterNearest)
|
||||
}
|
||||
|
||||
// ReplacePixels replaces the image pixels with the given pixels slice.
|
||||
|
@ -102,7 +102,6 @@ func TestRestore(t *testing.T) {
|
||||
}
|
||||
|
||||
func vertices(sw, sh int, x, y int) []float32 {
|
||||
const a, b, c, d = 1, 0, 0, 1
|
||||
swf := float32(sw)
|
||||
shf := float32(sh)
|
||||
tx := float32(x)
|
||||
@ -111,8 +110,8 @@ func vertices(sw, sh int, x, y int) []float32 {
|
||||
// For the rule of values, see vertices.go.
|
||||
return []float32{
|
||||
0 + tx, 0 + ty, 0, 0, 1, 1,
|
||||
0 + tx, shf + ty, 0, 1, 1, 0,
|
||||
swf + tx, 0 + ty, 1, 0, 0, 1,
|
||||
0 + tx, shf + ty, 0, 1, 1, 0,
|
||||
swf + tx, shf + ty, 1, 1, 0, 0,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user