summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--graphics/java/android/renderscript/Allocation.java29
-rw-r--r--graphics/java/android/renderscript/RSSurfaceView.java11
-rw-r--r--graphics/java/android/renderscript/RenderScript.java4
-rw-r--r--graphics/java/android/renderscript/RenderScriptGL.java87
-rw-r--r--graphics/jni/android_renderscript_RenderScript.cpp24
-rw-r--r--libs/rs/java/Fountain/src/com/android/fountain/FountainView.java3
-rw-r--r--libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java2
-rw-r--r--libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphView.java4
-rw-r--r--libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java2
-rw-r--r--libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelView.java4
-rw-r--r--libs/rs/java/Samples/src/com/android/samples/RsListView.java4
-rw-r--r--libs/rs/java/Samples/src/com/android/samples/RsRenderStatesView.java4
-rw-r--r--libs/rs/java/tests/src/com/android/rs/test/RSTestView.java3
-rw-r--r--libs/rs/rs.spec10
-rw-r--r--libs/rs/rsScript.cpp4
-rw-r--r--libs/rs/rsScriptC.cpp4
16 files changed, 108 insertions, 91 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index 2c076b3..06bfbcf 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -372,17 +372,6 @@ public class Allocation extends BaseObj {
return a;
}
- static Allocation createFromBitmapBoxed(RenderScript rs, Bitmap b, Element dstFmt, boolean genMips)
- throws IllegalArgumentException {
-
- rs.validate();
- int id = rs.nAllocationCreateFromBitmapBoxed(dstFmt.mID, genMips, b);
- if(id == 0) {
- throw new IllegalStateException("Load failed.");
- }
- return new Allocation(id, rs, null);
- }
-
static public Allocation createFromBitmapResource(RenderScript rs, Resources res, int id, Element dstFmt, boolean genMips)
throws IllegalArgumentException {
@@ -415,24 +404,6 @@ public class Allocation extends BaseObj {
return null;
}
- static public Allocation createFromBitmapResourceBoxed(RenderScript rs, Resources res, int id, Element dstFmt, boolean genMips)
- throws IllegalArgumentException {
-
- mBitmapOptions.inPreferredConfig = null;
- if (dstFmt == rs.mElement_RGBA_8888) {
- mBitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
- } else if (dstFmt == rs.mElement_RGB_888) {
- mBitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
- } else if (dstFmt == rs.mElement_RGBA_4444) {
- mBitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_4444;
- } else if (dstFmt == rs.mElement_RGB_565) {
- mBitmapOptions.inPreferredConfig = Bitmap.Config.RGB_565;
- }
-
- Bitmap b = BitmapFactory.decodeResource(res, id, mBitmapOptions);
- return createFromBitmapBoxed(rs, b, dstFmt, genMips);
- }
-
static public Allocation createFromString(RenderScript rs, String str)
throws IllegalArgumentException {
byte[] allocArray = null;
diff --git a/graphics/java/android/renderscript/RSSurfaceView.java b/graphics/java/android/renderscript/RSSurfaceView.java
index f05e84c..2540d01 100644
--- a/graphics/java/android/renderscript/RSSurfaceView.java
+++ b/graphics/java/android/renderscript/RSSurfaceView.java
@@ -25,7 +25,6 @@ import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.Log;
-import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@@ -146,22 +145,18 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
// ----------------------------------------------------------------------
- public RenderScriptGL createRenderScript(boolean useDepth, boolean forceSW) {
+ public RenderScriptGL createRenderScript(RenderScriptGL.SurfaceConfig sc) {
Log.v(RenderScript.LOG_TAG, "createRenderScript");
- mRS = new RenderScriptGL(useDepth, forceSW);
+ mRS = new RenderScriptGL(sc);
return mRS;
}
- public RenderScriptGL createRenderScript(boolean useDepth) {
- return createRenderScript(useDepth, false);
- }
-
public void destroyRenderScript() {
Log.v(RenderScript.LOG_TAG, "destroyRenderScript");
mRS.destroy();
mRS = null;
}
-
+
public void createRenderScript(RenderScriptGL rs) {
mRS = rs;
}
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 0088373..27c40fa 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -194,10 +194,6 @@ public class RenderScript {
synchronized int nAllocationCreateBitmapRef(int type, Bitmap bmp) {
return rsnAllocationCreateBitmapRef(mContext, type, bmp);
}
- native int rsnAllocationCreateFromBitmapBoxed(int con, int dstFmt, boolean genMips, Bitmap bmp);
- synchronized int nAllocationCreateFromBitmapBoxed(int dstFmt, boolean genMips, Bitmap bmp) {
- return rsnAllocationCreateFromBitmapBoxed(mContext, dstFmt, genMips, bmp);
- }
native int rsnAllocationCreateFromAssetStream(int con, int dstFmt, boolean genMips, int assetStream);
synchronized int nAllocationCreateFromAssetStream(int dstFmt, boolean genMips, int assetStream) {
return rsnAllocationCreateFromAssetStream(mContext, dstFmt, genMips, assetStream);
diff --git a/graphics/java/android/renderscript/RenderScriptGL.java b/graphics/java/android/renderscript/RenderScriptGL.java
index 61ecc8d..b60c689 100644
--- a/graphics/java/android/renderscript/RenderScriptGL.java
+++ b/graphics/java/android/renderscript/RenderScriptGL.java
@@ -23,7 +23,8 @@ import android.graphics.BitmapFactory;
import android.util.Config;
import android.util.Log;
import android.view.Surface;
-
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
/**
* @hide
@@ -34,16 +35,90 @@ public class RenderScriptGL extends RenderScript {
int mWidth;
int mHeight;
+ public static class SurfaceConfig {
+ int mDepthMin = 0;
+ int mDepthPref = 0;
+ int mStencilMin = 0;
+ int mStencilPref = 0;
+ int mColorMin = 8;
+ int mColorPref = 8;
+ int mAlphaMin = 0;
+ int mAlphaPref = 0;
+ int mSamplesMin = 1;
+ int mSamplesPref = 1;
+ float mSamplesQ = 1.f;
+
+ public SurfaceConfig() {
+ }
+
+ public SurfaceConfig(SurfaceConfig sc) {
+ mDepthMin = sc.mDepthMin;
+ mDepthPref = sc.mDepthPref;
+ mStencilMin = sc.mStencilMin;
+ mStencilPref = sc.mStencilPref;
+ mColorMin = sc.mColorMin;
+ mColorPref = sc.mColorPref;
+ mAlphaMin = sc.mAlphaMin;
+ mAlphaPref = sc.mAlphaPref;
+ mSamplesMin = sc.mSamplesMin;
+ mSamplesPref = sc.mSamplesPref;
+ mSamplesQ = sc.mSamplesQ;
+ }
+
+ private void validateRange(int umin, int upref, int rmin, int rmax) {
+ if (umin < rmin || umin > rmax) {
+ throw new IllegalArgumentException("Minimum value provided out of range.");
+ }
+ if (upref < umin) {
+ throw new IllegalArgumentException("Prefered must be >= Minimum.");
+ }
+ }
+
+ public void setColor(int minimum, int prefered) {
+ validateRange(minimum, prefered, 5, 8);
+ mColorMin = minimum;
+ mColorPref = prefered;
+ }
+ public void setAlpha(int minimum, int prefered) {
+ validateRange(minimum, prefered, 0, 8);
+ mAlphaMin = minimum;
+ mAlphaPref = prefered;
+ }
+ public void setDepth(int minimum, int prefered) {
+ validateRange(minimum, prefered, 0, 24);
+ mDepthMin = minimum;
+ mDepthPref = prefered;
+ }
+ public void setSamples(int minimum, int prefered, float Q) {
+ validateRange(minimum, prefered, 0, 24);
+ if (Q < 0.0f || Q > 1.0f) {
+ throw new IllegalArgumentException("Quality out of 0-1 range.");
+ }
+ mSamplesMin = minimum;
+ mSamplesPref = prefered;
+ mSamplesQ = Q;
+ }
+ };
+
+ SurfaceConfig mSurfaceConfig;
+
+ public void configureSurface(SurfaceHolder sh) {
+ //getHolder().setFormat(PixelFormat.TRANSLUCENT);
+ }
+
+ public void checkSurface(SurfaceHolder sh) {
+ }
+
+ public RenderScriptGL(SurfaceConfig sc) {
+ mSurfaceConfig = new SurfaceConfig(sc);
+
+
- public RenderScriptGL(boolean useDepth, boolean forceSW) {
mSurface = null;
mWidth = 0;
mHeight = 0;
mDev = nDeviceCreate();
- if(forceSW) {
- nDeviceSetConfig(mDev, 0, 1);
- }
- mContext = nContextCreateGL(mDev, 0, useDepth);
+ mContext = nContextCreateGL(mDev, 0, mSurfaceConfig.mDepthMin > 0);
mMessageThread = new MessageThread(this);
mMessageThread.start();
Element.initPredefined(this);
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 8f1e93c..3e52fef 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -466,29 +466,6 @@ nAllocationCreateFromAssetStream(JNIEnv *_env, jobject _this, RsContext con, jin
return 0;
}
-static int
-nAllocationCreateFromBitmapBoxed(JNIEnv *_env, jobject _this, RsContext con, jint dstFmt, jboolean genMips, jobject jbitmap)
-{
- SkBitmap const * nativeBitmap =
- (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID);
- const SkBitmap& bitmap(*nativeBitmap);
- SkBitmap::Config config = bitmap.getConfig();
-
- RsElement e = SkBitmapToPredefined(config);
-
- if (e) {
- bitmap.lockPixels();
- const int w = bitmap.width();
- const int h = bitmap.height();
- const void* ptr = bitmap.getPixels();
- jint id = (jint)rsAllocationCreateFromBitmapBoxed(con, w, h, (RsElement)dstFmt, e, genMips, ptr);
- bitmap.unlockPixels();
- return id;
- }
- return 0;
-}
-
-
static void
nAllocationSubData1D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint count, jintArray data, int sizeBytes)
{
@@ -1252,7 +1229,6 @@ static JNINativeMethod methods[] = {
{"rsnAllocationCreateTyped", "(II)I", (void*)nAllocationCreateTyped },
{"rsnAllocationCreateFromBitmap", "(IIZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap },
{"rsnAllocationCreateBitmapRef", "(IILandroid/graphics/Bitmap;)I", (void*)nAllocationCreateBitmapRef },
-{"rsnAllocationCreateFromBitmapBoxed","(IIZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmapBoxed },
{"rsnAllocationCreateFromAssetStream","(IIZI)I", (void*)nAllocationCreateFromAssetStream },
{"rsnAllocationUploadToTexture", "(IIZI)V", (void*)nAllocationUploadToTexture },
{"rsnAllocationUploadToBufferObject","(II)V", (void*)nAllocationUploadToBufferObject },
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
index c141165..987bebe 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
@@ -52,7 +52,8 @@ public class FountainView extends RSSurfaceView {
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
super.surfaceChanged(holder, format, w, h);
if (mRS == null) {
- mRS = createRenderScript(false);
+ RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
+ mRS = createRenderScript(sc);
mRS.contextSetSurface(w, h, holder.getSurface());
mRender = new FountainRS();
mRender.init(mRS, getResources(), w, h);
diff --git a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
index b5592f0..81bd578 100644
--- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
+++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
@@ -128,7 +128,7 @@ public class SceneGraphRS {
}
private void loadImage() {
- mGridImage = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.robot, Element.RGB_565(mRS), true);
+ mGridImage = Allocation.createFromBitmapResource(mRS, mRes, R.drawable.robot, Element.RGB_565(mRS), true);
mGridImage.uploadToTexture(0);
mScript.set_gTGrid(mGridImage);
diff --git a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphView.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphView.java
index 44a59b2..9457fd7 100644
--- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphView.java
+++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphView.java
@@ -53,7 +53,9 @@ public class SceneGraphView extends RSSurfaceView {
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
super.surfaceChanged(holder, format, w, h);
if (mRS == null) {
- mRS = createRenderScript(true);
+ RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
+ sc.setDepth(16, 24);
+ mRS = createRenderScript(sc);
mRS.contextSetSurface(w, h, holder.getSurface());
mRender = new SceneGraphRS();
mRender.init(mRS, getResources(), w, h);
diff --git a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
index afbf30b..ccbecd8 100644
--- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
+++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
@@ -124,7 +124,7 @@ public class SimpleModelRS {
}
private void loadImage() {
- mGridImage = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.robot, Element.RGB_565(mRS), true);
+ mGridImage = Allocation.createFromBitmapResource(mRS, mRes, R.drawable.robot, Element.RGB_565(mRS), true);
mGridImage.uploadToTexture(0);
mScript.set_gTGrid(mGridImage);
diff --git a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelView.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelView.java
index 2574fdd..4253085 100644
--- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelView.java
+++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelView.java
@@ -53,7 +53,9 @@ public class SimpleModelView extends RSSurfaceView {
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
super.surfaceChanged(holder, format, w, h);
if (mRS == null) {
- mRS = createRenderScript(true);
+ RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
+ sc.setDepth(16, 24);
+ mRS = createRenderScript(sc);
mRS.contextSetSurface(w, h, holder.getSurface());
mRender = new SimpleModelRS();
mRender.init(mRS, getResources(), w, h);
diff --git a/libs/rs/java/Samples/src/com/android/samples/RsListView.java b/libs/rs/java/Samples/src/com/android/samples/RsListView.java
index b98ea08..cd66fbb 100644
--- a/libs/rs/java/Samples/src/com/android/samples/RsListView.java
+++ b/libs/rs/java/Samples/src/com/android/samples/RsListView.java
@@ -53,7 +53,9 @@ public class RsListView extends RSSurfaceView {
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
super.surfaceChanged(holder, format, w, h);
if (mRS == null) {
- mRS = createRenderScript(true);
+ RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
+ sc.setDepth(16, 24);
+ mRS = createRenderScript(sc);
mRS.contextSetSurface(w, h, holder.getSurface());
mRender = new RsListRS();
mRender.init(mRS, getResources(), w, h);
diff --git a/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesView.java b/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesView.java
index 5548de3..c434c09 100644
--- a/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesView.java
+++ b/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesView.java
@@ -53,7 +53,9 @@ public class RsRenderStatesView extends RSSurfaceView {
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
super.surfaceChanged(holder, format, w, h);
if (mRS == null) {
- mRS = createRenderScript(true);
+ RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
+ sc.setDepth(16, 24);
+ mRS = createRenderScript(sc);
mRS.contextSetSurface(w, h, holder.getSurface());
mRender = new RsRenderStatesRS();
mRender.init(mRS, getResources(), w, h);
diff --git a/libs/rs/java/tests/src/com/android/rs/test/RSTestView.java b/libs/rs/java/tests/src/com/android/rs/test/RSTestView.java
index b811d48..c65f8c6 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/RSTestView.java
+++ b/libs/rs/java/tests/src/com/android/rs/test/RSTestView.java
@@ -52,7 +52,8 @@ public class RSTestView extends RSSurfaceView {
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
super.surfaceChanged(holder, format, w, h);
if (mRS == null) {
- mRS = createRenderScript(false);
+ RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
+ mRS = createRenderScript(sc);
mRS.contextSetSurface(w, h, holder.getSurface());
mRender = new RSTestCore();
mRender.init(mRS, getResources(), w, h);
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index 0da637e..a1c0671 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -145,16 +145,6 @@ AllocationCreateFromBitmap {
ret RsAllocation
}
-AllocationCreateFromBitmapBoxed {
- param uint32_t width
- param uint32_t height
- param RsElement dstFmt
- param RsElement srcFmt
- param bool genMips
- param const void * data
- ret RsAllocation
- }
-
AllocationUploadToTexture {
param RsAllocation alloc
diff --git a/libs/rs/rsScript.cpp b/libs/rs/rsScript.cpp
index 0e76dae..c2f9689 100644
--- a/libs/rs/rsScript.cpp
+++ b/libs/rs/rsScript.cpp
@@ -66,7 +66,9 @@ void Script::setVar(uint32_t slot, const void *val, uint32_t len)
memcpy(destPtr, val, len);
//LOGE("setVar f2 %f", ((const float *)destPtr)[0]);
} else {
- LOGE("Calling setVar on slot = %i which is null", slot);
+ //if (rsc->props.mLogScripts) {
+ LOGV("Calling setVar on slot = %i which is null", slot);
+ //}
}
}
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index d961fed..e60255a 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -81,7 +81,9 @@ void ScriptC::setupScript(Context *rsc)
if (dest) {
*dest = ptr;
} else {
- LOGE("ScriptC::setupScript, NULL var binding address.");
+ if (rsc->props.mLogScripts) {
+ LOGV("ScriptC::setupScript, NULL var binding address.");
+ }
}
}
}