From 0831fd2a0dbadc8717415d4ff9fcd7548b226f48 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 19 Sep 2017 01:37:24 +0900 Subject: [PATCH] graphics: Add comments --- internal/graphics/command.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/internal/graphics/command.go b/internal/graphics/command.go index a1d297b06..6f6aa4e7e 100644 --- a/internal/graphics/command.go +++ b/internal/graphics/command.go @@ -39,15 +39,24 @@ type command interface { // commandQueue is a command queue for drawing commands. type commandQueue struct { - commands []command - vertices []float32 + // commands is a queue of drawing commands. + commands []command + + // vertices represents a vertices data in OpenGL's array buffer. + vertices []float32 + + // verticesNum represents the current length of vertices. + // verticesNum must <= len(vertices). + // vertices is never shrunk since re-extending a vertices buffer is heavy. verticesNum int - m sync.Mutex + + m sync.Mutex } // theCommandQueue is the command queue for the current process. var theCommandQueue = &commandQueue{} +// appendVertices appends vertices to the queue. func (q *commandQueue) appendVertices(vertices []float32) { if len(q.vertices) < q.verticesNum+len(vertices) { n := q.verticesNum + len(vertices) - len(q.vertices) @@ -61,6 +70,7 @@ func (q *commandQueue) appendVertices(vertices []float32) { q.verticesNum += len(vertices) } +// EnqueueDrawImageCommand enqueues a drawing-image command. func (q *commandQueue) EnqueueDrawImageCommand(dst, src *Image, vertices []float32, clr *affine.ColorM, mode opengl.CompositeMode) { // Avoid defer for performance q.m.Lock()