May 2017
Beginner to intermediate
470 pages
10h 49m
English
When the usage bit is not set to GRALLOC_USAGE_HW_FB or the system cannot support double buffering, we have to allocate the buffer from system memory using gralloc_alloc_buffer. Let's look at the implementation of gralloc_alloc_buffer:
static int gralloc_alloc_buffer(alloc_device_t* dev, size_t size, int /*usage*/, buffer_handle_t* pHandle) { int err = 0; int fd = -1; size = roundUpToPageSize(size); fd = ashmem_create_region("gralloc-buffer", size); if (fd < 0) { ALOGE("couldn't create ashmem (%s)", strerror(-errno)); err = -errno; } if (err == 0) { private_handle_t* hnd = new private_handle_t(fd, size, 0); gralloc_module_t* module = reinterpret_cast<gralloc_module_t*>( dev->common.module); err ...Read now
Unlock full access