summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Stephen Hines <srhines@google.com> 2013-04-10 17:17:50 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2013-04-10 17:17:51 +0000
commit439752d484b93efff52bc4e95c96a0be86c87f1e (patch)
treecb8f669e2a6d8ddf2cfc2dbfb51750e00410ecec
parent8515256ad477721a97108745da4c86f378f50637 (diff)
parent7d25a829d3da96fb6ac0d285aa1bfb2022271bee (diff)
Merge "Defer RS cache creation until a ScriptC is built." into jb-mr2-dev
-rw-r--r--graphics/java/android/renderscript/RenderScript.java11
-rw-r--r--graphics/java/android/renderscript/ScriptC.java14
2 files changed, 16 insertions, 9 deletions
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 2438532c98dd..d5af2767bb40 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -83,11 +83,7 @@ public class RenderScript {
native void nContextInitToClient(int con);
native void nContextDeinitToClient(int con);
- /**
- * Name of the file that holds the object cache.
- */
- private static final String CACHE_PATH = "com.android.renderscript.cache";
- static String mCachePath;
+ static File mCacheDir;
/**
* Sets the directory to use as a persistent storage for the
@@ -97,9 +93,8 @@ public class RenderScript {
* @param cacheDir A directory the current process can write to
*/
public static void setupDiskCache(File cacheDir) {
- File f = new File(cacheDir, CACHE_PATH);
- mCachePath = f.getAbsolutePath();
- f.mkdirs();
+ // Defer creation of cache path to nScriptCCreate().
+ mCacheDir = cacheDir;
}
public enum ContextType {
diff --git a/graphics/java/android/renderscript/ScriptC.java b/graphics/java/android/renderscript/ScriptC.java
index 9221c7aac69f..2f69775a20ae 100644
--- a/graphics/java/android/renderscript/ScriptC.java
+++ b/graphics/java/android/renderscript/ScriptC.java
@@ -64,6 +64,12 @@ public class ScriptC extends Script {
rs.addAllocSizeForGC(mGCSize);
}
+ /**
+ * Name of the file that holds the object cache.
+ */
+ private static final String CACHE_PATH = "com.android.renderscript.cache";
+
+ static String mCachePath;
private static synchronized int internalCreate(RenderScript rs, Resources resources, int resourceID) {
byte[] pgm;
@@ -96,7 +102,13 @@ public class ScriptC extends Script {
String resName = resources.getResourceEntryName(resourceID);
+ // Create the RS cache path if we haven't done so already.
+ if (mCachePath == null) {
+ File f = new File(rs.mCacheDir, CACHE_PATH);
+ mCachePath = f.getAbsolutePath();
+ f.mkdirs();
+ }
Log.v(TAG, "Create script for resource = " + resName);
- return rs.nScriptCCreate(resName, rs.mCachePath, pgm, pgmLength);
+ return rs.nScriptCCreate(resName, mCachePath, pgm, pgmLength);
}
}