diff options
author | Jason Sams <rjsams@android.com> | 2012-02-24 17:21:32 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-24 17:21:32 -0800 |
commit | 93d083b6ad4e54032f4525125d750926e2433f87 (patch) | |
tree | 94595af405f3ee21eaf87aa6bc310d7da08fe9de /graphics | |
parent | 3d408e50100f00340d442b774e2e911074500682 (diff) | |
parent | a6f338ca5f0c8359d1952167858851dd025e47e2 (diff) | |
download | frameworks_base-93d083b6ad4e54032f4525125d750926e2433f87.zip frameworks_base-93d083b6ad4e54032f4525125d750926e2433f87.tar.gz frameworks_base-93d083b6ad4e54032f4525125d750926e2433f87.tar.bz2 |
Merge "Do RS caching the same way HardwareRenderer does. Eliminates the need for an application context for caching."
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 21 | ||||
-rw-r--r-- | graphics/java/android/renderscript/ScriptC.java | 6 |
2 files changed, 22 insertions, 5 deletions
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 9517513..fd4ecf1 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -17,6 +17,7 @@ package android.renderscript; import java.lang.reflect.Field; +import java.io.File; import android.content.Context; import android.content.pm.ApplicationInfo; @@ -82,6 +83,26 @@ 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"; + + /** + * Sets the directory to use as a persistent storage for the + * renderscript object file cache. + * + * @hide + * @param cacheDir A directory the current process can write to + */ + + static String mCachePath; + public static void setupDiskCache(File cacheDir) { + File f = new File(cacheDir, CACHE_PATH); + mCachePath = f.getAbsolutePath(); + f.mkdirs(); + } + // Methods below are wrapped to protect the non-threadsafe // lockless fifo. diff --git a/graphics/java/android/renderscript/ScriptC.java b/graphics/java/android/renderscript/ScriptC.java index 90f959f..108b230 100644 --- a/graphics/java/android/renderscript/ScriptC.java +++ b/graphics/java/android/renderscript/ScriptC.java @@ -92,13 +92,9 @@ public class ScriptC extends Script { throw new Resources.NotFoundException(); } - // E.g, /system/apps/Fountain.apk - //String packageName = rs.getApplicationContext().getPackageResourcePath(); - // For res/raw/fountain.bc, it wil be /com.android.fountain:raw/fountain String resName = resources.getResourceEntryName(resourceID); - String cacheDir = rs.getApplicationContext().getCacheDir().toString(); Log.v(TAG, "Create script for resource = " + resName); - return rs.nScriptCCreate(resName, cacheDir, pgm, pgmLength); + return rs.nScriptCCreate(resName, rs.mCachePath, pgm, pgmLength); } } |