diff options
Diffstat (limited to 'include/gui/BufferQueue.h')
-rw-r--r-- | include/gui/BufferQueue.h | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h index 1c80d0c..85d8fb6 100644 --- a/include/gui/BufferQueue.h +++ b/include/gui/BufferQueue.h @@ -23,6 +23,7 @@ #include <gui/IGraphicBufferAlloc.h> #include <gui/ISurfaceTexture.h> +#include <ui/Fence.h> #include <ui/GraphicBuffer.h> #include <utils/String8.h> @@ -96,7 +97,9 @@ public: // allowSynchronousMode specifies whether or not synchronous mode can be // enabled. // bufferCount sets the minimum number of undequeued buffers for this queue - BufferQueue( bool allowSynchronousMode = true, int bufferCount = MIN_UNDEQUEUED_BUFFERS); + BufferQueue(bool allowSynchronousMode = true, + int bufferCount = MIN_UNDEQUEUED_BUFFERS, + const sp<IGraphicBufferAlloc>& allocator = NULL); virtual ~BufferQueue(); virtual int query(int what, int* value); @@ -113,12 +116,18 @@ public: // pointed to by the buf argument and a status of OK is returned. If no // slot is available then a status of -EBUSY is returned and buf is // unmodified. + // + // The fence parameter will be updated to hold the fence associated with + // the buffer. The contents of the buffer must not be overwritten until the + // fence signals. If the fence is NULL, the buffer may be written + // immediately. + // // The width and height parameters must be no greater than the minimum of // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). // An error due to invalid dimensions might not be reported until // updateTexImage() is called. - virtual status_t dequeueBuffer(int *buf, uint32_t width, uint32_t height, - uint32_t format, uint32_t usage); + virtual status_t dequeueBuffer(int *buf, sp<Fence>& fence, + uint32_t width, uint32_t height, uint32_t format, uint32_t usage); // queueBuffer returns a filled buffer to the BufferQueue. In addition, a // timestamp must be provided for the buffer. The timestamp is in @@ -128,7 +137,7 @@ public: virtual status_t queueBuffer(int buf, const QueueBufferInput& input, QueueBufferOutput* output); - virtual void cancelBuffer(int buf); + virtual void cancelBuffer(int buf, sp<Fence> fence); // setSynchronousMode set whether dequeueBuffer is synchronous or // asynchronous. In synchronous mode, dequeueBuffer blocks until @@ -193,6 +202,9 @@ public: // mBuf is the slot index of this buffer int mBuf; + + // mFence is a fence that will signal when the buffer is idle. + sp<Fence> mFence; }; // The following public functions is the consumer facing interface @@ -209,9 +221,15 @@ public: // releaseBuffer releases a buffer slot from the consumer back to the // BufferQueue pending a fence sync. // + // If releaseBuffer returns STALE_BUFFER_SLOT, then the consumer must free + // any references to the just-released buffer that it might have, as if it + // had received a onBuffersReleased() call with a mask set for the released + // buffer. + // // Note that the dependencies on EGL will be removed once we switch to using // the Android HW Sync HAL. - status_t releaseBuffer(int buf, EGLDisplay display, EGLSyncKHR fence); + status_t releaseBuffer(int buf, EGLDisplay display, EGLSyncKHR fence, + const sp<Fence>& releaseFence); // consumerConnect connects a consumer to the BufferQueue. Only one // consumer may be connected, and when that consumer disconnects the @@ -292,7 +310,7 @@ private: mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE), mTimestamp(0), mFrameNumber(0), - mFence(EGL_NO_SYNC_KHR), + mEglFence(EGL_NO_SYNC_KHR), mAcquireCalled(false), mNeedsCleanupOnRelease(false) { mCrop.makeInvalid(); @@ -365,11 +383,22 @@ private: // mFrameNumber is the number of the queued frame for this slot. uint64_t mFrameNumber; - // mFence is the EGL sync object that must signal before the buffer + // mEglFence is the EGL sync object that must signal before the buffer // associated with this buffer slot may be dequeued. It is initialized // to EGL_NO_SYNC_KHR when the buffer is created and (optionally, based // on a compile-time option) set to a new sync object in updateTexImage. - EGLSyncKHR mFence; + EGLSyncKHR mEglFence; + + // mFence is a fence which will signal when work initiated by the + // previous owner of the buffer is finished. When the buffer is FREE, + // the fence indicates when the consumer has finished reading + // from the buffer, or when the producer has finished writing if it + // called cancelBuffer after queueing some writes. When the buffer is + // QUEUED, it indicates when the producer has finished filling the + // buffer. When the buffer is DEQUEUED or ACQUIRED, the fence has been + // passed to the consumer or producer along with ownership of the + // buffer, and mFence is empty. + sp<Fence> mFence; // Indicates whether this buffer has been seen by a consumer yet bool mAcquireCalled; @@ -393,10 +422,6 @@ private: // in requestBuffers() if a width and height of zero is specified. uint32_t mDefaultHeight; - // mPixelFormat holds the pixel format of allocated buffers. It is used - // in requestBuffers() if a format of zero is specified. - uint32_t mPixelFormat; - // mMinUndequeuedBuffers is a constraint on the number of buffers // not dequeued at any time int mMinUndequeuedBuffers; |