diff options
author | Shih-wei Liao <sliao@google.com> | 2010-12-10 01:03:59 -0800 |
---|---|---|
committer | Shih-wei Liao <sliao@google.com> | 2010-12-14 11:17:20 -0800 |
commit | 6b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bd (patch) | |
tree | 49b2bdb6cec0af7f5e0131c8d17d88d365382b8a /graphics/java/android/renderscript/RenderScript.java | |
parent | 2bc248b698b17fd333beae828039a8bff7604a9f (diff) |
1. Add Context to a RenderScript or RenderScriptGL instance.
This is to allow RenderScript to better interact with the Android environment.
E.g., per-app cache.
2. Plumbing, testing.
3. Added getApplicationContext in RenderScript.java.
Change-Id: I85edeebe38825e20b2e86f4f4815689dfc332ef9
Diffstat (limited to 'graphics/java/android/renderscript/RenderScript.java')
-rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index c6dcff5f069b..5f93f5b769ec 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -18,6 +18,7 @@ package android.renderscript; import java.lang.reflect.Field; +import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.util.Config; @@ -42,9 +43,9 @@ public class RenderScript { @SuppressWarnings({"UnusedDeclaration", "deprecation"}) static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV; + private Context mApplicationContext; - - /* + /* * We use a class initializer to allow the native code to cache some * field offsets. */ @@ -416,9 +417,9 @@ public class RenderScript { synchronized void nScriptCSetScript(byte[] script, int offset, int length) { rsnScriptCSetScript(mContext, script, offset, length); } - native int rsnScriptCCreate(int con, String val); - synchronized int nScriptCCreate(String val) { - return rsnScriptCCreate(mContext, val); + native int rsnScriptCCreate(int con, String val, String cacheDir); + synchronized int nScriptCCreate(String resName, String cacheDir) { + return rsnScriptCCreate(mContext, resName, cacheDir); } native void rsnSamplerBegin(int con); @@ -776,17 +777,27 @@ public class RenderScript { } } - RenderScript() { + RenderScript(Context ctx) { + mApplicationContext = ctx.getApplicationContext(); } /** - * Create a basic RenderScript context. + * Gets the application context associated with the RenderScript context. * + * @return The application context. + */ + public final Context getApplicationContext() { + return mApplicationContext; + } + + /** + * Create a basic RenderScript context. * + * @param ctx The context. * @return RenderScript */ - public static RenderScript create() { - RenderScript rs = new RenderScript(); + public static RenderScript create(Context ctx) { + RenderScript rs = new RenderScript(ctx); rs.mDev = rs.nDeviceCreate(); rs.mContext = rs.nContextCreate(rs.mDev, 0); |