Recreate TextureView's display list on attach

Bug #9425270

When a TextureView is detached from its window and immediately
re-attached, the display list is not destroyed but reused as is.
TextureView will however destroy the layer and surface texture
reference by the display list.

The solution is to force TextureView to invalidate its display
list on re-attach if it previously had a surface/layer pair.

Change-Id: I475096ffa7e5709155c4c943bf1bfaaaedbd4a1d
This commit is contained in:
Romain Guy
2013-06-27 10:58:10 -07:00
committed by The Android Automerger
parent 46bb6d6cb7
commit f63fdf8680

View File

@@ -108,6 +108,7 @@ public class TextureView extends View {
private HardwareLayer mLayer;
private SurfaceTexture mSurface;
private SurfaceTextureListener mListener;
private boolean mHadSurface;
private boolean mOpaque = true;
@@ -202,6 +203,11 @@ public class TextureView extends View {
Log.w(LOG_TAG, "A TextureView or a subclass can only be "
+ "used with hardware acceleration enabled.");
}
if (mHadSurface) {
invalidate(true);
mHadSurface = false;
}
}
@Override
@@ -241,6 +247,8 @@ public class TextureView extends View {
if (shouldRelease) mSurface.release();
mSurface = null;
mLayer = null;
mHadSurface = true;
}
}