• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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_SURFACE_H
18 #define ANDROID_GUI_SURFACE_H
19 
20 #include <gui/BufferQueueDefs.h>
21 #include <gui/HdrMetadata.h>
22 #include <gui/IGraphicBufferProducer.h>
23 #include <gui/IProducerListener.h>
24 #include <system/window.h>
25 #include <ui/ANativeObjectBase.h>
26 #include <ui/GraphicTypes.h>
27 #include <ui/Region.h>
28 #include <utils/Condition.h>
29 #include <utils/Mutex.h>
30 #include <utils/RefBase.h>
31 
32 #include <shared_mutex>
33 #include <unordered_set>
34 
35 namespace android {
36 
37 class ISurfaceComposer;
38 
39 /* This is the same as ProducerListener except that onBuffersDiscarded is
40  * called with a vector of graphic buffers instead of buffer slots.
41  */
42 class SurfaceListener : public virtual RefBase
43 {
44 public:
45     SurfaceListener() = default;
46     virtual ~SurfaceListener() = default;
47 
48     virtual void onBufferReleased() = 0;
49     virtual bool needsReleaseNotify() = 0;
50 
51     virtual void onBuffersDiscarded(const std::vector<sp<GraphicBuffer>>& buffers) = 0;
52 };
53 
54 /*
55  * An implementation of ANativeWindow that feeds graphics buffers into a
56  * BufferQueue.
57  *
58  * This is typically used by programs that want to render frames through
59  * some means (maybe OpenGL, a software renderer, or a hardware decoder)
60  * and have the frames they create forwarded to SurfaceFlinger for
61  * compositing.  For example, a video decoder could render a frame and call
62  * eglSwapBuffers(), which invokes ANativeWindow callbacks defined by
63  * Surface.  Surface then forwards the buffers through Binder IPC
64  * to the BufferQueue's producer interface, providing the new frame to a
65  * consumer such as GLConsumer.
66  */
67 class Surface
68     : public ANativeObjectBase<ANativeWindow, Surface, RefBase>
69 {
70 public:
71 
72     /*
73      * creates a Surface from the given IGraphicBufferProducer (which concrete
74      * implementation is a BufferQueue).
75      *
76      * Surface is mainly state-less while it's disconnected, it can be
77      * viewed as a glorified IGraphicBufferProducer holder. It's therefore
78      * safe to create other Surfaces from the same IGraphicBufferProducer.
79      *
80      * However, once a Surface is connected, it'll prevent other Surfaces
81      * referring to the same IGraphicBufferProducer to become connected and
82      * therefore prevent them to be used as actual producers of buffers.
83      *
84      * the controlledByApp flag indicates that this Surface (producer) is
85      * controlled by the application. This flag is used at connect time.
86      */
87     explicit Surface(const sp<IGraphicBufferProducer>& bufferProducer,
88             bool controlledByApp = false);
89 
90     /* getIGraphicBufferProducer() returns the IGraphicBufferProducer this
91      * Surface was created with. Usually it's an error to use the
92      * IGraphicBufferProducer while the Surface is connected.
93      */
94     sp<IGraphicBufferProducer> getIGraphicBufferProducer() const;
95 
96     /* convenience function to check that the given surface is non NULL as
97      * well as its IGraphicBufferProducer */
isValid(const sp<Surface> & surface)98     static bool isValid(const sp<Surface>& surface) {
99         return surface != nullptr && surface->getIGraphicBufferProducer() != nullptr;
100     }
101 
102     /* Attaches a sideband buffer stream to the Surface's IGraphicBufferProducer.
103      *
104      * A sideband stream is a device-specific mechanism for passing buffers
105      * from the producer to the consumer without using dequeueBuffer/
106      * queueBuffer. If a sideband stream is present, the consumer can choose
107      * whether to acquire buffers from the sideband stream or from the queued
108      * buffers.
109      *
110      * Passing NULL or a different stream handle will detach the previous
111      * handle if any.
112      */
113     void setSidebandStream(const sp<NativeHandle>& stream);
114 
115     /* Allocates buffers based on the current dimensions/format.
116      *
117      * This function will allocate up to the maximum number of buffers
118      * permitted by the current BufferQueue configuration. It will use the
119      * default format and dimensions. This is most useful to avoid an allocation
120      * delay during dequeueBuffer. If there are already the maximum number of
121      * buffers allocated, this function has no effect.
122      */
123     void allocateBuffers();
124 
125     /* Sets the generation number on the IGraphicBufferProducer and updates the
126      * generation number on any buffers attached to the Surface after this call.
127      * See IGBP::setGenerationNumber for more information. */
128     status_t setGenerationNumber(uint32_t generationNumber);
129 
130     // See IGraphicBufferProducer::getConsumerName
131     String8 getConsumerName() const;
132 
133     // See IGraphicBufferProducer::getNextFrameNumber
134     uint64_t getNextFrameNumber() const;
135 
136     /* Set the scaling mode to be used with a Surface.
137      * See NATIVE_WINDOW_SET_SCALING_MODE and its parameters
138      * in <system/window.h>. */
139     int setScalingMode(int mode);
140 
141     // See IGraphicBufferProducer::setDequeueTimeout
142     status_t setDequeueTimeout(nsecs_t timeout);
143 
144     /*
145      * Wait for frame number to increase past lastFrame for at most
146      * timeoutNs. Useful for one thread to wait for another unknown
147      * thread to queue a buffer.
148      */
149     bool waitForNextFrame(uint64_t lastFrame, nsecs_t timeout);
150 
151     // See IGraphicBufferProducer::getLastQueuedBuffer
152     // See GLConsumer::getTransformMatrix for outTransformMatrix format
153     status_t getLastQueuedBuffer(sp<GraphicBuffer>* outBuffer,
154             sp<Fence>* outFence, float outTransformMatrix[16]);
155 
156     status_t getDisplayRefreshCycleDuration(nsecs_t* outRefreshDuration);
157 
158     /* Enables or disables frame timestamp tracking. It is disabled by default
159      * to avoid overhead during queue and dequeue for applications that don't
160      * need the feature. If disabled, calls to getFrameTimestamps will fail.
161      */
162     void enableFrameTimestamps(bool enable);
163 
164     status_t getCompositorTiming(
165             nsecs_t* compositeDeadline, nsecs_t* compositeInterval,
166             nsecs_t* compositeToPresentLatency);
167 
168     // See IGraphicBufferProducer::getFrameTimestamps
169     status_t getFrameTimestamps(uint64_t frameNumber,
170             nsecs_t* outRequestedPresentTime, nsecs_t* outAcquireTime,
171             nsecs_t* outLatchTime, nsecs_t* outFirstRefreshStartTime,
172             nsecs_t* outLastRefreshStartTime, nsecs_t* outGlCompositionDoneTime,
173             nsecs_t* outDisplayPresentTime, nsecs_t* outDequeueReadyTime,
174             nsecs_t* outReleaseTime);
175 
176     status_t getWideColorSupport(bool* supported);
177     status_t getHdrSupport(bool* supported);
178 
179     status_t getUniqueId(uint64_t* outId) const;
180     status_t getConsumerUsage(uint64_t* outUsage) const;
181 
182     status_t setFrameRate(float frameRate, int8_t compatibility);
183 
184 protected:
185     virtual ~Surface();
186 
187     // Virtual for testing.
188     virtual sp<ISurfaceComposer> composerService() const;
189     virtual nsecs_t now() const;
190 
191 private:
192     // can't be copied
193     Surface& operator = (const Surface& rhs);
194     Surface(const Surface& rhs);
195 
196     // ANativeWindow hooks
197     static int hook_cancelBuffer(ANativeWindow* window,
198             ANativeWindowBuffer* buffer, int fenceFd);
199     static int hook_dequeueBuffer(ANativeWindow* window,
200             ANativeWindowBuffer** buffer, int* fenceFd);
201     static int hook_perform(ANativeWindow* window, int operation, ...);
202     static int hook_query(const ANativeWindow* window, int what, int* value);
203     static int hook_queueBuffer(ANativeWindow* window,
204             ANativeWindowBuffer* buffer, int fenceFd);
205     static int hook_setSwapInterval(ANativeWindow* window, int interval);
206 
207     static int cancelBufferInternal(ANativeWindow* window, ANativeWindowBuffer* buffer,
208                                     int fenceFd);
209     static int dequeueBufferInternal(ANativeWindow* window, ANativeWindowBuffer** buffer,
210                                      int* fenceFd);
211     static int performInternal(ANativeWindow* window, int operation, va_list args);
212     static int queueBufferInternal(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd);
213     static int queryInternal(const ANativeWindow* window, int what, int* value);
214 
215     static int hook_cancelBuffer_DEPRECATED(ANativeWindow* window,
216             ANativeWindowBuffer* buffer);
217     static int hook_dequeueBuffer_DEPRECATED(ANativeWindow* window,
218             ANativeWindowBuffer** buffer);
219     static int hook_lockBuffer_DEPRECATED(ANativeWindow* window,
220             ANativeWindowBuffer* buffer);
221     static int hook_queueBuffer_DEPRECATED(ANativeWindow* window,
222             ANativeWindowBuffer* buffer);
223 
224     int dispatchConnect(va_list args);
225     int dispatchDisconnect(va_list args);
226     int dispatchSetBufferCount(va_list args);
227     int dispatchSetBuffersGeometry(va_list args);
228     int dispatchSetBuffersDimensions(va_list args);
229     int dispatchSetBuffersUserDimensions(va_list args);
230     int dispatchSetBuffersFormat(va_list args);
231     int dispatchSetScalingMode(va_list args);
232     int dispatchSetBuffersTransform(va_list args);
233     int dispatchSetBuffersStickyTransform(va_list args);
234     int dispatchSetBuffersTimestamp(va_list args);
235     int dispatchSetCrop(va_list args);
236     int dispatchSetUsage(va_list args);
237     int dispatchSetUsage64(va_list args);
238     int dispatchLock(va_list args);
239     int dispatchUnlockAndPost(va_list args);
240     int dispatchSetSidebandStream(va_list args);
241     int dispatchSetBuffersDataSpace(va_list args);
242     int dispatchSetBuffersSmpte2086Metadata(va_list args);
243     int dispatchSetBuffersCta8613Metadata(va_list args);
244     int dispatchSetBuffersHdr10PlusMetadata(va_list args);
245     int dispatchSetSurfaceDamage(va_list args);
246     int dispatchSetSharedBufferMode(va_list args);
247     int dispatchSetAutoRefresh(va_list args);
248     int dispatchGetDisplayRefreshCycleDuration(va_list args);
249     int dispatchGetNextFrameId(va_list args);
250     int dispatchEnableFrameTimestamps(va_list args);
251     int dispatchGetCompositorTiming(va_list args);
252     int dispatchGetFrameTimestamps(va_list args);
253     int dispatchGetWideColorSupport(va_list args);
254     int dispatchGetHdrSupport(va_list args);
255     int dispatchGetConsumerUsage64(va_list args);
256     int dispatchSetAutoPrerotation(va_list args);
257     int dispatchGetLastDequeueStartTime(va_list args);
258     int dispatchSetDequeueTimeout(va_list args);
259     int dispatchGetLastDequeueDuration(va_list args);
260     int dispatchGetLastQueueDuration(va_list args);
261     int dispatchSetFrameRate(va_list args);
262     int dispatchAddCancelInterceptor(va_list args);
263     int dispatchAddDequeueInterceptor(va_list args);
264     int dispatchAddPerformInterceptor(va_list args);
265     int dispatchAddQueueInterceptor(va_list args);
266     int dispatchAddQueryInterceptor(va_list args);
267     int dispatchGetLastQueuedBuffer(va_list args);
268     bool transformToDisplayInverse();
269 
270 protected:
271     virtual int dequeueBuffer(ANativeWindowBuffer** buffer, int* fenceFd);
272     virtual int cancelBuffer(ANativeWindowBuffer* buffer, int fenceFd);
273     virtual int queueBuffer(ANativeWindowBuffer* buffer, int fenceFd);
274     virtual int perform(int operation, va_list args);
275     virtual int setSwapInterval(int interval);
276 
277     virtual int lockBuffer_DEPRECATED(ANativeWindowBuffer* buffer);
278 
279     virtual int connect(int api);
280     virtual int setBufferCount(int bufferCount);
281     virtual int setBuffersUserDimensions(uint32_t width, uint32_t height);
282     virtual int setBuffersFormat(PixelFormat format);
283     virtual int setBuffersTransform(uint32_t transform);
284     virtual int setBuffersStickyTransform(uint32_t transform);
285     virtual int setBuffersTimestamp(int64_t timestamp);
286     virtual int setBuffersDataSpace(ui::Dataspace dataSpace);
287     virtual int setBuffersSmpte2086Metadata(const android_smpte2086_metadata* metadata);
288     virtual int setBuffersCta8613Metadata(const android_cta861_3_metadata* metadata);
289     virtual int setBuffersHdr10PlusMetadata(const size_t size, const uint8_t* metadata);
290     virtual int setCrop(Rect const* rect);
291     virtual int setUsage(uint64_t reqUsage);
292     virtual void setSurfaceDamage(android_native_rect_t* rects, size_t numRects);
293 
294 public:
295     virtual int disconnect(int api,
296             IGraphicBufferProducer::DisconnectMode mode =
297                     IGraphicBufferProducer::DisconnectMode::Api);
298 
299     virtual int setMaxDequeuedBufferCount(int maxDequeuedBuffers);
300     virtual int setAsyncMode(bool async);
301     virtual int setSharedBufferMode(bool sharedBufferMode);
302     virtual int setAutoRefresh(bool autoRefresh);
303     virtual int setAutoPrerotation(bool autoPrerotation);
304     virtual int setBuffersDimensions(uint32_t width, uint32_t height);
305     virtual int lock(ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds);
306     virtual int unlockAndPost();
307     virtual int query(int what, int* value) const;
308 
309     virtual int connect(int api, const sp<IProducerListener>& listener);
310 
311     // When reportBufferRemoval is true, clients must call getAndFlushRemovedBuffers to fetch
312     // GraphicBuffers removed from this surface after a dequeueBuffer, detachNextBuffer or
313     // attachBuffer call. This allows clients with their own buffer caches to free up buffers no
314     // longer in use by this surface.
315     virtual int connect(
316             int api, const sp<IProducerListener>& listener,
317             bool reportBufferRemoval);
318     virtual int detachNextBuffer(sp<GraphicBuffer>* outBuffer,
319             sp<Fence>* outFence);
320     virtual int attachBuffer(ANativeWindowBuffer*);
321 
322     virtual int connect(
323             int api, bool reportBufferRemoval,
324             const sp<SurfaceListener>& sListener);
325 
326     // When client connects to Surface with reportBufferRemoval set to true, any buffers removed
327     // from this Surface will be collected and returned here. Once this method returns, these
328     // buffers will no longer be referenced by this Surface unless they are attached to this
329     // Surface later. The list of removed buffers will only be stored until the next dequeueBuffer,
330     // detachNextBuffer, or attachBuffer call.
331     status_t getAndFlushRemovedBuffers(std::vector<sp<GraphicBuffer>>* out);
332 
333     ui::Dataspace getBuffersDataSpace();
334 
335     static status_t attachAndQueueBufferWithDataspace(Surface* surface, sp<GraphicBuffer> buffer,
336                                                       ui::Dataspace dataspace);
337 
338 protected:
339     enum { NUM_BUFFER_SLOTS = BufferQueueDefs::NUM_BUFFER_SLOTS };
340     enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 };
341 
342     class ProducerListenerProxy : public BnProducerListener {
343     public:
ProducerListenerProxy(wp<Surface> parent,sp<SurfaceListener> listener)344         ProducerListenerProxy(wp<Surface> parent, sp<SurfaceListener> listener)
345                : mParent(parent), mSurfaceListener(listener) {}
~ProducerListenerProxy()346         virtual ~ProducerListenerProxy() {}
347 
onBufferReleased()348         virtual void onBufferReleased() {
349             mSurfaceListener->onBufferReleased();
350         }
351 
needsReleaseNotify()352         virtual bool needsReleaseNotify() {
353             return mSurfaceListener->needsReleaseNotify();
354         }
355 
356         virtual void onBuffersDiscarded(const std::vector<int32_t>& slots);
357     private:
358         wp<Surface> mParent;
359         sp<SurfaceListener> mSurfaceListener;
360     };
361 
362     void querySupportedTimestampsLocked() const;
363 
364     void freeAllBuffers();
365     int getSlotFromBufferLocked(android_native_buffer_t* buffer) const;
366 
367     struct BufferSlot {
368         sp<GraphicBuffer> buffer;
369         Region dirtyRegion;
370     };
371 
372     // mSurfaceTexture is the interface to the surface texture server. All
373     // operations on the surface texture client ultimately translate into
374     // interactions with the server using this interface.
375     // TODO: rename to mBufferProducer
376     sp<IGraphicBufferProducer> mGraphicBufferProducer;
377 
378     // mSlots stores the buffers that have been allocated for each buffer slot.
379     // It is initialized to null pointers, and gets filled in with the result of
380     // IGraphicBufferProducer::requestBuffer when the client dequeues a buffer from a
381     // slot that has not yet been used. The buffer allocated to a slot will also
382     // be replaced if the requested buffer usage or geometry differs from that
383     // of the buffer allocated to a slot.
384     BufferSlot mSlots[NUM_BUFFER_SLOTS];
385 
386     // mReqWidth is the buffer width that will be requested at the next dequeue
387     // operation. It is initialized to 1.
388     uint32_t mReqWidth;
389 
390     // mReqHeight is the buffer height that will be requested at the next
391     // dequeue operation. It is initialized to 1.
392     uint32_t mReqHeight;
393 
394     // mReqFormat is the buffer pixel format that will be requested at the next
395     // deuque operation. It is initialized to PIXEL_FORMAT_RGBA_8888.
396     PixelFormat mReqFormat;
397 
398     // mReqUsage is the set of buffer usage flags that will be requested
399     // at the next deuque operation. It is initialized to 0.
400     uint64_t mReqUsage;
401 
402     // mTimestamp is the timestamp that will be used for the next buffer queue
403     // operation. It defaults to NATIVE_WINDOW_TIMESTAMP_AUTO, which means that
404     // a timestamp is auto-generated when queueBuffer is called.
405     int64_t mTimestamp;
406 
407     // mDataSpace is the buffer dataSpace that will be used for the next buffer
408     // queue operation. It defaults to Dataspace::UNKNOWN, which
409     // means that the buffer contains some type of color data.
410     ui::Dataspace mDataSpace;
411 
412     // mHdrMetadata is the HDR metadata that will be used for the next buffer
413     // queue operation.  There is no HDR metadata by default.
414     HdrMetadata mHdrMetadata;
415 
416     // mCrop is the crop rectangle that will be used for the next buffer
417     // that gets queued. It is set by calling setCrop.
418     Rect mCrop;
419 
420     // mScalingMode is the scaling mode that will be used for the next
421     // buffers that get queued. It is set by calling setScalingMode.
422     int mScalingMode;
423 
424     // mTransform is the transform identifier that will be used for the next
425     // buffer that gets queued. It is set by calling setTransform.
426     uint32_t mTransform;
427 
428     // mStickyTransform is a transform that is applied on top of mTransform
429     // in each buffer that is queued.  This is typically used to force the
430     // compositor to apply a transform, and will prevent the transform hint
431     // from being set by the compositor.
432     uint32_t mStickyTransform;
433 
434     // mDefaultWidth is default width of the buffers, regardless of the
435     // native_window_set_buffers_dimensions call.
436     uint32_t mDefaultWidth;
437 
438     // mDefaultHeight is default height of the buffers, regardless of the
439     // native_window_set_buffers_dimensions call.
440     uint32_t mDefaultHeight;
441 
442     // mUserWidth, if non-zero, is an application-specified override
443     // of mDefaultWidth.  This is lower priority than the width set by
444     // native_window_set_buffers_dimensions.
445     uint32_t mUserWidth;
446 
447     // mUserHeight, if non-zero, is an application-specified override
448     // of mDefaultHeight.  This is lower priority than the height set
449     // by native_window_set_buffers_dimensions.
450     uint32_t mUserHeight;
451 
452     // mTransformHint is the transform probably applied to buffers of this
453     // window. this is only a hint, actual transform may differ.
454     uint32_t mTransformHint;
455 
456     // mProducerControlledByApp whether this buffer producer is controlled
457     // by the application
458     bool mProducerControlledByApp;
459 
460     // mSwapIntervalZero set if we should drop buffers at queue() time to
461     // achieve an asynchronous swap interval
462     bool mSwapIntervalZero;
463 
464     // mConsumerRunningBehind whether the consumer is running more than
465     // one buffer behind the producer.
466     mutable bool mConsumerRunningBehind;
467 
468     // mMutex is the mutex used to prevent concurrent access to the member
469     // variables of Surface objects. It must be locked whenever the
470     // member variables are accessed.
471     mutable Mutex mMutex;
472 
473     // mInterceptorMutex is the mutex guarding interceptors.
474     mutable std::shared_mutex mInterceptorMutex;
475 
476     ANativeWindow_cancelBufferInterceptor mCancelInterceptor = nullptr;
477     void* mCancelInterceptorData = nullptr;
478     ANativeWindow_dequeueBufferInterceptor mDequeueInterceptor = nullptr;
479     void* mDequeueInterceptorData = nullptr;
480     ANativeWindow_performInterceptor mPerformInterceptor = nullptr;
481     void* mPerformInterceptorData = nullptr;
482     ANativeWindow_queueBufferInterceptor mQueueInterceptor = nullptr;
483     void* mQueueInterceptorData = nullptr;
484     ANativeWindow_queryInterceptor mQueryInterceptor = nullptr;
485     void* mQueryInterceptorData = nullptr;
486 
487     // must be used from the lock/unlock thread
488     sp<GraphicBuffer>           mLockedBuffer;
489     sp<GraphicBuffer>           mPostedBuffer;
490     bool                        mConnectedToCpu;
491 
492     // When a CPU producer is attached, this reflects the region that the
493     // producer wished to update as well as whether the Surface was able to copy
494     // the previous buffer back to allow a partial update.
495     //
496     // When a non-CPU producer is attached, this reflects the surface damage
497     // (the change since the previous frame) passed in by the producer.
498     Region mDirtyRegion;
499 
500     // mBufferAge tracks the age of the contents of the most recently dequeued
501     // buffer as the number of frames that have elapsed since it was last queued
502     uint64_t mBufferAge;
503 
504     // Stores the current generation number. See setGenerationNumber and
505     // IGraphicBufferProducer::setGenerationNumber for more information.
506     uint32_t mGenerationNumber;
507 
508     // Caches the values that have been passed to the producer.
509     bool mSharedBufferMode;
510     bool mAutoRefresh;
511     bool mAutoPrerotation;
512 
513     // If in shared buffer mode and auto refresh is enabled, store the shared
514     // buffer slot and return it for all calls to queue/dequeue without going
515     // over Binder.
516     int mSharedBufferSlot;
517 
518     // This is true if the shared buffer has already been queued/canceled. It's
519     // used to prevent a mismatch between the number of queue/dequeue calls.
520     bool mSharedBufferHasBeenQueued;
521 
522     // These are used to satisfy the NATIVE_WINDOW_LAST_*_DURATION queries
523     nsecs_t mLastDequeueDuration = 0;
524     nsecs_t mLastQueueDuration = 0;
525 
526     // Stores the time right before we call IGBP::dequeueBuffer
527     nsecs_t mLastDequeueStartTime = 0;
528 
529     Condition mQueueBufferCondition;
530 
531     uint64_t mNextFrameNumber = 1;
532     uint64_t mLastFrameNumber = 0;
533 
534     // Mutable because ANativeWindow::query needs this class const.
535     mutable bool mQueriedSupportedTimestamps;
536     mutable bool mFrameTimestampsSupportsPresent;
537 
538     // A cached copy of the FrameEventHistory maintained by the consumer.
539     bool mEnableFrameTimestamps = false;
540     std::unique_ptr<ProducerFrameEventHistory> mFrameEventHistory;
541 
542     bool mReportRemovedBuffers = false;
543     std::vector<sp<GraphicBuffer>> mRemovedBuffers;
544     int mMaxBufferCount;
545 
546     sp<IProducerListener> mListenerProxy;
547 
548     // Get and flush the buffers of given slots, if the buffer in the slot
549     // is currently dequeued then it won't be flushed and won't be returned
550     // in outBuffers.
551     status_t getAndFlushBuffersFromSlots(const std::vector<int32_t>& slots,
552             std::vector<sp<GraphicBuffer>>* outBuffers);
553 
554     // Buffers that are successfully dequeued/attached and handed to clients
555     std::unordered_set<int> mDequeuedSlots;
556 };
557 
558 } // namespace android
559 
560 #endif  // ANDROID_GUI_SURFACE_H
561