blob: 441cf5079fec04957585966da66280e05c25d426 [file] [log] [blame]
Dan Stozab9b08832014-03-13 11:55:57 -07001/*
2 * Copyright 2014 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_MONITORED_PRODUCER_H
18#define ANDROID_MONITORED_PRODUCER_H
19
20#include <gui/IGraphicBufferProducer.h>
21
22namespace android {
23
Dan Stozaf0eaf252014-03-21 13:05:51 -070024class IProducerListener;
Dan Stozab9b08832014-03-13 11:55:57 -070025class NativeHandle;
26class SurfaceFlinger;
27
28// MonitoredProducer wraps an IGraphicBufferProducer so that SurfaceFlinger will
29// be notified upon its destruction
Dan Stozab3d0bdf2014-04-07 16:33:59 -070030class MonitoredProducer : public IGraphicBufferProducer {
Dan Stozab9b08832014-03-13 11:55:57 -070031public:
Dan Stozab3d0bdf2014-04-07 16:33:59 -070032 MonitoredProducer(const sp<IGraphicBufferProducer>& producer,
Dan Stozab9b08832014-03-13 11:55:57 -070033 const sp<SurfaceFlinger>& flinger);
34 virtual ~MonitoredProducer();
35
36 // From IGraphicBufferProducer
37 virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
Pablo Ceballosfa455352015-08-12 17:47:47 -070038 virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers);
39 virtual status_t setAsyncMode(bool async);
Pablo Ceballos567dbbb2015-08-26 18:59:08 -070040 virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w,
41 uint32_t h, PixelFormat format, uint32_t usage);
Dan Stozab9b08832014-03-13 11:55:57 -070042 virtual status_t detachBuffer(int slot);
Dan Stozad9822a32014-03-28 15:25:31 -070043 virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
44 sp<Fence>* outFence);
Dan Stozab9b08832014-03-13 11:55:57 -070045 virtual status_t attachBuffer(int* outSlot,
46 const sp<GraphicBuffer>& buffer);
47 virtual status_t queueBuffer(int slot, const QueueBufferInput& input,
48 QueueBufferOutput* output);
Pablo Ceballos583b1b32015-09-03 18:23:52 -070049 virtual status_t cancelBuffer(int slot, const sp<Fence>& fence);
Dan Stozab9b08832014-03-13 11:55:57 -070050 virtual int query(int what, int* value);
Dan Stozaf0eaf252014-03-21 13:05:51 -070051 virtual status_t connect(const sp<IProducerListener>& token, int api,
Dan Stozab9b08832014-03-13 11:55:57 -070052 bool producerControlledByApp, QueueBufferOutput* output);
53 virtual status_t disconnect(int api);
54 virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
Pablo Ceballos567dbbb2015-08-26 18:59:08 -070055 virtual void allocateBuffers(uint32_t width, uint32_t height,
Dan Stoza3be1c6b2014-11-18 10:24:03 -080056 PixelFormat format, uint32_t usage);
Dan Stoza9de72932015-04-16 17:28:43 -070057 virtual status_t allowAllocation(bool allow);
Dan Stoza812ed062015-06-02 15:45:22 -070058 virtual status_t setGenerationNumber(uint32_t generationNumber);
Dan Stozac6f30bd2015-06-08 09:32:50 -070059 virtual String8 getConsumerName() const override;
Dan Stoza7dde5992015-05-22 09:51:44 -070060 virtual uint64_t getNextFrameNumber() const override;
Dan Stoza127fc632015-06-30 13:43:32 -070061 virtual status_t setDequeueTimeout(nsecs_t timeout) override;
Dan Stozab3d0bdf2014-04-07 16:33:59 -070062 virtual IBinder* onAsBinder();
Pablo Ceballos3559fbf2016-03-17 15:50:23 -070063 virtual status_t setSharedBufferMode(bool sharedBufferMode) override;
Pablo Ceballosff95aab2016-01-13 17:09:58 -080064 virtual status_t setAutoRefresh(bool autoRefresh) override;
Dan Stozab9b08832014-03-13 11:55:57 -070065
66private:
Dan Stozab3d0bdf2014-04-07 16:33:59 -070067 sp<IGraphicBufferProducer> mProducer;
Dan Stozab9b08832014-03-13 11:55:57 -070068 sp<SurfaceFlinger> mFlinger;
69};
70
71}; // namespace android
72
73#endif // ANDROID_MONITORED_PRODUCER_H