mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/affine: Rename UnsafeElements -> Elements as this is no longer unsafe
This commit is contained in:
parent
8c9ec8fc9f
commit
58ea710a84
@ -45,7 +45,7 @@ type ColorM interface {
|
|||||||
IsIdentity() bool
|
IsIdentity() bool
|
||||||
ScaleOnly() bool
|
ScaleOnly() bool
|
||||||
At(i, j int) float32
|
At(i, j int) float32
|
||||||
UnsafeElements(body *[16]float32, translate *[4]float32)
|
Elements(body *[16]float32, translate *[4]float32)
|
||||||
Apply(clr color.Color) color.Color
|
Apply(clr color.Color) color.Color
|
||||||
|
|
||||||
// IsInvertible returns a boolean value indicating
|
// IsInvertible returns a boolean value indicating
|
||||||
@ -74,7 +74,7 @@ type ColorM interface {
|
|||||||
func ColorMString(c ColorM) string {
|
func ColorMString(c ColorM) string {
|
||||||
var b [16]float32
|
var b [16]float32
|
||||||
var t [4]float32
|
var t [4]float32
|
||||||
c.UnsafeElements(&b, &t)
|
c.Elements(&b, &t)
|
||||||
return fmt.Sprintf("[[%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f]]",
|
return fmt.Sprintf("[[%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f]]",
|
||||||
b[0], b[4], b[8], b[12], t[0],
|
b[0], b[4], b[8], b[12], t[0],
|
||||||
b[1], b[5], b[9], b[13], t[1],
|
b[1], b[5], b[9], b[13], t[1],
|
||||||
@ -241,7 +241,7 @@ func (c *colorMImplBodyTranslate) Apply(clr color.Color) color.Color {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ColorMIdentity) UnsafeElements(body *[16]float32, translate *[4]float32) {
|
func (c ColorMIdentity) Elements(body *[16]float32, translate *[4]float32) {
|
||||||
body[0] = 1
|
body[0] = 1
|
||||||
body[1] = 0
|
body[1] = 0
|
||||||
body[2] = 0
|
body[2] = 0
|
||||||
@ -264,7 +264,7 @@ func (c ColorMIdentity) UnsafeElements(body *[16]float32, translate *[4]float32)
|
|||||||
translate[3] = 0
|
translate[3] = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c colorMImplScale) UnsafeElements(body *[16]float32, translate *[4]float32) {
|
func (c colorMImplScale) Elements(body *[16]float32, translate *[4]float32) {
|
||||||
body[0] = c.scale[0]
|
body[0] = c.scale[0]
|
||||||
body[1] = 0
|
body[1] = 0
|
||||||
body[2] = 0
|
body[2] = 0
|
||||||
@ -287,7 +287,7 @@ func (c colorMImplScale) UnsafeElements(body *[16]float32, translate *[4]float32
|
|||||||
translate[3] = 0
|
translate[3] = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *colorMImplBodyTranslate) UnsafeElements(body *[16]float32, translate *[4]float32) {
|
func (c *colorMImplBodyTranslate) Elements(body *[16]float32, translate *[4]float32) {
|
||||||
copy(body[:], c.body[:])
|
copy(body[:], c.body[:])
|
||||||
copy(translate[:], c.translate[:])
|
copy(translate[:], c.translate[:])
|
||||||
}
|
}
|
||||||
@ -482,7 +482,7 @@ func ColorMSetElement(c ColorM, i, j int, element float32) ColorM {
|
|||||||
body: colorMIdentityBody,
|
body: colorMIdentityBody,
|
||||||
}
|
}
|
||||||
if !c.IsIdentity() {
|
if !c.IsIdentity() {
|
||||||
c.UnsafeElements(&newImpl.body, &newImpl.translate)
|
c.Elements(&newImpl.body, &newImpl.translate)
|
||||||
}
|
}
|
||||||
if j < (ColorMDim - 1) {
|
if j < (ColorMDim - 1) {
|
||||||
newImpl.body[i+j*(ColorMDim-1)] = element
|
newImpl.body[i+j*(ColorMDim-1)] = element
|
||||||
@ -520,7 +520,7 @@ func (c colorMImplScale) Equals(other ColorM) bool {
|
|||||||
func (c *colorMImplBodyTranslate) Equals(other ColorM) bool {
|
func (c *colorMImplBodyTranslate) Equals(other ColorM) bool {
|
||||||
var lhsb [16]float32
|
var lhsb [16]float32
|
||||||
var lhst [4]float32
|
var lhst [4]float32
|
||||||
other.UnsafeElements(&lhsb, &lhst)
|
other.Elements(&lhsb, &lhst)
|
||||||
rhsb := &c.body
|
rhsb := &c.body
|
||||||
rhst := &c.translate
|
rhst := &c.translate
|
||||||
return lhsb == *rhsb && lhst == *rhst
|
return lhsb == *rhsb && lhst == *rhst
|
||||||
@ -541,7 +541,7 @@ func (c colorMImplScale) Concat(other ColorM) ColorM {
|
|||||||
|
|
||||||
var lhsb [16]float32
|
var lhsb [16]float32
|
||||||
var lhst [4]float32
|
var lhst [4]float32
|
||||||
other.UnsafeElements(&lhsb, &lhst)
|
other.Elements(&lhsb, &lhst)
|
||||||
s := &c.scale
|
s := &c.scale
|
||||||
return &colorMImplBodyTranslate{
|
return &colorMImplBodyTranslate{
|
||||||
body: [...]float32{
|
body: [...]float32{
|
||||||
@ -561,7 +561,7 @@ func (c *colorMImplBodyTranslate) Concat(other ColorM) ColorM {
|
|||||||
|
|
||||||
var lhsb [16]float32
|
var lhsb [16]float32
|
||||||
var lhst [4]float32
|
var lhst [4]float32
|
||||||
other.UnsafeElements(&lhsb, &lhst)
|
other.Elements(&lhsb, &lhst)
|
||||||
rhsb := &c.body
|
rhsb := &c.body
|
||||||
rhst := &c.translate
|
rhst := &c.translate
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ const (
|
|||||||
type ColorM interface {
|
type ColorM interface {
|
||||||
IsIdentity() bool
|
IsIdentity() bool
|
||||||
At(i, j int) float32
|
At(i, j int) float32
|
||||||
UnsafeElements(body *[16]float32, translate *[4]float32)
|
Elements(body *[16]float32, translate *[4]float32)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Graphics interface {
|
type Graphics interface {
|
||||||
|
@ -910,7 +910,7 @@ func (g *Graphics) DrawTriangles(dstID driver.ImageID, srcIDs [graphics.ShaderIm
|
|||||||
}
|
}
|
||||||
var esBody [16]float32
|
var esBody [16]float32
|
||||||
var esTranslate [4]float32
|
var esTranslate [4]float32
|
||||||
colorM.UnsafeElements(&esBody, &esTranslate)
|
colorM.Elements(&esBody, &esTranslate)
|
||||||
scale := float32(0)
|
scale := float32(0)
|
||||||
if filter == driver.FilterScreen {
|
if filter == driver.FilterScreen {
|
||||||
scale = float32(dst.width) / float32(srcs[0].width)
|
scale = float32(dst.width) / float32(srcs[0].width)
|
||||||
|
@ -190,7 +190,7 @@ func (g *Graphics) DrawTriangles(dstID driver.ImageID, srcIDs [graphics.ShaderIm
|
|||||||
// ColorM's elements are immutable. It's OK to hold the reference without copying.
|
// ColorM's elements are immutable. It's OK to hold the reference without copying.
|
||||||
var esBody [16]float32
|
var esBody [16]float32
|
||||||
var esTranslate [4]float32
|
var esTranslate [4]float32
|
||||||
colorM.UnsafeElements(&esBody, &esTranslate)
|
colorM.Elements(&esBody, &esTranslate)
|
||||||
uniformVars = append(uniformVars, uniformVariable{
|
uniformVars = append(uniformVars, uniformVariable{
|
||||||
name: "color_matrix_body",
|
name: "color_matrix_body",
|
||||||
value: esBody[:],
|
value: esBody[:],
|
||||||
|
Loading…
Reference in New Issue
Block a user