mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-03 14:34:26 +01:00
restorable: Don't flatten vertices until actually needed
This commit is contained in:
parent
de3a8d8893
commit
b5d065151a
@ -28,7 +28,7 @@ import (
|
|||||||
// drawImageHistoryItem is an item for history of draw-image commands.
|
// drawImageHistoryItem is an item for history of draw-image commands.
|
||||||
type drawImageHistoryItem struct {
|
type drawImageHistoryItem struct {
|
||||||
image *Image
|
image *Image
|
||||||
vertices []float32
|
vertices [][]float32
|
||||||
colorm *affine.ColorM
|
colorm *affine.ColorM
|
||||||
mode opengl.CompositeMode
|
mode opengl.CompositeMode
|
||||||
filter graphics.Filter
|
filter graphics.Filter
|
||||||
@ -165,7 +165,7 @@ func (i *Image) appendDrawImageHistory(image *Image, vertices []float32, colorm
|
|||||||
if len(i.drawImageHistory) > 0 {
|
if len(i.drawImageHistory) > 0 {
|
||||||
last := i.drawImageHistory[len(i.drawImageHistory)-1]
|
last := i.drawImageHistory[len(i.drawImageHistory)-1]
|
||||||
if last.canMerge(image, colorm, mode, filter) {
|
if last.canMerge(image, colorm, mode, filter) {
|
||||||
last.vertices = append(last.vertices, vertices...)
|
last.vertices = append(last.vertices, vertices)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ func (i *Image) appendDrawImageHistory(image *Image, vertices []float32, colorm
|
|||||||
// So we don't have to care if image is stale or not here.
|
// So we don't have to care if image is stale or not here.
|
||||||
item := &drawImageHistoryItem{
|
item := &drawImageHistoryItem{
|
||||||
image: image,
|
image: image,
|
||||||
vertices: vertices,
|
vertices: [][]float32{vertices},
|
||||||
colorm: colorm,
|
colorm: colorm,
|
||||||
mode: mode,
|
mode: mode,
|
||||||
filter: filter,
|
filter: filter,
|
||||||
@ -306,7 +306,11 @@ func (i *Image) restore() error {
|
|||||||
if c.image.hasDependency() {
|
if c.image.hasDependency() {
|
||||||
panic("not reached")
|
panic("not reached")
|
||||||
}
|
}
|
||||||
gimg.DrawImage(c.image.image, c.vertices, c.colorm, c.mode, c.filter)
|
vs := []float32{}
|
||||||
|
for _, v := range c.vertices {
|
||||||
|
vs = append(vs, v...)
|
||||||
|
}
|
||||||
|
gimg.DrawImage(c.image.image, vs, c.colorm, c.mode, c.filter)
|
||||||
}
|
}
|
||||||
i.image = gimg
|
i.image = gimg
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user