diff options
author | Mathias Agopian <mathias@google.com> | 2011-04-08 19:10:43 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2011-04-08 19:28:04 -0700 |
commit | 4cb18881b55b82a24873ccd8e298bc2d5a9c17e5 (patch) | |
tree | 8708afe05c6c0c485f81aa6aaef2aabd425982ad /services/surfaceflinger | |
parent | 626d865d418cf3fcea985429ef85cf83f8cd978e (diff) | |
download | frameworks_native-4cb18881b55b82a24873ccd8e298bc2d5a9c17e5.zip frameworks_native-4cb18881b55b82a24873ccd8e298bc2d5a9c17e5.tar.gz frameworks_native-4cb18881b55b82a24873ccd8e298bc2d5a9c17e5.tar.bz2 |
Fix a GraphicBuffer leak in SurfaceTexture
This leak was intentional, it was there to deal with the fact that
some gralloc implementations don't track buffer handles with
file-descriptors so buffers needed to stay alive until there were
registered, which is not guaranteed by binder transactions.
In this new implementation, we use a small BBinder holding a
reference to the buffer, which with tuck into the parcel. This forces
the reference to stay alive until the parcel is destroyed, which
is guaranteed (by construction) to happen after the buffer is
registered.
this allows the public facing API to not expose the previous hack.
Change-Id: I1dd6cd83679a2b7457ad628169e2851acc027143
Diffstat (limited to 'services/surfaceflinger')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 13 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 6 |
2 files changed, 0 insertions, 19 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index ea283c6..2f3a144 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2553,22 +2553,9 @@ sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t w, uint32_t h LOGE("createGraphicBuffer: unable to create GraphicBuffer"); return 0; } - Mutex::Autolock _l(mLock); - mBuffers.add(graphicBuffer); return graphicBuffer; } -void GraphicBufferAlloc::freeAllGraphicBuffersExcept(int bufIdx) { - Mutex::Autolock _l(mLock); - if (bufIdx >= 0 && size_t(bufIdx) < mBuffers.size()) { - sp<GraphicBuffer> b(mBuffers[bufIdx]); - mBuffers.clear(); - mBuffers.add(b); - } else { - mBuffers.clear(); - } -} - // --------------------------------------------------------------------------- GraphicPlane::GraphicPlane() diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 0964848..8d43157 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -125,14 +125,8 @@ class GraphicBufferAlloc : public BnGraphicBufferAlloc public: GraphicBufferAlloc(); virtual ~GraphicBufferAlloc(); - virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage); - virtual void freeAllGraphicBuffersExcept(int bufIdx); - -private: - Vector<sp<GraphicBuffer> > mBuffers; - Mutex mLock; }; // --------------------------------------------------------------------------- |