diff options
author | koron393 <koron393@gmail.com> | 2019-05-07 03:01:14 +0900 |
---|---|---|
committer | Arian <arian.kulmer@web.de> | 2019-10-25 22:16:13 +0200 |
commit | 5a6ff3a367c8736fef6af23608866248c2fec43e (patch) | |
tree | 6e072264562929dadeea7f4e178a6cbdd8e7a43f /libshims/ui | |
parent | eb4c130ccf05799fe7c20a4737f21dd63c0dbed5 (diff) |
msm8974-common: libshim_camera: Apply revert patches to Marshmallow
* Fix build.
* Revert GraphicBuffer method to Marshmallow (for 23.5.A.1.291 blobs).
* Apply module loading changes.
* TODO: Remove unneeded sources.
Change-Id: Ifce6a23840bd8c6170e0b8a714233d7b5e99acb4
Diffstat (limited to 'libshims/ui')
-rw-r--r-- | libshims/ui/GraphicBuffer.cpp | 61 | ||||
-rw-r--r-- | libshims/ui/GraphicBufferAllocator.cpp | 32 |
2 files changed, 54 insertions, 39 deletions
diff --git a/libshims/ui/GraphicBuffer.cpp b/libshims/ui/GraphicBuffer.cpp index 7670ac6..a1cf872 100644 --- a/libshims/ui/GraphicBuffer.cpp +++ b/libshims/ui/GraphicBuffer.cpp @@ -58,40 +58,47 @@ GraphicBuffer::GraphicBuffer() handle = NULL; } -// deprecated GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight, - PixelFormat inFormat, uint32_t inUsage, std::string requestorName) - : GraphicBuffer(inWidth, inHeight, inFormat, 1, static_cast<uint64_t>(inUsage), requestorName) -{ -} - -GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight, - PixelFormat inFormat, uint32_t inLayerCount, uint64_t usage, std::string requestorName) - : GraphicBuffer() + PixelFormat inFormat, uint32_t inUsage) + : BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()), + mInitCheck(NO_ERROR), mId(getUniqueId()) { - mInitCheck = initWithSize(inWidth, inHeight, inFormat, inLayerCount, - usage, std::move(requestorName)); + width = + height = + stride = + format = + usage = 0; + handle = NULL; + mInitCheck = initWithSize(inWidth, inHeight, inFormat, 1, + static_cast<uint64_t>(inUsage), "<Unknown>"); } -// deprecated GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight, - PixelFormat inFormat, uint32_t inLayerCount, uint32_t inUsage, - uint32_t inStride, native_handle_t* inHandle, bool keepOwnership) - : GraphicBuffer(inHandle, keepOwnership ? TAKE_HANDLE : WRAP_HANDLE, - inWidth, inHeight, inFormat, inLayerCount, static_cast<uint64_t>(inUsage), - inStride) + PixelFormat inFormat, uint32_t inUsage, uint32_t inStride, + native_handle_t* inHandle, bool keepOwnership) + : BASE(), mOwner(keepOwnership ? ownHandle : ownNone), + mBufferMapper(GraphicBufferMapper::get()), + mInitCheck(NO_ERROR), mId(getUniqueId()) { -} - -GraphicBuffer::GraphicBuffer(const native_handle_t* handle, - HandleWrapMethod method, uint32_t width, uint32_t height, - PixelFormat format, uint32_t layerCount, - uint64_t usage, - uint32_t stride) - : GraphicBuffer() + width = static_cast<int>(inWidth); + height = static_cast<int>(inHeight); + stride = static_cast<int>(inStride); + format = inFormat; + usage = static_cast<int>(inUsage); + handle = inHandle; +} + +GraphicBuffer::GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership) + : BASE(), mOwner(keepOwnership ? ownHandle : ownNone), + mBufferMapper(GraphicBufferMapper::get()), + mInitCheck(NO_ERROR), mWrappedBuffer(buffer), mId(getUniqueId()) { - mInitCheck = initWithHandle(handle, method, width, height, format, - layerCount, usage, stride); + width = buffer->width; + height = buffer->height; + stride = buffer->stride; + format = buffer->format; + usage = buffer->usage; + handle = buffer->handle; } GraphicBuffer::~GraphicBuffer() diff --git a/libshims/ui/GraphicBufferAllocator.cpp b/libshims/ui/GraphicBufferAllocator.cpp index eaba1ed..3806a8d 100644 --- a/libshims/ui/GraphicBufferAllocator.cpp +++ b/libshims/ui/GraphicBufferAllocator.cpp @@ -42,13 +42,20 @@ KeyedVector<buffer_handle_t, GraphicBufferAllocator::alloc_rec_t> GraphicBufferAllocator::sAllocList; GraphicBufferAllocator::GraphicBufferAllocator() - : mMapper(GraphicBufferMapper::getInstance()), - mAllocator(std::make_unique<Gralloc2::Allocator>( - mMapper.getGrallocMapper())) + : mAllocDev(0) { + hw_module_t const* module; + int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); + ALOGE_IF(err, "FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID); + if (err == 0) { + gralloc_open(module, &mAllocDev); + } } -GraphicBufferAllocator::~GraphicBufferAllocator() {} +GraphicBufferAllocator::~GraphicBufferAllocator() +{ + gralloc_close(mAllocDev); +} void GraphicBufferAllocator::dump(String8& result) const { @@ -143,17 +150,18 @@ status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, status_t GraphicBufferAllocator::free(buffer_handle_t handle) { - ATRACE_CALL(); + status_t err; - // We allocated a buffer from the allocator and imported it into the - // mapper to get the handle. We just need to free the handle now. - mMapper.freeBuffer(handle); + err = mAllocDev->free(mAllocDev, handle); - Mutex::Autolock _l(sLock); - KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList); - list.removeItem(handle); + ALOGW_IF(err, "free(...) failed %d (%s)", err, strerror(-err)); + if (err == NO_ERROR) { + Mutex::Autolock _l(sLock); + KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList); + list.removeItem(handle); + } - return NO_ERROR; + return err; } // --------------------------------------------------------------------------- |