Source
void renderTextureQuad(
RenderState renderState,
RenderTextureQuad renderTextureQuad) {
if (renderTextureQuad.hasCustomVertices) {
var ixList = renderTextureQuad.ixList;
var vxList = renderTextureQuad.vxList;
this.renderTextureMesh(renderState, ixList, vxList);
return;
}
var alpha = renderState.globalAlpha;
var matrix = renderState.globalMatrix;
var vxList = renderTextureQuad.vxListQuad;
var ixListCount = 6;
var vxListCount = 4;
// check buffer sizes and flush if necessary
var ixData = renderBufferIndex.data;
var ixPosition = renderBufferIndex.position;
if (ixPosition + ixListCount >= ixData.length) flush();
var vxData = renderBufferVertex.data;
var vxPosition = renderBufferVertex.position;
if (vxPosition + vxListCount * 5 >= vxData.length) flush();
var ixIndex = renderBufferIndex.position;
var vxIndex = renderBufferVertex.position;
var vxCount = renderBufferVertex.count;
// copy index list
ixData[ixIndex + 0] = vxCount + 0;
ixData[ixIndex + 1] = vxCount + 1;
ixData[ixIndex + 2] = vxCount + 2;
ixData[ixIndex + 3] = vxCount + 0;
ixData[ixIndex + 4] = vxCount + 2;
ixData[ixIndex + 5] = vxCount + 3;
renderBufferIndex.position += ixListCount;
renderBufferIndex.count += ixListCount;
// copy vertex list
var ma1 = vxList[0] * matrix.a + matrix.tx;
var ma2 = vxList[8] * matrix.a + matrix.tx;
var mb1 = vxList[0] * matrix.b + matrix.ty;
var mb2 = vxList[8] * matrix.b + matrix.ty;
var mc1 = vxList[1] * matrix.c;
var mc2 = vxList[9] * matrix.c;
var md1 = vxList[1] * matrix.d;
var md2 = vxList[9] * matrix.d;
vxData[vxIndex + 00] = ma1 + mc1;
vxData[vxIndex + 01] = mb1 + md1;
vxData[vxIndex + 02] = vxList[2];
vxData[vxIndex + 03] = vxList[3];
vxData[vxIndex + 04] = alpha;
vxData[vxIndex + 05] = ma2 + mc1;
vxData[vxIndex + 06] = mb2 + md1;
vxData[vxIndex + 07] = vxList[6];
vxData[vxIndex + 08] = vxList[7];
vxData[vxIndex + 09] = alpha;
vxData[vxIndex + 10] = ma2 + mc2;
vxData[vxIndex + 11] = mb2 + md2;
vxData[vxIndex + 12] = vxList[10];
vxData[vxIndex + 13] = vxList[11];
vxData[vxIndex + 14] = alpha;
vxData[vxIndex + 15] = ma1 + mc2;
vxData[vxIndex + 16] = mb1 + md2;
vxData[vxIndex + 17] = vxList[14];
vxData[vxIndex + 18] = vxList[15];
vxData[vxIndex + 19] = alpha;
renderBufferVertex.position += vxListCount * 5;
renderBufferVertex.count += vxListCount;
}