mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 03:02:49 +01:00
restorable: Refactoring
This commit is contained in:
parent
701c4eeb7c
commit
7e4e9cc893
@ -180,7 +180,7 @@ func NewScreenFramebufferImage(width, height int) *Image {
|
|||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) Fill(r, g, b, a uint8) {
|
func (i *Image) Fill(r, g, b, a byte) {
|
||||||
theImages.makeStaleIfDependingOn(i)
|
theImages.makeStaleIfDependingOn(i)
|
||||||
i.fill(r, g, b, a)
|
i.fill(r, g, b, a)
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ func (i *Image) clearForInitialization() {
|
|||||||
i.fill(0, 0, 0, 0)
|
i.fill(0, 0, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) fill(r, g, b, a uint8) {
|
func (i *Image) fill(r, g, b, a byte) {
|
||||||
if i.priority {
|
if i.priority {
|
||||||
panic("restorable: clear cannot be called on a priority image")
|
panic("restorable: clear cannot be called on a priority image")
|
||||||
}
|
}
|
||||||
@ -533,7 +533,7 @@ func (i *Image) restore() error {
|
|||||||
gimg.ReplacePixels(i.basePixels.Slice(), 0, 0, w, h)
|
gimg.ReplacePixels(i.basePixels.Slice(), 0, 0, w, h)
|
||||||
} else {
|
} else {
|
||||||
// Clear the image explicitly.
|
// Clear the image explicitly.
|
||||||
pix := make([]uint8, w*h*4)
|
pix := make([]byte, w*h*4)
|
||||||
gimg.ReplacePixels(pix, 0, 0, w, h)
|
gimg.ReplacePixels(pix, 0, 0, w, h)
|
||||||
}
|
}
|
||||||
for _, c := range i.drawTrianglesHistory {
|
for _, c := range i.drawTrianglesHistory {
|
||||||
|
@ -90,6 +90,9 @@ func RestoreIfNeeded() error {
|
|||||||
return theImages.restore()
|
return theImages.restore()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Images returns all the current images.
|
||||||
|
//
|
||||||
|
// This is for testing usage.
|
||||||
func Images() []image.Image {
|
func Images() []image.Image {
|
||||||
var imgs []image.Image
|
var imgs []image.Image
|
||||||
for img := range theImages.images {
|
for img := range theImages.images {
|
||||||
|
Loading…
Reference in New Issue
Block a user