TextureView.java revision a9489274d67b540804aafb587a226f7c2ae4464d
1aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy/* 2aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Copyright (C) 2011 The Android Open Source Project 3aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 4aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Licensed under the Apache License, Version 2.0 (the "License"); 5aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * you may not use this file except in compliance with the License. 6aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * You may obtain a copy of the License at 7aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 8aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * http://www.apache.org/licenses/LICENSE-2.0 9aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 10aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Unless required by applicable law or agreed to in writing, software 11aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * distributed under the License is distributed on an "AS IS" BASIS, 12aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * See the License for the specific language governing permissions and 14aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * limitations under the License. 15aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 16aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 17aa6c24c21c727a196451332448d4e3b11a80be69Romain Guypackage android.view; 18aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 19aa6c24c21c727a196451332448d4e3b11a80be69Romain Guyimport android.content.Context; 2077a811610f99e21da7f88dafef60d09f345d0506Romain Guyimport android.graphics.Bitmap; 21aa6c24c21c727a196451332448d4e3b11a80be69Romain Guyimport android.graphics.Canvas; 22aa6c24c21c727a196451332448d4e3b11a80be69Romain Guyimport android.graphics.Paint; 23aa6c24c21c727a196451332448d4e3b11a80be69Romain Guyimport android.graphics.SurfaceTexture; 24aa6c24c21c727a196451332448d4e3b11a80be69Romain Guyimport android.util.AttributeSet; 25aa6c24c21c727a196451332448d4e3b11a80be69Romain Guyimport android.util.Log; 26aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 27aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy/** 28aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * <p>A TextureView can be used to display a content stream. Such a content 29aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * stream can for instance be a video or an OpenGL scene. The content stream 30aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * can come from the application's process as well as a remote process.</p> 31aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 32aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * <p>TextureView can only be used in a hardware accelerated window. When 33aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * rendered in software, TextureView will draw nothing.</p> 34aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 35aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * <p>Unlike {@link SurfaceView}, TextureView does not create a separate 36aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * window but behaves as a regular View. This key difference allows a 37aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * TextureView to be moved, transformed, animated, etc. For instance, you 38aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * can make a TextureView semi-translucent by calling 39aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * <code>myView.setAlpha(0.5f)</code>.</p> 40aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 41aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * <p>Using a TextureView is simple: all you need to do is get its 42aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * {@link SurfaceTexture}. The {@link SurfaceTexture} can then be used to 43aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * render content. The following example demonstrates how to render the 44aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * camera preview into a TextureView:</p> 45aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 46aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * <pre> 47aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * public class LiveCameraActivity extends Activity implements TextureView.SurfaceTextureListener { 48aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * private Camera mCamera; 49aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * private TextureView mTextureView; 50aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 51aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * protected void onCreate(Bundle savedInstanceState) { 52aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * super.onCreate(savedInstanceState); 53aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 54aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * mTextureView = new TextureView(this); 55aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * mTextureView.setSurfaceTextureListener(this); 56aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 57aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * setContentView(mTextureView); 58aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * } 59aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 60451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy * public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { 61aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * mCamera = Camera.open(); 62aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 63aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * try { 64aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * mCamera.setPreviewTexture(surface); 65aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * mCamera.startPreview(); 66aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * } catch (IOException ioe) { 67aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * // Something bad happened 68aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * } 69aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * } 708f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy * 718f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy * public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { 728f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy * // Ignored, Camera does all the work for us 738f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy * } 74451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy * 75451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy * public void onSurfaceTextureDestroyed(SurfaceTexture surface) { 76451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy * mCamera.stopPreview(); 77451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy * mCamera.release(); 78451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy * } 79aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * } 80aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * </pre> 81aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 82aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * <p>A TextureView's SurfaceTexture can be obtained either by invoking 83aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * {@link #getSurfaceTexture()} or by using a {@link SurfaceTextureListener}. 84aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * It is important to know that a SurfaceTexture is available only after the 85aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * TextureView is attached to a window (and {@link #onAttachedToWindow()} has 86aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * been invoked.) It is therefore highly recommended you use a listener to 87aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * be notified when the SurfaceTexture becomes available.</p> 88aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 89aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @see SurfaceView 90aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @see SurfaceTexture 91aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 92aa6c24c21c727a196451332448d4e3b11a80be69Romain Guypublic class TextureView extends View { 9377a811610f99e21da7f88dafef60d09f345d0506Romain Guy private static final String LOG_TAG = "TextureView"; 9477a811610f99e21da7f88dafef60d09f345d0506Romain Guy 95aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy private HardwareLayer mLayer; 96aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy private SurfaceTexture mSurface; 97aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy private SurfaceTextureListener mListener; 98aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 99a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy private boolean mOpaque = true; 100c989d867f2580a99cde25fab0e49e445aea33f2fRomain Guy 101a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy private final Runnable mUpdateLayerAction = new Runnable() { 102a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy @Override 103a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy public void run() { 104a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy updateLayer(); 105a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy } 106a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy }; 1078f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy private SurfaceTexture.OnFrameAvailableListener mUpdateListener; 108aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 109aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 110aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Creates a new TextureView. 111aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 112aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @param context The context to associate this view with. 113aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 114aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy public TextureView(Context context) { 115aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy super(context); 116aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy init(); 117aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 118aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 119aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 120aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Creates a new TextureView. 121aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 122aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @param context The context to associate this view with. 123aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @param attrs The attributes of the XML tag that is inflating the view. 124aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 125aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy @SuppressWarnings({"UnusedDeclaration"}) 126aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy public TextureView(Context context, AttributeSet attrs) { 127aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy super(context, attrs); 128aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy init(); 129aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 130aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 131aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 132aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Creates a new TextureView. 133aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 134aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @param context The context to associate this view with. 135aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @param attrs The attributes of the XML tag that is inflating the view. 136aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @param defStyle The default style to apply to this view. If 0, no style 137aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * will be applied (beyond what is included in the theme). This may 138aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * either be an attribute resource, whose value will be retrieved 139aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * from the current theme, or an explicit style resource. 140aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 141aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy @SuppressWarnings({"UnusedDeclaration"}) 142aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy public TextureView(Context context, AttributeSet attrs, int defStyle) { 143aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy super(context, attrs, defStyle); 144aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy init(); 145aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 146aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 147aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy private void init() { 148aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy mLayerPaint = new Paint(); 149aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 150aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 151a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy /** 152a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy * {@inheritDoc} 153a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy */ 154a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy @Override 155a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy public boolean isOpaque() { 156a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy return mOpaque; 157a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy } 158a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy 159a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy /** 160a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy * Indicates whether the content of this TextureView is opaque. The 161a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy * content is assumed to be opaque by default. 162a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy * 163a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy * @param opaque True if the content of this TextureView is opaque, 164a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy * false otherwise 165a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy */ 166a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy public void setOpaque(boolean opaque) { 167a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy if (opaque != mOpaque) { 168a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy mOpaque = opaque; 169a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy updateLayer(); 170a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy } 171a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy } 172a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy 173aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy @Override 174aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy protected void onAttachedToWindow() { 175aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy super.onAttachedToWindow(); 176aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 177aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy if (!isHardwareAccelerated()) { 17877a811610f99e21da7f88dafef60d09f345d0506Romain Guy Log.w(LOG_TAG, "A TextureView or a subclass can only be " 179aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy + "used with hardware acceleration enabled."); 180aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 181aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 182aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 183451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy @Override 184451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy protected void onDetachedFromWindow() { 185451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy super.onDetachedFromWindow(); 186451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy 187451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy if (isHardwareAccelerated() && mLayer != null) { 188451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy if (mListener != null) { 189451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy mListener.onSurfaceTextureDestroyed(mSurface); 190451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy } 191451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy 192451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy mLayer.destroy(); 193451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy mSurface = null; 194451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy mLayer = null; 195451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy } 196451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy } 197451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy 198aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 199aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * The layer type of a TextureView is ignored since a TextureView is always 200aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * considered to act as a hardware layer. The optional paint supplied to this 201aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * method will however be taken into account when rendering the content of 202aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * this TextureView. 203aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 204aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @param layerType The ype of layer to use with this view, must be one of 205aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or 206aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * {@link #LAYER_TYPE_HARDWARE} 207aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @param paint The paint used to compose the layer. This argument is optional 208aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * and can be null. It is ignored when the layer type is 209aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * {@link #LAYER_TYPE_NONE} 210aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 211aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy @Override 212aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy public void setLayerType(int layerType, Paint paint) { 213aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy if (paint != mLayerPaint) { 214aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy mLayerPaint = paint; 215aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy invalidate(); 216aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 217aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 218aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 219aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 220aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Always returns {@link #LAYER_TYPE_HARDWARE}. 221aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 222aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy @Override 223aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy public int getLayerType() { 224aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy return LAYER_TYPE_HARDWARE; 225aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 226aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 227aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 228aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Calling this method has no effect. 229aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 230aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy @Override 231aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy public void buildLayer() { 232aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 233aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 234aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 235aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Subclasses of TextureView cannot do their own rendering 236aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * with the {@link Canvas} object. 237aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 238aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @param canvas The Canvas to which the View is rendered. 239aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 240aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy @Override 241aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy public final void draw(Canvas canvas) { 242aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 243aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 244aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 245aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Subclasses of TextureView cannot do their own rendering 246aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * with the {@link Canvas} object. 247aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 248aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @param canvas The Canvas to which the View is rendered. 249aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 250aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy @Override 251aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy protected final void onDraw(Canvas canvas) { 252aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 253aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 254aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy @Override 2558f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy protected void onSizeChanged(int w, int h, int oldw, int oldh) { 2568f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy super.onSizeChanged(w, h, oldw, oldh); 2578f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy if (mSurface != null) { 258e5e0c50f7dfaccc220725c5595080e921ffda1e4Romain Guy nSetDefaultBufferSize(mSurface, getWidth(), getHeight()); 259451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy if (mListener != null) { 260451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy mListener.onSurfaceTextureSizeChanged(mSurface, getWidth(), getHeight()); 261451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy } 2628f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy } 2638f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy } 2648f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy 2658f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy @Override 266aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy HardwareLayer getHardwareLayer() { 267aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { 268aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy return null; 269aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 270aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 271aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy if (mLayer == null) { 272a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy mLayer = mAttachInfo.mHardwareRenderer.createHardwareLayer(mOpaque); 273e5e0c50f7dfaccc220725c5595080e921ffda1e4Romain Guy mSurface = mAttachInfo.mHardwareRenderer.createSurfaceTexture(mLayer); 274e5e0c50f7dfaccc220725c5595080e921ffda1e4Romain Guy nSetDefaultBufferSize(mSurface, getWidth(), getHeight()); 275aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 2768f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy mUpdateListener = new SurfaceTexture.OnFrameAvailableListener() { 277aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy @Override 278aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy public void onFrameAvailable(SurfaceTexture surfaceTexture) { 279aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy // Per SurfaceTexture's documentation, the callback may be invoked 280aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy // from an arbitrary thread 281a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy post(mUpdateLayerAction); 282aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 2838f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy }; 2848f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy mSurface.setOnFrameAvailableListener(mUpdateListener); 285aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 286aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy if (mListener != null) { 287451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy mListener.onSurfaceTextureAvailable(mSurface, getWidth(), getHeight()); 288aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 289aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 290aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 291aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy return mLayer; 292aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 293aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 2948f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy @Override 2958f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy protected void onVisibilityChanged(View changedView, int visibility) { 2968f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy super.onVisibilityChanged(changedView, visibility); 2978f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy 2988f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy if (mSurface != null) { 2998f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy // When the view becomes invisible, stop updating it, it's a waste of CPU 3008f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy // To cancel updates, the easiest thing to do is simply to remove the 3018f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy // updates listener 3028f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy if (visibility == VISIBLE) { 3038f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy mSurface.setOnFrameAvailableListener(mUpdateListener); 304a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy updateLayer(); 3058f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy } else { 3068f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy mSurface.setOnFrameAvailableListener(null); 3078f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy } 3088f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy } 3098f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy } 3108f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy 311a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy private void updateLayer() { 312a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { 313a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy return; 314a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy } 315a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy 316a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy mAttachInfo.mHardwareRenderer.updateTextureLayer(mLayer, getWidth(), getHeight(), mOpaque); 317a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy 318a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy invalidate(); 319a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy } 320a9489274d67b540804aafb587a226f7c2ae4464dRomain Guy 321aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 32277a811610f99e21da7f88dafef60d09f345d0506Romain Guy * <p>Returns a {@link android.graphics.Bitmap} representation of the content 32377a811610f99e21da7f88dafef60d09f345d0506Romain Guy * of the associated surface texture. If the surface texture is not available, 32477a811610f99e21da7f88dafef60d09f345d0506Romain Guy * this method returns null.</p> 32577a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 32677a811610f99e21da7f88dafef60d09f345d0506Romain Guy * <p>The bitmap returned by this method uses the {@link Bitmap.Config#ARGB_8888} 32777a811610f99e21da7f88dafef60d09f345d0506Romain Guy * pixel format and its dimensions are the same as this view's.</p> 32877a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 32977a811610f99e21da7f88dafef60d09f345d0506Romain Guy * <p><strong>Do not</strong> invoke this method from a drawing method 33077a811610f99e21da7f88dafef60d09f345d0506Romain Guy * ({@link #onDraw(android.graphics.Canvas)} for instance).</p> 33177a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 332d6b2a00dd43257d1498b09175bff63663f6cb861Romain Guy * <p>If an error occurs during the copy, an empty bitmap will be returned.</p> 333d6b2a00dd43257d1498b09175bff63663f6cb861Romain Guy * 33477a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @return A valid {@link Bitmap.Config#ARGB_8888} bitmap, or null if the surface 33577a811610f99e21da7f88dafef60d09f345d0506Romain Guy * texture is not available or the width <= 0 or the height <= 0 33677a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 33777a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @see #isAvailable() 33877a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @see #getBitmap(android.graphics.Bitmap) 33977a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @see #getBitmap(int, int) 34077a811610f99e21da7f88dafef60d09f345d0506Romain Guy */ 34177a811610f99e21da7f88dafef60d09f345d0506Romain Guy public Bitmap getBitmap() { 34277a811610f99e21da7f88dafef60d09f345d0506Romain Guy return getBitmap(getWidth(), getHeight()); 34377a811610f99e21da7f88dafef60d09f345d0506Romain Guy } 34477a811610f99e21da7f88dafef60d09f345d0506Romain Guy 34577a811610f99e21da7f88dafef60d09f345d0506Romain Guy /** 34677a811610f99e21da7f88dafef60d09f345d0506Romain Guy * <p>Returns a {@link android.graphics.Bitmap} representation of the content 34777a811610f99e21da7f88dafef60d09f345d0506Romain Guy * of the associated surface texture. If the surface texture is not available, 34877a811610f99e21da7f88dafef60d09f345d0506Romain Guy * this method returns null.</p> 34977a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 35077a811610f99e21da7f88dafef60d09f345d0506Romain Guy * <p>The bitmap returned by this method uses the {@link Bitmap.Config#ARGB_8888} 35177a811610f99e21da7f88dafef60d09f345d0506Romain Guy * pixel format.</p> 35277a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 35377a811610f99e21da7f88dafef60d09f345d0506Romain Guy * <p><strong>Do not</strong> invoke this method from a drawing method 35477a811610f99e21da7f88dafef60d09f345d0506Romain Guy * ({@link #onDraw(android.graphics.Canvas)} for instance).</p> 35577a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 356d6b2a00dd43257d1498b09175bff63663f6cb861Romain Guy * <p>If an error occurs during the copy, an empty bitmap will be returned.</p> 357d6b2a00dd43257d1498b09175bff63663f6cb861Romain Guy * 35877a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @param width The width of the bitmap to create 35977a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @param height The height of the bitmap to create 36077a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 36177a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @return A valid {@link Bitmap.Config#ARGB_8888} bitmap, or null if the surface 36277a811610f99e21da7f88dafef60d09f345d0506Romain Guy * texture is not available or width is <= 0 or height is <= 0 36377a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 36477a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @see #isAvailable() 36577a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @see #getBitmap(android.graphics.Bitmap) 36677a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @see #getBitmap() 36777a811610f99e21da7f88dafef60d09f345d0506Romain Guy */ 36877a811610f99e21da7f88dafef60d09f345d0506Romain Guy public Bitmap getBitmap(int width, int height) { 36977a811610f99e21da7f88dafef60d09f345d0506Romain Guy if (isAvailable() && width > 0 && height > 0) { 37077a811610f99e21da7f88dafef60d09f345d0506Romain Guy return getBitmap(Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)); 37177a811610f99e21da7f88dafef60d09f345d0506Romain Guy } 37277a811610f99e21da7f88dafef60d09f345d0506Romain Guy return null; 37377a811610f99e21da7f88dafef60d09f345d0506Romain Guy } 37477a811610f99e21da7f88dafef60d09f345d0506Romain Guy 37577a811610f99e21da7f88dafef60d09f345d0506Romain Guy /** 37677a811610f99e21da7f88dafef60d09f345d0506Romain Guy * <p>Copies the content of this view's surface texture into the specified 37777a811610f99e21da7f88dafef60d09f345d0506Romain Guy * bitmap. If the surface texture is not available, the copy is not executed. 37877a811610f99e21da7f88dafef60d09f345d0506Romain Guy * The content of the surface texture will be scaled to fit exactly inside 37977a811610f99e21da7f88dafef60d09f345d0506Romain Guy * the specified bitmap.</p> 38077a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 38177a811610f99e21da7f88dafef60d09f345d0506Romain Guy * <p><strong>Do not</strong> invoke this method from a drawing method 38277a811610f99e21da7f88dafef60d09f345d0506Romain Guy * ({@link #onDraw(android.graphics.Canvas)} for instance).</p> 38377a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 384d6b2a00dd43257d1498b09175bff63663f6cb861Romain Guy * <p>If an error occurs, the bitmap is left unchanged.</p> 385d6b2a00dd43257d1498b09175bff63663f6cb861Romain Guy * 38677a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @param bitmap The bitmap to copy the content of the surface texture into, 38777a811610f99e21da7f88dafef60d09f345d0506Romain Guy * cannot be null, all configurations are supported 38877a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 38977a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @return The bitmap specified as a parameter 39077a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 39177a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @see #isAvailable() 39277a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @see #getBitmap(int, int) 39377a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @see #getBitmap() 39477a811610f99e21da7f88dafef60d09f345d0506Romain Guy */ 39577a811610f99e21da7f88dafef60d09f345d0506Romain Guy public Bitmap getBitmap(Bitmap bitmap) { 39677a811610f99e21da7f88dafef60d09f345d0506Romain Guy if (bitmap != null && isAvailable()) { 39777a811610f99e21da7f88dafef60d09f345d0506Romain Guy mAttachInfo.mHardwareRenderer.copyLayer(mLayer, bitmap); 39877a811610f99e21da7f88dafef60d09f345d0506Romain Guy } 39977a811610f99e21da7f88dafef60d09f345d0506Romain Guy return bitmap; 40077a811610f99e21da7f88dafef60d09f345d0506Romain Guy } 40177a811610f99e21da7f88dafef60d09f345d0506Romain Guy 40277a811610f99e21da7f88dafef60d09f345d0506Romain Guy /** 40377a811610f99e21da7f88dafef60d09f345d0506Romain Guy * Returns true if the {@link SurfaceTexture} associated with this 40477a811610f99e21da7f88dafef60d09f345d0506Romain Guy * TextureView is available for rendering. When this method returns 40577a811610f99e21da7f88dafef60d09f345d0506Romain Guy * true, {@link #getSurfaceTexture()} returns a valid surface texture. 40677a811610f99e21da7f88dafef60d09f345d0506Romain Guy */ 40777a811610f99e21da7f88dafef60d09f345d0506Romain Guy public boolean isAvailable() { 40877a811610f99e21da7f88dafef60d09f345d0506Romain Guy return mSurface != null; 40977a811610f99e21da7f88dafef60d09f345d0506Romain Guy } 41077a811610f99e21da7f88dafef60d09f345d0506Romain Guy 41177a811610f99e21da7f88dafef60d09f345d0506Romain Guy /** 412aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Returns the {@link SurfaceTexture} used by this view. This method 41377a811610f99e21da7f88dafef60d09f345d0506Romain Guy * may return null if the view is not attached to a window or if the surface 41477a811610f99e21da7f88dafef60d09f345d0506Romain Guy * texture has not been initialized yet. 41577a811610f99e21da7f88dafef60d09f345d0506Romain Guy * 41677a811610f99e21da7f88dafef60d09f345d0506Romain Guy * @see #isAvailable() 417aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 418aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy public SurfaceTexture getSurfaceTexture() { 419aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy return mSurface; 420aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 421aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 422aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 423aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Returns the {@link SurfaceTextureListener} currently associated with this 424aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * texture view. 425aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 426aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @see #setSurfaceTextureListener(android.view.TextureView.SurfaceTextureListener) 427aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @see SurfaceTextureListener 428aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 429aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy public SurfaceTextureListener getSurfaceTextureListener() { 430aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy return mListener; 431aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 432aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 433aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 434aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Sets the {@link SurfaceTextureListener} used to listen to surface 435aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * texture events. 436aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 437aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @see #getSurfaceTextureListener() 438aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @see SurfaceTextureListener 439aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 440aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy public void setSurfaceTextureListener(SurfaceTextureListener listener) { 441aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy mListener = listener; 442aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 443aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy 444aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 445aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * This listener can be used to be notified when the surface texture 446aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * associated with this texture view is available. 447aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 448aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy public static interface SurfaceTextureListener { 449aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy /** 450aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * Invoked when a {@link TextureView}'s SurfaceTexture is ready for use. 451aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * 452aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * @param surface The surface returned by 453aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy * {@link android.view.TextureView#getSurfaceTexture()} 454451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy * @param width The width of the surface 455451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy * @param height The height of the surface 456aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy */ 457451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height); 4588f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy 4598f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy /** 4608f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy * Invoked when the {@link SurfaceTexture}'s buffers size changed. 4618f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy * 4628f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy * @param surface The surface returned by 4638f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy * {@link android.view.TextureView#getSurfaceTexture()} 4648f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy * @param width The new width of the surface 4658f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy * @param height The new height of the surface 4668f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy */ 4678f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height); 468451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy 469451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy /** 470451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy * Invoked when the specified {@link SurfaceTexture} is about to be destroyed. 471451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy * After this method is invoked, no rendering should happen inside the surface 472451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy * texture. 473451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy * 474451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy * @param surface The surface about to be destroyed 475451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy */ 476451ce44a18e4c48f8a43aa250957f76967a35d31Romain Guy public void onSurfaceTextureDestroyed(SurfaceTexture surface); 477aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy } 4788f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy 479d6b2a00dd43257d1498b09175bff63663f6cb861Romain Guy private static native void nSetDefaultBufferSize(SurfaceTexture surfaceTexture, 480d6b2a00dd43257d1498b09175bff63663f6cb861Romain Guy int width, int height); 481aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy} 482