mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
internal/affine: Use a pointer of an array for UnsafeElements
This commit is contained in:
parent
2c26e85183
commit
7e5b259dd2
@ -173,15 +173,15 @@ func (c *colorMImplBodyTranslate) Apply(clr color.Color) color.Color {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ColorM) UnsafeElements() ([]float32, []float32) {
|
||||
func (c *ColorM) UnsafeElements() (*[16]float32, *[4]float32) {
|
||||
if c.isIdentity() {
|
||||
return colorMIdentityBody[:], colorMIdentityTranslate[:]
|
||||
return &colorMIdentityBody, &colorMIdentityTranslate
|
||||
}
|
||||
return c.impl.UnsafeElements()
|
||||
}
|
||||
|
||||
func (c *colorMImplBodyTranslate) UnsafeElements() ([]float32, []float32) {
|
||||
return c.body[:], c.translate[:]
|
||||
func (c *colorMImplBodyTranslate) UnsafeElements() (*[16]float32, *[4]float32) {
|
||||
return &c.body, &c.translate
|
||||
}
|
||||
|
||||
func (c *ColorM) det() float32 {
|
||||
|
@ -917,8 +917,8 @@ func (g *Graphics) DrawTriangles(dstID driver.ImageID, srcIDs [graphics.ShaderIm
|
||||
uniformVars = []interface{}{
|
||||
[]float32{float32(w), float32(h)},
|
||||
sourceSize,
|
||||
esBody,
|
||||
esTranslate,
|
||||
esBody[:],
|
||||
esTranslate[:],
|
||||
scale,
|
||||
[]float32{
|
||||
srcRegion.X,
|
||||
|
@ -192,11 +192,11 @@ func (g *Graphics) DrawTriangles(dstID driver.ImageID, srcIDs [graphics.ShaderIm
|
||||
esBody, esTranslate := colorM.UnsafeElements()
|
||||
uniformVars = append(uniformVars, uniformVariable{
|
||||
name: "color_matrix_body",
|
||||
value: esBody,
|
||||
value: esBody[:],
|
||||
typ: shaderir.Type{Main: shaderir.Mat4},
|
||||
}, uniformVariable{
|
||||
name: "color_matrix_translation",
|
||||
value: esTranslate,
|
||||
value: esTranslate[:],
|
||||
typ: shaderir.Type{Main: shaderir.Vec4},
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user