From c6d993077761fc737bbb0f4db44b961a4e7b6bbb Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Thu, 5 Apr 2012 11:34:02 -0700 Subject: SurfaceTexture: add GL context attach & detach This change adds Java API support for detaching a SurfaceTexture from one GLES context and then attaching it to a different one. Change-Id: I8eed4b0d0e339c11598cb0408d9f4f2d99b3aa06 --- graphics/java/android/graphics/SurfaceTexture.java | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'graphics/java/android') diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java index 0521e6985eb1..e10158139505 100644 --- a/graphics/java/android/graphics/SurfaceTexture.java +++ b/graphics/java/android/graphics/SurfaceTexture.java @@ -161,7 +161,31 @@ public class SurfaceTexture { public void updateTexImage() { int err = nativeUpdateTexImage(); if (err != 0) { - throw new RuntimeException("Error during updateTexImage (see logs)"); + throw new RuntimeException("Error during updateTexImage (see logcat for details)"); + } + } + + /** + * Detach the SurfaceTexture from the OpenGL ES context with which it is currently associated. + * This can be used to change from one OpenGL ES context to another. + * + * @hide + */ + public void detachFromGLContext() { + int err = nativeDetachFromGLContext(); + if (err != 0) { + throw new RuntimeException("Error during detachFromGLContext (see logcat for details)"); + } + } + + /** + * + * @hide + */ + public void attachToGLContext(int texName) { + int err = nativeAttachToGLContext(texName); + if (err != 0) { + throw new RuntimeException("Error during detachFromGLContext (see logcat for details)"); } } @@ -269,6 +293,8 @@ public class SurfaceTexture { private native long nativeGetTimestamp(); private native void nativeSetDefaultBufferSize(int width, int height); private native int nativeUpdateTexImage(); + private native int nativeDetachFromGLContext(); + private native int nativeAttachToGLContext(int texName); private native int nativeGetQueuedCount(); private native void nativeRelease(); -- cgit v1.2.3-59-g8ed1b