summaryrefslogtreecommitdiff
path: root/libs/surfaceflinger/LayerBitmap.cpp
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2009-07-02 17:33:40 -0700
committer Mathias Agopian <mathias@google.com> 2009-07-02 18:45:29 -0700
commit759fdb2ef735422d6b8c65e168fa9d1c24562a86 (patch)
tree043f7f5a9288a37b0e888ebb2d537930c154a149 /libs/surfaceflinger/LayerBitmap.cpp
parent84d1f7a09827fe195dd08b647b8c5092d03516f7 (diff)
free gralloc buffers as soon as possible (when a surface is not visible any longer), client who have the buffers still mapped won't crash, btu may see garbage data
Diffstat (limited to 'libs/surfaceflinger/LayerBitmap.cpp')
-rw-r--r--libs/surfaceflinger/LayerBitmap.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/libs/surfaceflinger/LayerBitmap.cpp b/libs/surfaceflinger/LayerBitmap.cpp
index a368ca93aa..e0984fe48c 100644
--- a/libs/surfaceflinger/LayerBitmap.cpp
+++ b/libs/surfaceflinger/LayerBitmap.cpp
@@ -130,13 +130,10 @@ status_t Buffer::lock(GGLSurface* sur, uint32_t usage)
return res;
}
-
-
// ===========================================================================
// LayerBitmap
// ===========================================================================
-
LayerBitmap::LayerBitmap()
: mInfo(0), mWidth(0), mHeight(0)
{
@@ -184,7 +181,7 @@ sp<Buffer> LayerBitmap::allocate()
sp<Buffer> buffer(mBuffer);
const uint32_t w = mWidth;
const uint32_t h = mHeight;
- if (w != buffer->getWidth() || h != buffer->getHeight()) {
+ if (buffer!=0 && (w != buffer->getWidth() || h != buffer->getHeight())) {
surface_info_t* info = mInfo;
buffer = new Buffer(w, h, mFormat, mFlags);
status_t err = buffer->initCheck();
@@ -200,6 +197,15 @@ sp<Buffer> LayerBitmap::allocate()
return buffer;
}
+status_t LayerBitmap::free()
+{
+ mBuffer.clear();
+ mWidth = 0;
+ mHeight = 0;
+ return NO_ERROR;
+}
+
+
// ---------------------------------------------------------------------------
}; // namespace android