java.lang.Object | |
↳ | com.facebook.imagepipeline.memory.BufferMemoryChunk |
Wrapper around chunk using a direct ByteBuffer in native memory. A direct ByteBuffer is composed of a Java ByteBuffer object allocated on the Java heap and the underlying buffer which is in native memory.
The buffer in native memory will be released when the Java object gets garbage collected.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
BufferMemoryChunk(int size) |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
synchronized void |
close()
This has to be called before we get rid of this object in order to release underlying memory
| ||||||||||
void |
copy(int offset, MemoryChunk other, int otherOffset, int count)
Copy bytes from buffer memory wrapped by this MemoryChunk instance to buffer memory wrapped by
another MemoryChunk.
| ||||||||||
synchronized ByteBuffer |
getByteBuffer()
Gets the ByteBuffer associated with the memory chunk if available, else null.
| ||||||||||
long |
getNativePtr()
Gets the pointer the native memory.
| ||||||||||
int |
getSize()
Get the size of this memory chunk.
| ||||||||||
long |
getUniqueId()
Gets the unique identifier associated with the memory chunk.
| ||||||||||
synchronized boolean |
isClosed()
Check if this chunk is already closed
| ||||||||||
synchronized int |
read(int memoryOffset, byte[] byteArray, int byteArrayOffset, int count)
Copy bytes from memory to byte array.
| ||||||||||
synchronized byte |
read(int offset)
Read byte at given offset.
| ||||||||||
synchronized int |
write(int memoryOffset, byte[] byteArray, int byteArrayOffset, int count)
Copy bytes from byte array to buffer.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
com.facebook.imagepipeline.memory.MemoryChunk
| |||||||||||
From interface
java.io.Closeable
| |||||||||||
From interface
java.lang.AutoCloseable
|
This has to be called before we get rid of this object in order to release underlying memory
Copy bytes from buffer memory wrapped by this MemoryChunk instance to buffer memory wrapped by another MemoryChunk. The two MemoryChunks should have the same type.
offset | number of first byte to copy |
---|---|
other | other MemoryChunk to copy to |
otherOffset | number of first byte to write to |
count | number of bytes to copy |
Gets the ByteBuffer associated with the memory chunk if available, else null.
Gets the pointer the native memory.
Get the size of this memory chunk. Ignores if this chunk has been closed
Gets the unique identifier associated with the memory chunk.
Check if this chunk is already closed
Copy bytes from memory to byte array.
memoryOffset | number of first byte to copy |
---|---|
byteArray | byte array to copy to |
byteArrayOffset | number of first byte in byte array to be written |
count | number of bytes to copy |
Read byte at given offset.
offset | The offset from which the byte will be read |
---|
Copy bytes from byte array to buffer.
memoryOffset | number of first byte to be written by copy operation |
---|---|
byteArray | byte array to copy from |
byteArrayOffset | number of first byte in byteArray to copy |
count | number of bytes to copy |