libgralloc: Store unaligned buffer resolution in private handle.
Add unaligned_width and unaligned_height in private_handle_t to store
the buffer resolution without alignment that client asked to allocate.
Change-Id: I28d757af4178f581e6a83dc06198106c85fc7262
CRs-Fixed: 1040942
diff --git a/libgralloc1/gr_buf_mgr.cpp b/libgralloc1/gr_buf_mgr.cpp
index 33abd40..9bba82b 100644
--- a/libgralloc1/gr_buf_mgr.cpp
+++ b/libgralloc1/gr_buf_mgr.cpp
@@ -361,8 +361,8 @@
return flags;
}
-int BufferManager::AllocateBuffer(unsigned int size, int aligned_w, int aligned_h, int real_w,
- int real_h, int format, int bufferType,
+int BufferManager::AllocateBuffer(unsigned int size, int aligned_w, int aligned_h, int unaligned_w,
+ int unaligned_h, int format, int bufferType,
gralloc1_producer_usage_t prod_usage,
gralloc1_consumer_usage_t cons_usage, buffer_handle_t *handle) {
int err = 0;
@@ -405,7 +405,7 @@
uint64_t eBaseAddr = (uint64_t)(e_data.base) + e_data.offset;
private_handle_t *hnd = new private_handle_t(data.fd, size, flags, bufferType, format, aligned_w,
aligned_h, e_data.fd, e_data.offset, eBaseAddr,
- real_w, real_h, prod_usage, cons_usage);
+ unaligned_w, unaligned_h, prod_usage, cons_usage);
hnd->offset = data.offset;
hnd->base = (uint64_t)(data.base) + data.offset;
@@ -493,6 +493,7 @@
private_handle_t *hnd = reinterpret_cast<private_handle_t *>(
native_handle_create(private_handle_t::kNumFds, private_handle_t::NumInts()));
if (hnd) {
+ unsigned int alignedw = 0, alignedh = 0;
hnd->magic = private_handle_t::kMagic;
hnd->fd = fd;
hnd->flags = private_handle_t::PRIV_FLAGS_USES_ION;
@@ -500,8 +501,12 @@
hnd->offset = offset;
hnd->base = uint64_t(base) + offset;
hnd->gpuaddr = 0;
- hnd->width = width;
- hnd->height = height;
+ BufferDescriptor descriptor(width, height, format);
+ allocator_->GetAlignedWidthAndHeight(descriptor, &alignedw, &alignedh);
+ hnd->unaligned_width = width;
+ hnd->unaligned_height = height;
+ hnd->width = alignedw;
+ hnd->height = alignedh;
hnd->format = format;
*handle = reinterpret_cast<native_handle_t *>(hnd);
}