modules/graphics/src/main/java/com/sun/prism/impl/VertexBuffer.java

Print this page

        

*** 48,65 **** --- 48,74 ---- protected byte r, g, b, a; protected byte colorArray[]; protected float coordArray[]; + protected BaseContext owner; + public VertexBuffer(int maxQuads) { capacity = maxQuads * VERTS_PER_QUAD; index = 0; colorArray = new byte [capacity * BYTES_PER_VERT]; coordArray = new float[capacity * FLOATS_PER_VERT]; } + public void setOwner(BaseContext owner) { + if (this.owner != null) { + throw new InternalError("Only one owner per VertexBuffer allowed"); + } + this.owner = owner; + } + protected void drawQuads(int numVertices) { throw new Error ("flush not implemented for lightweight"); } // it had better be the case if this method be moved to Graphics
*** 99,108 **** --- 108,125 ---- * destination render target. This operation only applies to heavyweight * buffers; calling flush() on a lightweight buffer will result in an * exception. */ public final void flush() { + if (owner == null) { + ownerFlush(); + } else { + owner.flushVertexBuffer(); + } + } + + public final void ownerFlush() { if (index > 0) { drawQuads(index); index = 0; } }
*** 207,218 **** drawTriangles(numVerts/3, vb.coordArray, vb.colorArray); } private void ensureCapacityForQuad() { if (index + VERTS_PER_QUAD > capacity) { ! drawQuads(index); ! index = 0; } } public final void addQuad(float dx1, float dy1, float dx2, float dy2) { ensureCapacityForQuad(); --- 224,234 ---- drawTriangles(numVerts/3, vb.coordArray, vb.colorArray); } private void ensureCapacityForQuad() { if (index + VERTS_PER_QUAD > capacity) { ! flush(); } } public final void addQuad(float dx1, float dy1, float dx2, float dy2) { ensureCapacityForQuad();
*** 289,301 **** boolean isText) { // ensureCapacityForQuad(); int idx = index; if (idx + VERTS_PER_QUAD > capacity) { ! // grow(); ! drawQuads(idx); ! idx = index = 0; } int i = FLOATS_PER_VERT * idx; float farr[] = coordArray; --- 305,316 ---- boolean isText) { // ensureCapacityForQuad(); int idx = index; if (idx + VERTS_PER_QUAD > capacity) { ! flush(); ! idx = index; } int i = FLOATS_PER_VERT * idx; float farr[] = coordArray;
*** 335,346 **** float tx1, float ty1, float tx2, float ty2) { // ensureCapacityForQuad(); int idx = index; if (idx + VERTS_PER_QUAD > capacity) { ! drawQuads(idx); ! idx = index = 0; } int i = FLOATS_PER_VERT * idx; float farr[] = coordArray; --- 350,361 ---- float tx1, float ty1, float tx2, float ty2) { // ensureCapacityForQuad(); int idx = index; if (idx + VERTS_PER_QUAD > capacity) { ! flush(); ! idx = index; } int i = FLOATS_PER_VERT * idx; float farr[] = coordArray;
*** 375,386 **** float dx1, float dy1, float dx2, float dy2, float tx1, float ty1, float tx2, float ty2) { int idx = index; if (idx + VERTS_PER_QUAD > capacity) { ! drawQuads(idx); ! idx = index = 0; } int i = FLOATS_PER_VERT * idx; float farr[] = coordArray; --- 390,401 ---- float dx1, float dy1, float dx2, float dy2, float tx1, float ty1, float tx2, float ty2) { int idx = index; if (idx + VERTS_PER_QUAD > capacity) { ! flush(); ! idx = index; } int i = FLOATS_PER_VERT * idx; float farr[] = coordArray;
*** 446,457 **** float ux12, float uy12, float ux22, float uy22, float vx, float vy) { int idx = index; if (idx + VERTS_PER_QUAD > capacity) { ! drawQuads(idx); ! idx = index = 0; } int i = FLOATS_PER_VERT * idx; float farr[] = coordArray; --- 461,472 ---- float ux12, float uy12, float ux22, float uy22, float vx, float vy) { int idx = index; if (idx + VERTS_PER_QUAD > capacity) { ! flush(); ! idx = index; } int i = FLOATS_PER_VERT * idx; float farr[] = coordArray;
*** 494,505 **** float vx11, float vy11, float vx21, float vy21, float vx12, float vy12, float vx22, float vy22) { int idx = index; if (idx + VERTS_PER_QUAD > capacity) { ! drawQuads(idx); ! idx = index = 0; } int i = FLOATS_PER_VERT * idx; float farr[] = coordArray; --- 509,520 ---- float vx11, float vy11, float vx21, float vy21, float vx12, float vy12, float vx22, float vy22) { int idx = index; if (idx + VERTS_PER_QUAD > capacity) { ! flush(); ! idx = index; } int i = FLOATS_PER_VERT * idx; float farr[] = coordArray;