diff options
author | 2009-07-02 17:33:40 -0700 | |
---|---|---|
committer | 2009-07-02 18:45:29 -0700 | |
commit | 359140c171f67b9b29a1beae9743b49d0759414b (patch) | |
tree | ec5255d464b929e5396c3fb29cefd862f818e982 /libs/surfaceflinger/LayerBitmap.cpp | |
parent | dfe983bd7979ccb1602f29b8f9804c98411d9cd6 (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.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libs/surfaceflinger/LayerBitmap.cpp b/libs/surfaceflinger/LayerBitmap.cpp index a368ca93aaa6..e0984fe48c7c 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 |