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_H2BGRAPHICBUFFERPRODUCER_H 18 #define ANDROID_HARDWARE_GRAPHICS_BUFFERQUEUE_V2_0_H2BGRAPHICBUFFERPRODUCER_H 19 20 #include <gui/IGraphicBufferProducer.h> 21 #include <gui/IProducerListener.h> 22 #include <hidl/HybridInterface.h> 23 #include <ui/Fence.h> 24 25 #include <android/hardware/graphics/bufferqueue/2.0/IGraphicBufferProducer.h> 26 27 namespace android { 28 namespace hardware { 29 namespace graphics { 30 namespace bufferqueue { 31 namespace V2_0 { 32 namespace utils { 33 34 using ::android::BnGraphicBufferProducer; 35 using ::android::IProducerListener; 36 using Fence = ::android::Fence; 37 38 using HGraphicBufferProducer = 39 ::android::hardware::graphics::bufferqueue::V2_0:: 40 IGraphicBufferProducer; 41 using HProducerListener = 42 ::android::hardware::graphics::bufferqueue::V2_0:: 43 IProducerListener; 44 using BGraphicBufferProducer = 45 ::android::IGraphicBufferProducer; 46 47 struct H2BGraphicBufferProducer 48 : public ::android::H2BConverter<HGraphicBufferProducer, 49 BnGraphicBufferProducer> { H2BGraphicBufferProducerH2BGraphicBufferProducer50 explicit H2BGraphicBufferProducer( 51 sp<HGraphicBufferProducer> const& base) : CBase(base) {} 52 53 virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf) override; 54 virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers) override; 55 virtual status_t setAsyncMode(bool async) override; 56 virtual status_t dequeueBuffer( 57 int* slot, sp<Fence>* fence, 58 uint32_t width, uint32_t height, 59 PixelFormat format, uint64_t usage, 60 uint64_t* outBufferAge, 61 FrameEventHistoryDelta* outTimestamps) override; 62 virtual status_t detachBuffer(int slot) override; 63 virtual status_t detachNextBuffer( 64 sp<GraphicBuffer>* outBuffer, 65 sp<Fence>* outFence) override; 66 virtual status_t attachBuffer( 67 int* outSlot, 68 sp<GraphicBuffer> const& buffer) override; 69 virtual status_t queueBuffer( 70 int slot, 71 QueueBufferInput const& input, 72 QueueBufferOutput* output) override; 73 virtual status_t cancelBuffer(int slot, sp<Fence> const& fence) override; 74 virtual int query(int what, int* value) override; 75 virtual status_t connect( 76 sp<IProducerListener> const& listener, 77 int api, 78 bool producerControlledByApp, 79 QueueBufferOutput* output) override; 80 virtual status_t disconnect( 81 int api, 82 DisconnectMode mode = DisconnectMode::Api) override; 83 virtual status_t setSidebandStream(sp<NativeHandle> const& stream) override; 84 virtual void allocateBuffers( 85 uint32_t width, uint32_t height, 86 PixelFormat format, uint64_t usage) override; 87 virtual status_t allowAllocation(bool allow) override; 88 virtual status_t setGenerationNumber(uint32_t generationNumber) override; 89 virtual String8 getConsumerName() const override; 90 virtual status_t setSharedBufferMode(bool sharedBufferMode) override; 91 virtual status_t setAutoRefresh(bool autoRefresh) override; 92 virtual status_t setDequeueTimeout(nsecs_t timeout) override; 93 virtual status_t getLastQueuedBuffer(sp<GraphicBuffer>* outBuffer, 94 sp<Fence>* outFence, float outTransformMatrix[16]) override; 95 virtual void getFrameTimestamps(FrameEventHistoryDelta* outDelta) override; 96 virtual status_t getUniqueId(uint64_t* outId) const override; 97 virtual status_t getConsumerUsage(uint64_t* outUsage) const override; 98 }; 99 100 } // namespace utils 101 } // namespace V2_0 102 } // namespace bufferqueue 103 } // namespace graphics 104 } // namespace hardware 105 } // namespace android 106 107 #endif // ANDROID_HARDWARE_GRAPHICS_BUFFERQUEUE_V2_0_H2BGRAPHICBUFFERPRODUCER_H 108