From 4ce850df7037a544cb44f91c9f69d8fdf572b0a6 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 22 Jan 2019 01:44:47 +0900 Subject: [PATCH] graphics: Bug fix: Resolve pixels before the screen is cleared Fixes #792 Clearing the screen is so special on some environments (like macOS Metal) that other operations on other images can be invalidated. This fixes the issue by resolving the pixels of the offscreen that is used as a render source for the screen before the screen is cleared. We are not sure this is a correct way, but this actually fixes the problem on macOS. --- graphicscontext.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/graphicscontext.go b/graphicscontext.go index 3a9e9d88b..f5b414ec9 100644 --- a/graphicscontext.go +++ b/graphicscontext.go @@ -112,6 +112,11 @@ func (c *graphicsContext) Update(afterFrameUpdate func()) error { afterFrameUpdate() } + // Before clearing the screen, the offscreen's pixels must be solved. + // After clearing the screen, resolving doesn't work. This is very hacky + // but we could not find other way so far (#792). + c.offscreen.resolvePixelsToSet(true) + // This clear is needed for fullscreen mode or some mobile platforms (#622). c.screen.Clear()