display: Clean up gralloc
* Remove pmem and ashmem implementations
* Remove usage of RefBase
* Reduce log verbosity
Change-Id: If8ef543d236e5305bd5430f4f9c62c51b3a13787
diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp
index 4249f3f..99f9f08 100644
--- a/libgralloc/mapper.cpp
+++ b/libgralloc/mapper.cpp
@@ -44,15 +44,14 @@
#include "memalloc.h"
using namespace gralloc;
-using android::sp;
/*****************************************************************************/
// Return the type of allocator -
// these are used for mapping/unmapping
-static sp<IMemAlloc> getAllocator(int flags)
+static IMemAlloc* getAllocator(int flags)
{
- sp<IMemAlloc> memalloc;
- sp<IAllocController> alloc_ctrl = IAllocController::getInstance(true);
+ IMemAlloc* memalloc;
+ IAllocController* alloc_ctrl = IAllocController::getInstance();
memalloc = alloc_ctrl->getAllocator(flags);
return memalloc;
}
@@ -66,7 +65,7 @@
if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) &&
!(hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER)) {
size_t size = hnd->size;
- sp<IMemAlloc> memalloc = getAllocator(hnd->flags) ;
+ IMemAlloc* memalloc = getAllocator(hnd->flags) ;
int err = memalloc->map_buffer(&mappedAddress, size,
hnd->offset, hnd->fd);
if(err) {
@@ -98,7 +97,7 @@
int err = -EINVAL;
void* base = (void*)hnd->base;
size_t size = hnd->size;
- sp<IMemAlloc> memalloc = getAllocator(hnd->flags) ;
+ IMemAlloc* memalloc = getAllocator(hnd->flags) ;
if(memalloc != NULL)
err = memalloc->unmap_buffer(base, size, hnd->offset);
if (err) {
@@ -284,7 +283,7 @@
if (hnd->flags & private_handle_t::PRIV_FLAGS_NEEDS_FLUSH) {
int err;
- sp<IMemAlloc> memalloc = getAllocator(hnd->flags) ;
+ IMemAlloc* memalloc = getAllocator(hnd->flags) ;
err = memalloc->clean_buffer((void*)hnd->base,
hnd->size, hnd->offset, hnd->fd);
ALOGE_IF(err < 0, "cannot flush handle %p (offs=%x len=%x, flags = 0x%x) err=%s\n",
@@ -328,25 +327,7 @@
private_handle_t::sNumFds, private_handle_t::sNumInts);
hnd->magic = private_handle_t::sMagic;
hnd->fd = fd;
- unsigned int contigFlags = GRALLOC_USAGE_PRIVATE_ADSP_HEAP |
- GRALLOC_USAGE_PRIVATE_UI_CONTIG_HEAP |
- GRALLOC_USAGE_PRIVATE_SMI_HEAP;
-
- if (memoryFlags & contigFlags) {
- // check if the buffer is a pmem buffer
- pmem_region region;
- if (ioctl(fd, PMEM_GET_SIZE, ®ion) < 0)
- hnd->flags = private_handle_t::PRIV_FLAGS_USES_ION;
- else
- hnd->flags = private_handle_t::PRIV_FLAGS_USES_PMEM |
- private_handle_t::PRIV_FLAGS_DO_NOT_FLUSH;
- } else {
- if (memoryFlags & GRALLOC_USAGE_PRIVATE_ION)
- hnd->flags = private_handle_t::PRIV_FLAGS_USES_ION;
- else
- hnd->flags = private_handle_t::PRIV_FLAGS_USES_ASHMEM;
- }
-
+ hnd->flags = private_handle_t::PRIV_FLAGS_USES_ION;
hnd->size = size;
hnd->offset = offset;
hnd->base = intptr_t(base) + offset;