summaryrefslogtreecommitdiffstats
path: root/libs/ui/GraphicBufferAllocator.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2009-10-05 18:19:57 -0700
committerMathias Agopian <mathias@google.com>2009-10-06 17:00:25 -0700
commit6f5f5a095a5a4d42fc656cf8c1e6d0f67594f88d (patch)
tree3e4391ac9de9fe573abe63c88aee3d234b75be32 /libs/ui/GraphicBufferAllocator.cpp
parent6950e428feaccc8164b989ef64e771a99948797a (diff)
downloadframeworks_base-6f5f5a095a5a4d42fc656cf8c1e6d0f67594f88d.zip
frameworks_base-6f5f5a095a5a4d42fc656cf8c1e6d0f67594f88d.tar.gz
frameworks_base-6f5f5a095a5a4d42fc656cf8c1e6d0f67594f88d.tar.bz2
fix [2168531] have software-only gralloc buffer side-step the HAL
Diffstat (limited to 'libs/ui/GraphicBufferAllocator.cpp')
-rw-r--r--libs/ui/GraphicBufferAllocator.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index 10b1051..57d5fc3 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -22,6 +22,7 @@
#include <ui/GraphicBufferAllocator.h>
+#include <private/ui/sw_gralloc_handle.h>
namespace android {
// ---------------------------------------------------------------------------
@@ -29,7 +30,8 @@ namespace android {
ANDROID_SINGLETON_STATIC_INSTANCE( GraphicBufferAllocator )
Mutex GraphicBufferAllocator::sLock;
-KeyedVector<buffer_handle_t, GraphicBufferAllocator::alloc_rec_t> GraphicBufferAllocator::sAllocList;
+KeyedVector<buffer_handle_t,
+ GraphicBufferAllocator::alloc_rec_t> GraphicBufferAllocator::sAllocList;
GraphicBufferAllocator::GraphicBufferAllocator()
: mAllocDev(0)
@@ -83,8 +85,13 @@ status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat forma
h = clamp(h);
// we have a h/w allocator and h/w buffer is requested
- status_t err = mAllocDev->alloc(mAllocDev,
- w, h, format, usage, handle, stride);
+ 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);
+ }
LOGW_IF(err, "alloc(%u, %u, %d, %08x, ...) failed %d (%s)",
w, h, format, usage, err, strerror(-err));
@@ -113,9 +120,14 @@ status_t GraphicBufferAllocator::free(buffer_handle_t handle)
{
Mutex::Autolock _l(mLock);
- status_t err = mAllocDev->free(mAllocDev, 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);
+ }
+
LOGW_IF(err, "free(...) failed %d (%s)", err, strerror(-err));
-
if (err == NO_ERROR) {
Mutex::Autolock _l(sLock);
KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList);