blob: 89d5ea29af827f66aa1e8691c0b427e6c0fdb444 [file] [log] [blame]
Jamie Gennis8ba32fa2010-12-20 11:27:26 -08001/*
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 Hall399184a2014-03-03 15:42:54 -080021#include <utils/NativeHandle.h>
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080022#include <utils/RefBase.h>
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080023#include <utils/Timers.h>
Jesse Hall399184a2014-03-03 15:42:54 -080024#include <utils/Vector.h>
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080025
26#include <binder/Parcel.h>
27#include <binder/IInterface.h>
28
Andy McFadden2adaf042012-12-18 09:49:45 -080029#include <gui/IGraphicBufferProducer.h>
Dan Stozaf0eaf252014-03-21 13:05:51 -070030#include <gui/IProducerListener.h>
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080031
32namespace android {
33// ----------------------------------------------------------------------------
34
35enum {
36 REQUEST_BUFFER = IBinder::FIRST_CALL_TRANSACTION,
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080037 DEQUEUE_BUFFER,
Dan Stoza9f3053d2014-03-06 15:14:33 -080038 DETACH_BUFFER,
Dan Stozad9822a32014-03-28 15:25:31 -070039 DETACH_NEXT_BUFFER,
Dan Stoza9f3053d2014-03-06 15:14:33 -080040 ATTACH_BUFFER,
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080041 QUEUE_BUFFER,
42 CANCEL_BUFFER,
Mathias Agopianeafabcd2011-04-20 14:20:59 -070043 QUERY,
Jamie Gennisfe0a87b2011-07-13 19:12:20 -070044 CONNECT,
45 DISCONNECT,
Jesse Hall399184a2014-03-03 15:42:54 -080046 SET_SIDEBAND_STREAM,
Dan Stoza29a3e902014-06-20 13:13:57 -070047 ALLOCATE_BUFFERS,
Dan Stoza9de72932015-04-16 17:28:43 -070048 ALLOW_ALLOCATION,
Dan Stoza812ed062015-06-02 15:45:22 -070049 SET_GENERATION_NUMBER,
Dan Stozac6f30bd2015-06-08 09:32:50 -070050 GET_CONSUMER_NAME,
Pablo Ceballosfa455352015-08-12 17:47:47 -070051 SET_MAX_DEQUEUED_BUFFER_COUNT,
Dan Stoza7dde5992015-05-22 09:51:44 -070052 SET_ASYNC_MODE,
Pablo Ceballosccdfd602015-10-07 15:05:45 -070053 GET_NEXT_FRAME_NUMBER,
Pablo Ceballos3559fbf2016-03-17 15:50:23 -070054 SET_SHARED_BUFFER_MODE,
Pablo Ceballosff95aab2016-01-13 17:09:58 -080055 SET_AUTO_REFRESH,
Dan Stoza127fc632015-06-30 13:43:32 -070056 SET_DEQUEUE_TIMEOUT,
Dan Stoza50101d02016-04-07 16:53:23 -070057 GET_LAST_QUEUED_BUFFER,
Pablo Ceballos0ade2472016-06-30 16:48:02 -070058 GET_FRAME_TIMESTAMPS,
59 GET_UNIQUE_ID
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080060};
61
Andy McFadden2adaf042012-12-18 09:49:45 -080062class BpGraphicBufferProducer : public BpInterface<IGraphicBufferProducer>
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080063{
64public:
Andy McFadden2adaf042012-12-18 09:49:45 -080065 BpGraphicBufferProducer(const sp<IBinder>& impl)
66 : BpInterface<IGraphicBufferProducer>(impl)
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080067 {
68 }
69
Dan Stoza3be1c6b2014-11-18 10:24:03 -080070 virtual ~BpGraphicBufferProducer();
71
Jamie Gennis7b305ff2011-07-19 12:08:33 -070072 virtual status_t requestBuffer(int bufferIdx, sp<GraphicBuffer>* buf) {
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080073 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -080074 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080075 data.writeInt32(bufferIdx);
Jamie Gennis8a29ff22011-10-14 15:03:17 -070076 status_t result =remote()->transact(REQUEST_BUFFER, data, &reply);
77 if (result != NO_ERROR) {
78 return result;
79 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080080 bool nonNull = reply.readInt32();
81 if (nonNull) {
Jamie Gennis7b305ff2011-07-19 12:08:33 -070082 *buf = new GraphicBuffer();
Lingyun Zhu2aff7022012-11-20 19:24:35 +080083 result = reply.read(**buf);
84 if(result != NO_ERROR) {
85 (*buf).clear();
86 return result;
87 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080088 }
Jamie Gennis8a29ff22011-10-14 15:03:17 -070089 result = reply.readInt32();
Jamie Gennis7b305ff2011-07-19 12:08:33 -070090 return result;
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080091 }
92
Pablo Ceballosfa455352015-08-12 17:47:47 -070093 virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers) {
94 Parcel data, reply;
95 data.writeInterfaceToken(
96 IGraphicBufferProducer::getInterfaceDescriptor());
97 data.writeInt32(maxDequeuedBuffers);
98 status_t result = remote()->transact(SET_MAX_DEQUEUED_BUFFER_COUNT,
99 data, &reply);
100 if (result != NO_ERROR) {
101 return result;
102 }
103 result = reply.readInt32();
104 return result;
105 }
106
107 virtual status_t setAsyncMode(bool async) {
108 Parcel data, reply;
109 data.writeInterfaceToken(
110 IGraphicBufferProducer::getInterfaceDescriptor());
111 data.writeInt32(async);
112 status_t result = remote()->transact(SET_ASYNC_MODE,
113 data, &reply);
114 if (result != NO_ERROR) {
115 return result;
116 }
117 result = reply.readInt32();
118 return result;
119 }
120
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700121 virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, uint32_t width,
122 uint32_t height, PixelFormat format, uint32_t usage) {
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800123 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800124 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800125 data.writeUint32(width);
126 data.writeUint32(height);
127 data.writeInt32(static_cast<int32_t>(format));
128 data.writeUint32(usage);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700129 status_t result = remote()->transact(DEQUEUE_BUFFER, data, &reply);
130 if (result != NO_ERROR) {
131 return result;
132 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800133 *buf = reply.readInt32();
Mathias Agopianba93b3f2013-08-01 15:48:40 -0700134 bool nonNull = reply.readInt32();
135 if (nonNull) {
Jesse Hall4c00cc12013-03-15 21:34:30 -0700136 *fence = new Fence();
Pablo Ceballos70636b32016-07-06 15:24:54 -0700137 result = reply.read(**fence);
138 if (result != NO_ERROR) {
139 fence->clear();
140 return result;
141 }
Jesse Hallf7857542012-06-14 15:26:33 -0700142 }
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700143 result = reply.readInt32();
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800144 return result;
145 }
146
Dan Stoza9f3053d2014-03-06 15:14:33 -0800147 virtual status_t detachBuffer(int slot) {
148 Parcel data, reply;
149 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
150 data.writeInt32(slot);
151 status_t result = remote()->transact(DETACH_BUFFER, data, &reply);
152 if (result != NO_ERROR) {
153 return result;
154 }
155 result = reply.readInt32();
156 return result;
157 }
158
Dan Stozad9822a32014-03-28 15:25:31 -0700159 virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
160 sp<Fence>* outFence) {
161 if (outBuffer == NULL) {
162 ALOGE("detachNextBuffer: outBuffer must not be NULL");
163 return BAD_VALUE;
164 } else if (outFence == NULL) {
165 ALOGE("detachNextBuffer: outFence must not be NULL");
166 return BAD_VALUE;
167 }
168 Parcel data, reply;
169 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
170 status_t result = remote()->transact(DETACH_NEXT_BUFFER, data, &reply);
171 if (result != NO_ERROR) {
172 return result;
173 }
174 result = reply.readInt32();
175 if (result == NO_ERROR) {
176 bool nonNull = reply.readInt32();
177 if (nonNull) {
178 *outBuffer = new GraphicBuffer;
Pablo Ceballos70636b32016-07-06 15:24:54 -0700179 result = reply.read(**outBuffer);
180 if (result != NO_ERROR) {
181 outBuffer->clear();
182 return result;
183 }
Dan Stozad9822a32014-03-28 15:25:31 -0700184 }
185 nonNull = reply.readInt32();
186 if (nonNull) {
187 *outFence = new Fence;
Pablo Ceballos70636b32016-07-06 15:24:54 -0700188 result = reply.read(**outFence);
189 if (result != NO_ERROR) {
190 outBuffer->clear();
191 outFence->clear();
192 return result;
193 }
Dan Stozad9822a32014-03-28 15:25:31 -0700194 }
195 }
196 return result;
197 }
198
Dan Stoza9f3053d2014-03-06 15:14:33 -0800199 virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer) {
200 Parcel data, reply;
201 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
202 data.write(*buffer.get());
203 status_t result = remote()->transact(ATTACH_BUFFER, data, &reply);
204 if (result != NO_ERROR) {
205 return result;
206 }
207 *slot = reply.readInt32();
208 result = reply.readInt32();
209 return result;
210 }
211
Mathias Agopianf0bc2f12012-04-09 16:14:01 -0700212 virtual status_t queueBuffer(int buf,
213 const QueueBufferInput& input, QueueBufferOutput* output) {
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800214 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800215 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800216 data.writeInt32(buf);
Jesse Hallc777b0b2012-06-28 12:52:05 -0700217 data.write(input);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700218 status_t result = remote()->transact(QUEUE_BUFFER, data, &reply);
219 if (result != NO_ERROR) {
220 return result;
221 }
Mathias Agopianf0bc2f12012-04-09 16:14:01 -0700222 memcpy(output, reply.readInplace(sizeof(*output)), sizeof(*output));
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700223 result = reply.readInt32();
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800224 return result;
225 }
226
Pablo Ceballos583b1b32015-09-03 18:23:52 -0700227 virtual status_t cancelBuffer(int buf, const sp<Fence>& fence) {
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800228 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800229 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800230 data.writeInt32(buf);
Jamie Gennis1df8c342012-12-20 14:05:45 -0800231 data.write(*fence.get());
Pablo Ceballos583b1b32015-09-03 18:23:52 -0700232 status_t result = remote()->transact(CANCEL_BUFFER, data, &reply);
233 if (result != NO_ERROR) {
234 return result;
235 }
236 result = reply.readInt32();
237 return result;
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800238 }
239
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700240 virtual int query(int what, int* value) {
241 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800242 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700243 data.writeInt32(what);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700244 status_t result = remote()->transact(QUERY, data, &reply);
245 if (result != NO_ERROR) {
246 return result;
247 }
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700248 value[0] = reply.readInt32();
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700249 result = reply.readInt32();
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700250 return result;
251 }
252
Dan Stozaf0eaf252014-03-21 13:05:51 -0700253 virtual status_t connect(const sp<IProducerListener>& listener,
Mathias Agopian365857d2013-09-11 19:35:45 -0700254 int api, bool producerControlledByApp, QueueBufferOutput* output) {
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700255 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800256 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Dan Stozaf0eaf252014-03-21 13:05:51 -0700257 if (listener != NULL) {
258 data.writeInt32(1);
Marco Nelissen097ca272014-11-14 08:01:01 -0800259 data.writeStrongBinder(IInterface::asBinder(listener));
Dan Stozaf0eaf252014-03-21 13:05:51 -0700260 } else {
261 data.writeInt32(0);
262 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700263 data.writeInt32(api);
Mathias Agopian595264f2013-07-16 22:56:09 -0700264 data.writeInt32(producerControlledByApp);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700265 status_t result = remote()->transact(CONNECT, data, &reply);
266 if (result != NO_ERROR) {
267 return result;
268 }
Mathias Agopian24202f52012-04-23 14:28:58 -0700269 memcpy(output, reply.readInplace(sizeof(*output)), sizeof(*output));
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700270 result = reply.readInt32();
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700271 return result;
272 }
Mathias Agopian80727112011-05-02 19:51:12 -0700273
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700274 virtual status_t disconnect(int api) {
275 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800276 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700277 data.writeInt32(api);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700278 status_t result =remote()->transact(DISCONNECT, data, &reply);
279 if (result != NO_ERROR) {
280 return result;
281 }
282 result = reply.readInt32();
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700283 return result;
284 }
Jesse Hall399184a2014-03-03 15:42:54 -0800285
286 virtual status_t setSidebandStream(const sp<NativeHandle>& stream) {
287 Parcel data, reply;
288 status_t result;
289 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
290 if (stream.get()) {
291 data.writeInt32(true);
292 data.writeNativeHandle(stream->handle());
293 } else {
294 data.writeInt32(false);
295 }
296 if ((result = remote()->transact(SET_SIDEBAND_STREAM, data, &reply)) == NO_ERROR) {
297 result = reply.readInt32();
298 }
299 return result;
300 }
Dan Stoza29a3e902014-06-20 13:13:57 -0700301
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700302 virtual void allocateBuffers(uint32_t width, uint32_t height,
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800303 PixelFormat format, uint32_t usage) {
Dan Stoza29a3e902014-06-20 13:13:57 -0700304 Parcel data, reply;
305 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800306 data.writeUint32(width);
307 data.writeUint32(height);
Dan Stoza29a3e902014-06-20 13:13:57 -0700308 data.writeInt32(static_cast<int32_t>(format));
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800309 data.writeUint32(usage);
Dan Stoza29a3e902014-06-20 13:13:57 -0700310 status_t result = remote()->transact(ALLOCATE_BUFFERS, data, &reply);
311 if (result != NO_ERROR) {
312 ALOGE("allocateBuffers failed to transact: %d", result);
313 }
314 }
Dan Stoza9de72932015-04-16 17:28:43 -0700315
316 virtual status_t allowAllocation(bool allow) {
317 Parcel data, reply;
318 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
319 data.writeInt32(static_cast<int32_t>(allow));
320 status_t result = remote()->transact(ALLOW_ALLOCATION, data, &reply);
321 if (result != NO_ERROR) {
322 return result;
323 }
324 result = reply.readInt32();
325 return result;
326 }
Dan Stoza812ed062015-06-02 15:45:22 -0700327
328 virtual status_t setGenerationNumber(uint32_t generationNumber) {
329 Parcel data, reply;
330 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
331 data.writeUint32(generationNumber);
332 status_t result = remote()->transact(SET_GENERATION_NUMBER, data, &reply);
333 if (result == NO_ERROR) {
334 result = reply.readInt32();
335 }
336 return result;
337 }
Dan Stozac6f30bd2015-06-08 09:32:50 -0700338
339 virtual String8 getConsumerName() const {
340 Parcel data, reply;
341 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
342 status_t result = remote()->transact(GET_CONSUMER_NAME, data, &reply);
343 if (result != NO_ERROR) {
344 ALOGE("getConsumerName failed to transact: %d", result);
345 return String8("TransactFailed");
346 }
347 return reply.readString8();
348 }
Dan Stoza7dde5992015-05-22 09:51:44 -0700349
350 virtual uint64_t getNextFrameNumber() const {
351 Parcel data, reply;
352 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
353 status_t result = remote()->transact(GET_NEXT_FRAME_NUMBER, data, &reply);
354 if (result != NO_ERROR) {
355 ALOGE("getNextFrameNumber failed to transact: %d", result);
356 return 0;
357 }
358 uint64_t frameNumber = reply.readUint64();
359 return frameNumber;
360 }
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700361
Pablo Ceballos3559fbf2016-03-17 15:50:23 -0700362 virtual status_t setSharedBufferMode(bool sharedBufferMode) {
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700363 Parcel data, reply;
364 data.writeInterfaceToken(
365 IGraphicBufferProducer::getInterfaceDescriptor());
Pablo Ceballos3559fbf2016-03-17 15:50:23 -0700366 data.writeInt32(sharedBufferMode);
367 status_t result = remote()->transact(SET_SHARED_BUFFER_MODE, data,
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700368 &reply);
369 if (result == NO_ERROR) {
370 result = reply.readInt32();
371 }
372 return result;
373 }
Dan Stoza127fc632015-06-30 13:43:32 -0700374
Pablo Ceballosff95aab2016-01-13 17:09:58 -0800375 virtual status_t setAutoRefresh(bool autoRefresh) {
376 Parcel data, reply;
377 data.writeInterfaceToken(
378 IGraphicBufferProducer::getInterfaceDescriptor());
379 data.writeInt32(autoRefresh);
380 status_t result = remote()->transact(SET_AUTO_REFRESH, data, &reply);
381 if (result == NO_ERROR) {
382 result = reply.readInt32();
383 }
384 return result;
385 }
386
Dan Stoza127fc632015-06-30 13:43:32 -0700387 virtual status_t setDequeueTimeout(nsecs_t timeout) {
388 Parcel data, reply;
389 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
390 data.writeInt64(timeout);
391 status_t result = remote()->transact(SET_DEQUEUE_TIMEOUT, data, &reply);
392 if (result != NO_ERROR) {
393 ALOGE("setDequeueTimeout failed to transact: %d", result);
394 return result;
395 }
396 return reply.readInt32();
397 }
Dan Stoza50101d02016-04-07 16:53:23 -0700398
399 virtual status_t getLastQueuedBuffer(sp<GraphicBuffer>* outBuffer,
John Reck1a61da52016-04-28 13:18:15 -0700400 sp<Fence>* outFence, float outTransformMatrix[16]) override {
Dan Stoza50101d02016-04-07 16:53:23 -0700401 Parcel data, reply;
402 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
403 status_t result = remote()->transact(GET_LAST_QUEUED_BUFFER, data,
404 &reply);
405 if (result != NO_ERROR) {
406 ALOGE("getLastQueuedBuffer failed to transact: %d", result);
407 return result;
408 }
409 result = reply.readInt32();
410 if (result != NO_ERROR) {
411 return result;
412 }
John Reckce8e5df2016-04-28 10:12:47 -0700413 bool hasBuffer = reply.readBool();
414 sp<GraphicBuffer> buffer;
415 if (hasBuffer) {
416 buffer = new GraphicBuffer();
417 result = reply.read(*buffer);
John Reck1a61da52016-04-28 13:18:15 -0700418 if (result == NO_ERROR) {
419 result = reply.read(outTransformMatrix, sizeof(float) * 16);
420 }
John Reckce8e5df2016-04-28 10:12:47 -0700421 }
Dan Stoza50101d02016-04-07 16:53:23 -0700422 if (result != NO_ERROR) {
423 ALOGE("getLastQueuedBuffer failed to read buffer: %d", result);
424 return result;
425 }
426 sp<Fence> fence(new Fence);
427 result = reply.read(*fence);
428 if (result != NO_ERROR) {
429 ALOGE("getLastQueuedBuffer failed to read fence: %d", result);
430 return result;
431 }
432 *outBuffer = buffer;
433 *outFence = fence;
434 return result;
435 }
Pablo Ceballosce796e72016-02-04 19:10:51 -0800436
437 virtual bool getFrameTimestamps(uint64_t frameNumber,
438 FrameTimestamps* outTimestamps) const {
439 Parcel data, reply;
440 status_t result = data.writeInterfaceToken(
441 IGraphicBufferProducer::getInterfaceDescriptor());
442 if (result != NO_ERROR) {
443 ALOGE("getFrameTimestamps failed to write token: %d", result);
444 return false;
445 }
446 result = data.writeUint64(frameNumber);
447 if (result != NO_ERROR) {
448 ALOGE("getFrameTimestamps failed to write: %d", result);
449 return false;
450 }
451 result = remote()->transact(GET_FRAME_TIMESTAMPS, data, &reply);
452 if (result != NO_ERROR) {
453 ALOGE("getFrameTimestamps failed to transact: %d", result);
454 return false;
455 }
456 bool found = false;
457 result = reply.readBool(&found);
458 if (result != NO_ERROR) {
459 ALOGE("getFrameTimestamps failed to read: %d", result);
460 return false;
461 }
462 if (found) {
463 result = reply.read(*outTimestamps);
464 if (result != NO_ERROR) {
465 ALOGE("getFrameTimestamps failed to read timestamps: %d",
466 result);
467 return false;
468 }
469 }
470 return found;
471 }
Pablo Ceballos0ade2472016-06-30 16:48:02 -0700472
Pablo Ceballos8e3e92b2016-06-27 17:56:53 -0700473 virtual status_t getUniqueId(uint64_t* outId) const {
474 Parcel data, reply;
475 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
476 status_t result = remote()->transact(GET_UNIQUE_ID, data, &reply);
477 if (result != NO_ERROR) {
478 ALOGE("getUniqueId failed to transact: %d", result);
479 }
480 status_t actualResult = NO_ERROR;
481 result = reply.readInt32(&actualResult);
482 if (result != NO_ERROR) {
483 return result;
484 }
485 result = reply.readUint64(outId);
486 if (result != NO_ERROR) {
487 return result;
488 }
489 return actualResult;
490 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800491};
492
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800493// Out-of-line virtual method definition to trigger vtable emission in this
494// translation unit (see clang warning -Wweak-vtables)
495BpGraphicBufferProducer::~BpGraphicBufferProducer() {}
496
Andy McFadden466a1922013-01-08 11:25:51 -0800497IMPLEMENT_META_INTERFACE(GraphicBufferProducer, "android.gui.IGraphicBufferProducer");
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800498
499// ----------------------------------------------------------------------
500
Andy McFadden2adaf042012-12-18 09:49:45 -0800501status_t BnGraphicBufferProducer::onTransact(
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800502 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
503{
504 switch(code) {
505 case REQUEST_BUFFER: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800506 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800507 int bufferIdx = data.readInt32();
Jamie Gennis7b305ff2011-07-19 12:08:33 -0700508 sp<GraphicBuffer> buffer;
509 int result = requestBuffer(bufferIdx, &buffer);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800510 reply->writeInt32(buffer != 0);
511 if (buffer != 0) {
512 reply->write(*buffer);
513 }
Jamie Gennis7b305ff2011-07-19 12:08:33 -0700514 reply->writeInt32(result);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800515 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800516 }
Pablo Ceballosfa455352015-08-12 17:47:47 -0700517 case SET_MAX_DEQUEUED_BUFFER_COUNT: {
518 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
519 int maxDequeuedBuffers = data.readInt32();
520 int result = setMaxDequeuedBufferCount(maxDequeuedBuffers);
521 reply->writeInt32(result);
522 return NO_ERROR;
523 }
524 case SET_ASYNC_MODE: {
525 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
526 bool async = data.readInt32();
527 int result = setAsyncMode(async);
528 reply->writeInt32(result);
529 return NO_ERROR;
530 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800531 case DEQUEUE_BUFFER: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800532 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800533 uint32_t width = data.readUint32();
534 uint32_t height = data.readUint32();
535 PixelFormat format = static_cast<PixelFormat>(data.readInt32());
536 uint32_t usage = data.readUint32();
Naveen Leekha12ba0f52015-09-21 17:28:04 -0700537 int buf = 0;
Jesse Hallf7857542012-06-14 15:26:33 -0700538 sp<Fence> fence;
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700539 int result = dequeueBuffer(&buf, &fence, width, height, format,
540 usage);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800541 reply->writeInt32(buf);
Jamie Gennis1df8c342012-12-20 14:05:45 -0800542 reply->writeInt32(fence != NULL);
543 if (fence != NULL) {
Mathias Agopianba93b3f2013-08-01 15:48:40 -0700544 reply->write(*fence);
Jesse Hallf7857542012-06-14 15:26:33 -0700545 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800546 reply->writeInt32(result);
547 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800548 }
Dan Stoza9f3053d2014-03-06 15:14:33 -0800549 case DETACH_BUFFER: {
550 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
551 int slot = data.readInt32();
552 int result = detachBuffer(slot);
553 reply->writeInt32(result);
554 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800555 }
Dan Stozad9822a32014-03-28 15:25:31 -0700556 case DETACH_NEXT_BUFFER: {
557 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
558 sp<GraphicBuffer> buffer;
559 sp<Fence> fence;
560 int32_t result = detachNextBuffer(&buffer, &fence);
561 reply->writeInt32(result);
562 if (result == NO_ERROR) {
563 reply->writeInt32(buffer != NULL);
564 if (buffer != NULL) {
565 reply->write(*buffer);
566 }
567 reply->writeInt32(fence != NULL);
568 if (fence != NULL) {
569 reply->write(*fence);
570 }
571 }
572 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800573 }
Dan Stoza9f3053d2014-03-06 15:14:33 -0800574 case ATTACH_BUFFER: {
575 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
576 sp<GraphicBuffer> buffer = new GraphicBuffer();
Pablo Ceballos70636b32016-07-06 15:24:54 -0700577 status_t result = data.read(*buffer.get());
Naveen Leekha12ba0f52015-09-21 17:28:04 -0700578 int slot = 0;
Pablo Ceballos70636b32016-07-06 15:24:54 -0700579 if (result == NO_ERROR) {
580 result = attachBuffer(&slot, buffer);
581 }
Dan Stoza9f3053d2014-03-06 15:14:33 -0800582 reply->writeInt32(slot);
583 reply->writeInt32(result);
584 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800585 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800586 case QUEUE_BUFFER: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800587 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800588 int buf = data.readInt32();
Jesse Hallc777b0b2012-06-28 12:52:05 -0700589 QueueBufferInput input(data);
Mathias Agopianf0bc2f12012-04-09 16:14:01 -0700590 QueueBufferOutput* const output =
591 reinterpret_cast<QueueBufferOutput *>(
592 reply->writeInplace(sizeof(QueueBufferOutput)));
Robert Shihd06421f2016-01-11 15:02:12 -0800593 memset(output, 0, sizeof(QueueBufferOutput));
Jesse Hallc777b0b2012-06-28 12:52:05 -0700594 status_t result = queueBuffer(buf, input, output);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800595 reply->writeInt32(result);
596 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800597 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800598 case CANCEL_BUFFER: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800599 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800600 int buf = data.readInt32();
Jamie Gennis1df8c342012-12-20 14:05:45 -0800601 sp<Fence> fence = new Fence();
Pablo Ceballos70636b32016-07-06 15:24:54 -0700602 status_t result = data.read(*fence.get());
603 if (result == NO_ERROR) {
604 result = cancelBuffer(buf, fence);
605 }
Pablo Ceballos583b1b32015-09-03 18:23:52 -0700606 reply->writeInt32(result);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800607 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800608 }
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700609 case QUERY: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800610 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Naveen Leekha12ba0f52015-09-21 17:28:04 -0700611 int value = 0;
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700612 int what = data.readInt32();
613 int res = query(what, &value);
614 reply->writeInt32(value);
615 reply->writeInt32(res);
616 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800617 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700618 case CONNECT: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800619 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Dan Stozaf0eaf252014-03-21 13:05:51 -0700620 sp<IProducerListener> listener;
621 if (data.readInt32() == 1) {
622 listener = IProducerListener::asInterface(data.readStrongBinder());
623 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700624 int api = data.readInt32();
Mathias Agopian595264f2013-07-16 22:56:09 -0700625 bool producerControlledByApp = data.readInt32();
Mathias Agopian24202f52012-04-23 14:28:58 -0700626 QueueBufferOutput* const output =
627 reinterpret_cast<QueueBufferOutput *>(
628 reply->writeInplace(sizeof(QueueBufferOutput)));
Pablo Ceballos93c617f2016-03-15 18:10:49 -0700629 memset(output, 0, sizeof(QueueBufferOutput));
Dan Stozaf0eaf252014-03-21 13:05:51 -0700630 status_t res = connect(listener, api, producerControlledByApp, output);
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700631 reply->writeInt32(res);
632 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800633 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700634 case DISCONNECT: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800635 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700636 int api = data.readInt32();
Mathias Agopian27730042011-07-14 20:20:58 -0700637 status_t res = disconnect(api);
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700638 reply->writeInt32(res);
639 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800640 }
Jesse Hall399184a2014-03-03 15:42:54 -0800641 case SET_SIDEBAND_STREAM: {
642 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
643 sp<NativeHandle> stream;
644 if (data.readInt32()) {
Wonsik Kim0ec54e12014-03-21 10:46:24 +0900645 stream = NativeHandle::create(data.readNativeHandle(), true);
Jesse Hall399184a2014-03-03 15:42:54 -0800646 }
647 status_t result = setSidebandStream(stream);
648 reply->writeInt32(result);
649 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800650 }
Dan Stoza9de72932015-04-16 17:28:43 -0700651 case ALLOCATE_BUFFERS: {
Dan Stoza29a3e902014-06-20 13:13:57 -0700652 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800653 uint32_t width = data.readUint32();
654 uint32_t height = data.readUint32();
655 PixelFormat format = static_cast<PixelFormat>(data.readInt32());
656 uint32_t usage = data.readUint32();
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700657 allocateBuffers(width, height, format, usage);
Dan Stoza29a3e902014-06-20 13:13:57 -0700658 return NO_ERROR;
Dan Stoza9de72932015-04-16 17:28:43 -0700659 }
660 case ALLOW_ALLOCATION: {
661 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
662 bool allow = static_cast<bool>(data.readInt32());
663 status_t result = allowAllocation(allow);
664 reply->writeInt32(result);
665 return NO_ERROR;
666 }
Dan Stoza812ed062015-06-02 15:45:22 -0700667 case SET_GENERATION_NUMBER: {
668 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
669 uint32_t generationNumber = data.readUint32();
670 status_t result = setGenerationNumber(generationNumber);
671 reply->writeInt32(result);
672 return NO_ERROR;
673 }
Dan Stozac6f30bd2015-06-08 09:32:50 -0700674 case GET_CONSUMER_NAME: {
675 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
676 reply->writeString8(getConsumerName());
677 return NO_ERROR;
678 }
Dan Stoza7dde5992015-05-22 09:51:44 -0700679 case GET_NEXT_FRAME_NUMBER: {
680 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
681 uint64_t frameNumber = getNextFrameNumber();
682 reply->writeUint64(frameNumber);
683 return NO_ERROR;
684 }
Pablo Ceballos3559fbf2016-03-17 15:50:23 -0700685 case SET_SHARED_BUFFER_MODE: {
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700686 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Pablo Ceballos3559fbf2016-03-17 15:50:23 -0700687 bool sharedBufferMode = data.readInt32();
688 status_t result = setSharedBufferMode(sharedBufferMode);
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700689 reply->writeInt32(result);
690 return NO_ERROR;
691 }
Pablo Ceballosff95aab2016-01-13 17:09:58 -0800692 case SET_AUTO_REFRESH: {
693 CHECK_INTERFACE(IGraphicBuffer, data, reply);
694 bool autoRefresh = data.readInt32();
695 status_t result = setAutoRefresh(autoRefresh);
696 reply->writeInt32(result);
697 return NO_ERROR;
698 }
Dan Stoza127fc632015-06-30 13:43:32 -0700699 case SET_DEQUEUE_TIMEOUT: {
700 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
701 nsecs_t timeout = data.readInt64();
702 status_t result = setDequeueTimeout(timeout);
703 reply->writeInt32(result);
704 return NO_ERROR;
705 }
Dan Stoza50101d02016-04-07 16:53:23 -0700706 case GET_LAST_QUEUED_BUFFER: {
707 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
708 sp<GraphicBuffer> buffer(nullptr);
709 sp<Fence> fence(Fence::NO_FENCE);
John Reck1a61da52016-04-28 13:18:15 -0700710 float transform[16] = {};
711 status_t result = getLastQueuedBuffer(&buffer, &fence, transform);
Dan Stoza50101d02016-04-07 16:53:23 -0700712 reply->writeInt32(result);
713 if (result != NO_ERROR) {
714 return result;
715 }
John Reckce8e5df2016-04-28 10:12:47 -0700716 if (!buffer.get()) {
717 reply->writeBool(false);
718 } else {
719 reply->writeBool(true);
720 result = reply->write(*buffer);
John Reck1a61da52016-04-28 13:18:15 -0700721 if (result == NO_ERROR) {
722 reply->write(transform, sizeof(float) * 16);
723 }
John Reckce8e5df2016-04-28 10:12:47 -0700724 }
Dan Stoza50101d02016-04-07 16:53:23 -0700725 if (result != NO_ERROR) {
726 ALOGE("getLastQueuedBuffer failed to write buffer: %d", result);
727 return result;
728 }
729 result = reply->write(*fence);
730 if (result != NO_ERROR) {
731 ALOGE("getLastQueuedBuffer failed to write fence: %d", result);
732 return result;
733 }
734 return NO_ERROR;
735 }
Pablo Ceballosce796e72016-02-04 19:10:51 -0800736 case GET_FRAME_TIMESTAMPS: {
737 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
738 uint64_t frameNumber = 0;
739 status_t result = data.readUint64(&frameNumber);
740 if (result != NO_ERROR) {
741 ALOGE("onTransact failed to read: %d", result);
742 return result;
743 }
744 FrameTimestamps timestamps;
745 bool found = getFrameTimestamps(frameNumber, &timestamps);
746 result = reply->writeBool(found);
747 if (result != NO_ERROR) {
748 ALOGE("onTransact failed to write: %d", result);
749 return result;
750 }
751 if (found) {
752 result = reply->write(timestamps);
753 if (result != NO_ERROR) {
754 ALOGE("onTransact failed to write timestamps: %d", result);
755 return result;
756 }
757 }
758 return NO_ERROR;
759 }
Pablo Ceballos8e3e92b2016-06-27 17:56:53 -0700760 case GET_UNIQUE_ID: {
761 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
762 uint64_t outId = 0;
763 status_t actualResult = getUniqueId(&outId);
764 status_t result = reply->writeInt32(actualResult);
765 if (result != NO_ERROR) {
766 return result;
767 }
768 result = reply->writeUint64(outId);
769 if (result != NO_ERROR) {
770 return result;
771 }
772 return NO_ERROR;
773 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800774 }
775 return BBinder::onTransact(code, data, reply, flags);
776}
777
778// ----------------------------------------------------------------------------
779
Andy McFadden2adaf042012-12-18 09:49:45 -0800780IGraphicBufferProducer::QueueBufferInput::QueueBufferInput(const Parcel& parcel) {
Jesse Hallc777b0b2012-06-28 12:52:05 -0700781 parcel.read(*this);
782}
783
Mathias Agopiane1424282013-07-29 21:24:40 -0700784size_t IGraphicBufferProducer::QueueBufferInput::getFlattenedSize() const {
Jesse Hallc777b0b2012-06-28 12:52:05 -0700785 return sizeof(timestamp)
Andy McFadden3c256212013-08-16 14:55:39 -0700786 + sizeof(isAutoTimestamp)
Eino-Ville Talvala82c6bcc2015-02-19 16:10:43 -0800787 + sizeof(dataSpace)
Jesse Hallc777b0b2012-06-28 12:52:05 -0700788 + sizeof(crop)
789 + sizeof(scalingMode)
790 + sizeof(transform)
Ruben Brunk1681d952014-06-27 15:51:55 -0700791 + sizeof(stickyTransform)
Dan Stoza5065a552015-03-17 16:23:42 -0700792 + fence->getFlattenedSize()
793 + surfaceDamage.getFlattenedSize();
Jesse Hallc777b0b2012-06-28 12:52:05 -0700794}
795
Mathias Agopiane1424282013-07-29 21:24:40 -0700796size_t IGraphicBufferProducer::QueueBufferInput::getFdCount() const {
Jamie Gennis1df8c342012-12-20 14:05:45 -0800797 return fence->getFdCount();
Jesse Hallc777b0b2012-06-28 12:52:05 -0700798}
799
Mathias Agopiane1424282013-07-29 21:24:40 -0700800status_t IGraphicBufferProducer::QueueBufferInput::flatten(
801 void*& buffer, size_t& size, int*& fds, size_t& count) const
Jesse Hallc777b0b2012-06-28 12:52:05 -0700802{
Mathias Agopiane1424282013-07-29 21:24:40 -0700803 if (size < getFlattenedSize()) {
804 return NO_MEMORY;
805 }
806 FlattenableUtils::write(buffer, size, timestamp);
Andy McFadden3c256212013-08-16 14:55:39 -0700807 FlattenableUtils::write(buffer, size, isAutoTimestamp);
Eino-Ville Talvala82c6bcc2015-02-19 16:10:43 -0800808 FlattenableUtils::write(buffer, size, dataSpace);
Mathias Agopiane1424282013-07-29 21:24:40 -0700809 FlattenableUtils::write(buffer, size, crop);
810 FlattenableUtils::write(buffer, size, scalingMode);
811 FlattenableUtils::write(buffer, size, transform);
Ruben Brunk1681d952014-06-27 15:51:55 -0700812 FlattenableUtils::write(buffer, size, stickyTransform);
Dan Stoza5065a552015-03-17 16:23:42 -0700813 status_t result = fence->flatten(buffer, size, fds, count);
814 if (result != NO_ERROR) {
815 return result;
816 }
817 return surfaceDamage.flatten(buffer, size);
Jesse Hallc777b0b2012-06-28 12:52:05 -0700818}
819
Mathias Agopiane1424282013-07-29 21:24:40 -0700820status_t IGraphicBufferProducer::QueueBufferInput::unflatten(
821 void const*& buffer, size_t& size, int const*& fds, size_t& count)
Jesse Hallc777b0b2012-06-28 12:52:05 -0700822{
Mathias Agopiane1424282013-07-29 21:24:40 -0700823 size_t minNeeded =
824 sizeof(timestamp)
Andy McFadden3c256212013-08-16 14:55:39 -0700825 + sizeof(isAutoTimestamp)
Eino-Ville Talvala82c6bcc2015-02-19 16:10:43 -0800826 + sizeof(dataSpace)
Mathias Agopiane1424282013-07-29 21:24:40 -0700827 + sizeof(crop)
828 + sizeof(scalingMode)
829 + sizeof(transform)
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700830 + sizeof(stickyTransform);
Mathias Agopiane1424282013-07-29 21:24:40 -0700831
832 if (size < minNeeded) {
833 return NO_MEMORY;
834 }
835
836 FlattenableUtils::read(buffer, size, timestamp);
Andy McFadden3c256212013-08-16 14:55:39 -0700837 FlattenableUtils::read(buffer, size, isAutoTimestamp);
Eino-Ville Talvala82c6bcc2015-02-19 16:10:43 -0800838 FlattenableUtils::read(buffer, size, dataSpace);
Mathias Agopiane1424282013-07-29 21:24:40 -0700839 FlattenableUtils::read(buffer, size, crop);
840 FlattenableUtils::read(buffer, size, scalingMode);
841 FlattenableUtils::read(buffer, size, transform);
Ruben Brunk1681d952014-06-27 15:51:55 -0700842 FlattenableUtils::read(buffer, size, stickyTransform);
Mathias Agopiane1424282013-07-29 21:24:40 -0700843
Jamie Gennis1df8c342012-12-20 14:05:45 -0800844 fence = new Fence();
Dan Stoza5065a552015-03-17 16:23:42 -0700845 status_t result = fence->unflatten(buffer, size, fds, count);
846 if (result != NO_ERROR) {
847 return result;
848 }
849 return surfaceDamage.unflatten(buffer, size);
Jesse Hallc777b0b2012-06-28 12:52:05 -0700850}
851
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800852}; // namespace android