mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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()
|
||||
vs := vertices(parts, w, h, &options.GeoM)
|
||||
vs := vertices(parts, w, h, &options.GeoM.impl)
|
||||
if len(vs) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
@ -18,20 +18,23 @@ package ebiten
|
||||
|
||||
import (
|
||||
"github.com/gopherjs/gopherjs/js"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||
"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?
|
||||
totalSize := graphics.QuadVertexSizeInBytes() / 4
|
||||
l := parts.Len()
|
||||
vs := js.Global.Get("Float32Array").New(l * totalSize)
|
||||
g0 := geo.Element(0, 0)
|
||||
g1 := geo.Element(0, 1)
|
||||
g2 := geo.Element(1, 0)
|
||||
g3 := geo.Element(1, 1)
|
||||
g4 := geo.Element(0, 2)
|
||||
g5 := geo.Element(1, 2)
|
||||
g := geo.Elements()
|
||||
g0 := g[0]
|
||||
g1 := g[1]
|
||||
g2 := g[3]
|
||||
g3 := g[4]
|
||||
g4 := g[2]
|
||||
g5 := g[5]
|
||||
w := 1.0
|
||||
h := 1.0
|
||||
for w < float64(width) {
|
||||
|
@ -17,20 +17,22 @@
|
||||
package ebiten
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||
"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?
|
||||
totalSize := graphics.QuadVertexSizeInBytes() / 4
|
||||
l := parts.Len()
|
||||
vs := make([]float32, l*totalSize)
|
||||
g0 := float32(geo.Element(0, 0))
|
||||
g1 := float32(geo.Element(0, 1))
|
||||
g2 := float32(geo.Element(1, 0))
|
||||
g3 := float32(geo.Element(1, 1))
|
||||
g4 := float32(geo.Element(0, 2))
|
||||
g5 := float32(geo.Element(1, 2))
|
||||
g := geo.Elements()
|
||||
g0 := float32(g[0])
|
||||
g1 := float32(g[1])
|
||||
g2 := float32(g[3])
|
||||
g3 := float32(g[4])
|
||||
g4 := float32(g[2])
|
||||
g5 := float32(g[5])
|
||||
w := float32(1)
|
||||
h := float32(1)
|
||||
for w < float32(width) {
|
||||
|
Loading…
Reference in New Issue
Block a user