ui: Rework GraphicBuffer + Allocator for 64bit usage
Removes gralloc1-style flags, and replaces with HIDL-style single 64bit
usage. Internal storage of the usage is still 32bit; to be addressed
with a future change.
Change-Id: I60062208cbb06bc8cf6c293e7c7e1530c1147912
Bug: b/33350696
Test: Bullhead: booted to launcher, take photo, watch youtube
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index 11f0250..eaba1ed 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -64,18 +64,16 @@
const alloc_rec_t& rec(list.valueAt(i));
if (rec.size) {
snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %4u | %8X | 0x%" PRIx64
- ", 0x%" PRIx64 " | %s\n",
+ " | %s\n",
list.keyAt(i), rec.size/1024.0,
rec.width, rec.stride, rec.height, rec.layerCount, rec.format,
- rec.producerUsage, rec.consumerUsage,
- rec.requestorName.c_str());
+ rec.usage, rec.requestorName.c_str());
} else {
snprintf(buffer, SIZE, "%10p: unknown | %4u (%4u) x %4u | %4u | %8X | 0x%" PRIx64
- ", 0x%" PRIx64 " | %s\n",
+ " | %s\n",
list.keyAt(i),
rec.width, rec.stride, rec.height, rec.layerCount, rec.format,
- rec.producerUsage, rec.consumerUsage,
- rec.requestorName.c_str());
+ rec.usage, rec.requestorName.c_str());
}
result.append(buffer);
total += rec.size;
@@ -95,8 +93,8 @@
}
status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount, uint64_t producerUsage,
- uint64_t consumerUsage, buffer_handle_t* handle, uint32_t* stride,
+ PixelFormat format, uint32_t layerCount, uint64_t usage,
+ buffer_handle_t* handle, uint32_t* stride,
uint64_t /*graphicBufferId*/, std::string requestorName)
{
ATRACE_CALL();
@@ -115,8 +113,7 @@
info.height = height;
info.layerCount = layerCount;
info.format = static_cast<Gralloc2::PixelFormat>(format);
- info.usage = static_cast<uint64_t>(android_convertGralloc1To0Usage(
- producerUsage, consumerUsage));
+ info.usage = usage;
Gralloc2::Error error = mAllocator->allocate(info, stride, handle);
if (error == Gralloc2::Error::NONE) {
@@ -129,8 +126,7 @@
rec.stride = *stride;
rec.format = format;
rec.layerCount = layerCount;
- rec.producerUsage = producerUsage;
- rec.consumerUsage = consumerUsage;
+ rec.usage = usage;
rec.size = static_cast<size_t>(height * (*stride) * bpp);
rec.requestorName = std::move(requestorName);
list.add(*handle, rec);
@@ -138,9 +134,9 @@
return NO_ERROR;
} else {
ALOGE("Failed to allocate (%u x %u) layerCount %u format %d "
- "producerUsage %" PRIx64 " consumerUsage %" PRIx64 ": %d",
- width, height, layerCount, format, producerUsage,
- consumerUsage, error);
+ "usage %" PRIx64 ": %d",
+ width, height, layerCount, format, usage,
+ error);
return NO_MEMORY;
}
}