mirror of
https://github.com/androidx/media.git
synced 2025-05-16 03:59:54 +08:00
Add GlUtil createBuffer overload which doesn't copy values
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=217846755
This commit is contained in:
parent
1ef3efaa90
commit
8f3c3e2841
@ -95,14 +95,23 @@ public final class GlUtil {
|
||||
return program;
|
||||
}
|
||||
|
||||
/** Allocates a FloatBuffer with the given data. */
|
||||
/**
|
||||
* Allocates a FloatBuffer with the given data.
|
||||
*
|
||||
* @param data Used to initialize the new buffer.
|
||||
*/
|
||||
public static FloatBuffer createBuffer(float[] data) {
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(data.length * C.BYTES_PER_FLOAT);
|
||||
byteBuffer.order(ByteOrder.nativeOrder());
|
||||
FloatBuffer buffer = byteBuffer.asFloatBuffer();
|
||||
buffer.put(data);
|
||||
buffer.flip();
|
||||
return buffer;
|
||||
return (FloatBuffer) createBuffer(data.length).put(data).flip();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a FloatBuffer.
|
||||
*
|
||||
* @param capacity The new buffer's capacity, in floats.
|
||||
*/
|
||||
public static FloatBuffer createBuffer(int capacity) {
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(capacity * C.BYTES_PER_FLOAT);
|
||||
return byteBuffer.order(ByteOrder.nativeOrder()).asFloatBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user