Merge "Defer RS cache creation until a ScriptC is built." into jb-mr2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
439752d484
@@ -83,11 +83,7 @@ public class RenderScript {
|
|||||||
native void nContextInitToClient(int con);
|
native void nContextInitToClient(int con);
|
||||||
native void nContextDeinitToClient(int con);
|
native void nContextDeinitToClient(int con);
|
||||||
|
|
||||||
/**
|
static File mCacheDir;
|
||||||
* Name of the file that holds the object cache.
|
|
||||||
*/
|
|
||||||
private static final String CACHE_PATH = "com.android.renderscript.cache";
|
|
||||||
static String mCachePath;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the directory to use as a persistent storage for the
|
* 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
|
* @param cacheDir A directory the current process can write to
|
||||||
*/
|
*/
|
||||||
public static void setupDiskCache(File cacheDir) {
|
public static void setupDiskCache(File cacheDir) {
|
||||||
File f = new File(cacheDir, CACHE_PATH);
|
// Defer creation of cache path to nScriptCCreate().
|
||||||
mCachePath = f.getAbsolutePath();
|
mCacheDir = cacheDir;
|
||||||
f.mkdirs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ContextType {
|
public enum ContextType {
|
||||||
|
|||||||
@@ -64,6 +64,12 @@ public class ScriptC extends Script {
|
|||||||
rs.addAllocSizeForGC(mGCSize);
|
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) {
|
private static synchronized int internalCreate(RenderScript rs, Resources resources, int resourceID) {
|
||||||
byte[] pgm;
|
byte[] pgm;
|
||||||
@@ -96,7 +102,13 @@ public class ScriptC extends Script {
|
|||||||
|
|
||||||
String resName = resources.getResourceEntryName(resourceID);
|
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);
|
Log.v(TAG, "Create script for resource = " + resName);
|
||||||
return rs.nScriptCCreate(resName, rs.mCachePath, pgm, pgmLength);
|
return rs.nScriptCCreate(resName, mCachePath, pgm, pgmLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user