From f7acf162f8d682c6ebc9af41ca76795b79509193 Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Wed, 12 Jan 2011 18:30:40 -0800 Subject: Fix remote GraphicBuffer allocation in SurfaceFlinger. This change fixes a horrible hack that I did to allow application processes to create GraphicBuffer objects by making a binder call to SurfaceFlinger. This change introduces a new binder interface specifically for doing this, and does it in such a way that SurfaceFlinger will maintain a reference to the buffers until the app is done with them. Change-Id: Icb240397c6c206d7f69124c1497a829f051cb49b --- include/gui/SurfaceTexture.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/gui') diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h index 09cf2a2..002e48b 100644 --- a/include/gui/SurfaceTexture.h +++ b/include/gui/SurfaceTexture.h @@ -26,12 +26,15 @@ #include #include +#include #define ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID "mSurfaceTexture" namespace android { // ---------------------------------------------------------------------------- +class IGraphicBufferAlloc; + class SurfaceTexture : public BnSurfaceTexture { public: enum { MIN_BUFFER_SLOTS = 3 }; @@ -140,6 +143,12 @@ private: // reset mCurrentTexture to INVALID_BUFFER_SLOT. int mCurrentTexture; + // mCurrentTextureBuf is the graphic buffer of the current texture. It's + // possible that this buffer is not associated with any buffer slot, so we + // must track it separately in order to properly use + // IGraphicBufferAlloc::freeAllGraphicBuffersExcept. + sp mCurrentTextureBuf; + // mCurrentCrop is the crop rectangle that applies to the current texture. // It gets set to mLastQueuedCrop each time updateTexImage is called. Rect mCurrentCrop; @@ -176,6 +185,16 @@ private: // changed with a call to setTexName. const GLuint mTexName; + // mGraphicBufferAlloc is the connection to SurfaceFlinger that is used to + // allocate new GraphicBuffer objects. + sp mGraphicBufferAlloc; + + // mAllocdBuffers is mirror of the list of buffers that SurfaceFlinger is + // referencing. This is kept so that gralloc implementations do not need to + // properly handle the case where SurfaceFlinger no longer holds a reference + // to a buffer, but other processes do. + Vector > mAllocdBuffers; + // mMutex is the mutex used to prevent concurrent access to the member // variables of SurfaceTexture objects. It must be locked whenever the // member variables are accessed. -- cgit v1.1