From 2e5e7e6e2447ee6ec1302228ba9801702e655e89 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 10 Jun 2018 20:06:17 +0900 Subject: [PATCH] restorable: Remove merging commands for code simplicity --- internal/restorable/image.go | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/internal/restorable/image.go b/internal/restorable/image.go index 14f9e3375..ead958c66 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -27,30 +27,12 @@ import ( // drawImageHistoryItem is an item for history of draw-image commands. type drawImageHistoryItem struct { image *Image - vertices [][]float32 + vertices []float32 colorm *affine.ColorM mode opengl.CompositeMode filter graphics.Filter } -// canMerge returns a boolean value indicating whether the drawImageHistoryItem d -// can be merged with the given conditions. -func (d *drawImageHistoryItem) canMerge(image *Image, colorm *affine.ColorM, mode opengl.CompositeMode, filter graphics.Filter) bool { - if d.image != image { - return false - } - if !d.colorm.Equals(colorm) { - return false - } - if d.mode != mode { - return false - } - if d.filter != filter { - return false - } - return true -} - // Image represents an image that can be restored when GL context is lost. type Image struct { image *graphics.Image @@ -224,13 +206,6 @@ func (i *Image) appendDrawImageHistory(image *Image, vertices []float32, colorm if i.stale || i.volatile || i.screen { return } - if len(i.drawImageHistory) > 0 { - last := i.drawImageHistory[len(i.drawImageHistory)-1] - if last.canMerge(image, colorm, mode, filter) { - last.vertices = append(last.vertices, vertices) - return - } - } const maxDrawImageHistoryNum = 100 if len(i.drawImageHistory)+1 > maxDrawImageHistoryNum { i.makeStale() @@ -240,7 +215,7 @@ func (i *Image) appendDrawImageHistory(image *Image, vertices []float32, colorm // So we don't have to care if image is stale or not here. item := &drawImageHistoryItem{ image: image, - vertices: [][]float32{vertices}, + vertices: vertices, colorm: colorm, mode: mode, filter: filter, @@ -375,9 +350,7 @@ func (i *Image) restore() error { if c.image.hasDependency() { panic("not reached") } - for _, v := range c.vertices { - gimg.DrawImage(c.image.image, v, quadIndices, c.colorm, c.mode, c.filter) - } + gimg.DrawImage(c.image.image, c.vertices, quadIndices, c.colorm, c.mode, c.filter) } i.image = gimg