summaryrefslogtreecommitdiff
path: root/rs/java/android/renderscript/RenderScript.java
diff options
context:
space:
mode:
Diffstat (limited to 'rs/java/android/renderscript/RenderScript.java')
-rw-r--r--rs/java/android/renderscript/RenderScript.java89
1 files changed, 67 insertions, 22 deletions
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
index 4d53c8d94c65..425569cd8fa1 100644
--- a/rs/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -18,18 +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.os.Process;
-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.
@@ -142,16 +142,31 @@ public class RenderScript {
// this should be a monotonically increasing ID
// used in conjunction with the API version of a device
- static final long sMinorID = 1;
+ static final long sMinorVersion = 1;
+
+ /**
+ * @hide
+ *
+ * Only exist to be compatible with old version RenderScript Support lib.
+ * Will eventually be removed.
+ *
+ * @return Always return 1
+ *
+ */
+ public static long getMinorID() {
+ return 1;
+ }
+
/**
* Returns an identifier that can be used to identify a particular
* minor version of RS.
*
- * @hide
+ * @return The minor RenderScript version number
+ *
*/
- public static long getMinorID() {
- return sMinorID;
+ public static long getMinorVersion() {
+ return sMinorVersion;
}
/**
@@ -462,12 +477,28 @@ public class RenderScript {
rsnAllocationCopyToBitmap(mContext, alloc, bmp);
}
-
native void rsnAllocationSyncAll(long con, long alloc, int src);
synchronized void nAllocationSyncAll(long alloc, int src) {
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 void rsnAllocationSetupBufferQueue(long con, long alloc, int numAlloc);
+ synchronized void nAllocationSetupBufferQueue(long alloc, int numAlloc) {
+ validate();
+ rsnAllocationSetupBufferQueue(mContext, alloc, numAlloc);
+ }
+ native void rsnAllocationShareBufferQueue(long con, long alloc1, long alloc2);
+ synchronized void nAllocationShareBufferQueue(long alloc1, long alloc2) {
+ validate();
+ rsnAllocationShareBufferQueue(mContext, alloc1, alloc2);
+ }
native Surface rsnAllocationGetSurface(long con, long alloc);
synchronized Surface nAllocationGetSurface(long alloc) {
validate();
@@ -483,13 +514,12 @@ public class RenderScript {
validate();
rsnAllocationIoSend(mContext, alloc);
}
- native void rsnAllocationIoReceive(long con, long alloc);
- synchronized void nAllocationIoReceive(long alloc) {
+ native long rsnAllocationIoReceive(long con, long alloc);
+ synchronized long nAllocationIoReceive(long alloc) {
validate();
- rsnAllocationIoReceive(mContext, alloc);
+ return rsnAllocationIoReceive(mContext, alloc);
}
-
native void rsnAllocationGenerateMipmaps(long con, long alloc);
synchronized void nAllocationGenerateMipmaps(long alloc) {
validate();
@@ -730,6 +760,14 @@ public class RenderScript {
rsnScriptReduce(mContext, id, slot, ain, aout, limits);
}
+ native void rsnScriptReduceNew(long con, long id, int slot, long[] ains,
+ long aout, int[] limits);
+ synchronized void nScriptReduceNew(long id, int slot, long ains[], long aout,
+ int[] limits) {
+ validate();
+ rsnScriptReduceNew(mContext, id, slot, ains, aout, limits);
+ }
+
native void rsnScriptInvokeV(long con, long id, int slot, byte[] params);
synchronized void nScriptInvokeV(long id, int slot, byte[] params) {
validate();
@@ -1351,7 +1389,6 @@ public class RenderScript {
/**
* Create a RenderScript context.
*
- * @hide
* @param ctx The context.
* @return RenderScript
*/
@@ -1457,14 +1494,13 @@ public class RenderScript {
/**
* Gets or creates a RenderScript context of the specified type.
*
- * @hide
* @param ctx The context.
* @param ct The type of context to be created.
* @param sdkVersion The target SDK Version.
* @param flags The OR of the CREATE_FLAG_* options desired
* @return RenderScript
*/
- public static RenderScript create(Context ctx, int sdkVersion, ContextType ct, int flags) {
+ private static RenderScript create(Context ctx, int sdkVersion, ContextType ct, int flags) {
if (sdkVersion < 23) {
return internalCreate(ctx, sdkVersion, ct, flags);
}
@@ -1487,8 +1523,6 @@ public class RenderScript {
}
/**
- * @hide
- *
* Releases all the process contexts. This is the same as
* calling .destroy() on each unique context retreived with
* create(...). If no contexts have been created this
@@ -1525,7 +1559,6 @@ public class RenderScript {
*
* If you need a single context please use create()
*
- * @hide
* @param ctx The context.
* @return RenderScript
*/
@@ -1567,9 +1600,21 @@ public class RenderScript {
nContextDeinitToClient(mContext);
mMessageThread.mRun = false;
- try {
- mMessageThread.join();
- } catch(InterruptedException e) {
+
+ // Wait for mMessageThread to join. Try in a loop, in case this thread gets interrupted
+ // during the wait. If interrupted, set the "interrupted" status of the current thread.
+ boolean hasJoined = false, interrupted = false;
+ while (!hasJoined) {
+ try {
+ mMessageThread.join();
+ hasJoined = true;
+ } catch (InterruptedException e) {
+ interrupted = true;
+ }
+ }
+ if (interrupted) {
+ Log.v(LOG_TAG, "Interrupted during wait for MessageThread to join");
+ Thread.currentThread().interrupt();
}
nContextDestroy();