From f1b38247d4d9c2ddc7315a72b609a95e0ed8050f Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 20 Aug 2010 15:59:53 -0700 Subject: [PATCH] don't try to lock a buffer that wasn't allocated with SW usage bits Change-Id: Iabbcec1bfa30dc47d45ece699dd178653f1b675b --- services/surfaceflinger/Layer.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 6f3c66d74..03d7a0232 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -196,12 +196,16 @@ void Layer::reloadTexture(const Region& dirty) } else { slowpath: GGLSurface t; - status_t res = buffer->lock(&t, GRALLOC_USAGE_SW_READ_OFTEN); - LOGE_IF(res, "error %d (%s) locking buffer %p", - res, strerror(res), buffer.get()); - if (res == NO_ERROR) { - mBufferManager.loadTexture(dirty, t); - buffer->unlock(); + if (buffer->usage & GRALLOC_USAGE_SW_READ_MASK) { + status_t res = buffer->lock(&t, GRALLOC_USAGE_SW_READ_OFTEN); + LOGE_IF(res, "error %d (%s) locking buffer %p", + res, strerror(res), buffer.get()); + if (res == NO_ERROR) { + mBufferManager.loadTexture(dirty, t); + buffer->unlock(); + } + } else { + // we can't do anything } } }