diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index fd0ba3db3..ba6d36433 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -237,11 +237,6 @@ func (c *drawImageCommand) Exec(indexOffsetInBytes int) error { return err } driver().DrawElements(c.nindices, indexOffsetInBytes) - - // glFlush() might be necessary at least on MacBook Pro (a smilar problem at #419), - // but basically this pass the tests (esp. TestImageTooManyFill). - // As glFlush() causes performance problems, this should be avoided as much as possible. - // Let's wait and see, and file a new issue when this problem is newly found. return nil } @@ -298,10 +293,7 @@ func (c *replacePixelsCommand) String() string { // Exec executes the replacePixelsCommand. func (c *replacePixelsCommand) Exec(indexOffsetInBytes int) error { - // glFlush is necessary on Android. - // glTexSubImage2D didn't work without this hack at least on Nexus 5x and NuAns NEO [Reloaded] (#211). - driver().Flush() - c.dst.image.TexSubImage2D(c.pixels, c.x, c.y, c.width, c.height) + c.dst.image.ReplacePixels(c.pixels, c.x, c.y, c.width, c.height) return nil } diff --git a/internal/graphicsdriver/graphicsdriver.go b/internal/graphicsdriver/graphicsdriver.go index fda385672..352ff986b 100644 --- a/internal/graphicsdriver/graphicsdriver.go +++ b/internal/graphicsdriver/graphicsdriver.go @@ -36,5 +36,5 @@ type Image interface { Pixels() ([]byte, error) SetAsDestination() SetAsSource() - TexSubImage2D(p []byte, x, y, width, height int) + ReplacePixels(pixels []byte, x, y, width, height int) } diff --git a/internal/graphicsdriver/opengl/driver.go b/internal/graphicsdriver/opengl/driver.go index 6099b6ab1..39c76aa7f 100644 --- a/internal/graphicsdriver/opengl/driver.go +++ b/internal/graphicsdriver/opengl/driver.go @@ -77,6 +77,10 @@ func (d *Driver) UseProgram(mode graphics.CompositeMode, colorM *affine.ColorM, func (d *Driver) DrawElements(len int, offsetInBytes int) { theContext.drawElements(len, offsetInBytes) + // glFlush() might be necessary at least on MacBook Pro (a smilar problem at #419), + // but basically this pass the tests (esp. TestImageTooManyFill). + // As glFlush() causes performance problems, this should be avoided as much as possible. + // Let's wait and see, and file a new issue when this problem is newly found. } func (d *Driver) Flush() { diff --git a/internal/graphicsdriver/opengl/image.go b/internal/graphicsdriver/opengl/image.go index 22f67c019..5f22223f2 100644 --- a/internal/graphicsdriver/opengl/image.go +++ b/internal/graphicsdriver/opengl/image.go @@ -100,7 +100,10 @@ func (i *Image) ensureFramebuffer() error { return nil } -func (i *Image) TexSubImage2D(p []byte, x, y, width, height int) { +func (i *Image) ReplacePixels(p []byte, x, y, width, height int) { + // glFlush is necessary on Android. + // glTexSubImage2D didn't work without this hack at least on Nexus 5x and NuAns NEO [Reloaded] (#211). + theContext.flush() theContext.texSubImage2D(i.textureNative, p, x, y, width, height) }