mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
buffered, shareable: Bug fix: Check source images correctly
This commit is contained in:
parent
f8956941b7
commit
ab95c9014d
@ -269,21 +269,16 @@ func (i *Image) drawImage(src *Image, bounds image.Rectangle, g mipmap.GeoM, col
|
||||
//
|
||||
// Copying vertices and indices is the caller's responsibility.
|
||||
func (i *Image) DrawTriangles(src *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, textures []*Image) {
|
||||
var srcs []*Image
|
||||
if src != nil {
|
||||
srcs = append(srcs, src)
|
||||
}
|
||||
for _, u := range uniforms {
|
||||
if src, ok := u.(*Image); ok {
|
||||
srcs = append(srcs, src)
|
||||
}
|
||||
}
|
||||
|
||||
for _, src := range srcs {
|
||||
if i == src {
|
||||
panic("buffered: Image.DrawTriangles: src must be different from the receiver")
|
||||
}
|
||||
}
|
||||
for _, src := range textures {
|
||||
if i == src {
|
||||
panic("buffered: Image.DrawTriangles: source images must be different from the receiver")
|
||||
}
|
||||
}
|
||||
|
||||
if maybeCanAddDelayedCommand() {
|
||||
if tryAddDelayedCommand(func() error {
|
||||
@ -295,7 +290,10 @@ func (i *Image) DrawTriangles(src *Image, vertices []float32, indices []uint16,
|
||||
}
|
||||
}
|
||||
|
||||
for _, src := range srcs {
|
||||
if src != nil {
|
||||
src.resolvePendingPixels(true)
|
||||
}
|
||||
for _, src := range textures {
|
||||
src.resolvePendingPixels(true)
|
||||
}
|
||||
i.resolvePendingPixels(false)
|
||||
|
@ -373,10 +373,8 @@ func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16,
|
||||
if img != nil {
|
||||
makeSharedIfNeeded(img)
|
||||
}
|
||||
for _, u := range uniforms {
|
||||
if src, ok := u.(*Image); ok {
|
||||
makeSharedIfNeeded(src)
|
||||
}
|
||||
for _, src := range textures {
|
||||
makeSharedIfNeeded(src)
|
||||
}
|
||||
|
||||
backendsM.Unlock()
|
||||
|
Loading…
Reference in New Issue
Block a user