summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Grace Kloba <klobag@google.com> 2011-08-09 18:47:17 -0700
committer Grace Kloba <klobag@google.com> 2011-08-09 18:47:17 -0700
commit402f05530352f34d5320c2d23be43c274d97c4e2 (patch)
treef16fff92ad3dead45679fff4ee4c7c3fdb5888bb
parent5229f7f2266c25f976070e0c2007e425010152ff (diff)
Add a return value for SurfaceTextureListener#onSurfaceTextureDestroyed.
If returns true, the SurfaceTexture will be released by TextureView. If returns false, the client needs to release the SurfaceTexture. Change-Id: I946f71e337ad4170c168854ac27e028b82489c8c
-rw-r--r--api/current.txt4
-rw-r--r--core/java/android/view/TextureView.java14
-rw-r--r--graphics/java/android/renderscript/RSTextureView.java4
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/CanvasTextureViewActivity.java3
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java3
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java3
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java3
7 files changed, 21 insertions, 13 deletions
diff --git a/api/current.txt b/api/current.txt
index bf4efea3a4bf..e73cbf5c099f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -17930,7 +17930,7 @@ package android.renderscript {
method public void destroyRenderScriptGL();
method public android.renderscript.RenderScriptGL getRenderScriptGL();
method public void onSurfaceTextureAvailable(android.graphics.SurfaceTexture, int, int);
- method public void onSurfaceTextureDestroyed(android.graphics.SurfaceTexture);
+ method public boolean onSurfaceTextureDestroyed(android.graphics.SurfaceTexture);
method public void onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture, int, int);
method public void onSurfaceTextureUpdated(android.graphics.SurfaceTexture);
method public void pause();
@@ -22351,7 +22351,7 @@ package android.view {
public static abstract interface TextureView.SurfaceTextureListener {
method public abstract void onSurfaceTextureAvailable(android.graphics.SurfaceTexture, int, int);
- method public abstract void onSurfaceTextureDestroyed(android.graphics.SurfaceTexture);
+ method public abstract boolean onSurfaceTextureDestroyed(android.graphics.SurfaceTexture);
method public abstract void onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture, int, int);
method public abstract void onSurfaceTextureUpdated(android.graphics.SurfaceTexture);
}
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index 76aa21f225c7..53a6bcba98c8 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -73,9 +73,10 @@ import android.util.Log;
* // Ignored, Camera does all the work for us
* }
*
- * public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+ * public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
* mCamera.stopPreview();
* mCamera.release();
+ * return true;
* }
*
* public void onSurfaceTextureUpdated(SurfaceTexture surface) {
@@ -195,8 +196,9 @@ public class TextureView extends View {
super.onDetachedFromWindow();
if (mLayer != null) {
+ boolean shouldRelease = true;
if (mListener != null) {
- mListener.onSurfaceTextureDestroyed(mSurface);
+ shouldRelease = mListener.onSurfaceTextureDestroyed(mSurface);
}
synchronized (mNativeWindowLock) {
@@ -204,7 +206,7 @@ public class TextureView extends View {
}
mLayer.destroy();
- mSurface.release();
+ if (shouldRelease) mSurface.release();
mSurface = null;
mLayer = null;
}
@@ -578,12 +580,12 @@ public class TextureView extends View {
/**
* Invoked when the specified {@link SurfaceTexture} is about to be destroyed.
- * After this method is invoked, no rendering should happen inside the surface
- * texture.
+ * If returns true, no rendering should happen inside the surface texture after this method
+ * is invoked. If returns false, the client needs to call {@link SurfaceTexture#release()}.
*
* @param surface The surface about to be destroyed
*/
- public void onSurfaceTextureDestroyed(SurfaceTexture surface);
+ public boolean onSurfaceTextureDestroyed(SurfaceTexture surface);
/**
* Invoked when the specified {@link SurfaceTexture} is updated through
diff --git a/graphics/java/android/renderscript/RSTextureView.java b/graphics/java/android/renderscript/RSTextureView.java
index b8dd577cb83e..30b2f994d39c 100644
--- a/graphics/java/android/renderscript/RSTextureView.java
+++ b/graphics/java/android/renderscript/RSTextureView.java
@@ -85,13 +85,15 @@ public class RSTextureView extends TextureView implements TextureView.SurfaceTex
}
@Override
- public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+ public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
//Log.e(RenderScript.LOG_TAG, "onSurfaceTextureDestroyed");
mSurfaceTexture = surface;
if (mRS != null) {
mRS.setSurfaceTexture(null, 0, 0);
}
+
+ return true;
}
@Override
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/CanvasTextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/CanvasTextureViewActivity.java
index 81c22b88900b..bd2f68f77f28 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/CanvasTextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/CanvasTextureViewActivity.java
@@ -58,8 +58,9 @@ public class CanvasTextureViewActivity extends Activity
}
@Override
- public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+ public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
if (mThread != null) mThread.stopRendering();
+ return true;
}
@Override
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
index 949589f7ca47..e77178d5e59d 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
@@ -110,13 +110,14 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa
}
@Override
- public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+ public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
mRenderThread.finish();
try {
mRenderThread.join();
} catch (InterruptedException e) {
Log.e(RenderThread.LOG_TAG, "Could not wait for render thread");
}
+ return true;
}
@Override
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java
index f420fa06e720..038434a72de2 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java
@@ -96,9 +96,10 @@ public class GetBitmapActivity extends Activity implements TextureView.SurfaceTe
}
@Override
- public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+ public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
mCamera.stopPreview();
mCamera.release();
+ return true;
}
@Override
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
index 634e7e3adf0e..97e21089428c 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
@@ -92,9 +92,10 @@ public class TextureViewActivity extends Activity implements TextureView.Surface
}
@Override
- public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+ public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
mCamera.stopPreview();
mCamera.release();
+ return true;
}
@Override