mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
shareable: Call (*restorable.Image).Clear() when possible
This is a kind of relanding of c68c36b0b7
.
Clearing the restorable.Image state can reduce the operations for
restoring.
This commit is contained in:
parent
5990da4844
commit
40f728a326
@ -103,6 +103,11 @@ func NewScreenFramebufferImage(width, height int) *Image {
|
||||
return i
|
||||
}
|
||||
|
||||
func (i *Image) Clear() {
|
||||
theImages.makeStaleIfDependingOn(i)
|
||||
i.clear()
|
||||
}
|
||||
|
||||
func (i *Image) clear() {
|
||||
if i.priority {
|
||||
panic("restorable: clear cannot be called on a priority image")
|
||||
|
@ -278,6 +278,11 @@ func (i *Image) Fill(r, g, b, a uint8) {
|
||||
i.ensureNotShared()
|
||||
backendsM.Unlock()
|
||||
|
||||
if r == 0 && g == 0 && b == 0 && a == 0 {
|
||||
i.backend.restorable.Clear()
|
||||
return
|
||||
}
|
||||
|
||||
rf := float32(0)
|
||||
gf := float32(0)
|
||||
bf := float32(0)
|
||||
|
Loading…
Reference in New Issue
Block a user