diff options
Diffstat (limited to 'rs/java/android/renderscript/RenderScript.java')
-rw-r--r-- | rs/java/android/renderscript/RenderScript.java | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java index 425569cd8fa1..2650e5a868d2 100644 --- a/rs/java/android/renderscript/RenderScript.java +++ b/rs/java/android/renderscript/RenderScript.java @@ -1031,7 +1031,6 @@ public class RenderScript { - long mDev; long mContext; private boolean mDestroyed = false; @@ -1387,6 +1386,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. @@ -1405,8 +1425,8 @@ public class RenderScript { RenderScript rs = new RenderScript(ctx); - rs.mDev = rs.nDeviceCreate(); - rs.mContext = rs.nContextCreate(rs.mDev, flags, sdkVersion, ct.mID); + long device = rs.nDeviceCreate(); + rs.mContext = rs.nContextCreate(device, flags, sdkVersion, ct.mID); rs.mContextType = ct; rs.mContextFlags = flags; rs.mContextSdkVersion = sdkVersion; @@ -1415,11 +1435,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(); @@ -1618,9 +1634,6 @@ public class RenderScript { } nContextDestroy(); - - nDeviceDestroy(mDev); - mDev = 0; } } |