better fix for gralloc on sim
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 @@
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 @@
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<private_module_t*>(
dev->common.module);
@@ -290,9 +288,18 @@
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 @@
int index = (hnd->base - m->framebuffer->base) / bufferSize;
m->bufferMask &= ~(1<<index);
}
+#if HAVE_ANDROID_OS
else if (hnd->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 @@
sAllocator.deallocate(hnd->offset);
}
}
-#endif // HAVE_ANDROID_OS
}
+#endif // HAVE_ANDROID_OS
gralloc_module_t* m = reinterpret_cast<gralloc_module_t*>(
dev->common.module);