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