diff options
author | Christopher N. Hesse <raymanfx@gmail.com> | 2016-06-27 15:47:28 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2016-08-16 09:03:28 +0200 |
commit | 06f17ef12e49baf3f136f35e257488623d329221 (patch) | |
tree | a22a8331723200d7c2a4482336c8a564803ad041 /gralloc | |
parent | ba8e5f2537da560e1164216c7f1cb6a2b6d38488 (diff) | |
download | android_hardware_samsung_slsi_exynos5430-06f17ef12e49baf3f136f35e257488623d329221.tar.gz android_hardware_samsung_slsi_exynos5430-06f17ef12e49baf3f136f35e257488623d329221.tar.xz android_hardware_samsung_slsi_exynos5430-06f17ef12e49baf3f136f35e257488623d329221.zip |
gralloc: Check for page flip capabilities at runtime
Change-Id: I68d1721158d1f322f72297cc69de7078226917bc
Diffstat (limited to 'gralloc')
-rw-r--r-- | gralloc/framebuffer.cpp | 78 |
1 files changed, 46 insertions, 32 deletions
diff --git a/gralloc/framebuffer.cpp b/gralloc/framebuffer.cpp index 1fc133e..dcdf335 100644 --- a/gralloc/framebuffer.cpp +++ b/gralloc/framebuffer.cpp @@ -52,7 +52,11 @@ inline size_t roundUpToPageSize(size_t x) { // numbers of buffers for page flipping #define NUM_BUFFERS 2 -#define HWC_EXIST 1 + +// Can we use the HWC for page flipping? +// Most modern devices should be able to use this and you will face +// performance degradation without it. +static bool page_flip_allowed = true; struct hwc_callback_entry { @@ -68,6 +72,28 @@ struct fb_context_t { /*****************************************************************************/ +/* + * Copy buffer to the front if page flip is not available/allowed because of + * size constraints. + */ +inline void memcpy_buffer(private_module_t* m, buffer_handle_t &buffer) { + void* fb_vaddr; + void* buffer_vaddr; + + m->base.lock(&m->base, m->framebuffer, GRALLOC_USAGE_SW_WRITE_RARELY, + 0, 0, m->info.xres, m->info.yres, &fb_vaddr); + + m->base.lock(&m->base, buffer, GRALLOC_USAGE_SW_READ_RARELY, + 0, 0, m->info.xres, m->info.yres, &buffer_vaddr); + + // Do a direct copy. + // TODO: Implement a copybit HAL for this + memcpy(fb_vaddr, buffer_vaddr, m->finfo.line_length * m->info.yres); + m->base.unlock(&m->base, buffer); + m->base.unlock(&m->base, m->framebuffer); +} + +/*****************************************************************************/ /* * Keep track of the vsync state to avoid making excessive ioctl calls. @@ -107,39 +133,27 @@ static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer) private_handle_t const* hnd = reinterpret_cast<private_handle_t const*>(buffer); private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module); -#if HWC_EXIST - hwc_callback_queue_t *queue = reinterpret_cast<hwc_callback_queue_t *>(m->queue); - pthread_mutex_lock(&m->queue_lock); - if(queue->isEmpty()) - pthread_mutex_unlock(&m->queue_lock); - else { - private_handle_t *hnd = private_handle_t::dynamicCast(buffer); - struct hwc_callback_entry entry = queue->top(); - queue->pop(); - pthread_mutex_unlock(&m->queue_lock); - entry.callback(entry.data, hnd); - } -#else - // If we can't do the page_flip, just copy the buffer to the front - // FIXME: use copybit HAL instead of memcpy - void* fb_vaddr; - void* buffer_vaddr; - - m->base.lock(&m->base, m->framebuffer, - GRALLOC_USAGE_SW_WRITE_RARELY, - 0, 0, m->info.xres, m->info.yres, - &fb_vaddr); - m->base.lock(&m->base, buffer, - GRALLOC_USAGE_SW_READ_RARELY, - 0, 0, m->info.xres, m->info.yres, - &buffer_vaddr); - - memcpy(fb_vaddr, buffer_vaddr, m->finfo.line_length * m->info.yres); + ALOGW("%s: page flipping %s", page_flip_allowed ? " allowed" : " not allowed"); + + if (page_flip_allowed) { + hwc_callback_queue_t *queue = reinterpret_cast<hwc_callback_queue_t *>(m->queue); + pthread_mutex_lock(&m->queue_lock); + if(queue->isEmpty()) + pthread_mutex_unlock(&m->queue_lock); + else { + private_handle_t *hnd = private_handle_t::dynamicCast(buffer); + struct hwc_callback_entry entry = queue->top(); + queue->pop(); + pthread_mutex_unlock(&m->queue_lock); + entry.callback(entry.data, hnd); + } + } else { + // If we can't do the page_flip, just copy the buffer to the front + // FIXME: use copybit HAL instead of memcpy + memcpy_buffer(m, buffer); + } - m->base.unlock(&m->base, buffer); - m->base.unlock(&m->base, m->framebuffer); -#endif return 0; } |