blob: ec304378c6c43e803c73fcaf2db2ea118c036ba2 [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#include <gui/BufferQueue.h>
18
19namespace android {
20
21class HostBufferQueue : public IGraphicBufferProducer, public IGraphicBufferConsumer {
22public:
23 HostBufferQueue() : mWidth(0), mHeight(0) { }
24
25 virtual status_t setConsumerIsProtected(bool isProtected) { return OK; }
26
27 virtual status_t detachBuffer(int slot) { return OK; }
28
29 virtual status_t getReleasedBuffers(uint64_t* slotMask) { return OK; }
30
31 virtual status_t setDefaultBufferSize(uint32_t w, uint32_t h) {
32 mWidth = w;
33 mHeight = h;
34 mBuffer = sp<GraphicBuffer>(new GraphicBuffer(mWidth, mHeight));
35 return OK;
36 }
37
38 virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat) { return OK; }
39
40 virtual status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace) { return OK; }
41
42 virtual status_t discardFreeBuffers() { return OK; }
43
44 virtual status_t acquireBuffer(BufferItem* buffer, nsecs_t presentWhen,
45 uint64_t maxFrameNumber = 0) {
46 buffer->mGraphicBuffer = mBuffer;
47 buffer->mSlot = 0;
48 return OK;
49 }
50
51 virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers) { return OK; }
52
53 virtual status_t setConsumerUsageBits(uint64_t usage) { return OK; }
54private:
55 sp<GraphicBuffer> mBuffer;
56 uint32_t mWidth;
57 uint32_t mHeight;
58};
59
60void BufferQueue::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
61 sp<IGraphicBufferConsumer>* outConsumer) {
62
63 sp<HostBufferQueue> obj(new HostBufferQueue());
64
65 *outProducer = obj;
66 *outConsumer = obj;
67}
68
69} // namespace android