blob: da876ec6e266eb94d89fa5709eeb2bf8ec01bf67 [file] [log] [blame]
Daniel Lam6b091c52012-01-22 15:26:27 -08001/*
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
Dan Stoza3e96f192014-03-03 10:16:19 -080020#include <gui/BufferQueueProducer.h>
21#include <gui/BufferQueueConsumer.h>
22#include <gui/IConsumerListener.h>
23
24// These are only required to keep other parts of the framework with incomplete
25// dependencies building successfully
26#include <gui/IGraphicBufferAlloc.h>
Daniel Lam6b091c52012-01-22 15:26:27 -080027
Mathias Agopian365857d2013-09-11 19:35:45 -070028#include <binder/IBinder.h>
29
Daniel Lam6b091c52012-01-22 15:26:27 -080030namespace android {
Daniel Lam6b091c52012-01-22 15:26:27 -080031
Dan Stoza9f3053d2014-03-06 15:14:33 -080032// BQProducer and BQConsumer are thin shim classes to allow methods with the
33// same signature in both IGraphicBufferProducer and IGraphicBufferConsumer.
34// This will stop being an issue when we deprecate creating BufferQueues
35// directly (as opposed to using the *Producer and *Consumer interfaces).
36class BQProducer : public BnGraphicBufferProducer {
37public:
38 virtual status_t detachProducerBuffer(int slot) = 0;
39 virtual status_t attachProducerBuffer(int* slot,
40 const sp<GraphicBuffer>& buffer) = 0;
41
42 virtual status_t detachBuffer(int slot) {
43 return detachProducerBuffer(slot);
44 }
45
46 virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer) {
47 return attachProducerBuffer(slot, buffer);
48 }
49};
50
51class BQConsumer : public BnGraphicBufferConsumer {
52public:
53 virtual status_t detachConsumerBuffer(int slot) = 0;
54 virtual status_t attachConsumerBuffer(int* slot,
55 const sp<GraphicBuffer>& buffer) = 0;
56
57 virtual status_t detachBuffer(int slot) {
58 return detachConsumerBuffer(slot);
59 }
60
61 virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer) {
62 return attachConsumerBuffer(slot, buffer);
63 }
64};
65
66class BufferQueue : public BQProducer,
67 public BQConsumer,
Mathias Agopian365857d2013-09-11 19:35:45 -070068 private IBinder::DeathRecipient {
Daniel Lam6b091c52012-01-22 15:26:27 -080069public:
Igor Murashkin7d2d1602013-11-12 18:02:20 -080070 // BufferQueue will keep track of at most this value of buffers.
71 // Attempts at runtime to increase the number of buffers past this will fail.
Daniel Lam6b091c52012-01-22 15:26:27 -080072 enum { NUM_BUFFER_SLOTS = 32 };
Igor Murashkin7d2d1602013-11-12 18:02:20 -080073 // Used as a placeholder slot# when the value isn't pointing to an existing buffer.
74 enum { INVALID_BUFFER_SLOT = IGraphicBufferConsumer::BufferItem::INVALID_BUFFER_SLOT };
75 // Alias to <IGraphicBufferConsumer.h> -- please scope from there in future code!
76 enum {
77 NO_BUFFER_AVAILABLE = IGraphicBufferConsumer::NO_BUFFER_AVAILABLE,
78 PRESENT_LATER = IGraphicBufferConsumer::PRESENT_LATER,
79 };
Daniel Lam6b091c52012-01-22 15:26:27 -080080
Jamie Gennisc68f2ec2012-08-30 18:36:22 -070081 // When in async mode we reserve two slots in order to guarantee that the
82 // producer and consumer can run asynchronously.
83 enum { MAX_MAX_ACQUIRED_BUFFERS = NUM_BUFFER_SLOTS - 2 };
84
Mathias Agopiana4e19522013-07-31 20:09:53 -070085 // for backward source compatibility
86 typedef ::android::ConsumerListener ConsumerListener;
Daniel Lam6b091c52012-01-22 15:26:27 -080087
Jamie Gennisfa5b40e2012-03-15 14:01:24 -070088 // ProxyConsumerListener is a ConsumerListener implementation that keeps a weak
89 // reference to the actual consumer object. It forwards all calls to that
90 // consumer object so long as it exists.
91 //
92 // This class exists to avoid having a circular reference between the
93 // BufferQueue object and the consumer object. The reason this can't be a weak
94 // reference in the BufferQueue class is because we're planning to expose the
95 // consumer side of a BufferQueue as a binder interface, which doesn't support
96 // weak references.
Mathias Agopiana4e19522013-07-31 20:09:53 -070097 class ProxyConsumerListener : public BnConsumerListener {
Jamie Gennisfa5b40e2012-03-15 14:01:24 -070098 public:
Mathias Agopiana4e19522013-07-31 20:09:53 -070099 ProxyConsumerListener(const wp<ConsumerListener>& consumerListener);
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700100 virtual ~ProxyConsumerListener();
101 virtual void onFrameAvailable();
102 virtual void onBuffersReleased();
Jesse Hall399184a2014-03-03 15:42:54 -0800103 virtual void onSidebandStreamChanged();
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700104 private:
Mathias Agopiana4e19522013-07-31 20:09:53 -0700105 // mConsumerListener is a weak reference to the IConsumerListener. This is
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700106 // the raison d'etre of ProxyConsumerListener.
Mathias Agopiana4e19522013-07-31 20:09:53 -0700107 wp<ConsumerListener> mConsumerListener;
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700108 };
109
Jamie Gennis72f096f2012-08-27 18:48:37 -0700110 // BufferQueue manages a pool of gralloc memory slots to be used by
Mathias Agopian595264f2013-07-16 22:56:09 -0700111 // producers and consumers. allocator is used to allocate all the
112 // needed gralloc buffers.
113 BufferQueue(const sp<IGraphicBufferAlloc>& allocator = NULL);
Dan Stozaf522af72014-03-12 10:17:20 -0700114
Dan Stozaf522af72014-03-12 10:17:20 -0700115 static void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
116 sp<IGraphicBufferConsumer>* outConsumer,
117 const sp<IGraphicBufferAlloc>& allocator = NULL);
118
Daniel Lam6b091c52012-01-22 15:26:27 -0800119 virtual ~BufferQueue();
120
Mathias Agopiana4e19522013-07-31 20:09:53 -0700121 /*
Mathias Agopian365857d2013-09-11 19:35:45 -0700122 * IBinder::DeathRecipient interface
123 */
124
125 virtual void binderDied(const wp<IBinder>& who);
126
127 /*
Mathias Agopiana4e19522013-07-31 20:09:53 -0700128 * IGraphicBufferProducer interface
129 */
130
Andy McFadden753e3412013-04-04 17:09:03 -0700131 // Query native window attributes. The "what" values are enumerated in
132 // window.h (e.g. NATIVE_WINDOW_FORMAT).
Daniel Lamb8560522012-01-30 15:51:27 -0800133 virtual int query(int what, int* value);
134
Andy McFadden753e3412013-04-04 17:09:03 -0700135 // setBufferCount updates the number of available buffer slots. If this
136 // method succeeds, buffer slots will be both unallocated and owned by
137 // the BufferQueue object (i.e. they are not owned by the producer or
138 // consumer).
139 //
140 // This will fail if the producer has dequeued any buffers, or if
141 // bufferCount is invalid. bufferCount must generally be a value
Igor Murashkin7ea777f2013-11-18 16:58:36 -0800142 // between the minimum undequeued buffer count (exclusive) and NUM_BUFFER_SLOTS
Andy McFadden753e3412013-04-04 17:09:03 -0700143 // (inclusive). It may also be set to zero (the default) to indicate
144 // that the producer does not wish to set a value. The minimum value
145 // can be obtained by calling query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
146 // ...).
147 //
148 // This may only be called by the producer. The consumer will be told
149 // to discard buffers through the onBuffersReleased callback.
Daniel Lam6b091c52012-01-22 15:26:27 -0800150 virtual status_t setBufferCount(int bufferCount);
151
Andy McFadden753e3412013-04-04 17:09:03 -0700152 // requestBuffer returns the GraphicBuffer for slot N.
153 //
154 // In normal operation, this is called the first time slot N is returned
155 // by dequeueBuffer. It must be called again if dequeueBuffer returns
156 // flags indicating that previously-returned buffers are no longer valid.
Daniel Lam6b091c52012-01-22 15:26:27 -0800157 virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
158
Andy McFadden753e3412013-04-04 17:09:03 -0700159 // dequeueBuffer gets the next buffer slot index for the producer to use.
160 // If a buffer slot is available then that slot index is written to the
161 // location pointed to by the buf argument and a status of OK is returned.
162 // If no slot is available then a status of -EBUSY is returned and buf is
Daniel Lam6b091c52012-01-22 15:26:27 -0800163 // unmodified.
Jesse Hallf7857542012-06-14 15:26:33 -0700164 //
165 // The fence parameter will be updated to hold the fence associated with
166 // the buffer. The contents of the buffer must not be overwritten until the
Andy McFadden753e3412013-04-04 17:09:03 -0700167 // fence signals. If the fence is Fence::NO_FENCE, the buffer may be
168 // written immediately.
Jesse Hallf7857542012-06-14 15:26:33 -0700169 //
Daniel Lam6b091c52012-01-22 15:26:27 -0800170 // The width and height parameters must be no greater than the minimum of
171 // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv).
172 // An error due to invalid dimensions might not be reported until
Andy McFadden753e3412013-04-04 17:09:03 -0700173 // updateTexImage() is called. If width and height are both zero, the
174 // default values specified by setDefaultBufferSize() are used instead.
175 //
176 // The pixel formats are enumerated in graphics.h, e.g.
177 // HAL_PIXEL_FORMAT_RGBA_8888. If the format is 0, the default format
178 // will be used.
179 //
180 // The usage argument specifies gralloc buffer usage flags. The values
181 // are enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER. These
182 // will be merged with the usage flags specified by setConsumerUsageBits.
183 //
184 // The return value may be a negative error value or a non-negative
185 // collection of flags. If the flags are set, the return values are
186 // valid, but additional actions must be performed.
187 //
188 // If IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION is set, the
189 // producer must discard cached GraphicBuffer references for the slot
190 // returned in buf.
191 // If IGraphicBufferProducer::RELEASE_ALL_BUFFERS is set, the producer
192 // must discard cached GraphicBuffer references for all slots.
193 //
194 // In both cases, the producer will need to call requestBuffer to get a
195 // GraphicBuffer handle for the returned slot.
Mathias Agopian7cdd7862013-07-18 22:10:56 -0700196 virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, bool async,
Jesse Hallf7857542012-06-14 15:26:33 -0700197 uint32_t width, uint32_t height, uint32_t format, uint32_t usage);
Daniel Lam6b091c52012-01-22 15:26:27 -0800198
Dan Stoza9f3053d2014-03-06 15:14:33 -0800199 // See IGraphicBufferProducer::detachBuffer
200 virtual status_t detachProducerBuffer(int slot);
201
202 // See IGraphicBufferProducer::attachBuffer
203 virtual status_t attachProducerBuffer(int* slot,
204 const sp<GraphicBuffer>& buffer);
205
Andy McFadden753e3412013-04-04 17:09:03 -0700206 // queueBuffer returns a filled buffer to the BufferQueue.
207 //
208 // Additional data is provided in the QueueBufferInput struct. Notably,
209 // a timestamp must be provided for the buffer. The timestamp is in
Daniel Lam6b091c52012-01-22 15:26:27 -0800210 // nanoseconds, and must be monotonically increasing. Its other semantics
Andy McFadden753e3412013-04-04 17:09:03 -0700211 // (zero point, etc) are producer-specific and should be documented by the
212 // producer.
213 //
214 // The caller may provide a fence that signals when all rendering
215 // operations have completed. Alternatively, NO_FENCE may be used,
216 // indicating that the buffer is ready immediately.
217 //
218 // Some values are returned in the output struct: the current settings
219 // for default width and height, the current transform hint, and the
220 // number of queued buffers.
Mathias Agopianf0bc2f12012-04-09 16:14:01 -0700221 virtual status_t queueBuffer(int buf,
222 const QueueBufferInput& input, QueueBufferOutput* output);
223
Andy McFadden753e3412013-04-04 17:09:03 -0700224 // cancelBuffer returns a dequeued buffer to the BufferQueue, but doesn't
225 // queue it for use by the consumer.
226 //
227 // The buffer will not be overwritten until the fence signals. The fence
228 // will usually be the one obtained from dequeueBuffer.
Jesse Hall4c00cc12013-03-15 21:34:30 -0700229 virtual void cancelBuffer(int buf, const sp<Fence>& fence);
Daniel Lam6b091c52012-01-22 15:26:27 -0800230
Dan Stozaf0eaf252014-03-21 13:05:51 -0700231 // See IGraphicBufferProducer::connect
232 virtual status_t connect(const sp<IProducerListener>& listener,
Mathias Agopian365857d2013-09-11 19:35:45 -0700233 int api, bool producerControlledByApp, QueueBufferOutput* output);
Daniel Lam6b091c52012-01-22 15:26:27 -0800234
Andy McFadden753e3412013-04-04 17:09:03 -0700235 // disconnect attempts to disconnect a producer API from the BufferQueue.
236 // Calling this method will cause any subsequent calls to other
Andy McFadden2adaf042012-12-18 09:49:45 -0800237 // IGraphicBufferProducer methods to fail except for getAllocator and connect.
Daniel Lam6b091c52012-01-22 15:26:27 -0800238 // Successfully calling connect after this will allow the other methods to
239 // succeed again.
240 //
241 // This method will fail if the the BufferQueue is not currently
Andy McFadden753e3412013-04-04 17:09:03 -0700242 // connected to the specified producer API.
Daniel Lam6b091c52012-01-22 15:26:27 -0800243 virtual status_t disconnect(int api);
244
Jesse Hall399184a2014-03-03 15:42:54 -0800245 // Attaches a sideband buffer stream to the BufferQueue.
246 //
247 // A sideband stream is a device-specific mechanism for passing buffers
248 // from the producer to the consumer without using dequeueBuffer/
249 // queueBuffer. If a sideband stream is present, the consumer can choose
250 // whether to acquire buffers from the sideband stream or from the queued
251 // buffers.
252 //
253 // Passing NULL or a different stream handle will detach the previous
254 // handle if any.
255 virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
256
Mathias Agopiana4e19522013-07-31 20:09:53 -0700257 /*
258 * IGraphicBufferConsumer interface
259 */
Daniel Lameae59d22012-01-22 15:26:27 -0800260
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700261 // acquireBuffer attempts to acquire ownership of the next pending buffer in
Igor Murashkin7d2d1602013-11-12 18:02:20 -0800262 // the BufferQueue. If no buffer is pending then it returns NO_BUFFER_AVAILABLE. If a
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700263 // buffer is successfully acquired, the information about the buffer is
264 // returned in BufferItem. If the buffer returned had previously been
265 // acquired then the BufferItem::mGraphicBuffer field of buffer is set to
266 // NULL and it is assumed that the consumer still holds a reference to the
267 // buffer.
Andy McFadden1585c4d2013-06-28 13:52:40 -0700268 //
269 // If presentWhen is nonzero, it indicates the time when the buffer will
270 // be displayed on screen. If the buffer's timestamp is farther in the
271 // future, the buffer won't be acquired, and PRESENT_LATER will be
272 // returned. The presentation time is in nanoseconds, and the time base
273 // is CLOCK_MONOTONIC.
Igor Murashkin7d2d1602013-11-12 18:02:20 -0800274 virtual status_t acquireBuffer(BufferItem* buffer, nsecs_t presentWhen);
Daniel Lameae59d22012-01-22 15:26:27 -0800275
Dan Stoza9f3053d2014-03-06 15:14:33 -0800276 // See IGraphicBufferConsumer::detachBuffer
277 virtual status_t detachConsumerBuffer(int slot);
278
279 // See IGraphicBufferConsumer::attachBuffer
280 virtual status_t attachConsumerBuffer(int* slot,
281 const sp<GraphicBuffer>& buffer);
282
Daniel Lameae59d22012-01-22 15:26:27 -0800283 // releaseBuffer releases a buffer slot from the consumer back to the
Andy McFadden753e3412013-04-04 17:09:03 -0700284 // BufferQueue. This may be done while the buffer's contents are still
285 // being accessed. The fence will signal when the buffer is no longer
Lajos Molnarc5d7b7d2013-05-03 14:50:50 -0700286 // in use. frameNumber is used to indentify the exact buffer returned.
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700287 //
Eino-Ville Talvalae41b3182012-04-16 17:54:33 -0700288 // If releaseBuffer returns STALE_BUFFER_SLOT, then the consumer must free
289 // any references to the just-released buffer that it might have, as if it
290 // had received a onBuffersReleased() call with a mask set for the released
291 // buffer.
292 //
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700293 // Note that the dependencies on EGL will be removed once we switch to using
294 // the Android HW Sync HAL.
Mathias Agopiana4e19522013-07-31 20:09:53 -0700295 virtual status_t releaseBuffer(int buf, uint64_t frameNumber,
Lajos Molnarc5d7b7d2013-05-03 14:50:50 -0700296 EGLDisplay display, EGLSyncKHR fence,
Jesse Hallf7857542012-06-14 15:26:33 -0700297 const sp<Fence>& releaseFence);
Daniel Lameae59d22012-01-22 15:26:27 -0800298
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700299 // consumerConnect connects a consumer to the BufferQueue. Only one
300 // consumer may be connected, and when that consumer disconnects the
301 // BufferQueue is placed into the "abandoned" state, causing most
302 // interactions with the BufferQueue by the producer to fail.
Mathias Agopian595264f2013-07-16 22:56:09 -0700303 // controlledByApp indicates whether the consumer is controlled by
304 // the application.
Andy McFadden753e3412013-04-04 17:09:03 -0700305 //
306 // consumer may not be NULL.
Mathias Agopiana4e19522013-07-31 20:09:53 -0700307 virtual status_t consumerConnect(const sp<IConsumerListener>& consumer, bool controlledByApp);
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700308
Daniel Lameae59d22012-01-22 15:26:27 -0800309 // consumerDisconnect disconnects a consumer from the BufferQueue. All
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700310 // buffers will be freed and the BufferQueue is placed in the "abandoned"
311 // state, causing most interactions with the BufferQueue by the producer to
312 // fail.
Mathias Agopiana4e19522013-07-31 20:09:53 -0700313 virtual status_t consumerDisconnect();
Daniel Lameae59d22012-01-22 15:26:27 -0800314
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700315 // getReleasedBuffers sets the value pointed to by slotMask to a bit mask
Andy McFadden753e3412013-04-04 17:09:03 -0700316 // indicating which buffer slots have been released by the BufferQueue
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700317 // but have not yet been released by the consumer.
Andy McFadden753e3412013-04-04 17:09:03 -0700318 //
319 // This should be called from the onBuffersReleased() callback.
Mathias Agopiana4e19522013-07-31 20:09:53 -0700320 virtual status_t getReleasedBuffers(uint32_t* slotMask);
Jamie Gennisfa5b40e2012-03-15 14:01:24 -0700321
Daniel Lameae59d22012-01-22 15:26:27 -0800322 // setDefaultBufferSize is used to set the size of buffers returned by
Andy McFadden753e3412013-04-04 17:09:03 -0700323 // dequeueBuffer when a width and height of zero is requested. Default
324 // is 1x1.
Mathias Agopiana4e19522013-07-31 20:09:53 -0700325 virtual status_t setDefaultBufferSize(uint32_t w, uint32_t h);
Daniel Lameae59d22012-01-22 15:26:27 -0800326
Andy McFadden753e3412013-04-04 17:09:03 -0700327 // setDefaultMaxBufferCount sets the default value for the maximum buffer
328 // count (the initial default is 2). If the producer has requested a
329 // buffer count using setBufferCount, the default buffer count will only
330 // take effect if the producer sets the count back to zero.
331 //
332 // The count must be between 2 and NUM_BUFFER_SLOTS, inclusive.
Mathias Agopiana4e19522013-07-31 20:09:53 -0700333 virtual status_t setDefaultMaxBufferCount(int bufferCount);
Daniel Lameae59d22012-01-22 15:26:27 -0800334
Mathias Agopianad678e12013-07-23 17:28:53 -0700335 // disableAsyncBuffer disables the extra buffer used in async mode
336 // (when both producer and consumer have set their "isControlledByApp"
337 // flag) and has dequeueBuffer() return WOULD_BLOCK instead.
338 //
339 // This can only be called before consumerConnect().
Mathias Agopiana4e19522013-07-31 20:09:53 -0700340 virtual status_t disableAsyncBuffer();
Mathias Agopianad678e12013-07-23 17:28:53 -0700341
Jamie Gennis72f096f2012-08-27 18:48:37 -0700342 // setMaxAcquiredBufferCount sets the maximum number of buffers that can
Andy McFadden753e3412013-04-04 17:09:03 -0700343 // be acquired by the consumer at one time (default 1). This call will
344 // fail if a producer is connected to the BufferQueue.
Mathias Agopiana4e19522013-07-31 20:09:53 -0700345 virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers);
Jamie Gennis72f096f2012-08-27 18:48:37 -0700346
Daniel Lameae59d22012-01-22 15:26:27 -0800347 // setConsumerName sets the name used in logging
Mathias Agopiana4e19522013-07-31 20:09:53 -0700348 virtual void setConsumerName(const String8& name);
Daniel Lameae59d22012-01-22 15:26:27 -0800349
Daniel Lamb2675792012-02-23 14:35:13 -0800350 // setDefaultBufferFormat allows the BufferQueue to create
351 // GraphicBuffers of a defaultFormat if no format is specified
Andy McFadden753e3412013-04-04 17:09:03 -0700352 // in dequeueBuffer. Formats are enumerated in graphics.h; the
353 // initial default is HAL_PIXEL_FORMAT_RGBA_8888.
Mathias Agopiana4e19522013-07-31 20:09:53 -0700354 virtual status_t setDefaultBufferFormat(uint32_t defaultFormat);
Daniel Lamb2675792012-02-23 14:35:13 -0800355
Andy McFadden753e3412013-04-04 17:09:03 -0700356 // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer.
357 // These are merged with the bits passed to dequeueBuffer. The values are
358 // enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER; the default is 0.
Mathias Agopiana4e19522013-07-31 20:09:53 -0700359 virtual status_t setConsumerUsageBits(uint32_t usage);
Daniel Lamb2675792012-02-23 14:35:13 -0800360
Andy McFadden753e3412013-04-04 17:09:03 -0700361 // setTransformHint bakes in rotation to buffers so overlays can be used.
362 // The values are enumerated in window.h, e.g.
363 // NATIVE_WINDOW_TRANSFORM_ROT_90. The default is 0 (no transform).
Mathias Agopiana4e19522013-07-31 20:09:53 -0700364 virtual status_t setTransformHint(uint32_t hint);
Daniel Lameae59d22012-01-22 15:26:27 -0800365
Jesse Hall399184a2014-03-03 15:42:54 -0800366 // Retrieve the BufferQueue's sideband stream, if any.
367 virtual sp<NativeHandle> getSidebandStream() const;
368
Mathias Agopiandb89edc2013-08-02 01:40:18 -0700369 // dump our state in a String
370 virtual void dump(String8& result, const char* prefix) const;
371
Daniel Lameae59d22012-01-22 15:26:27 -0800372private:
Dan Stoza3e96f192014-03-03 10:16:19 -0800373 sp<BufferQueueProducer> mProducer;
374 sp<BufferQueueConsumer> mConsumer;
Daniel Lam6b091c52012-01-22 15:26:27 -0800375};
376
377// ----------------------------------------------------------------------------
378}; // namespace android
379
380#endif // ANDROID_GUI_BUFFERQUEUE_H