diff options
author | Mathias Agopian <mathias@google.com> | 2010-12-08 16:40:01 -0800 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2010-12-08 16:48:28 -0800 |
commit | 19f9eda28a1bd182a5f7bba9dde015b29ab04d25 (patch) | |
tree | 6f50da25906fa72cc7610c253ef1a441e4de1cdc /libs | |
parent | e5c16ab5a8b4e12aff03a88d3c3c6eac03b609c3 (diff) | |
download | frameworks_base-19f9eda28a1bd182a5f7bba9dde015b29ab04d25.zip frameworks_base-19f9eda28a1bd182a5f7bba9dde015b29ab04d25.tar.gz frameworks_base-19f9eda28a1bd182a5f7bba9dde015b29ab04d25.tar.bz2 |
fix [3259708] Graphic Buffer Mapper does not support YV12
remove a bunch of a code that was there only to support broken gralloc implementations
Change-Id: I3c1a9172224cbcc283601abfbbd695a20815451f
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ui/GraphicBufferAllocator.cpp | 15 | ||||
-rw-r--r-- | libs/ui/GraphicBufferMapper.cpp | 163 |
2 files changed, 17 insertions, 161 deletions
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp index 610e2c5..ce84683 100644 --- a/libs/ui/GraphicBufferAllocator.cpp +++ b/libs/ui/GraphicBufferAllocator.cpp @@ -24,8 +24,6 @@ #include <ui/GraphicBufferAllocator.h> -#include <private/ui/sw_gralloc_handle.h> - namespace android { // --------------------------------------------------------------------------- @@ -95,11 +93,7 @@ status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat forma // we have a h/w allocator and h/w buffer is requested status_t err; - if (usage & GRALLOC_USAGE_HW_MASK) { - err = mAllocDev->alloc(mAllocDev, w, h, format, usage, handle, stride); - } else { - err = sw_gralloc_handle_t::alloc(w, h, format, usage, handle, stride); - } + err = mAllocDev->alloc(mAllocDev, w, h, format, usage, handle, stride); LOGW_IF(err, "alloc(%u, %u, %d, %08x, ...) failed %d (%s)", w, h, format, usage, err, strerror(-err)); @@ -123,11 +117,8 @@ status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat forma status_t GraphicBufferAllocator::free(buffer_handle_t handle) { status_t err; - if (sw_gralloc_handle_t::validate(handle) < 0) { - err = mAllocDev->free(mAllocDev, handle); - } else { - err = sw_gralloc_handle_t::free((sw_gralloc_handle_t*)handle); - } + + err = mAllocDev->free(mAllocDev, handle); LOGW_IF(err, "free(...) failed %d (%s)", err, strerror(-err)); if (err == NO_ERROR) { diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp index ce2acd0..07c0674 100644 --- a/libs/ui/GraphicBufferMapper.cpp +++ b/libs/ui/GraphicBufferMapper.cpp @@ -17,15 +17,7 @@ #define LOG_TAG "GraphicBufferMapper" #include <stdint.h> -#ifdef HAVE_ANDROID_OS // just want PAGE_SIZE define -# include <asm/page.h> -#else -# include <sys/user.h> -#endif #include <errno.h> -#include <sys/mman.h> - -#include <cutils/ashmem.h> #include <utils/Errors.h> #include <utils/Log.h> @@ -35,8 +27,6 @@ #include <hardware/gralloc.h> -#include <private/ui/sw_gralloc_handle.h> - namespace android { // --------------------------------------------------------------------------- @@ -57,11 +47,9 @@ GraphicBufferMapper::GraphicBufferMapper() status_t GraphicBufferMapper::registerBuffer(buffer_handle_t handle) { status_t err; - if (sw_gralloc_handle_t::validate(handle) < 0) { - err = mAllocMod->registerBuffer(mAllocMod, handle); - } else { - err = sw_gralloc_handle_t::registerBuffer((sw_gralloc_handle_t*)handle); - } + + err = mAllocMod->registerBuffer(mAllocMod, handle); + LOGW_IF(err, "registerBuffer(%p) failed %d (%s)", handle, err, strerror(-err)); return err; @@ -70,11 +58,9 @@ status_t GraphicBufferMapper::registerBuffer(buffer_handle_t handle) status_t GraphicBufferMapper::unregisterBuffer(buffer_handle_t handle) { status_t err; - if (sw_gralloc_handle_t::validate(handle) < 0) { - err = mAllocMod->unregisterBuffer(mAllocMod, handle); - } else { - err = sw_gralloc_handle_t::unregisterBuffer((sw_gralloc_handle_t*)handle); - } + + err = mAllocMod->unregisterBuffer(mAllocMod, handle); + LOGW_IF(err, "unregisterBuffer(%p) failed %d (%s)", handle, err, strerror(-err)); return err; @@ -84,15 +70,11 @@ status_t GraphicBufferMapper::lock(buffer_handle_t handle, int usage, const Rect& bounds, void** vaddr) { status_t err; - if (sw_gralloc_handle_t::validate(handle) < 0) { - err = mAllocMod->lock(mAllocMod, handle, usage, - bounds.left, bounds.top, bounds.width(), bounds.height(), - vaddr); - } else { - err = sw_gralloc_handle_t::lock((sw_gralloc_handle_t*)handle, usage, - bounds.left, bounds.top, bounds.width(), bounds.height(), - vaddr); - } + + err = mAllocMod->lock(mAllocMod, handle, usage, + bounds.left, bounds.top, bounds.width(), bounds.height(), + vaddr); + LOGW_IF(err, "lock(...) failed %d (%s)", err, strerror(-err)); return err; } @@ -100,128 +82,11 @@ status_t GraphicBufferMapper::lock(buffer_handle_t handle, status_t GraphicBufferMapper::unlock(buffer_handle_t handle) { status_t err; - if (sw_gralloc_handle_t::validate(handle) < 0) { - err = mAllocMod->unlock(mAllocMod, handle); - } else { - err = sw_gralloc_handle_t::unlock((sw_gralloc_handle_t*)handle); - } - LOGW_IF(err, "unlock(...) failed %d (%s)", err, strerror(-err)); - return err; -} - -// --------------------------------------------------------------------------- - -status_t sw_gralloc_handle_t::alloc(uint32_t w, uint32_t h, int format, - int usage, buffer_handle_t* pHandle, int32_t* pStride) -{ - int align = 4; - int bpp = 0; - switch (format) { - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_BGRA_8888: - bpp = 4; - break; - case HAL_PIXEL_FORMAT_RGB_888: - bpp = 3; - break; - case HAL_PIXEL_FORMAT_RGB_565: - case HAL_PIXEL_FORMAT_RGBA_5551: - case HAL_PIXEL_FORMAT_RGBA_4444: - bpp = 2; - break; - default: - return -EINVAL; - } - size_t bpr = (w*bpp + (align-1)) & ~(align-1); - size_t size = bpr * h; - size_t stride = bpr / bpp; - size = (size + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1); - - int fd = ashmem_create_region("sw-gralloc-buffer", size); - if (fd < 0) { - LOGE("ashmem_create_region(size=%d) failed (%s)", - size, strerror(-errno)); - return -errno; - } - - int prot = PROT_READ; - if (usage & GRALLOC_USAGE_SW_WRITE_MASK) - prot |= PROT_WRITE; - - if (ashmem_set_prot_region(fd, prot) < 0) { - LOGE("ashmem_set_prot_region(fd=%d, prot=%x) failed (%s)", - fd, prot, strerror(-errno)); - close(fd); - return -errno; - } - void* base = mmap(0, size, prot, MAP_SHARED, fd, 0); - if (base == MAP_FAILED) { - LOGE("alloc mmap(fd=%d, size=%d, prot=%x) failed (%s)", - fd, size, prot, strerror(-errno)); - close(fd); - return -errno; - } - - sw_gralloc_handle_t* hnd = new sw_gralloc_handle_t(); - hnd->fd = fd; - hnd->size = size; - hnd->base = intptr_t(base); - hnd->prot = prot; - *pStride = stride; - *pHandle = hnd; - - return NO_ERROR; -} - -status_t sw_gralloc_handle_t::free(sw_gralloc_handle_t* hnd) -{ - if (hnd->base) { - munmap((void*)hnd->base, hnd->size); - } - if (hnd->fd >= 0) { - close(hnd->fd); - } - delete hnd; - return NO_ERROR; -} - -status_t sw_gralloc_handle_t::registerBuffer(sw_gralloc_handle_t* hnd) -{ - if (hnd->pid != getpid()) { - void* base = mmap(0, hnd->size, hnd->prot, MAP_SHARED, hnd->fd, 0); - if (base == MAP_FAILED) { - LOGE("registerBuffer mmap(fd=%d, size=%d, prot=%x) failed (%s)", - hnd->fd, hnd->size, hnd->prot, strerror(-errno)); - return -errno; - } - hnd->base = intptr_t(base); - } - return NO_ERROR; -} - -status_t sw_gralloc_handle_t::unregisterBuffer(sw_gralloc_handle_t* hnd) -{ - if (hnd->pid != getpid()) { - if (hnd->base) { - munmap((void*)hnd->base, hnd->size); - } - hnd->base = 0; - } - return NO_ERROR; -} + err = mAllocMod->unlock(mAllocMod, handle); -status_t sw_gralloc_handle_t::lock(sw_gralloc_handle_t* hnd, int usage, - int l, int t, int w, int h, void** vaddr) -{ - *vaddr = (void*)hnd->base; - return NO_ERROR; -} - -status_t sw_gralloc_handle_t::unlock(sw_gralloc_handle_t* hnd) -{ - return NO_ERROR; + LOGW_IF(err, "unlock(...) failed %d (%s)", err, strerror(-err)); + return err; } // --------------------------------------------------------------------------- |