gralloc: Return aligned w,h for UPDATE_BUFFER_GEOMETRY
Return aligned width and height in case meta operation is
UPDATE_BUFFER_GEOMETRY.
CRs-Fixed: 880373
Change-Id: I3b263518d509f4de68c93692eace3cb0b2c69808
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index a7e00c5..0070fa1 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -149,6 +149,26 @@
return 0;
}
+void AdrenoMemInfo::getAlignedWidthAndHeight(const private_handle_t *hnd, int& aligned_w,
+ int& aligned_h) {
+ MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
+ if(metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
+ int w = metadata->bufferDim.sliceWidth;
+ int h = metadata->bufferDim.sliceHeight;
+ int f = hnd->format;
+ int usage = 0;
+
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_UBWC_ALIGNED) {
+ usage = GRALLOC_USAGE_PRIVATE_ALLOC_UBWC;
+ }
+
+ getAlignedWidthAndHeight(w, h, f, usage, aligned_w, aligned_h);
+ } else {
+ aligned_w = hnd->width;
+ aligned_h = hnd->height;
+ }
+
+}
void AdrenoMemInfo::getAlignedWidthAndHeight(int width, int height, int format,
int usage, int& aligned_w, int& aligned_h)
@@ -158,8 +178,7 @@
// Currently surface padding is only computed for RGB* surfaces.
if (format <= HAL_PIXEL_FORMAT_BGRA_8888) {
int tileEnabled = ubwc_enabled || isMacroTileEnabled(format, usage);
- AdrenoMemInfo::getInstance().getGpuAlignedWidthHeight(width,
- height, format, tileEnabled, aligned_w, aligned_h);
+ getGpuAlignedWidthHeight(width, height, format, tileEnabled, aligned_w, aligned_h);
return;
}
@@ -649,6 +668,7 @@
int width = hnd->width;
int height = hnd->height;
int format = hnd->format;
+
unsigned int ystride, cstride;
unsigned int alignment = 4096;
@@ -662,8 +682,14 @@
// Check metadata if the geometry has been updated.
if(metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
+ int usage = 0;
+
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_UBWC_ALIGNED) {
+ usage = GRALLOC_USAGE_PRIVATE_ALLOC_UBWC;
+ }
+
AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(metadata->bufferDim.sliceWidth,
- metadata->bufferDim.sliceHeight, format, 0, width, height);
+ metadata->bufferDim.sliceHeight, format, usage, width, height);
}
// Get the chroma offsets from the handle width/height. We take advantage
diff --git a/libgralloc/gr.h b/libgralloc/gr.h
index e27203a..6d7f4a7 100644
--- a/libgralloc/gr.h
+++ b/libgralloc/gr.h
@@ -120,6 +120,14 @@
int usage, int& aligned_w, int& aligned_h);
/*
+ * Function to compute aligned width and aligned height based on
+ * private handle
+ *
+ * @return aligned width, aligned height
+ */
+ void getAlignedWidthAndHeight(const private_handle_t *hnd, int& aligned_w, int& aligned_h);
+
+ /*
* Function to compute the adreno aligned width and aligned height
* based on the width and format.
*
diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp
index 3cfdc55..a5d3e69 100644
--- a/libgralloc/mapper.cpp
+++ b/libgralloc/mapper.cpp
@@ -344,36 +344,33 @@
case GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_FROM_HANDLE:
{
- private_handle_t* hnd = va_arg(args, private_handle_t*);
+ const private_handle_t* hnd = va_arg(args, private_handle_t*);
int *stride = va_arg(args, int *);
if (private_handle_t::validate(hnd)) {
return res;
}
- MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
- if(metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
- *stride = metadata->bufferDim.sliceWidth;
- } else {
- *stride = hnd->width;
- }
+
+ int alignedw = 0, alignedh = 0;
+ AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(hnd, alignedw, alignedh);
+ *stride = alignedw;
+
res = 0;
} break;
case GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE:
{
- private_handle_t* hnd = va_arg(args, private_handle_t*);
+ const private_handle_t* hnd = va_arg(args, private_handle_t*);
int *stride = va_arg(args, int *);
int *height = va_arg(args, int *);
if (private_handle_t::validate(hnd)) {
return res;
}
- MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
- if(metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
- *stride = metadata->bufferDim.sliceWidth;
- *height = metadata->bufferDim.sliceHeight;
- } else {
- *stride = hnd->width;
- *height = hnd->height;
- }
+
+ int alignedw = 0, alignedh = 0;
+ AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(hnd, alignedw, alignedh);
+ *stride = alignedw;
+ *height = alignedh;
+
res = 0;
} break;
diff --git a/sdm/libs/hwc/hwc_display_virtual.cpp b/sdm/libs/hwc/hwc_display_virtual.cpp
index 10a8ec2..aa79a5f 100644
--- a/sdm/libs/hwc/hwc_display_virtual.cpp
+++ b/sdm/libs/hwc/hwc_display_virtual.cpp
@@ -39,24 +39,6 @@
namespace sdm {
-static int GetWidthFromMetaData(const private_handle_t *handle) {
- MetaData_t *metadata = reinterpret_cast<MetaData_t *>(handle->base_metadata);
- if (metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
- return metadata->bufferDim.sliceWidth;
- }
-
- return handle->width;
-}
-
-static int GetHeightFromMetaData(const private_handle_t *handle) {
- MetaData_t *metadata = reinterpret_cast<MetaData_t *>(handle->base_metadata);
- if (metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
- return metadata->bufferDim.sliceHeight;
- }
-
- return handle->height;
-}
-
int HWCDisplayVirtual::Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs,
uint32_t primary_width, uint32_t primary_height,
hwc_display_contents_1_t *content_list,
@@ -217,8 +199,11 @@
return -EINVAL;
}
- int active_width = GetWidthFromMetaData(output_handle);
- int active_height = GetHeightFromMetaData(output_handle);
+ int active_width;
+ int active_height;
+
+ AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(output_handle, active_width,
+ active_height);
if ((active_width != INT(output_buffer_->width)) ||
(active_height!= INT(output_buffer_->height)) ||
@@ -259,8 +244,12 @@
return -EINVAL;
}
- output_buffer_->width = GetWidthFromMetaData(output_handle);
- output_buffer_->height = GetHeightFromMetaData(output_handle);
+ int output_buffer_width, output_buffer_height;
+ AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(output_handle, output_buffer_width,
+ output_buffer_height);
+
+ output_buffer_->width = output_buffer_width;
+ output_buffer_->height = output_buffer_height;
output_buffer_->flags.secure = 0;
output_buffer_->flags.video = 0;