graphics: Use addition instead of multiplying in vertices

This commit is contained in:
Hajime Hoshi 2016-10-27 03:33:19 +09:00
parent b77a28b208
commit 8c793ce53b
2 changed files with 36 additions and 30 deletions

View File

@ -89,26 +89,29 @@ func vertices(parts ImageParts, width, height int, geo *GeoM) []int16 {
for j, g := range geo16 {
vs[offset+4+j] = g
}
vs[offset+oneSize] = x1
vs[offset+oneSize+1] = y0
vs[offset+oneSize+2] = u1
vs[offset+oneSize+3] = v0
offset += oneSize
vs[offset] = x1
vs[offset+1] = y0
vs[offset+2] = u1
vs[offset+3] = v0
for j, g := range geo16 {
vs[offset+oneSize+4+j] = g
vs[offset+4+j] = g
}
vs[offset+2*oneSize] = x0
vs[offset+2*oneSize+1] = y1
vs[offset+2*oneSize+2] = u0
vs[offset+2*oneSize+3] = v1
offset += oneSize
vs[offset] = x0
vs[offset+1] = y1
vs[offset+2] = u0
vs[offset+3] = v1
for j, g := range geo16 {
vs[offset+2*oneSize+4+j] = g
vs[offset+4+j] = g
}
vs[offset+3*oneSize] = x1
vs[offset+3*oneSize+1] = y1
vs[offset+3*oneSize+2] = u1
vs[offset+3*oneSize+3] = v1
offset += oneSize
vs[offset] = x1
vs[offset+1] = y1
vs[offset+2] = u1
vs[offset+3] = v1
for j, g := range geo16 {
vs[offset+3*oneSize+4+j] = g
vs[offset+4+j] = g
}
n++
}

View File

@ -67,26 +67,29 @@ func vertices(parts ImageParts, width, height int, geo *GeoM) []int16 {
for j, g := range gs {
af32.SetIndex((offset+4)/2+j, g)
}
a16.SetIndex(offset+oneSize, dx1)
a16.SetIndex(offset+oneSize+1, dy0)
a16.SetIndex(offset+oneSize+2, u1)
a16.SetIndex(offset+oneSize+3, v0)
offset += oneSize
a16.SetIndex(offset, dx1)
a16.SetIndex(offset+1, dy0)
a16.SetIndex(offset+2, u1)
a16.SetIndex(offset+3, v0)
for j, g := range gs {
af32.SetIndex((offset+oneSize+4)/2+j, g)
af32.SetIndex((offset+4)/2+j, g)
}
a16.SetIndex(offset+2*oneSize, dx0)
a16.SetIndex(offset+2*oneSize+1, dy1)
a16.SetIndex(offset+2*oneSize+2, u0)
a16.SetIndex(offset+2*oneSize+3, v1)
offset += oneSize
a16.SetIndex(offset, dx0)
a16.SetIndex(offset+1, dy1)
a16.SetIndex(offset+2, u0)
a16.SetIndex(offset+3, v1)
for j, g := range gs {
af32.SetIndex((offset+2*oneSize+4)/2+j, g)
af32.SetIndex((offset+4)/2+j, g)
}
a16.SetIndex(offset+3*oneSize, dx1)
a16.SetIndex(offset+3*oneSize+1, dy1)
a16.SetIndex(offset+3*oneSize+2, u1)
a16.SetIndex(offset+3*oneSize+3, v1)
offset += oneSize
a16.SetIndex(offset, dx1)
a16.SetIndex(offset+1, dy1)
a16.SetIndex(offset+2, u1)
a16.SetIndex(offset+3, v1)
for j, g := range gs {
af32.SetIndex((offset+3*oneSize+4)/2+j, g)
af32.SetIndex((offset+4)/2+j, g)
}
n++
}