summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/TextureView.java48
1 files changed, 30 insertions, 18 deletions
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index b2e2505f5c5b..ce2fa81976a3 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -218,33 +218,45 @@ public class TextureView extends View {
/** @hide */
@Override
protected void onDetachedFromWindowInternal() {
- destroySurface();
+ destroyHardwareLayer();
+ releaseSurfaceTexture();
super.onDetachedFromWindowInternal();
}
- private void destroySurface() {
+ /**
+ * @hide
+ */
+ @Override
+ protected void destroyHardwareResources() {
+ destroyHardwareLayer();
+ mUpdateSurface = mSurface != null;
+ }
+
+ private void destroyHardwareLayer() {
if (mLayer != null) {
mLayer.detachSurfaceTexture();
+ mLayer.destroy();
+ mLayer = null;
+ mMatrixChanged = true;
+ }
+ }
- boolean shouldRelease = true;
- if (mListener != null) {
- shouldRelease = mListener.onSurfaceTextureDestroyed(mSurface);
- }
+ private void releaseSurfaceTexture() {
+ boolean shouldRelease = true;
- synchronized (mNativeWindowLock) {
- nDestroyNativeWindow();
- }
+ if (mListener != null) {
+ shouldRelease = mListener.onSurfaceTextureDestroyed(mSurface);
+ }
- mLayer.destroy();
- if (shouldRelease) mSurface.release();
- mSurface = null;
- mLayer = null;
+ synchronized (mNativeWindowLock) {
+ nDestroyNativeWindow();
+ }
- // Make sure if/when new layer gets re-created, transform matrix will
- // be re-applied.
- mMatrixChanged = true;
- mHadSurface = true;
+ if (shouldRelease) {
+ mSurface.release();
}
+ mSurface = null;
+ mHadSurface = true;
}
/**
@@ -366,9 +378,9 @@ public class TextureView extends View {
// Create a new SurfaceTexture for the layer.
mSurface = new SurfaceTexture(false);
mLayer.setSurfaceTexture(mSurface);
+ nCreateNativeWindow(mSurface);
}
mSurface.setDefaultBufferSize(getWidth(), getHeight());
- nCreateNativeWindow(mSurface);
mSurface.setOnFrameAvailableListener(mUpdateListener, mAttachInfo.mHandler);