buffered, shareable: Bug fix: Check source images correctly

This commit is contained in:
Hajime Hoshi 2020-07-15 03:37:35 +09:00
parent f8956941b7
commit ab95c9014d
2 changed files with 11 additions and 15 deletions

View File

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

View File

@ -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()