summaryrefslogtreecommitdiffstats
path: root/include/gui
diff options
context:
space:
mode:
authorDan Stoza <stoza@google.com>2015-05-12 12:56:16 -0700
committerDan Stoza <stoza@google.com>2015-05-12 13:10:17 -0700
commita4650a50a0b35e9e4342d6600b6eb24fd94bb8e5 (patch)
tree756ed49e76eb52abc3b1e8ec7cb962b9a627fcc6 /include/gui
parent2a7dde58036e02b2417e49c8965d4a518d981b0b (diff)
downloadframeworks_native-a4650a50a0b35e9e4342d6600b6eb24fd94bb8e5.zip
frameworks_native-a4650a50a0b35e9e4342d6600b6eb24fd94bb8e5.tar.gz
frameworks_native-a4650a50a0b35e9e4342d6600b6eb24fd94bb8e5.tar.bz2
Fix PTS handling for buffer replacement
This changes the way that SurfaceFlinger's shadow buffer management works such that instead of tracking the size of the shadow queue in the BufferQueue, SF tracks the last frame number it has seen, and passes that into the acquireBuffer call. BufferQueueConsumer then ensures that it never returns a buffer newer than that frame number, even if that means that it must return PRESENT_LATER for an otherwise valid buffer. Change-Id: I3fcb45f683ed660c3f18a8b85ae1f8a962ba6f0e
Diffstat (limited to 'include/gui')
-rw-r--r--include/gui/BufferQueueConsumer.h5
-rw-r--r--include/gui/BufferQueueCore.h6
-rw-r--r--include/gui/ConsumerBase.h3
-rw-r--r--include/gui/GLConsumer.h3
-rw-r--r--include/gui/IGraphicBufferConsumer.h14
5 files changed, 13 insertions, 18 deletions
diff --git a/include/gui/BufferQueueConsumer.h b/include/gui/BufferQueueConsumer.h
index 0f42613..cde302f 100644
--- a/include/gui/BufferQueueConsumer.h
+++ b/include/gui/BufferQueueConsumer.h
@@ -47,7 +47,7 @@ public:
// returned. The presentation time is in nanoseconds, and the time base
// is CLOCK_MONOTONIC.
virtual status_t acquireBuffer(BufferItem* outBuffer,
- nsecs_t expectedPresent);
+ nsecs_t expectedPresent, uint64_t maxFrameNumber = 0) override;
// See IGraphicBufferConsumer::detachBuffer
virtual status_t detachBuffer(int slot);
@@ -148,9 +148,6 @@ public:
// Retrieve the sideband buffer stream, if any.
virtual sp<NativeHandle> getSidebandStream() const;
- // See IGraphicBufferConsumer::setShadowQueueSize
- virtual void setShadowQueueSize(size_t size);
-
// dump our state in a String
virtual void dump(String8& result, const char* prefix) const;
diff --git a/include/gui/BufferQueueCore.h b/include/gui/BufferQueueCore.h
index a22015c..d7686ec 100644
--- a/include/gui/BufferQueueCore.h
+++ b/include/gui/BufferQueueCore.h
@@ -275,12 +275,6 @@ private:
// buffer as the number of frames that have elapsed since it was last queued
uint64_t mBufferAge;
- // mConsumerHasShadowQueue determines if acquireBuffer should be more
- // cautious about dropping buffers so that it always returns a buffer that
- // is represented in the consumer's shadow queue.
- bool mConsumerHasShadowQueue;
- size_t mConsumerShadowQueueSize;
-
}; // class BufferQueueCore
} // namespace android
diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h
index 5be3ffb..f46bf01 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(BufferItem *item, nsecs_t presentWhen);
+ virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen,
+ uint64_t maxFrameNumber = 0);
// 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 4912580..c35c7be 100644
--- a/include/gui/GLConsumer.h
+++ b/include/gui/GLConsumer.h
@@ -241,7 +241,8 @@ protected:
// acquireBufferLocked overrides the ConsumerBase method to update the
// mEglSlots array in addition to the ConsumerBase behavior.
- virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen);
+ virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen,
+ uint64_t maxFrameNumber = 0) override;
// releaseBufferLocked overrides the ConsumerBase method to update the
// mEglSlots array in addition to the ConsumerBase.
diff --git a/include/gui/IGraphicBufferConsumer.h b/include/gui/IGraphicBufferConsumer.h
index 0be09a2..6363a3a 100644
--- a/include/gui/IGraphicBufferConsumer.h
+++ b/include/gui/IGraphicBufferConsumer.h
@@ -69,6 +69,12 @@ public:
// returned. The presentation time is in nanoseconds, and the time base
// is CLOCK_MONOTONIC.
//
+ // If maxFrameNumber is non-zero, it indicates that acquireBuffer should
+ // only return a buffer with a frame number less than or equal to
+ // maxFrameNumber. If no such frame is available (such as when a buffer has
+ // been replaced but the consumer has not received the onFrameReplaced
+ // callback), then PRESENT_LATER will be returned.
+ //
// Return of NO_ERROR means the operation completed as normal.
//
// Return of a positive value means the operation could not be completed
@@ -78,7 +84,8 @@ public:
//
// Return of a negative value means an error has occurred:
// * INVALID_OPERATION - too many buffers have been acquired
- virtual status_t acquireBuffer(BufferItem* buffer, nsecs_t presentWhen) = 0;
+ virtual status_t acquireBuffer(BufferItem* buffer, nsecs_t presentWhen,
+ uint64_t maxFrameNumber = 0) = 0;
// detachBuffer attempts to remove all ownership of the buffer in the given
// slot from the buffer queue. If this call succeeds, the slot will be
@@ -248,11 +255,6 @@ public:
// Retrieve the sideband buffer stream, if any.
virtual sp<NativeHandle> getSidebandStream() const = 0;
- // setShadowQueueSize notifies the BufferQueue that the consumer is
- // shadowing its queue and allows it to limit the number of buffers it is
- // permitted to drop during acquire so as to not get out of sync.
- virtual void setShadowQueueSize(size_t size) = 0;
-
// dump state into a string
virtual void dump(String8& result, const char* prefix) const = 0;