mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
graphics: Skip clearing if possible
This commit is contained in:
parent
aa96822ce5
commit
b2ed6ef027
@ -112,6 +112,9 @@ func (i *imageImpl) Fill(clr color.Color) error {
|
|||||||
if i.disposed {
|
if i.disposed {
|
||||||
return errors.New("ebiten: image is already disposed")
|
return errors.New("ebiten: image is already disposed")
|
||||||
}
|
}
|
||||||
|
if clr == color.Transparent && i.pixels.isCleared() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
i.pixels.fill(clr)
|
i.pixels.fill(clr)
|
||||||
return i.image.Fill(clr)
|
return i.image.Fill(clr)
|
||||||
}
|
}
|
||||||
@ -125,6 +128,9 @@ func (i *imageImpl) clearIfVolatile() error {
|
|||||||
if !i.volatile {
|
if !i.volatile {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if i.pixels.isCleared() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
i.pixels.clear()
|
i.pixels.clear()
|
||||||
return i.image.Fill(color.Transparent)
|
return i.image.Fill(color.Transparent)
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,10 @@ func (p *pixels) clear() {
|
|||||||
p.drawImageHistory = nil
|
p.drawImageHistory = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *pixels) isCleared() bool {
|
||||||
|
return p.basePixels == nil && p.baseColor == nil && p.drawImageHistory == nil
|
||||||
|
}
|
||||||
|
|
||||||
func (p *pixels) fill(clr color.Color) {
|
func (p *pixels) fill(clr color.Color) {
|
||||||
p.basePixels = nil
|
p.basePixels = nil
|
||||||
p.baseColor = clr
|
p.baseColor = clr
|
||||||
|
Loading…
Reference in New Issue
Block a user