summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2012-02-24 17:52:59 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-02-24 17:52:59 -0800
commitb73644a94f090f551e24e2e658756a7ff127dbb2 (patch)
tree3d9ab1873a11a296521b19e838cc5423fe8c02a9
parent5cd164c5cf58047cda39b05a2c4f3cbab2d10078 (diff)
parent1a4e1f3efd077f3a61038aedab84dc84c9c44d19 (diff)
downloadframeworks_base-b73644a94f090f551e24e2e658756a7ff127dbb2.zip
frameworks_base-b73644a94f090f551e24e2e658756a7ff127dbb2.tar.gz
frameworks_base-b73644a94f090f551e24e2e658756a7ff127dbb2.tar.bz2
Merge "Make compute work without an app context."
-rw-r--r--graphics/java/android/renderscript/RenderScript.java27
-rw-r--r--graphics/java/android/renderscript/RenderScriptGL.java2
2 files changed, 18 insertions, 11 deletions
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index fd4ecf1..6921f37 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -87,6 +87,7 @@ public class RenderScript {
* 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
@@ -95,8 +96,6 @@ public class RenderScript {
* @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();
@@ -905,7 +904,9 @@ public class RenderScript {
}
RenderScript(Context ctx) {
- mApplicationContext = ctx.getApplicationContext();
+ if (ctx != null) {
+ mApplicationContext = ctx.getApplicationContext();
+ }
}
/**
@@ -917,21 +918,16 @@ public class RenderScript {
return mApplicationContext;
}
- static int getTargetSdkVersion(Context ctx) {
- return ctx.getApplicationInfo().targetSdkVersion;
- }
-
/**
* Create a basic RenderScript context.
*
+ * @hide
* @param ctx The context.
* @return RenderScript
*/
- public static RenderScript create(Context ctx) {
+ public static RenderScript create(Context ctx, int sdkVersion) {
RenderScript rs = new RenderScript(ctx);
- int sdkVersion = getTargetSdkVersion(ctx);
-
rs.mDev = rs.nDeviceCreate();
rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion);
if (rs.mContext == 0) {
@@ -943,6 +939,17 @@ public class RenderScript {
}
/**
+ * Create a basic RenderScript context.
+ *
+ * @param ctx The context.
+ * @return RenderScript
+ */
+ public static RenderScript create(Context ctx) {
+ int v = ctx.getApplicationInfo().targetSdkVersion;
+ return create(ctx, v);
+ }
+
+ /**
* Print the currently available debugging information about the state of
* the RS context to the log.
*
diff --git a/graphics/java/android/renderscript/RenderScriptGL.java b/graphics/java/android/renderscript/RenderScriptGL.java
index 2cfeb17..1b2ac90 100644
--- a/graphics/java/android/renderscript/RenderScriptGL.java
+++ b/graphics/java/android/renderscript/RenderScriptGL.java
@@ -166,7 +166,7 @@ public class RenderScriptGL extends RenderScript {
super(ctx);
mSurfaceConfig = new SurfaceConfig(sc);
- int sdkVersion = getTargetSdkVersion(ctx);
+ int sdkVersion = ctx.getApplicationInfo().targetSdkVersion;
mWidth = 0;
mHeight = 0;