Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | #include <stdint.h> |
| 18 | #include <sys/types.h> |
| 19 | |
| 20 | #include <utils/Errors.h> |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 21 | #include <utils/NativeHandle.h> |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 22 | #include <utils/RefBase.h> |
Brian Anderson | 175a720 | 2016-10-10 16:52:56 -0700 | [diff] [blame] | 23 | #include <utils/String8.h> |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 24 | #include <utils/Timers.h> |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 25 | #include <utils/Vector.h> |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 26 | |
| 27 | #include <binder/Parcel.h> |
| 28 | #include <binder/IInterface.h> |
| 29 | |
Jiyong Park | a75d3d6 | 2018-04-09 12:16:30 +0900 | [diff] [blame] | 30 | #ifndef NO_BUFFERHUB |
Jiwen 'Steve' Cai | c90a77f | 2018-01-14 15:42:29 -0800 | [diff] [blame] | 31 | #include <gui/BufferHubProducer.h> |
Jiyong Park | a75d3d6 | 2018-04-09 12:16:30 +0900 | [diff] [blame] | 32 | #endif |
Pawin Vongmasa | e672cd0 | 2019-02-14 16:01:29 -0800 | [diff] [blame] | 33 | |
| 34 | #include <gui/bufferqueue/1.0/H2BGraphicBufferProducer.h> |
| 35 | #include <gui/bufferqueue/2.0/H2BGraphicBufferProducer.h> |
Chia-I Wu | c79a296 | 2017-05-15 10:32:27 -0700 | [diff] [blame] | 36 | #include <gui/BufferQueueDefs.h> |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 37 | #include <gui/IGraphicBufferProducer.h> |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 38 | #include <gui/IProducerListener.h> |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 39 | |
| 40 | namespace android { |
| 41 | // ---------------------------------------------------------------------------- |
| 42 | |
Pawin Vongmasa | e672cd0 | 2019-02-14 16:01:29 -0800 | [diff] [blame] | 43 | using H2BGraphicBufferProducerV1_0 = |
| 44 | ::android::hardware::graphics::bufferqueue::V1_0::utils:: |
| 45 | H2BGraphicBufferProducer; |
| 46 | using H2BGraphicBufferProducerV2_0 = |
| 47 | ::android::hardware::graphics::bufferqueue::V2_0::utils:: |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 48 | H2BGraphicBufferProducer; |
| 49 | |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 50 | enum { |
| 51 | REQUEST_BUFFER = IBinder::FIRST_CALL_TRANSACTION, |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 52 | DEQUEUE_BUFFER, |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 53 | DETACH_BUFFER, |
Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 54 | DETACH_NEXT_BUFFER, |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 55 | ATTACH_BUFFER, |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 56 | QUEUE_BUFFER, |
| 57 | CANCEL_BUFFER, |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 58 | QUERY, |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 59 | CONNECT, |
| 60 | DISCONNECT, |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 61 | SET_SIDEBAND_STREAM, |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 62 | ALLOCATE_BUFFERS, |
Dan Stoza | 9de7293 | 2015-04-16 17:28:43 -0700 | [diff] [blame] | 63 | ALLOW_ALLOCATION, |
Dan Stoza | 812ed06 | 2015-06-02 15:45:22 -0700 | [diff] [blame] | 64 | SET_GENERATION_NUMBER, |
Dan Stoza | c6f30bd | 2015-06-08 09:32:50 -0700 | [diff] [blame] | 65 | GET_CONSUMER_NAME, |
Pablo Ceballos | fa45535 | 2015-08-12 17:47:47 -0700 | [diff] [blame] | 66 | SET_MAX_DEQUEUED_BUFFER_COUNT, |
Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 67 | SET_ASYNC_MODE, |
Pablo Ceballos | 3559fbf | 2016-03-17 15:50:23 -0700 | [diff] [blame] | 68 | SET_SHARED_BUFFER_MODE, |
Pablo Ceballos | ff95aab | 2016-01-13 17:09:58 -0800 | [diff] [blame] | 69 | SET_AUTO_REFRESH, |
Dan Stoza | 127fc63 | 2015-06-30 13:43:32 -0700 | [diff] [blame] | 70 | SET_DEQUEUE_TIMEOUT, |
Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 71 | GET_LAST_QUEUED_BUFFER, |
Pablo Ceballos | fc35258 | 2016-06-30 17:22:20 -0700 | [diff] [blame] | 72 | GET_FRAME_TIMESTAMPS, |
Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 73 | GET_UNIQUE_ID, |
| 74 | GET_CONSUMER_USAGE, |
Sungtak Lee | 3249fb6 | 2019-03-02 16:40:47 -0800 | [diff] [blame] | 75 | SET_LEGACY_BUFFER_DROP, |
Yiwei Zhang | 538cedc | 2019-06-24 19:35:03 -0700 | [diff] [blame] | 76 | SET_AUTO_PREROTATION, |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 77 | REQUEST_BUFFERS, |
| 78 | DEQUEUE_BUFFERS, |
| 79 | DETACH_BUFFERS, |
| 80 | ATTACH_BUFFERS, |
| 81 | QUEUE_BUFFERS, |
| 82 | CANCEL_BUFFERS, |
| 83 | QUERY_MULTIPLE, |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 84 | }; |
| 85 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 86 | class BpGraphicBufferProducer : public BpInterface<IGraphicBufferProducer> |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 87 | { |
| 88 | public: |
Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame] | 89 | explicit BpGraphicBufferProducer(const sp<IBinder>& impl) |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 90 | : BpInterface<IGraphicBufferProducer>(impl) |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 91 | { |
| 92 | } |
| 93 | |
Yi Kong | ca03851 | 2017-05-02 16:55:24 -0700 | [diff] [blame] | 94 | ~BpGraphicBufferProducer() override; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 95 | |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 96 | virtual status_t requestBuffer(int bufferIdx, sp<GraphicBuffer>* buf) { |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 97 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 98 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 99 | data.writeInt32(bufferIdx); |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 100 | status_t result = remote()->transact(REQUEST_BUFFER, data, &reply); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 101 | if (result != NO_ERROR) { |
| 102 | return result; |
| 103 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 104 | bool nonNull = reply.readInt32(); |
| 105 | if (nonNull) { |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 106 | *buf = new GraphicBuffer(); |
Lingyun Zhu | 2aff702 | 2012-11-20 19:24:35 +0800 | [diff] [blame] | 107 | result = reply.read(**buf); |
| 108 | if(result != NO_ERROR) { |
| 109 | (*buf).clear(); |
| 110 | return result; |
| 111 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 112 | } |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 113 | result = reply.readInt32(); |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 114 | return result; |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 115 | } |
| 116 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 117 | virtual status_t requestBuffers( |
| 118 | const std::vector<int32_t>& slots, |
| 119 | std::vector<RequestBufferOutput>* outputs) override { |
| 120 | Parcel data, reply; |
| 121 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 122 | data.writeInt32Vector(slots); |
| 123 | status_t result = remote()->transact(REQUEST_BUFFERS, data, &reply); |
| 124 | if (result != NO_ERROR) { |
| 125 | return result; |
| 126 | } |
| 127 | result = reply.resizeOutVector(outputs); |
| 128 | for (RequestBufferOutput& output : *outputs) { |
| 129 | if (result != NO_ERROR) { |
| 130 | return result; |
| 131 | } |
| 132 | result = reply.read(output); |
| 133 | } |
| 134 | |
| 135 | return result; |
| 136 | } |
| 137 | |
Pablo Ceballos | fa45535 | 2015-08-12 17:47:47 -0700 | [diff] [blame] | 138 | virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers) { |
| 139 | Parcel data, reply; |
| 140 | data.writeInterfaceToken( |
| 141 | IGraphicBufferProducer::getInterfaceDescriptor()); |
| 142 | data.writeInt32(maxDequeuedBuffers); |
| 143 | status_t result = remote()->transact(SET_MAX_DEQUEUED_BUFFER_COUNT, |
| 144 | data, &reply); |
| 145 | if (result != NO_ERROR) { |
| 146 | return result; |
| 147 | } |
| 148 | result = reply.readInt32(); |
| 149 | return result; |
| 150 | } |
| 151 | |
| 152 | virtual status_t setAsyncMode(bool async) { |
| 153 | Parcel data, reply; |
| 154 | data.writeInterfaceToken( |
| 155 | IGraphicBufferProducer::getInterfaceDescriptor()); |
| 156 | data.writeInt32(async); |
| 157 | status_t result = remote()->transact(SET_ASYNC_MODE, |
| 158 | data, &reply); |
| 159 | if (result != NO_ERROR) { |
| 160 | return result; |
| 161 | } |
| 162 | result = reply.readInt32(); |
| 163 | return result; |
| 164 | } |
| 165 | |
Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 166 | virtual status_t dequeueBuffer(int* buf, sp<Fence>* fence, uint32_t width, uint32_t height, |
| 167 | PixelFormat format, uint64_t usage, uint64_t* outBufferAge, |
| 168 | FrameEventHistoryDelta* outTimestamps) { |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 169 | Parcel data, reply; |
Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 170 | bool getFrameTimestamps = (outTimestamps != nullptr); |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 171 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 172 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 173 | data.writeUint32(width); |
| 174 | data.writeUint32(height); |
| 175 | data.writeInt32(static_cast<int32_t>(format)); |
Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 176 | data.writeUint64(usage); |
Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 177 | data.writeBool(getFrameTimestamps); |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 178 | |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 179 | status_t result = remote()->transact(DEQUEUE_BUFFER, data, &reply); |
| 180 | if (result != NO_ERROR) { |
| 181 | return result; |
| 182 | } |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 183 | |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 184 | *buf = reply.readInt32(); |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 185 | *fence = new Fence(); |
| 186 | result = reply.read(**fence); |
| 187 | if (result != NO_ERROR) { |
| 188 | fence->clear(); |
| 189 | return result; |
Jesse Hall | f785754 | 2012-06-14 15:26:33 -0700 | [diff] [blame] | 190 | } |
Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 191 | if (outBufferAge) { |
| 192 | result = reply.readUint64(outBufferAge); |
| 193 | } else { |
| 194 | // Read the value even if outBufferAge is nullptr: |
| 195 | uint64_t bufferAge; |
| 196 | result = reply.readUint64(&bufferAge); |
| 197 | } |
| 198 | if (result != NO_ERROR) { |
| 199 | ALOGE("IGBP::dequeueBuffer failed to read buffer age: %d", result); |
| 200 | return result; |
| 201 | } |
Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 202 | if (getFrameTimestamps) { |
| 203 | result = reply.read(*outTimestamps); |
| 204 | if (result != NO_ERROR) { |
| 205 | ALOGE("IGBP::dequeueBuffer failed to read timestamps: %d", |
| 206 | result); |
| 207 | return result; |
| 208 | } |
| 209 | } |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 210 | result = reply.readInt32(); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 211 | return result; |
| 212 | } |
| 213 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 214 | virtual status_t dequeueBuffers( |
| 215 | const std::vector<DequeueBufferInput>& inputs, |
| 216 | std::vector<DequeueBufferOutput>* outputs) { |
| 217 | Parcel data, reply; |
| 218 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 219 | data.writeVectorSize(inputs); |
| 220 | for (const auto& input : inputs) { |
| 221 | data.write(input); |
| 222 | } |
| 223 | status_t result = remote()->transact(DEQUEUE_BUFFERS, data, &reply); |
| 224 | if (result != NO_ERROR) { |
| 225 | return result; |
| 226 | } |
| 227 | result = reply.resizeOutVector(outputs); |
| 228 | for (auto& output : *outputs) { |
| 229 | if (result != NO_ERROR) { |
| 230 | return result; |
| 231 | } |
| 232 | result = reply.read(output); |
| 233 | } |
| 234 | return result; |
| 235 | } |
| 236 | |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 237 | virtual status_t detachBuffer(int slot) { |
| 238 | Parcel data, reply; |
| 239 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 240 | data.writeInt32(slot); |
| 241 | status_t result = remote()->transact(DETACH_BUFFER, data, &reply); |
| 242 | if (result != NO_ERROR) { |
| 243 | return result; |
| 244 | } |
| 245 | result = reply.readInt32(); |
| 246 | return result; |
| 247 | } |
| 248 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 249 | virtual status_t detachBuffers(const std::vector<int32_t>& slots, |
| 250 | std::vector<status_t>* results) { |
| 251 | Parcel data, reply; |
| 252 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 253 | data.writeInt32Vector(slots); |
| 254 | status_t result = remote()->transact(DETACH_BUFFERS, data, &reply); |
| 255 | if (result != NO_ERROR) { |
| 256 | return result; |
| 257 | } |
| 258 | result = reply.readInt32Vector(results); |
| 259 | return result; |
| 260 | } |
| 261 | |
Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 262 | virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer, |
| 263 | sp<Fence>* outFence) { |
Yi Kong | 48a619f | 2018-06-05 16:34:59 -0700 | [diff] [blame] | 264 | if (outBuffer == nullptr) { |
Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 265 | ALOGE("detachNextBuffer: outBuffer must not be NULL"); |
| 266 | return BAD_VALUE; |
Yi Kong | 48a619f | 2018-06-05 16:34:59 -0700 | [diff] [blame] | 267 | } else if (outFence == nullptr) { |
Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 268 | ALOGE("detachNextBuffer: outFence must not be NULL"); |
| 269 | return BAD_VALUE; |
| 270 | } |
| 271 | Parcel data, reply; |
| 272 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 273 | status_t result = remote()->transact(DETACH_NEXT_BUFFER, data, &reply); |
| 274 | if (result != NO_ERROR) { |
| 275 | return result; |
| 276 | } |
| 277 | result = reply.readInt32(); |
| 278 | if (result == NO_ERROR) { |
| 279 | bool nonNull = reply.readInt32(); |
| 280 | if (nonNull) { |
| 281 | *outBuffer = new GraphicBuffer; |
Pablo Ceballos | 70636b3 | 2016-07-06 15:24:54 -0700 | [diff] [blame] | 282 | result = reply.read(**outBuffer); |
| 283 | if (result != NO_ERROR) { |
| 284 | outBuffer->clear(); |
| 285 | return result; |
| 286 | } |
Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 287 | } |
| 288 | nonNull = reply.readInt32(); |
| 289 | if (nonNull) { |
| 290 | *outFence = new Fence; |
Pablo Ceballos | 70636b3 | 2016-07-06 15:24:54 -0700 | [diff] [blame] | 291 | result = reply.read(**outFence); |
| 292 | if (result != NO_ERROR) { |
| 293 | outBuffer->clear(); |
| 294 | outFence->clear(); |
| 295 | return result; |
| 296 | } |
Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 297 | } |
| 298 | } |
| 299 | return result; |
| 300 | } |
| 301 | |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 302 | virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer) { |
| 303 | Parcel data, reply; |
| 304 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 305 | data.write(*buffer.get()); |
| 306 | status_t result = remote()->transact(ATTACH_BUFFER, data, &reply); |
| 307 | if (result != NO_ERROR) { |
| 308 | return result; |
| 309 | } |
Chia-I Wu | c79a296 | 2017-05-15 10:32:27 -0700 | [diff] [blame] | 310 | |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 311 | *slot = reply.readInt32(); |
| 312 | result = reply.readInt32(); |
Chia-I Wu | c79a296 | 2017-05-15 10:32:27 -0700 | [diff] [blame] | 313 | if (result == NO_ERROR && |
| 314 | (*slot < 0 || *slot >= BufferQueueDefs::NUM_BUFFER_SLOTS)) { |
| 315 | ALOGE("attachBuffer returned invalid slot %d", *slot); |
| 316 | android_errorWriteLog(0x534e4554, "37478824"); |
| 317 | return UNKNOWN_ERROR; |
| 318 | } |
| 319 | |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 320 | return result; |
| 321 | } |
| 322 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 323 | virtual status_t attachBuffers( |
| 324 | const std::vector<sp<GraphicBuffer>>& buffers, |
| 325 | std::vector<AttachBufferOutput>* outputs) { |
| 326 | Parcel data, reply; |
| 327 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 328 | data.writeVectorSize(buffers); |
| 329 | for (const sp<GraphicBuffer>& buffer : buffers) { |
| 330 | data.write(*buffer.get()); |
| 331 | } |
| 332 | status_t result = remote()->transact(ATTACH_BUFFERS, data, &reply); |
| 333 | if (result != NO_ERROR) { |
| 334 | return result; |
| 335 | } |
| 336 | result = reply.resizeOutVector(outputs); |
| 337 | for (AttachBufferOutput& output : *outputs) { |
| 338 | if (result != NO_ERROR) { |
| 339 | return result; |
| 340 | } |
| 341 | result = reply.read(output); |
| 342 | } |
| 343 | if (result == NO_ERROR) { |
| 344 | for (AttachBufferOutput& output : *outputs) { |
| 345 | if (output.result == NO_ERROR && output.slot < 0) { |
| 346 | ALOGE("attachBuffers returned invalid slot %d", |
| 347 | output.slot); |
| 348 | android_errorWriteLog(0x534e4554, "37478824"); |
| 349 | output.result = UNKNOWN_ERROR; |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | return result; |
| 354 | } |
| 355 | |
Mathias Agopian | f0bc2f1 | 2012-04-09 16:14:01 -0700 | [diff] [blame] | 356 | virtual status_t queueBuffer(int buf, |
| 357 | const QueueBufferInput& input, QueueBufferOutput* output) { |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 358 | Parcel data, reply; |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 359 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 360 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 361 | data.writeInt32(buf); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 362 | data.write(input); |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 363 | |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 364 | status_t result = remote()->transact(QUEUE_BUFFER, data, &reply); |
| 365 | if (result != NO_ERROR) { |
| 366 | return result; |
| 367 | } |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 368 | |
| 369 | result = reply.read(*output); |
| 370 | if (result != NO_ERROR) { |
| 371 | return result; |
| 372 | } |
| 373 | |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 374 | result = reply.readInt32(); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 375 | return result; |
| 376 | } |
| 377 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 378 | virtual status_t queueBuffers(const std::vector<QueueBufferInput>& inputs, |
| 379 | std::vector<QueueBufferOutput>* outputs) { |
| 380 | Parcel data, reply; |
| 381 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 382 | data.writeVectorSize(inputs); |
| 383 | for (const QueueBufferInput& input : inputs) { |
| 384 | data.write(input); |
| 385 | } |
| 386 | status_t result = remote()->transact(QUEUE_BUFFERS, data, &reply); |
| 387 | if (result != NO_ERROR) { |
| 388 | return result; |
| 389 | } |
| 390 | result = reply.resizeOutVector(outputs); |
| 391 | for (QueueBufferOutput& output : *outputs) { |
| 392 | if (result != NO_ERROR) { |
| 393 | return result; |
| 394 | } |
| 395 | result = reply.read(output); |
| 396 | } |
| 397 | return result; |
| 398 | } |
| 399 | |
Pablo Ceballos | 583b1b3 | 2015-09-03 18:23:52 -0700 | [diff] [blame] | 400 | virtual status_t cancelBuffer(int buf, const sp<Fence>& fence) { |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 401 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 402 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 403 | data.writeInt32(buf); |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame] | 404 | data.write(*fence.get()); |
Pablo Ceballos | 583b1b3 | 2015-09-03 18:23:52 -0700 | [diff] [blame] | 405 | status_t result = remote()->transact(CANCEL_BUFFER, data, &reply); |
| 406 | if (result != NO_ERROR) { |
| 407 | return result; |
| 408 | } |
| 409 | result = reply.readInt32(); |
| 410 | return result; |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 411 | } |
| 412 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 413 | virtual status_t cancelBuffers( |
| 414 | const std::vector<CancelBufferInput>& inputs, |
| 415 | std::vector<status_t>* results) { |
| 416 | Parcel data, reply; |
| 417 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 418 | data.writeVectorSize(inputs); |
| 419 | for (const CancelBufferInput& input : inputs) { |
| 420 | data.write(input); |
| 421 | } |
| 422 | status_t result = remote()->transact(CANCEL_BUFFERS, data, &reply); |
| 423 | if (result != NO_ERROR) { |
| 424 | return result; |
| 425 | } |
| 426 | result = reply.readInt32Vector(results); |
| 427 | return result; |
| 428 | } |
| 429 | |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 430 | virtual int query(int what, int* value) { |
| 431 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 432 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 433 | data.writeInt32(what); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 434 | status_t result = remote()->transact(QUERY, data, &reply); |
| 435 | if (result != NO_ERROR) { |
| 436 | return result; |
| 437 | } |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 438 | value[0] = reply.readInt32(); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 439 | result = reply.readInt32(); |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 440 | return result; |
| 441 | } |
| 442 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 443 | virtual status_t query(const std::vector<int32_t> inputs, |
| 444 | std::vector<QueryOutput>* outputs) { |
| 445 | Parcel data, reply; |
| 446 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 447 | data.writeInt32Vector(inputs); |
| 448 | status_t result = remote()->transact(QUERY_MULTIPLE, data, &reply); |
| 449 | if (result != NO_ERROR) { |
| 450 | return result; |
| 451 | } |
| 452 | result = reply.resizeOutVector(outputs); |
| 453 | for (QueryOutput& output : *outputs) { |
| 454 | if (result != NO_ERROR) { |
| 455 | return result; |
| 456 | } |
| 457 | result = reply.read(output); |
| 458 | } |
| 459 | return result; |
| 460 | } |
| 461 | |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 462 | virtual status_t connect(const sp<IProducerListener>& listener, |
Mathias Agopian | 365857d | 2013-09-11 19:35:45 -0700 | [diff] [blame] | 463 | int api, bool producerControlledByApp, QueueBufferOutput* output) { |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 464 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 465 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Yi Kong | 48a619f | 2018-06-05 16:34:59 -0700 | [diff] [blame] | 466 | if (listener != nullptr) { |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 467 | data.writeInt32(1); |
Marco Nelissen | 097ca27 | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 468 | data.writeStrongBinder(IInterface::asBinder(listener)); |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 469 | } else { |
| 470 | data.writeInt32(0); |
| 471 | } |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 472 | data.writeInt32(api); |
Mathias Agopian | 595264f | 2013-07-16 22:56:09 -0700 | [diff] [blame] | 473 | data.writeInt32(producerControlledByApp); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 474 | status_t result = remote()->transact(CONNECT, data, &reply); |
| 475 | if (result != NO_ERROR) { |
| 476 | return result; |
| 477 | } |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 478 | reply.read(*output); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 479 | result = reply.readInt32(); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 480 | return result; |
| 481 | } |
Mathias Agopian | 8072711 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 482 | |
Robert Carr | 97b9c86 | 2016-09-08 13:54:35 -0700 | [diff] [blame] | 483 | virtual status_t disconnect(int api, DisconnectMode mode) { |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 484 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 485 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 486 | data.writeInt32(api); |
Robert Carr | 97b9c86 | 2016-09-08 13:54:35 -0700 | [diff] [blame] | 487 | data.writeInt32(static_cast<int32_t>(mode)); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 488 | status_t result =remote()->transact(DISCONNECT, data, &reply); |
| 489 | if (result != NO_ERROR) { |
| 490 | return result; |
| 491 | } |
| 492 | result = reply.readInt32(); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 493 | return result; |
| 494 | } |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 495 | |
| 496 | virtual status_t setSidebandStream(const sp<NativeHandle>& stream) { |
| 497 | Parcel data, reply; |
| 498 | status_t result; |
| 499 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 500 | if (stream.get()) { |
| 501 | data.writeInt32(true); |
| 502 | data.writeNativeHandle(stream->handle()); |
| 503 | } else { |
| 504 | data.writeInt32(false); |
| 505 | } |
| 506 | if ((result = remote()->transact(SET_SIDEBAND_STREAM, data, &reply)) == NO_ERROR) { |
| 507 | result = reply.readInt32(); |
| 508 | } |
| 509 | return result; |
| 510 | } |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 511 | |
Pablo Ceballos | 567dbbb | 2015-08-26 18:59:08 -0700 | [diff] [blame] | 512 | virtual void allocateBuffers(uint32_t width, uint32_t height, |
Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 513 | PixelFormat format, uint64_t usage) { |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 514 | Parcel data, reply; |
| 515 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 516 | data.writeUint32(width); |
| 517 | data.writeUint32(height); |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 518 | data.writeInt32(static_cast<int32_t>(format)); |
Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 519 | data.writeUint64(usage); |
Steven Moreland | 366eb42 | 2019-04-01 19:22:32 -0700 | [diff] [blame] | 520 | status_t result = remote()->transact(ALLOCATE_BUFFERS, data, &reply, IBinder::FLAG_ONEWAY); |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 521 | if (result != NO_ERROR) { |
| 522 | ALOGE("allocateBuffers failed to transact: %d", result); |
| 523 | } |
| 524 | } |
Dan Stoza | 9de7293 | 2015-04-16 17:28:43 -0700 | [diff] [blame] | 525 | |
| 526 | virtual status_t allowAllocation(bool allow) { |
| 527 | Parcel data, reply; |
| 528 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 529 | data.writeInt32(static_cast<int32_t>(allow)); |
| 530 | status_t result = remote()->transact(ALLOW_ALLOCATION, data, &reply); |
| 531 | if (result != NO_ERROR) { |
| 532 | return result; |
| 533 | } |
| 534 | result = reply.readInt32(); |
| 535 | return result; |
| 536 | } |
Dan Stoza | 812ed06 | 2015-06-02 15:45:22 -0700 | [diff] [blame] | 537 | |
| 538 | virtual status_t setGenerationNumber(uint32_t generationNumber) { |
| 539 | Parcel data, reply; |
| 540 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 541 | data.writeUint32(generationNumber); |
| 542 | status_t result = remote()->transact(SET_GENERATION_NUMBER, data, &reply); |
| 543 | if (result == NO_ERROR) { |
| 544 | result = reply.readInt32(); |
| 545 | } |
| 546 | return result; |
| 547 | } |
Dan Stoza | c6f30bd | 2015-06-08 09:32:50 -0700 | [diff] [blame] | 548 | |
| 549 | virtual String8 getConsumerName() const { |
| 550 | Parcel data, reply; |
| 551 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 552 | status_t result = remote()->transact(GET_CONSUMER_NAME, data, &reply); |
| 553 | if (result != NO_ERROR) { |
| 554 | ALOGE("getConsumerName failed to transact: %d", result); |
| 555 | return String8("TransactFailed"); |
| 556 | } |
| 557 | return reply.readString8(); |
| 558 | } |
Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 559 | |
Pablo Ceballos | 3559fbf | 2016-03-17 15:50:23 -0700 | [diff] [blame] | 560 | virtual status_t setSharedBufferMode(bool sharedBufferMode) { |
Pablo Ceballos | ccdfd60 | 2015-10-07 15:05:45 -0700 | [diff] [blame] | 561 | Parcel data, reply; |
| 562 | data.writeInterfaceToken( |
| 563 | IGraphicBufferProducer::getInterfaceDescriptor()); |
Pablo Ceballos | 3559fbf | 2016-03-17 15:50:23 -0700 | [diff] [blame] | 564 | data.writeInt32(sharedBufferMode); |
| 565 | status_t result = remote()->transact(SET_SHARED_BUFFER_MODE, data, |
Pablo Ceballos | ccdfd60 | 2015-10-07 15:05:45 -0700 | [diff] [blame] | 566 | &reply); |
| 567 | if (result == NO_ERROR) { |
| 568 | result = reply.readInt32(); |
| 569 | } |
| 570 | return result; |
| 571 | } |
Dan Stoza | 127fc63 | 2015-06-30 13:43:32 -0700 | [diff] [blame] | 572 | |
Pablo Ceballos | ff95aab | 2016-01-13 17:09:58 -0800 | [diff] [blame] | 573 | virtual status_t setAutoRefresh(bool autoRefresh) { |
| 574 | Parcel data, reply; |
| 575 | data.writeInterfaceToken( |
| 576 | IGraphicBufferProducer::getInterfaceDescriptor()); |
| 577 | data.writeInt32(autoRefresh); |
| 578 | status_t result = remote()->transact(SET_AUTO_REFRESH, data, &reply); |
| 579 | if (result == NO_ERROR) { |
| 580 | result = reply.readInt32(); |
| 581 | } |
| 582 | return result; |
| 583 | } |
| 584 | |
Dan Stoza | 127fc63 | 2015-06-30 13:43:32 -0700 | [diff] [blame] | 585 | virtual status_t setDequeueTimeout(nsecs_t timeout) { |
| 586 | Parcel data, reply; |
| 587 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 588 | data.writeInt64(timeout); |
| 589 | status_t result = remote()->transact(SET_DEQUEUE_TIMEOUT, data, &reply); |
| 590 | if (result != NO_ERROR) { |
| 591 | ALOGE("setDequeueTimeout failed to transact: %d", result); |
| 592 | return result; |
| 593 | } |
| 594 | return reply.readInt32(); |
| 595 | } |
Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 596 | |
Sungtak Lee | 3249fb6 | 2019-03-02 16:40:47 -0800 | [diff] [blame] | 597 | virtual status_t setLegacyBufferDrop(bool drop) { |
| 598 | Parcel data, reply; |
| 599 | data.writeInterfaceToken( |
| 600 | IGraphicBufferProducer::getInterfaceDescriptor()); |
| 601 | data.writeInt32(drop); |
| 602 | status_t result = remote()->transact(SET_LEGACY_BUFFER_DROP, |
| 603 | data, &reply); |
| 604 | if (result != NO_ERROR) { |
| 605 | return result; |
| 606 | } |
| 607 | result = reply.readInt32(); |
| 608 | return result; |
| 609 | } |
| 610 | |
Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 611 | virtual status_t getLastQueuedBuffer(sp<GraphicBuffer>* outBuffer, |
John Reck | 1a61da5 | 2016-04-28 13:18:15 -0700 | [diff] [blame] | 612 | sp<Fence>* outFence, float outTransformMatrix[16]) override { |
Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 613 | Parcel data, reply; |
| 614 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 615 | status_t result = remote()->transact(GET_LAST_QUEUED_BUFFER, data, |
| 616 | &reply); |
| 617 | if (result != NO_ERROR) { |
| 618 | ALOGE("getLastQueuedBuffer failed to transact: %d", result); |
| 619 | return result; |
| 620 | } |
| 621 | result = reply.readInt32(); |
| 622 | if (result != NO_ERROR) { |
| 623 | return result; |
| 624 | } |
John Reck | ce8e5df | 2016-04-28 10:12:47 -0700 | [diff] [blame] | 625 | bool hasBuffer = reply.readBool(); |
| 626 | sp<GraphicBuffer> buffer; |
| 627 | if (hasBuffer) { |
| 628 | buffer = new GraphicBuffer(); |
| 629 | result = reply.read(*buffer); |
John Reck | 1a61da5 | 2016-04-28 13:18:15 -0700 | [diff] [blame] | 630 | if (result == NO_ERROR) { |
| 631 | result = reply.read(outTransformMatrix, sizeof(float) * 16); |
| 632 | } |
John Reck | ce8e5df | 2016-04-28 10:12:47 -0700 | [diff] [blame] | 633 | } |
Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 634 | if (result != NO_ERROR) { |
| 635 | ALOGE("getLastQueuedBuffer failed to read buffer: %d", result); |
| 636 | return result; |
| 637 | } |
| 638 | sp<Fence> fence(new Fence); |
| 639 | result = reply.read(*fence); |
| 640 | if (result != NO_ERROR) { |
| 641 | ALOGE("getLastQueuedBuffer failed to read fence: %d", result); |
| 642 | return result; |
| 643 | } |
| 644 | *outBuffer = buffer; |
| 645 | *outFence = fence; |
| 646 | return result; |
| 647 | } |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 648 | |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 649 | virtual void getFrameTimestamps(FrameEventHistoryDelta* outDelta) { |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 650 | Parcel data, reply; |
| 651 | status_t result = data.writeInterfaceToken( |
| 652 | IGraphicBufferProducer::getInterfaceDescriptor()); |
| 653 | if (result != NO_ERROR) { |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 654 | ALOGE("IGBP::getFrameTimestamps failed to write token: %d", result); |
| 655 | return; |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 656 | } |
| 657 | result = remote()->transact(GET_FRAME_TIMESTAMPS, data, &reply); |
| 658 | if (result != NO_ERROR) { |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 659 | ALOGE("IGBP::getFrameTimestamps failed to transact: %d", result); |
| 660 | return; |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 661 | } |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 662 | result = reply.read(*outDelta); |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 663 | if (result != NO_ERROR) { |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 664 | ALOGE("IGBP::getFrameTimestamps failed to read timestamps: %d", |
| 665 | result); |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 666 | } |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 667 | } |
Pablo Ceballos | 6155b40 | 2016-06-30 17:01:49 -0700 | [diff] [blame] | 668 | |
Pablo Ceballos | 8e3e92b | 2016-06-27 17:56:53 -0700 | [diff] [blame] | 669 | virtual status_t getUniqueId(uint64_t* outId) const { |
| 670 | Parcel data, reply; |
| 671 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 672 | status_t result = remote()->transact(GET_UNIQUE_ID, data, &reply); |
| 673 | if (result != NO_ERROR) { |
| 674 | ALOGE("getUniqueId failed to transact: %d", result); |
| 675 | } |
| 676 | status_t actualResult = NO_ERROR; |
| 677 | result = reply.readInt32(&actualResult); |
| 678 | if (result != NO_ERROR) { |
| 679 | return result; |
| 680 | } |
| 681 | result = reply.readUint64(outId); |
| 682 | if (result != NO_ERROR) { |
| 683 | return result; |
| 684 | } |
| 685 | return actualResult; |
| 686 | } |
Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 687 | |
| 688 | virtual status_t getConsumerUsage(uint64_t* outUsage) const { |
| 689 | Parcel data, reply; |
| 690 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 691 | status_t result = remote()->transact(GET_CONSUMER_USAGE, data, &reply); |
| 692 | if (result != NO_ERROR) { |
| 693 | ALOGE("getConsumerUsage failed to transact: %d", result); |
| 694 | } |
| 695 | status_t actualResult = NO_ERROR; |
| 696 | result = reply.readInt32(&actualResult); |
| 697 | if (result != NO_ERROR) { |
| 698 | return result; |
| 699 | } |
| 700 | result = reply.readUint64(outUsage); |
| 701 | if (result != NO_ERROR) { |
| 702 | return result; |
| 703 | } |
| 704 | return actualResult; |
| 705 | } |
Yiwei Zhang | 538cedc | 2019-06-24 19:35:03 -0700 | [diff] [blame] | 706 | |
| 707 | virtual status_t setAutoPrerotation(bool autoPrerotation) { |
| 708 | Parcel data, reply; |
| 709 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 710 | data.writeBool(autoPrerotation); |
| 711 | status_t result = remote()->transact(SET_AUTO_PREROTATION, data, &reply); |
| 712 | if (result == NO_ERROR) { |
| 713 | result = reply.readInt32(); |
| 714 | } |
| 715 | return result; |
| 716 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 717 | }; |
| 718 | |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 719 | // Out-of-line virtual method definition to trigger vtable emission in this |
| 720 | // translation unit (see clang warning -Wweak-vtables) |
| 721 | BpGraphicBufferProducer::~BpGraphicBufferProducer() {} |
| 722 | |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 723 | class HpGraphicBufferProducer : public HpInterface< |
Pawin Vongmasa | e672cd0 | 2019-02-14 16:01:29 -0800 | [diff] [blame] | 724 | BpGraphicBufferProducer, |
| 725 | H2BGraphicBufferProducerV1_0, |
| 726 | H2BGraphicBufferProducerV2_0> { |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 727 | public: |
Chih-Hung Hsieh | aaf6216 | 2018-12-20 15:45:04 -0800 | [diff] [blame] | 728 | explicit HpGraphicBufferProducer(const sp<IBinder>& base) : PBase(base) {} |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 729 | |
| 730 | status_t requestBuffer(int slot, sp<GraphicBuffer>* buf) override { |
| 731 | return mBase->requestBuffer(slot, buf); |
| 732 | } |
| 733 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 734 | status_t requestBuffers( |
| 735 | const std::vector<int32_t>& slots, |
| 736 | std::vector<RequestBufferOutput>* outputs) override { |
| 737 | return mBase->requestBuffers(slots, outputs); |
| 738 | } |
| 739 | |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 740 | status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers) override { |
| 741 | return mBase->setMaxDequeuedBufferCount(maxDequeuedBuffers); |
| 742 | } |
| 743 | |
| 744 | status_t setAsyncMode(bool async) override { |
| 745 | return mBase->setAsyncMode(async); |
| 746 | } |
| 747 | |
Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 748 | status_t dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w, uint32_t h, PixelFormat format, |
| 749 | uint64_t usage, uint64_t* outBufferAge, |
| 750 | FrameEventHistoryDelta* outTimestamps) override { |
| 751 | return mBase->dequeueBuffer(slot, fence, w, h, format, usage, outBufferAge, outTimestamps); |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 752 | } |
| 753 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 754 | status_t dequeueBuffers( |
| 755 | const std::vector<DequeueBufferInput>& inputs, |
| 756 | std::vector<DequeueBufferOutput>* outputs) override { |
| 757 | return mBase->dequeueBuffers(inputs, outputs); |
| 758 | } |
| 759 | |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 760 | status_t detachBuffer(int slot) override { |
| 761 | return mBase->detachBuffer(slot); |
| 762 | } |
| 763 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 764 | status_t detachBuffers(const std::vector<int32_t>& slots, |
| 765 | std::vector<status_t>* results) override { |
| 766 | return mBase->detachBuffers(slots, results); |
| 767 | } |
| 768 | |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 769 | status_t detachNextBuffer( |
| 770 | sp<GraphicBuffer>* outBuffer, sp<Fence>* outFence) override { |
| 771 | return mBase->detachNextBuffer(outBuffer, outFence); |
| 772 | } |
| 773 | |
| 774 | status_t attachBuffer( |
| 775 | int* outSlot, const sp<GraphicBuffer>& buffer) override { |
| 776 | return mBase->attachBuffer(outSlot, buffer); |
| 777 | } |
| 778 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 779 | status_t attachBuffers( |
| 780 | const std::vector<sp<GraphicBuffer>>& buffers, |
| 781 | std::vector<AttachBufferOutput>* outputs) override { |
| 782 | return mBase->attachBuffers(buffers, outputs); |
| 783 | } |
| 784 | |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 785 | status_t queueBuffer( |
| 786 | int slot, |
| 787 | const QueueBufferInput& input, |
| 788 | QueueBufferOutput* output) override { |
| 789 | return mBase->queueBuffer(slot, input, output); |
| 790 | } |
| 791 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 792 | status_t queueBuffers(const std::vector<QueueBufferInput>& inputs, |
| 793 | std::vector<QueueBufferOutput>* outputs) override { |
| 794 | return mBase->queueBuffers(inputs, outputs); |
| 795 | } |
| 796 | |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 797 | status_t cancelBuffer(int slot, const sp<Fence>& fence) override { |
| 798 | return mBase->cancelBuffer(slot, fence); |
| 799 | } |
| 800 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 801 | status_t cancelBuffers( |
| 802 | const std::vector<CancelBufferInput>& inputs, |
| 803 | std::vector<status_t>* results) override { |
| 804 | return mBase->cancelBuffers(inputs, results); |
| 805 | } |
| 806 | |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 807 | int query(int what, int* value) override { |
| 808 | return mBase->query(what, value); |
| 809 | } |
| 810 | |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 811 | status_t query(const std::vector<int32_t> inputs, |
| 812 | std::vector<QueryOutput>* outputs) override { |
| 813 | return mBase->query(inputs, outputs); |
| 814 | } |
| 815 | |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 816 | status_t connect( |
| 817 | const sp<IProducerListener>& listener, |
| 818 | int api, bool producerControlledByApp, |
| 819 | QueueBufferOutput* output) override { |
| 820 | return mBase->connect(listener, api, producerControlledByApp, output); |
| 821 | } |
| 822 | |
| 823 | status_t disconnect( |
| 824 | int api, DisconnectMode mode = DisconnectMode::Api) override { |
| 825 | return mBase->disconnect(api, mode); |
| 826 | } |
| 827 | |
| 828 | status_t setSidebandStream(const sp<NativeHandle>& stream) override { |
| 829 | return mBase->setSidebandStream(stream); |
| 830 | } |
| 831 | |
| 832 | void allocateBuffers(uint32_t width, uint32_t height, |
Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 833 | PixelFormat format, uint64_t usage) override { |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 834 | return mBase->allocateBuffers(width, height, format, usage); |
| 835 | } |
| 836 | |
| 837 | status_t allowAllocation(bool allow) override { |
| 838 | return mBase->allowAllocation(allow); |
| 839 | } |
| 840 | |
| 841 | status_t setGenerationNumber(uint32_t generationNumber) override { |
| 842 | return mBase->setGenerationNumber(generationNumber); |
| 843 | } |
| 844 | |
| 845 | String8 getConsumerName() const override { |
| 846 | return mBase->getConsumerName(); |
| 847 | } |
| 848 | |
| 849 | status_t setSharedBufferMode(bool sharedBufferMode) override { |
| 850 | return mBase->setSharedBufferMode(sharedBufferMode); |
| 851 | } |
| 852 | |
| 853 | status_t setAutoRefresh(bool autoRefresh) override { |
| 854 | return mBase->setAutoRefresh(autoRefresh); |
| 855 | } |
| 856 | |
| 857 | status_t setDequeueTimeout(nsecs_t timeout) override { |
| 858 | return mBase->setDequeueTimeout(timeout); |
| 859 | } |
| 860 | |
Sungtak Lee | 3249fb6 | 2019-03-02 16:40:47 -0800 | [diff] [blame] | 861 | status_t setLegacyBufferDrop(bool drop) override { |
| 862 | return mBase->setLegacyBufferDrop(drop); |
| 863 | } |
| 864 | |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 865 | status_t getLastQueuedBuffer( |
| 866 | sp<GraphicBuffer>* outBuffer, |
| 867 | sp<Fence>* outFence, |
| 868 | float outTransformMatrix[16]) override { |
| 869 | return mBase->getLastQueuedBuffer( |
| 870 | outBuffer, outFence, outTransformMatrix); |
| 871 | } |
| 872 | |
| 873 | void getFrameTimestamps(FrameEventHistoryDelta* outDelta) override { |
| 874 | return mBase->getFrameTimestamps(outDelta); |
| 875 | } |
| 876 | |
| 877 | status_t getUniqueId(uint64_t* outId) const override { |
| 878 | return mBase->getUniqueId(outId); |
| 879 | } |
Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 880 | |
| 881 | status_t getConsumerUsage(uint64_t* outUsage) const override { |
| 882 | return mBase->getConsumerUsage(outUsage); |
| 883 | } |
Yiwei Zhang | 538cedc | 2019-06-24 19:35:03 -0700 | [diff] [blame] | 884 | |
| 885 | status_t setAutoPrerotation(bool autoPrerotation) override { |
| 886 | return mBase->setAutoPrerotation(autoPrerotation); |
| 887 | } |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 888 | }; |
| 889 | |
Pawin Vongmasa | 338b81d | 2019-01-31 05:20:07 -0800 | [diff] [blame] | 890 | IMPLEMENT_HYBRID_META_INTERFACE(GraphicBufferProducer, |
Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 891 | "android.gui.IGraphicBufferProducer"); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 892 | |
| 893 | // ---------------------------------------------------------------------- |
| 894 | |
Sungtak Lee | 3249fb6 | 2019-03-02 16:40:47 -0800 | [diff] [blame] | 895 | status_t IGraphicBufferProducer::setLegacyBufferDrop(bool drop) { |
| 896 | // No-op for IGBP other than BufferQueue. |
| 897 | (void) drop; |
| 898 | return INVALID_OPERATION; |
| 899 | } |
| 900 | |
Yiwei Zhang | 538cedc | 2019-06-24 19:35:03 -0700 | [diff] [blame] | 901 | status_t IGraphicBufferProducer::setAutoPrerotation(bool autoPrerotation) { |
| 902 | // No-op for IGBP other than BufferQueue. |
| 903 | (void)autoPrerotation; |
| 904 | return INVALID_OPERATION; |
| 905 | } |
| 906 | |
Jiwen 'Steve' Cai | c90a77f | 2018-01-14 15:42:29 -0800 | [diff] [blame] | 907 | status_t IGraphicBufferProducer::exportToParcel(Parcel* parcel) { |
| 908 | status_t res = OK; |
| 909 | res = parcel->writeUint32(USE_BUFFER_QUEUE); |
| 910 | if (res != NO_ERROR) { |
| 911 | ALOGE("exportToParcel: Cannot write magic, res=%d.", res); |
| 912 | return res; |
| 913 | } |
| 914 | |
| 915 | return parcel->writeStrongBinder(IInterface::asBinder(this)); |
| 916 | } |
| 917 | |
| 918 | /* static */ |
| 919 | status_t IGraphicBufferProducer::exportToParcel(const sp<IGraphicBufferProducer>& producer, |
| 920 | Parcel* parcel) { |
| 921 | if (parcel == nullptr) { |
| 922 | ALOGE("exportToParcel: Invalid parcel object."); |
| 923 | return BAD_VALUE; |
| 924 | } |
| 925 | |
| 926 | if (producer == nullptr) { |
| 927 | status_t res = OK; |
| 928 | res = parcel->writeUint32(IGraphicBufferProducer::USE_BUFFER_QUEUE); |
| 929 | if (res != NO_ERROR) return res; |
| 930 | return parcel->writeStrongBinder(nullptr); |
| 931 | } else { |
| 932 | return producer->exportToParcel(parcel); |
| 933 | } |
| 934 | } |
| 935 | |
| 936 | /* static */ |
| 937 | sp<IGraphicBufferProducer> IGraphicBufferProducer::createFromParcel(const Parcel* parcel) { |
| 938 | uint32_t outMagic = 0; |
| 939 | status_t res = NO_ERROR; |
| 940 | |
| 941 | res = parcel->readUint32(&outMagic); |
| 942 | if (res != NO_ERROR) { |
| 943 | ALOGE("createFromParcel: Failed to read magic, error=%d.", res); |
| 944 | return nullptr; |
| 945 | } |
| 946 | |
| 947 | switch (outMagic) { |
| 948 | case USE_BUFFER_QUEUE: { |
| 949 | sp<IBinder> binder; |
| 950 | res = parcel->readNullableStrongBinder(&binder); |
| 951 | if (res != NO_ERROR) { |
| 952 | ALOGE("createFromParcel: Can't read strong binder."); |
| 953 | return nullptr; |
| 954 | } |
| 955 | return interface_cast<IGraphicBufferProducer>(binder); |
| 956 | } |
| 957 | case USE_BUFFER_HUB: { |
| 958 | ALOGE("createFromParcel: BufferHub not implemented."); |
Jiyong Park | a75d3d6 | 2018-04-09 12:16:30 +0900 | [diff] [blame] | 959 | #ifndef NO_BUFFERHUB |
Jiwen 'Steve' Cai | c90a77f | 2018-01-14 15:42:29 -0800 | [diff] [blame] | 960 | dvr::ProducerQueueParcelable producerParcelable; |
| 961 | res = producerParcelable.readFromParcel(parcel); |
| 962 | if (res != NO_ERROR) { |
| 963 | ALOGE("createFromParcel: Failed to read from parcel, error=%d", res); |
| 964 | return nullptr; |
| 965 | } |
| 966 | return BufferHubProducer::Create(std::move(producerParcelable)); |
Jiyong Park | a75d3d6 | 2018-04-09 12:16:30 +0900 | [diff] [blame] | 967 | #else |
| 968 | return nullptr; |
| 969 | #endif |
Jiwen 'Steve' Cai | c90a77f | 2018-01-14 15:42:29 -0800 | [diff] [blame] | 970 | } |
| 971 | default: { |
| 972 | ALOGE("createFromParcel: Unexpected mgaic: 0x%x.", outMagic); |
| 973 | return nullptr; |
| 974 | } |
| 975 | } |
| 976 | } |
| 977 | |
| 978 | // ---------------------------------------------------------------------------- |
| 979 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 980 | status_t BnGraphicBufferProducer::onTransact( |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 981 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 982 | { |
| 983 | switch(code) { |
| 984 | case REQUEST_BUFFER: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 985 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 986 | int bufferIdx = data.readInt32(); |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 987 | sp<GraphicBuffer> buffer; |
| 988 | int result = requestBuffer(bufferIdx, &buffer); |
Yi Kong | 48a619f | 2018-06-05 16:34:59 -0700 | [diff] [blame] | 989 | reply->writeInt32(buffer != nullptr); |
| 990 | if (buffer != nullptr) { |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 991 | reply->write(*buffer); |
| 992 | } |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 993 | reply->writeInt32(result); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 994 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 995 | } |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 996 | case REQUEST_BUFFERS: { |
| 997 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 998 | std::vector<int32_t> slots; |
| 999 | std::vector<RequestBufferOutput> outputs; |
| 1000 | status_t result = data.readInt32Vector(&slots); |
| 1001 | if (result != NO_ERROR) { |
| 1002 | return result; |
| 1003 | } |
| 1004 | (void)requestBuffers(slots, &outputs); |
| 1005 | result = reply->writeVectorSize(outputs); |
| 1006 | for (const RequestBufferOutput& output : outputs) { |
| 1007 | if (result != NO_ERROR) { |
| 1008 | return result; |
| 1009 | } |
| 1010 | result = reply->write(output); |
| 1011 | } |
| 1012 | return result; |
| 1013 | } |
Pablo Ceballos | fa45535 | 2015-08-12 17:47:47 -0700 | [diff] [blame] | 1014 | case SET_MAX_DEQUEUED_BUFFER_COUNT: { |
| 1015 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1016 | int maxDequeuedBuffers = data.readInt32(); |
| 1017 | int result = setMaxDequeuedBufferCount(maxDequeuedBuffers); |
| 1018 | reply->writeInt32(result); |
| 1019 | return NO_ERROR; |
| 1020 | } |
| 1021 | case SET_ASYNC_MODE: { |
| 1022 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1023 | bool async = data.readInt32(); |
| 1024 | int result = setAsyncMode(async); |
| 1025 | reply->writeInt32(result); |
| 1026 | return NO_ERROR; |
| 1027 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1028 | case DEQUEUE_BUFFER: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 1029 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1030 | uint32_t width = data.readUint32(); |
| 1031 | uint32_t height = data.readUint32(); |
| 1032 | PixelFormat format = static_cast<PixelFormat>(data.readInt32()); |
Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 1033 | uint64_t usage = data.readUint64(); |
Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 1034 | uint64_t bufferAge = 0; |
Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1035 | bool getTimestamps = data.readBool(); |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1036 | |
Naveen Leekha | 12ba0f5 | 2015-09-21 17:28:04 -0700 | [diff] [blame] | 1037 | int buf = 0; |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1038 | sp<Fence> fence = Fence::NO_FENCE; |
Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1039 | FrameEventHistoryDelta frameTimestamps; |
Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 1040 | int result = dequeueBuffer(&buf, &fence, width, height, format, usage, &bufferAge, |
| 1041 | getTimestamps ? &frameTimestamps : nullptr); |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1042 | |
Tobin Ehlis | 209e5fb | 2019-03-26 14:06:29 -0600 | [diff] [blame] | 1043 | if (fence == nullptr) { |
| 1044 | ALOGE("dequeueBuffer returned a NULL fence, setting to Fence::NO_FENCE"); |
| 1045 | fence = Fence::NO_FENCE; |
| 1046 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1047 | reply->writeInt32(buf); |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1048 | reply->write(*fence); |
Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 1049 | reply->writeUint64(bufferAge); |
Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1050 | if (getTimestamps) { |
| 1051 | reply->write(frameTimestamps); |
| 1052 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1053 | reply->writeInt32(result); |
| 1054 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1055 | } |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 1056 | case DEQUEUE_BUFFERS: { |
| 1057 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1058 | std::vector<DequeueBufferInput> inputs; |
| 1059 | std::vector<DequeueBufferOutput> outputs; |
| 1060 | status_t result = data.resizeOutVector(&inputs); |
| 1061 | if (result != NO_ERROR) { |
| 1062 | return result; |
| 1063 | } |
| 1064 | for (DequeueBufferInput& input : inputs) { |
| 1065 | result = data.read(input); |
| 1066 | if (result != NO_ERROR) { |
| 1067 | return result; |
| 1068 | } |
| 1069 | } |
| 1070 | (void)dequeueBuffers(inputs, &outputs); |
| 1071 | result = reply->writeVectorSize(outputs); |
| 1072 | for (const DequeueBufferOutput& output : outputs) { |
| 1073 | if (result != NO_ERROR) { |
| 1074 | return result; |
| 1075 | } |
| 1076 | result = reply->write(output); |
| 1077 | } |
| 1078 | return result; |
| 1079 | } |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 1080 | case DETACH_BUFFER: { |
| 1081 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1082 | int slot = data.readInt32(); |
| 1083 | int result = detachBuffer(slot); |
| 1084 | reply->writeInt32(result); |
| 1085 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1086 | } |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 1087 | case DETACH_BUFFERS: { |
| 1088 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1089 | std::vector<int32_t> slots; |
| 1090 | std::vector<status_t> results; |
| 1091 | status_t result = data.readInt32Vector(&slots); |
| 1092 | if (result != NO_ERROR) { |
| 1093 | return result; |
| 1094 | } |
| 1095 | (void)detachBuffers(slots, &results); |
| 1096 | return reply->writeInt32Vector(results); |
| 1097 | } |
Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 1098 | case DETACH_NEXT_BUFFER: { |
| 1099 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1100 | sp<GraphicBuffer> buffer; |
| 1101 | sp<Fence> fence; |
| 1102 | int32_t result = detachNextBuffer(&buffer, &fence); |
| 1103 | reply->writeInt32(result); |
| 1104 | if (result == NO_ERROR) { |
Yi Kong | 48a619f | 2018-06-05 16:34:59 -0700 | [diff] [blame] | 1105 | reply->writeInt32(buffer != nullptr); |
| 1106 | if (buffer != nullptr) { |
Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 1107 | reply->write(*buffer); |
| 1108 | } |
Yi Kong | 48a619f | 2018-06-05 16:34:59 -0700 | [diff] [blame] | 1109 | reply->writeInt32(fence != nullptr); |
| 1110 | if (fence != nullptr) { |
Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 1111 | reply->write(*fence); |
| 1112 | } |
| 1113 | } |
| 1114 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1115 | } |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 1116 | case ATTACH_BUFFER: { |
| 1117 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1118 | sp<GraphicBuffer> buffer = new GraphicBuffer(); |
Pablo Ceballos | 70636b3 | 2016-07-06 15:24:54 -0700 | [diff] [blame] | 1119 | status_t result = data.read(*buffer.get()); |
Naveen Leekha | 12ba0f5 | 2015-09-21 17:28:04 -0700 | [diff] [blame] | 1120 | int slot = 0; |
Pablo Ceballos | 70636b3 | 2016-07-06 15:24:54 -0700 | [diff] [blame] | 1121 | if (result == NO_ERROR) { |
| 1122 | result = attachBuffer(&slot, buffer); |
| 1123 | } |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 1124 | reply->writeInt32(slot); |
| 1125 | reply->writeInt32(result); |
| 1126 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1127 | } |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 1128 | case ATTACH_BUFFERS: { |
| 1129 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1130 | std::vector<sp<GraphicBuffer>> buffers; |
| 1131 | status_t result = data.resizeOutVector(&buffers); |
| 1132 | if (result != NO_ERROR) { |
| 1133 | return result; |
| 1134 | } |
| 1135 | for (sp<GraphicBuffer>& buffer : buffers) { |
| 1136 | buffer = new GraphicBuffer(); |
| 1137 | result = data.read(*buffer.get()); |
| 1138 | if (result != NO_ERROR) { |
| 1139 | return result; |
| 1140 | } |
| 1141 | } |
| 1142 | std::vector<AttachBufferOutput> outputs; |
| 1143 | (void)attachBuffers(buffers, &outputs); |
| 1144 | result = reply->writeVectorSize(outputs); |
| 1145 | for (const AttachBufferOutput& output : outputs) { |
| 1146 | if (result != NO_ERROR) { |
| 1147 | return result; |
| 1148 | } |
| 1149 | result = reply->write(output); |
| 1150 | } |
| 1151 | return result; |
| 1152 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1153 | case QUEUE_BUFFER: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 1154 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1155 | |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1156 | int buf = data.readInt32(); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 1157 | QueueBufferInput input(data); |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1158 | QueueBufferOutput output; |
| 1159 | status_t result = queueBuffer(buf, input, &output); |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1160 | reply->write(output); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1161 | reply->writeInt32(result); |
Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1162 | |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1163 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1164 | } |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 1165 | case QUEUE_BUFFERS: { |
| 1166 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1167 | std::vector<QueueBufferInput> inputs; |
| 1168 | status_t result = data.resizeOutVector(&inputs); |
| 1169 | if (result != NO_ERROR) { |
| 1170 | return result; |
| 1171 | } |
| 1172 | for (QueueBufferInput& input : inputs) { |
| 1173 | result = data.read(input); |
| 1174 | if (result != NO_ERROR) { |
| 1175 | return result; |
| 1176 | } |
| 1177 | } |
| 1178 | std::vector<QueueBufferOutput> outputs; |
| 1179 | (void)queueBuffers(inputs, &outputs); |
| 1180 | result = reply->writeVectorSize(outputs); |
| 1181 | for (const QueueBufferOutput& output : outputs) { |
| 1182 | if (result != NO_ERROR) { |
| 1183 | return result; |
| 1184 | } |
| 1185 | result = reply->write(output); |
| 1186 | } |
| 1187 | return result; |
| 1188 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1189 | case CANCEL_BUFFER: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 1190 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1191 | int buf = data.readInt32(); |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame] | 1192 | sp<Fence> fence = new Fence(); |
Pablo Ceballos | 70636b3 | 2016-07-06 15:24:54 -0700 | [diff] [blame] | 1193 | status_t result = data.read(*fence.get()); |
| 1194 | if (result == NO_ERROR) { |
| 1195 | result = cancelBuffer(buf, fence); |
| 1196 | } |
Pablo Ceballos | 583b1b3 | 2015-09-03 18:23:52 -0700 | [diff] [blame] | 1197 | reply->writeInt32(result); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1198 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1199 | } |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 1200 | case CANCEL_BUFFERS: { |
| 1201 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1202 | std::vector<CancelBufferInput> inputs; |
| 1203 | status_t result = data.resizeOutVector(&inputs); |
| 1204 | for (CancelBufferInput& input : inputs) { |
| 1205 | if (result != NO_ERROR) { |
| 1206 | return result; |
| 1207 | } |
| 1208 | result = data.read(input); |
| 1209 | } |
| 1210 | if (result != NO_ERROR) { |
| 1211 | return result; |
| 1212 | } |
| 1213 | std::vector<status_t> results; |
| 1214 | result = cancelBuffers(inputs, &results); |
| 1215 | if (result != NO_ERROR) { |
| 1216 | return result; |
| 1217 | } |
| 1218 | return reply->writeInt32Vector(results); |
| 1219 | } |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 1220 | case QUERY: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 1221 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Naveen Leekha | 12ba0f5 | 2015-09-21 17:28:04 -0700 | [diff] [blame] | 1222 | int value = 0; |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 1223 | int what = data.readInt32(); |
| 1224 | int res = query(what, &value); |
| 1225 | reply->writeInt32(value); |
| 1226 | reply->writeInt32(res); |
| 1227 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1228 | } |
Yin-Chia Yeh | 64ee5f5 | 2020-01-02 17:53:18 +0700 | [diff] [blame^] | 1229 | case QUERY_MULTIPLE: { |
| 1230 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1231 | std::vector<int32_t> inputs; |
| 1232 | status_t result = data.readInt32Vector(&inputs); |
| 1233 | if (result != NO_ERROR) { |
| 1234 | return result; |
| 1235 | } |
| 1236 | std::vector<QueryOutput> outputs; |
| 1237 | result = query(inputs, &outputs); |
| 1238 | if (result != NO_ERROR) { |
| 1239 | return result; |
| 1240 | } |
| 1241 | result = reply->writeVectorSize(outputs); |
| 1242 | for (const QueryOutput& output : outputs) { |
| 1243 | if (result != NO_ERROR) { |
| 1244 | return result; |
| 1245 | } |
| 1246 | result = reply->write(output); |
| 1247 | } |
| 1248 | return result; |
| 1249 | } |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 1250 | case CONNECT: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 1251 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 1252 | sp<IProducerListener> listener; |
| 1253 | if (data.readInt32() == 1) { |
| 1254 | listener = IProducerListener::asInterface(data.readStrongBinder()); |
| 1255 | } |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 1256 | int api = data.readInt32(); |
Mathias Agopian | 595264f | 2013-07-16 22:56:09 -0700 | [diff] [blame] | 1257 | bool producerControlledByApp = data.readInt32(); |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1258 | QueueBufferOutput output; |
| 1259 | status_t res = connect(listener, api, producerControlledByApp, &output); |
| 1260 | reply->write(output); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 1261 | reply->writeInt32(res); |
| 1262 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1263 | } |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 1264 | case DISCONNECT: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 1265 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 1266 | int api = data.readInt32(); |
Robert Carr | 97b9c86 | 2016-09-08 13:54:35 -0700 | [diff] [blame] | 1267 | DisconnectMode mode = static_cast<DisconnectMode>(data.readInt32()); |
| 1268 | status_t res = disconnect(api, mode); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 1269 | reply->writeInt32(res); |
| 1270 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1271 | } |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 1272 | case SET_SIDEBAND_STREAM: { |
| 1273 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1274 | sp<NativeHandle> stream; |
| 1275 | if (data.readInt32()) { |
Wonsik Kim | 0ec54e1 | 2014-03-21 10:46:24 +0900 | [diff] [blame] | 1276 | stream = NativeHandle::create(data.readNativeHandle(), true); |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 1277 | } |
| 1278 | status_t result = setSidebandStream(stream); |
| 1279 | reply->writeInt32(result); |
| 1280 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1281 | } |
Dan Stoza | 9de7293 | 2015-04-16 17:28:43 -0700 | [diff] [blame] | 1282 | case ALLOCATE_BUFFERS: { |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 1283 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 1284 | uint32_t width = data.readUint32(); |
| 1285 | uint32_t height = data.readUint32(); |
| 1286 | PixelFormat format = static_cast<PixelFormat>(data.readInt32()); |
Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 1287 | uint64_t usage = data.readUint64(); |
Pablo Ceballos | 567dbbb | 2015-08-26 18:59:08 -0700 | [diff] [blame] | 1288 | allocateBuffers(width, height, format, usage); |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 1289 | return NO_ERROR; |
Dan Stoza | 9de7293 | 2015-04-16 17:28:43 -0700 | [diff] [blame] | 1290 | } |
| 1291 | case ALLOW_ALLOCATION: { |
| 1292 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1293 | bool allow = static_cast<bool>(data.readInt32()); |
| 1294 | status_t result = allowAllocation(allow); |
| 1295 | reply->writeInt32(result); |
| 1296 | return NO_ERROR; |
| 1297 | } |
Dan Stoza | 812ed06 | 2015-06-02 15:45:22 -0700 | [diff] [blame] | 1298 | case SET_GENERATION_NUMBER: { |
| 1299 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1300 | uint32_t generationNumber = data.readUint32(); |
| 1301 | status_t result = setGenerationNumber(generationNumber); |
| 1302 | reply->writeInt32(result); |
| 1303 | return NO_ERROR; |
| 1304 | } |
Dan Stoza | c6f30bd | 2015-06-08 09:32:50 -0700 | [diff] [blame] | 1305 | case GET_CONSUMER_NAME: { |
| 1306 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1307 | reply->writeString8(getConsumerName()); |
| 1308 | return NO_ERROR; |
| 1309 | } |
Pablo Ceballos | 3559fbf | 2016-03-17 15:50:23 -0700 | [diff] [blame] | 1310 | case SET_SHARED_BUFFER_MODE: { |
Pablo Ceballos | ccdfd60 | 2015-10-07 15:05:45 -0700 | [diff] [blame] | 1311 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Pablo Ceballos | 3559fbf | 2016-03-17 15:50:23 -0700 | [diff] [blame] | 1312 | bool sharedBufferMode = data.readInt32(); |
| 1313 | status_t result = setSharedBufferMode(sharedBufferMode); |
Pablo Ceballos | ccdfd60 | 2015-10-07 15:05:45 -0700 | [diff] [blame] | 1314 | reply->writeInt32(result); |
| 1315 | return NO_ERROR; |
| 1316 | } |
Pablo Ceballos | ff95aab | 2016-01-13 17:09:58 -0800 | [diff] [blame] | 1317 | case SET_AUTO_REFRESH: { |
| 1318 | CHECK_INTERFACE(IGraphicBuffer, data, reply); |
| 1319 | bool autoRefresh = data.readInt32(); |
| 1320 | status_t result = setAutoRefresh(autoRefresh); |
| 1321 | reply->writeInt32(result); |
| 1322 | return NO_ERROR; |
| 1323 | } |
Dan Stoza | 127fc63 | 2015-06-30 13:43:32 -0700 | [diff] [blame] | 1324 | case SET_DEQUEUE_TIMEOUT: { |
| 1325 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1326 | nsecs_t timeout = data.readInt64(); |
| 1327 | status_t result = setDequeueTimeout(timeout); |
| 1328 | reply->writeInt32(result); |
| 1329 | return NO_ERROR; |
| 1330 | } |
Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 1331 | case GET_LAST_QUEUED_BUFFER: { |
| 1332 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1333 | sp<GraphicBuffer> buffer(nullptr); |
| 1334 | sp<Fence> fence(Fence::NO_FENCE); |
John Reck | 1a61da5 | 2016-04-28 13:18:15 -0700 | [diff] [blame] | 1335 | float transform[16] = {}; |
| 1336 | status_t result = getLastQueuedBuffer(&buffer, &fence, transform); |
Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 1337 | reply->writeInt32(result); |
| 1338 | if (result != NO_ERROR) { |
| 1339 | return result; |
| 1340 | } |
John Reck | ce8e5df | 2016-04-28 10:12:47 -0700 | [diff] [blame] | 1341 | if (!buffer.get()) { |
| 1342 | reply->writeBool(false); |
| 1343 | } else { |
| 1344 | reply->writeBool(true); |
| 1345 | result = reply->write(*buffer); |
John Reck | 1a61da5 | 2016-04-28 13:18:15 -0700 | [diff] [blame] | 1346 | if (result == NO_ERROR) { |
| 1347 | reply->write(transform, sizeof(float) * 16); |
| 1348 | } |
John Reck | ce8e5df | 2016-04-28 10:12:47 -0700 | [diff] [blame] | 1349 | } |
Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 1350 | if (result != NO_ERROR) { |
| 1351 | ALOGE("getLastQueuedBuffer failed to write buffer: %d", result); |
| 1352 | return result; |
| 1353 | } |
Tobin Ehlis | 209e5fb | 2019-03-26 14:06:29 -0600 | [diff] [blame] | 1354 | if (fence == nullptr) { |
| 1355 | ALOGE("getLastQueuedBuffer returned a NULL fence, setting to Fence::NO_FENCE"); |
| 1356 | fence = Fence::NO_FENCE; |
| 1357 | } |
Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 1358 | result = reply->write(*fence); |
| 1359 | if (result != NO_ERROR) { |
| 1360 | ALOGE("getLastQueuedBuffer failed to write fence: %d", result); |
| 1361 | return result; |
| 1362 | } |
| 1363 | return NO_ERROR; |
| 1364 | } |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 1365 | case GET_FRAME_TIMESTAMPS: { |
| 1366 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1367 | FrameEventHistoryDelta frameTimestamps; |
| 1368 | getFrameTimestamps(&frameTimestamps); |
| 1369 | status_t result = reply->write(frameTimestamps); |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 1370 | if (result != NO_ERROR) { |
Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1371 | ALOGE("BnGBP::GET_FRAME_TIMESTAMPS failed to write buffer: %d", |
| 1372 | result); |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 1373 | return result; |
| 1374 | } |
Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 1375 | return NO_ERROR; |
| 1376 | } |
Pablo Ceballos | 8e3e92b | 2016-06-27 17:56:53 -0700 | [diff] [blame] | 1377 | case GET_UNIQUE_ID: { |
| 1378 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1379 | uint64_t outId = 0; |
| 1380 | status_t actualResult = getUniqueId(&outId); |
| 1381 | status_t result = reply->writeInt32(actualResult); |
| 1382 | if (result != NO_ERROR) { |
| 1383 | return result; |
| 1384 | } |
| 1385 | result = reply->writeUint64(outId); |
| 1386 | if (result != NO_ERROR) { |
| 1387 | return result; |
| 1388 | } |
| 1389 | return NO_ERROR; |
| 1390 | } |
Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 1391 | case GET_CONSUMER_USAGE: { |
| 1392 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1393 | uint64_t outUsage = 0; |
| 1394 | status_t actualResult = getConsumerUsage(&outUsage); |
| 1395 | status_t result = reply->writeInt32(actualResult); |
| 1396 | if (result != NO_ERROR) { |
| 1397 | return result; |
| 1398 | } |
| 1399 | result = reply->writeUint64(outUsage); |
| 1400 | if (result != NO_ERROR) { |
| 1401 | return result; |
| 1402 | } |
| 1403 | return NO_ERROR; |
| 1404 | } |
Sungtak Lee | 3249fb6 | 2019-03-02 16:40:47 -0800 | [diff] [blame] | 1405 | case SET_LEGACY_BUFFER_DROP: { |
| 1406 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 1407 | bool drop = data.readInt32(); |
| 1408 | int result = setLegacyBufferDrop(drop); |
| 1409 | reply->writeInt32(result); |
| 1410 | return NO_ERROR; |
| 1411 | } |
Yiwei Zhang | 538cedc | 2019-06-24 19:35:03 -0700 | [diff] [blame] | 1412 | case SET_AUTO_PREROTATION: { |
| 1413 | CHECK_INTERFACE(IGraphicBuffer, data, reply); |
| 1414 | bool autoPrerotation = data.readBool(); |
| 1415 | status_t result = setAutoPrerotation(autoPrerotation); |
| 1416 | reply->writeInt32(result); |
| 1417 | return NO_ERROR; |
| 1418 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1419 | } |
| 1420 | return BBinder::onTransact(code, data, reply, flags); |
| 1421 | } |
| 1422 | |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1423 | }; // namespace android |