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