summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2017-06-13 17:09:11 -0700
committerEino-Ville Talvala <etalvala@google.com>2017-06-13 17:09:11 -0700
commitc6ff79830b9126f948791f03164a58ad079e9e5d (patch)
treea303749034c3b6ffb35b11f1f6907bfe668bc2c2
parent2672decb92fa24ef012cbbd3690c120530fa3cd3 (diff)
downloadnative-c6ff79830b9126f948791f03164a58ad079e9e5d.tar.gz
ConsumerBase: discardFreeBuffers() also needs to dump its own cache
ConsumerBase has its own cached slots with graphic buffer references, so it's not enough to just ask the buffer queue consumer to free buffers. Add code equivalent to what happens in the onBuffersReleased callback. Test: Bug: 62593139 Change-Id: Ibc1444b868c6150aa2da1c209e06bdba42f1595d
-rw-r--r--include/gui/IGraphicBufferConsumer.h2
-rw-r--r--libs/gui/ConsumerBase.cpp13
2 files changed, 14 insertions, 1 deletions
diff --git a/include/gui/IGraphicBufferConsumer.h b/include/gui/IGraphicBufferConsumer.h
index 57cce16d10..3d069dfe48 100644
--- a/include/gui/IGraphicBufferConsumer.h
+++ b/include/gui/IGraphicBufferConsumer.h
@@ -267,6 +267,8 @@ public:
// discardFreeBuffers releases all currently-free buffers held by the BufferQueue, in order to
// reduce the memory consumption of the BufferQueue to the minimum possible without
// discarding data.
+ // The consumer invoking this method is responsible for calling getReleasedBuffers() after this
+ // call to free up any of its locally cached buffers.
virtual status_t discardFreeBuffers() = 0;
// dump state into a string
diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp
index 5c6158c771..c2b10a91dd 100644
--- a/libs/gui/ConsumerBase.cpp
+++ b/libs/gui/ConsumerBase.cpp
@@ -253,7 +253,18 @@ status_t ConsumerBase::discardFreeBuffers() {
CB_LOGE("discardFreeBuffers: ConsumerBase is abandoned!");
return NO_INIT;
}
- return mConsumer->discardFreeBuffers();
+ status_t err = mConsumer->discardFreeBuffers();
+ if (err != OK) {
+ return err;
+ }
+ uint64_t mask;
+ mConsumer->getReleasedBuffers(&mask);
+ for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
+ if (mask & (1ULL << i)) {
+ freeBufferLocked(i);
+ }
+ }
+ return OK;
}
void ConsumerBase::dumpState(String8& result) const {