internal/affine: Use a pointer of an array for UnsafeElements

This commit is contained in:
Hajime Hoshi 2021-07-26 21:19:53 +09:00
parent 2c26e85183
commit 7e5b259dd2
3 changed files with 8 additions and 8 deletions

View File

@ -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 {

View File

@ -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,

View File

@ -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},
})
}