From c5a56e10677e9dc0a048c2be3de16701aac9ad17 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 1 May 2011 07:37:05 +0200 Subject: PointerBuffer: Add duplicate() method (as req by JOCL) --- src/java/com/jogamp/common/nio/PointerBuffer.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/java') diff --git a/src/java/com/jogamp/common/nio/PointerBuffer.java b/src/java/com/jogamp/common/nio/PointerBuffer.java index 69f8bbd..089b8b1 100644 --- a/src/java/com/jogamp/common/nio/PointerBuffer.java +++ b/src/java/com/jogamp/common/nio/PointerBuffer.java @@ -97,6 +97,25 @@ public class PointerBuffer extends AbstractBuffer { return new PointerBuffer(src); } + /** + * @return new PointerBuffer sharing the same buffer data of this instance (identity), + * but having independent position, limit and capacity. + */ + public final PointerBuffer duplicate() { + PointerBuffer npb; + if (Platform.is32Bit()) { + npb = new PointerBuffer((IntBuffer)buffer); + } else { + npb = new PointerBuffer((LongBuffer)buffer); + } + if(null != dataMap) { + npb.dataMap = (LongObjectHashMap) dataMap.clone(); + } + npb.capacity = capacity; + npb.position = position; + return npb; + } + /** * Relative bulk get method. Copy the source values src[position .. capacity] [ * to this buffer and increment the position by capacity-position. */ -- cgit v1.2.3