diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2016-09-28 05:18:45 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-09-28 05:18:45 -0700 |
commit | 81c6c49dc4c14a668075d41ac943656203580083 (patch) | |
tree | 225358df955bab332046b90a445e93678f5b146f /libgralloc1 | |
parent | 65eaf80ad66093457c21d8abe267dd3dbc72efe4 (diff) | |
parent | ba55eac6aee47cb725b790751970e57be35e0814 (diff) | |
download | display-81c6c49dc4c14a668075d41ac943656203580083.tar.gz |
Merge "libgralloc: Store unaligned buffer resolution in private handle."
Diffstat (limited to 'libgralloc1')
-rw-r--r-- | libgralloc1/gr_buf_mgr.cpp | 15 | ||||
-rw-r--r-- | libgralloc1/gr_buf_mgr.h | 7 | ||||
-rw-r--r-- | libgralloc1/gr_device_impl.cpp | 4 | ||||
-rw-r--r-- | libgralloc1/gr_priv_handle.h | 47 |
4 files changed, 48 insertions, 25 deletions
diff --git a/libgralloc1/gr_buf_mgr.cpp b/libgralloc1/gr_buf_mgr.cpp index 33abd401..9bba82b1 100644 --- a/libgralloc1/gr_buf_mgr.cpp +++ b/libgralloc1/gr_buf_mgr.cpp @@ -361,8 +361,8 @@ int BufferManager::GetHandleFlags(int format, gralloc1_producer_usage_t prod_usa 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 @@ int BufferManager::AllocateBuffer(unsigned int size, int aligned_w, int aligned_ 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 @@ gralloc1_error_t BufferManager::Perform(int operation, va_list args) { 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 @@ gralloc1_error_t BufferManager::Perform(int operation, va_list args) { 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); } diff --git a/libgralloc1/gr_buf_mgr.h b/libgralloc1/gr_buf_mgr.h index d3c0e675..ed6b5911 100644 --- a/libgralloc1/gr_buf_mgr.h +++ b/libgralloc1/gr_buf_mgr.h @@ -49,9 +49,10 @@ class BufferManager { int GetBufferType(int format); int AllocateBuffer(const BufferDescriptor &descriptor, buffer_handle_t *handle, unsigned int bufferSize = 0); - int AllocateBuffer(unsigned int size, int aligned_w, int aligned_h, int real_w, int real_h, - int format, int bufferType, gralloc1_producer_usage_t prod_usage, - gralloc1_consumer_usage_t cons_usage, buffer_handle_t *handle); + int 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 GetDataAlignment(int format, gralloc1_producer_usage_t prod_usage, gralloc1_consumer_usage_t cons_usage); int GetHandleFlags(int format, gralloc1_producer_usage_t prod_usage, diff --git a/libgralloc1/gr_device_impl.cpp b/libgralloc1/gr_device_impl.cpp index 62589413..f837ee28 100644 --- a/libgralloc1/gr_device_impl.cpp +++ b/libgralloc1/gr_device_impl.cpp @@ -298,8 +298,8 @@ gralloc1_error_t GrallocImpl::GetBufferDimensions(gralloc1_device_t *device, buf gralloc1_error_t status = CheckDeviceAndHandle(device, buffer); if (status == GRALLOC1_ERROR_NONE) { const private_handle_t *hnd = PRIV_HANDLE_CONST(buffer); - *outWidth = UINT(hnd->GetRealWidth()); - *outHeight = UINT(hnd->GetRealHeight()); + *outWidth = UINT(hnd->GetUnalignedWidth()); + *outHeight = UINT(hnd->GetUnalignedHeight()); } return status; diff --git a/libgralloc1/gr_priv_handle.h b/libgralloc1/gr_priv_handle.h index 444fc800..ee38b4dc 100644 --- a/libgralloc1/gr_priv_handle.h +++ b/libgralloc1/gr_priv_handle.h @@ -86,8 +86,8 @@ struct private_handle_t : public native_handle_t { uint64_t base_metadata __attribute__((aligned(8))); // added for gralloc1 - int real_width; // holds width client asked to allocate - int real_height; // holds height client asked to allocate// holds width client asked to allocate + int unaligned_width; // holds width client asked to allocate + int unaligned_height; // holds height client asked to allocate gralloc1_producer_usage_t producer_usage __attribute__((aligned(8))); gralloc1_consumer_usage_t consumer_usage __attribute__((aligned(8))); @@ -99,33 +99,50 @@ struct private_handle_t : public native_handle_t { } private_handle_t(int fd, unsigned int size, int flags, int buf_type, int format, int width, - int height, int meta_fd = -1, unsigned int meta_offset = 0, - uint64_t meta_base = 0, int rw = 0, int rh = 0, - gralloc1_producer_usage_t prod_usage = GRALLOC1_PRODUCER_USAGE_NONE, - gralloc1_consumer_usage_t cons_usage = GRALLOC1_CONSUMER_USAGE_NONE) + int height) : fd(fd), - fd_metadata(meta_fd), + fd_metadata(-1), magic(kMagic), flags(flags), size(size), offset(0), buffer_type(buf_type), base(0), - offset_metadata(meta_offset), + offset_metadata(0), gpuaddr(0), format(format), width(width), height(height), - base_metadata(meta_base), - real_width(rw), - real_height(rh), - producer_usage(prod_usage), - consumer_usage(cons_usage) { + base_metadata(0), + unaligned_width(width), + unaligned_height(height), + producer_usage(GRALLOC1_PRODUCER_USAGE_NONE), + consumer_usage(GRALLOC1_CONSUMER_USAGE_NONE) { version = static_cast<int>(sizeof(native_handle)); numInts = NumInts(); numFds = kNumFds; } + private_handle_t(int fd, unsigned int size, int flags, int buf_type, int format, int width, + int height, int meta_fd, unsigned int meta_offset, uint64_t meta_base) + : private_handle_t(fd, size, flags, buf_type, format, width, height) { + fd_metadata = meta_fd; + offset_metadata = meta_offset; + base_metadata = meta_base; + } + + private_handle_t(int fd, unsigned int size, int flags, int buf_type, int format, int width, + int height, int meta_fd, unsigned int meta_offset, uint64_t meta_base, + int unaligned_w , int unaligned_h, + gralloc1_producer_usage_t prod_usage, gralloc1_consumer_usage_t cons_usage) + : private_handle_t(fd, size, flags, buf_type, format, width, height, meta_fd, meta_offset + meta_base) { + unaligned_width = unaligned_w; + unaligned_height = unaligned_h; + producer_usage = prod_usage; + consumer_usage = cons_usage; + } + ~private_handle_t() { magic = 0; ALOGE_IF(DBG_HANDLE, "deleting buffer handle %p", this); @@ -151,9 +168,9 @@ struct private_handle_t : public native_handle_t { return 0; } - int GetRealWidth() const { return real_width; } + int GetUnalignedWidth() const { return unaligned_width; } - int GetRealHeight() const { return real_height; } + int GetUnalignedHeight() const { return unaligned_height; } int GetColorFormat() const { return format; } |