aboutsummaryrefslogtreecommitdiff
path: root/libshims/ui/GraphicBufferAllocator.cpp
diff options
context:
space:
mode:
authorkoron393 <koron393@gmail.com>2019-05-07 03:01:14 +0900
committerArian <arian.kulmer@web.de>2019-10-25 22:16:13 +0200
commit5a6ff3a367c8736fef6af23608866248c2fec43e (patch)
tree6e072264562929dadeea7f4e178a6cbdd8e7a43f /libshims/ui/GraphicBufferAllocator.cpp
parenteb4c130ccf05799fe7c20a4737f21dd63c0dbed5 (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/GraphicBufferAllocator.cpp')
-rw-r--r--libshims/ui/GraphicBufferAllocator.cpp32
1 files changed, 20 insertions, 12 deletions
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;
}
// ---------------------------------------------------------------------------