another minor change (code consistency)
This commit is contained in:
parent
b0d4233286
commit
79bffcc7e8
|
@ -65,7 +65,7 @@ func NewCanvas(bounds pixel.Rect, smooth bool) *Canvas {
|
|||
func (c *Canvas) MakeTriangles(t pixel.Triangles) pixel.TargetTriangles {
|
||||
return &canvasTriangles{
|
||||
GLTriangles: NewGLTriangles(c.s, t),
|
||||
c: c,
|
||||
dst: c,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,29 +287,29 @@ func (c *Canvas) Color(at pixel.Vec) pixel.NRGBA {
|
|||
type canvasTriangles struct {
|
||||
*GLTriangles
|
||||
|
||||
c *Canvas
|
||||
dst *Canvas
|
||||
}
|
||||
|
||||
func (ct *canvasTriangles) draw(tex *glhf.Texture, borders, bounds pixel.Rect) {
|
||||
ct.c.orig.dirty = true
|
||||
ct.dst.orig.dirty = true
|
||||
|
||||
// save the current state vars to avoid race condition
|
||||
mat := ct.c.mat
|
||||
col := ct.c.col
|
||||
mat := ct.dst.mat
|
||||
col := ct.dst.col
|
||||
|
||||
mainthread.CallNonBlock(func() {
|
||||
ct.c.setGlhfBounds()
|
||||
ct.c.f.Begin()
|
||||
ct.c.s.Begin()
|
||||
ct.dst.setGlhfBounds()
|
||||
ct.dst.f.Begin()
|
||||
ct.dst.s.Begin()
|
||||
|
||||
ct.c.s.SetUniformAttr(canvasBounds, mgl32.Vec4{
|
||||
float32(ct.c.bounds.X()),
|
||||
float32(ct.c.bounds.Y()),
|
||||
float32(ct.c.bounds.W()),
|
||||
float32(ct.c.bounds.H()),
|
||||
ct.dst.s.SetUniformAttr(canvasBounds, mgl32.Vec4{
|
||||
float32(ct.dst.bounds.X()),
|
||||
float32(ct.dst.bounds.Y()),
|
||||
float32(ct.dst.bounds.W()),
|
||||
float32(ct.dst.bounds.H()),
|
||||
})
|
||||
ct.c.s.SetUniformAttr(canvasTransform, mat)
|
||||
ct.c.s.SetUniformAttr(canvasColorMask, col)
|
||||
ct.dst.s.SetUniformAttr(canvasTransform, mat)
|
||||
ct.dst.s.SetUniformAttr(canvasColorMask, col)
|
||||
|
||||
if tex == nil {
|
||||
ct.vs.Begin()
|
||||
|
@ -318,21 +318,21 @@ func (ct *canvasTriangles) draw(tex *glhf.Texture, borders, bounds pixel.Rect) {
|
|||
} else {
|
||||
tex.Begin()
|
||||
|
||||
ct.c.s.SetUniformAttr(canvasTexBorders, mgl32.Vec4{
|
||||
ct.dst.s.SetUniformAttr(canvasTexBorders, mgl32.Vec4{
|
||||
float32(borders.X()),
|
||||
float32(borders.Y()),
|
||||
float32(borders.W()),
|
||||
float32(borders.H()),
|
||||
})
|
||||
ct.c.s.SetUniformAttr(canvasTexBounds, mgl32.Vec4{
|
||||
ct.dst.s.SetUniformAttr(canvasTexBounds, mgl32.Vec4{
|
||||
float32(bounds.X()),
|
||||
float32(bounds.Y()),
|
||||
float32(bounds.W()),
|
||||
float32(bounds.H()),
|
||||
})
|
||||
|
||||
if tex.Smooth() != ct.c.smooth {
|
||||
tex.SetSmooth(ct.c.smooth)
|
||||
if tex.Smooth() != ct.dst.smooth {
|
||||
tex.SetSmooth(ct.dst.smooth)
|
||||
}
|
||||
|
||||
ct.vs.Begin()
|
||||
|
@ -342,8 +342,8 @@ func (ct *canvasTriangles) draw(tex *glhf.Texture, borders, bounds pixel.Rect) {
|
|||
tex.End()
|
||||
}
|
||||
|
||||
ct.c.s.End()
|
||||
ct.c.f.End()
|
||||
ct.dst.s.End()
|
||||
ct.dst.f.End()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ func (cp *canvasPicture) Original() pixel.Picture {
|
|||
|
||||
func (cp *canvasPicture) Draw(t pixel.TargetTriangles) {
|
||||
ct := t.(*canvasTriangles)
|
||||
if cp.dst != ct.c {
|
||||
if cp.dst != ct.dst {
|
||||
panic(fmt.Errorf("%T.Draw: TargetTriangles generated by different Canvas", cp))
|
||||
}
|
||||
ct.draw(cp.tex, cp.borders, cp.bounds)
|
||||
|
@ -406,7 +406,7 @@ func (ccp *canvasCanvasPicture) Original() pixel.Picture {
|
|||
|
||||
func (ccp *canvasCanvasPicture) Draw(t pixel.TargetTriangles) {
|
||||
ct := t.(*canvasTriangles)
|
||||
if ccp.dst != ct.c {
|
||||
if ccp.dst != ct.dst {
|
||||
panic(fmt.Errorf("%T.Draw: TargetTriangles generated by different Canvas", ccp))
|
||||
}
|
||||
ct.draw(ccp.src.f.Texture(), ccp.src.orig.bounds, ccp.bounds)
|
||||
|
|
Loading…
Reference in New Issue