diff options
Diffstat (limited to 'services/surfaceflinger')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 24 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 4c1cb22..9074c29 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2706,7 +2706,13 @@ status_t Client::destroySurface(SurfaceID sid) { // --------------------------------------------------------------------------- +#ifdef QCOM_HARDWARE +GraphicBufferAlloc::GraphicBufferAlloc() { + mFreedIndex = -1; +} +#else GraphicBufferAlloc::GraphicBufferAlloc() {} +#endif GraphicBufferAlloc::~GraphicBufferAlloc() {} @@ -2726,7 +2732,12 @@ sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t w, uint32_t h } #ifdef QCOM_HARDWARE Mutex::Autolock _l(mLock); - mBuffers.add(graphicBuffer); + if (-1 != mFreedIndex) { + mBuffers.insertAt(graphicBuffer, mFreedIndex); + mFreedIndex = -1; + } else { + mBuffers.add(graphicBuffer); + } #endif return graphicBuffer; } @@ -2741,6 +2752,17 @@ void GraphicBufferAlloc::freeAllGraphicBuffersExcept(int bufIdx) { } else { mBuffers.clear(); } + mFreedIndex = -1; +} + +void GraphicBufferAlloc::freeGraphicBufferAtIndex(int bufIdx) { + Mutex::Autolock _l(mLock); + if (0 <= bufIdx && bufIdx < mBuffers.size()) { + mBuffers.removeItemsAt(bufIdx); + mFreedIndex = bufIdx; + } else { + mFreedIndex = -1; + } } #endif // --------------------------------------------------------------------------- diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 7acb66e..66cf291 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -99,9 +99,11 @@ public: PixelFormat format, uint32_t usage, status_t* error); #ifdef QCOM_HARDWARE virtual void freeAllGraphicBuffersExcept(int bufIdx); + virtual void freeGraphicBufferAtIndex(int bufIdx); private: Vector<sp<GraphicBuffer> > mBuffers; Mutex mLock; + int mFreedIndex; #endif }; |