diff options
Diffstat (limited to 'rs/java/android/renderscript/RenderScript.java')
-rw-r--r-- | rs/java/android/renderscript/RenderScript.java | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java index e8e942c8db8d..5fc1f93cb653 100644 --- a/rs/java/android/renderscript/RenderScript.java +++ b/rs/java/android/renderscript/RenderScript.java @@ -129,8 +129,6 @@ public class RenderScript { native void nContextInitToClient(long con); native void nContextDeinitToClient(long con); - static File mCacheDir; - // this should be a monotonically increasing ID // used in conjunction with the API version of a device static final long sMinorID = 1; @@ -139,29 +137,13 @@ public class RenderScript { * 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; } - /** - * Sets the directory to use as a persistent storage for the - * renderscript object file cache. - * - * @hide - * @param cacheDir A directory the current process can write to - */ - public static void setupDiskCache(File cacheDir) { - if (!sInitialized) { - Log.e(LOG_TAG, "RenderScript.setupDiskCache() called when disabled"); - return; - } - - // Defer creation of cache path to nScriptCCreate(). - mCacheDir = cacheDir; - } - /** * ContextType specifies the specific type of context to be created. * @@ -250,6 +232,11 @@ public class RenderScript { validate(); rsnContextSetPriority(mContext, p); } + native void rsnContextSetCacheDir(long con, String cacheDir); + synchronized void nContextSetCacheDir(String cacheDir) { + validate(); + rsnContextSetCacheDir(mContext, cacheDir); + } native void rsnContextDump(long con, int bits); synchronized void nContextDump(int bits) { validate(); @@ -1321,7 +1308,6 @@ public class RenderScript { /** * Create a RenderScript context. * - * @hide * @param ctx The context. * @return RenderScript */ @@ -1345,6 +1331,14 @@ public class RenderScript { if (rs.mContext == 0) { throw new RSDriverException("Failed to create RS context."); } + + // 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.mMessageThread = new MessageThread(rs); rs.mMessageThread.start(); return rs; @@ -1418,14 +1412,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); } @@ -1448,8 +1441,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 @@ -1486,7 +1477,6 @@ public class RenderScript { * * If you need a single context please use create() * - * @hide * @param ctx The context. * @return RenderScript */ |