summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2011-08-05 13:47:00 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-08-05 13:47:00 -0700
commit8f019d63055ad76b94710b7b96e29625173584c4 (patch)
tree32e943403122c078c06c14bd10a171ae1e491fb6 /graphics/java
parente3373ff620bcab34ac0030ee06140563f5dbb016 (diff)
parent4382467a80dd12c6362d57edca7f2367f7ae877c (diff)
downloadframeworks_base-8f019d63055ad76b94710b7b96e29625173584c4.zip
frameworks_base-8f019d63055ad76b94710b7b96e29625173584c4.tar.gz
frameworks_base-8f019d63055ad76b94710b7b96e29625173584c4.tar.bz2
Merge "Start using bcinfo components within librs."
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/renderscript/RenderScript.java29
-rw-r--r--graphics/java/android/renderscript/RenderScriptGL.java4
2 files changed, 25 insertions, 8 deletions
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 4856ab6..571b895 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -19,6 +19,8 @@ package android.renderscript;
import java.lang.reflect.Field;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -28,6 +30,7 @@ import android.util.Log;
import android.view.Surface;
+
/**
* RenderScript base master class. An instance of this class creates native
* worker threads for processing commands from this object. This base class
@@ -79,26 +82,26 @@ public class RenderScript {
// Methods below are wrapped to protect the non-threadsafe
// lockless fifo.
- native int rsnContextCreateGL(int dev, int ver,
+ native int rsnContextCreateGL(int dev, int ver, int sdkVer,
int colorMin, int colorPref,
int alphaMin, int alphaPref,
int depthMin, int depthPref,
int stencilMin, int stencilPref,
int samplesMin, int samplesPref, float samplesQ, int dpi);
- synchronized int nContextCreateGL(int dev, int ver,
+ synchronized int nContextCreateGL(int dev, int ver, int sdkVer,
int colorMin, int colorPref,
int alphaMin, int alphaPref,
int depthMin, int depthPref,
int stencilMin, int stencilPref,
int samplesMin, int samplesPref, float samplesQ, int dpi) {
- return rsnContextCreateGL(dev, ver, colorMin, colorPref,
+ return rsnContextCreateGL(dev, ver, sdkVer, colorMin, colorPref,
alphaMin, alphaPref, depthMin, depthPref,
stencilMin, stencilPref,
samplesMin, samplesPref, samplesQ, dpi);
}
- native int rsnContextCreate(int dev, int ver);
- synchronized int nContextCreate(int dev, int ver) {
- return rsnContextCreate(dev, ver);
+ native int rsnContextCreate(int dev, int ver, int sdkVer);
+ synchronized int nContextCreate(int dev, int ver, int sdkVer) {
+ return rsnContextCreate(dev, ver, sdkVer);
}
native void rsnContextDestroy(int con);
synchronized void nContextDestroy() {
@@ -864,6 +867,16 @@ public class RenderScript {
return mApplicationContext;
}
+ static int getTargetSdkVersion(Context ctx) {
+ try {
+ PackageManager pm = ctx.getPackageManager();
+ ApplicationInfo app = pm.getApplicationInfo(ctx.getPackageName(), 0);
+ return app.targetSdkVersion;
+ } catch (Exception e) {
+ throw new RSDriverException("Error calculating target SDK version for RS.");
+ }
+ }
+
/**
* Create a basic RenderScript context.
*
@@ -873,8 +886,10 @@ public class RenderScript {
public static RenderScript create(Context ctx) {
RenderScript rs = new RenderScript(ctx);
+ int sdkVersion = getTargetSdkVersion(ctx);
+
rs.mDev = rs.nDeviceCreate();
- rs.mContext = rs.nContextCreate(rs.mDev, 0);
+ rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion);
if (rs.mContext == 0) {
throw new RSDriverException("Failed to create RS context.");
}
diff --git a/graphics/java/android/renderscript/RenderScriptGL.java b/graphics/java/android/renderscript/RenderScriptGL.java
index 935b75a..2dfcc83 100644
--- a/graphics/java/android/renderscript/RenderScriptGL.java
+++ b/graphics/java/android/renderscript/RenderScriptGL.java
@@ -160,11 +160,13 @@ public class RenderScriptGL extends RenderScript {
super(ctx);
mSurfaceConfig = new SurfaceConfig(sc);
+ int sdkVersion = getTargetSdkVersion(ctx);
+
mWidth = 0;
mHeight = 0;
mDev = nDeviceCreate();
int dpi = ctx.getResources().getDisplayMetrics().densityDpi;
- mContext = nContextCreateGL(mDev, 0,
+ mContext = nContextCreateGL(mDev, 0, sdkVersion,
mSurfaceConfig.mColorMin, mSurfaceConfig.mColorPref,
mSurfaceConfig.mAlphaMin, mSurfaceConfig.mAlphaPref,
mSurfaceConfig.mDepthMin, mSurfaceConfig.mDepthPref,