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