summaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-10-18 08:53:19 +0200
committerSven Gothel <[email protected]>2012-10-18 08:53:19 +0200
commitfebd5421a3e00673bd43cecd19aaa088eafb99e7 (patch)
tree0cae6cdb411a2d6ccce15a17b090cc4b0363704f /src/java
parent73e8828566404e864170688dfb4fd530a83f8add (diff)
Fix Buffers.copy<Type>Buffer[asByteBuffer](..): Reset position of the passed buffer (was missing).
This is an API regression as introduced in commit 25cc744f6bd5ca97e0ae58fa7e1c35f7b0f3046d where JOGL's BufferUtil and GlueGen's were merged and API doc elaborated. The latter states the desired fact that the source passed buffer's position shall remain unchanged, however no code was added to take care of this detail.
Diffstat (limited to 'src/java')
-rwxr-xr-xsrc/java/com/jogamp/common/nio/Buffers.java29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/java/com/jogamp/common/nio/Buffers.java b/src/java/com/jogamp/common/nio/Buffers.java
index 07a73b1..3da1261 100755
--- a/src/java/com/jogamp/common/nio/Buffers.java
+++ b/src/java/com/jogamp/common/nio/Buffers.java
@@ -465,13 +465,14 @@ public class Buffers {
* a newly-allocated direct ByteBuffer. The returned buffer will
* have its byte order set to the host platform's native byte
* order. The position of the newly-allocated buffer will be zero,
- * and the position of the passed buffer is unchanged (though its
- * mark is changed).
+ * and the position of the passed buffer is unchanged.
*/
public static ByteBuffer copyByteBuffer(ByteBuffer orig) {
+ final int op0 = orig.position();
ByteBuffer dest = newDirectByteBuffer(orig.remaining());
dest.put(orig);
dest.rewind();
+ orig.position(op0);
return dest;
}
@@ -481,8 +482,7 @@ public class Buffers {
* into a newly-allocated direct FloatBuffer. The returned buffer
* will have its byte order set to the host platform's native byte
* order. The position of the newly-allocated buffer will be zero,
- * and the position of the passed buffer is unchanged (though its
- * mark is changed).
+ * and the position of the passed buffer is unchanged.
*/
public static FloatBuffer copyFloatBuffer(FloatBuffer orig) {
return copyFloatBufferAsByteBuffer(orig).asFloatBuffer();
@@ -494,8 +494,7 @@ public class Buffers {
* into a newly-allocated direct IntBuffer. The returned buffer
* will have its byte order set to the host platform's native byte
* order. The position of the newly-allocated buffer will be zero,
- * and the position of the passed buffer is unchanged (though its
- * mark is changed).
+ * and the position of the passed buffer is unchanged.
*/
public static IntBuffer copyIntBuffer(IntBuffer orig) {
return copyIntBufferAsByteBuffer(orig).asIntBuffer();
@@ -507,8 +506,7 @@ public class Buffers {
* into a newly-allocated direct ShortBuffer. The returned buffer
* will have its byte order set to the host platform's native byte
* order. The position of the newly-allocated buffer will be zero,
- * and the position of the passed buffer is unchanged (though its
- * mark is changed).
+ * and the position of the passed buffer is unchanged.
*/
public static ShortBuffer copyShortBuffer(ShortBuffer orig) {
return copyShortBufferAsByteBuffer(orig).asShortBuffer();
@@ -523,13 +521,14 @@ public class Buffers {
* into a newly-allocated direct ByteBuffer. The returned buffer
* will have its byte order set to the host platform's native byte
* order. The position of the newly-allocated buffer will be zero,
- * and the position of the passed buffer is unchanged (though its
- * mark is changed).
+ * and the position of the passed buffer is unchanged.
*/
public static ByteBuffer copyFloatBufferAsByteBuffer(FloatBuffer orig) {
+ final int op0 = orig.position();
ByteBuffer dest = newDirectByteBuffer(orig.remaining() * SIZEOF_FLOAT);
dest.asFloatBuffer().put(orig);
dest.rewind();
+ orig.position(op0);
return dest;
}
@@ -539,13 +538,14 @@ public class Buffers {
* a newly-allocated direct ByteBuffer. The returned buffer will
* have its byte order set to the host platform's native byte
* order. The position of the newly-allocated buffer will be zero,
- * and the position of the passed buffer is unchanged (though its
- * mark is changed).
+ * and the position of the passed buffer is unchanged.
*/
public static ByteBuffer copyIntBufferAsByteBuffer(IntBuffer orig) {
+ final int op0 = orig.position();
ByteBuffer dest = newDirectByteBuffer(orig.remaining() * SIZEOF_INT);
dest.asIntBuffer().put(orig);
dest.rewind();
+ orig.position(op0);
return dest;
}
@@ -555,13 +555,14 @@ public class Buffers {
* into a newly-allocated direct ByteBuffer. The returned buffer
* will have its byte order set to the host platform's native byte
* order. The position of the newly-allocated buffer will be zero,
- * and the position of the passed buffer is unchanged (though its
- * mark is changed).
+ * and the position of the passed buffer is unchanged.
*/
public static ByteBuffer copyShortBufferAsByteBuffer(ShortBuffer orig) {
+ final int op0 = orig.position();
ByteBuffer dest = newDirectByteBuffer(orig.remaining() * SIZEOF_SHORT);
dest.asShortBuffer().put(orig);
dest.rewind();
+ orig.position(op0);
return dest;
}