summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/ClientCache.cpp
diff options
context:
space:
mode:
author Alec Mouri <alecmouri@google.com> 2019-08-12 16:01:52 -0700
committer android-build-merger <android-build-merger@google.com> 2019-08-12 16:01:52 -0700
commita0fb6c30cdbb64c387808d3c070ad5db2fe81c1b (patch)
tree6e2bc2c1bfa41001ccc3dbb367995a2f6dcb978f /services/surfaceflinger/ClientCache.cpp
parent04b07cf876b6dc30344980f576ad258c69c71f3c (diff)
parent2778a9fcf33c8a9afa0c161a936faab70f60d4fd (diff)
Merge "[SurfaceFlinger] Callback to renderengine when erasing BLAST buffers" into qt-r1-dev am: 9939d091ec
am: 2778a9fcf3 Change-Id: I150aa5c7d08e7f5037f7886d0380d157f45c4534
Diffstat (limited to 'services/surfaceflinger/ClientCache.cpp')
-rw-r--r--services/surfaceflinger/ClientCache.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/services/surfaceflinger/ClientCache.cpp b/services/surfaceflinger/ClientCache.cpp
index 77f2f5765c..16fe27c00a 100644
--- a/services/surfaceflinger/ClientCache.cpp
+++ b/services/surfaceflinger/ClientCache.cpp
@@ -55,16 +55,16 @@ bool ClientCache::getBuffer(const client_cache_t& cacheId,
return true;
}
-void ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& buffer) {
+bool ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& buffer) {
auto& [processToken, id] = cacheId;
if (processToken == nullptr) {
ALOGE("failed to cache buffer: invalid process token");
- return;
+ return false;
}
if (!buffer) {
ALOGE("failed to cache buffer: invalid buffer");
- return;
+ return false;
}
std::lock_guard lock(mMutex);
@@ -77,13 +77,13 @@ void ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& bu
token = processToken.promote();
if (!token) {
ALOGE("failed to cache buffer: invalid token");
- return;
+ return false;
}
status_t err = token->linkToDeath(mDeathRecipient);
if (err != NO_ERROR) {
ALOGE("failed to cache buffer: could not link to death");
- return;
+ return false;
}
auto [itr, success] =
mBuffers.emplace(processToken, std::unordered_map<uint64_t, ClientCacheBuffer>());
@@ -95,10 +95,11 @@ void ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& bu
if (processBuffers.size() > BUFFER_CACHE_MAX_SIZE) {
ALOGE("failed to cache buffer: cache is full");
- return;
+ return false;
}
processBuffers[id].buffer = buffer;
+ return true;
}
void ClientCache::erase(const client_cache_t& cacheId) {
@@ -139,16 +140,17 @@ sp<GraphicBuffer> ClientCache::get(const client_cache_t& cacheId) {
return buf->buffer;
}
-void ClientCache::registerErasedRecipient(const client_cache_t& cacheId,
+bool ClientCache::registerErasedRecipient(const client_cache_t& cacheId,
const wp<ErasedRecipient>& recipient) {
std::lock_guard lock(mMutex);
ClientCacheBuffer* buf = nullptr;
if (!getBuffer(cacheId, &buf)) {
ALOGE("failed to register erased recipient, could not retrieve buffer");
- return;
+ return false;
}
buf->recipients.insert(recipient);
+ return true;
}
void ClientCache::unregisterErasedRecipient(const client_cache_t& cacheId,