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