diff options
author | Andy McFadden <fadden@android.com> | 2013-06-28 13:52:40 -0700 |
---|---|---|
committer | Andy McFadden <fadden@android.com> | 2013-07-10 15:38:40 -0700 |
commit | 1585c4d9fbbba3ba70ae625923b85cd02cb8a0fd (patch) | |
tree | 42299de67a0088fb4416dba825e40f5b6a22312a /include | |
parent | 06b6aed2f158d48ae04c4854d2a8832777ac942e (diff) | |
download | frameworks_native-1585c4d9fbbba3ba70ae625923b85cd02cb8a0fd.zip frameworks_native-1585c4d9fbbba3ba70ae625923b85cd02cb8a0fd.tar.gz frameworks_native-1585c4d9fbbba3ba70ae625923b85cd02cb8a0fd.tar.bz2 |
Pay attention to buffer timestamps
When acquiring a buffer, SurfaceFlinger now computes the expected
presentation time and passes it to the BufferQueue acquireBuffer()
method. If it's not yet time to display the buffer, acquireBuffer()
returns PRESENT_LATER instead of a buffer.
The current implementation of the expected-present-time computation
uses approximations and guesswork.
Bug 7900302
Change-Id: If9345611c5983a11a811935aaf27d6388a5036f1
Diffstat (limited to 'include')
-rw-r--r-- | include/gui/BufferItemConsumer.h | 3 | ||||
-rw-r--r-- | include/gui/BufferQueue.h | 10 | ||||
-rw-r--r-- | include/gui/ConsumerBase.h | 3 | ||||
-rw-r--r-- | include/gui/GLConsumer.h | 3 |
4 files changed, 14 insertions, 5 deletions
diff --git a/include/gui/BufferItemConsumer.h b/include/gui/BufferItemConsumer.h index 98b450c..5bf9acb 100644 --- a/include/gui/BufferItemConsumer.h +++ b/include/gui/BufferItemConsumer.h @@ -71,7 +71,8 @@ class BufferItemConsumer: public ConsumerBase // // If waitForFence is true, and the acquired BufferItem has a valid fence object, // acquireBuffer will wait on the fence with no timeout before returning. - status_t acquireBuffer(BufferItem *item, bool waitForFence = true); + status_t acquireBuffer(BufferItem *item, nsecs_t presentWhen, + bool waitForFence = true); // Returns an acquired buffer to the queue, allowing it to be reused. Since // only a fixed number of buffers may be acquired at a time, old buffers diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h index 766fa0f..0143be3 100644 --- a/include/gui/BufferQueue.h +++ b/include/gui/BufferQueue.h @@ -39,7 +39,7 @@ public: enum { NUM_BUFFER_SLOTS = 32 }; enum { NO_CONNECTED_API = 0 }; enum { INVALID_BUFFER_SLOT = -1 }; - enum { STALE_BUFFER_SLOT = 1, NO_BUFFER_AVAILABLE }; + enum { STALE_BUFFER_SLOT = 1, NO_BUFFER_AVAILABLE, PRESENT_LATER }; // When in async mode we reserve two slots in order to guarantee that the // producer and consumer can run asynchronously. @@ -284,7 +284,13 @@ public: // acquired then the BufferItem::mGraphicBuffer field of buffer is set to // NULL and it is assumed that the consumer still holds a reference to the // buffer. - status_t acquireBuffer(BufferItem *buffer); + // + // If presentWhen is nonzero, it indicates the time when the buffer will + // be displayed on screen. If the buffer's timestamp is farther in the + // future, the buffer won't be acquired, and PRESENT_LATER will be + // returned. The presentation time is in nanoseconds, and the time base + // is CLOCK_MONOTONIC. + status_t acquireBuffer(BufferItem *buffer, nsecs_t presentWhen); // releaseBuffer releases a buffer slot from the consumer back to the // BufferQueue. This may be done while the buffer's contents are still diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h index 1d51bc9..42b84cc 100644 --- a/include/gui/ConsumerBase.h +++ b/include/gui/ConsumerBase.h @@ -152,7 +152,8 @@ protected: // initialization that must take place the first time a buffer is assigned // to a slot. If it is overridden the derived class's implementation must // call ConsumerBase::acquireBufferLocked. - virtual status_t acquireBufferLocked(BufferQueue::BufferItem *item); + virtual status_t acquireBufferLocked(BufferQueue::BufferItem *item, + nsecs_t presentWhen); // releaseBufferLocked relinquishes control over a buffer, returning that // control to the BufferQueue. diff --git a/include/gui/GLConsumer.h b/include/gui/GLConsumer.h index 031684e..fbc8840 100644 --- a/include/gui/GLConsumer.h +++ b/include/gui/GLConsumer.h @@ -237,7 +237,8 @@ protected: // acquireBufferLocked overrides the ConsumerBase method to update the // mEglSlots array in addition to the ConsumerBase behavior. - virtual status_t acquireBufferLocked(BufferQueue::BufferItem *item); + virtual status_t acquireBufferLocked(BufferQueue::BufferItem *item, + nsecs_t presentWhen); // releaseBufferLocked overrides the ConsumerBase method to update the // mEglSlots array in addition to the ConsumerBase. |