libgui: Plumb attach/detach through CpuConsumer

Adds CpuConsumer::{detachNextBuffer,attachAndReleaseBuffer}, which
can be used to more carefully manage the ownership of GraphicBuffers.

Bug: 19628705
Change-Id: Ia7a7e30da6d81eb2367241998f14988db0afc3bf
diff --git a/libs/gui/BufferQueueConsumer.cpp b/libs/gui/BufferQueueConsumer.cpp
index 526c3b7..c7faeeb 100644
--- a/libs/gui/BufferQueueConsumer.cpp
+++ b/libs/gui/BufferQueueConsumer.cpp
@@ -247,12 +247,16 @@
     ATRACE_BUFFER_INDEX(*outSlot);
     BQ_LOGV("attachBuffer(C): returning slot %d", *outSlot);
 
+    // If these are modified, they also need to be modified in
+    // CpuConsumer::attachAndReleaseBuffer
     mSlots[*outSlot].mGraphicBuffer = buffer;
+    mSlots[*outSlot].mFence = Fence::NO_FENCE;
+    mSlots[*outSlot].mFrameNumber = 0;
+
+    // Changes to these do not need to be propagated to CpuConsumer
     mSlots[*outSlot].mBufferState = BufferSlot::ACQUIRED;
     mSlots[*outSlot].mAttachedByConsumer = true;
     mSlots[*outSlot].mNeedsCleanupOnRelease = false;
-    mSlots[*outSlot].mFence = Fence::NO_FENCE;
-    mSlots[*outSlot].mFrameNumber = 0;
 
     // mAcquireCalled tells BufferQueue that it doesn't need to send a valid
     // GraphicBuffer pointer on the next acquireBuffer call, which decreases