restorable: Refactoring: Do not have to update basePixels in some cases

If there is no draw-traiangles command, the image can keep its
basePixels.
This commit is contained in:
Hajime Hoshi 2019-07-16 02:48:49 +09:00
parent 6d20e3f951
commit 8ae2fef817

View File

@ -563,14 +563,16 @@ func (i *Image) restore() error {
} }
gimg.DrawTriangles(c.image.image, c.vertices, c.indices, c.colorm, c.mode, c.filter, c.address) gimg.DrawTriangles(c.image.image, c.vertices, c.indices, c.colorm, c.mode, c.filter, c.address)
} }
i.image = gimg
// TODO: Can we avoid getting pixels here? (#897) if len(i.drawTrianglesHistory) > 0 {
pix := gimg.Pixels() pix := gimg.Pixels()
i.basePixels = &Pixels{ i.basePixels = &Pixels{
pixels: pix, pixels: pix,
length: len(pix), length: len(pix),
} }
}
i.image = gimg
i.drawTrianglesHistory = nil i.drawTrianglesHistory = nil
i.stale = false i.stale = false
return nil return nil