diff options
Diffstat (limited to 'libs/ui/GraphicBufferAllocator.cpp')
-rw-r--r-- | libs/ui/GraphicBufferAllocator.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp index 3f958ba68f..943d13ec68 100644 --- a/libs/ui/GraphicBufferAllocator.cpp +++ b/libs/ui/GraphicBufferAllocator.cpp @@ -83,17 +83,20 @@ void GraphicBufferAllocator::dump(std::string& result, bool less) const { KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList); uint64_t total = 0; result.append("GraphicBufferAllocator buffers:\n"); - const size_t count = list.size(); - StringAppendF(&result, "%10s | %11s | %18s | %s | %8s | %10s | %s\n", "Handle", "Size", - "W (Stride) x H", "Layers", "Format", "Usage", "Requestor"); - for (size_t i = 0; i < count; i++) { + const size_t c = list.size(); + for (size_t i=0 ; i<c ; i++) { const alloc_rec_t& rec(list.valueAt(i)); - std::string sizeStr = (rec.size) - ? base::StringPrintf("%7.2f KiB", static_cast<double>(rec.size) / 1024.0) - : "unknown"; - StringAppendF(&result, "%10p | %11s | %4u (%4u) x %4u | %6u | %8X | 0x%8" PRIx64 " | %s\n", - list.keyAt(i), sizeStr.c_str(), rec.width, rec.stride, rec.height, - rec.layerCount, rec.format, rec.usage, rec.requestorName.c_str()); + if (rec.size) { + StringAppendF(&result, + "%10p: %7.2f KiB | %4u (%4u) x %4u | %4u | %8X | 0x%" PRIx64 " | %s\n", + list.keyAt(i), static_cast<double>(rec.size) / 1024.0, rec.width, rec.stride, rec.height, + rec.layerCount, rec.format, rec.usage, rec.requestorName.c_str()); + } else { + StringAppendF(&result, + "%10p: unknown | %4u (%4u) x %4u | %4u | %8X | 0x%" PRIx64 " | %s\n", + list.keyAt(i), rec.width, rec.stride, rec.height, rec.layerCount, + rec.format, rec.usage, rec.requestorName.c_str()); + } total += rec.size; } StringAppendF(&result, "Total allocated by GraphicBufferAllocator (estimate): %.2f KB\n", @@ -128,9 +131,8 @@ status_t GraphicBufferAllocator::allocateHelper(uint32_t width, uint32_t height, } // Ensure that layerCount is valid. - if (layerCount < 1) { + if (layerCount < 1) layerCount = 1; - } // TODO(b/72323293, b/72703005): Remove these invalid bits from callers usage &= ~static_cast<uint64_t>((1 << 10) | (1 << 13)); @@ -141,7 +143,7 @@ status_t GraphicBufferAllocator::allocateHelper(uint32_t width, uint32_t height, ALOGE("Failed to allocate (%u x %u) layerCount %u format %d " "usage %" PRIx64 ": %d", width, height, layerCount, format, usage, error); - return error; + return NO_MEMORY; } if (!importBuffer) { |