On Android platform (API-19) I would like to copy a direct byte buffer into a render script allocation. Is it possible to improve the following code, for example by using NDK?
final ByteBuffer buffer = ...src;
final byte[] bytes;
if (buffer.hasArray()) {
bytes = buffer.array();
} else {
bytes = new byte[buffer.capacity()];
buffer.get(bytes);
buffer.rewind();
}
allocation.copyFromUnchecked(bytes);
Unfortunately, no. The APIs are not constructed where you can provide the backing data store for the Allocation or even retrieve an NIO based buffer that the Allocation created. The closest thing you could use would be to have a Bitmap based Allocation which was created with USAGE_SHARED so it could be sync'd as differences rather than a full copy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With