|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.utils.BufferUtils
public class BufferUtils
Class with static helper methods to increase the speed of array/direct buffer and direct buffer/direct buffer transfers
Constructor Summary | |
---|---|
BufferUtils()
|
Method Summary | |
---|---|
static void |
clear(java.nio.ByteBuffer buffer,
int numBytes)
Writes the specified number of zeros to the buffer. |
static void |
copy(java.nio.Buffer src,
java.nio.Buffer dst,
int numElements)
Copies the contents of src to dst, starting from the current position of src, copying numElements elements (using the data type of src, no matter the datatype of dst). |
static void |
copy(byte[] src,
int srcOffset,
java.nio.Buffer dst,
int numElements)
Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements. |
static void |
copy(char[] src,
int srcOffset,
java.nio.Buffer dst,
int numElements)
Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements. |
static void |
copy(double[] src,
int srcOffset,
java.nio.Buffer dst,
int numElements)
Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements. |
static void |
copy(float[] src,
java.nio.Buffer dst,
int numFloats,
int offset)
Copies numFloats floats from src starting at offset to dst. |
static void |
copy(float[] src,
int srcOffset,
java.nio.Buffer dst,
int numElements)
Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements. |
static void |
copy(int[] src,
int srcOffset,
java.nio.Buffer dst,
int numElements)
Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements. |
static void |
copy(long[] src,
int srcOffset,
java.nio.Buffer dst,
int numElements)
Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements. |
static void |
copy(short[] src,
int srcOffset,
java.nio.Buffer dst,
int numElements)
Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements. |
static void |
disposeUnsafeByteBuffer(java.nio.ByteBuffer buffer)
|
static int |
getAllocatedBytesUnsafe()
|
static long |
getUnsafeBufferAddress(java.nio.Buffer buffer)
Returns the address of the Buffer, it assumes it is an unsafe buffer. |
static java.nio.ByteBuffer |
newByteBuffer(int numBytes)
|
static java.nio.CharBuffer |
newCharBuffer(int numChars)
|
static java.nio.DoubleBuffer |
newDoubleBuffer(int numDoubles)
|
static java.nio.FloatBuffer |
newFloatBuffer(int numFloats)
|
static java.nio.IntBuffer |
newIntBuffer(int numInts)
|
static java.nio.LongBuffer |
newLongBuffer(int numLongs)
|
static java.nio.ShortBuffer |
newShortBuffer(int numShorts)
|
static java.nio.ByteBuffer |
newUnsafeByteBuffer(java.nio.ByteBuffer buffer)
Registers the given ByteBuffer as an unsafe ByteBuffer. |
static java.nio.ByteBuffer |
newUnsafeByteBuffer(int numBytes)
Allocates a new direct ByteBuffer from native heap memory using the native byte order. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BufferUtils()
Method Detail |
---|
public static void copy(float[] src, java.nio.Buffer dst, int numFloats, int offset)
Buffer
. The method will
crash if that is not the case. The position and limit of the buffer are ignored, the copy is placed at position 0 in the
buffer. After the copying process the position of the buffer is set to 0 and its limit is set to numFloats * 4 if it is a
ByteBuffer and numFloats if it is a FloatBuffer. In case the Buffer is neither a ByteBuffer nor a FloatBuffer the limit is
not set. This is an expert method, use at your own risk.
src
- the source arraydst
- the destination buffer, has to be a direct BuffernumFloats
- the number of floats to copyoffset
- the offset in src to start copying frompublic static void copy(byte[] src, int srcOffset, java.nio.Buffer dst, int numElements)
Buffer
instance's
Buffer.position()
is used to define the offset into the Buffer itself. The position will stay the same, the limit
will be set to position + numElements. The Buffer must be a direct Buffer with native byte order. No error checking is
performed.
src
- the source array.srcOffset
- the offset into the source array.dst
- the destination Buffer, its position is used as an offset.numElements
- the number of elements to copy.public static void copy(short[] src, int srcOffset, java.nio.Buffer dst, int numElements)
Buffer
instance's
Buffer.position()
is used to define the offset into the Buffer itself. The position will stay the same, the limit
will be set to position + numElements. The Buffer must be a direct Buffer with native byte order. No error checking is
performed.
src
- the source array.srcOffset
- the offset into the source array.dst
- the destination Buffer, its position is used as an offset.numElements
- the number of elements to copy.public static void copy(char[] src, int srcOffset, java.nio.Buffer dst, int numElements)
Buffer
instance's
Buffer.position()
is used to define the offset into the Buffer itself. The position will stay the same, the limit
will be set to position + numElements. The Buffer must be a direct Buffer with native byte order. No error checking is
performed.
src
- the source array.srcOffset
- the offset into the source array.dst
- the destination Buffer, its position is used as an offset.numElements
- the number of elements to copy.public static void copy(int[] src, int srcOffset, java.nio.Buffer dst, int numElements)
Buffer
instance's
Buffer.position()
is used to define the offset into the Buffer itself. The position will stay the same, the limit
will be set to position + numElements. The Buffer must be a direct Buffer with native byte order. No error checking is
performed.
src
- the source array.srcOffset
- the offset into the source array.dst
- the destination Buffer, its position is used as an offset.numElements
- the number of elements to copy.public static void copy(long[] src, int srcOffset, java.nio.Buffer dst, int numElements)
Buffer
instance's
Buffer.position()
is used to define the offset into the Buffer itself. The position will stay the same, the limit
will be set to position + numElements. The Buffer must be a direct Buffer with native byte order. No error checking is
performed.
src
- the source array.srcOffset
- the offset into the source array.dst
- the destination Buffer, its position is used as an offset.numElements
- the number of elements to copy.public static void copy(float[] src, int srcOffset, java.nio.Buffer dst, int numElements)
Buffer
instance's
Buffer.position()
is used to define the offset into the Buffer itself. The position will stay the same, the limit
will be set to position + numElements. The Buffer must be a direct Buffer with native byte order. No error checking is
performed.
src
- the source array.srcOffset
- the offset into the source array.dst
- the destination Buffer, its position is used as an offset.numElements
- the number of elements to copy.public static void copy(double[] src, int srcOffset, java.nio.Buffer dst, int numElements)
Buffer
instance's
Buffer.position()
is used to define the offset into the Buffer itself. The position will stay the same, the limit
will be set to position + numElements. The Buffer must be a direct Buffer with native byte order. No error checking is
performed.
src
- the source array.srcOffset
- the offset into the source array.dst
- the destination Buffer, its position is used as an offset.numElements
- the number of elements to copy.public static void copy(java.nio.Buffer src, java.nio.Buffer dst, int numElements)
Buffer.position()
is used as the writing offset. The position
of both Buffers will stay the same. The limit of the src Buffer will stay the same. The limit of the dst Buffer will be set
to dst.position() + numElements, where numElements are translated to the number of elements appropriate for the dst Buffer
data type. The Buffers must be direct Buffers with native byte order. No error checking is performed.
src
- the source Buffer.dst
- the destination Buffer.numElements
- the number of elements to copy.public static java.nio.FloatBuffer newFloatBuffer(int numFloats)
public static java.nio.DoubleBuffer newDoubleBuffer(int numDoubles)
public static java.nio.ByteBuffer newByteBuffer(int numBytes)
public static java.nio.ShortBuffer newShortBuffer(int numShorts)
public static java.nio.CharBuffer newCharBuffer(int numChars)
public static java.nio.IntBuffer newIntBuffer(int numInts)
public static java.nio.LongBuffer newLongBuffer(int numLongs)
public static void disposeUnsafeByteBuffer(java.nio.ByteBuffer buffer)
public static java.nio.ByteBuffer newUnsafeByteBuffer(int numBytes)
freeMemory(ByteBuffer)
.
numBytes
- public static long getUnsafeBufferAddress(java.nio.Buffer buffer)
buffer
- The Buffer to ask the address for.
public static java.nio.ByteBuffer newUnsafeByteBuffer(java.nio.ByteBuffer buffer)
freeMemory(ByteBuffer)
.
buffer
- the ByteBuffer
to register
public static int getAllocatedBytesUnsafe()
newUnsafeByteBuffer(int)
public static void clear(java.nio.ByteBuffer buffer, int numBytes)
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |