shareable: Add comments

This commit is contained in:
Hajime Hoshi 2019-04-11 18:15:56 -07:00
parent c8cc98e307
commit 5afcc65387
2 changed files with 7 additions and 1 deletions

View File

@ -90,7 +90,8 @@ func quadVerticesImpl(sw, sh, x, y, u0, v0, u1, v1, a, b, c, d, tx, ty, cr, cg,
// Specifying a range explicitly here is redundant but this helps optimization
// to eliminate boundary checks.
//
// 4*VertexFloatNum is better than 48, but in GopherJS, optimization might not work.
// 4*VertexFloatNum is better than 48 in terms of code maintenanceability, but in GopherJS, optimization
// might not work.
vs := theVerticesBackend.slice(4)[0:48]
ax, by, cx, dy := a*x, b*y, c*x, d*y

View File

@ -185,6 +185,10 @@ func (i *Image) Size() (width, height int) {
return i.width, i.height
}
// QuadVertices returns the vertices for rendering a quad.
//
// QuadVertices is highly optimized for rendering quads, and that's the most significant difference from
// PutVertices.
func (i *Image) QuadVertices(sx0, sy0, sx1, sy1 int, a, b, c, d, tx, ty float32, cr, cg, cb, ca float32) []float32 {
if i.backend == nil {
i.allocate(true)
@ -193,6 +197,7 @@ func (i *Image) QuadVertices(sx0, sy0, sx1, sy1 int, a, b, c, d, tx, ty float32,
return i.backend.restorable.QuadVertices(sx0+ox, sy0+oy, sx1+ox, sy1+oy, a, b, c, d, tx, ty, cr, cg, cb, ca)
}
// PutVertices puts the given dest with vertices that can be passed to DrawImage.
func (i *Image) PutVertex(dest []float32, dx, dy, sx, sy float32, bx0, by0, bx1, by1 float32, cr, cg, cb, ca float32) {
if i.backend == nil {
i.allocate(true)