From 8ae2fef8176145e5921fd888de1e466463726567 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 16 Jul 2019 02:48:49 +0900 Subject: [PATCH] restorable: Refactoring: Do not have to update basePixels in some cases If there is no draw-traiangles command, the image can keep its basePixels. --- internal/restorable/image.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/restorable/image.go b/internal/restorable/image.go index 32bd33089..795c19150 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -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) } - i.image = gimg - // TODO: Can we avoid getting pixels here? (#897) - pix := gimg.Pixels() - i.basePixels = &Pixels{ - pixels: pix, - length: len(pix), + if len(i.drawTrianglesHistory) > 0 { + pix := gimg.Pixels() + i.basePixels = &Pixels{ + pixels: pix, + length: len(pix), + } } + + i.image = gimg i.drawTrianglesHistory = nil i.stale = false return nil