From 51f7c6b3620549429cd6c62e38bace43085e04fb Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Mon, 21 May 2012 16:32:59 -0700 Subject: [PATCH] Flip TextureView's layer after calling setSurfaceTexture() Bug #6531172 Changing the surface texture would not update the layer properties nor its transform matrix. Change-Id: I54e155a410d7e72f1a8edf3a4ab0034bf764ae28 --- core/java/android/view/TextureView.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java index 411aed348a555..a719a0159c18a 100644 --- a/core/java/android/view/TextureView.java +++ b/core/java/android/view/TextureView.java @@ -374,6 +374,14 @@ public class TextureView extends View { // tell mLayer about it and set the SurfaceTexture to use the // current view size. mUpdateSurface = false; + + // Since we are updating the layer, force an update to ensure its + // parameters are correct (width, height, transform, etc.) + synchronized (mLock) { + mUpdateLayer = true; + } + mMatrixChanged = true; + mAttachInfo.mHardwareRenderer.setSurfaceTexture(mLayer, mSurface); nSetDefaultBufferSize(mSurface, getWidth(), getHeight()); } @@ -471,7 +479,7 @@ public class TextureView extends View { } private void applyTransformMatrix() { - if (mMatrixChanged) { + if (mMatrixChanged && mLayer != null) { mLayer.setTransform(mMatrix); mMatrixChanged = false; }