From 8379e17cacd2aa5b315aac94984f542c2d53d98c Mon Sep 17 00:00:00 2001 From: faiface Date: Mon, 10 Apr 2017 00:41:56 +0200 Subject: [PATCH] fix drawing onto Canvas --- pixelgl/canvas.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pixelgl/canvas.go b/pixelgl/canvas.go index f2a9bc5..eecc1a1 100644 --- a/pixelgl/canvas.go +++ b/pixelgl/canvas.go @@ -145,8 +145,8 @@ func (c *Canvas) setGlhfBounds() { } // must be manually called inside mainthread -func (c *Canvas) setBlendFunc() { - switch c.cmp { +func setBlendFunc(cmp pixel.ComposeMethod) { + switch cmp { case pixel.ComposeOver: glhf.BlendFunc(glhf.One, glhf.OneMinusSrcAlpha) case pixel.ComposeIn: @@ -218,12 +218,14 @@ func (ct *canvasTriangles) draw(tex *glhf.Texture, bounds pixel.Rect) { ct.dst.gf.Dirty() // save the current state vars to avoid race condition + cmp := ct.dst.cmp mat := ct.dst.mat col := ct.dst.col + smt := ct.dst.smooth mainthread.CallNonBlock(func() { ct.dst.setGlhfBounds() - ct.dst.setBlendFunc() + setBlendFunc(cmp) frame := ct.dst.gf.Frame() shader := ct.dst.shader @@ -256,8 +258,8 @@ func (ct *canvasTriangles) draw(tex *glhf.Texture, bounds pixel.Rect) { float32(bh), }) - if tex.Smooth() != ct.dst.smooth { - tex.SetSmooth(ct.dst.smooth) + if tex.Smooth() != smt { + tex.SetSmooth(smt) } ct.vs.Begin()