summaryrefslogtreecommitdiff
path: root/core/java/android/view/TextureView.java
diff options
context:
space:
mode:
authorNaveen Kalla <nkalla@codeaurora.org>2015-03-17 15:20:53 -0700
committerNaveen Kalla <nkalla@codeaurora.org>2015-03-18 15:57:10 -0700
commitfd69e2a258c76300c47aff703d34281263d2a373 (patch)
tree82dea0d81bb553f28703f8497ad0fd988f630839 /core/java/android/view/TextureView.java
parent969b0278525fb61da145baedc791e1f2df4c8c1e (diff)
Fix setSurfaceTexture to handle surface caching
TextureView contains its surfaceTexture (i.e. mSurface) and its OnFrameAvailableListener(i.e. mUpdateListener). In order to apply a cached/pre-existing SurfaceTexture s1 to a TextureView, if we call TextureView.setSurfaceTexture(s1), the OnFrameAvailableListener of s1 should get set to mUpdateListener of TextureView since the mSurface has been updated. The existing code doesn't apply this and causes the frames to not be updated on a TextureView that uses setSurfaceTexture. This change fixes setSurfaceTexture method by setting s1's OnFrameAvailableListener to mUpdateListener. Change-Id: I4c1a704c587e977ab7a6b1fe3a7d3e0d20d00218
Diffstat (limited to 'core/java/android/view/TextureView.java')
-rw-r--r--core/java/android/view/TextureView.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index 59ec058b35dd..ad34f020fa9d 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -723,6 +723,12 @@ public class TextureView extends View {
mSurface.release();
}
mSurface = surfaceTexture;
+
+ // If the view is visible, update the listener in the new surface to use
+ // the existing listener in the view.
+ if (((mViewFlags & VISIBILITY_MASK) == VISIBLE)) {
+ mSurface.setOnFrameAvailableListener(mUpdateListener, mAttachInfo.mHandler);
+ }
mUpdateSurface = true;
invalidateParentIfNeeded();
}