blob: c177922492460d629db96b7275bf4b23655c14f9 [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();
Mathias Agopianba93b3f2013-08-01 15:48:40 -0700137 reply.read(**fence);
Jesse Hallf7857542012-06-14 15:26:33 -0700138 }
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700139 result = reply.readInt32();
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800140 return result;
141 }
142
Dan Stoza9f3053d2014-03-06 15:14:33 -0800143 virtual status_t detachBuffer(int slot) {
144 Parcel data, reply;
145 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
146 data.writeInt32(slot);
147 status_t result = remote()->transact(DETACH_BUFFER, data, &reply);
148 if (result != NO_ERROR) {
149 return result;
150 }
151 result = reply.readInt32();
152 return result;
153 }
154
Dan Stozad9822a32014-03-28 15:25:31 -0700155 virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
156 sp<Fence>* outFence) {
157 if (outBuffer == NULL) {
158 ALOGE("detachNextBuffer: outBuffer must not be NULL");
159 return BAD_VALUE;
160 } else if (outFence == NULL) {
161 ALOGE("detachNextBuffer: outFence must not be NULL");
162 return BAD_VALUE;
163 }
164 Parcel data, reply;
165 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
166 status_t result = remote()->transact(DETACH_NEXT_BUFFER, data, &reply);
167 if (result != NO_ERROR) {
168 return result;
169 }
170 result = reply.readInt32();
171 if (result == NO_ERROR) {
172 bool nonNull = reply.readInt32();
173 if (nonNull) {
174 *outBuffer = new GraphicBuffer;
175 reply.read(**outBuffer);
176 }
177 nonNull = reply.readInt32();
178 if (nonNull) {
179 *outFence = new Fence;
180 reply.read(**outFence);
181 }
182 }
183 return result;
184 }
185
Dan Stoza9f3053d2014-03-06 15:14:33 -0800186 virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer) {
187 Parcel data, reply;
188 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
189 data.write(*buffer.get());
190 status_t result = remote()->transact(ATTACH_BUFFER, data, &reply);
191 if (result != NO_ERROR) {
192 return result;
193 }
194 *slot = reply.readInt32();
195 result = reply.readInt32();
196 return result;
197 }
198
Mathias Agopianf0bc2f12012-04-09 16:14:01 -0700199 virtual status_t queueBuffer(int buf,
200 const QueueBufferInput& input, QueueBufferOutput* output) {
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800201 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800202 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800203 data.writeInt32(buf);
Jesse Hallc777b0b2012-06-28 12:52:05 -0700204 data.write(input);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700205 status_t result = remote()->transact(QUEUE_BUFFER, data, &reply);
206 if (result != NO_ERROR) {
207 return result;
208 }
Mathias Agopianf0bc2f12012-04-09 16:14:01 -0700209 memcpy(output, reply.readInplace(sizeof(*output)), sizeof(*output));
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700210 result = reply.readInt32();
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800211 return result;
212 }
213
Pablo Ceballos583b1b32015-09-03 18:23:52 -0700214 virtual status_t cancelBuffer(int buf, const sp<Fence>& fence) {
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800215 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800216 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800217 data.writeInt32(buf);
Jamie Gennis1df8c342012-12-20 14:05:45 -0800218 data.write(*fence.get());
Pablo Ceballos583b1b32015-09-03 18:23:52 -0700219 status_t result = remote()->transact(CANCEL_BUFFER, data, &reply);
220 if (result != NO_ERROR) {
221 return result;
222 }
223 result = reply.readInt32();
224 return result;
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800225 }
226
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700227 virtual int query(int what, int* value) {
228 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800229 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700230 data.writeInt32(what);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700231 status_t result = remote()->transact(QUERY, data, &reply);
232 if (result != NO_ERROR) {
233 return result;
234 }
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700235 value[0] = reply.readInt32();
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700236 result = reply.readInt32();
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700237 return result;
238 }
239
Dan Stozaf0eaf252014-03-21 13:05:51 -0700240 virtual status_t connect(const sp<IProducerListener>& listener,
Mathias Agopian365857d2013-09-11 19:35:45 -0700241 int api, bool producerControlledByApp, QueueBufferOutput* output) {
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700242 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800243 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Dan Stozaf0eaf252014-03-21 13:05:51 -0700244 if (listener != NULL) {
245 data.writeInt32(1);
Marco Nelissen097ca272014-11-14 08:01:01 -0800246 data.writeStrongBinder(IInterface::asBinder(listener));
Dan Stozaf0eaf252014-03-21 13:05:51 -0700247 } else {
248 data.writeInt32(0);
249 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700250 data.writeInt32(api);
Mathias Agopian595264f2013-07-16 22:56:09 -0700251 data.writeInt32(producerControlledByApp);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700252 status_t result = remote()->transact(CONNECT, data, &reply);
253 if (result != NO_ERROR) {
254 return result;
255 }
Mathias Agopian24202f52012-04-23 14:28:58 -0700256 memcpy(output, reply.readInplace(sizeof(*output)), sizeof(*output));
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700257 result = reply.readInt32();
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700258 return result;
259 }
Mathias Agopian80727112011-05-02 19:51:12 -0700260
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700261 virtual status_t disconnect(int api) {
262 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800263 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700264 data.writeInt32(api);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700265 status_t result =remote()->transact(DISCONNECT, data, &reply);
266 if (result != NO_ERROR) {
267 return result;
268 }
269 result = reply.readInt32();
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700270 return result;
271 }
Jesse Hall399184a2014-03-03 15:42:54 -0800272
273 virtual status_t setSidebandStream(const sp<NativeHandle>& stream) {
274 Parcel data, reply;
275 status_t result;
276 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
277 if (stream.get()) {
278 data.writeInt32(true);
279 data.writeNativeHandle(stream->handle());
280 } else {
281 data.writeInt32(false);
282 }
283 if ((result = remote()->transact(SET_SIDEBAND_STREAM, data, &reply)) == NO_ERROR) {
284 result = reply.readInt32();
285 }
286 return result;
287 }
Dan Stoza29a3e902014-06-20 13:13:57 -0700288
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700289 virtual void allocateBuffers(uint32_t width, uint32_t height,
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800290 PixelFormat format, uint32_t usage) {
Dan Stoza29a3e902014-06-20 13:13:57 -0700291 Parcel data, reply;
292 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800293 data.writeUint32(width);
294 data.writeUint32(height);
Dan Stoza29a3e902014-06-20 13:13:57 -0700295 data.writeInt32(static_cast<int32_t>(format));
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800296 data.writeUint32(usage);
Dan Stoza29a3e902014-06-20 13:13:57 -0700297 status_t result = remote()->transact(ALLOCATE_BUFFERS, data, &reply);
298 if (result != NO_ERROR) {
299 ALOGE("allocateBuffers failed to transact: %d", result);
300 }
301 }
Dan Stoza9de72932015-04-16 17:28:43 -0700302
303 virtual status_t allowAllocation(bool allow) {
304 Parcel data, reply;
305 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
306 data.writeInt32(static_cast<int32_t>(allow));
307 status_t result = remote()->transact(ALLOW_ALLOCATION, data, &reply);
308 if (result != NO_ERROR) {
309 return result;
310 }
311 result = reply.readInt32();
312 return result;
313 }
Dan Stoza812ed062015-06-02 15:45:22 -0700314
315 virtual status_t setGenerationNumber(uint32_t generationNumber) {
316 Parcel data, reply;
317 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
318 data.writeUint32(generationNumber);
319 status_t result = remote()->transact(SET_GENERATION_NUMBER, data, &reply);
320 if (result == NO_ERROR) {
321 result = reply.readInt32();
322 }
323 return result;
324 }
Dan Stozac6f30bd2015-06-08 09:32:50 -0700325
326 virtual String8 getConsumerName() const {
327 Parcel data, reply;
328 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
329 status_t result = remote()->transact(GET_CONSUMER_NAME, data, &reply);
330 if (result != NO_ERROR) {
331 ALOGE("getConsumerName failed to transact: %d", result);
332 return String8("TransactFailed");
333 }
334 return reply.readString8();
335 }
Dan Stoza7dde5992015-05-22 09:51:44 -0700336
337 virtual uint64_t getNextFrameNumber() const {
338 Parcel data, reply;
339 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
340 status_t result = remote()->transact(GET_NEXT_FRAME_NUMBER, data, &reply);
341 if (result != NO_ERROR) {
342 ALOGE("getNextFrameNumber failed to transact: %d", result);
343 return 0;
344 }
345 uint64_t frameNumber = reply.readUint64();
346 return frameNumber;
347 }
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700348
Pablo Ceballos3559fbf2016-03-17 15:50:23 -0700349 virtual status_t setSharedBufferMode(bool sharedBufferMode) {
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700350 Parcel data, reply;
351 data.writeInterfaceToken(
352 IGraphicBufferProducer::getInterfaceDescriptor());
Pablo Ceballos3559fbf2016-03-17 15:50:23 -0700353 data.writeInt32(sharedBufferMode);
354 status_t result = remote()->transact(SET_SHARED_BUFFER_MODE, data,
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700355 &reply);
356 if (result == NO_ERROR) {
357 result = reply.readInt32();
358 }
359 return result;
360 }
Dan Stoza127fc632015-06-30 13:43:32 -0700361
Pablo Ceballosff95aab2016-01-13 17:09:58 -0800362 virtual status_t setAutoRefresh(bool autoRefresh) {
363 Parcel data, reply;
364 data.writeInterfaceToken(
365 IGraphicBufferProducer::getInterfaceDescriptor());
366 data.writeInt32(autoRefresh);
367 status_t result = remote()->transact(SET_AUTO_REFRESH, data, &reply);
368 if (result == NO_ERROR) {
369 result = reply.readInt32();
370 }
371 return result;
372 }
373
Dan Stoza127fc632015-06-30 13:43:32 -0700374 virtual status_t setDequeueTimeout(nsecs_t timeout) {
375 Parcel data, reply;
376 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
377 data.writeInt64(timeout);
378 status_t result = remote()->transact(SET_DEQUEUE_TIMEOUT, data, &reply);
379 if (result != NO_ERROR) {
380 ALOGE("setDequeueTimeout failed to transact: %d", result);
381 return result;
382 }
383 return reply.readInt32();
384 }
Dan Stoza50101d02016-04-07 16:53:23 -0700385
386 virtual status_t getLastQueuedBuffer(sp<GraphicBuffer>* outBuffer,
John Reck1a61da52016-04-28 13:18:15 -0700387 sp<Fence>* outFence, float outTransformMatrix[16]) override {
Dan Stoza50101d02016-04-07 16:53:23 -0700388 Parcel data, reply;
389 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
390 status_t result = remote()->transact(GET_LAST_QUEUED_BUFFER, data,
391 &reply);
392 if (result != NO_ERROR) {
393 ALOGE("getLastQueuedBuffer failed to transact: %d", result);
394 return result;
395 }
396 result = reply.readInt32();
397 if (result != NO_ERROR) {
398 return result;
399 }
John Reckce8e5df2016-04-28 10:12:47 -0700400 bool hasBuffer = reply.readBool();
401 sp<GraphicBuffer> buffer;
402 if (hasBuffer) {
403 buffer = new GraphicBuffer();
404 result = reply.read(*buffer);
John Reck1a61da52016-04-28 13:18:15 -0700405 if (result == NO_ERROR) {
406 result = reply.read(outTransformMatrix, sizeof(float) * 16);
407 }
John Reckce8e5df2016-04-28 10:12:47 -0700408 }
Dan Stoza50101d02016-04-07 16:53:23 -0700409 if (result != NO_ERROR) {
410 ALOGE("getLastQueuedBuffer failed to read buffer: %d", result);
411 return result;
412 }
413 sp<Fence> fence(new Fence);
414 result = reply.read(*fence);
415 if (result != NO_ERROR) {
416 ALOGE("getLastQueuedBuffer failed to read fence: %d", result);
417 return result;
418 }
419 *outBuffer = buffer;
420 *outFence = fence;
421 return result;
422 }
Pablo Ceballosce796e72016-02-04 19:10:51 -0800423
424 virtual bool getFrameTimestamps(uint64_t frameNumber,
425 FrameTimestamps* outTimestamps) const {
426 Parcel data, reply;
427 status_t result = data.writeInterfaceToken(
428 IGraphicBufferProducer::getInterfaceDescriptor());
429 if (result != NO_ERROR) {
430 ALOGE("getFrameTimestamps failed to write token: %d", result);
431 return false;
432 }
433 result = data.writeUint64(frameNumber);
434 if (result != NO_ERROR) {
435 ALOGE("getFrameTimestamps failed to write: %d", result);
436 return false;
437 }
438 result = remote()->transact(GET_FRAME_TIMESTAMPS, data, &reply);
439 if (result != NO_ERROR) {
440 ALOGE("getFrameTimestamps failed to transact: %d", result);
441 return false;
442 }
443 bool found = false;
444 result = reply.readBool(&found);
445 if (result != NO_ERROR) {
446 ALOGE("getFrameTimestamps failed to read: %d", result);
447 return false;
448 }
449 if (found) {
450 result = reply.read(*outTimestamps);
451 if (result != NO_ERROR) {
452 ALOGE("getFrameTimestamps failed to read timestamps: %d",
453 result);
454 return false;
455 }
456 }
457 return found;
458 }
Pablo Ceballos0ade2472016-06-30 16:48:02 -0700459
Pablo Ceballos8e3e92b2016-06-27 17:56:53 -0700460 virtual status_t getUniqueId(uint64_t* outId) const {
461 Parcel data, reply;
462 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
463 status_t result = remote()->transact(GET_UNIQUE_ID, data, &reply);
464 if (result != NO_ERROR) {
465 ALOGE("getUniqueId failed to transact: %d", result);
466 }
467 status_t actualResult = NO_ERROR;
468 result = reply.readInt32(&actualResult);
469 if (result != NO_ERROR) {
470 return result;
471 }
472 result = reply.readUint64(outId);
473 if (result != NO_ERROR) {
474 return result;
475 }
476 return actualResult;
477 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800478};
479
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800480// Out-of-line virtual method definition to trigger vtable emission in this
481// translation unit (see clang warning -Wweak-vtables)
482BpGraphicBufferProducer::~BpGraphicBufferProducer() {}
483
Andy McFadden466a1922013-01-08 11:25:51 -0800484IMPLEMENT_META_INTERFACE(GraphicBufferProducer, "android.gui.IGraphicBufferProducer");
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800485
486// ----------------------------------------------------------------------
487
Andy McFadden2adaf042012-12-18 09:49:45 -0800488status_t BnGraphicBufferProducer::onTransact(
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800489 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
490{
491 switch(code) {
492 case REQUEST_BUFFER: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800493 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800494 int bufferIdx = data.readInt32();
Jamie Gennis7b305ff2011-07-19 12:08:33 -0700495 sp<GraphicBuffer> buffer;
496 int result = requestBuffer(bufferIdx, &buffer);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800497 reply->writeInt32(buffer != 0);
498 if (buffer != 0) {
499 reply->write(*buffer);
500 }
Jamie Gennis7b305ff2011-07-19 12:08:33 -0700501 reply->writeInt32(result);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800502 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800503 }
Pablo Ceballosfa455352015-08-12 17:47:47 -0700504 case SET_MAX_DEQUEUED_BUFFER_COUNT: {
505 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
506 int maxDequeuedBuffers = data.readInt32();
507 int result = setMaxDequeuedBufferCount(maxDequeuedBuffers);
508 reply->writeInt32(result);
509 return NO_ERROR;
510 }
511 case SET_ASYNC_MODE: {
512 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
513 bool async = data.readInt32();
514 int result = setAsyncMode(async);
515 reply->writeInt32(result);
516 return NO_ERROR;
517 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800518 case DEQUEUE_BUFFER: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800519 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800520 uint32_t width = data.readUint32();
521 uint32_t height = data.readUint32();
522 PixelFormat format = static_cast<PixelFormat>(data.readInt32());
523 uint32_t usage = data.readUint32();
Naveen Leekha12ba0f52015-09-21 17:28:04 -0700524 int buf = 0;
Jesse Hallf7857542012-06-14 15:26:33 -0700525 sp<Fence> fence;
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700526 int result = dequeueBuffer(&buf, &fence, width, height, format,
527 usage);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800528 reply->writeInt32(buf);
Jamie Gennis1df8c342012-12-20 14:05:45 -0800529 reply->writeInt32(fence != NULL);
530 if (fence != NULL) {
Mathias Agopianba93b3f2013-08-01 15:48:40 -0700531 reply->write(*fence);
Jesse Hallf7857542012-06-14 15:26:33 -0700532 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800533 reply->writeInt32(result);
534 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800535 }
Dan Stoza9f3053d2014-03-06 15:14:33 -0800536 case DETACH_BUFFER: {
537 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
538 int slot = data.readInt32();
539 int result = detachBuffer(slot);
540 reply->writeInt32(result);
541 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800542 }
Dan Stozad9822a32014-03-28 15:25:31 -0700543 case DETACH_NEXT_BUFFER: {
544 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
545 sp<GraphicBuffer> buffer;
546 sp<Fence> fence;
547 int32_t result = detachNextBuffer(&buffer, &fence);
548 reply->writeInt32(result);
549 if (result == NO_ERROR) {
550 reply->writeInt32(buffer != NULL);
551 if (buffer != NULL) {
552 reply->write(*buffer);
553 }
554 reply->writeInt32(fence != NULL);
555 if (fence != NULL) {
556 reply->write(*fence);
557 }
558 }
559 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800560 }
Dan Stoza9f3053d2014-03-06 15:14:33 -0800561 case ATTACH_BUFFER: {
562 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
563 sp<GraphicBuffer> buffer = new GraphicBuffer();
564 data.read(*buffer.get());
Naveen Leekha12ba0f52015-09-21 17:28:04 -0700565 int slot = 0;
Dan Stoza9f3053d2014-03-06 15:14:33 -0800566 int result = attachBuffer(&slot, buffer);
567 reply->writeInt32(slot);
568 reply->writeInt32(result);
569 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800570 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800571 case QUEUE_BUFFER: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800572 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800573 int buf = data.readInt32();
Jesse Hallc777b0b2012-06-28 12:52:05 -0700574 QueueBufferInput input(data);
Mathias Agopianf0bc2f12012-04-09 16:14:01 -0700575 QueueBufferOutput* const output =
576 reinterpret_cast<QueueBufferOutput *>(
577 reply->writeInplace(sizeof(QueueBufferOutput)));
Robert Shihd06421f2016-01-11 15:02:12 -0800578 memset(output, 0, sizeof(QueueBufferOutput));
Jesse Hallc777b0b2012-06-28 12:52:05 -0700579 status_t result = queueBuffer(buf, input, output);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800580 reply->writeInt32(result);
581 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800582 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800583 case CANCEL_BUFFER: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800584 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800585 int buf = data.readInt32();
Jamie Gennis1df8c342012-12-20 14:05:45 -0800586 sp<Fence> fence = new Fence();
587 data.read(*fence.get());
Pablo Ceballos583b1b32015-09-03 18:23:52 -0700588 status_t result = cancelBuffer(buf, fence);
589 reply->writeInt32(result);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800590 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800591 }
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700592 case QUERY: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800593 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Naveen Leekha12ba0f52015-09-21 17:28:04 -0700594 int value = 0;
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700595 int what = data.readInt32();
596 int res = query(what, &value);
597 reply->writeInt32(value);
598 reply->writeInt32(res);
599 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800600 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700601 case CONNECT: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800602 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Dan Stozaf0eaf252014-03-21 13:05:51 -0700603 sp<IProducerListener> listener;
604 if (data.readInt32() == 1) {
605 listener = IProducerListener::asInterface(data.readStrongBinder());
606 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700607 int api = data.readInt32();
Mathias Agopian595264f2013-07-16 22:56:09 -0700608 bool producerControlledByApp = data.readInt32();
Mathias Agopian24202f52012-04-23 14:28:58 -0700609 QueueBufferOutput* const output =
610 reinterpret_cast<QueueBufferOutput *>(
611 reply->writeInplace(sizeof(QueueBufferOutput)));
Pablo Ceballos93c617f2016-03-15 18:10:49 -0700612 memset(output, 0, sizeof(QueueBufferOutput));
Dan Stozaf0eaf252014-03-21 13:05:51 -0700613 status_t res = connect(listener, api, producerControlledByApp, output);
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700614 reply->writeInt32(res);
615 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800616 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700617 case DISCONNECT: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800618 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700619 int api = data.readInt32();
Mathias Agopian27730042011-07-14 20:20:58 -0700620 status_t res = disconnect(api);
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700621 reply->writeInt32(res);
622 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800623 }
Jesse Hall399184a2014-03-03 15:42:54 -0800624 case SET_SIDEBAND_STREAM: {
625 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
626 sp<NativeHandle> stream;
627 if (data.readInt32()) {
Wonsik Kim0ec54e12014-03-21 10:46:24 +0900628 stream = NativeHandle::create(data.readNativeHandle(), true);
Jesse Hall399184a2014-03-03 15:42:54 -0800629 }
630 status_t result = setSidebandStream(stream);
631 reply->writeInt32(result);
632 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800633 }
Dan Stoza9de72932015-04-16 17:28:43 -0700634 case ALLOCATE_BUFFERS: {
Dan Stoza29a3e902014-06-20 13:13:57 -0700635 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800636 uint32_t width = data.readUint32();
637 uint32_t height = data.readUint32();
638 PixelFormat format = static_cast<PixelFormat>(data.readInt32());
639 uint32_t usage = data.readUint32();
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700640 allocateBuffers(width, height, format, usage);
Dan Stoza29a3e902014-06-20 13:13:57 -0700641 return NO_ERROR;
Dan Stoza9de72932015-04-16 17:28:43 -0700642 }
643 case ALLOW_ALLOCATION: {
644 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
645 bool allow = static_cast<bool>(data.readInt32());
646 status_t result = allowAllocation(allow);
647 reply->writeInt32(result);
648 return NO_ERROR;
649 }
Dan Stoza812ed062015-06-02 15:45:22 -0700650 case SET_GENERATION_NUMBER: {
651 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
652 uint32_t generationNumber = data.readUint32();
653 status_t result = setGenerationNumber(generationNumber);
654 reply->writeInt32(result);
655 return NO_ERROR;
656 }
Dan Stozac6f30bd2015-06-08 09:32:50 -0700657 case GET_CONSUMER_NAME: {
658 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
659 reply->writeString8(getConsumerName());
660 return NO_ERROR;
661 }
Dan Stoza7dde5992015-05-22 09:51:44 -0700662 case GET_NEXT_FRAME_NUMBER: {
663 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
664 uint64_t frameNumber = getNextFrameNumber();
665 reply->writeUint64(frameNumber);
666 return NO_ERROR;
667 }
Pablo Ceballos3559fbf2016-03-17 15:50:23 -0700668 case SET_SHARED_BUFFER_MODE: {
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700669 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Pablo Ceballos3559fbf2016-03-17 15:50:23 -0700670 bool sharedBufferMode = data.readInt32();
671 status_t result = setSharedBufferMode(sharedBufferMode);
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700672 reply->writeInt32(result);
673 return NO_ERROR;
674 }
Pablo Ceballosff95aab2016-01-13 17:09:58 -0800675 case SET_AUTO_REFRESH: {
676 CHECK_INTERFACE(IGraphicBuffer, data, reply);
677 bool autoRefresh = data.readInt32();
678 status_t result = setAutoRefresh(autoRefresh);
679 reply->writeInt32(result);
680 return NO_ERROR;
681 }
Dan Stoza127fc632015-06-30 13:43:32 -0700682 case SET_DEQUEUE_TIMEOUT: {
683 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
684 nsecs_t timeout = data.readInt64();
685 status_t result = setDequeueTimeout(timeout);
686 reply->writeInt32(result);
687 return NO_ERROR;
688 }
Dan Stoza50101d02016-04-07 16:53:23 -0700689 case GET_LAST_QUEUED_BUFFER: {
690 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
691 sp<GraphicBuffer> buffer(nullptr);
692 sp<Fence> fence(Fence::NO_FENCE);
John Reck1a61da52016-04-28 13:18:15 -0700693 float transform[16] = {};
694 status_t result = getLastQueuedBuffer(&buffer, &fence, transform);
Dan Stoza50101d02016-04-07 16:53:23 -0700695 reply->writeInt32(result);
696 if (result != NO_ERROR) {
697 return result;
698 }
John Reckce8e5df2016-04-28 10:12:47 -0700699 if (!buffer.get()) {
700 reply->writeBool(false);
701 } else {
702 reply->writeBool(true);
703 result = reply->write(*buffer);
John Reck1a61da52016-04-28 13:18:15 -0700704 if (result == NO_ERROR) {
705 reply->write(transform, sizeof(float) * 16);
706 }
John Reckce8e5df2016-04-28 10:12:47 -0700707 }
Dan Stoza50101d02016-04-07 16:53:23 -0700708 if (result != NO_ERROR) {
709 ALOGE("getLastQueuedBuffer failed to write buffer: %d", result);
710 return result;
711 }
712 result = reply->write(*fence);
713 if (result != NO_ERROR) {
714 ALOGE("getLastQueuedBuffer failed to write fence: %d", result);
715 return result;
716 }
717 return NO_ERROR;
718 }
Pablo Ceballosce796e72016-02-04 19:10:51 -0800719 case GET_FRAME_TIMESTAMPS: {
720 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
721 uint64_t frameNumber = 0;
722 status_t result = data.readUint64(&frameNumber);
723 if (result != NO_ERROR) {
724 ALOGE("onTransact failed to read: %d", result);
725 return result;
726 }
727 FrameTimestamps timestamps;
728 bool found = getFrameTimestamps(frameNumber, &timestamps);
729 result = reply->writeBool(found);
730 if (result != NO_ERROR) {
731 ALOGE("onTransact failed to write: %d", result);
732 return result;
733 }
734 if (found) {
735 result = reply->write(timestamps);
736 if (result != NO_ERROR) {
737 ALOGE("onTransact failed to write timestamps: %d", result);
738 return result;
739 }
740 }
741 return NO_ERROR;
742 }
Pablo Ceballos8e3e92b2016-06-27 17:56:53 -0700743 case GET_UNIQUE_ID: {
744 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
745 uint64_t outId = 0;
746 status_t actualResult = getUniqueId(&outId);
747 status_t result = reply->writeInt32(actualResult);
748 if (result != NO_ERROR) {
749 return result;
750 }
751 result = reply->writeUint64(outId);
752 if (result != NO_ERROR) {
753 return result;
754 }
755 return NO_ERROR;
756 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800757 }
758 return BBinder::onTransact(code, data, reply, flags);
759}
760
761// ----------------------------------------------------------------------------
762
Andy McFadden2adaf042012-12-18 09:49:45 -0800763IGraphicBufferProducer::QueueBufferInput::QueueBufferInput(const Parcel& parcel) {
Jesse Hallc777b0b2012-06-28 12:52:05 -0700764 parcel.read(*this);
765}
766
Mathias Agopiane1424282013-07-29 21:24:40 -0700767size_t IGraphicBufferProducer::QueueBufferInput::getFlattenedSize() const {
Jesse Hallc777b0b2012-06-28 12:52:05 -0700768 return sizeof(timestamp)
Andy McFadden3c256212013-08-16 14:55:39 -0700769 + sizeof(isAutoTimestamp)
Eino-Ville Talvala82c6bcc2015-02-19 16:10:43 -0800770 + sizeof(dataSpace)
Jesse Hallc777b0b2012-06-28 12:52:05 -0700771 + sizeof(crop)
772 + sizeof(scalingMode)
773 + sizeof(transform)
Ruben Brunk1681d952014-06-27 15:51:55 -0700774 + sizeof(stickyTransform)
Dan Stoza5065a552015-03-17 16:23:42 -0700775 + fence->getFlattenedSize()
776 + surfaceDamage.getFlattenedSize();
Jesse Hallc777b0b2012-06-28 12:52:05 -0700777}
778
Mathias Agopiane1424282013-07-29 21:24:40 -0700779size_t IGraphicBufferProducer::QueueBufferInput::getFdCount() const {
Jamie Gennis1df8c342012-12-20 14:05:45 -0800780 return fence->getFdCount();
Jesse Hallc777b0b2012-06-28 12:52:05 -0700781}
782
Mathias Agopiane1424282013-07-29 21:24:40 -0700783status_t IGraphicBufferProducer::QueueBufferInput::flatten(
784 void*& buffer, size_t& size, int*& fds, size_t& count) const
Jesse Hallc777b0b2012-06-28 12:52:05 -0700785{
Mathias Agopiane1424282013-07-29 21:24:40 -0700786 if (size < getFlattenedSize()) {
787 return NO_MEMORY;
788 }
789 FlattenableUtils::write(buffer, size, timestamp);
Andy McFadden3c256212013-08-16 14:55:39 -0700790 FlattenableUtils::write(buffer, size, isAutoTimestamp);
Eino-Ville Talvala82c6bcc2015-02-19 16:10:43 -0800791 FlattenableUtils::write(buffer, size, dataSpace);
Mathias Agopiane1424282013-07-29 21:24:40 -0700792 FlattenableUtils::write(buffer, size, crop);
793 FlattenableUtils::write(buffer, size, scalingMode);
794 FlattenableUtils::write(buffer, size, transform);
Ruben Brunk1681d952014-06-27 15:51:55 -0700795 FlattenableUtils::write(buffer, size, stickyTransform);
Dan Stoza5065a552015-03-17 16:23:42 -0700796 status_t result = fence->flatten(buffer, size, fds, count);
797 if (result != NO_ERROR) {
798 return result;
799 }
800 return surfaceDamage.flatten(buffer, size);
Jesse Hallc777b0b2012-06-28 12:52:05 -0700801}
802
Mathias Agopiane1424282013-07-29 21:24:40 -0700803status_t IGraphicBufferProducer::QueueBufferInput::unflatten(
804 void const*& buffer, size_t& size, int const*& fds, size_t& count)
Jesse Hallc777b0b2012-06-28 12:52:05 -0700805{
Mathias Agopiane1424282013-07-29 21:24:40 -0700806 size_t minNeeded =
807 sizeof(timestamp)
Andy McFadden3c256212013-08-16 14:55:39 -0700808 + sizeof(isAutoTimestamp)
Eino-Ville Talvala82c6bcc2015-02-19 16:10:43 -0800809 + sizeof(dataSpace)
Mathias Agopiane1424282013-07-29 21:24:40 -0700810 + sizeof(crop)
811 + sizeof(scalingMode)
812 + sizeof(transform)
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700813 + sizeof(stickyTransform);
Mathias Agopiane1424282013-07-29 21:24:40 -0700814
815 if (size < minNeeded) {
816 return NO_MEMORY;
817 }
818
819 FlattenableUtils::read(buffer, size, timestamp);
Andy McFadden3c256212013-08-16 14:55:39 -0700820 FlattenableUtils::read(buffer, size, isAutoTimestamp);
Eino-Ville Talvala82c6bcc2015-02-19 16:10:43 -0800821 FlattenableUtils::read(buffer, size, dataSpace);
Mathias Agopiane1424282013-07-29 21:24:40 -0700822 FlattenableUtils::read(buffer, size, crop);
823 FlattenableUtils::read(buffer, size, scalingMode);
824 FlattenableUtils::read(buffer, size, transform);
Ruben Brunk1681d952014-06-27 15:51:55 -0700825 FlattenableUtils::read(buffer, size, stickyTransform);
Mathias Agopiane1424282013-07-29 21:24:40 -0700826
Jamie Gennis1df8c342012-12-20 14:05:45 -0800827 fence = new Fence();
Dan Stoza5065a552015-03-17 16:23:42 -0700828 status_t result = fence->unflatten(buffer, size, fds, count);
829 if (result != NO_ERROR) {
830 return result;
831 }
832 return surfaceDamage.unflatten(buffer, size);
Jesse Hallc777b0b2012-06-28 12:52:05 -0700833}
834
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800835}; // namespace android