GLConsumer: Allow creation in detached mode

Adds a constructor that doesn't require a GLES texture name and sets
up the GLConsumer in detached mode.

Bug: 15616428
Change-Id: Idc9ea2e59baa24bbd959da9fffe0fb71c0aa9818
diff --git a/include/gui/GLConsumer.h b/include/gui/GLConsumer.h
index 787b3d4..1aacee9 100644
--- a/include/gui/GLConsumer.h
+++ b/include/gui/GLConsumer.h
@@ -56,23 +56,13 @@
     enum { TEXTURE_EXTERNAL = 0x8D65 }; // GL_TEXTURE_EXTERNAL_OES
     typedef ConsumerBase::FrameAvailableListener FrameAvailableListener;
 
-    // GLConsumer constructs a new GLConsumer object. tex indicates the
-    // name of the OpenGL ES texture to which images are to be streamed.
-    // allowSynchronousMode specifies whether or not synchronous mode can be
-    // enabled. texTarget specifies the OpenGL ES texture target to which the
-    // texture will be bound in updateTexImage. useFenceSync specifies whether
-    // fences should be used to synchronize access to buffers if that behavior
-    // is enabled at compile-time. A custom bufferQueue can be specified
-    // if behavior for queue/dequeue/connect etc needs to be customized.
-    // Otherwise a default BufferQueue will be created and used.
-    //
-    // For legacy reasons, the GLConsumer is created in a state where it is
-    // considered attached to an OpenGL ES context for the purposes of the
-    // attachToContext and detachFromContext methods. However, despite being
-    // considered "attached" to a context, the specific OpenGL ES context
-    // doesn't get latched until the first call to updateTexImage. After that
-    // point, all calls to updateTexImage must be made with the same OpenGL ES
-    // context current.
+    // GLConsumer constructs a new GLConsumer object. If the constructor with
+    // the tex parameter is used, tex indicates the name of the OpenGL ES
+    // texture to which images are to be streamed. texTarget specifies the
+    // OpenGL ES texture target to which the texture will be bound in
+    // updateTexImage. useFenceSync specifies whether fences should be used to
+    // synchronize access to buffers if that behavior is enabled at
+    // compile-time.
     //
     // A GLConsumer may be detached from one OpenGL ES context and then
     // attached to a different context using the detachFromContext and
@@ -80,10 +70,25 @@
     // purely to allow a GLConsumer to be transferred from one consumer
     // context to another. If such a transfer is not needed there is no
     // requirement that either of these methods be called.
+    //
+    // If the constructor with the tex parameter is used, the GLConsumer is
+    // created in a state where it is considered attached to an OpenGL ES
+    // context for the purposes of the attachToContext and detachFromContext
+    // methods. However, despite being considered "attached" to a context, the
+    // specific OpenGL ES context doesn't get latched until the first call to
+    // updateTexImage. After that point, all calls to updateTexImage must be
+    // made with the same OpenGL ES context current.
+    //
+    // If the constructor without the tex parameter is used, the GLConsumer is
+    // created in a detached state, and attachToContext must be called before
+    // calls to updateTexImage.
     GLConsumer(const sp<IGraphicBufferConsumer>& bq,
             uint32_t tex, uint32_t texureTarget, bool useFenceSync,
             bool isControlledByApp);
 
+    GLConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t texureTarget,
+            bool useFenceSync, bool isControlledByApp);
+
     // updateTexImage acquires the most recently queued buffer, and sets the
     // image contents of the target texture to it.
     //