GFX-3D: Hold the BufferReference of GraphicBuffer in BpGraphicBufferAlloc

BZ: 86716

In WIDI usage, BufferQueue is outside of SurfaceFlinger. If BufferQueue
allocates a GraphicBuffer from SurfaceFlinger, BnGraphicBufferAlloc will
create a BufferReference to hold a last ref to the GraphicBuffer, but
when the transction finishes, the parcel used in the transaction will be
destroyed and the BufferReference will be freed which caused the last
ref of the GraphicBuffer in SurfaceFlinger side goes away and then
destroy the GraphicBuffer. This leads to the buffer state between
BufferQueue and SurfaceFlinger out of sync, because in BufferQueue side,
the GraphicBuffer was just created and will be used later.

This patch add a sp<IBinder> of BufferReference for each GraphicBuffer
when created in BpGraphicBufferAlloc, this will make the BufferReference
in BnGraphicBufferAlloc stay still when the transaction finishes, which
also leads the GraphicBuffer be held. When BufferQueue free a
GraphicBuffer, the sp<IBinder> BufferReference will be set to 0 which
will free BufferReference and then GraphicBuffer in
BnGraphicBufferAlloc/SurfaceFlinger side, and will not lead to memory
leak.

In normal use case, since the BufferQueue and SurfaceFlinger are in the
same process, there will no Bp side exist. Thus, this patch will not
affect the normal use case.

https://code.google.com/p/android/issues/detail?id=54597

Change-Id: I812bbf046fd592a6dca1e4d157b459c9654835fb
Signed-off-by: Lingyun Zhu <lingyun.zhu@intel.com>
Revert "GFX-3D: Hold the BufferReference of GraphicBuffer in BpGraphicBufferAlloc"

This reverts commit 7a3802e7699164eb7760f354803ab59afbf42eab.

Change-Id: Ie29d5404c23ca8610f5fa3e5916fe1a124956ba0
Merge branch 'cm-11.0' of https://github.com/CyanogenMod/android_frameworks_native into temp