Understanding Android Graphics Internals – Graphic Buffer Handling Interfaces

In this post, we touch IGraphicBufferProducer, IGraphicBufferAlloc.

  • IGraphicBufferProducer

Defined in include/gui/IGraphicBufferProducer.h, it was formerly known as ISurfaceTexture. It is the Interface underpinning the queueBuffer(), dequeueBuffer, requestBuffer() and cancelBuffer() operations in Surface class.

An IGraphicBufferProducer is instantiated in ISurfaceComposerClient::createSurface();  BnGraphicBufferProducer implementor is BufferQueue (declared in frameworks/native/include/gui/BufferQueue.h); In SurfaceFlinger, its subclass variant SurfaceTextureLayer with reference to SurfaceFlinger is actually used,  and each instance of SurfaceTextureLayer corresponds to a Layer instance.

  • IGraphicBufferAlloc

Defined in framework/native/include/gui/IGraphicBufferAlloc.h, IGraphicBufferAlloc’s use is coupled with IGraphicBufferProducer to realize dequeueBuffer() operation.  ISurfaceComposer::createGraphicBufferAlloc() creates the interface.

In the SurfaceFlinger, the BnGraphicBufferAlloc implementor is GraphicBufferAlloc, declared in framework/native/include/gui/GraphicBufferAlloc.h.

Leave a comment