diff options
author | Dan Stoza <stoza@google.com> | 2015-04-16 15:39:18 -0700 |
---|---|---|
committer | Dan Stoza <stoza@google.com> | 2015-04-17 09:28:41 -0700 |
commit | 8dddc990103b71137be2a6365a26b1ac36598e68 (patch) | |
tree | a3e41d09c0483314a10bb676d851778ee2bfbb75 /include/gui | |
parent | 2e398e64b3bc827ec8caaa1457442a8b3d546aed (diff) | |
download | frameworks_native-8dddc990103b71137be2a6365a26b1ac36598e68.zip frameworks_native-8dddc990103b71137be2a6365a26b1ac36598e68.tar.gz frameworks_native-8dddc990103b71137be2a6365a26b1ac36598e68.tar.bz2 |
libgui: Change BufferQueue to use free lists
BufferQueue used to choose free buffers by scanning through its array
of slots and picking one based on timestamp. This changes that
mechanism to use a pair of free lists: one with buffers attached and
one without. This makes it easier to choose either type of free slot
depending on the needs of the current operation.
Bug: 13175420
Change-Id: Ic8398e7511bd11a60a1c82e3ad2ee271c9822be1
Diffstat (limited to 'include/gui')
-rw-r--r-- | include/gui/BufferQueueCore.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/gui/BufferQueueCore.h b/include/gui/BufferQueueCore.h index 40026bd..a6065a9 100644 --- a/include/gui/BufferQueueCore.h +++ b/include/gui/BufferQueueCore.h @@ -30,6 +30,9 @@ #include <utils/Trace.h> #include <utils/Vector.h> +#include <list> +#include <set> + #define BQ_LOGV(x, ...) ALOGV("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) #define BQ_LOGD(x, ...) ALOGD("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) #define BQ_LOGI(x, ...) ALOGI("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) @@ -123,6 +126,10 @@ private: // waitWhileAllocatingLocked blocks until mIsAllocating is false. void waitWhileAllocatingLocked() const; + // validateConsistencyLocked ensures that the free lists are in sync with + // the information stored in mSlots + void validateConsistencyLocked() const; + // mAllocator is the connection to SurfaceFlinger that is used to allocate // new GraphicBuffer objects. sp<IGraphicBufferAlloc> mAllocator; @@ -177,6 +184,14 @@ private: // mQueue is a FIFO of queued buffers used in synchronous mode. Fifo mQueue; + // mFreeSlots contains all of the slots which are FREE and do not currently + // have a buffer attached + std::set<int> mFreeSlots; + + // mFreeBuffers contains all of the slots which are FREE and currently have + // a buffer attached + std::list<int> mFreeBuffers; + // mOverrideMaxBufferCount is the limit on the number of buffers that will // be allocated at one time. This value is set by the producer by calling // setBufferCount. The default is 0, which means that the producer doesn't |