diff options
Diffstat (limited to 'services/surfaceflinger/ClientCache.cpp')
-rw-r--r-- | services/surfaceflinger/ClientCache.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/services/surfaceflinger/ClientCache.cpp b/services/surfaceflinger/ClientCache.cpp index f310738423..3c7b9d93aa 100644 --- a/services/surfaceflinger/ClientCache.cpp +++ b/services/surfaceflinger/ClientCache.cpp @@ -21,12 +21,13 @@ #include <cinttypes> +#include <android-base/stringprintf.h> +#include <renderengine/impl/ExternalTexture.h> + #include "ClientCache.h" namespace android { -using base::StringAppendF; - ANDROID_SINGLETON_STATIC_INSTANCE(ClientCache); ClientCache::ClientCache() : mDeathRecipient(new CacheDeathRecipient) {} @@ -82,10 +83,13 @@ bool ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& bu return false; } - status_t err = token->linkToDeath(mDeathRecipient); - if (err != NO_ERROR) { - ALOGE("failed to cache buffer: could not link to death"); - return false; + // Only call linkToDeath if not a local binder + if (token->localBinder() == nullptr) { + status_t err = token->linkToDeath(mDeathRecipient); + if (err != NO_ERROR) { + ALOGE("failed to cache buffer: could not link to death"); + return false; + } } auto [itr, success] = mBuffers.emplace(processToken, @@ -106,8 +110,9 @@ bool ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& bu "Attempted to build the ClientCache before a RenderEngine instance was " "ready!"); processBuffers[id].buffer = std::make_shared< - renderengine::ExternalTexture>(buffer, *mRenderEngine, - renderengine::ExternalTexture::Usage::READABLE); + renderengine::impl::ExternalTexture>(buffer, *mRenderEngine, + renderengine::impl::ExternalTexture::Usage:: + READABLE); return true; } @@ -212,16 +217,15 @@ void ClientCache::CacheDeathRecipient::binderDied(const wp<IBinder>& who) { void ClientCache::dump(std::string& result) { std::lock_guard lock(mMutex); - for (auto i : mBuffers) { - const sp<IBinder>& cacheOwner = i.second.first; - StringAppendF(&result," Cache owner: %p\n", cacheOwner.get()); - auto &buffers = i.second.second; - for (auto& [id, clientCacheBuffer] : buffers) { - StringAppendF(&result, "\t ID: %d, Width/Height: %d,%d\n", (int)id, - (int)clientCacheBuffer.buffer->getBuffer()->getWidth(), - (int)clientCacheBuffer.buffer->getBuffer()->getHeight()); + for (const auto& [_, cache] : mBuffers) { + base::StringAppendF(&result, " Cache owner: %p\n", cache.first.get()); + + for (const auto& [id, entry] : cache.second) { + const auto& buffer = entry.buffer->getBuffer(); + base::StringAppendF(&result, "\tID: %" PRIu64 ", size: %ux%u\n", id, buffer->getWidth(), + buffer->getHeight()); } } } -}; // namespace android +} // namespace android |