Home | History | Annotate | Download | only in 1.0
      1 /*
      2  * Copyright 2016, 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_V1_0_H2BGRAPHICBUFFERPRODUCER_H
     18 #define ANDROID_HARDWARE_GRAPHICS_BUFFERQUEUE_V1_0_H2BGRAPHICBUFFERPRODUCER_H
     19 
     20 #include <hidl/MQDescriptor.h>
     21 #include <hidl/Status.h>
     22 
     23 #include <binder/Binder.h>
     24 #include <gui/IGraphicBufferProducer.h>
     25 #include <gui/IProducerListener.h>
     26 
     27 #include <hidl/HybridInterface.h>
     28 #include <android/hardware/graphics/bufferqueue/1.0/IGraphicBufferProducer.h>
     29 
     30 namespace android {
     31 namespace hardware {
     32 namespace graphics {
     33 namespace bufferqueue {
     34 namespace V1_0 {
     35 namespace utils {
     36 
     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;
     44 using ::android::sp;
     45 
     46 using ::android::hardware::graphics::common::V1_0::PixelFormat;
     47 using ::android::hardware::media::V1_0::AnwBuffer;
     48 
     49 typedef ::android::hardware::graphics::bufferqueue::V1_0::IGraphicBufferProducer
     50         HGraphicBufferProducer;
     51 typedef ::android::hardware::graphics::bufferqueue::V1_0::IProducerListener
     52         HProducerListener;
     53 
     54 typedef ::android::IGraphicBufferProducer BGraphicBufferProducer;
     55 using ::android::BnGraphicBufferProducer;
     56 using ::android::IProducerListener;
     57 
     58 struct H2BGraphicBufferProducer : public ::android::H2BConverter<
     59         HGraphicBufferProducer,
     60         BGraphicBufferProducer,
     61         BnGraphicBufferProducer> {
     62     H2BGraphicBufferProducer(sp<HGraphicBufferProducer> const& base) : CBase(base) {}
     63 
     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, uint32_t h,
     68                            ::android::PixelFormat format, uint64_t usage, uint64_t* outBufferAge,
     69                            FrameEventHistoryDelta* outTimestamps) override;
     70     status_t detachBuffer(int slot) override;
     71     status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer, sp<Fence>* outFence)
     72             override;
     73     status_t attachBuffer(int* outSlot, const sp<GraphicBuffer>& buffer)
     74             override;
     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)
     83             override;
     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;
     97     status_t getConsumerUsage(uint64_t* outUsage) const override;
     98 };
     99 
    100 }  // namespace utils
    101 }  // namespace V1_0
    102 }  // namespace bufferqueue
    103 }  // namespace graphics
    104 }  // namespace hardware
    105 }  // namespace android
    106 
    107 #endif  // ANDROID_HARDWARE_GRAPHICS_BUFFERQUEUE_V1_0_H2BGRAPHICBUFFERPRODUCER_H
    108