Gralloc: Use adreno APIs for buffer size calculations
1) Add support to use adreno APIs for non video layers'
buffer size calculations.
2) Add graphics metadata field to MetaData_t structure.
3) Add bindings for newly introduced formats in
GetGpuPixelFormat.
4) Add support to retrieve the graphics metadata in
Perform API.
5) Modify BUFFER_TYPE determination logic
Change-Id: I7674209b42d7cd39bc8de39e3a10582bb216e6cf
CRs-Fixed: 2226672
diff --git a/gralloc/gr_buf_mgr.cpp b/gralloc/gr_buf_mgr.cpp
index 5e1973e..5cf18aa 100644
--- a/gralloc/gr_buf_mgr.cpp
+++ b/gralloc/gr_buf_mgr.cpp
@@ -301,10 +301,10 @@
}
int BufferManager::GetBufferType(int inputFormat) {
- int buffer_type = BUFFER_TYPE_VIDEO;
- if (IsUncompressedRGBFormat(inputFormat)) {
- // RGB formats
- buffer_type = BUFFER_TYPE_UI;
+ int buffer_type = BUFFER_TYPE_UI;
+ if (IsYuvFormat(inputFormat)) {
+ // Video format
+ buffer_type = BUFFER_TYPE_VIDEO;
}
return buffer_type;
@@ -326,9 +326,18 @@
int buffer_type = GetBufferType(format);
BufferInfo info = GetBufferInfo(descriptor);
info.format = format;
- GetBufferSizeAndDimensions(info, &size, &alignedw, &alignedh);
- size = (bufferSize >= size) ? bufferSize : size;
+ bool use_adreno_for_size = false;
+ GraphicsMetadata graphics_metadata = {};
+
+ use_adreno_for_size = ((buffer_type != BUFFER_TYPE_VIDEO) && GetAdrenoSizeAPIStatus());
+ if (use_adreno_for_size) {
+ GetGpuResourceSizeAndDimensions(info, &size, &alignedw, &alignedh, &graphics_metadata);
+ } else {
+ GetBufferSizeAndDimensions(info, &size, &alignedw, &alignedh);
+ }
+
+ size = (bufferSize >= size) ? bufferSize : size;
int err = 0;
int flags = 0;
auto page_size = UINT(getpagesize());
@@ -373,6 +382,10 @@
ColorSpace_t colorSpace = (buffer_type == BUFFER_TYPE_VIDEO) ? ITU_R_601 : ITU_R_709;
setMetaData(hnd, UPDATE_COLOR_SPACE, reinterpret_cast<void *>(&colorSpace));
+ if (use_adreno_for_size) {
+ setMetaData(hnd, SET_GRAPHICS_METADATA, reinterpret_cast<void *>(&graphics_metadata));
+ }
+
*handle = hnd;
RegisterHandleLocked(hnd, data.ion_handle, e_data.ion_handle);
ALOGD_IF(DEBUG, "Allocated buffer handle: %p id: %" PRIu64, hnd, hnd->id);