mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Avoid copying ColorM
This commit is contained in:
parent
1b72263ce1
commit
1b1b996817
2
image.go
2
image.go
@ -123,7 +123,7 @@ func (i *Image) DrawImage(image *Image, options *DrawImageOptions) error {
|
||||
panic("ebiten: Image.DrawImage: image must be different from the receiver")
|
||||
}
|
||||
mode := opengl.CompositeMode(options.CompositeMode)
|
||||
i.restorable.DrawImage(image.restorable, vs, options.ColorM.impl, mode)
|
||||
i.restorable.DrawImage(image.restorable, vs, &options.ColorM.impl, mode)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ func (q *commandQueue) appendVertices(vertices []float32) {
|
||||
q.verticesNum += len(vertices)
|
||||
}
|
||||
|
||||
func (q *commandQueue) EnqueueDrawImageCommand(dst, src *Image, vertices []float32, clr affine.ColorM, mode opengl.CompositeMode) {
|
||||
func (q *commandQueue) EnqueueDrawImageCommand(dst, src *Image, vertices []float32, clr *affine.ColorM, mode opengl.CompositeMode) {
|
||||
q.m.Lock()
|
||||
defer q.m.Unlock()
|
||||
q.appendVertices(vertices)
|
||||
@ -64,7 +64,7 @@ func (q *commandQueue) EnqueueDrawImageCommand(dst, src *Image, vertices []float
|
||||
dst: dst,
|
||||
src: src,
|
||||
verticesNum: len(vertices),
|
||||
color: clr,
|
||||
color: *clr,
|
||||
mode: mode,
|
||||
}
|
||||
q.commands = append(q.commands, c)
|
||||
@ -232,14 +232,14 @@ func (c *drawImageCommand) split(quadsNum int) [2]*drawImageCommand {
|
||||
return [2]*drawImageCommand{&c1, &c2}
|
||||
}
|
||||
|
||||
func (c *drawImageCommand) isMergeable(dst, src *Image, clr affine.ColorM, mode opengl.CompositeMode) bool {
|
||||
func (c *drawImageCommand) isMergeable(dst, src *Image, clr *affine.ColorM, mode opengl.CompositeMode) bool {
|
||||
if c.dst != dst {
|
||||
return false
|
||||
}
|
||||
if c.src != src {
|
||||
return false
|
||||
}
|
||||
if !c.color.Equals(&clr) {
|
||||
if !c.color.Equals(clr) {
|
||||
return false
|
||||
}
|
||||
if c.mode != mode {
|
||||
|
@ -141,7 +141,7 @@ func (i *Image) Fill(clr color.RGBA) {
|
||||
theCommandQueue.Enqueue(c)
|
||||
}
|
||||
|
||||
func (i *Image) DrawImage(src *Image, vertices []float32, clr affine.ColorM, mode opengl.CompositeMode) {
|
||||
func (i *Image) DrawImage(src *Image, vertices []float32, clr *affine.ColorM, mode opengl.CompositeMode) {
|
||||
theCommandQueue.EnqueueDrawImageCommand(i, src, vertices, clr, mode)
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ func (p *Image) ReplacePixels(pixels []uint8) {
|
||||
p.stale = false
|
||||
}
|
||||
|
||||
func (p *Image) DrawImage(img *Image, vertices []float32, colorm affine.ColorM, mode opengl.CompositeMode) {
|
||||
func (p *Image) DrawImage(img *Image, vertices []float32, colorm *affine.ColorM, mode opengl.CompositeMode) {
|
||||
theImages.resetPixelsIfDependingOn(p)
|
||||
if img.stale || img.volatile {
|
||||
p.makeStale()
|
||||
@ -140,7 +140,7 @@ func (p *Image) DrawImage(img *Image, vertices []float32, colorm affine.ColorM,
|
||||
p.image.DrawImage(img.image, vertices, colorm, mode)
|
||||
}
|
||||
|
||||
func (p *Image) appendDrawImageHistory(image *Image, vertices []float32, colorm affine.ColorM, mode opengl.CompositeMode) {
|
||||
func (p *Image) appendDrawImageHistory(image *Image, vertices []float32, colorm *affine.ColorM, mode opengl.CompositeMode) {
|
||||
if p.stale {
|
||||
return
|
||||
}
|
||||
@ -153,7 +153,7 @@ func (p *Image) appendDrawImageHistory(image *Image, vertices []float32, colorm
|
||||
item := &drawImageHistoryItem{
|
||||
image: image,
|
||||
vertices: vertices,
|
||||
colorm: colorm,
|
||||
colorm: *colorm,
|
||||
mode: mode,
|
||||
}
|
||||
p.drawImageHistory = append(p.drawImageHistory, item)
|
||||
@ -264,7 +264,7 @@ func (p *Image) restore(context *opengl.Context) error {
|
||||
if c.image.hasDependency() {
|
||||
panic("not reach")
|
||||
}
|
||||
gimg.DrawImage(c.image.image, c.vertices, c.colorm, c.mode)
|
||||
gimg.DrawImage(c.image.image, c.vertices, &c.colorm, c.mode)
|
||||
}
|
||||
p.image = gimg
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user