blob: 9eb67b218800f0ade8c1ea9924cabf57a38779d2 [file] [log] [blame]
Fedor Kudasov15e58b42019-07-04 17:52:39 +01001/*
2 * Copyright (C) 2019 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#pragma once
18
19#include <utils/RefBase.h>
20
21#include <ui/PixelFormat.h>
22
23#include <utils/Errors.h>
24
25namespace android {
26
27class BufferItem;
28class Fence;
29class GraphicBuffer;
30
31class IGraphicBufferConsumer : virtual public RefBase {
32public:
33 enum {
34 // Returned by releaseBuffer, after which the consumer must free any references to the
35 // just-released buffer that it might have.
36 STALE_BUFFER_SLOT = 1,
37 // Returned by dequeueBuffer if there are no pending buffers available.
38 NO_BUFFER_AVAILABLE,
39 // Returned by dequeueBuffer if it's too early for the buffer to be acquired.
40 PRESENT_LATER,
41 };
42
43 virtual status_t acquireBuffer(BufferItem* buffer, nsecs_t presentWhen,
44 uint64_t maxFrameNumber = 0) = 0;
45
46 virtual status_t detachBuffer(int slot) = 0;
47
48 virtual status_t getReleasedBuffers(uint64_t* slotMask) = 0;
49
50 virtual status_t setDefaultBufferSize(uint32_t w, uint32_t h) = 0;
51
52 virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers) = 0;
53
54 virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat) = 0;
55
56 virtual status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace) = 0;
57
58 virtual status_t setConsumerUsageBits(uint64_t usage) = 0;
59
60 virtual status_t setConsumerIsProtected(bool isProtected) = 0;
61
62 virtual status_t discardFreeBuffers() = 0;
63};
64
65} // namespace android