BufferQueue.h revision b267579ba8dfe3f47d2a481c5a3c2254e3d565a1
16b091c53000c843211c218ce40287a7edca9bc63Daniel Lam/* 26b091c53000c843211c218ce40287a7edca9bc63Daniel Lam * Copyright (C) 2012 The Android Open Source Project 36b091c53000c843211c218ce40287a7edca9bc63Daniel Lam * 46b091c53000c843211c218ce40287a7edca9bc63Daniel Lam * Licensed under the Apache License, Version 2.0 (the "License"); 56b091c53000c843211c218ce40287a7edca9bc63Daniel Lam * you may not use this file except in compliance with the License. 66b091c53000c843211c218ce40287a7edca9bc63Daniel Lam * You may obtain a copy of the License at 76b091c53000c843211c218ce40287a7edca9bc63Daniel Lam * 86b091c53000c843211c218ce40287a7edca9bc63Daniel Lam * http://www.apache.org/licenses/LICENSE-2.0 96b091c53000c843211c218ce40287a7edca9bc63Daniel Lam * 106b091c53000c843211c218ce40287a7edca9bc63Daniel Lam * Unless required by applicable law or agreed to in writing, software 116b091c53000c843211c218ce40287a7edca9bc63Daniel Lam * distributed under the License is distributed on an "AS IS" BASIS, 126b091c53000c843211c218ce40287a7edca9bc63Daniel Lam * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136b091c53000c843211c218ce40287a7edca9bc63Daniel Lam * See the License for the specific language governing permissions and 146b091c53000c843211c218ce40287a7edca9bc63Daniel Lam * limitations under the License. 156b091c53000c843211c218ce40287a7edca9bc63Daniel Lam */ 166b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 176b091c53000c843211c218ce40287a7edca9bc63Daniel Lam#ifndef ANDROID_GUI_BUFFERQUEUE_H 186b091c53000c843211c218ce40287a7edca9bc63Daniel Lam#define ANDROID_GUI_BUFFERQUEUE_H 196b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 206b091c53000c843211c218ce40287a7edca9bc63Daniel Lam#include <EGL/egl.h> 216b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 2290ac799241f077a7b7e6c1875fd933864c8dd2a7Mathias Agopian#include <gui/IGraphicBufferAlloc.h> 236b091c53000c843211c218ce40287a7edca9bc63Daniel Lam#include <gui/ISurfaceTexture.h> 246b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 256b091c53000c843211c218ce40287a7edca9bc63Daniel Lam#include <ui/GraphicBuffer.h> 266b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 276b091c53000c843211c218ce40287a7edca9bc63Daniel Lam#include <utils/String8.h> 286b091c53000c843211c218ce40287a7edca9bc63Daniel Lam#include <utils/Vector.h> 296b091c53000c843211c218ce40287a7edca9bc63Daniel Lam#include <utils/threads.h> 306b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 316b091c53000c843211c218ce40287a7edca9bc63Daniel Lamnamespace android { 326b091c53000c843211c218ce40287a7edca9bc63Daniel Lam// ---------------------------------------------------------------------------- 336b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 346b091c53000c843211c218ce40287a7edca9bc63Daniel Lamclass BufferQueue : public BnSurfaceTexture { 356b091c53000c843211c218ce40287a7edca9bc63Daniel Lampublic: 366b091c53000c843211c218ce40287a7edca9bc63Daniel Lam enum { MIN_UNDEQUEUED_BUFFERS = 2 }; 376b091c53000c843211c218ce40287a7edca9bc63Daniel Lam enum { 386b091c53000c843211c218ce40287a7edca9bc63Daniel Lam MIN_ASYNC_BUFFER_SLOTS = MIN_UNDEQUEUED_BUFFERS + 1, 396b091c53000c843211c218ce40287a7edca9bc63Daniel Lam MIN_SYNC_BUFFER_SLOTS = MIN_UNDEQUEUED_BUFFERS 406b091c53000c843211c218ce40287a7edca9bc63Daniel Lam }; 416b091c53000c843211c218ce40287a7edca9bc63Daniel Lam enum { NUM_BUFFER_SLOTS = 32 }; 426b091c53000c843211c218ce40287a7edca9bc63Daniel Lam enum { NO_CONNECTED_API = 0 }; 43eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam enum { INVALID_BUFFER_SLOT = -1 }; 446b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 456b091c53000c843211c218ce40287a7edca9bc63Daniel Lam struct FrameAvailableListener : public virtual RefBase { 466b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // onFrameAvailable() is called from queueBuffer() each time an 476b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // additional frame becomes available for consumption. This means that 486b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // frames that are queued while in asynchronous mode only trigger the 496b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // callback if no previous frames are pending. Frames queued while in 506b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // synchronous mode always trigger the callback. 516b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // 526b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // This is called without any lock held and can be called concurrently 536b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // by multiple threads. 546b091c53000c843211c218ce40287a7edca9bc63Daniel Lam virtual void onFrameAvailable() = 0; 556b091c53000c843211c218ce40287a7edca9bc63Daniel Lam }; 566b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 576b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // BufferQueue manages a pool of gralloc memory slots to be used 586b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // by producers and consumers. 596b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // allowSynchronousMode specifies whether or not synchronous mode can be 606b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // enabled. 616b091c53000c843211c218ce40287a7edca9bc63Daniel Lam BufferQueue(bool allowSynchronousMode = true); 626b091c53000c843211c218ce40287a7edca9bc63Daniel Lam virtual ~BufferQueue(); 636b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 64b856052c00dfef70d0957482c72c2979ffc4733aDaniel Lam virtual int query(int what, int* value); 65b856052c00dfef70d0957482c72c2979ffc4733aDaniel Lam 666b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // setBufferCount updates the number of available buffer slots. After 676b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // calling this all buffer slots are both unallocated and owned by the 686b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // BufferQueue object (i.e. they are not owned by the client). 696b091c53000c843211c218ce40287a7edca9bc63Daniel Lam virtual status_t setBufferCount(int bufferCount); 706b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 716b091c53000c843211c218ce40287a7edca9bc63Daniel Lam virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf); 726b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 736b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // dequeueBuffer gets the next buffer slot index for the client to use. If a 746b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // buffer slot is available then that slot index is written to the location 756b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // pointed to by the buf argument and a status of OK is returned. If no 766b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // slot is available then a status of -EBUSY is returned and buf is 776b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // unmodified. 786b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // The width and height parameters must be no greater than the minimum of 796b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). 806b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // An error due to invalid dimensions might not be reported until 816b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // updateTexImage() is called. 826b091c53000c843211c218ce40287a7edca9bc63Daniel Lam virtual status_t dequeueBuffer(int *buf, uint32_t width, uint32_t height, 836b091c53000c843211c218ce40287a7edca9bc63Daniel Lam uint32_t format, uint32_t usage); 846b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 856b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // queueBuffer returns a filled buffer to the BufferQueue. In addition, a 866b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // timestamp must be provided for the buffer. The timestamp is in 876b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // nanoseconds, and must be monotonically increasing. Its other semantics 886b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // (zero point, etc) are client-dependent and should be documented by the 896b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // client. 906b091c53000c843211c218ce40287a7edca9bc63Daniel Lam virtual status_t queueBuffer(int buf, int64_t timestamp, 916b091c53000c843211c218ce40287a7edca9bc63Daniel Lam uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform); 926b091c53000c843211c218ce40287a7edca9bc63Daniel Lam virtual void cancelBuffer(int buf); 936b091c53000c843211c218ce40287a7edca9bc63Daniel Lam virtual status_t setCrop(const Rect& reg); 946b091c53000c843211c218ce40287a7edca9bc63Daniel Lam virtual status_t setTransform(uint32_t transform); 956b091c53000c843211c218ce40287a7edca9bc63Daniel Lam virtual status_t setScalingMode(int mode); 966b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 976b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // setSynchronousMode set whether dequeueBuffer is synchronous or 986b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // asynchronous. In synchronous mode, dequeueBuffer blocks until 996b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // a buffer is available, the currently bound buffer can be dequeued and 1006b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // queued buffers will be retired in order. 1016b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // The default mode is asynchronous. 1026b091c53000c843211c218ce40287a7edca9bc63Daniel Lam virtual status_t setSynchronousMode(bool enabled); 1036b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 1046b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // connect attempts to connect a producer client API to the BufferQueue. 1056b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // This must be called before any other ISurfaceTexture methods are called 1066b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // except for getAllocator. 1076b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // 1086b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // This method will fail if the connect was previously called on the 1096b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // BufferQueue and no corresponding disconnect call was made. 1106b091c53000c843211c218ce40287a7edca9bc63Daniel Lam virtual status_t connect(int api, 1116b091c53000c843211c218ce40287a7edca9bc63Daniel Lam uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform); 1126b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 1136b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // disconnect attempts to disconnect a producer client API from the 1146b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // BufferQueue. Calling this method will cause any subsequent calls to other 1156b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // ISurfaceTexture methods to fail except for getAllocator and connect. 1166b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // Successfully calling connect after this will allow the other methods to 1176b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // succeed again. 1186b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // 1196b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // This method will fail if the the BufferQueue is not currently 1206b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // connected to the specified client API. 1216b091c53000c843211c218ce40287a7edca9bc63Daniel Lam virtual status_t disconnect(int api); 1226b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 123eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // dump our state in a String 124eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam virtual void dump(String8& result) const; 125eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam virtual void dump(String8& result, const char* prefix, char* buffer, size_t SIZE) const; 126eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 127eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // public facing structure for BufferSlot 128eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam struct BufferItem { 129eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 130eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam BufferItem() 131eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam : 132eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam mTransform(0), 133eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE), 134eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam mTimestamp(0), 135eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam mFrameNumber(0), 136eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam mBuf(INVALID_BUFFER_SLOT) { 137eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam mCrop.makeInvalid(); 138eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam } 139eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // mGraphicBuffer points to the buffer allocated for this slot or is NULL 140eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // if no buffer has been allocated. 141eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam sp<GraphicBuffer> mGraphicBuffer; 142eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 143eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // mCrop is the current crop rectangle for this buffer slot. This gets 144eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // set to mNextCrop each time queueBuffer gets called for this buffer. 145eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam Rect mCrop; 146eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 147eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // mTransform is the current transform flags for this buffer slot. This 148eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // gets set to mNextTransform each time queueBuffer gets called for this 149eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // slot. 150eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam uint32_t mTransform; 151eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 152eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // mScalingMode is the current scaling mode for this buffer slot. This 153eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // gets set to mNextScalingMode each time queueBuffer gets called for 154eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // this slot. 155eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam uint32_t mScalingMode; 156eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 157eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // mTimestamp is the current timestamp for this buffer slot. This gets 158eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // to set by queueBuffer each time this slot is queued. 159eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam int64_t mTimestamp; 1606b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 161eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // mFrameNumber is the number of the queued frame for this slot. 162eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam uint64_t mFrameNumber; 163eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 164eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // buf is the slot index of this buffer 165eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam int mBuf; 166eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 167eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam }; 168eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 169eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // The following public functions is the consumer facing interface 170eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 171eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // acquire consumes a buffer by transferring its ownership to a consumer. 172eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // buffer contains the GraphicBuffer and its corresponding information. 173eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // buffer.mGraphicsBuffer will be NULL when the buffer has been already 174eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // acquired by the consumer. 175eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 176eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam status_t acquire(BufferItem *buffer); 177eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 178eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // releaseBuffer releases a buffer slot from the consumer back to the 179eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // BufferQueue pending a fence sync. 180eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam status_t releaseBuffer(int buf, EGLDisplay display, EGLSyncKHR fence); 181eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 182eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // consumerDisconnect disconnects a consumer from the BufferQueue. All 183eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // buffers will be freed. 184eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam status_t consumerDisconnect(); 185eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 186eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // setDefaultBufferSize is used to set the size of buffers returned by 187eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // requestBuffers when a with and height of zero is requested. 188eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam status_t setDefaultBufferSize(uint32_t w, uint32_t h); 189eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 190eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // setBufferCountServer set the buffer count. If the client has requested 191eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // a buffer count using setBufferCount, the server-buffer count will 192eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // take effect once the client sets the count back to zero. 193eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam status_t setBufferCountServer(int bufferCount); 194eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 195eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // isSynchronousMode returns whether the SurfaceTexture is currently in 196eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // synchronous mode. 197eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam bool isSynchronousMode() const; 198eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 199eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // setConsumerName sets the name used in logging 200eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam void setConsumerName(const String8& name); 201eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 202eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // setFrameAvailableListener sets the listener object that will be notified 203eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // when a new frame becomes available. 204eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam void setFrameAvailableListener(const sp<FrameAvailableListener>& listener); 205eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 206b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam // setDefaultBufferFormat allows the BufferQueue to create 207b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam // GraphicBuffers of a defaultFormat if no format is specified 208b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam // in dequeueBuffer 209b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam status_t setDefaultBufferFormat(uint32_t defaultFormat); 210b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam 211b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer 212b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam status_t setConsumerUsageBits(uint32_t usage); 213b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam 214b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam // setTransformHint bakes in rotation to buffers so overlays can be used 215b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam status_t setTransformHint(uint32_t hint); 216eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 217eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lamprivate: 2186b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // freeBufferLocked frees the resources (both GraphicBuffer and EGLImage) 2196b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // for the given slot. 2206b091c53000c843211c218ce40287a7edca9bc63Daniel Lam void freeBufferLocked(int index); 2216b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 2226b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // freeAllBuffersLocked frees the resources (both GraphicBuffer and 2236b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // EGLImage) for all slots. 2246b091c53000c843211c218ce40287a7edca9bc63Daniel Lam void freeAllBuffersLocked(); 2256b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 2266b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // freeAllBuffersExceptHeadLocked frees the resources (both GraphicBuffer 2276b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // and EGLImage) for all slots except the head of mQueue 2286b091c53000c843211c218ce40287a7edca9bc63Daniel Lam void freeAllBuffersExceptHeadLocked(); 2296b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 2306b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // drainQueueLocked drains the buffer queue if we're in synchronous mode 2316b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // returns immediately otherwise. It returns NO_INIT if the BufferQueue 2326b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // became abandoned or disconnected during this call. 2336b091c53000c843211c218ce40287a7edca9bc63Daniel Lam status_t drainQueueLocked(); 2346b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 2356b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // drainQueueAndFreeBuffersLocked drains the buffer queue if we're in 2366b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // synchronous mode and free all buffers. In asynchronous mode, all buffers 2376b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // are freed except the current buffer. 2386b091c53000c843211c218ce40287a7edca9bc63Daniel Lam status_t drainQueueAndFreeBuffersLocked(); 2396b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 2406b091c53000c843211c218ce40287a7edca9bc63Daniel Lam status_t setBufferCountServerLocked(int bufferCount); 2416b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 2426b091c53000c843211c218ce40287a7edca9bc63Daniel Lam struct BufferSlot { 2436b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 2446b091c53000c843211c218ce40287a7edca9bc63Daniel Lam BufferSlot() 245eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam : mEglDisplay(EGL_NO_DISPLAY), 2466b091c53000c843211c218ce40287a7edca9bc63Daniel Lam mBufferState(BufferSlot::FREE), 2476b091c53000c843211c218ce40287a7edca9bc63Daniel Lam mRequestBufferCalled(false), 2486b091c53000c843211c218ce40287a7edca9bc63Daniel Lam mTransform(0), 2496b091c53000c843211c218ce40287a7edca9bc63Daniel Lam mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE), 2506b091c53000c843211c218ce40287a7edca9bc63Daniel Lam mTimestamp(0), 2516b091c53000c843211c218ce40287a7edca9bc63Daniel Lam mFrameNumber(0), 252eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam mFence(EGL_NO_SYNC_KHR), 253eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam mAcquireCalled(false) { 2546b091c53000c843211c218ce40287a7edca9bc63Daniel Lam mCrop.makeInvalid(); 2556b091c53000c843211c218ce40287a7edca9bc63Daniel Lam } 2566b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 2576b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mGraphicBuffer points to the buffer allocated for this slot or is NULL 2586b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // if no buffer has been allocated. 2596b091c53000c843211c218ce40287a7edca9bc63Daniel Lam sp<GraphicBuffer> mGraphicBuffer; 2606b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 2616b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mEglDisplay is the EGLDisplay used to create mEglImage. 2626b091c53000c843211c218ce40287a7edca9bc63Daniel Lam EGLDisplay mEglDisplay; 2636b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 2646b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // BufferState represents the different states in which a buffer slot 2656b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // can be. 2666b091c53000c843211c218ce40287a7edca9bc63Daniel Lam enum BufferState { 2676b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // FREE indicates that the buffer is not currently being used and 2686b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // will not be used in the future until it gets dequeued and 2696b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // subsequently queued by the client. 270eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // aka "owned by BufferQueue, ready to be dequeued" 2716b091c53000c843211c218ce40287a7edca9bc63Daniel Lam FREE = 0, 2726b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 2736b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // DEQUEUED indicates that the buffer has been dequeued by the 2746b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // client, but has not yet been queued or canceled. The buffer is 2756b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // considered 'owned' by the client, and the server should not use 2766b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // it for anything. 2776b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // 2786b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // Note that when in synchronous-mode (mSynchronousMode == true), 2796b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // the buffer that's currently attached to the texture may be 2806b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // dequeued by the client. That means that the current buffer can 2816b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // be in either the DEQUEUED or QUEUED state. In asynchronous mode, 2826b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // however, the current buffer is always in the QUEUED state. 283eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // aka "owned by producer, ready to be queued" 2846b091c53000c843211c218ce40287a7edca9bc63Daniel Lam DEQUEUED = 1, 2856b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 2866b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // QUEUED indicates that the buffer has been queued by the client, 2876b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // and has not since been made available for the client to dequeue. 2886b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // Attaching the buffer to the texture does NOT transition the 2896b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // buffer away from the QUEUED state. However, in Synchronous mode 2906b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // the current buffer may be dequeued by the client under some 2916b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // circumstances. See the note about the current buffer in the 2926b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // documentation for DEQUEUED. 293eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // aka "owned by BufferQueue, ready to be acquired" 2946b091c53000c843211c218ce40287a7edca9bc63Daniel Lam QUEUED = 2, 295eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 296eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // aka "owned by consumer, ready to be released" 297eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam ACQUIRED = 3 2986b091c53000c843211c218ce40287a7edca9bc63Daniel Lam }; 2996b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3006b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mBufferState is the current state of this buffer slot. 3016b091c53000c843211c218ce40287a7edca9bc63Daniel Lam BufferState mBufferState; 3026b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3036b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mRequestBufferCalled is used for validating that the client did 3046b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // call requestBuffer() when told to do so. Technically this is not 3056b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // needed but useful for debugging and catching client bugs. 3066b091c53000c843211c218ce40287a7edca9bc63Daniel Lam bool mRequestBufferCalled; 3076b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3086b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mCrop is the current crop rectangle for this buffer slot. This gets 3096b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // set to mNextCrop each time queueBuffer gets called for this buffer. 3106b091c53000c843211c218ce40287a7edca9bc63Daniel Lam Rect mCrop; 3116b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3126b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mTransform is the current transform flags for this buffer slot. This 3136b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // gets set to mNextTransform each time queueBuffer gets called for this 3146b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // slot. 3156b091c53000c843211c218ce40287a7edca9bc63Daniel Lam uint32_t mTransform; 3166b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3176b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mScalingMode is the current scaling mode for this buffer slot. This 3186b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // gets set to mNextScalingMode each time queueBuffer gets called for 3196b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // this slot. 3206b091c53000c843211c218ce40287a7edca9bc63Daniel Lam uint32_t mScalingMode; 3216b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3226b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mTimestamp is the current timestamp for this buffer slot. This gets 3236b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // to set by queueBuffer each time this slot is queued. 3246b091c53000c843211c218ce40287a7edca9bc63Daniel Lam int64_t mTimestamp; 3256b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3266b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mFrameNumber is the number of the queued frame for this slot. 3276b091c53000c843211c218ce40287a7edca9bc63Daniel Lam uint64_t mFrameNumber; 3286b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3296b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mFence is the EGL sync object that must signal before the buffer 3306b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // associated with this buffer slot may be dequeued. It is initialized 3316b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // to EGL_NO_SYNC_KHR when the buffer is created and (optionally, based 3326b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // on a compile-time option) set to a new sync object in updateTexImage. 3336b091c53000c843211c218ce40287a7edca9bc63Daniel Lam EGLSyncKHR mFence; 334eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 335eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam // Indicates whether this buffer has been seen by a consumer yet 336eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam bool mAcquireCalled; 3376b091c53000c843211c218ce40287a7edca9bc63Daniel Lam }; 3386b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3396b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mSlots is the array of buffer slots that must be mirrored on the client 3406b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // side. This allows buffer ownership to be transferred between the client 3416b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // and server without sending a GraphicBuffer over binder. The entire array 3426b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // is initialized to NULL at construction time, and buffers are allocated 3436b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // for a slot when requestBuffer is called with that slot's index. 3446b091c53000c843211c218ce40287a7edca9bc63Daniel Lam BufferSlot mSlots[NUM_BUFFER_SLOTS]; 3456b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3466b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mDefaultWidth holds the default width of allocated buffers. It is used 3476b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // in requestBuffers() if a width and height of zero is specified. 3486b091c53000c843211c218ce40287a7edca9bc63Daniel Lam uint32_t mDefaultWidth; 3496b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3506b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mDefaultHeight holds the default height of allocated buffers. It is used 3516b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // in requestBuffers() if a width and height of zero is specified. 3526b091c53000c843211c218ce40287a7edca9bc63Daniel Lam uint32_t mDefaultHeight; 3536b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3546b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mPixelFormat holds the pixel format of allocated buffers. It is used 3556b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // in requestBuffers() if a format of zero is specified. 3566b091c53000c843211c218ce40287a7edca9bc63Daniel Lam uint32_t mPixelFormat; 3576b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3586b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mBufferCount is the number of buffer slots that the client and server 3596b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // must maintain. It defaults to MIN_ASYNC_BUFFER_SLOTS and can be changed 3606b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // by calling setBufferCount or setBufferCountServer 3616b091c53000c843211c218ce40287a7edca9bc63Daniel Lam int mBufferCount; 3626b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3636b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mClientBufferCount is the number of buffer slots requested by the client. 3646b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // The default is zero, which means the client doesn't care how many buffers 3656b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // there is. 3666b091c53000c843211c218ce40287a7edca9bc63Daniel Lam int mClientBufferCount; 3676b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3686b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mServerBufferCount buffer count requested by the server-side 3696b091c53000c843211c218ce40287a7edca9bc63Daniel Lam int mServerBufferCount; 3706b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3716b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mNextCrop is the crop rectangle that will be used for the next buffer 3726b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // that gets queued. It is set by calling setCrop. 3736b091c53000c843211c218ce40287a7edca9bc63Daniel Lam Rect mNextCrop; 3746b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3756b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mNextTransform is the transform identifier that will be used for the next 3766b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // buffer that gets queued. It is set by calling setTransform. 3776b091c53000c843211c218ce40287a7edca9bc63Daniel Lam uint32_t mNextTransform; 3786b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3796b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mNextScalingMode is the scaling mode that will be used for the next 3806b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // buffers that get queued. It is set by calling setScalingMode. 3816b091c53000c843211c218ce40287a7edca9bc63Daniel Lam int mNextScalingMode; 3826b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3836b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mGraphicBufferAlloc is the connection to SurfaceFlinger that is used to 3846b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // allocate new GraphicBuffer objects. 3856b091c53000c843211c218ce40287a7edca9bc63Daniel Lam sp<IGraphicBufferAlloc> mGraphicBufferAlloc; 3866b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3876b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mFrameAvailableListener is the listener object that will be called when a 3886b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // new frame becomes available. If it is not NULL it will be called from 3896b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // queueBuffer. 3906b091c53000c843211c218ce40287a7edca9bc63Daniel Lam sp<FrameAvailableListener> mFrameAvailableListener; 3916b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3926b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mSynchronousMode whether we're in synchronous mode or not 3936b091c53000c843211c218ce40287a7edca9bc63Daniel Lam bool mSynchronousMode; 3946b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3956b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mAllowSynchronousMode whether we allow synchronous mode or not 3966b091c53000c843211c218ce40287a7edca9bc63Daniel Lam const bool mAllowSynchronousMode; 3976b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 3986b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mConnectedApi indicates the API that is currently connected to this 3996b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // BufferQueue. It defaults to NO_CONNECTED_API (= 0), and gets updated 4006b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // by the connect and disconnect methods. 4016b091c53000c843211c218ce40287a7edca9bc63Daniel Lam int mConnectedApi; 4026b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 4036b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mDequeueCondition condition used for dequeueBuffer in synchronous mode 4046b091c53000c843211c218ce40287a7edca9bc63Daniel Lam mutable Condition mDequeueCondition; 4056b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 4066b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mQueue is a FIFO of queued buffers used in synchronous mode 4076b091c53000c843211c218ce40287a7edca9bc63Daniel Lam typedef Vector<int> Fifo; 4086b091c53000c843211c218ce40287a7edca9bc63Daniel Lam Fifo mQueue; 4096b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 4106b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mAbandoned indicates that the BufferQueue will no longer be used to 4116b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // consume images buffers pushed to it using the ISurfaceTexture interface. 4126b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // It is initialized to false, and set to true in the abandon method. A 4136b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // BufferQueue that has been abandoned will return the NO_INIT error from 4146b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // all ISurfaceTexture methods capable of returning an error. 4156b091c53000c843211c218ce40287a7edca9bc63Daniel Lam bool mAbandoned; 4166b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 4176b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mName is a string used to identify the BufferQueue in log messages. 4186b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // It is set by the setName method. 419eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam String8 mConsumerName; 4206b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 4216b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mMutex is the mutex used to prevent concurrent access to the member 4226b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // variables of BufferQueue objects. It must be locked whenever the 4236b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // member variables are accessed. 4246b091c53000c843211c218ce40287a7edca9bc63Daniel Lam mutable Mutex mMutex; 4256b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 4266b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // mFrameCounter is the free running counter, incremented for every buffer queued 4276b091c53000c843211c218ce40287a7edca9bc63Daniel Lam // with the surface Texture. 4286b091c53000c843211c218ce40287a7edca9bc63Daniel Lam uint64_t mFrameCounter; 429eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam 430b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam // mBufferHasBeenQueued is true once a buffer has been queued. It is reset 431b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam // by changing the buffer count. 432eae59d2ea77ef57aab203fb185a880ce37ac38d6Daniel Lam bool mBufferHasBeenQueued; 433b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam 434b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam // mDefaultBufferFormat can be set so it will override 435b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam // the buffer format when it isn't specified in dequeueBuffer 436b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam uint32_t mDefaultBufferFormat; 437b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam 438b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam // mConsumerUsageBits contains flags the consumer wants for GraphicBuffers 439b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam uint32_t mConsumerUsageBits; 440b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam 441b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam // mTransformHint is used to optimize for screen rotations 442b267579ba8dfe3f47d2a481c5a3c2254e3d565a1Daniel Lam uint32_t mTransformHint; 4436b091c53000c843211c218ce40287a7edca9bc63Daniel Lam}; 4446b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 4456b091c53000c843211c218ce40287a7edca9bc63Daniel Lam// ---------------------------------------------------------------------------- 4466b091c53000c843211c218ce40287a7edca9bc63Daniel Lam}; // namespace android 4476b091c53000c843211c218ce40287a7edca9bc63Daniel Lam 4486b091c53000c843211c218ce40287a7edca9bc63Daniel Lam#endif // ANDROID_GUI_BUFFERQUEUE_H 449