diff options
author | Harvey Harrison <[email protected]> | 2013-06-15 09:57:38 -0700 |
---|---|---|
committer | Harvey Harrison <[email protected]> | 2013-06-15 09:57:38 -0700 |
commit | 7364a234d53424515f6e709ede01140441a4d356 (patch) | |
tree | d771e8ec6c8781187735a15c2874e33869f2474a | |
parent | ac32c044ea2c69cd97b4ac95c5bbeabb8af183dc (diff) |
j3dcore: remove last use of the BufferWrapper classes from the core
Directly hold read-only views of the nio buffers, this likely fixes the vertex data held in
an nio buffer for the JOGL backend as the Object[] parameter hid the change from float[] to
FloatBuffer that occured at some point in history.
Signed-off-by: Harvey Harrison <[email protected]>
7 files changed, 21 insertions, 44 deletions
diff --git a/src/classes/share/javax/media/j3d/GeometryArrayRetained.java b/src/classes/share/javax/media/j3d/GeometryArrayRetained.java index 76f3acb..186f7a2 100644 --- a/src/classes/share/javax/media/j3d/GeometryArrayRetained.java +++ b/src/classes/share/javax/media/j3d/GeometryArrayRetained.java @@ -51,7 +51,6 @@ import javax.vecmath.Vector3d; import javax.vecmath.Vector3f; import com.sun.j3d.internal.Distance; -import com.sun.j3d.internal.FloatBufferWrapper; /** @@ -238,8 +237,7 @@ ArrayList<GeometryAtom> gaList = new ArrayList<GeometryAtom>(1); // Used for NIO buffer vertex attrs J3DBuffer[] vertexAttrsRefBuffer = null; - FloatBufferWrapper[] floatBufferRefVertexAttrs = null; - Object[] nioFloatBufferRefVertexAttrs = null; + FloatBuffer[] floatBufferRefVertexAttrs = null; // used by "by reference" tex coords Object[] refTexCoords = null; @@ -1538,7 +1536,7 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null; } } else { for (int i = 0; i < vertexAttrCount; i++) { - if (nioFloatBufferRefVertexAttrs[i] == null) { + if (floatBufferRefVertexAttrs[i] == null) { allNonNull = false; } else { allNull = false; @@ -1637,8 +1635,7 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null; this.mirrorFloatRefVertexAttrs = new float[vertexAttrCount][]; if ((vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0) { this.vertexAttrsRefBuffer = new J3DBuffer[vertexAttrCount]; - this.floatBufferRefVertexAttrs = new FloatBufferWrapper[vertexAttrCount]; - this.nioFloatBufferRefVertexAttrs = new Object[vertexAttrCount]; + this.floatBufferRefVertexAttrs = new FloatBuffer[vertexAttrCount]; } } } @@ -2600,7 +2597,7 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null; normal, vertexAttrCount, vertexAttrSizes, initialVertexAttrIndex, - nioFloatBufferRefVertexAttrs, + floatBufferRefVertexAttrs, ((texCoordSetMap == null) ? 0:texCoordSetMap.length), texCoordSetMap, cv.numActiveTexUnit, @@ -3211,7 +3208,7 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null; for (index=start; index < end; index++) { for (i = 0; i < vertexAttrCount; i++) { int vaOffset = vOffset + vertexAttrOffsets[i]; - FloatBufferWrapper vaBuffer = src.floatBufferRefVertexAttrs[i]; + FloatBuffer vaBuffer = src.floatBufferRefVertexAttrs[i]; vaBuffer.position(src.indexVertexAttr[i][index]*vertexAttrSizes[i]); vaBuffer.get(vertexData, vaOffset, vertexAttrSizes[i]); } @@ -9296,13 +9293,13 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null; // set the tex coord with nio buffer void setTexCoordRefBuffer(int texCoordSet, J3DBuffer texCoords) { - FloatBufferWrapper bufferImpl = null; + FloatBuffer bufferImpl = null; if (texCoords != null) { if(texCoords.bufferType != J3DBuffer.Type.FLOAT) throw new IllegalArgumentException(J3dI18N.getString("GeometryArray116")); - bufferImpl = (FloatBufferWrapper)texCoords.getBufferImpl(); + bufferImpl = (FloatBuffer)texCoords.getROBuffer(); int bufferSize = bufferImpl.limit(); assert bufferImpl.isDirect(); @@ -9330,7 +9327,7 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null; } else { // refTexCoords contains NIOBuffer object for tex coord - refTexCoords[texCoordSet] = bufferImpl.getBufferAsObject(); + refTexCoords[texCoordSet] = bufferImpl; } texCoordType = TF; validateTexCoordPointerType(); @@ -9537,13 +9534,13 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null; */ void setVertexAttrRefBuffer(int vertexAttrNum, J3DBuffer vertexAttrs) { - FloatBufferWrapper bufferImpl = null; + FloatBuffer bufferImpl = null; if (vertexAttrs != null) { if(vertexAttrs.bufferType != J3DBuffer.Type.FLOAT) throw new IllegalArgumentException(J3dI18N.getString("GeometryArray116")); - bufferImpl = (FloatBufferWrapper)vertexAttrs.getBufferImpl(); + bufferImpl = (FloatBuffer)vertexAttrs.getROBuffer(); int bufferSize = bufferImpl.limit(); assert bufferImpl.isDirect(); @@ -9568,12 +9565,9 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null; vertexAttrsRefBuffer[vertexAttrNum] = vertexAttrs; if (vertexAttrs == null) { floatBufferRefVertexAttrs[vertexAttrNum] = null; - nioFloatBufferRefVertexAttrs[vertexAttrNum] = null; } else { floatBufferRefVertexAttrs[vertexAttrNum] = bufferImpl; - nioFloatBufferRefVertexAttrs[vertexAttrNum] = - bufferImpl.getBufferAsObject(); } vertexAttrType = AF; validateVertexAttrPointerType(); diff --git a/src/classes/share/javax/media/j3d/GeometryStripArrayRetained.java b/src/classes/share/javax/media/j3d/GeometryStripArrayRetained.java index 019794f..a6113a6 100644 --- a/src/classes/share/javax/media/j3d/GeometryStripArrayRetained.java +++ b/src/classes/share/javax/media/j3d/GeometryStripArrayRetained.java @@ -32,8 +32,6 @@ import java.util.ArrayList; import javax.vecmath.TexCoord2f; import javax.vecmath.TexCoord3f; -import com.sun.j3d.internal.FloatBufferWrapper; - /** * The GeometryStripArray object is an abstract class that is extended for @@ -694,7 +692,7 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { for (k = 0; k < vertexAttrCount; k++) { int vaOffset = vOffset + vertexAttrOffsets[k]; - FloatBufferWrapper vaBuffer = src.floatBufferRefVertexAttrs[k]; + FloatBuffer vaBuffer = src.floatBufferRefVertexAttrs[k]; vaBuffer.position(src.indexVertexAttr[k][index]*vertexAttrSizes[k]); vaBuffer.get(vertexData, vaOffset, vertexAttrSizes[k]); } diff --git a/src/classes/share/javax/media/j3d/IndexedGeometryArrayRetained.java b/src/classes/share/javax/media/j3d/IndexedGeometryArrayRetained.java index d6b4bdb..811f364 100644 --- a/src/classes/share/javax/media/j3d/IndexedGeometryArrayRetained.java +++ b/src/classes/share/javax/media/j3d/IndexedGeometryArrayRetained.java @@ -1524,7 +1524,7 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { cfdata, cbdata, normal, vertexAttrCount, vertexAttrSizes, - nioFloatBufferRefVertexAttrs, + floatBufferRefVertexAttrs, ((texCoordSetMap == null) ? 0:texCoordSetMap.length), texCoordSetMap, cv.numActiveTexUnit, diff --git a/src/classes/share/javax/media/j3d/J3DBuffer.java b/src/classes/share/javax/media/j3d/J3DBuffer.java index 8abaeae..2cacf8a 100644 --- a/src/classes/share/javax/media/j3d/J3DBuffer.java +++ b/src/classes/share/javax/media/j3d/J3DBuffer.java @@ -36,11 +36,6 @@ import java.nio.IntBuffer; import java.nio.LongBuffer; import java.nio.ShortBuffer; -import com.sun.j3d.internal.BufferWrapper; -import com.sun.j3d.internal.ByteBufferWrapper; -import com.sun.j3d.internal.DoubleBufferWrapper; -import com.sun.j3d.internal.FloatBufferWrapper; - /** * Java 3D wrapper class for java.nio.Buffer objects. * When used to wrap a non-null NIO buffer object, this class will @@ -75,7 +70,6 @@ enum Type { private Buffer originalBuffer = null; private Buffer readonlyBuffer = null; - private BufferWrapper bufferImpl = null; Type bufferType = Type.NULL; /** @@ -190,23 +184,19 @@ enum Type { ByteBuffer byteBuffer = ((ByteBuffer)buffer).asReadOnlyBuffer(); byteBuffer.rewind(); readonlyBuffer = byteBuffer; - bufferImpl = new ByteBufferWrapper(byteBuffer); break; case FLOAT: FloatBuffer floatBuffer = ((FloatBuffer)buffer).asReadOnlyBuffer(); floatBuffer.rewind(); readonlyBuffer = floatBuffer; - bufferImpl = new FloatBufferWrapper(floatBuffer); break; case DOUBLE: DoubleBuffer doubleBuffer = ((DoubleBuffer)buffer).asReadOnlyBuffer(); doubleBuffer.rewind(); readonlyBuffer = doubleBuffer; - bufferImpl = new DoubleBufferWrapper(doubleBuffer); break; default: readonlyBuffer = null; - bufferImpl = null; } } @@ -227,8 +217,4 @@ enum Type { Buffer getROBuffer() { return readonlyBuffer; } - - BufferWrapper getBufferImpl() { - return bufferImpl; - } } diff --git a/src/classes/share/javax/media/j3d/JoglPipeline.java b/src/classes/share/javax/media/j3d/JoglPipeline.java index cc228e8..86d7cb8 100644 --- a/src/classes/share/javax/media/j3d/JoglPipeline.java +++ b/src/classes/share/javax/media/j3d/JoglPipeline.java @@ -254,7 +254,7 @@ class JoglPipeline extends Pipeline { float[] cfdata, byte[] cbdata, int initialNormalIndex, FloatBuffer ndata, int vertexAttrCount, int[] vertexAttrSizes, - int[] vertexAttrIndices, Object[] vertexAttrData, + int[] vertexAttrIndices, FloatBuffer[] vertexAttrData, int texCoordMapLength, int[] texcoordoffset, int numActiveTexUnitState, @@ -279,9 +279,8 @@ class JoglPipeline extends Pipeline { FloatBuffer[] vertexAttrBufs = null; // Get vertex attribute arrays - if (vattrDefined) { - vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData); - } + if (vattrDefined) + vertexAttrBufs = vertexAttrData; // get texture arrays if (textureDefined) { @@ -1836,7 +1835,7 @@ class JoglPipeline extends Pipeline { float[] cfdata, byte[] cbdata, FloatBuffer ndata, int vertexAttrCount, int[] vertexAttrSizes, - Object[] vertexAttrData, + FloatBuffer[] vertexAttrData, int texCoordMapLength, int[] texcoordoffset, int numActiveTexUnitState, @@ -1863,7 +1862,7 @@ class JoglPipeline extends Pipeline { // Get vertex attribute arrays if (vattrDefined) { - vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData); + vertexAttrBufs = vertexAttrData; } // get texture arrays diff --git a/src/classes/share/javax/media/j3d/NoopPipeline.java b/src/classes/share/javax/media/j3d/NoopPipeline.java index 6b57dbc..66726f4 100644 --- a/src/classes/share/javax/media/j3d/NoopPipeline.java +++ b/src/classes/share/javax/media/j3d/NoopPipeline.java @@ -108,7 +108,7 @@ class NoopPipeline extends Pipeline { float[] cfdata, byte[] cbdata, int normalIndex, FloatBuffer ndata, int vertexAttrCount, int[] vertexAttrSizes, - int[] vertexAttrIndex, Object[] vertexAttrData, + int[] vertexAttrIndex, FloatBuffer[] vertexAttrData, int texcoordmaplength, int[] texcoordoffset, int numActiveTexUnitState, @@ -255,7 +255,7 @@ class NoopPipeline extends Pipeline { float[] cfdata, byte[] cbdata, FloatBuffer normal, int vertexAttrCount, int[] vertexAttrSizes, - Object[] vertexAttrData, + FloatBuffer[] vertexAttrData, int texcoordmaplength, int[] texcoordoffset, int numActiveTexUnitState, diff --git a/src/classes/share/javax/media/j3d/Pipeline.java b/src/classes/share/javax/media/j3d/Pipeline.java index bcfad61..b42cf13 100644 --- a/src/classes/share/javax/media/j3d/Pipeline.java +++ b/src/classes/share/javax/media/j3d/Pipeline.java @@ -205,7 +205,7 @@ public Pipeline run() { float[] cfdata, byte[] cbdata, int normalIndex, FloatBuffer ndata, int vertexAttrCount, int[] vertexAttrSizes, - int[] vertexAttrIndex, Object[] vertexAttrData, + int[] vertexAttrIndex, FloatBuffer[] vertexAttrData, int texcoordmaplength, int[] texcoordoffset, int numActiveTexUnitState, @@ -364,7 +364,7 @@ public Pipeline run() { float[] cfdata, byte[] cbdata, FloatBuffer normal, int vertexAttrCount, int[] vertexAttrSizes, - Object[] vertexAttrData, + FloatBuffer[] vertexAttrData, int texcoordmaplength, int[] texcoordoffset, int numActiveTexUnitState, |