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) ci := len(p.colors)
p.vertices = p.vertices[0 : vi+vlenrequired] p.vertices = p.vertices[0 : vi+vlenrequired]
p.colors = p.colors[0 : ci+clenrequired] p.colors = p.colors[0 : ci+clenrequired]
var (
colors []uint8
vertices []int32
)
for _, s := range ss { for _, s := range ss {
ma := s.A >> 16 ma := s.A >> 16
a := ma * p.ca / M16 a := uint8((ma * p.ca / M16) >> 8)
p.colors[ci] = p.cr colors = p.colors[ci:]
ci++ colors[0] = p.cr
p.colors[ci] = p.cg colors[1] = p.cg
ci++ colors[2] = p.cb
p.colors[ci] = p.cb colors[3] = a
ci++ colors[4] = p.cr
p.colors[ci] = uint8(a >> 8) colors[5] = p.cg
ci++ colors[6] = p.cb
p.colors[ci] = p.cr colors[7] = a
ci++ ci += 8
p.colors[ci] = p.cg vertices = p.vertices[vi:]
ci++ vertices[0] = int32(s.X0)
p.colors[ci] = p.cb vertices[1] = int32(s.Y)
ci++ vertices[2] = int32(s.X1)
p.colors[ci] = uint8(a >> 8) vertices[3] = int32(s.Y)
ci++ vi += 4
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++
} }
} }