From 759fdb2ef735422d6b8c65e168fa9d1c24562a86 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 2 Jul 2009 17:33:40 -0700 Subject: 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 --- libs/surfaceflinger/LayerBitmap.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'libs/surfaceflinger/LayerBitmap.cpp') 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 LayerBitmap::allocate() sp 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 LayerBitmap::allocate() return buffer; } +status_t LayerBitmap::free() +{ + mBuffer.clear(); + mWidth = 0; + mHeight = 0; + return NO_ERROR; +} + + // --------------------------------------------------------------------------- }; // namespace android -- cgit v1.2.3-59-g8ed1b