2 * Copyright 2016, The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_HARDWARE_GRAPHICS_BUFFERQUEUE_V1_0_H2BGRAPHICBUFFERPRODUCER_H
18 #define ANDROID_HARDWARE_GRAPHICS_BUFFERQUEUE_V1_0_H2BGRAPHICBUFFERPRODUCER_H
20 #include <hidl/MQDescriptor.h>
21 #include <hidl/Status.h>
23 #include <binder/Binder.h>
24 #include <gui/IGraphicBufferProducer.h>
25 #include <gui/IProducerListener.h>
27 #include <hidl/HybridInterface.h>
28 #include <android/hardware/graphics/bufferqueue/1.0/IGraphicBufferProducer.h>
33 namespace bufferqueue {
37 using ::android::hidl::base::V1_0::IBase;
38 using ::android::hardware::hidl_array;
39 using ::android::hardware::hidl_memory;
40 using ::android::hardware::hidl_string;
41 using ::android::hardware::hidl_vec;
42 using ::android::hardware::Return;
43 using ::android::hardware::Void;
46 using ::android::hardware::graphics::common::V1_0::PixelFormat;
47 using ::android::hardware::media::V1_0::AnwBuffer;
49 typedef ::android::hardware::graphics::bufferqueue::V1_0::IGraphicBufferProducer
50 HGraphicBufferProducer;
51 typedef ::android::hardware::graphics::bufferqueue::V1_0::IProducerListener
54 typedef ::android::IGraphicBufferProducer BGraphicBufferProducer;
55 using ::android::BnGraphicBufferProducer;
56 using ::android::IProducerListener;
58 struct H2BGraphicBufferProducer : public ::android::H2BConverter<
59 HGraphicBufferProducer,
60 BGraphicBufferProducer,
61 BnGraphicBufferProducer> {
62 H2BGraphicBufferProducer(sp<HGraphicBufferProducer> const& base) : CBase(base) {}
64 status_t requestBuffer(int slot, sp<GraphicBuffer>* buf) override;
65 status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers) override;
66 status_t setAsyncMode(bool async) override;
67 status_t dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w,
68 uint32_t h, ::android::PixelFormat format, uint64_t usage,
69 FrameEventHistoryDelta* outTimestamps) override;
70 status_t detachBuffer(int slot) override;
71 status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer, sp<Fence>* outFence)
73 status_t attachBuffer(int* outSlot, const sp<GraphicBuffer>& buffer)
75 status_t queueBuffer(int slot,
76 const QueueBufferInput& input,
77 QueueBufferOutput* output) override;
78 status_t cancelBuffer(int slot, const sp<Fence>& fence) override;
79 int query(int what, int* value) override;
80 status_t connect(const sp<IProducerListener>& listener, int api,
81 bool producerControlledByApp, QueueBufferOutput* output) override;
82 status_t disconnect(int api, DisconnectMode mode = DisconnectMode::Api)
84 status_t setSidebandStream(const sp<NativeHandle>& stream) override;
85 void allocateBuffers(uint32_t width, uint32_t height,
86 ::android::PixelFormat format, uint64_t usage) override;
87 status_t allowAllocation(bool allow) override;
88 status_t setGenerationNumber(uint32_t generationNumber) override;
89 String8 getConsumerName() const override;
90 status_t setSharedBufferMode(bool sharedBufferMode) override;
91 status_t setAutoRefresh(bool autoRefresh) override;
92 status_t setDequeueTimeout(nsecs_t timeout) override;
93 status_t getLastQueuedBuffer(sp<GraphicBuffer>* outBuffer,
94 sp<Fence>* outFence, float outTransformMatrix[16]) override;
95 void getFrameTimestamps(FrameEventHistoryDelta* outDelta) override;
96 status_t getUniqueId(uint64_t* outId) const override;
101 } // namespace bufferqueue
102 } // namespace graphics
103 } // namespace hardware
104 } // namespace android
106 #endif // ANDROID_HARDWARE_GRAPHICS_BUFFERQUEUE_V1_0_H2BGRAPHICBUFFERPRODUCER_H