• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 struct Obituary;
49 
50 class B2HGraphicBufferProducer : public HGraphicBufferProducer {
51 public:
52     B2HGraphicBufferProducer(sp<BGraphicBufferProducer> const& base);
53 
54     virtual Return<HStatus> setMaxDequeuedBufferCount(
55             int32_t maxDequeuedBuffers) override;
56 
57     virtual Return<void> requestBuffer(
58             int32_t slot,
59             requestBuffer_cb _hidl_cb) override;
60 
61     virtual Return<HStatus> setAsyncMode(bool async) override;
62 
63     virtual Return<void> dequeueBuffer(
64             DequeueBufferInput const& input,
65             dequeueBuffer_cb _hidl_cb) override;
66 
67     virtual Return<HStatus> detachBuffer(int32_t slot) override;
68 
69     virtual Return<void> detachNextBuffer(
70             detachNextBuffer_cb _hidl_cb) override;
71 
72     virtual Return<void> attachBuffer(
73             HardwareBuffer const& buffer,
74             uint32_t generationNumber,
75             attachBuffer_cb _hidl_cb) override;
76 
77     virtual Return<void> queueBuffer(
78             int32_t slot,
79             QueueBufferInput const& input,
80             queueBuffer_cb _hidl_cb) override;
81 
82     virtual Return<HStatus> cancelBuffer(
83             int32_t slot,
84             hidl_handle const& fence) override;
85 
86     virtual Return<void> query(int32_t what, query_cb _hidl_cb) override;
87 
88     virtual Return<void> connect(
89             sp<HProducerListener> const& listener,
90             HConnectionType api,
91             bool producerControlledByApp,
92             connect_cb _hidl_cb) override;
93 
94     virtual Return<HStatus> disconnect(HConnectionType api) override;
95 
96     virtual Return<HStatus> allocateBuffers(
97             uint32_t width, uint32_t height,
98             uint32_t format, uint64_t usage) override;
99 
100     virtual Return<HStatus> allowAllocation(bool allow) override;
101 
102     virtual Return<HStatus> setGenerationNumber(uint32_t generationNumber) override;
103 
104     virtual Return<HStatus> setDequeueTimeout(int64_t timeoutNs) override;
105 
106     virtual Return<uint64_t> getUniqueId() override;
107 
108     virtual Return<void> getConsumerName(getConsumerName_cb _hidl_cb) override;
109 
110 protected:
111     sp<BGraphicBufferProducer> mBase;
112     sp<Obituary> mObituary;
113 };
114 
115 
116 }  // namespace utils
117 }  // namespace V2_0
118 }  // namespace bufferqueue
119 }  // namespace graphics
120 }  // namespace hardware
121 }  // namespace android
122 
123 #endif  // ANDROID_HARDWARE_GRAPHICS_BUFFERQUEUE_V2_0_B2HGRAPHICBUFFERPRODUCER_H
124