From 678bdd6349344df254cc0c3377a40fd99e216635 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 3 Dec 2010 17:33:09 -0800 Subject: [PATCH] [3171580] don't automatically log GraphicBuffer allocation failures some of these failures are not fatal and even expected in some cases so they should not emit a dump in the log in those cases. Change-Id: Idcfa252e3bfa9d74e27fe4ad8f8623aa01aa9c5e --- include/ui/GraphicBuffer.h | 5 ++++- include/ui/GraphicBufferAllocator.h | 1 + libs/ui/GraphicBuffer.cpp | 5 +++++ libs/ui/GraphicBufferAllocator.cpp | 11 +++++++---- services/surfaceflinger/Layer.cpp | 1 + 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h index a3e85a96a..6edc3caab 100644 --- a/include/ui/GraphicBuffer.h +++ b/include/ui/GraphicBuffer.h @@ -88,12 +88,15 @@ public: status_t lock(uint32_t usage, const Rect& rect, void** vaddr); status_t lock(GGLSurface* surface, uint32_t usage); status_t unlock(); - + android_native_buffer_t* getNativeBuffer() const; void setIndex(int index); int getIndex() const; + // for debugging + static void dumpAllocationsToSystemLog(); + private: virtual ~GraphicBuffer(); diff --git a/include/ui/GraphicBufferAllocator.h b/include/ui/GraphicBufferAllocator.h index 54b8236e2..dffa788f4 100644 --- a/include/ui/GraphicBufferAllocator.h +++ b/include/ui/GraphicBufferAllocator.h @@ -68,6 +68,7 @@ public: status_t free(buffer_handle_t handle); void dump(String8& res) const; + static void dumpToSystemLog(); private: struct alloc_rec_t { diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp index 519c277c6..828a988be 100644 --- a/libs/ui/GraphicBuffer.cpp +++ b/libs/ui/GraphicBuffer.cpp @@ -99,6 +99,11 @@ status_t GraphicBuffer::initCheck() const { return mInitCheck; } +void GraphicBuffer::dumpAllocationsToSystemLog() +{ + GraphicBufferAllocator::dumpToSystemLog(); +} + android_native_buffer_t* GraphicBuffer::getNativeBuffer() const { return static_cast( diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp index d51664dde..fa46ab7b3 100644 --- a/libs/ui/GraphicBufferAllocator.cpp +++ b/libs/ui/GraphicBufferAllocator.cpp @@ -73,6 +73,13 @@ void GraphicBufferAllocator::dump(String8& result) const result.append(buffer); } +void GraphicBufferAllocator::dumpToSystemLog() +{ + String8 s; + GraphicBufferAllocator::getInstance().dump(s); + LOGD("%s", s.string()); +} + status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat format, int usage, buffer_handle_t* handle, int32_t* stride) { @@ -104,10 +111,6 @@ status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat forma rec.usage = usage; rec.size = h * stride[0] * bytesPerPixel(format); list.add(*handle, rec); - } else { - String8 s; - dump(s); - LOGD("%s", s.string()); } return err; diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index a060d316d..5018fb3c4 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -347,6 +347,7 @@ sp Layer::requestBuffer(int index, err = buffer->initCheck(); if (err || buffer->handle == 0) { + GraphicBuffer::dumpAllocationsToSystemLog(); LOGE_IF(err || buffer->handle == 0, "Layer::requestBuffer(this=%p), index=%d, w=%d, h=%d failed (%s)", this, index, w, h, strerror(-err));