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