From bfc010a750eb091017e370640d5c1644d671c7e4 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Tue, 7 Jul 2009 12:43:35 -0700 Subject: [PATCH] better fix for gralloc on sim --- modules/gralloc/gralloc.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/gralloc/gralloc.cpp b/modules/gralloc/gralloc.cpp index 44e42d8..257bb4a 100644 --- a/modules/gralloc/gralloc.cpp +++ b/modules/gralloc/gralloc.cpp @@ -222,6 +222,8 @@ static int gralloc_alloc_buffer(alloc_device_t* dev, size = roundUpToPageSize(size); +#if HAVE_ANDROID_OS // should probably define HAVE_PMEM somewhere + if (usage & GRALLOC_USAGE_HW_TEXTURE) { // enable pmem in that case, so our software GL can fallback to // the copybit module. @@ -240,10 +242,6 @@ try_ashmem: err = -errno; } } else { -#ifndef HAVE_ANDROID_OS // should probably define HAVE_PMEM somewhere - LOGE("pmem not available on this target"); - err = -1; -#else private_module_t* m = reinterpret_cast( dev->common.module); @@ -290,9 +288,18 @@ try_ashmem: LOGE("couldn't open pmem (%s)", strerror(-errno)); } } -#endif // HAVE_ANDROID_OS } +#else // HAVE_ANDROID_OS + + fd = ashmem_create_region("Buffer", size); + if (fd < 0) { + LOGE("couldn't create ashmem (%s)", strerror(-errno)); + err = -errno; + } + +#endif // HAVE_ANDROID_OS + if (err == 0) { private_handle_t* hnd = new private_handle_t(fd, size, flags); hnd->offset = offset; @@ -385,12 +392,9 @@ static int gralloc_free(alloc_device_t* dev, int index = (hnd->base - m->framebuffer->base) / bufferSize; m->bufferMask &= ~(1<flags & private_handle_t::PRIV_FLAGS_USES_PMEM) { -#ifndef HAVE_ANDROID_OS - LOGE("pmem not available on this target"); - return -EINVAL; -#else if (hnd->fd >= 0) { struct pmem_region sub = { hnd->offset, hnd->size }; int err = ioctl(hnd->fd, PMEM_UNMAP, &sub); @@ -404,8 +408,8 @@ static int gralloc_free(alloc_device_t* dev, sAllocator.deallocate(hnd->offset); } } -#endif // HAVE_ANDROID_OS } +#endif // HAVE_ANDROID_OS gralloc_module_t* m = reinterpret_cast( dev->common.module); -- 2.11.0