Loading core/java/android/view/TextureView.java +19 −18 Original line number Diff line number Diff line Loading @@ -96,12 +96,9 @@ public class TextureView extends View { private SurfaceTexture mSurface; private SurfaceTextureListener mListener; private final Runnable mUpdateLayerAction = new Runnable() { @Override public void run() { updateLayer(); } }; private final Object[] mLock = new Object[0]; private boolean mUpdateLayer; private SurfaceTexture.OnFrameAvailableListener mUpdateListener; /** Loading Loading @@ -232,6 +229,8 @@ public class TextureView extends View { protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); if (mSurface != null) { // No need to synchronize here, we set update layer to false only on the UI thread mUpdateLayer = true; nSetDefaultBufferSize(mSurface, getWidth(), getHeight()); if (mListener != null) { mListener.onSurfaceTextureSizeChanged(mSurface, getWidth(), getHeight()); Loading @@ -255,7 +254,10 @@ public class TextureView extends View { public void onFrameAvailable(SurfaceTexture surfaceTexture) { // Per SurfaceTexture's documentation, the callback may be invoked // from an arbitrary thread post(mUpdateLayerAction); synchronized (mLock) { mUpdateLayer = true; postInvalidate(); } } }; mSurface.setOnFrameAvailableListener(mUpdateListener); Loading @@ -265,6 +267,13 @@ public class TextureView extends View { } } synchronized (mLock) { if (mUpdateLayer) { mAttachInfo.mHardwareRenderer.updateTextureLayer(mLayer, getWidth(), getHeight()); mUpdateLayer = false; } } return mLayer; } Loading @@ -278,23 +287,15 @@ public class TextureView extends View { // updates listener if (visibility == VISIBLE) { mSurface.setOnFrameAvailableListener(mUpdateListener); updateLayer(); // No need to synchronize here, we set update layer to false only on the UI thread mUpdateLayer = true; invalidate(); } else { mSurface.setOnFrameAvailableListener(null); } } } private void updateLayer() { if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { return; } mAttachInfo.mHardwareRenderer.updateTextureLayer(mLayer, getWidth(), getHeight()); invalidate(); } /** * <p>Returns a {@link android.graphics.Bitmap} representation of the content * of the associated surface texture. If the surface texture is not available, Loading core/jni/android_view_GLES20Canvas.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -649,8 +649,9 @@ static void android_view_GLES20Canvas_updateTextureLayer(JNIEnv* env, jobject cl float transform[16]; sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, surface)); while (surfaceTexture->getQueuedCount() > 0) while (surfaceTexture->getQueuedCount() > 0) { surfaceTexture->updateTexImage(); } surfaceTexture->getTransformMatrix(transform); GLenum renderTarget = surfaceTexture->getCurrentTextureTarget(); Loading Loading
core/java/android/view/TextureView.java +19 −18 Original line number Diff line number Diff line Loading @@ -96,12 +96,9 @@ public class TextureView extends View { private SurfaceTexture mSurface; private SurfaceTextureListener mListener; private final Runnable mUpdateLayerAction = new Runnable() { @Override public void run() { updateLayer(); } }; private final Object[] mLock = new Object[0]; private boolean mUpdateLayer; private SurfaceTexture.OnFrameAvailableListener mUpdateListener; /** Loading Loading @@ -232,6 +229,8 @@ public class TextureView extends View { protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); if (mSurface != null) { // No need to synchronize here, we set update layer to false only on the UI thread mUpdateLayer = true; nSetDefaultBufferSize(mSurface, getWidth(), getHeight()); if (mListener != null) { mListener.onSurfaceTextureSizeChanged(mSurface, getWidth(), getHeight()); Loading @@ -255,7 +254,10 @@ public class TextureView extends View { public void onFrameAvailable(SurfaceTexture surfaceTexture) { // Per SurfaceTexture's documentation, the callback may be invoked // from an arbitrary thread post(mUpdateLayerAction); synchronized (mLock) { mUpdateLayer = true; postInvalidate(); } } }; mSurface.setOnFrameAvailableListener(mUpdateListener); Loading @@ -265,6 +267,13 @@ public class TextureView extends View { } } synchronized (mLock) { if (mUpdateLayer) { mAttachInfo.mHardwareRenderer.updateTextureLayer(mLayer, getWidth(), getHeight()); mUpdateLayer = false; } } return mLayer; } Loading @@ -278,23 +287,15 @@ public class TextureView extends View { // updates listener if (visibility == VISIBLE) { mSurface.setOnFrameAvailableListener(mUpdateListener); updateLayer(); // No need to synchronize here, we set update layer to false only on the UI thread mUpdateLayer = true; invalidate(); } else { mSurface.setOnFrameAvailableListener(null); } } } private void updateLayer() { if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { return; } mAttachInfo.mHardwareRenderer.updateTextureLayer(mLayer, getWidth(), getHeight()); invalidate(); } /** * <p>Returns a {@link android.graphics.Bitmap} representation of the content * of the associated surface texture. If the surface texture is not available, Loading
core/jni/android_view_GLES20Canvas.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -649,8 +649,9 @@ static void android_view_GLES20Canvas_updateTextureLayer(JNIEnv* env, jobject cl float transform[16]; sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, surface)); while (surfaceTexture->getQueuedCount() > 0) while (surfaceTexture->getQueuedCount() > 0) { surfaceTexture->updateTexImage(); } surfaceTexture->getTransformMatrix(transform); GLenum renderTarget = surfaceTexture->getCurrentTextureTarget(); Loading