summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2009-11-03 16:02:21 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2009-11-03 16:02:21 -0800
commita1c3681fb84e9baa3055709a18c635dc77c1b041 (patch)
tree23024d961df3e10eeb770214eaf205637f37192d /graphics
parentd14ea3c7d7278695b9c51c243949de88cf38a1a4 (diff)
parentdecc139b232721ea1b0521d144521c8082636f0c (diff)
downloadframeworks_base-a1c3681fb84e9baa3055709a18c635dc77c1b041.zip
frameworks_base-a1c3681fb84e9baa3055709a18c635dc77c1b041.tar.gz
frameworks_base-a1c3681fb84e9baa3055709a18c635dc77c1b041.tar.bz2
am decc139b: Merge change I7a824efc into eclair
Merge commit 'decc139b232721ea1b0521d144521c8082636f0c' into eclair-mr2 * commit 'decc139b232721ea1b0521d144521c8082636f0c': Support applications changing the surface attached to the RS.
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/renderscript/RSSurfaceView.java6
-rw-r--r--graphics/java/android/renderscript/RenderScript.java6
-rw-r--r--graphics/jni/android_renderscript_RenderScript.cpp19
3 files changed, 31 insertions, 0 deletions
diff --git a/graphics/java/android/renderscript/RSSurfaceView.java b/graphics/java/android/renderscript/RSSurfaceView.java
index 53466cc..1bc03ac 100644
--- a/graphics/java/android/renderscript/RSSurfaceView.java
+++ b/graphics/java/android/renderscript/RSSurfaceView.java
@@ -80,6 +80,9 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
*/
public void surfaceDestroyed(SurfaceHolder holder) {
// Surface will be destroyed when we return
+ if (mRS != null) {
+ mRS.contextSetSurface(null);
+ }
//Log.v(RenderScript.LOG_TAG, "surfaceDestroyed");
}
@@ -88,6 +91,9 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
* not normally called or subclassed by clients of RSSurfaceView.
*/
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
+ if (mRS != null) {
+ mRS.contextSetSurface(holder.getSurface());
+ }
//Log.v(RenderScript.LOG_TAG, "surfaceChanged");
}
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 1f2ea38..f1e5af1 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -64,6 +64,7 @@ public class RenderScript {
native void nDeviceSetConfig(int dev, int param, int value);
native int nContextCreate(int dev, Surface sur, int ver, boolean useDepth);
native void nContextDestroy(int con);
+ native void nContextSetSurface(Surface sur);
native void nContextBindRootScript(int script);
native void nContextBindSampler(int sampler, int slot);
@@ -276,6 +277,11 @@ public class RenderScript {
mMessageThread.start();
}
+ public void contextSetSurface(Surface sur) {
+ mSurface = sur;
+ nContextSetSurface(mSurface);
+ }
+
public void destroy() {
nContextDeinitToClient();
mMessageThread.mRun = false;
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index fa3baa2..f3dda41 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -171,6 +171,24 @@ nContextCreate(JNIEnv *_env, jobject _this, jint dev, jobject wnd, jint ver, jbo
}
static void
+nContextSetSurface(JNIEnv *_env, jobject _this, jobject wnd)
+{
+ RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
+ LOG_API("nContextSetSurface, con(%p), surface(%p)", con, (Surface *)wnd);
+
+ Surface * window = NULL;
+ if (wnd == NULL) {
+
+ } else {
+ jclass surface_class = _env->FindClass("android/view/Surface");
+ jfieldID surfaceFieldID = _env->GetFieldID(surface_class, "mSurface", "I");
+ window = (Surface*)_env->GetIntField(wnd, surfaceFieldID);
+ }
+
+ rsContextSetSurface(con, window);
+}
+
+static void
nContextDestroy(JNIEnv *_env, jobject _this, jint con)
{
LOG_API("nContextDestroy, con(%p)", (RsContext)con);
@@ -1328,6 +1346,7 @@ static JNINativeMethod methods[] = {
{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy },
{"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig },
{"nContextCreate", "(ILandroid/view/Surface;IZ)I", (void*)nContextCreate },
+{"nContextSetSurface", "(Landroid/view/Surface;)V", (void*)nContextSetSurface },
{"nContextDestroy", "(I)V", (void*)nContextDestroy },
{"nContextPause", "()V", (void*)nContextPause },
{"nContextResume", "()V", (void*)nContextResume },