* commit 'af61d43d6ce065832f906757c2185c3dad74d489': Add support for setting the cache directory.
This commit is contained in:
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.renderscript;
|
package android.renderscript;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
@ -231,6 +232,11 @@ public class RenderScript {
|
|||||||
validate();
|
validate();
|
||||||
rsnContextSetPriority(mContext, p);
|
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);
|
native void rsnContextDump(long con, int bits);
|
||||||
synchronized void nContextDump(int bits) {
|
synchronized void nContextDump(int bits) {
|
||||||
validate();
|
validate();
|
||||||
@ -1326,6 +1332,14 @@ public class RenderScript {
|
|||||||
if (rs.mContext == 0) {
|
if (rs.mContext == 0) {
|
||||||
throw new RSDriverException("Failed to create RS context.");
|
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 = new MessageThread(rs);
|
||||||
rs.mMessageThread.start();
|
rs.mMessageThread.start();
|
||||||
return rs;
|
return rs;
|
||||||
|
@ -689,6 +689,17 @@ nContextSetPriority(JNIEnv *_env, jobject _this, jlong con, jint p)
|
|||||||
rsContextSetPriority((RsContext)con, p);
|
rsContextSetPriority((RsContext)con, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nContextSetCacheDir(JNIEnv *_env, jobject _this, jlong con, jstring cacheDir)
|
||||||
|
{
|
||||||
|
AutoJavaStringToUTF8 cacheDirUTF(_env, cacheDir);
|
||||||
|
|
||||||
|
if (kLogApi) {
|
||||||
|
ALOGD("ContextSetCacheDir, con(%p), cacheDir(%s)", (RsContext)con, cacheDirUTF.c_str());
|
||||||
|
}
|
||||||
|
rsContextSetCacheDir((RsContext)con, cacheDirUTF.c_str(), cacheDirUTF.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2312,6 +2323,7 @@ static JNINativeMethod methods[] = {
|
|||||||
{"rsnContextCreateGL", "(JIIIIIIIIIIIIFI)J", (void*)nContextCreateGL },
|
{"rsnContextCreateGL", "(JIIIIIIIIIIIIFI)J", (void*)nContextCreateGL },
|
||||||
{"rsnContextFinish", "(J)V", (void*)nContextFinish },
|
{"rsnContextFinish", "(J)V", (void*)nContextFinish },
|
||||||
{"rsnContextSetPriority", "(JI)V", (void*)nContextSetPriority },
|
{"rsnContextSetPriority", "(JI)V", (void*)nContextSetPriority },
|
||||||
|
{"rsnContextSetCacheDir", "(JLjava/lang/String;)V", (void*)nContextSetCacheDir },
|
||||||
{"rsnContextSetSurface", "(JIILandroid/view/Surface;)V", (void*)nContextSetSurface },
|
{"rsnContextSetSurface", "(JIILandroid/view/Surface;)V", (void*)nContextSetSurface },
|
||||||
{"rsnContextDestroy", "(J)V", (void*)nContextDestroy },
|
{"rsnContextDestroy", "(J)V", (void*)nContextDestroy },
|
||||||
{"rsnContextDump", "(JI)V", (void*)nContextDump },
|
{"rsnContextDump", "(JI)V", (void*)nContextDump },
|
||||||
|
Reference in New Issue
Block a user