aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/nio/PointerBuffer.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-06-25 09:31:04 +0200
committerSven Gothel <[email protected]>2013-06-25 09:31:04 +0200
commitc28d5c8d0d83670a548671a1d0da55e3447ea0c7 (patch)
treed13acf6876a404389821c2a7beb900c5962889d3 /src/java/com/jogamp/common/nio/PointerBuffer.java
parent72f60a534db7c0b731d4dca83481679817ad7574 (diff)
Refine commit 5e01e993aeba4e95fc8aa6e75b3e295011e27bbb, skip Buffers.sizeOfBufferElem(..) call.
Diffstat (limited to 'src/java/com/jogamp/common/nio/PointerBuffer.java')
-rw-r--r--src/java/com/jogamp/common/nio/PointerBuffer.java15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/java/com/jogamp/common/nio/PointerBuffer.java b/src/java/com/jogamp/common/nio/PointerBuffer.java
index f05c6ad..df1c4b1 100644
--- a/src/java/com/jogamp/common/nio/PointerBuffer.java
+++ b/src/java/com/jogamp/common/nio/PointerBuffer.java
@@ -57,18 +57,18 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> {
}
/** no backup array, use for direct usage only */
- PointerBuffer(ByteBuffer bb) {
- super(Platform.is32Bit() ? bb.asIntBuffer() : bb.asLongBuffer(), ELEMENT_SIZE);
+ static PointerBuffer create(ByteBuffer bb) {
+ return Platform.is32Bit() ? new PointerBuffer( bb.asIntBuffer() ) : new PointerBuffer( bb.asLongBuffer() );
}
/** supports backup array */
PointerBuffer(IntBuffer b) {
- super(b, ELEMENT_SIZE);
+ super(b, ELEMENT_SIZE, b.capacity());
}
/** supports backup array */
PointerBuffer(LongBuffer b) {
- super(b, ELEMENT_SIZE);
+ super(b, ELEMENT_SIZE, b.capacity());
}
private final void validateDataMap() {
@@ -89,16 +89,16 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> {
/** Returns a direct PointerBuffer in native order, w/o backup array */
public static PointerBuffer allocateDirect(int size) {
- return new PointerBuffer(Buffers.newDirectByteBuffer(ELEMENT_SIZE * size));
+ return create(Buffers.newDirectByteBuffer(ELEMENT_SIZE * size));
}
public static PointerBuffer wrap(ByteBuffer src) {
- return new PointerBuffer(src);
+ return create(src);
}
/**
* @return new PointerBuffer sharing the same buffer data of this instance (identity),
- * but having independent position, limit and capacity.
+ * but having an independent position.
*/
public final PointerBuffer duplicate() {
PointerBuffer npb;
@@ -110,7 +110,6 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> {
if(null != dataMap) {
npb.dataMap = (LongObjectHashMap) dataMap.clone();
}
- npb.capacity = capacity;
npb.position = position;
return npb;
}