summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Stoza <stoza@google.com>2014-06-25 14:21:45 -0700
committerDan Stoza <stoza@google.com>2014-06-25 15:00:48 -0700
commitab57491de3a89a2d454d3060d36adef71741a7ae (patch)
tree839135b48a33989fc47a261bf0e916a81b549749
parente49ba8e2ed8e17156eb00c8fc8e2285df62bc018 (diff)
downloadframeworks_native-ab57491de3a89a2d454d3060d36adef71741a7ae.zip
frameworks_native-ab57491de3a89a2d454d3060d36adef71741a7ae.tar.gz
frameworks_native-ab57491de3a89a2d454d3060d36adef71741a7ae.tar.bz2
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
-rw-r--r--include/gui/GLConsumer.h39
-rw-r--r--libs/gui/GLConsumer.cpp27
2 files changed, 49 insertions, 17 deletions
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 @@ public:
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 @@ public:
// 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.
//
diff --git a/libs/gui/GLConsumer.cpp b/libs/gui/GLConsumer.cpp
index 3215b2f..924fc0d 100644
--- a/libs/gui/GLConsumer.cpp
+++ b/libs/gui/GLConsumer.cpp
@@ -143,6 +143,33 @@ GLConsumer::GLConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex,
mConsumer->setConsumerUsageBits(DEFAULT_USAGE_FLAGS);
}
+GLConsumer::GLConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t texTarget,
+ bool useFenceSync, bool isControlledByApp) :
+ ConsumerBase(bq, isControlledByApp),
+ mCurrentTransform(0),
+ mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
+ mCurrentFence(Fence::NO_FENCE),
+ mCurrentTimestamp(0),
+ mCurrentFrameNumber(0),
+ mDefaultWidth(1),
+ mDefaultHeight(1),
+ mFilteringEnabled(true),
+ mTexName(-1),
+ mUseFenceSync(useFenceSync),
+ mTexTarget(texTarget),
+ mEglDisplay(EGL_NO_DISPLAY),
+ mEglContext(EGL_NO_CONTEXT),
+ mCurrentTexture(BufferQueue::INVALID_BUFFER_SLOT),
+ mAttached(false)
+{
+ ST_LOGV("GLConsumer");
+
+ memcpy(mCurrentTransformMatrix, mtxIdentity,
+ sizeof(mCurrentTransformMatrix));
+
+ mConsumer->setConsumerUsageBits(DEFAULT_USAGE_FLAGS);
+}
+
status_t GLConsumer::setDefaultMaxBufferCount(int bufferCount) {
Mutex::Autolock lock(mMutex);
return mConsumer->setDefaultMaxBufferCount(bufferCount);