mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-23 08:20:10 +01:00
graphics: Improve speed when getting elements from geo matrices
This commit is contained in:
parent
71a4465c6f
commit
eec59d5cf8
@ -152,7 +152,7 @@ func (i *imageImpl) DrawImage(image *Image, options *DrawImageOptions) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
w, h := image.impl.restorable.Size()
|
w, h := image.impl.restorable.Size()
|
||||||
vs := vertices(parts, w, h, &options.GeoM)
|
vs := vertices(parts, w, h, &options.GeoM.impl)
|
||||||
if len(vs) == 0 {
|
if len(vs) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -18,20 +18,23 @@ package ebiten
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gopherjs/gopherjs/js"
|
"github.com/gopherjs/gopherjs/js"
|
||||||
|
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||||
)
|
)
|
||||||
|
|
||||||
func vertices(parts ImageParts, width, height int, geo *GeoM) []float32 {
|
func vertices(parts ImageParts, width, height int, geo *affine.GeoM) []float32 {
|
||||||
// TODO: This function should be in graphics package?
|
// TODO: This function should be in graphics package?
|
||||||
totalSize := graphics.QuadVertexSizeInBytes() / 4
|
totalSize := graphics.QuadVertexSizeInBytes() / 4
|
||||||
l := parts.Len()
|
l := parts.Len()
|
||||||
vs := js.Global.Get("Float32Array").New(l * totalSize)
|
vs := js.Global.Get("Float32Array").New(l * totalSize)
|
||||||
g0 := geo.Element(0, 0)
|
g := geo.Elements()
|
||||||
g1 := geo.Element(0, 1)
|
g0 := g[0]
|
||||||
g2 := geo.Element(1, 0)
|
g1 := g[1]
|
||||||
g3 := geo.Element(1, 1)
|
g2 := g[3]
|
||||||
g4 := geo.Element(0, 2)
|
g3 := g[4]
|
||||||
g5 := geo.Element(1, 2)
|
g4 := g[2]
|
||||||
|
g5 := g[5]
|
||||||
w := 1.0
|
w := 1.0
|
||||||
h := 1.0
|
h := 1.0
|
||||||
for w < float64(width) {
|
for w < float64(width) {
|
||||||
|
@ -17,20 +17,22 @@
|
|||||||
package ebiten
|
package ebiten
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||||
)
|
)
|
||||||
|
|
||||||
func vertices(parts ImageParts, width, height int, geo *GeoM) []float32 {
|
func vertices(parts ImageParts, width, height int, geo *affine.GeoM) []float32 {
|
||||||
// TODO: This function should be in graphics package?
|
// TODO: This function should be in graphics package?
|
||||||
totalSize := graphics.QuadVertexSizeInBytes() / 4
|
totalSize := graphics.QuadVertexSizeInBytes() / 4
|
||||||
l := parts.Len()
|
l := parts.Len()
|
||||||
vs := make([]float32, l*totalSize)
|
vs := make([]float32, l*totalSize)
|
||||||
g0 := float32(geo.Element(0, 0))
|
g := geo.Elements()
|
||||||
g1 := float32(geo.Element(0, 1))
|
g0 := float32(g[0])
|
||||||
g2 := float32(geo.Element(1, 0))
|
g1 := float32(g[1])
|
||||||
g3 := float32(geo.Element(1, 1))
|
g2 := float32(g[3])
|
||||||
g4 := float32(geo.Element(0, 2))
|
g3 := float32(g[4])
|
||||||
g5 := float32(geo.Element(1, 2))
|
g4 := float32(g[2])
|
||||||
|
g5 := float32(g[5])
|
||||||
w := float32(1)
|
w := float32(1)
|
||||||
h := float32(1)
|
h := float32(1)
|
||||||
for w < float32(width) {
|
for w < float32(width) {
|
||||||
|
Loading…
Reference in New Issue
Block a user