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> |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 23 | #include <utils/Timers.h> |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 24 | #include <utils/Vector.h> |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 25 | |
| 26 | #include <binder/Parcel.h> |
| 27 | #include <binder/IInterface.h> |
| 28 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 29 | #include <gui/IGraphicBufferProducer.h> |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 30 | #include <gui/IProducerListener.h> |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 31 | |
| 32 | namespace android { |
| 33 | // ---------------------------------------------------------------------------- |
| 34 | |
| 35 | enum { |
| 36 | REQUEST_BUFFER = IBinder::FIRST_CALL_TRANSACTION, |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 37 | DEQUEUE_BUFFER, |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 38 | DETACH_BUFFER, |
Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 39 | DETACH_NEXT_BUFFER, |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 40 | ATTACH_BUFFER, |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 41 | QUEUE_BUFFER, |
| 42 | CANCEL_BUFFER, |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 43 | QUERY, |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 44 | CONNECT, |
| 45 | DISCONNECT, |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 46 | SET_SIDEBAND_STREAM, |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 47 | ALLOCATE_BUFFERS, |
Dan Stoza | 9de7293 | 2015-04-16 17:28:43 -0700 | [diff] [blame] | 48 | ALLOW_ALLOCATION, |
Dan Stoza | 812ed06 | 2015-06-02 15:45:22 -0700 | [diff] [blame] | 49 | SET_GENERATION_NUMBER, |
Dan Stoza | c6f30bd | 2015-06-08 09:32:50 -0700 | [diff] [blame] | 50 | GET_CONSUMER_NAME, |
Pablo Ceballos | fa45535 | 2015-08-12 17:47:47 -0700 | [diff] [blame] | 51 | SET_MAX_DEQUEUED_BUFFER_COUNT, |
Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 52 | SET_ASYNC_MODE, |
| 53 | GET_NEXT_FRAME_NUMBER |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 54 | }; |
| 55 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 56 | class BpGraphicBufferProducer : public BpInterface<IGraphicBufferProducer> |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 57 | { |
| 58 | public: |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 59 | BpGraphicBufferProducer(const sp<IBinder>& impl) |
| 60 | : BpInterface<IGraphicBufferProducer>(impl) |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 61 | { |
| 62 | } |
| 63 | |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 64 | virtual ~BpGraphicBufferProducer(); |
| 65 | |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 66 | virtual status_t requestBuffer(int bufferIdx, sp<GraphicBuffer>* buf) { |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 67 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 68 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 69 | data.writeInt32(bufferIdx); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 70 | status_t result =remote()->transact(REQUEST_BUFFER, data, &reply); |
| 71 | if (result != NO_ERROR) { |
| 72 | return result; |
| 73 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 74 | bool nonNull = reply.readInt32(); |
| 75 | if (nonNull) { |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 76 | *buf = new GraphicBuffer(); |
Lingyun Zhu | 2aff702 | 2012-11-20 19:24:35 +0800 | [diff] [blame] | 77 | result = reply.read(**buf); |
| 78 | if(result != NO_ERROR) { |
| 79 | (*buf).clear(); |
| 80 | return result; |
| 81 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 82 | } |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 83 | result = reply.readInt32(); |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 84 | return result; |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 85 | } |
| 86 | |
Pablo Ceballos | fa45535 | 2015-08-12 17:47:47 -0700 | [diff] [blame] | 87 | virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers) { |
| 88 | Parcel data, reply; |
| 89 | data.writeInterfaceToken( |
| 90 | IGraphicBufferProducer::getInterfaceDescriptor()); |
| 91 | data.writeInt32(maxDequeuedBuffers); |
| 92 | status_t result = remote()->transact(SET_MAX_DEQUEUED_BUFFER_COUNT, |
| 93 | data, &reply); |
| 94 | if (result != NO_ERROR) { |
| 95 | return result; |
| 96 | } |
| 97 | result = reply.readInt32(); |
| 98 | return result; |
| 99 | } |
| 100 | |
| 101 | virtual status_t setAsyncMode(bool async) { |
| 102 | Parcel data, reply; |
| 103 | data.writeInterfaceToken( |
| 104 | IGraphicBufferProducer::getInterfaceDescriptor()); |
| 105 | data.writeInt32(async); |
| 106 | status_t result = remote()->transact(SET_ASYNC_MODE, |
| 107 | data, &reply); |
| 108 | if (result != NO_ERROR) { |
| 109 | return result; |
| 110 | } |
| 111 | result = reply.readInt32(); |
| 112 | return result; |
| 113 | } |
| 114 | |
Pablo Ceballos | 567dbbb | 2015-08-26 18:59:08 -0700 | [diff] [blame] | 115 | virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, uint32_t width, |
| 116 | uint32_t height, PixelFormat format, uint32_t usage) { |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 117 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 118 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 119 | data.writeUint32(width); |
| 120 | data.writeUint32(height); |
| 121 | data.writeInt32(static_cast<int32_t>(format)); |
| 122 | data.writeUint32(usage); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 123 | status_t result = remote()->transact(DEQUEUE_BUFFER, data, &reply); |
| 124 | if (result != NO_ERROR) { |
| 125 | return result; |
| 126 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 127 | *buf = reply.readInt32(); |
Mathias Agopian | ba93b3f | 2013-08-01 15:48:40 -0700 | [diff] [blame] | 128 | bool nonNull = reply.readInt32(); |
| 129 | if (nonNull) { |
Jesse Hall | 4c00cc1 | 2013-03-15 21:34:30 -0700 | [diff] [blame] | 130 | *fence = new Fence(); |
Mathias Agopian | ba93b3f | 2013-08-01 15:48:40 -0700 | [diff] [blame] | 131 | reply.read(**fence); |
Jesse Hall | f785754 | 2012-06-14 15:26:33 -0700 | [diff] [blame] | 132 | } |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 133 | result = reply.readInt32(); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 134 | return result; |
| 135 | } |
| 136 | |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 137 | virtual status_t detachBuffer(int slot) { |
| 138 | Parcel data, reply; |
| 139 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 140 | data.writeInt32(slot); |
| 141 | status_t result = remote()->transact(DETACH_BUFFER, data, &reply); |
| 142 | if (result != NO_ERROR) { |
| 143 | return result; |
| 144 | } |
| 145 | result = reply.readInt32(); |
| 146 | return result; |
| 147 | } |
| 148 | |
Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 149 | virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer, |
| 150 | sp<Fence>* outFence) { |
| 151 | if (outBuffer == NULL) { |
| 152 | ALOGE("detachNextBuffer: outBuffer must not be NULL"); |
| 153 | return BAD_VALUE; |
| 154 | } else if (outFence == NULL) { |
| 155 | ALOGE("detachNextBuffer: outFence must not be NULL"); |
| 156 | return BAD_VALUE; |
| 157 | } |
| 158 | Parcel data, reply; |
| 159 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 160 | status_t result = remote()->transact(DETACH_NEXT_BUFFER, data, &reply); |
| 161 | if (result != NO_ERROR) { |
| 162 | return result; |
| 163 | } |
| 164 | result = reply.readInt32(); |
| 165 | if (result == NO_ERROR) { |
| 166 | bool nonNull = reply.readInt32(); |
| 167 | if (nonNull) { |
| 168 | *outBuffer = new GraphicBuffer; |
| 169 | reply.read(**outBuffer); |
| 170 | } |
| 171 | nonNull = reply.readInt32(); |
| 172 | if (nonNull) { |
| 173 | *outFence = new Fence; |
| 174 | reply.read(**outFence); |
| 175 | } |
| 176 | } |
| 177 | return result; |
| 178 | } |
| 179 | |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 180 | virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer) { |
| 181 | Parcel data, reply; |
| 182 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 183 | data.write(*buffer.get()); |
| 184 | status_t result = remote()->transact(ATTACH_BUFFER, data, &reply); |
| 185 | if (result != NO_ERROR) { |
| 186 | return result; |
| 187 | } |
| 188 | *slot = reply.readInt32(); |
| 189 | result = reply.readInt32(); |
| 190 | return result; |
| 191 | } |
| 192 | |
Mathias Agopian | f0bc2f1 | 2012-04-09 16:14:01 -0700 | [diff] [blame] | 193 | virtual status_t queueBuffer(int buf, |
| 194 | const QueueBufferInput& input, QueueBufferOutput* output) { |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 195 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 196 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 197 | data.writeInt32(buf); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 198 | data.write(input); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 199 | status_t result = remote()->transact(QUEUE_BUFFER, data, &reply); |
| 200 | if (result != NO_ERROR) { |
| 201 | return result; |
| 202 | } |
Mathias Agopian | f0bc2f1 | 2012-04-09 16:14:01 -0700 | [diff] [blame] | 203 | memcpy(output, reply.readInplace(sizeof(*output)), sizeof(*output)); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 204 | result = reply.readInt32(); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 205 | return result; |
| 206 | } |
| 207 | |
Pablo Ceballos | 583b1b3 | 2015-09-03 18:23:52 -0700 | [diff] [blame] | 208 | virtual status_t cancelBuffer(int buf, const sp<Fence>& fence) { |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 209 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 210 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 211 | data.writeInt32(buf); |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame] | 212 | data.write(*fence.get()); |
Pablo Ceballos | 583b1b3 | 2015-09-03 18:23:52 -0700 | [diff] [blame] | 213 | status_t result = remote()->transact(CANCEL_BUFFER, data, &reply); |
| 214 | if (result != NO_ERROR) { |
| 215 | return result; |
| 216 | } |
| 217 | result = reply.readInt32(); |
| 218 | return result; |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 219 | } |
| 220 | |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 221 | virtual int query(int what, int* value) { |
| 222 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 223 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 224 | data.writeInt32(what); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 225 | status_t result = remote()->transact(QUERY, data, &reply); |
| 226 | if (result != NO_ERROR) { |
| 227 | return result; |
| 228 | } |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 229 | value[0] = reply.readInt32(); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 230 | result = reply.readInt32(); |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 231 | return result; |
| 232 | } |
| 233 | |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 234 | virtual status_t connect(const sp<IProducerListener>& listener, |
Mathias Agopian | 365857d | 2013-09-11 19:35:45 -0700 | [diff] [blame] | 235 | int api, bool producerControlledByApp, QueueBufferOutput* output) { |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 236 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 237 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 238 | if (listener != NULL) { |
| 239 | data.writeInt32(1); |
Marco Nelissen | 097ca27 | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 240 | data.writeStrongBinder(IInterface::asBinder(listener)); |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 241 | } else { |
| 242 | data.writeInt32(0); |
| 243 | } |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 244 | data.writeInt32(api); |
Mathias Agopian | 595264f | 2013-07-16 22:56:09 -0700 | [diff] [blame] | 245 | data.writeInt32(producerControlledByApp); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 246 | status_t result = remote()->transact(CONNECT, data, &reply); |
| 247 | if (result != NO_ERROR) { |
| 248 | return result; |
| 249 | } |
Mathias Agopian | 24202f5 | 2012-04-23 14:28:58 -0700 | [diff] [blame] | 250 | memcpy(output, reply.readInplace(sizeof(*output)), sizeof(*output)); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 251 | result = reply.readInt32(); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 252 | return result; |
| 253 | } |
Mathias Agopian | 8072711 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 254 | |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 255 | virtual status_t disconnect(int api) { |
| 256 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 257 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 258 | data.writeInt32(api); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 259 | status_t result =remote()->transact(DISCONNECT, data, &reply); |
| 260 | if (result != NO_ERROR) { |
| 261 | return result; |
| 262 | } |
| 263 | result = reply.readInt32(); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 264 | return result; |
| 265 | } |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 266 | |
| 267 | virtual status_t setSidebandStream(const sp<NativeHandle>& stream) { |
| 268 | Parcel data, reply; |
| 269 | status_t result; |
| 270 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 271 | if (stream.get()) { |
| 272 | data.writeInt32(true); |
| 273 | data.writeNativeHandle(stream->handle()); |
| 274 | } else { |
| 275 | data.writeInt32(false); |
| 276 | } |
| 277 | if ((result = remote()->transact(SET_SIDEBAND_STREAM, data, &reply)) == NO_ERROR) { |
| 278 | result = reply.readInt32(); |
| 279 | } |
| 280 | return result; |
| 281 | } |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 282 | |
Pablo Ceballos | 567dbbb | 2015-08-26 18:59:08 -0700 | [diff] [blame] | 283 | virtual void allocateBuffers(uint32_t width, uint32_t height, |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 284 | PixelFormat format, uint32_t usage) { |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 285 | Parcel data, reply; |
| 286 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 287 | data.writeUint32(width); |
| 288 | data.writeUint32(height); |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 289 | data.writeInt32(static_cast<int32_t>(format)); |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 290 | data.writeUint32(usage); |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 291 | status_t result = remote()->transact(ALLOCATE_BUFFERS, data, &reply); |
| 292 | if (result != NO_ERROR) { |
| 293 | ALOGE("allocateBuffers failed to transact: %d", result); |
| 294 | } |
| 295 | } |
Dan Stoza | 9de7293 | 2015-04-16 17:28:43 -0700 | [diff] [blame] | 296 | |
| 297 | virtual status_t allowAllocation(bool allow) { |
| 298 | Parcel data, reply; |
| 299 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 300 | data.writeInt32(static_cast<int32_t>(allow)); |
| 301 | status_t result = remote()->transact(ALLOW_ALLOCATION, data, &reply); |
| 302 | if (result != NO_ERROR) { |
| 303 | return result; |
| 304 | } |
| 305 | result = reply.readInt32(); |
| 306 | return result; |
| 307 | } |
Dan Stoza | 812ed06 | 2015-06-02 15:45:22 -0700 | [diff] [blame] | 308 | |
| 309 | virtual status_t setGenerationNumber(uint32_t generationNumber) { |
| 310 | Parcel data, reply; |
| 311 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 312 | data.writeUint32(generationNumber); |
| 313 | status_t result = remote()->transact(SET_GENERATION_NUMBER, data, &reply); |
| 314 | if (result == NO_ERROR) { |
| 315 | result = reply.readInt32(); |
| 316 | } |
| 317 | return result; |
| 318 | } |
Dan Stoza | c6f30bd | 2015-06-08 09:32:50 -0700 | [diff] [blame] | 319 | |
| 320 | virtual String8 getConsumerName() const { |
| 321 | Parcel data, reply; |
| 322 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 323 | status_t result = remote()->transact(GET_CONSUMER_NAME, data, &reply); |
| 324 | if (result != NO_ERROR) { |
| 325 | ALOGE("getConsumerName failed to transact: %d", result); |
| 326 | return String8("TransactFailed"); |
| 327 | } |
| 328 | return reply.readString8(); |
| 329 | } |
Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 330 | |
| 331 | virtual uint64_t getNextFrameNumber() const { |
| 332 | Parcel data, reply; |
| 333 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
| 334 | status_t result = remote()->transact(GET_NEXT_FRAME_NUMBER, data, &reply); |
| 335 | if (result != NO_ERROR) { |
| 336 | ALOGE("getNextFrameNumber failed to transact: %d", result); |
| 337 | return 0; |
| 338 | } |
| 339 | uint64_t frameNumber = reply.readUint64(); |
| 340 | return frameNumber; |
| 341 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 342 | }; |
| 343 | |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 344 | // Out-of-line virtual method definition to trigger vtable emission in this |
| 345 | // translation unit (see clang warning -Wweak-vtables) |
| 346 | BpGraphicBufferProducer::~BpGraphicBufferProducer() {} |
| 347 | |
Andy McFadden | 466a192 | 2013-01-08 11:25:51 -0800 | [diff] [blame] | 348 | IMPLEMENT_META_INTERFACE(GraphicBufferProducer, "android.gui.IGraphicBufferProducer"); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 349 | |
| 350 | // ---------------------------------------------------------------------- |
| 351 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 352 | status_t BnGraphicBufferProducer::onTransact( |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 353 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 354 | { |
| 355 | switch(code) { |
| 356 | case REQUEST_BUFFER: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 357 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 358 | int bufferIdx = data.readInt32(); |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 359 | sp<GraphicBuffer> buffer; |
| 360 | int result = requestBuffer(bufferIdx, &buffer); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 361 | reply->writeInt32(buffer != 0); |
| 362 | if (buffer != 0) { |
| 363 | reply->write(*buffer); |
| 364 | } |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 365 | reply->writeInt32(result); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 366 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 367 | } |
Pablo Ceballos | fa45535 | 2015-08-12 17:47:47 -0700 | [diff] [blame] | 368 | case SET_MAX_DEQUEUED_BUFFER_COUNT: { |
| 369 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 370 | int maxDequeuedBuffers = data.readInt32(); |
| 371 | int result = setMaxDequeuedBufferCount(maxDequeuedBuffers); |
| 372 | reply->writeInt32(result); |
| 373 | return NO_ERROR; |
| 374 | } |
| 375 | case SET_ASYNC_MODE: { |
| 376 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 377 | bool async = data.readInt32(); |
| 378 | int result = setAsyncMode(async); |
| 379 | reply->writeInt32(result); |
| 380 | return NO_ERROR; |
| 381 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 382 | case DEQUEUE_BUFFER: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 383 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 384 | uint32_t width = data.readUint32(); |
| 385 | uint32_t height = data.readUint32(); |
| 386 | PixelFormat format = static_cast<PixelFormat>(data.readInt32()); |
| 387 | uint32_t usage = data.readUint32(); |
Naveen Leekha | 12ba0f5 | 2015-09-21 17:28:04 -0700 | [diff] [blame] | 388 | int buf = 0; |
Jesse Hall | f785754 | 2012-06-14 15:26:33 -0700 | [diff] [blame] | 389 | sp<Fence> fence; |
Pablo Ceballos | 567dbbb | 2015-08-26 18:59:08 -0700 | [diff] [blame] | 390 | int result = dequeueBuffer(&buf, &fence, width, height, format, |
| 391 | usage); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 392 | reply->writeInt32(buf); |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame] | 393 | reply->writeInt32(fence != NULL); |
| 394 | if (fence != NULL) { |
Mathias Agopian | ba93b3f | 2013-08-01 15:48:40 -0700 | [diff] [blame] | 395 | reply->write(*fence); |
Jesse Hall | f785754 | 2012-06-14 15:26:33 -0700 | [diff] [blame] | 396 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 397 | reply->writeInt32(result); |
| 398 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 399 | } |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 400 | case DETACH_BUFFER: { |
| 401 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 402 | int slot = data.readInt32(); |
| 403 | int result = detachBuffer(slot); |
| 404 | reply->writeInt32(result); |
| 405 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 406 | } |
Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 407 | case DETACH_NEXT_BUFFER: { |
| 408 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 409 | sp<GraphicBuffer> buffer; |
| 410 | sp<Fence> fence; |
| 411 | int32_t result = detachNextBuffer(&buffer, &fence); |
| 412 | reply->writeInt32(result); |
| 413 | if (result == NO_ERROR) { |
| 414 | reply->writeInt32(buffer != NULL); |
| 415 | if (buffer != NULL) { |
| 416 | reply->write(*buffer); |
| 417 | } |
| 418 | reply->writeInt32(fence != NULL); |
| 419 | if (fence != NULL) { |
| 420 | reply->write(*fence); |
| 421 | } |
| 422 | } |
| 423 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 424 | } |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 425 | case ATTACH_BUFFER: { |
| 426 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 427 | sp<GraphicBuffer> buffer = new GraphicBuffer(); |
| 428 | data.read(*buffer.get()); |
Naveen Leekha | 12ba0f5 | 2015-09-21 17:28:04 -0700 | [diff] [blame] | 429 | int slot = 0; |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 430 | int result = attachBuffer(&slot, buffer); |
| 431 | reply->writeInt32(slot); |
| 432 | reply->writeInt32(result); |
| 433 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 434 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 435 | case QUEUE_BUFFER: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 436 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 437 | int buf = data.readInt32(); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 438 | QueueBufferInput input(data); |
Mathias Agopian | f0bc2f1 | 2012-04-09 16:14:01 -0700 | [diff] [blame] | 439 | QueueBufferOutput* const output = |
| 440 | reinterpret_cast<QueueBufferOutput *>( |
| 441 | reply->writeInplace(sizeof(QueueBufferOutput))); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 442 | status_t result = queueBuffer(buf, input, output); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 443 | reply->writeInt32(result); |
| 444 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 445 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 446 | case CANCEL_BUFFER: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 447 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 448 | int buf = data.readInt32(); |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame] | 449 | sp<Fence> fence = new Fence(); |
| 450 | data.read(*fence.get()); |
Pablo Ceballos | 583b1b3 | 2015-09-03 18:23:52 -0700 | [diff] [blame] | 451 | status_t result = cancelBuffer(buf, fence); |
| 452 | reply->writeInt32(result); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 453 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 454 | } |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 455 | case QUERY: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 456 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Naveen Leekha | 12ba0f5 | 2015-09-21 17:28:04 -0700 | [diff] [blame] | 457 | int value = 0; |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 458 | int what = data.readInt32(); |
| 459 | int res = query(what, &value); |
| 460 | reply->writeInt32(value); |
| 461 | reply->writeInt32(res); |
| 462 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 463 | } |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 464 | case CONNECT: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 465 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 466 | sp<IProducerListener> listener; |
| 467 | if (data.readInt32() == 1) { |
| 468 | listener = IProducerListener::asInterface(data.readStrongBinder()); |
| 469 | } |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 470 | int api = data.readInt32(); |
Mathias Agopian | 595264f | 2013-07-16 22:56:09 -0700 | [diff] [blame] | 471 | bool producerControlledByApp = data.readInt32(); |
Mathias Agopian | 24202f5 | 2012-04-23 14:28:58 -0700 | [diff] [blame] | 472 | QueueBufferOutput* const output = |
| 473 | reinterpret_cast<QueueBufferOutput *>( |
| 474 | reply->writeInplace(sizeof(QueueBufferOutput))); |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 475 | status_t res = connect(listener, api, producerControlledByApp, output); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 476 | reply->writeInt32(res); |
| 477 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 478 | } |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 479 | case DISCONNECT: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 480 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 481 | int api = data.readInt32(); |
Mathias Agopian | 2773004 | 2011-07-14 20:20:58 -0700 | [diff] [blame] | 482 | status_t res = disconnect(api); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 483 | reply->writeInt32(res); |
| 484 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 485 | } |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 486 | case SET_SIDEBAND_STREAM: { |
| 487 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 488 | sp<NativeHandle> stream; |
| 489 | if (data.readInt32()) { |
Wonsik Kim | 0ec54e1 | 2014-03-21 10:46:24 +0900 | [diff] [blame] | 490 | stream = NativeHandle::create(data.readNativeHandle(), true); |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 491 | } |
| 492 | status_t result = setSidebandStream(stream); |
| 493 | reply->writeInt32(result); |
| 494 | return NO_ERROR; |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 495 | } |
Dan Stoza | 9de7293 | 2015-04-16 17:28:43 -0700 | [diff] [blame] | 496 | case ALLOCATE_BUFFERS: { |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 497 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 498 | uint32_t width = data.readUint32(); |
| 499 | uint32_t height = data.readUint32(); |
| 500 | PixelFormat format = static_cast<PixelFormat>(data.readInt32()); |
| 501 | uint32_t usage = data.readUint32(); |
Pablo Ceballos | 567dbbb | 2015-08-26 18:59:08 -0700 | [diff] [blame] | 502 | allocateBuffers(width, height, format, usage); |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 503 | return NO_ERROR; |
Dan Stoza | 9de7293 | 2015-04-16 17:28:43 -0700 | [diff] [blame] | 504 | } |
| 505 | case ALLOW_ALLOCATION: { |
| 506 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 507 | bool allow = static_cast<bool>(data.readInt32()); |
| 508 | status_t result = allowAllocation(allow); |
| 509 | reply->writeInt32(result); |
| 510 | return NO_ERROR; |
| 511 | } |
Dan Stoza | 812ed06 | 2015-06-02 15:45:22 -0700 | [diff] [blame] | 512 | case SET_GENERATION_NUMBER: { |
| 513 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 514 | uint32_t generationNumber = data.readUint32(); |
| 515 | status_t result = setGenerationNumber(generationNumber); |
| 516 | reply->writeInt32(result); |
| 517 | return NO_ERROR; |
| 518 | } |
Dan Stoza | c6f30bd | 2015-06-08 09:32:50 -0700 | [diff] [blame] | 519 | case GET_CONSUMER_NAME: { |
| 520 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 521 | reply->writeString8(getConsumerName()); |
| 522 | return NO_ERROR; |
| 523 | } |
Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 524 | case GET_NEXT_FRAME_NUMBER: { |
| 525 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
| 526 | uint64_t frameNumber = getNextFrameNumber(); |
| 527 | reply->writeUint64(frameNumber); |
| 528 | return NO_ERROR; |
| 529 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 530 | } |
| 531 | return BBinder::onTransact(code, data, reply, flags); |
| 532 | } |
| 533 | |
| 534 | // ---------------------------------------------------------------------------- |
| 535 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 536 | IGraphicBufferProducer::QueueBufferInput::QueueBufferInput(const Parcel& parcel) { |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 537 | parcel.read(*this); |
| 538 | } |
| 539 | |
Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 540 | size_t IGraphicBufferProducer::QueueBufferInput::getFlattenedSize() const { |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 541 | return sizeof(timestamp) |
Andy McFadden | 3c25621 | 2013-08-16 14:55:39 -0700 | [diff] [blame] | 542 | + sizeof(isAutoTimestamp) |
Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 543 | + sizeof(dataSpace) |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 544 | + sizeof(crop) |
| 545 | + sizeof(scalingMode) |
| 546 | + sizeof(transform) |
Ruben Brunk | 1681d95 | 2014-06-27 15:51:55 -0700 | [diff] [blame] | 547 | + sizeof(stickyTransform) |
Dan Stoza | 5065a55 | 2015-03-17 16:23:42 -0700 | [diff] [blame] | 548 | + fence->getFlattenedSize() |
| 549 | + surfaceDamage.getFlattenedSize(); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 550 | } |
| 551 | |
Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 552 | size_t IGraphicBufferProducer::QueueBufferInput::getFdCount() const { |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame] | 553 | return fence->getFdCount(); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 554 | } |
| 555 | |
Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 556 | status_t IGraphicBufferProducer::QueueBufferInput::flatten( |
| 557 | void*& buffer, size_t& size, int*& fds, size_t& count) const |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 558 | { |
Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 559 | if (size < getFlattenedSize()) { |
| 560 | return NO_MEMORY; |
| 561 | } |
| 562 | FlattenableUtils::write(buffer, size, timestamp); |
Andy McFadden | 3c25621 | 2013-08-16 14:55:39 -0700 | [diff] [blame] | 563 | FlattenableUtils::write(buffer, size, isAutoTimestamp); |
Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 564 | FlattenableUtils::write(buffer, size, dataSpace); |
Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 565 | FlattenableUtils::write(buffer, size, crop); |
| 566 | FlattenableUtils::write(buffer, size, scalingMode); |
| 567 | FlattenableUtils::write(buffer, size, transform); |
Ruben Brunk | 1681d95 | 2014-06-27 15:51:55 -0700 | [diff] [blame] | 568 | FlattenableUtils::write(buffer, size, stickyTransform); |
Dan Stoza | 5065a55 | 2015-03-17 16:23:42 -0700 | [diff] [blame] | 569 | status_t result = fence->flatten(buffer, size, fds, count); |
| 570 | if (result != NO_ERROR) { |
| 571 | return result; |
| 572 | } |
| 573 | return surfaceDamage.flatten(buffer, size); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 574 | } |
| 575 | |
Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 576 | status_t IGraphicBufferProducer::QueueBufferInput::unflatten( |
| 577 | void const*& buffer, size_t& size, int const*& fds, size_t& count) |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 578 | { |
Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 579 | size_t minNeeded = |
| 580 | sizeof(timestamp) |
Andy McFadden | 3c25621 | 2013-08-16 14:55:39 -0700 | [diff] [blame] | 581 | + sizeof(isAutoTimestamp) |
Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 582 | + sizeof(dataSpace) |
Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 583 | + sizeof(crop) |
| 584 | + sizeof(scalingMode) |
| 585 | + sizeof(transform) |
Pablo Ceballos | 567dbbb | 2015-08-26 18:59:08 -0700 | [diff] [blame] | 586 | + sizeof(stickyTransform); |
Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 587 | |
| 588 | if (size < minNeeded) { |
| 589 | return NO_MEMORY; |
| 590 | } |
| 591 | |
| 592 | FlattenableUtils::read(buffer, size, timestamp); |
Andy McFadden | 3c25621 | 2013-08-16 14:55:39 -0700 | [diff] [blame] | 593 | FlattenableUtils::read(buffer, size, isAutoTimestamp); |
Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 594 | FlattenableUtils::read(buffer, size, dataSpace); |
Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 595 | FlattenableUtils::read(buffer, size, crop); |
| 596 | FlattenableUtils::read(buffer, size, scalingMode); |
| 597 | FlattenableUtils::read(buffer, size, transform); |
Ruben Brunk | 1681d95 | 2014-06-27 15:51:55 -0700 | [diff] [blame] | 598 | FlattenableUtils::read(buffer, size, stickyTransform); |
Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 599 | |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame] | 600 | fence = new Fence(); |
Dan Stoza | 5065a55 | 2015-03-17 16:23:42 -0700 | [diff] [blame] | 601 | status_t result = fence->unflatten(buffer, size, fds, count); |
| 602 | if (result != NO_ERROR) { |
| 603 | return result; |
| 604 | } |
| 605 | return surfaceDamage.unflatten(buffer, size); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 606 | } |
| 607 | |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 608 | }; // namespace android |