From ab95c9014d3a51f6238f3c58f64aeb6ee69988d4 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 15 Jul 2020 03:37:35 +0900 Subject: [PATCH] buffered, shareable: Bug fix: Check source images correctly --- internal/buffered/image.go | 20 +++++++++----------- internal/shareable/image.go | 6 ++---- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/internal/buffered/image.go b/internal/buffered/image.go index 69baf0a96..db438ed87 100644 --- a/internal/buffered/image.go +++ b/internal/buffered/image.go @@ -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) diff --git a/internal/shareable/image.go b/internal/shareable/image.go index b632c6cce..0106bf9ba 100644 --- a/internal/shareable/image.go +++ b/internal/shareable/image.go @@ -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()