mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
graphics: Stop unnecessary copy of elements
This commit is contained in:
parent
f1f7e5bcec
commit
40b1948baa
@ -44,7 +44,7 @@ var (
|
||||
// The initial value is identity.
|
||||
type ColorM struct {
|
||||
// When elements is nil, this matrix is identity.
|
||||
// elements is immutable and a new array must be created when updating.
|
||||
// elements are immutable and a new array must be created when updating.
|
||||
body []float32
|
||||
translate []float32
|
||||
}
|
||||
|
@ -271,14 +271,16 @@ func (s *openGLState) useProgram(proj []float32, texture opengl.Texture, sourceW
|
||||
if s.lastColorMatrix == nil {
|
||||
s.lastColorMatrix = make([]float32, 16)
|
||||
}
|
||||
copy(s.lastColorMatrix, esBody)
|
||||
// ColorM's elements are immutable. It's OK to hold the reference without copying.
|
||||
s.lastColorMatrix = esBody
|
||||
}
|
||||
if !areSameFloat32Array(s.lastColorMatrixTranslation, esTranslate) {
|
||||
c.UniformFloats(program, "color_matrix_translation", esTranslate)
|
||||
if s.lastColorMatrixTranslation == nil {
|
||||
s.lastColorMatrixTranslation = make([]float32, 4)
|
||||
}
|
||||
copy(s.lastColorMatrixTranslation, esTranslate)
|
||||
// ColorM's elements are immutable. It's OK to hold the reference without copying.
|
||||
s.lastColorMatrixTranslation = esTranslate
|
||||
}
|
||||
|
||||
if program == s.programLinear {
|
||||
|
Loading…
Reference in New Issue
Block a user