From 5f05f99aaedaba18c426fac287bcb18d56dbe881 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 8 Apr 2011 19:10:43 -0700 Subject: 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 --- libs/gui/SurfaceTexture.cpp | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'libs/gui/SurfaceTexture.cpp') diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp index f4e2a676160f..e2346f060ecf 100644 --- a/libs/gui/SurfaceTexture.cpp +++ b/libs/gui/SurfaceTexture.cpp @@ -172,7 +172,6 @@ sp SurfaceTexture::requestBuffer(int buf, mSlots[buf].mEglImage = EGL_NO_IMAGE_KHR; mSlots[buf].mEglDisplay = EGL_NO_DISPLAY; } - mAllocdBuffers.add(graphicBuffer); } return graphicBuffer; } @@ -425,19 +424,6 @@ void SurfaceTexture::freeAllBuffers() { mSlots[i].mEglDisplay = EGL_NO_DISPLAY; } } - - int exceptBuf = -1; - for (size_t i = 0; i < mAllocdBuffers.size(); i++) { - if (mAllocdBuffers[i] == mCurrentTextureBuf) { - exceptBuf = i; - break; - } - } - mAllocdBuffers.clear(); - if (exceptBuf >= 0) { - mAllocdBuffers.add(mCurrentTextureBuf); - } - mGraphicBufferAlloc->freeAllGraphicBuffersExcept(exceptBuf); } EGLImageKHR SurfaceTexture::createImage(EGLDisplay dpy, -- cgit v1.2.3-59-g8ed1b