From dfd4bc89ed65fc046a132c48d949025a7a069a6a Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 11 Jun 2016 20:21:14 +0900 Subject: [PATCH] graphics: Revert FlushCommand execution --- graphicscontext.go | 1 - image.go | 2 +- internal/graphics/framebuffer.go | 8 +++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/graphicscontext.go b/graphicscontext.go index 6608b030b..ca694aa9c 100644 --- a/graphicscontext.go +++ b/graphicscontext.go @@ -84,7 +84,6 @@ func (c *graphicsContext) Update() error { if err := c.defaultRenderTarget.DrawImage(c.screen, options); err != nil { return err } - graphics.FlushCommands(ui.GLContext()) // Call glFlush to prevent black flicking (especially on Android (#226)). ui.GLContext().Flush() return nil diff --git a/image.go b/image.go index fe73dc5c6..de1dddf02 100644 --- a/image.go +++ b/image.go @@ -261,7 +261,7 @@ func (i *imageImpl) DrawImage(image *Image, options *DrawImageOptions) error { geom := &options.GeoM colorm := &options.ColorM mode := opengl.CompositeMode(options.CompositeMode) - if err := i.framebuffer.DrawTexture(image.impl.texture, vertices[:16*n], geom, colorm, mode); err != nil { + if err := i.framebuffer.DrawTexture(ui.GLContext(), image.impl.texture, vertices[:16*n], geom, colorm, mode); err != nil { return err } return nil diff --git a/internal/graphics/framebuffer.go b/internal/graphics/framebuffer.go index 08b3eb6b3..469a45f44 100644 --- a/internal/graphics/framebuffer.go +++ b/internal/graphics/framebuffer.go @@ -105,7 +105,7 @@ func (f *Framebuffer) Fill(clr color.Color) error { return nil } -func (f *Framebuffer) DrawTexture(t *Texture, vertices []int16, geo, clr Matrix, mode opengl.CompositeMode) error { +func (f *Framebuffer) DrawTexture(context *opengl.Context, t *Texture, vertices []int16, geo, clr Matrix, mode opengl.CompositeMode) error { c := &drawImageCommand{ dst: f, src: t, @@ -115,6 +115,12 @@ func (f *Framebuffer) DrawTexture(t *Texture, vertices []int16, geo, clr Matrix, mode: mode, } theCommandQueue.Enqueue(c) + // TODO: Can we move this to graphicscontext.go (again)? + if f.native == opengl.ZeroFramebuffer { + if err := FlushCommands(context); err != nil { + return err + } + } return nil }