• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_GUI_BUFFERQUEUE_H
18 #define ANDROID_GUI_BUFFERQUEUE_H
19 
20 #include <EGL/egl.h>
21 #include <EGL/eglext.h>
22 
23 #include <binder/IBinder.h>
24 
25 #include <gui/IConsumerListener.h>
26 #include <gui/IGraphicBufferAlloc.h>
27 #include <gui/IGraphicBufferProducer.h>
28 #include <gui/IGraphicBufferConsumer.h>
29 
30 #include <ui/Fence.h>
31 #include <ui/GraphicBuffer.h>
32 
33 #include <utils/String8.h>
34 #include <utils/Vector.h>
35 #include <utils/threads.h>
36 
37 namespace android {
38 // ----------------------------------------------------------------------------
39 
40 class BufferQueue : public BnGraphicBufferProducer,
41                     public BnGraphicBufferConsumer,
42                     private IBinder::DeathRecipient {
43 public:
44     enum { MIN_UNDEQUEUED_BUFFERS = 2 };
45     enum { NUM_BUFFER_SLOTS = 32 };
46     enum { NO_CONNECTED_API = 0 };
47     enum { INVALID_BUFFER_SLOT = -1 };
48     enum { STALE_BUFFER_SLOT = 1, NO_BUFFER_AVAILABLE, PRESENT_LATER };
49 
50     // When in async mode we reserve two slots in order to guarantee that the
51     // producer and consumer can run asynchronously.
52     enum { MAX_MAX_ACQUIRED_BUFFERS = NUM_BUFFER_SLOTS - 2 };
53 
54     // for backward source compatibility
55     typedef ::android::ConsumerListener ConsumerListener;
56 
57     // ProxyConsumerListener is a ConsumerListener implementation that keeps a weak
58     // reference to the actual consumer object.  It forwards all calls to that
59     // consumer object so long as it exists.
60     //
61     // This class exists to avoid having a circular reference between the
62     // BufferQueue object and the consumer object.  The reason this can't be a weak
63     // reference in the BufferQueue class is because we're planning to expose the
64     // consumer side of a BufferQueue as a binder interface, which doesn't support
65     // weak references.
66     class ProxyConsumerListener : public BnConsumerListener {
67     public:
68         ProxyConsumerListener(const wp<ConsumerListener>& consumerListener);
69         virtual ~ProxyConsumerListener();
70         virtual void onFrameAvailable();
71         virtual void onBuffersReleased();
72     private:
73         // mConsumerListener is a weak reference to the IConsumerListener.  This is
74         // the raison d'etre of ProxyConsumerListener.
75         wp<ConsumerListener> mConsumerListener;
76     };
77 
78 
79     // BufferQueue manages a pool of gralloc memory slots to be used by
80     // producers and consumers. allocator is used to allocate all the
81     // needed gralloc buffers.
82     BufferQueue(const sp<IGraphicBufferAlloc>& allocator = NULL);
83     virtual ~BufferQueue();
84 
85     /*
86      * IBinder::DeathRecipient interface
87      */
88 
89     virtual void binderDied(const wp<IBinder>& who);
90 
91     /*
92      * IGraphicBufferProducer interface
93      */
94 
95     // Query native window attributes.  The "what" values are enumerated in
96     // window.h (e.g. NATIVE_WINDOW_FORMAT).
97     virtual int query(int what, int* value);
98 
99     // setBufferCount updates the number of available buffer slots.  If this
100     // method succeeds, buffer slots will be both unallocated and owned by
101     // the BufferQueue object (i.e. they are not owned by the producer or
102     // consumer).
103     //
104     // This will fail if the producer has dequeued any buffers, or if
105     // bufferCount is invalid.  bufferCount must generally be a value
106     // between the minimum undequeued buffer count and NUM_BUFFER_SLOTS
107     // (inclusive).  It may also be set to zero (the default) to indicate
108     // that the producer does not wish to set a value.  The minimum value
109     // can be obtained by calling query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
110     // ...).
111     //
112     // This may only be called by the producer.  The consumer will be told
113     // to discard buffers through the onBuffersReleased callback.
114     virtual status_t setBufferCount(int bufferCount);
115 
116     // requestBuffer returns the GraphicBuffer for slot N.
117     //
118     // In normal operation, this is called the first time slot N is returned
119     // by dequeueBuffer.  It must be called again if dequeueBuffer returns
120     // flags indicating that previously-returned buffers are no longer valid.
121     virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
122 
123     // dequeueBuffer gets the next buffer slot index for the producer to use.
124     // If a buffer slot is available then that slot index is written to the
125     // location pointed to by the buf argument and a status of OK is returned.
126     // If no slot is available then a status of -EBUSY is returned and buf is
127     // unmodified.
128     //
129     // The fence parameter will be updated to hold the fence associated with
130     // the buffer. The contents of the buffer must not be overwritten until the
131     // fence signals. If the fence is Fence::NO_FENCE, the buffer may be
132     // written immediately.
133     //
134     // The width and height parameters must be no greater than the minimum of
135     // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv).
136     // An error due to invalid dimensions might not be reported until
137     // updateTexImage() is called.  If width and height are both zero, the
138     // default values specified by setDefaultBufferSize() are used instead.
139     //
140     // The pixel formats are enumerated in graphics.h, e.g.
141     // HAL_PIXEL_FORMAT_RGBA_8888.  If the format is 0, the default format
142     // will be used.
143     //
144     // The usage argument specifies gralloc buffer usage flags.  The values
145     // are enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER.  These
146     // will be merged with the usage flags specified by setConsumerUsageBits.
147     //
148     // The return value may be a negative error value or a non-negative
149     // collection of flags.  If the flags are set, the return values are
150     // valid, but additional actions must be performed.
151     //
152     // If IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION is set, the
153     // producer must discard cached GraphicBuffer references for the slot
154     // returned in buf.
155     // If IGraphicBufferProducer::RELEASE_ALL_BUFFERS is set, the producer
156     // must discard cached GraphicBuffer references for all slots.
157     //
158     // In both cases, the producer will need to call requestBuffer to get a
159     // GraphicBuffer handle for the returned slot.
160     virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, bool async,
161             uint32_t width, uint32_t height, uint32_t format, uint32_t usage);
162 
163     // queueBuffer returns a filled buffer to the BufferQueue.
164     //
165     // Additional data is provided in the QueueBufferInput struct.  Notably,
166     // a timestamp must be provided for the buffer. The timestamp is in
167     // nanoseconds, and must be monotonically increasing. Its other semantics
168     // (zero point, etc) are producer-specific and should be documented by the
169     // producer.
170     //
171     // The caller may provide a fence that signals when all rendering
172     // operations have completed.  Alternatively, NO_FENCE may be used,
173     // indicating that the buffer is ready immediately.
174     //
175     // Some values are returned in the output struct: the current settings
176     // for default width and height, the current transform hint, and the
177     // number of queued buffers.
178     virtual status_t queueBuffer(int buf,
179             const QueueBufferInput& input, QueueBufferOutput* output);
180 
181     // cancelBuffer returns a dequeued buffer to the BufferQueue, but doesn't
182     // queue it for use by the consumer.
183     //
184     // The buffer will not be overwritten until the fence signals.  The fence
185     // will usually be the one obtained from dequeueBuffer.
186     virtual void cancelBuffer(int buf, const sp<Fence>& fence);
187 
188     // connect attempts to connect a producer API to the BufferQueue.  This
189     // must be called before any other IGraphicBufferProducer methods are
190     // called except for getAllocator.  A consumer must already be connected.
191     //
192     // This method will fail if connect was previously called on the
193     // BufferQueue and no corresponding disconnect call was made (i.e. if
194     // it's still connected to a producer).
195     //
196     // APIs are enumerated in window.h (e.g. NATIVE_WINDOW_API_CPU).
197     virtual status_t connect(const sp<IBinder>& token,
198             int api, bool producerControlledByApp, QueueBufferOutput* output);
199 
200     // disconnect attempts to disconnect a producer API from the BufferQueue.
201     // Calling this method will cause any subsequent calls to other
202     // IGraphicBufferProducer methods to fail except for getAllocator and connect.
203     // Successfully calling connect after this will allow the other methods to
204     // succeed again.
205     //
206     // This method will fail if the the BufferQueue is not currently
207     // connected to the specified producer API.
208     virtual status_t disconnect(int api);
209 
210     /*
211      * IGraphicBufferConsumer interface
212      */
213 
214     // acquireBuffer attempts to acquire ownership of the next pending buffer in
215     // the BufferQueue.  If no buffer is pending then it returns -EINVAL.  If a
216     // buffer is successfully acquired, the information about the buffer is
217     // returned in BufferItem.  If the buffer returned had previously been
218     // acquired then the BufferItem::mGraphicBuffer field of buffer is set to
219     // NULL and it is assumed that the consumer still holds a reference to the
220     // buffer.
221     //
222     // If presentWhen is nonzero, it indicates the time when the buffer will
223     // be displayed on screen.  If the buffer's timestamp is farther in the
224     // future, the buffer won't be acquired, and PRESENT_LATER will be
225     // returned.  The presentation time is in nanoseconds, and the time base
226     // is CLOCK_MONOTONIC.
227     virtual status_t acquireBuffer(BufferItem *buffer, nsecs_t presentWhen);
228 
229     // releaseBuffer releases a buffer slot from the consumer back to the
230     // BufferQueue.  This may be done while the buffer's contents are still
231     // being accessed.  The fence will signal when the buffer is no longer
232     // in use. frameNumber is used to indentify the exact buffer returned.
233     //
234     // If releaseBuffer returns STALE_BUFFER_SLOT, then the consumer must free
235     // any references to the just-released buffer that it might have, as if it
236     // had received a onBuffersReleased() call with a mask set for the released
237     // buffer.
238     //
239     // Note that the dependencies on EGL will be removed once we switch to using
240     // the Android HW Sync HAL.
241     virtual status_t releaseBuffer(int buf, uint64_t frameNumber,
242             EGLDisplay display, EGLSyncKHR fence,
243             const sp<Fence>& releaseFence);
244 
245     // consumerConnect connects a consumer to the BufferQueue.  Only one
246     // consumer may be connected, and when that consumer disconnects the
247     // BufferQueue is placed into the "abandoned" state, causing most
248     // interactions with the BufferQueue by the producer to fail.
249     // controlledByApp indicates whether the consumer is controlled by
250     // the application.
251     //
252     // consumer may not be NULL.
253     virtual status_t consumerConnect(const sp<IConsumerListener>& consumer, bool controlledByApp);
254 
255     // consumerDisconnect disconnects a consumer from the BufferQueue. All
256     // buffers will be freed and the BufferQueue is placed in the "abandoned"
257     // state, causing most interactions with the BufferQueue by the producer to
258     // fail.
259     virtual status_t consumerDisconnect();
260 
261     // getReleasedBuffers sets the value pointed to by slotMask to a bit mask
262     // indicating which buffer slots have been released by the BufferQueue
263     // but have not yet been released by the consumer.
264     //
265     // This should be called from the onBuffersReleased() callback.
266     virtual status_t getReleasedBuffers(uint32_t* slotMask);
267 
268     // setDefaultBufferSize is used to set the size of buffers returned by
269     // dequeueBuffer when a width and height of zero is requested.  Default
270     // is 1x1.
271     virtual status_t setDefaultBufferSize(uint32_t w, uint32_t h);
272 
273     // setDefaultMaxBufferCount sets the default value for the maximum buffer
274     // count (the initial default is 2). If the producer has requested a
275     // buffer count using setBufferCount, the default buffer count will only
276     // take effect if the producer sets the count back to zero.
277     //
278     // The count must be between 2 and NUM_BUFFER_SLOTS, inclusive.
279     virtual status_t setDefaultMaxBufferCount(int bufferCount);
280 
281     // disableAsyncBuffer disables the extra buffer used in async mode
282     // (when both producer and consumer have set their "isControlledByApp"
283     // flag) and has dequeueBuffer() return WOULD_BLOCK instead.
284     //
285     // This can only be called before consumerConnect().
286     virtual status_t disableAsyncBuffer();
287 
288     // setMaxAcquiredBufferCount sets the maximum number of buffers that can
289     // be acquired by the consumer at one time (default 1).  This call will
290     // fail if a producer is connected to the BufferQueue.
291     virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers);
292 
293     // setConsumerName sets the name used in logging
294     virtual void setConsumerName(const String8& name);
295 
296     // setDefaultBufferFormat allows the BufferQueue to create
297     // GraphicBuffers of a defaultFormat if no format is specified
298     // in dequeueBuffer.  Formats are enumerated in graphics.h; the
299     // initial default is HAL_PIXEL_FORMAT_RGBA_8888.
300     virtual status_t setDefaultBufferFormat(uint32_t defaultFormat);
301 
302     // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer.
303     // These are merged with the bits passed to dequeueBuffer.  The values are
304     // enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER; the default is 0.
305     virtual status_t setConsumerUsageBits(uint32_t usage);
306 
307     // setTransformHint bakes in rotation to buffers so overlays can be used.
308     // The values are enumerated in window.h, e.g.
309     // NATIVE_WINDOW_TRANSFORM_ROT_90.  The default is 0 (no transform).
310     virtual status_t setTransformHint(uint32_t hint);
311 
312     // dump our state in a String
313     virtual void dump(String8& result, const char* prefix) const;
314 
315 
316 private:
317     // freeBufferLocked frees the GraphicBuffer and sync resources for the
318     // given slot.
319     void freeBufferLocked(int index);
320 
321     // freeAllBuffersLocked frees the GraphicBuffer and sync resources for
322     // all slots.
323     void freeAllBuffersLocked();
324 
325     // setDefaultMaxBufferCountLocked sets the maximum number of buffer slots
326     // that will be used if the producer does not override the buffer slot
327     // count.  The count must be between 2 and NUM_BUFFER_SLOTS, inclusive.
328     // The initial default is 2.
329     status_t setDefaultMaxBufferCountLocked(int count);
330 
331     // getMinUndequeuedBufferCount returns the minimum number of buffers
332     // that must remain in a state other than DEQUEUED.
333     // The async parameter tells whether we're in asynchronous mode.
334     int getMinUndequeuedBufferCount(bool async) const;
335 
336     // getMinBufferCountLocked returns the minimum number of buffers allowed
337     // given the current BufferQueue state.
338     // The async parameter tells whether we're in asynchronous mode.
339     int getMinMaxBufferCountLocked(bool async) const;
340 
341     // getMaxBufferCountLocked returns the maximum number of buffers that can
342     // be allocated at once.  This value depends upon the following member
343     // variables:
344     //
345     //      mDequeueBufferCannotBlock
346     //      mMaxAcquiredBufferCount
347     //      mDefaultMaxBufferCount
348     //      mOverrideMaxBufferCount
349     //      async parameter
350     //
351     // Any time one of these member variables is changed while a producer is
352     // connected, mDequeueCondition must be broadcast.
353     int getMaxBufferCountLocked(bool async) const;
354 
355     // stillTracking returns true iff the buffer item is still being tracked
356     // in one of the slots.
357     bool stillTracking(const BufferItem *item) const;
358 
359     struct BufferSlot {
360 
BufferSlotBufferSlot361         BufferSlot()
362         : mEglDisplay(EGL_NO_DISPLAY),
363           mBufferState(BufferSlot::FREE),
364           mRequestBufferCalled(false),
365           mFrameNumber(0),
366           mEglFence(EGL_NO_SYNC_KHR),
367           mAcquireCalled(false),
368           mNeedsCleanupOnRelease(false) {
369         }
370 
371         // mGraphicBuffer points to the buffer allocated for this slot or is NULL
372         // if no buffer has been allocated.
373         sp<GraphicBuffer> mGraphicBuffer;
374 
375         // mEglDisplay is the EGLDisplay used to create EGLSyncKHR objects.
376         EGLDisplay mEglDisplay;
377 
378         // BufferState represents the different states in which a buffer slot
379         // can be.  All slots are initially FREE.
380         enum BufferState {
381             // FREE indicates that the buffer is available to be dequeued
382             // by the producer.  The buffer may be in use by the consumer for
383             // a finite time, so the buffer must not be modified until the
384             // associated fence is signaled.
385             //
386             // The slot is "owned" by BufferQueue.  It transitions to DEQUEUED
387             // when dequeueBuffer is called.
388             FREE = 0,
389 
390             // DEQUEUED indicates that the buffer has been dequeued by the
391             // producer, but has not yet been queued or canceled.  The
392             // producer may modify the buffer's contents as soon as the
393             // associated ready fence is signaled.
394             //
395             // The slot is "owned" by the producer.  It can transition to
396             // QUEUED (via queueBuffer) or back to FREE (via cancelBuffer).
397             DEQUEUED = 1,
398 
399             // QUEUED indicates that the buffer has been filled by the
400             // producer and queued for use by the consumer.  The buffer
401             // contents may continue to be modified for a finite time, so
402             // the contents must not be accessed until the associated fence
403             // is signaled.
404             //
405             // The slot is "owned" by BufferQueue.  It can transition to
406             // ACQUIRED (via acquireBuffer) or to FREE (if another buffer is
407             // queued in asynchronous mode).
408             QUEUED = 2,
409 
410             // ACQUIRED indicates that the buffer has been acquired by the
411             // consumer.  As with QUEUED, the contents must not be accessed
412             // by the consumer until the fence is signaled.
413             //
414             // The slot is "owned" by the consumer.  It transitions to FREE
415             // when releaseBuffer is called.
416             ACQUIRED = 3
417         };
418 
419         // mBufferState is the current state of this buffer slot.
420         BufferState mBufferState;
421 
422         // mRequestBufferCalled is used for validating that the producer did
423         // call requestBuffer() when told to do so. Technically this is not
424         // needed but useful for debugging and catching producer bugs.
425         bool mRequestBufferCalled;
426 
427         // mFrameNumber is the number of the queued frame for this slot.  This
428         // is used to dequeue buffers in LRU order (useful because buffers
429         // may be released before their release fence is signaled).
430         uint64_t mFrameNumber;
431 
432         // mEglFence is the EGL sync object that must signal before the buffer
433         // associated with this buffer slot may be dequeued. It is initialized
434         // to EGL_NO_SYNC_KHR when the buffer is created and may be set to a
435         // new sync object in releaseBuffer.  (This is deprecated in favor of
436         // mFence, below.)
437         EGLSyncKHR mEglFence;
438 
439         // mFence is a fence which will signal when work initiated by the
440         // previous owner of the buffer is finished. When the buffer is FREE,
441         // the fence indicates when the consumer has finished reading
442         // from the buffer, or when the producer has finished writing if it
443         // called cancelBuffer after queueing some writes. When the buffer is
444         // QUEUED, it indicates when the producer has finished filling the
445         // buffer. When the buffer is DEQUEUED or ACQUIRED, the fence has been
446         // passed to the consumer or producer along with ownership of the
447         // buffer, and mFence is set to NO_FENCE.
448         sp<Fence> mFence;
449 
450         // Indicates whether this buffer has been seen by a consumer yet
451         bool mAcquireCalled;
452 
453         // Indicates whether this buffer needs to be cleaned up by the
454         // consumer.  This is set when a buffer in ACQUIRED state is freed.
455         // It causes releaseBuffer to return STALE_BUFFER_SLOT.
456         bool mNeedsCleanupOnRelease;
457     };
458 
459     // mSlots is the array of buffer slots that must be mirrored on the
460     // producer side. This allows buffer ownership to be transferred between
461     // the producer and consumer without sending a GraphicBuffer over binder.
462     // The entire array is initialized to NULL at construction time, and
463     // buffers are allocated for a slot when requestBuffer is called with
464     // that slot's index.
465     BufferSlot mSlots[NUM_BUFFER_SLOTS];
466 
467     // mDefaultWidth holds the default width of allocated buffers. It is used
468     // in dequeueBuffer() if a width and height of zero is specified.
469     uint32_t mDefaultWidth;
470 
471     // mDefaultHeight holds the default height of allocated buffers. It is used
472     // in dequeueBuffer() if a width and height of zero is specified.
473     uint32_t mDefaultHeight;
474 
475     // mMaxAcquiredBufferCount is the number of buffers that the consumer may
476     // acquire at one time.  It defaults to 1 and can be changed by the
477     // consumer via the setMaxAcquiredBufferCount method, but this may only be
478     // done when no producer is connected to the BufferQueue.
479     //
480     // This value is used to derive the value returned for the
481     // MIN_UNDEQUEUED_BUFFERS query by the producer.
482     int mMaxAcquiredBufferCount;
483 
484     // mDefaultMaxBufferCount is the default limit on the number of buffers
485     // that will be allocated at one time.  This default limit is set by the
486     // consumer.  The limit (as opposed to the default limit) may be
487     // overridden by the producer.
488     int mDefaultMaxBufferCount;
489 
490     // mOverrideMaxBufferCount is the limit on the number of buffers that will
491     // be allocated at one time. This value is set by the image producer by
492     // calling setBufferCount. The default is zero, which means the producer
493     // doesn't care about the number of buffers in the pool. In that case
494     // mDefaultMaxBufferCount is used as the limit.
495     int mOverrideMaxBufferCount;
496 
497     // mGraphicBufferAlloc is the connection to SurfaceFlinger that is used to
498     // allocate new GraphicBuffer objects.
499     sp<IGraphicBufferAlloc> mGraphicBufferAlloc;
500 
501     // mConsumerListener is used to notify the connected consumer of
502     // asynchronous events that it may wish to react to.  It is initially set
503     // to NULL and is written by consumerConnect and consumerDisconnect.
504     sp<IConsumerListener> mConsumerListener;
505 
506     // mConsumerControlledByApp whether the connected consumer is controlled by the
507     // application.
508     bool mConsumerControlledByApp;
509 
510     // mDequeueBufferCannotBlock whether dequeueBuffer() isn't allowed to block.
511     // this flag is set during connect() when both consumer and producer are controlled
512     // by the application.
513     bool mDequeueBufferCannotBlock;
514 
515     // mUseAsyncBuffer whether an extra buffer is used in async mode to prevent
516     // dequeueBuffer() from ever blocking.
517     bool mUseAsyncBuffer;
518 
519     // mConnectedApi indicates the producer API that is currently connected
520     // to this BufferQueue.  It defaults to NO_CONNECTED_API (= 0), and gets
521     // updated by the connect and disconnect methods.
522     int mConnectedApi;
523 
524     // mDequeueCondition condition used for dequeueBuffer in synchronous mode
525     mutable Condition mDequeueCondition;
526 
527     // mQueue is a FIFO of queued buffers used in synchronous mode
528     typedef Vector<BufferItem> Fifo;
529     Fifo mQueue;
530 
531     // mAbandoned indicates that the BufferQueue will no longer be used to
532     // consume image buffers pushed to it using the IGraphicBufferProducer
533     // interface.  It is initialized to false, and set to true in the
534     // consumerDisconnect method.  A BufferQueue that has been abandoned will
535     // return the NO_INIT error from all IGraphicBufferProducer methods
536     // capable of returning an error.
537     bool mAbandoned;
538 
539     // mConsumerName is a string used to identify the BufferQueue in log
540     // messages.  It is set by the setConsumerName method.
541     String8 mConsumerName;
542 
543     // mMutex is the mutex used to prevent concurrent access to the member
544     // variables of BufferQueue objects. It must be locked whenever the
545     // member variables are accessed.
546     mutable Mutex mMutex;
547 
548     // mFrameCounter is the free running counter, incremented on every
549     // successful queueBuffer call, and buffer allocation.
550     uint64_t mFrameCounter;
551 
552     // mBufferHasBeenQueued is true once a buffer has been queued.  It is
553     // reset when something causes all buffers to be freed (e.g. changing the
554     // buffer count).
555     bool mBufferHasBeenQueued;
556 
557     // mDefaultBufferFormat can be set so it will override
558     // the buffer format when it isn't specified in dequeueBuffer
559     uint32_t mDefaultBufferFormat;
560 
561     // mConsumerUsageBits contains flags the consumer wants for GraphicBuffers
562     uint32_t mConsumerUsageBits;
563 
564     // mTransformHint is used to optimize for screen rotations
565     uint32_t mTransformHint;
566 
567     // mConnectedProducerToken is used to set a binder death notification on the producer
568     sp<IBinder> mConnectedProducerToken;
569 };
570 
571 // ----------------------------------------------------------------------------
572 }; // namespace android
573 
574 #endif // ANDROID_GUI_BUFFERQUEUE_H
575