diff options
author | Miao Wang <miaowang@google.com> | 2015-11-25 11:21:13 -0800 |
---|---|---|
committer | Miao Wang <miaowang@google.com> | 2016-01-25 16:12:37 -0800 |
commit | 0facf021ea1a0399d956372b9d3ad9025a9a04d2 (patch) | |
tree | 158e05cbc7e58d435a2b242503b4cf5430cc55eb /rs/java/android/renderscript/RenderScript.java | |
parent | 9e892f53dd489c824b6a39c45028f838123daa85 (diff) |
[RenderScript] Add API to map Allocation mallocptr to Java ByteBuffer
Bug: 25926361
Bug: 23535524
- Construct the ByteBuffer using the AllocationGetPointer.
- Add an API to query the stride of the allocation.
- Both ByteBuffer and Stride will be cached for normal Allocations.
if using USAGE_IO, since after each ioReceive, the mallocPtr will
change, getByteBuffer will always create a new one using the most
up-to-date mallocPtr.
Change-Id: I5e84b6690e83bb062c383043275524d0e51e46eb
Diffstat (limited to 'rs/java/android/renderscript/RenderScript.java')
-rw-r--r-- | rs/java/android/renderscript/RenderScript.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java index 7eb80055c4d5..261a8a99e9b6 100644 --- a/rs/java/android/renderscript/RenderScript.java +++ b/rs/java/android/renderscript/RenderScript.java @@ -18,17 +18,18 @@ package android.renderscript; import java.io.File; import java.lang.reflect.Method; +import java.nio.ByteBuffer; +import java.util.ArrayList; import java.util.concurrent.locks.ReentrantReadWriteLock; import android.content.Context; import android.content.res.AssetManager; import android.graphics.Bitmap; import android.graphics.SurfaceTexture; -import android.util.Log; -import android.view.Surface; import android.os.SystemProperties; import android.os.Trace; -import java.util.ArrayList; +import android.util.Log; +import android.view.Surface; // TODO: Clean up the whitespace that separates methods in this class. @@ -489,6 +490,13 @@ public class RenderScript { validate(); rsnAllocationSyncAll(mContext, alloc, src); } + + native ByteBuffer rsnAllocationGetByteBuffer(long con, long alloc, long[] stride, int xBytesSize, int dimY, int dimZ); + synchronized ByteBuffer nAllocationGetByteBuffer(long alloc, long[] stride, int xBytesSize, int dimY, int dimZ) { + validate(); + return rsnAllocationGetByteBuffer(mContext, alloc, stride, xBytesSize, dimY, dimZ); + } + native Surface rsnAllocationGetSurface(long con, long alloc); synchronized Surface nAllocationGetSurface(long alloc) { validate(); |