slice vertices and colors

This commit is contained in:
Laurent Le Goff 2011-04-27 10:36:31 +02:00
parent 259014193d
commit 8bc0343156

View file

@ -39,33 +39,29 @@ func (p *GLPainter) Paint(ss []raster.Span, done bool) {
ci := len(p.colors)
p.vertices = p.vertices[0 : vi+vlenrequired]
p.colors = p.colors[0 : ci+clenrequired]
var (
colors []uint8
vertices []int32
)
for _, s := range ss {
ma := s.A >> 16
a := ma * p.ca / M16
p.colors[ci] = p.cr
ci++
p.colors[ci] = p.cg
ci++
p.colors[ci] = p.cb
ci++
p.colors[ci] = uint8(a >> 8)
ci++
p.colors[ci] = p.cr
ci++
p.colors[ci] = p.cg
ci++
p.colors[ci] = p.cb
ci++
p.colors[ci] = uint8(a >> 8)
ci++
p.vertices[vi] = int32(s.X0)
vi++
p.vertices[vi] = int32(s.Y)
vi++
p.vertices[vi] = int32(s.X1)
vi++
p.vertices[vi] = int32(s.Y)
vi++
a := uint8((ma * p.ca / M16) >> 8)
colors = p.colors[ci:]
colors[0] = p.cr
colors[1] = p.cg
colors[2] = p.cb
colors[3] = a
colors[4] = p.cr
colors[5] = p.cg
colors[6] = p.cb
colors[7] = a
ci += 8
vertices = p.vertices[vi:]
vertices[0] = int32(s.X0)
vertices[1] = int32(s.Y)
vertices[2] = int32(s.X1)
vertices[3] = int32(s.Y)
vi += 4
}
}