mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
internal/restorable: Remove draw-triangles-history items explicitly
Updates #1803
This commit is contained in:
parent
106ff7a84b
commit
dbe101a8ef
@ -203,7 +203,7 @@ func (i *Image) Extend(width, height int) *Image {
|
||||
|
||||
// Overwrite the history as if the image newImg is created only by ReplacePixels. Now drawTrianglesHistory
|
||||
// and basePixels cannot be mixed.
|
||||
newImg.drawTrianglesHistory = newImg.drawTrianglesHistory[:0]
|
||||
newImg.clearDrawTrianglesHistory()
|
||||
newImg.basePixels = i.basePixels
|
||||
newImg.stale = i.stale
|
||||
|
||||
@ -273,7 +273,7 @@ func (i *Image) BasePixelsForTesting() *Pixels {
|
||||
// makeStale makes the image stale.
|
||||
func (i *Image) makeStale() {
|
||||
i.basePixels = Pixels{}
|
||||
i.drawTrianglesHistory = i.drawTrianglesHistory[:0]
|
||||
i.clearDrawTrianglesHistory()
|
||||
i.stale = true
|
||||
|
||||
// Don't have to call makeStale recursively here.
|
||||
@ -327,7 +327,7 @@ func (i *Image) ReplacePixels(pixels []byte, x, y, width, height int) {
|
||||
} else {
|
||||
i.basePixels.Remove(0, 0, w, h)
|
||||
}
|
||||
i.drawTrianglesHistory = i.drawTrianglesHistory[:0]
|
||||
i.clearDrawTrianglesHistory()
|
||||
i.stale = false
|
||||
return
|
||||
}
|
||||
@ -503,7 +503,7 @@ func (i *Image) readPixelsFromGPU() error {
|
||||
}
|
||||
i.basePixels = Pixels{}
|
||||
i.basePixels.AddOrReplace(pix, 0, 0, i.width, i.height)
|
||||
i.drawTrianglesHistory = i.drawTrianglesHistory[:0]
|
||||
i.clearDrawTrianglesHistory()
|
||||
i.stale = false
|
||||
return nil
|
||||
}
|
||||
@ -583,7 +583,7 @@ func (i *Image) restore() error {
|
||||
// be changed.
|
||||
i.image = graphicscommand.NewScreenFramebufferImage(w, h)
|
||||
i.basePixels = Pixels{}
|
||||
i.drawTrianglesHistory = i.drawTrianglesHistory[:0]
|
||||
i.clearDrawTrianglesHistory()
|
||||
i.stale = false
|
||||
return nil
|
||||
}
|
||||
@ -634,7 +634,7 @@ func (i *Image) restore() error {
|
||||
}
|
||||
|
||||
i.image = gimg
|
||||
i.drawTrianglesHistory = i.drawTrianglesHistory[:0]
|
||||
i.clearDrawTrianglesHistory()
|
||||
i.stale = false
|
||||
return nil
|
||||
}
|
||||
@ -647,7 +647,7 @@ func (i *Image) Dispose() {
|
||||
i.image.Dispose()
|
||||
i.image = nil
|
||||
i.basePixels = Pixels{}
|
||||
i.drawTrianglesHistory = i.drawTrianglesHistory[:0]
|
||||
i.clearDrawTrianglesHistory()
|
||||
i.stale = false
|
||||
}
|
||||
|
||||
@ -665,3 +665,11 @@ func (i *Image) isInvalidated() (bool, error) {
|
||||
func (i *Image) Dump(path string, blackbg bool, rect image.Rectangle) error {
|
||||
return i.image.Dump(path, blackbg, rect)
|
||||
}
|
||||
|
||||
func (i *Image) clearDrawTrianglesHistory() {
|
||||
// Clear the items explicitly, or the references might remain (#1803).
|
||||
for idx := range i.drawTrianglesHistory {
|
||||
i.drawTrianglesHistory[idx] = nil
|
||||
}
|
||||
i.drawTrianglesHistory = i.drawTrianglesHistory[:0]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user