Add support for setting the cache directory.
Change-Id: I2bf1874705b877a8a8262ab49b47fe8241e603d5
This commit is contained in:
@ -16,6 +16,7 @@
|
||||
|
||||
package android.renderscript;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
@ -231,6 +232,11 @@ public class RenderScript {
|
||||
validate();
|
||||
rsnContextSetPriority(mContext, p);
|
||||
}
|
||||
native void rsnContextSetCacheDir(long con, String cacheDir);
|
||||
synchronized void nContextSetCacheDir(String cacheDir) {
|
||||
validate();
|
||||
rsnContextSetCacheDir(mContext, cacheDir);
|
||||
}
|
||||
native void rsnContextDump(long con, int bits);
|
||||
synchronized void nContextDump(int bits) {
|
||||
validate();
|
||||
@ -1326,6 +1332,14 @@ public class RenderScript {
|
||||
if (rs.mContext == 0) {
|
||||
throw new RSDriverException("Failed to create RS context.");
|
||||
}
|
||||
|
||||
// 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.mMessageThread = new MessageThread(rs);
|
||||
rs.mMessageThread.start();
|
||||
return rs;
|
||||
|
Reference in New Issue
Block a user