@@ -155,19 +155,23 @@ public void setDefaultBufferSize(int width, int height) {
155155
156156 /**
157157 * Update the texture image to the most recent frame from the image stream. This may only be
158- * called while the OpenGL ES context that owns the texture is bound to the thread. It will
159- * implicitly bind its texture to the GL_TEXTURE_EXTERNAL_OES texture target.
158+ * called while the OpenGL ES context that owns the texture is current on the calling thread.
159+ * It will implicitly bind its texture to the GL_TEXTURE_EXTERNAL_OES texture target.
160160 */
161161 public void updateTexImage () {
162- int err = nativeUpdateTexImage ();
163- if (err != 0 ) {
164- throw new RuntimeException ("Error during updateTexImage (see logcat for details)" );
165- }
162+ nativeUpdateTexImage ();
166163 }
167164
168165 /**
169- * Detach the SurfaceTexture from the OpenGL ES context with which it is currently associated.
170- * This can be used to change from one OpenGL ES context to another.
166+ * Detach the SurfaceTexture from the OpenGL ES context that owns the OpenGL ES texture object.
167+ * This call must be made with the OpenGL ES context current on the calling thread. The OpenGL
168+ * ES texture object will be deleted as a result of this call. After calling this method all
169+ * calls to {@link #updateTexImage} will throw an {@link java.lang.IllegalStateException} until
170+ * a successful call to {@link #attachToGLContext} is made.
171+ *
172+ * This can be used to access the SurfaceTexture image contents from multiple OpenGL ES
173+ * contexts. Note, however, that the image contents are only accessible from one OpenGL ES
174+ * context at a time.
171175 *
172176 * @hide
173177 */
@@ -179,6 +183,17 @@ public void detachFromGLContext() {
179183 }
180184
181185 /**
186+ * Attach the SurfaceTexture to the OpenGL ES context that is current on the calling thread. A
187+ * new OpenGL ES texture object is created and populated with the SurfaceTexture image frame
188+ * that was current at the time of the last call to {@link #detachFromGLContext}. This new
189+ * texture is bound to the GL_TEXTURE_EXTERNAL_OES texture target.
190+ *
191+ * This can be used to access the SurfaceTexture image contents from multiple OpenGL ES
192+ * contexts. Note, however, that the image contents are only accessible from one OpenGL ES
193+ * context at a time.
194+ *
195+ * @param texName The name of the OpenGL ES texture that will be created. This texture name
196+ * must be unusued in the OpenGL ES context that is current on the calling thread.
182197 *
183198 * @hide
184199 */
@@ -292,7 +307,7 @@ private static void postEventFromNative(Object selfRef) {
292307 private native void nativeGetTransformMatrix (float [] mtx );
293308 private native long nativeGetTimestamp ();
294309 private native void nativeSetDefaultBufferSize (int width , int height );
295- private native int nativeUpdateTexImage ();
310+ private native void nativeUpdateTexImage ();
296311 private native int nativeDetachFromGLContext ();
297312 private native int nativeAttachToGLContext (int texName );
298313 private native int nativeGetQueuedCount ();
0 commit comments