1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.graphics;
18 
19 import android.annotation.FloatRange;
20 import android.annotation.Nullable;
21 import android.annotation.SuppressLint;
22 import android.compat.annotation.UnsupportedAppUsage;
23 import android.hardware.DataSpace.NamedDataSpace;
24 import android.os.Build;
25 import android.os.Handler;
26 import android.os.Looper;
27 import android.os.Message;
28 import android.os.Trace;
29 import android.view.Surface;
30 import android.view.TextureView;
31 import android.view.flags.Flags;
32 
33 import java.lang.ref.WeakReference;
34 
35 /**
36  * Captures frames from an image stream as an OpenGL ES texture.
37  *
38  * <p>The image stream may come from either camera preview or video decode. A
39  * {@link android.view.Surface} created from a SurfaceTexture can be used as an output
40  * destination for the {@link android.hardware.camera2}, {@link android.media.MediaCodec},
41  * {@link android.media.MediaPlayer}, and {@link android.renderscript.Allocation} APIs.
42  * When {@link #updateTexImage} is called, the contents of the texture object specified
43  * when the SurfaceTexture was created are updated to contain the most recent image from the image
44  * stream.  This may cause some frames of the stream to be skipped.
45  *
46  * <p>A SurfaceTexture may also be used in place of a SurfaceHolder when specifying the output
47  * destination of the older {@link android.hardware.Camera} API. Doing so will cause all the
48  * frames from the image stream to be sent to the SurfaceTexture object rather than to the device's
49  * display.
50  *
51  * <p>A typical pattern is to use SurfaceTexture to render frames to a {@link TextureView}; however,
52  * a TextureView is not <i>required</i> for using the texture object. The texture object may be used
53  * as part of an OpenGL ES shader.
54  *
55  * <p>When sampling from the texture one should first transform the texture coordinates using the
56  * matrix queried via {@link #getTransformMatrix(float[])}.  The transform matrix may change each
57  * time {@link #updateTexImage} is called, so it should be re-queried each time the texture image
58  * is updated.
59  * This matrix transforms traditional 2D OpenGL ES texture coordinate column vectors of the form (s,
60  * t, 0, 1) where s and t are on the inclusive interval [0, 1] to the proper sampling location in
61  * the streamed texture.  This transform compensates for any properties of the image stream source
62  * that cause it to appear different from a traditional OpenGL ES texture.  For example, sampling
63  * from the bottom left corner of the image can be accomplished by transforming the column vector
64  * (0, 0, 0, 1) using the queried matrix, while sampling from the top right corner of the image can
65  * be done by transforming (1, 1, 0, 1).
66  *
67  * <p>The texture object uses the GL_TEXTURE_EXTERNAL_OES texture target, which is defined by the
68  * <a href="http://www.khronos.org/registry/gles/extensions/OES/OES_EGL_image_external.txt">
69  * GL_OES_EGL_image_external</a> OpenGL ES extension.  This limits how the texture may be used.
70  * Each time the texture is bound it must be bound to the GL_TEXTURE_EXTERNAL_OES target rather than
71  * the GL_TEXTURE_2D target.  Additionally, any OpenGL ES 2.0 shader that samples from the texture
72  * must declare its use of this extension using, for example, an "#extension
73  * GL_OES_EGL_image_external : require" directive.  Such shaders must also access the texture using
74  * the samplerExternalOES GLSL sampler type.
75  *
76  * <p>SurfaceTexture objects may be created on any thread.  {@link #updateTexImage} may only be
77  * called on the thread with the OpenGL ES context that contains the texture object.  The
78  * frame-available callback is called on an arbitrary thread, so unless special care is taken {@link
79  * #updateTexImage} should not be called directly from the callback.
80  */
81 public class SurfaceTexture {
82     private final Looper mCreatorLooper;
83     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
84     private Handler mOnFrameAvailableHandler;
85     private Handler mOnSetFrameRateHandler;
86 
87     /**
88      * These fields are used by native code, do not access or modify.
89      */
90     @UnsupportedAppUsage(trackingBug = 176388660)
91     private long mSurfaceTexture;
92     @UnsupportedAppUsage(trackingBug = 176388660)
93     private long mProducer;
94     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
95     private long mFrameAvailableListener;
96 
97     private boolean mIsSingleBuffered;
98 
99     /**
100      * Callback interface for being notified that a new stream frame is available.
101      */
102     public interface OnFrameAvailableListener {
onFrameAvailable(SurfaceTexture surfaceTexture)103         void onFrameAvailable(SurfaceTexture surfaceTexture);
104     }
105 
106     /**
107      * Callback interface for being notified that a producer set a frame rate
108      * @hide
109      */
110     public interface OnSetFrameRateListener {
111         /**
112          * Called when the producer sets a frame rate
113          * @hide
114          */
onSetFrameRate(SurfaceTexture surfaceTexture, @FloatRange(from = 0.0) float frameRate, @Surface.FrameRateCompatibility int compatibility, @Surface.ChangeFrameRateStrategy int changeFrameRateStrategy)115         void onSetFrameRate(SurfaceTexture surfaceTexture,
116                             @FloatRange(from = 0.0) float frameRate,
117                                  @Surface.FrameRateCompatibility int compatibility,
118                                  @Surface.ChangeFrameRateStrategy int changeFrameRateStrategy);
119     }
120 
121     /**
122      * Exception thrown when a SurfaceTexture couldn't be created or resized.
123      *
124      * @deprecated No longer thrown. {@link android.view.Surface.OutOfResourcesException}
125      * is used instead.
126      */
127     @SuppressWarnings("serial")
128     @Deprecated
129     public static class OutOfResourcesException extends Exception {
OutOfResourcesException()130         public OutOfResourcesException() {
131         }
OutOfResourcesException(String name)132         public OutOfResourcesException(String name) {
133             super(name);
134         }
135     }
136 
137     /**
138      * Construct a new SurfaceTexture to stream images to a given OpenGL texture.
139      *
140      * @param texName the OpenGL texture object name (e.g. generated via glGenTextures)
141      *
142      * @throws android.view.Surface.OutOfResourcesException If the SurfaceTexture cannot be created.
143      */
SurfaceTexture(int texName)144     public SurfaceTexture(int texName) {
145         this(texName, false);
146     }
147 
148     /**
149      * Construct a new SurfaceTexture to stream images to a given OpenGL texture.
150      * <p>
151      * In single buffered mode the application is responsible for serializing access to the image
152      * content buffer. Each time the image content is to be updated, the
153      * {@link #releaseTexImage()} method must be called before the image content producer takes
154      * ownership of the buffer. For example, when producing image content with the NDK
155      * ANativeWindow_lock and ANativeWindow_unlockAndPost functions, {@link #releaseTexImage()}
156      * must be called before each ANativeWindow_lock, or that call will fail. When producing
157      * image content with OpenGL ES, {@link #releaseTexImage()} must be called before the first
158      * OpenGL ES function call each frame.
159      *
160      * @param texName the OpenGL texture object name (e.g. generated via glGenTextures)
161      * @param singleBufferMode whether the SurfaceTexture will be in single buffered mode.
162      *
163      * @throws android.view.Surface.OutOfResourcesException If the SurfaceTexture cannot be created.
164      */
SurfaceTexture(int texName, boolean singleBufferMode)165     public SurfaceTexture(int texName, boolean singleBufferMode) {
166         mCreatorLooper = Looper.myLooper();
167         mIsSingleBuffered = singleBufferMode;
168         nativeInit(false, texName, singleBufferMode, new WeakReference<SurfaceTexture>(this));
169     }
170 
171     /**
172      * Construct a new SurfaceTexture to stream images to a given OpenGL texture.
173      * <p>
174      * In single buffered mode the application is responsible for serializing access to the image
175      * content buffer. Each time the image content is to be updated, the
176      * {@link #releaseTexImage()} method must be called before the image content producer takes
177      * ownership of the buffer. For example, when producing image content with the NDK
178      * ANativeWindow_lock and ANativeWindow_unlockAndPost functions, {@link #releaseTexImage()}
179      * must be called before each ANativeWindow_lock, or that call will fail. When producing
180      * image content with OpenGL ES, {@link #releaseTexImage()} must be called before the first
181      * OpenGL ES function call each frame.
182      * <p>
183      * Unlike {@link #SurfaceTexture(int, boolean)}, which takes an OpenGL texture object name,
184      * this constructor creates the SurfaceTexture in detached mode. A texture name must be passed
185      * in using {@link #attachToGLContext} before calling {@link #releaseTexImage()} and producing
186      * image content using OpenGL ES.
187      *
188      * @param singleBufferMode whether the SurfaceTexture will be in single buffered mode.
189      *
190      * @throws android.view.Surface.OutOfResourcesException If the SurfaceTexture cannot be created.
191      */
SurfaceTexture(boolean singleBufferMode)192     public SurfaceTexture(boolean singleBufferMode) {
193         mCreatorLooper = Looper.myLooper();
194         mIsSingleBuffered = singleBufferMode;
195         nativeInit(true, 0, singleBufferMode, new WeakReference<SurfaceTexture>(this));
196     }
197 
198     /**
199      * Register a callback to be invoked when a new image frame becomes available to the
200      * SurfaceTexture.
201      * <p>
202      * The callback may be called on an arbitrary thread, so it is not
203      * safe to call {@link #updateTexImage} without first binding the OpenGL ES context to the
204      * thread invoking the callback.
205      * </p>
206      *
207      * @param listener The listener to use, or null to remove the listener.
208      */
setOnFrameAvailableListener(@ullable OnFrameAvailableListener listener)209     public void setOnFrameAvailableListener(@Nullable OnFrameAvailableListener listener) {
210         setOnFrameAvailableListener(listener, null);
211     }
212 
213     /**
214      * Register a callback to be invoked when a new image frame becomes available to the
215      * SurfaceTexture.
216      * <p>
217      * If a handler is specified, the callback will be invoked on that handler's thread.
218      * If no handler is specified, then the callback may be called on an arbitrary thread,
219      * so it is not safe to call {@link #updateTexImage} without first binding the OpenGL ES
220      * context to the thread invoking the callback.
221      * </p>
222      *
223      * @param listener The listener to use, or null to remove the listener.
224      * @param handler The handler on which the listener should be invoked, or null
225      * to use an arbitrary thread.
226      */
setOnFrameAvailableListener(@ullable final OnFrameAvailableListener listener, @Nullable Handler handler)227     public void setOnFrameAvailableListener(@Nullable final OnFrameAvailableListener listener,
228             @Nullable Handler handler) {
229         if (listener != null) {
230             // Although we claim the thread is arbitrary, earlier implementation would
231             // prefer to send the callback on the creating looper or the main looper
232             // so we preserve this behavior here.
233             Looper looper = handler != null ? handler.getLooper() :
234                     mCreatorLooper != null ? mCreatorLooper : Looper.getMainLooper();
235             mOnFrameAvailableHandler = new Handler(looper, null, true /*async*/) {
236                 @Override
237                 public void handleMessage(Message msg) {
238                     listener.onFrameAvailable(SurfaceTexture.this);
239                 }
240             };
241         } else {
242             mOnFrameAvailableHandler = null;
243         }
244     }
245 
246     private static class SetFrameRateArgs {
SetFrameRateArgs(@loatRangefrom = 0.0) float frameRate, @Surface.FrameRateCompatibility int compatibility, @Surface.ChangeFrameRateStrategy int changeFrameRateStrategy)247         SetFrameRateArgs(@FloatRange(from = 0.0) float frameRate,
248                                 @Surface.FrameRateCompatibility int compatibility,
249                    @Surface.ChangeFrameRateStrategy int changeFrameRateStrategy) {
250             this.mFrameRate = frameRate;
251             this.mCompatibility = compatibility;
252             this.mChangeFrameRateStrategy = changeFrameRateStrategy;
253         }
254         final float mFrameRate;
255         final int mCompatibility;
256         final int mChangeFrameRateStrategy;
257     }
258 
259     /**
260      * Register a callback to be invoked when the producer sets a frame rate using
261      * Surface.setFrameRate.
262      * @hide
263      */
setOnSetFrameRateListener(@ullable final OnSetFrameRateListener listener, @Nullable Handler handler)264     public void setOnSetFrameRateListener(@Nullable final OnSetFrameRateListener listener,
265                                             @Nullable Handler handler) {
266         if (listener != null) {
267             Looper looper = handler != null ? handler.getLooper() :
268                     mCreatorLooper != null ? mCreatorLooper : Looper.getMainLooper();
269             mOnSetFrameRateHandler = new Handler(looper, null, true /*async*/) {
270                 @Override
271                 public void handleMessage(Message msg) {
272                     Trace.traceBegin(Trace.TRACE_TAG_VIEW, "onSetFrameRateHandler");
273                     try {
274                         SetFrameRateArgs args = (SetFrameRateArgs) msg.obj;
275                         listener.onSetFrameRate(SurfaceTexture.this,
276                                 args.mFrameRate, args.mCompatibility,
277                                 args.mChangeFrameRateStrategy);
278                     } finally {
279                         Trace.traceEnd(Trace.TRACE_TAG_VIEW);
280                     }
281                 }
282             };
283         } else {
284             mOnSetFrameRateHandler = null;
285         }
286     }
287 
288     /**
289      * Set the default size of the image buffers.  The image producer may override the buffer size,
290      * in which case the producer-set buffer size will be used, not the default size set by this
291      * method.  Both video and camera based image producers do override the size.  This method may
292      * be used to set the image size when producing images with {@link android.graphics.Canvas} (via
293      * {@link android.view.Surface#lockCanvas}), or OpenGL ES (via an EGLSurface).
294      * <p>
295      * The new default buffer size will take effect the next time the image producer requests a
296      * buffer to fill.  For {@link android.graphics.Canvas} this will be the next time {@link
297      * android.view.Surface#lockCanvas} is called.  For OpenGL ES, the EGLSurface should be
298      * destroyed (via eglDestroySurface), made not-current (via eglMakeCurrent), and then recreated
299      * (via {@code eglCreateWindowSurface}) to ensure that the new default size has taken effect.
300      * <p>
301      * The width and height parameters must be no greater than the minimum of
302      * {@code GL_MAX_VIEWPORT_DIMS} and {@code GL_MAX_TEXTURE_SIZE} (see
303      * {@link javax.microedition.khronos.opengles.GL10#glGetIntegerv glGetIntegerv}).
304      * An error due to invalid dimensions might not be reported until
305      * updateTexImage() is called.
306      */
setDefaultBufferSize(int width, int height)307     public void setDefaultBufferSize(int width, int height) {
308         nativeSetDefaultBufferSize(width, height);
309     }
310 
311     /**
312      * Update the texture image to the most recent frame from the image stream.  This may only be
313      * called while the OpenGL ES context that owns the texture is current on the calling thread.
314      * It will implicitly bind its texture to the {@code GL_TEXTURE_EXTERNAL_OES} texture target.
315      */
updateTexImage()316     public void updateTexImage() {
317         nativeUpdateTexImage();
318     }
319 
320     /**
321      * Releases the texture content. This is needed in single buffered mode to allow the image
322      * content producer to take ownership of the image buffer.
323      * <p>
324      * For more information see {@link #SurfaceTexture(int, boolean)}.
325      */
releaseTexImage()326     public void releaseTexImage() {
327         nativeReleaseTexImage();
328     }
329 
330     /**
331      * Detach the SurfaceTexture from the OpenGL ES context that owns the OpenGL ES texture object.
332      * This call must be made with the OpenGL ES context current on the calling thread.  The OpenGL
333      * ES texture object will be deleted as a result of this call.  After calling this method all
334      * calls to {@link #updateTexImage} will throw an {@link java.lang.IllegalStateException} until
335      * a successful call to {@link #attachToGLContext} is made.
336      * <p>
337      * This can be used to access the SurfaceTexture image contents from multiple OpenGL ES
338      * contexts.  Note, however, that the image contents are only accessible from one OpenGL ES
339      * context at a time.
340      */
detachFromGLContext()341     public void detachFromGLContext() {
342         int err = nativeDetachFromGLContext();
343         if (err != 0) {
344             throw new RuntimeException("Error during detachFromGLContext (see logcat for details)");
345         }
346     }
347 
348     /**
349      * Attach the SurfaceTexture to the OpenGL ES context that is current on the calling thread.  A
350      * new OpenGL ES texture object is created and populated with the SurfaceTexture image frame
351      * that was current at the time of the last call to {@link #detachFromGLContext}.  This new
352      * texture is bound to the {@code GL_TEXTURE_EXTERNAL_OES} texture target.
353      * <p>
354      * This can be used to access the SurfaceTexture image contents from multiple OpenGL ES
355      * contexts.  Note, however, that the image contents are only accessible from one OpenGL ES
356      * context at a time.
357      *
358      * @param texName The name of the OpenGL ES texture that will be created.  This texture name
359      * must be unused in the OpenGL ES context that is current on the calling thread.
360      */
attachToGLContext(int texName)361     public void attachToGLContext(int texName) {
362         int err = nativeAttachToGLContext(texName);
363         if (err != 0) {
364             throw new RuntimeException("Error during attachToGLContext (see logcat for details)");
365         }
366     }
367 
368     /**
369      * Retrieve the 4x4 texture coordinate transform matrix associated with the texture image set by
370      * the most recent call to {@link #updateTexImage}.
371      * <p>
372      * This transform matrix maps 2D homogeneous texture coordinates of the form (s, t, 0, 1) with s
373      * and t in the inclusive range [0, 1] to the texture coordinate that should be used to sample
374      * that location from the texture.  Sampling the texture outside of the range of this transform
375      * is undefined.
376      * <p>
377      * The matrix is stored in column-major order so that it may be passed directly to OpenGL ES via
378      * the {@code glLoadMatrixf} or {@code glUniformMatrix4fv} functions.
379      * <p>
380      * If the underlying buffer has a crop associated with it, the transformation will also include
381      * a slight scale to cut off a 1-texel border around the edge of the crop. This ensures that
382      * when the texture is bilinear sampled that no texels outside of the buffer's valid region
383      * are accessed by the GPU, avoiding any sampling artifacts when scaling.
384      *
385      * @param mtx the array into which the 4x4 matrix will be stored.  The array must have exactly
386      *     16 elements.
387      */
getTransformMatrix(float[] mtx)388     public void getTransformMatrix(float[] mtx) {
389         // Note we intentionally don't check mtx for null, so this will result in a
390         // NullPointerException. But it's safe because it happens before the call to native.
391         if (mtx.length != 16) {
392             throw new IllegalArgumentException();
393         }
394         nativeGetTransformMatrix(mtx);
395     }
396 
397     /**
398      * Retrieve the timestamp associated with the texture image set by the most recent call to
399      * {@link #updateTexImage}.
400      *
401      * <p>This timestamp is in nanoseconds, and is normally monotonically increasing. The timestamp
402      * should be unaffected by time-of-day adjustments. The specific meaning and zero point of the
403      * timestamp depends on the source providing images to the SurfaceTexture. Unless otherwise
404      * specified by the image source, timestamps cannot generally be compared across SurfaceTexture
405      * instances, or across multiple program invocations. It is mostly useful for determining time
406      * offsets between subsequent frames.</p>
407      *
408      * <p>For camera sources, timestamps should be strictly monotonic. Timestamps from MediaPlayer
409      * sources may be reset when the playback position is set. For EGL and Vulkan producers, the
410      * timestamp is the desired present time set with the {@code EGL_ANDROID_presentation_time} or
411      * {@code VK_GOOGLE_display_timing} extensions.</p>
412      */
413 
getTimestamp()414     public long getTimestamp() {
415         return nativeGetTimestamp();
416     }
417 
418     /**
419      * Retrieve the dataspace associated with the texture image.
420      */
421     @SuppressLint("MethodNameUnits")
getDataSpace()422     public @NamedDataSpace int getDataSpace() {
423         return nativeGetDataSpace();
424     }
425 
426     /**
427      * {@code release()} frees all the buffers and puts the SurfaceTexture into the
428      * 'abandoned' state. Once put in this state the SurfaceTexture can never
429      * leave it. When in the 'abandoned' state, all methods of the
430      * {@code IGraphicBufferProducer} interface will fail with the {@code NO_INIT}
431      * error.
432      * <p>
433      * Note that while calling this method causes all the buffers to be freed
434      * from the perspective of the SurfaceTexture, if there are additional
435      * references on the buffers (e.g. if a buffer is referenced by a client or
436      * by OpenGL ES as a texture) then those buffer will remain allocated.
437      * <p>
438      * Always call this method when you are done with SurfaceTexture. Failing
439      * to do so may delay resource deallocation for a significant amount of
440      * time.
441      *
442      * @see #isReleased()
443      */
release()444     public void release() {
445         nativeRelease();
446     }
447 
448     /**
449      * Returns {@code true} if the SurfaceTexture was released.
450      *
451      * @see #release()
452      */
isReleased()453     public boolean isReleased() {
454         return nativeIsReleased();
455     }
456 
457     @Override
finalize()458     protected void finalize() throws Throwable {
459         try {
460             nativeFinalize();
461         } finally {
462             super.finalize();
463         }
464     }
465 
466     /**
467      * This method is invoked from native code only.
468      */
469     @SuppressWarnings({"UnusedDeclaration"})
470     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
postEventFromNative(WeakReference<SurfaceTexture> weakSelf)471     private static void postEventFromNative(WeakReference<SurfaceTexture> weakSelf) {
472         SurfaceTexture st = weakSelf.get();
473         if (st != null) {
474             Handler handler = st.mOnFrameAvailableHandler;
475             if (handler != null) {
476                 handler.sendEmptyMessage(0);
477             }
478         }
479     }
480 
481     /**
482      * This method is invoked from native code only.
483      * @hide
484      */
485     @SuppressWarnings({"UnusedDeclaration"})
postOnSetFrameRateEventFromNative(WeakReference<SurfaceTexture> weakSelf, @FloatRange(from = 0.0) float frameRate, @Surface.FrameRateCompatibility int compatibility, @Surface.ChangeFrameRateStrategy int changeFrameRateStrategy)486     private static void postOnSetFrameRateEventFromNative(WeakReference<SurfaceTexture> weakSelf,
487             @FloatRange(from = 0.0) float frameRate,
488             @Surface.FrameRateCompatibility int compatibility,
489             @Surface.ChangeFrameRateStrategy int changeFrameRateStrategy) {
490         Trace.traceBegin(Trace.TRACE_TAG_VIEW, "postOnSetFrameRateEventFromNative");
491         try {
492             if (Flags.toolkitSetFrameRateReadOnly()) {
493                 SurfaceTexture st = weakSelf.get();
494                 if (st != null) {
495                     Handler handler = st.mOnSetFrameRateHandler;
496                     if (handler != null) {
497                         Message msg = new Message();
498                         msg.obj = new SetFrameRateArgs(frameRate, compatibility,
499                                 changeFrameRateStrategy);
500                         handler.sendMessage(msg);
501                     }
502                 }
503             }
504         } finally {
505             Trace.traceEnd(Trace.TRACE_TAG_VIEW);
506         }
507 
508     }
509 
510     /**
511      * Returns {@code true} if the SurfaceTexture is single-buffered.
512      * @hide
513      */
isSingleBuffered()514     public boolean isSingleBuffered() {
515         return mIsSingleBuffered;
516     }
517 
nativeInit(boolean isDetached, int texName, boolean singleBufferMode, WeakReference<SurfaceTexture> weakSelf)518     private native void nativeInit(boolean isDetached, int texName,
519             boolean singleBufferMode, WeakReference<SurfaceTexture> weakSelf)
520             throws Surface.OutOfResourcesException;
nativeFinalize()521     private native void nativeFinalize();
nativeGetTransformMatrix(float[] mtx)522     private native void nativeGetTransformMatrix(float[] mtx);
nativeGetTimestamp()523     private native long nativeGetTimestamp();
nativeGetDataSpace()524     private native int nativeGetDataSpace();
nativeSetDefaultBufferSize(int width, int height)525     private native void nativeSetDefaultBufferSize(int width, int height);
nativeUpdateTexImage()526     private native void nativeUpdateTexImage();
nativeReleaseTexImage()527     private native void nativeReleaseTexImage();
528     @UnsupportedAppUsage
nativeDetachFromGLContext()529     private native int nativeDetachFromGLContext();
nativeAttachToGLContext(int texName)530     private native int nativeAttachToGLContext(int texName);
nativeRelease()531     private native void nativeRelease();
nativeIsReleased()532     private native boolean nativeIsReleased();
533 }
534