mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
restorable: Add ResetRestoringState to reset the state
After Fill command, the image doesn't have to keep the restoring information. Now Fill command is as same as DrawTriangles, there is no way for restorable.Image to know whether it can reset the state or not. ResetRestoringState clears the state explicitly.
This commit is contained in:
parent
3f6628f1cc
commit
2d079b123f
4
image.go
4
image.go
@ -127,6 +127,10 @@ func (i *Image) Fill(clr color.Color) error {
|
||||
if af < 1.0 {
|
||||
op.CompositeMode = CompositeModeCopy
|
||||
}
|
||||
// As Fill will change all the pixels of the image into the same color, all the information for restoring
|
||||
// will be invalidated.
|
||||
// TODO: This is a little hacky. Is there a better way?
|
||||
i.mipmap.resetRestoringState()
|
||||
i.DrawImage(emptyImage, op)
|
||||
return nil
|
||||
}
|
||||
|
@ -224,7 +224,14 @@ func (i *Image) clear() {
|
||||
}
|
||||
|
||||
clearImage(i.image)
|
||||
i.ResetRestoringState()
|
||||
}
|
||||
|
||||
// ResetRestoringState resets all the information for restoring.
|
||||
// ResetRestoringState doen't affect the underlying image.
|
||||
//
|
||||
// After ResetRestoringState, the image is assumed to be cleared.
|
||||
func (i *Image) ResetRestoringState() {
|
||||
i.basePixels = &Pixels{}
|
||||
i.drawTrianglesHistory = nil
|
||||
i.stale = false
|
||||
|
@ -312,6 +312,15 @@ func (i *Image) ClearFramebuffer() {
|
||||
i.backend.restorable.Clear()
|
||||
}
|
||||
|
||||
func (i *Image) ResetRestoringState() {
|
||||
backendsM.Lock()
|
||||
defer backendsM.Unlock()
|
||||
if i.backend == nil {
|
||||
return
|
||||
}
|
||||
i.backend.restorable.ResetRestoringState()
|
||||
}
|
||||
|
||||
func (i *Image) ReplacePixels(p []byte) {
|
||||
backendsM.Lock()
|
||||
defer backendsM.Unlock()
|
||||
|
@ -112,6 +112,14 @@ func (m *mipmap) disposeMipmaps() {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *mipmap) clearFramebuffer() {
|
||||
m.orig.ClearFramebuffer()
|
||||
}
|
||||
|
||||
func (m *mipmap) resetRestoringState() {
|
||||
m.orig.ResetRestoringState()
|
||||
}
|
||||
|
||||
// mipmapLevel returns an appropriate mipmap level for the given determinant of a geometry matrix.
|
||||
//
|
||||
// mipmapLevel returns -1 if det is 0.
|
||||
|
@ -111,7 +111,7 @@ func (c *uiContext) Update(afterFrameUpdate func()) error {
|
||||
}
|
||||
|
||||
// This clear is needed for fullscreen mode or some mobile platforms (#622).
|
||||
c.screen.mipmap.orig.ClearFramebuffer()
|
||||
c.screen.mipmap.clearFramebuffer()
|
||||
|
||||
op := &DrawImageOptions{}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user