Defer RS cache creation until a ScriptC is built.

Bug: 8582926
Change-Id: If017f41382f023f8f6ddd78ba198402d427c95f8
This commit is contained in:
Stephen Hines
2013-04-09 23:51:56 -07:00
parent d7094ea29b
commit 7d25a829d3
2 changed files with 16 additions and 9 deletions

View File

@@ -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);
}
}