diff options
author | Jason Sams <rjsams@android.com> | 2009-09-25 14:51:22 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2009-09-25 14:51:22 -0700 |
commit | a9e7a05b84470257637c97d65f6562aa832c66ef (patch) | |
tree | 04a3175485ae7492c3387003c244953b6880c514 /libs/rs/java | |
parent | a0cad2f5d19d95cfe496ebb82f3227dd4ed7c169 (diff) | |
download | frameworks_base-a9e7a05b84470257637c97d65f6562aa832c66ef.zip frameworks_base-a9e7a05b84470257637c97d65f6562aa832c66ef.tar.gz frameworks_base-a9e7a05b84470257637c97d65f6562aa832c66ef.tar.bz2 |
Improve renderscript context teardown. Track object in the system and then force their cleanup by releasing all user references once destroy context is called. Java layer will no longer send destroy notifications for objects garbage collected once a context is destroyed.
Diffstat (limited to 'libs/rs/java')
-rw-r--r-- | libs/rs/java/Fountain/src/com/android/fountain/Fountain.java | 8 | ||||
-rw-r--r-- | libs/rs/java/Fountain/src/com/android/fountain/FountainView.java | 26 |
2 files changed, 33 insertions, 1 deletions
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/Fountain.java b/libs/rs/java/Fountain/src/com/android/fountain/Fountain.java index 58c78fa..9ae3e67 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/Fountain.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/Fountain.java @@ -62,6 +62,8 @@ public class Fountain extends Activity { @Override protected void onResume() { + Log.e("rs", "onResume"); + // Ideally a game should implement onResume() and onPause() // to take appropriate action when the activity looses focus super.onResume(); @@ -70,12 +72,16 @@ public class Fountain extends Activity { @Override protected void onPause() { + Log.e("rs", "onPause"); + // Ideally a game should implement onResume() and onPause() // to take appropriate action when the activity looses focus super.onPause(); mView.onPause(); - Runtime.getRuntime().exit(0); + + + //Runtime.getRuntime().exit(0); } 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 1b07f98..116afd0 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java @@ -49,14 +49,40 @@ public class FountainView extends RSSurfaceView { private RenderScript mRS; private FountainRS mRender; + private void destroyRS() { + if(mRS != null) { + mRS = null; + destroyRenderScript(); + } + java.lang.System.gc(); + } + public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { super.surfaceChanged(holder, format, w, h); + Log.e("rs", "surfaceChanged"); + destroyRS(); + + mRS = createRenderScript(false, true); mRender = new FountainRS(); mRender.init(mRS, getResources(), w, h); } + public void surfaceDestroyed(SurfaceHolder holder) { + // Surface will be destroyed when we return + Log.v("rs", "surfaceDestroyed"); + destroyRS(); + + try { + java.lang.Thread.sleep(5000); + } catch(InterruptedException e) { + + } + Runtime.getRuntime().exit(0); + } + + @Override public boolean onTouchEvent(MotionEvent ev) |