diff options
Diffstat (limited to 'include/gui')
-rw-r--r-- | include/gui/BufferQueue.h | 44 | ||||
-rw-r--r-- | include/gui/ConsumerBase.h | 24 | ||||
-rw-r--r-- | include/gui/CpuConsumer.h | 13 | ||||
-rw-r--r-- | include/gui/GLConsumer.h | 13 |
4 files changed, 50 insertions, 44 deletions
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h index 6c1b691..766fa0f 100644 --- a/include/gui/BufferQueue.h +++ b/include/gui/BufferQueue.h @@ -229,7 +229,7 @@ public: // dump our state in a String virtual void dump(String8& result) const; - virtual void dump(String8& result, const char* prefix, char* buffer, size_t SIZE) const; + virtual void dump(String8& result, const char* prefix) const; // public facing structure for BufferSlot struct BufferItem { @@ -240,7 +240,8 @@ public: mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE), mTimestamp(0), mFrameNumber(0), - mBuf(INVALID_BUFFER_SLOT) { + mBuf(INVALID_BUFFER_SLOT), + mAcquireCalled(false) { mCrop.makeInvalid(); } // mGraphicBuffer points to the buffer allocated for this slot, or is NULL @@ -269,6 +270,9 @@ public: // mFence is a fence that will signal when the buffer is idle. sp<Fence> mFence; + + // Indicates whether this buffer has been seen by a consumer yet + bool mAcquireCalled; }; // The following public functions are the consumer-facing interface @@ -285,7 +289,7 @@ public: // releaseBuffer releases a buffer slot from the consumer back to the // BufferQueue. This may be done while the buffer's contents are still // being accessed. The fence will signal when the buffer is no longer - // in use. + // in use. frameNumber is used to indentify the exact buffer returned. // // 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 @@ -294,7 +298,8 @@ public: // // 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, uint64_t frameNumber, + EGLDisplay display, EGLSyncKHR fence, const sp<Fence>& releaseFence); // consumerConnect connects a consumer to the BufferQueue. Only one @@ -368,10 +373,6 @@ private: // all slots. void freeAllBuffersLocked(); - // freeAllBuffersExceptHeadLocked frees the GraphicBuffer and sync - // resources for all slots except the head of mQueue. - void freeAllBuffersExceptHeadLocked(); - // drainQueueLocked waits for the buffer queue to empty if we're in // synchronous mode, or returns immediately otherwise. It returns NO_INIT // if the BufferQueue is abandoned (consumer disconnected) or disconnected @@ -410,20 +411,20 @@ private: // connected, mDequeueCondition must be broadcast. int getMaxBufferCountLocked() const; + // stillTracking returns true iff the buffer item is still being tracked + // in one of the slots. + bool stillTracking(const BufferItem *item) const; + struct BufferSlot { BufferSlot() : mEglDisplay(EGL_NO_DISPLAY), mBufferState(BufferSlot::FREE), mRequestBufferCalled(false), - mTransform(0), - mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE), - mTimestamp(0), mFrameNumber(0), mEglFence(EGL_NO_SYNC_KHR), mAcquireCalled(false), mNeedsCleanupOnRelease(false) { - mCrop.makeInvalid(); } // mGraphicBuffer points to the buffer allocated for this slot or is NULL @@ -482,21 +483,6 @@ private: // needed but useful for debugging and catching producer bugs. bool mRequestBufferCalled; - // mCrop is the current crop rectangle for this buffer slot. - Rect mCrop; - - // mTransform is the current transform flags for this buffer slot. - // (example: NATIVE_WINDOW_TRANSFORM_ROT_90) - uint32_t mTransform; - - // mScalingMode is the current scaling mode for this buffer slot. - // (example: NATIVE_WINDOW_SCALING_MODE_FREEZE) - uint32_t mScalingMode; - - // mTimestamp is the current timestamp for this buffer slot. This gets - // to set by queueBuffer each time this slot is queued. - int64_t mTimestamp; - // mFrameNumber is the number of the queued frame for this slot. This // is used to dequeue buffers in LRU order (useful because buffers // may be released before their release fence is signaled). @@ -592,7 +578,7 @@ private: mutable Condition mDequeueCondition; // mQueue is a FIFO of queued buffers used in synchronous mode - typedef Vector<int> Fifo; + typedef Vector<BufferItem> Fifo; Fifo mQueue; // mAbandoned indicates that the BufferQueue will no longer be used to @@ -613,7 +599,7 @@ private: mutable Mutex mMutex; // mFrameCounter is the free running counter, incremented on every - // successful queueBuffer call. + // successful queueBuffer call, and buffer allocation. uint64_t mFrameCounter; // mBufferHasBeenQueued is true once a buffer has been queued. It is diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h index 8a7545d..1d51bc9 100644 --- a/include/gui/ConsumerBase.h +++ b/include/gui/ConsumerBase.h @@ -73,7 +73,7 @@ public: // their state to the dump by overriding the dumpLocked method, which is // called by these methods after locking the mutex. void dump(String8& result) const; - void dump(String8& result, const char* prefix, char* buffer, size_t SIZE) const; + void dump(String8& result, const char* prefix) const; // setFrameAvailableListener sets the listener object that will be notified // when a new frame becomes available. @@ -143,8 +143,7 @@ protected: // should call ConsumerBase::dumpLocked. // // This method must be called with mMutex locked. - virtual void dumpLocked(String8& result, const char* prefix, char* buffer, - size_t size) const; + virtual void dumpLocked(String8& result, const char* prefix) const; // acquireBufferLocked fetches the next buffer from the BufferQueue and // updates the buffer slot for the buffer returned. @@ -161,17 +160,23 @@ protected: // Derived classes should override this method to perform any cleanup that // must take place when a buffer is released back to the BufferQueue. If // it is overridden the derived class's implementation must call - // ConsumerBase::releaseBufferLocked. - virtual status_t releaseBufferLocked(int buf, EGLDisplay display, - EGLSyncKHR eglFence); + // ConsumerBase::releaseBufferLocked.e + virtual status_t releaseBufferLocked(int slot, + const sp<GraphicBuffer> graphicBuffer, + EGLDisplay display, EGLSyncKHR eglFence); + + // returns true iff the slot still has the graphicBuffer in it. + bool stillTracking(int slot, const sp<GraphicBuffer> graphicBuffer); // addReleaseFence* adds the sync points associated with a fence to the set // of sync points that must be reached before the buffer in the given slot // may be used after the slot has been released. This should be called by // derived classes each time some asynchronous work is kicked off that // references the buffer. - status_t addReleaseFence(int slot, const sp<Fence>& fence); - status_t addReleaseFenceLocked(int slot, const sp<Fence>& fence); + status_t addReleaseFence(int slot, + const sp<GraphicBuffer> graphicBuffer, const sp<Fence>& fence); + status_t addReleaseFenceLocked(int slot, + const sp<GraphicBuffer> graphicBuffer, const sp<Fence>& fence); // Slot contains the information and object references that // ConsumerBase maintains about a BufferQueue buffer slot. @@ -185,6 +190,9 @@ protected: // overwritten. The buffer can be dequeued before the fence signals; // the producer is responsible for delaying writes until it signals. sp<Fence> mFence; + + // the frame number of the last acquired frame for this slot + uint64_t mFrameNumber; }; // mSlots stores the buffers that have been allocated by the BufferQueue diff --git a/include/gui/CpuConsumer.h b/include/gui/CpuConsumer.h index bf9918e..3c178ef 100644 --- a/include/gui/CpuConsumer.h +++ b/include/gui/CpuConsumer.h @@ -25,7 +25,6 @@ #include <utils/Vector.h> #include <utils/threads.h> -#define ANDROID_GRAPHICS_CPUCONSUMER_JNI_ID "mCpuConsumer" namespace android { @@ -73,6 +72,18 @@ class CpuConsumer : public ConsumerBase // log messages. void setName(const String8& name); + // setDefaultBufferSize is used to set the size of buffers returned by + // requestBuffers when a width and height of zero is requested. + // A call to setDefaultBufferSize() may trigger requestBuffers() to + // be called from the client. Default size is 1x1. + status_t setDefaultBufferSize(uint32_t width, uint32_t height); + + // setDefaultBufferFormat allows CpuConsumer's BufferQueue to create buffers + // of a defaultFormat if no format is specified by producer. Formats are + // enumerated in graphics.h; the initial default is + // HAL_PIXEL_FORMAT_RGBA_8888. + status_t setDefaultBufferFormat(uint32_t defaultFormat); + // Gets the next graphics buffer from the producer and locks it for CPU use, // filling out the passed-in locked buffer structure with the native pointer // and metadata. Returns BAD_VALUE if no new buffer is available, and diff --git a/include/gui/GLConsumer.h b/include/gui/GLConsumer.h index f0a75dc..031684e 100644 --- a/include/gui/GLConsumer.h +++ b/include/gui/GLConsumer.h @@ -233,8 +233,7 @@ protected: // dumpLocked overrides the ConsumerBase method to dump GLConsumer- // specific info in addition to the ConsumerBase behavior. - virtual void dumpLocked(String8& result, const char* prefix, char* buffer, - size_t size) const; + virtual void dumpLocked(String8& result, const char* prefix) const; // acquireBufferLocked overrides the ConsumerBase method to update the // mEglSlots array in addition to the ConsumerBase behavior. @@ -242,11 +241,13 @@ protected: // releaseBufferLocked overrides the ConsumerBase method to update the // mEglSlots array in addition to the ConsumerBase. - virtual status_t releaseBufferLocked(int buf, EGLDisplay display, - EGLSyncKHR eglFence); + virtual status_t releaseBufferLocked(int slot, + const sp<GraphicBuffer> graphicBuffer, + EGLDisplay display, EGLSyncKHR eglFence); - status_t releaseBufferLocked(int buf, EGLSyncKHR eglFence) { - return releaseBufferLocked(buf, mEglDisplay, eglFence); + status_t releaseBufferLocked(int slot, + const sp<GraphicBuffer> graphicBuffer, EGLSyncKHR eglFence) { + return releaseBufferLocked(slot, graphicBuffer, mEglDisplay, eglFence); } static bool isExternalFormat(uint32_t format); |