From e809991c9fe3b268b156613284cc2a1aa3c3cd3c Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 20 Dec 2018 23:24:26 +0900 Subject: [PATCH] shareable: Bug fix: Image invalidation by ReplacePixels ReplacePixels on a part of image might invalidate the other part of the image on MacBook Pro 2013, especially when the other part is rendered by DrawImage. Fixes #593 #758 --- internal/shareable/shareable.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/shareable/shareable.go b/internal/shareable/shareable.go index bfddace35..c9bb12271 100644 --- a/internal/shareable/shareable.go +++ b/internal/shareable/shareable.go @@ -65,9 +65,11 @@ func (b *backend) TryAlloc(width, height int) (*packing.Node, bool) { newImg := restorable.NewImage(s, s, false) oldImg := b.restorable w, h := oldImg.Size() - vs := graphics.QuadVertices(w, h, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1) - is := graphics.QuadIndices() - newImg.DrawImage(oldImg, vs, is, nil, graphics.CompositeModeCopy, graphics.FilterNearest) + // Do not use DrawImage here. ReplacePixels will be called on a part of newImg later, and it looked like + // ReplacePixels on a part of image deletes other region that are rendered by DrawImage (#593, 758). + // TODO: Add validations to ensure that an image cannot accept DrawImage after ReplacePixels on a part of + // it. + newImg.ReplacePixels(oldImg.Pixels(), 0, 0, w, h) oldImg.Dispose() b.restorable = newImg