diff options
author | Yang Ni <yangni@google.com> | 2016-03-21 19:58:24 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-03-21 19:58:25 +0000 |
commit | 60fa615cfc035fee38fe0a19de303457246e0b1f (patch) | |
tree | 4700f2c2efc53d704b3450211dab9035b5f57281 /rs/java/android/renderscript/RenderScript.java | |
parent | bdddbdf18439faa71393f368b6ff5b142a876644 (diff) | |
parent | 689f63770048589e1001ce99faf1d2eaf9780a80 (diff) |
Merge "Correctly init code cache path for RS"
Diffstat (limited to 'rs/java/android/renderscript/RenderScript.java')
-rw-r--r-- | rs/java/android/renderscript/RenderScript.java | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java index 425569cd8fa1..9beaba301072 100644 --- a/rs/java/android/renderscript/RenderScript.java +++ b/rs/java/android/renderscript/RenderScript.java @@ -1387,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. @@ -1415,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(); |