diff options
Diffstat (limited to 'graphics/java/android/graphics/SurfaceTexture.java')
| -rw-r--r-- | graphics/java/android/graphics/SurfaceTexture.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java index 64c209a..1fc2722 100644 --- a/graphics/java/android/graphics/SurfaceTexture.java +++ b/graphics/java/android/graphics/SurfaceTexture.java @@ -24,16 +24,32 @@ import android.os.Message; /** * Captures frames from an image stream as an OpenGL ES texture. * - * <p>The image stream may come from either video playback or camera preview. A SurfaceTexture may - * be used in place of a SurfaceHolder when specifying the output destination of a MediaPlayer or - * Camera object. This will cause all the frames from that image stream to be sent to the + * <p>The image stream may come from either camera preview. A SurfaceTexture may be used in place + * of a SurfaceHolder when specifying the output destination of a {@link android.hardware.Camera} + * object. Doing so will cause all the frames from the image stream to be sent to the * SurfaceTexture object rather than to the device's display. When {@link #updateTexImage} is * called, the contents of the texture object specified when the SurfaceTexture was created is * updated to contain the most recent image from the image stream. This may cause some frames of * the stream to be skipped. * + * <p>When sampling from the texture one should first transform the texture coordinates using the + * matrix queried via {@link #getTransformMatrix}. The transform matrix may change each time {@link + * #updateTexImage} is called, so it should be re-queried each time the texture image is updated. + * This matrix transforms traditional 2D OpenGL ES texture coordinate column vectors of the form (s, + * t, 0, 1) where s and t are on the inclusive interval [0, 1] to the proper sampling location in + * the streamed texture. This transform compensates for any properties of the image stream source + * that cause it to appear different from a traditional OpenGL ES texture. For example, sampling + * from the bottom left corner of the image can be accomplished by transforming the column vector + * (0, 0, 0, 1) using the queried matrix, while sampling from the top right corner of the image can + * be done by transforming (1, 1, 0, 1). + * * <p>The texture object uses the GL_TEXTURE_EXTERNAL_OES texture target, which is defined by the * OES_EGL_image_external OpenGL ES extension. This limits how the texture may be used. + * + * <p>SurfaceTexture objects may be created on any thread. {@link #updateTexImage} may only be + * called on the thread with the OpenGL ES context that contains the texture object. The + * frame-available callback is called on an arbitrary thread, so unless special care is taken {@link + * #updateTexImage} should not be called directly from the callback. */ public class SurfaceTexture { |
