Start using bcinfo components within librs.
BUG=4942491
Change-Id: I3a46783511c4954bac9eadbbbefe5abf85498c16
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 @@
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.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 @@
// 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 @@
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 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.");
}