diff options
author | Ian Elliott <ianelliott@google.com> | 2017-07-18 11:05:49 -0600 |
---|---|---|
committer | Ian Elliott <ianelliott@google.com> | 2017-07-31 15:34:11 +0000 |
commit | a2eb34cfbe089deb9a519e9702e17d9dfe26f9e8 (patch) | |
tree | 292e7d3fb3a109268e8e5304b789023b10ecbbbf /libs/gui/IGraphicBufferProducer.cpp | |
parent | 8cbab7c3c93c1bc9364a81726f02eeacc4a9356b (diff) | |
download | native-a2eb34cfbe089deb9a519e9702e17d9dfe26f9e8.tar.gz |
Have the Surface class track the buffer age.
Have the Surface class track the buffer age, so that Surface::query()
can return the buffer age without having to use a binder call to
BufferQueueProducer::query(). The idea is for
BufferQueueProducer::dequeueBuffer() to return the value, which the
Surface class will cache for later use by Surface::query().
Bug: b/27903668
Test: Use systrace to no ensure query binder call after dequeueBuffer.
Change-Id: I106a7bd27461d381f0bd84df70d804de56a128ab
(cherry picked from commit d11b044864be525a1646f93106ab496195bb8239)
Diffstat (limited to 'libs/gui/IGraphicBufferProducer.cpp')
-rw-r--r-- | libs/gui/IGraphicBufferProducer.cpp | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp index 1b0fe06810..8406a52544 100644 --- a/libs/gui/IGraphicBufferProducer.cpp +++ b/libs/gui/IGraphicBufferProducer.cpp @@ -124,9 +124,9 @@ public: return result; } - virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, uint32_t width, - uint32_t height, PixelFormat format, uint64_t usage, - FrameEventHistoryDelta* outTimestamps) { + virtual status_t dequeueBuffer(int* buf, sp<Fence>* fence, uint32_t width, uint32_t height, + PixelFormat format, uint64_t usage, uint64_t* outBufferAge, + FrameEventHistoryDelta* outTimestamps) { Parcel data, reply; bool getFrameTimestamps = (outTimestamps != nullptr); @@ -149,6 +149,17 @@ public: fence->clear(); return result; } + if (outBufferAge) { + result = reply.readUint64(outBufferAge); + } else { + // Read the value even if outBufferAge is nullptr: + uint64_t bufferAge; + result = reply.readUint64(&bufferAge); + } + if (result != NO_ERROR) { + ALOGE("IGBP::dequeueBuffer failed to read buffer age: %d", result); + return result; + } if (getFrameTimestamps) { result = reply.read(*outTimestamps); if (result != NO_ERROR) { @@ -516,11 +527,10 @@ public: return mBase->setAsyncMode(async); } - status_t dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w, uint32_t h, - PixelFormat format, uint64_t usage, - FrameEventHistoryDelta* outTimestamps) override { - return mBase->dequeueBuffer( - slot, fence, w, h, format, usage, outTimestamps); + status_t dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w, uint32_t h, PixelFormat format, + uint64_t usage, uint64_t* outBufferAge, + FrameEventHistoryDelta* outTimestamps) override { + return mBase->dequeueBuffer(slot, fence, w, h, format, usage, outBufferAge, outTimestamps); } status_t detachBuffer(int slot) override { @@ -655,16 +665,18 @@ status_t BnGraphicBufferProducer::onTransact( uint32_t height = data.readUint32(); PixelFormat format = static_cast<PixelFormat>(data.readInt32()); uint64_t usage = data.readUint64(); + uint64_t bufferAge = 0; bool getTimestamps = data.readBool(); int buf = 0; sp<Fence> fence = Fence::NO_FENCE; FrameEventHistoryDelta frameTimestamps; - int result = dequeueBuffer(&buf, &fence, width, height, format, - usage, getTimestamps ? &frameTimestamps : nullptr); + int result = dequeueBuffer(&buf, &fence, width, height, format, usage, &bufferAge, + getTimestamps ? &frameTimestamps : nullptr); reply->writeInt32(buf); reply->write(*fence); + reply->writeUint64(bufferAge); if (getTimestamps) { reply->write(frameTimestamps); } |