diff options
Diffstat (limited to 'rs/java/android/renderscript/RenderScript.java')
-rw-r--r-- | rs/java/android/renderscript/RenderScript.java | 68 |
1 files changed, 47 insertions, 21 deletions
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java index 3668ddd62303..9beaba301072 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. @@ -97,13 +98,6 @@ public class RenderScript { */ public static final int CREATE_FLAG_WAIT_FOR_ATTACH = 0x0008; - /** - * @hide - * Context creation flag which specifies that optimization level 0 is - * passed to the device compiler upon execution of the RenderScript kernel. - * The default optimization level is 3. - */ - public static final int CREATE_FLAG_OPT_LEVEL_0 = 0x0010; /* * Detect the bitness of the VM to allow FieldPacker to do the right thing. @@ -483,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(); @@ -504,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(); @@ -1378,6 +1387,27 @@ public class RenderScript { } /** + * Name of the file that holds the object cache. + */ + private static String mCachePath; + + /** + * Gets the path to the code cache. + */ + static synchronized String getCachePath() { + if (mCachePath == null) { + final String CACHE_PATH = "com.android.renderscript.cache"; + if (RenderScriptCacheDir.mCacheDir == null) { + throw new RSRuntimeException("RenderScript code cache directory uninitialized."); + } + File f = new File(RenderScriptCacheDir.mCacheDir, CACHE_PATH); + mCachePath = f.getAbsolutePath(); + f.mkdirs(); + } + return mCachePath; + } + + /** * Create a RenderScript context. * * @param ctx The context. @@ -1390,7 +1420,7 @@ public class RenderScript { } if ((flags & ~(CREATE_FLAG_LOW_LATENCY | CREATE_FLAG_LOW_POWER | - CREATE_FLAG_WAIT_FOR_ATTACH | CREATE_FLAG_OPT_LEVEL_0)) != 0) { + CREATE_FLAG_WAIT_FOR_ATTACH)) != 0) { throw new RSIllegalArgumentException("Invalid flags passed."); } @@ -1406,11 +1436,7 @@ public class RenderScript { } // set up cache directory for entire context - final String CACHE_PATH = "com.android.renderscript.cache"; - File f = new File(RenderScriptCacheDir.mCacheDir, CACHE_PATH); - String mCachePath = f.getAbsolutePath(); - f.mkdirs(); - rs.nContextSetCacheDir(mCachePath); + rs.nContextSetCacheDir(RenderScript.getCachePath()); rs.mMessageThread = new MessageThread(rs); rs.mMessageThread.start(); |