fix drawing onto Canvas

This commit is contained in:
faiface 2017-04-10 00:41:56 +02:00
parent 5be03c8beb
commit 8379e17cac
1 changed files with 7 additions and 5 deletions

View File

@ -145,8 +145,8 @@ func (c *Canvas) setGlhfBounds() {
} }
// must be manually called inside mainthread // must be manually called inside mainthread
func (c *Canvas) setBlendFunc() { func setBlendFunc(cmp pixel.ComposeMethod) {
switch c.cmp { switch cmp {
case pixel.ComposeOver: case pixel.ComposeOver:
glhf.BlendFunc(glhf.One, glhf.OneMinusSrcAlpha) glhf.BlendFunc(glhf.One, glhf.OneMinusSrcAlpha)
case pixel.ComposeIn: case pixel.ComposeIn:
@ -218,12 +218,14 @@ func (ct *canvasTriangles) draw(tex *glhf.Texture, bounds pixel.Rect) {
ct.dst.gf.Dirty() ct.dst.gf.Dirty()
// save the current state vars to avoid race condition // save the current state vars to avoid race condition
cmp := ct.dst.cmp
mat := ct.dst.mat mat := ct.dst.mat
col := ct.dst.col col := ct.dst.col
smt := ct.dst.smooth
mainthread.CallNonBlock(func() { mainthread.CallNonBlock(func() {
ct.dst.setGlhfBounds() ct.dst.setGlhfBounds()
ct.dst.setBlendFunc() setBlendFunc(cmp)
frame := ct.dst.gf.Frame() frame := ct.dst.gf.Frame()
shader := ct.dst.shader shader := ct.dst.shader
@ -256,8 +258,8 @@ func (ct *canvasTriangles) draw(tex *glhf.Texture, bounds pixel.Rect) {
float32(bh), float32(bh),
}) })
if tex.Smooth() != ct.dst.smooth { if tex.Smooth() != smt {
tex.SetSmooth(ct.dst.smooth) tex.SetSmooth(smt)
} }
ct.vs.Begin() ct.vs.Begin()