1 /* 2 * Copyright 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 #ifndef ANDROID_HARDWARE_GRAPHICS_BUFFERQUEUE_V2_0_B2HGRAPHICBUFFERPRODUCER_H 18 #define ANDROID_HARDWARE_GRAPHICS_BUFFERQUEUE_V2_0_B2HGRAPHICBUFFERPRODUCER_H 19 20 #include <android/hardware/graphics/bufferqueue/2.0/IGraphicBufferProducer.h> 21 #include <gui/IGraphicBufferProducer.h> 22 #include <gui/bufferqueue/2.0/types.h> 23 #include <hidl/HidlSupport.h> 24 25 namespace android { 26 namespace hardware { 27 namespace graphics { 28 namespace bufferqueue { 29 namespace V2_0 { 30 namespace utils { 31 32 using HGraphicBufferProducer = 33 ::android::hardware::graphics::bufferqueue::V2_0:: 34 IGraphicBufferProducer; 35 using BGraphicBufferProducer = 36 ::android:: 37 IGraphicBufferProducer; 38 using HProducerListener = 39 ::android::hardware::graphics::bufferqueue::V2_0:: 40 IProducerListener; 41 42 using ::android::hardware::Return; 43 using ::android::hardware::hidl_handle; 44 using ::android::hardware::hidl_string; 45 using ::android::hardware::hidl_vec; 46 47 using ::android::hardware::graphics::common::V1_2::HardwareBuffer; 48 49 class B2HGraphicBufferProducer : public HGraphicBufferProducer { 50 public: 51 B2HGraphicBufferProducer(sp<BGraphicBufferProducer> const& base); 52 53 virtual Return<HStatus> setMaxDequeuedBufferCount( 54 int32_t maxDequeuedBuffers) override; 55 56 virtual Return<void> requestBuffer( 57 int32_t slot, 58 requestBuffer_cb _hidl_cb) override; 59 60 virtual Return<HStatus> setAsyncMode(bool async) override; 61 62 virtual Return<void> dequeueBuffer( 63 DequeueBufferInput const& input, 64 dequeueBuffer_cb _hidl_cb) override; 65 66 virtual Return<HStatus> detachBuffer(int32_t slot) override; 67 68 virtual Return<void> detachNextBuffer( 69 detachNextBuffer_cb _hidl_cb) override; 70 71 virtual Return<void> attachBuffer( 72 HardwareBuffer const& buffer, 73 uint32_t generationNumber, 74 attachBuffer_cb _hidl_cb) override; 75 76 virtual Return<void> queueBuffer( 77 int32_t slot, 78 QueueBufferInput const& input, 79 queueBuffer_cb _hidl_cb) override; 80 81 virtual Return<HStatus> cancelBuffer( 82 int32_t slot, 83 hidl_handle const& fence) override; 84 85 virtual Return<void> query(int32_t what, query_cb _hidl_cb) override; 86 87 virtual Return<void> connect( 88 sp<HProducerListener> const& listener, 89 HConnectionType api, 90 bool producerControlledByApp, 91 connect_cb _hidl_cb) override; 92 93 virtual Return<HStatus> disconnect(HConnectionType api) override; 94 95 virtual Return<HStatus> allocateBuffers( 96 uint32_t width, uint32_t height, 97 uint32_t format, uint64_t usage) override; 98 99 virtual Return<HStatus> allowAllocation(bool allow) override; 100 101 virtual Return<HStatus> setGenerationNumber(uint32_t generationNumber) override; 102 103 virtual Return<HStatus> setDequeueTimeout(int64_t timeoutNs) override; 104 105 virtual Return<uint64_t> getUniqueId() override; 106 107 virtual Return<void> getConsumerName(getConsumerName_cb _hidl_cb) override; 108 109 protected: 110 sp<BGraphicBufferProducer> mBase; 111 }; 112 113 114 } // namespace utils 115 } // namespace V2_0 116 } // namespace bufferqueue 117 } // namespace graphics 118 } // namespace hardware 119 } // namespace android 120 121 #endif // ANDROID_HARDWARE_GRAPHICS_BUFFERQUEUE_V2_0_B2HGRAPHICBUFFERPRODUCER_H 122