User:VladVukicevic/Gralloc

From MozillaWiki
Jump to: navigation, search

This is a brain dump of what happens on b2g when we allocate a new GraphicBuffer from the child side.

Child:

entry point: PLayersTransactionChild->SendPGrallocBufferConstructor

  - sends synchronous IPC to compositor

Over to b2g/compositor:

on compositor side, this comes in as: PLayerTransactionParent::AllocPGrallocBuffer

 - implemented in LayersTransactionParent.cpp
 - calls GrallocBufferActor::Create(...)
 - ::Create(...) actually creates the GraphicBuffer* and a GrallocBufferActor*
 - (The GrallocBufferActor contains a sp<GraphicBuffer> that references the newly-created GraphicBuffer*)
 - ::Create returns the GrallocBufferActor as a PGrallocBufferParent*, and the GraphicBuffer* as a MaybeMagicGrallocBufferHandle
 - the GrallocBufferActor/PGrallocBufferParent* is added to the LayerTransactionParent's managed list
 - the MaybeMagicGrallocBufferHandle is serialized for reply (sending back the fd that represents the GraphicBuffer) -- using code in ShadowLayerUtilsGralloc ParamTraits<MGBH>::Write

Back to child:

 - after the sync IPC call, the child receives the MaybeMagicGrallocBufferHandle, using ShadowLayerUtilsGralloc.cpp's ParamTraits<MGBH>::Read
 - allocates empty GrallocBufferActor() to use a PGrallocBufferChild
 - the child then sets the previously created GrallocBufferActor/PGrallocBufferChild's mGraphicBuffer to the newly-received sp<GraphicBuffer>
 - the GrallocBufferActor/PGrallocBufferChild is added to the LayerTransactionChild's managed list
 - a SurfaceDescriptorGralloc is created using the PGrallocBufferChild, and returned to the caller