Loading api/current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -21025,6 +21025,7 @@ package android.view { public static abstract interface TextureView.SurfaceTextureListener { public static abstract interface TextureView.SurfaceTextureListener { method public abstract void onSurfaceTextureAvailable(android.graphics.SurfaceTexture); method public abstract void onSurfaceTextureAvailable(android.graphics.SurfaceTexture); method public abstract void onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture, int, int); } } public class TouchDelegate { public class TouchDelegate { core/java/android/view/GLES20Canvas.java +1 −2 Original line number Original line Diff line number Diff line Loading @@ -163,8 +163,7 @@ class GLES20Canvas extends HardwareCanvas { static native int nCreateTextureLayer(int[] layerInfo); static native int nCreateTextureLayer(int[] layerInfo); static native int nCreateLayer(int width, int height, boolean isOpaque, int[] layerInfo); static native int nCreateLayer(int width, int height, boolean isOpaque, int[] layerInfo); static native void nResizeLayer(int layerId, int width, int height, int[] layerInfo); static native void nResizeLayer(int layerId, int width, int height, int[] layerInfo); static native void nUpdateTextureLayer(int layerId, int width, int height, static native void nUpdateTextureLayer(int layerId, int width, int height, int surface); float[] textureTransform); static native void nDestroyLayer(int layerId); static native void nDestroyLayer(int layerId); static native void nDestroyLayerDeferred(int layerId); static native void nDestroyLayerDeferred(int layerId); Loading core/java/android/view/GLES20TextureLayer.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -70,7 +70,7 @@ class GLES20TextureLayer extends GLES20Layer { return mSurface; return mSurface; } } void update(int width, int height, float[] textureTransform) { void update(int width, int height, int surface) { GLES20Canvas.nUpdateTextureLayer(mLayer, width, height, textureTransform); GLES20Canvas.nUpdateTextureLayer(mLayer, width, height, surface); } } } } core/java/android/view/HardwareRenderer.java +4 −5 Original line number Original line Diff line number Diff line Loading @@ -202,11 +202,10 @@ public abstract class HardwareRenderer { * @param layer The hardware layer to update * @param layer The hardware layer to update * @param width The layer's width * @param width The layer's width * @param height The layer's height * @param height The layer's height * @param textureTransform A 4x4 column-first transform matrix to apply to * @param surface The surface to update * texture coordinates */ */ abstract void updateTextureLayer(HardwareLayer layer, int width, int height, abstract void updateTextureLayer(HardwareLayer layer, int width, int height, float[] textureTransform); SurfaceTexture surface); /** /** * Initializes the hardware renderer for the specified surface and setup the * Initializes the hardware renderer for the specified surface and setup the Loading Loading @@ -906,8 +905,8 @@ public abstract class HardwareRenderer { @Override @Override void updateTextureLayer(HardwareLayer layer, int width, int height, void updateTextureLayer(HardwareLayer layer, int width, int height, float[] textureTransform) { SurfaceTexture surface) { ((GLES20TextureLayer) layer).update(width, height, textureTransform); ((GLES20TextureLayer) layer).update(width, height, surface.mSurfaceTexture); } } static HardwareRenderer create(boolean translucent) { static HardwareRenderer create(boolean translucent) { Loading core/java/android/view/TextureView.java +47 −9 Original line number Original line Diff line number Diff line Loading @@ -73,6 +73,10 @@ import android.util.Log; * // Something bad happened * // Something bad happened * } * } * } * } * * public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { * // Ignored, Camera does all the work for us * } * } * } * </pre> * </pre> * * Loading @@ -91,14 +95,13 @@ public class TextureView extends View { private SurfaceTexture mSurface; private SurfaceTexture mSurface; private SurfaceTextureListener mListener; private SurfaceTextureListener mListener; private final float[] mTextureTransform = new float[16]; private final Runnable mUpdateLayerAction = new Runnable() { private final Runnable mUpdateLayerAction = new Runnable() { @Override @Override public void run() { public void run() { updateLayer(); updateLayer(); } } }; }; private SurfaceTexture.OnFrameAvailableListener mUpdateListener; /** /** * Creates a new TextureView. * Creates a new TextureView. Loading Loading @@ -209,6 +212,14 @@ public class TextureView extends View { protected final void onDraw(Canvas canvas) { protected final void onDraw(Canvas canvas) { } } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); if (mSurface != null) { nSetDefaultBufferSize(mSurface.mSurfaceTexture, getWidth(), getHeight()); } } @Override @Override HardwareLayer getHardwareLayer() { HardwareLayer getHardwareLayer() { if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { Loading @@ -218,15 +229,17 @@ public class TextureView extends View { if (mLayer == null) { if (mLayer == null) { mLayer = mAttachInfo.mHardwareRenderer.createHardwareLayer(); mLayer = mAttachInfo.mHardwareRenderer.createHardwareLayer(); mSurface = mAttachInfo.mHardwareRenderer.createSuraceTexture(mLayer); mSurface = mAttachInfo.mHardwareRenderer.createSuraceTexture(mLayer); nSetDefaultBufferSize(mSurface.mSurfaceTexture, getWidth(), getHeight()); mSurface.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() { mUpdateListener = new SurfaceTexture.OnFrameAvailableListener() { @Override @Override public void onFrameAvailable(SurfaceTexture surfaceTexture) { public void onFrameAvailable(SurfaceTexture surfaceTexture) { // Per SurfaceTexture's documentation, the callback may be invoked // Per SurfaceTexture's documentation, the callback may be invoked // from an arbitrary thread // from an arbitrary thread post(mUpdateLayerAction); post(mUpdateLayerAction); } } }); }; mSurface.setOnFrameAvailableListener(mUpdateListener); if (mListener != null) { if (mListener != null) { mListener.onSurfaceTextureAvailable(mSurface); mListener.onSurfaceTextureAvailable(mSurface); Loading @@ -236,16 +249,29 @@ public class TextureView extends View { return mLayer; return mLayer; } } @Override protected void onVisibilityChanged(View changedView, int visibility) { super.onVisibilityChanged(changedView, visibility); if (mSurface != null) { // When the view becomes invisible, stop updating it, it's a waste of CPU // To cancel updates, the easiest thing to do is simply to remove the // updates listener if (visibility == VISIBLE) { mSurface.setOnFrameAvailableListener(mUpdateListener); updateLayer(); } else { mSurface.setOnFrameAvailableListener(null); } } } private void updateLayer() { private void updateLayer() { if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { return; return; } } mSurface.updateTexImage(); mAttachInfo.mHardwareRenderer.updateTextureLayer(mLayer, getWidth(), getHeight(), mSurface); mSurface.getTransformMatrix(mTextureTransform); mAttachInfo.mHardwareRenderer.updateTextureLayer(mLayer, getWidth(), getHeight(), mTextureTransform); invalidate(); invalidate(); } } Loading Loading @@ -292,5 +318,17 @@ public class TextureView extends View { * {@link android.view.TextureView#getSurfaceTexture()} * {@link android.view.TextureView#getSurfaceTexture()} */ */ public void onSurfaceTextureAvailable(SurfaceTexture surface); public void onSurfaceTextureAvailable(SurfaceTexture surface); /** * Invoked when the {@link SurfaceTexture}'s buffers size changed. * * @param surface The surface returned by * {@link android.view.TextureView#getSurfaceTexture()} * @param width The new width of the surface * @param height The new height of the surface */ public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height); } } private static native void nSetDefaultBufferSize(int surfaceTexture, int width, int height); } } Loading
api/current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -21025,6 +21025,7 @@ package android.view { public static abstract interface TextureView.SurfaceTextureListener { public static abstract interface TextureView.SurfaceTextureListener { method public abstract void onSurfaceTextureAvailable(android.graphics.SurfaceTexture); method public abstract void onSurfaceTextureAvailable(android.graphics.SurfaceTexture); method public abstract void onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture, int, int); } } public class TouchDelegate { public class TouchDelegate {
core/java/android/view/GLES20Canvas.java +1 −2 Original line number Original line Diff line number Diff line Loading @@ -163,8 +163,7 @@ class GLES20Canvas extends HardwareCanvas { static native int nCreateTextureLayer(int[] layerInfo); static native int nCreateTextureLayer(int[] layerInfo); static native int nCreateLayer(int width, int height, boolean isOpaque, int[] layerInfo); static native int nCreateLayer(int width, int height, boolean isOpaque, int[] layerInfo); static native void nResizeLayer(int layerId, int width, int height, int[] layerInfo); static native void nResizeLayer(int layerId, int width, int height, int[] layerInfo); static native void nUpdateTextureLayer(int layerId, int width, int height, static native void nUpdateTextureLayer(int layerId, int width, int height, int surface); float[] textureTransform); static native void nDestroyLayer(int layerId); static native void nDestroyLayer(int layerId); static native void nDestroyLayerDeferred(int layerId); static native void nDestroyLayerDeferred(int layerId); Loading
core/java/android/view/GLES20TextureLayer.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -70,7 +70,7 @@ class GLES20TextureLayer extends GLES20Layer { return mSurface; return mSurface; } } void update(int width, int height, float[] textureTransform) { void update(int width, int height, int surface) { GLES20Canvas.nUpdateTextureLayer(mLayer, width, height, textureTransform); GLES20Canvas.nUpdateTextureLayer(mLayer, width, height, surface); } } } }
core/java/android/view/HardwareRenderer.java +4 −5 Original line number Original line Diff line number Diff line Loading @@ -202,11 +202,10 @@ public abstract class HardwareRenderer { * @param layer The hardware layer to update * @param layer The hardware layer to update * @param width The layer's width * @param width The layer's width * @param height The layer's height * @param height The layer's height * @param textureTransform A 4x4 column-first transform matrix to apply to * @param surface The surface to update * texture coordinates */ */ abstract void updateTextureLayer(HardwareLayer layer, int width, int height, abstract void updateTextureLayer(HardwareLayer layer, int width, int height, float[] textureTransform); SurfaceTexture surface); /** /** * Initializes the hardware renderer for the specified surface and setup the * Initializes the hardware renderer for the specified surface and setup the Loading Loading @@ -906,8 +905,8 @@ public abstract class HardwareRenderer { @Override @Override void updateTextureLayer(HardwareLayer layer, int width, int height, void updateTextureLayer(HardwareLayer layer, int width, int height, float[] textureTransform) { SurfaceTexture surface) { ((GLES20TextureLayer) layer).update(width, height, textureTransform); ((GLES20TextureLayer) layer).update(width, height, surface.mSurfaceTexture); } } static HardwareRenderer create(boolean translucent) { static HardwareRenderer create(boolean translucent) { Loading
core/java/android/view/TextureView.java +47 −9 Original line number Original line Diff line number Diff line Loading @@ -73,6 +73,10 @@ import android.util.Log; * // Something bad happened * // Something bad happened * } * } * } * } * * public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { * // Ignored, Camera does all the work for us * } * } * } * </pre> * </pre> * * Loading @@ -91,14 +95,13 @@ public class TextureView extends View { private SurfaceTexture mSurface; private SurfaceTexture mSurface; private SurfaceTextureListener mListener; private SurfaceTextureListener mListener; private final float[] mTextureTransform = new float[16]; private final Runnable mUpdateLayerAction = new Runnable() { private final Runnable mUpdateLayerAction = new Runnable() { @Override @Override public void run() { public void run() { updateLayer(); updateLayer(); } } }; }; private SurfaceTexture.OnFrameAvailableListener mUpdateListener; /** /** * Creates a new TextureView. * Creates a new TextureView. Loading Loading @@ -209,6 +212,14 @@ public class TextureView extends View { protected final void onDraw(Canvas canvas) { protected final void onDraw(Canvas canvas) { } } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); if (mSurface != null) { nSetDefaultBufferSize(mSurface.mSurfaceTexture, getWidth(), getHeight()); } } @Override @Override HardwareLayer getHardwareLayer() { HardwareLayer getHardwareLayer() { if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { Loading @@ -218,15 +229,17 @@ public class TextureView extends View { if (mLayer == null) { if (mLayer == null) { mLayer = mAttachInfo.mHardwareRenderer.createHardwareLayer(); mLayer = mAttachInfo.mHardwareRenderer.createHardwareLayer(); mSurface = mAttachInfo.mHardwareRenderer.createSuraceTexture(mLayer); mSurface = mAttachInfo.mHardwareRenderer.createSuraceTexture(mLayer); nSetDefaultBufferSize(mSurface.mSurfaceTexture, getWidth(), getHeight()); mSurface.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() { mUpdateListener = new SurfaceTexture.OnFrameAvailableListener() { @Override @Override public void onFrameAvailable(SurfaceTexture surfaceTexture) { public void onFrameAvailable(SurfaceTexture surfaceTexture) { // Per SurfaceTexture's documentation, the callback may be invoked // Per SurfaceTexture's documentation, the callback may be invoked // from an arbitrary thread // from an arbitrary thread post(mUpdateLayerAction); post(mUpdateLayerAction); } } }); }; mSurface.setOnFrameAvailableListener(mUpdateListener); if (mListener != null) { if (mListener != null) { mListener.onSurfaceTextureAvailable(mSurface); mListener.onSurfaceTextureAvailable(mSurface); Loading @@ -236,16 +249,29 @@ public class TextureView extends View { return mLayer; return mLayer; } } @Override protected void onVisibilityChanged(View changedView, int visibility) { super.onVisibilityChanged(changedView, visibility); if (mSurface != null) { // When the view becomes invisible, stop updating it, it's a waste of CPU // To cancel updates, the easiest thing to do is simply to remove the // updates listener if (visibility == VISIBLE) { mSurface.setOnFrameAvailableListener(mUpdateListener); updateLayer(); } else { mSurface.setOnFrameAvailableListener(null); } } } private void updateLayer() { private void updateLayer() { if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { return; return; } } mSurface.updateTexImage(); mAttachInfo.mHardwareRenderer.updateTextureLayer(mLayer, getWidth(), getHeight(), mSurface); mSurface.getTransformMatrix(mTextureTransform); mAttachInfo.mHardwareRenderer.updateTextureLayer(mLayer, getWidth(), getHeight(), mTextureTransform); invalidate(); invalidate(); } } Loading Loading @@ -292,5 +318,17 @@ public class TextureView extends View { * {@link android.view.TextureView#getSurfaceTexture()} * {@link android.view.TextureView#getSurfaceTexture()} */ */ public void onSurfaceTextureAvailable(SurfaceTexture surface); public void onSurfaceTextureAvailable(SurfaceTexture surface); /** * Invoked when the {@link SurfaceTexture}'s buffers size changed. * * @param surface The surface returned by * {@link android.view.TextureView#getSurfaceTexture()} * @param width The new width of the surface * @param height The new height of the surface */ public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height); } } private static native void nSetDefaultBufferSize(int surfaceTexture, int width, int height); } }