blob: fbd704d03d5b09fe26d8a59bfb76c0374572b97c [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 Ceballos3559fbf2016-03-17 15:50:23 -070053 SET_SHARED_BUFFER_MODE,
Pablo Ceballosff95aab2016-01-13 17:09:58 -080054 SET_AUTO_REFRESH,
Dan Stoza127fc632015-06-30 13:43:32 -070055 SET_DEQUEUE_TIMEOUT,
Dan Stoza50101d02016-04-07 16:53:23 -070056 GET_LAST_QUEUED_BUFFER,
Pablo Ceballos0ade2472016-06-30 16:48:02 -070057 GET_FRAME_TIMESTAMPS,
58 GET_UNIQUE_ID
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080059};
60
Andy McFadden2adaf042012-12-18 09:49:45 -080061class BpGraphicBufferProducer : public BpInterface<IGraphicBufferProducer>
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080062{
63public:
Andy McFadden2adaf042012-12-18 09:49:45 -080064 BpGraphicBufferProducer(const sp<IBinder>& impl)
65 : BpInterface<IGraphicBufferProducer>(impl)
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080066 {
67 }
68
Dan Stoza3be1c6b2014-11-18 10:24:03 -080069 virtual ~BpGraphicBufferProducer();
70
Jamie Gennis7b305ff2011-07-19 12:08:33 -070071 virtual status_t requestBuffer(int bufferIdx, sp<GraphicBuffer>* buf) {
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080072 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -080073 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080074 data.writeInt32(bufferIdx);
Jamie Gennis8a29ff22011-10-14 15:03:17 -070075 status_t result =remote()->transact(REQUEST_BUFFER, data, &reply);
76 if (result != NO_ERROR) {
77 return result;
78 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080079 bool nonNull = reply.readInt32();
80 if (nonNull) {
Jamie Gennis7b305ff2011-07-19 12:08:33 -070081 *buf = new GraphicBuffer();
Lingyun Zhu2aff7022012-11-20 19:24:35 +080082 result = reply.read(**buf);
83 if(result != NO_ERROR) {
84 (*buf).clear();
85 return result;
86 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080087 }
Jamie Gennis8a29ff22011-10-14 15:03:17 -070088 result = reply.readInt32();
Jamie Gennis7b305ff2011-07-19 12:08:33 -070089 return result;
Jamie Gennis8ba32fa2010-12-20 11:27:26 -080090 }
91
Pablo Ceballosfa455352015-08-12 17:47:47 -070092 virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers) {
93 Parcel data, reply;
94 data.writeInterfaceToken(
95 IGraphicBufferProducer::getInterfaceDescriptor());
96 data.writeInt32(maxDequeuedBuffers);
97 status_t result = remote()->transact(SET_MAX_DEQUEUED_BUFFER_COUNT,
98 data, &reply);
99 if (result != NO_ERROR) {
100 return result;
101 }
102 result = reply.readInt32();
103 return result;
104 }
105
106 virtual status_t setAsyncMode(bool async) {
107 Parcel data, reply;
108 data.writeInterfaceToken(
109 IGraphicBufferProducer::getInterfaceDescriptor());
110 data.writeInt32(async);
111 status_t result = remote()->transact(SET_ASYNC_MODE,
112 data, &reply);
113 if (result != NO_ERROR) {
114 return result;
115 }
116 result = reply.readInt32();
117 return result;
118 }
119
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700120 virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, uint32_t width,
121 uint32_t height, PixelFormat format, uint32_t usage) {
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800122 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800123 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800124 data.writeUint32(width);
125 data.writeUint32(height);
126 data.writeInt32(static_cast<int32_t>(format));
127 data.writeUint32(usage);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700128 status_t result = remote()->transact(DEQUEUE_BUFFER, data, &reply);
129 if (result != NO_ERROR) {
130 return result;
131 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800132 *buf = reply.readInt32();
Mathias Agopianba93b3f2013-08-01 15:48:40 -0700133 bool nonNull = reply.readInt32();
134 if (nonNull) {
Jesse Hall4c00cc12013-03-15 21:34:30 -0700135 *fence = new Fence();
Pablo Ceballos70636b32016-07-06 15:24:54 -0700136 result = reply.read(**fence);
137 if (result != NO_ERROR) {
138 fence->clear();
139 return result;
140 }
Jesse Hallf7857542012-06-14 15:26:33 -0700141 }
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700142 result = reply.readInt32();
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800143 return result;
144 }
145
Dan Stoza9f3053d2014-03-06 15:14:33 -0800146 virtual status_t detachBuffer(int slot) {
147 Parcel data, reply;
148 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
149 data.writeInt32(slot);
150 status_t result = remote()->transact(DETACH_BUFFER, data, &reply);
151 if (result != NO_ERROR) {
152 return result;
153 }
154 result = reply.readInt32();
155 return result;
156 }
157
Dan Stozad9822a32014-03-28 15:25:31 -0700158 virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
159 sp<Fence>* outFence) {
160 if (outBuffer == NULL) {
161 ALOGE("detachNextBuffer: outBuffer must not be NULL");
162 return BAD_VALUE;
163 } else if (outFence == NULL) {
164 ALOGE("detachNextBuffer: outFence must not be NULL");
165 return BAD_VALUE;
166 }
167 Parcel data, reply;
168 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
169 status_t result = remote()->transact(DETACH_NEXT_BUFFER, data, &reply);
170 if (result != NO_ERROR) {
171 return result;
172 }
173 result = reply.readInt32();
174 if (result == NO_ERROR) {
175 bool nonNull = reply.readInt32();
176 if (nonNull) {
177 *outBuffer = new GraphicBuffer;
Pablo Ceballos70636b32016-07-06 15:24:54 -0700178 result = reply.read(**outBuffer);
179 if (result != NO_ERROR) {
180 outBuffer->clear();
181 return result;
182 }
Dan Stozad9822a32014-03-28 15:25:31 -0700183 }
184 nonNull = reply.readInt32();
185 if (nonNull) {
186 *outFence = new Fence;
Pablo Ceballos70636b32016-07-06 15:24:54 -0700187 result = reply.read(**outFence);
188 if (result != NO_ERROR) {
189 outBuffer->clear();
190 outFence->clear();
191 return result;
192 }
Dan Stozad9822a32014-03-28 15:25:31 -0700193 }
194 }
195 return result;
196 }
197
Dan Stoza9f3053d2014-03-06 15:14:33 -0800198 virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer) {
199 Parcel data, reply;
200 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
201 data.write(*buffer.get());
202 status_t result = remote()->transact(ATTACH_BUFFER, data, &reply);
203 if (result != NO_ERROR) {
204 return result;
205 }
206 *slot = reply.readInt32();
207 result = reply.readInt32();
208 return result;
209 }
210
Mathias Agopianf0bc2f12012-04-09 16:14:01 -0700211 virtual status_t queueBuffer(int buf,
212 const QueueBufferInput& input, QueueBufferOutput* output) {
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800213 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800214 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800215 data.writeInt32(buf);
Jesse Hallc777b0b2012-06-28 12:52:05 -0700216 data.write(input);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700217 status_t result = remote()->transact(QUEUE_BUFFER, data, &reply);
218 if (result != NO_ERROR) {
219 return result;
220 }
Mathias Agopianf0bc2f12012-04-09 16:14:01 -0700221 memcpy(output, reply.readInplace(sizeof(*output)), sizeof(*output));
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700222 result = reply.readInt32();
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800223 return result;
224 }
225
Pablo Ceballos583b1b32015-09-03 18:23:52 -0700226 virtual status_t cancelBuffer(int buf, const sp<Fence>& fence) {
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800227 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800228 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800229 data.writeInt32(buf);
Jamie Gennis1df8c342012-12-20 14:05:45 -0800230 data.write(*fence.get());
Pablo Ceballos583b1b32015-09-03 18:23:52 -0700231 status_t result = remote()->transact(CANCEL_BUFFER, data, &reply);
232 if (result != NO_ERROR) {
233 return result;
234 }
235 result = reply.readInt32();
236 return result;
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800237 }
238
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700239 virtual int query(int what, int* value) {
240 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800241 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700242 data.writeInt32(what);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700243 status_t result = remote()->transact(QUERY, data, &reply);
244 if (result != NO_ERROR) {
245 return result;
246 }
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700247 value[0] = reply.readInt32();
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700248 result = reply.readInt32();
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700249 return result;
250 }
251
Dan Stozaf0eaf252014-03-21 13:05:51 -0700252 virtual status_t connect(const sp<IProducerListener>& listener,
Mathias Agopian365857d2013-09-11 19:35:45 -0700253 int api, bool producerControlledByApp, QueueBufferOutput* output) {
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700254 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800255 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Dan Stozaf0eaf252014-03-21 13:05:51 -0700256 if (listener != NULL) {
257 data.writeInt32(1);
Marco Nelissen097ca272014-11-14 08:01:01 -0800258 data.writeStrongBinder(IInterface::asBinder(listener));
Dan Stozaf0eaf252014-03-21 13:05:51 -0700259 } else {
260 data.writeInt32(0);
261 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700262 data.writeInt32(api);
Mathias Agopian595264f2013-07-16 22:56:09 -0700263 data.writeInt32(producerControlledByApp);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700264 status_t result = remote()->transact(CONNECT, data, &reply);
265 if (result != NO_ERROR) {
266 return result;
267 }
Mathias Agopian24202f52012-04-23 14:28:58 -0700268 memcpy(output, reply.readInplace(sizeof(*output)), sizeof(*output));
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700269 result = reply.readInt32();
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700270 return result;
271 }
Mathias Agopian80727112011-05-02 19:51:12 -0700272
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700273 virtual status_t disconnect(int api) {
274 Parcel data, reply;
Andy McFadden2adaf042012-12-18 09:49:45 -0800275 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700276 data.writeInt32(api);
Jamie Gennis8a29ff22011-10-14 15:03:17 -0700277 status_t result =remote()->transact(DISCONNECT, data, &reply);
278 if (result != NO_ERROR) {
279 return result;
280 }
281 result = reply.readInt32();
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700282 return result;
283 }
Jesse Hall399184a2014-03-03 15:42:54 -0800284
285 virtual status_t setSidebandStream(const sp<NativeHandle>& stream) {
286 Parcel data, reply;
287 status_t result;
288 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
289 if (stream.get()) {
290 data.writeInt32(true);
291 data.writeNativeHandle(stream->handle());
292 } else {
293 data.writeInt32(false);
294 }
295 if ((result = remote()->transact(SET_SIDEBAND_STREAM, data, &reply)) == NO_ERROR) {
296 result = reply.readInt32();
297 }
298 return result;
299 }
Dan Stoza29a3e902014-06-20 13:13:57 -0700300
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700301 virtual void allocateBuffers(uint32_t width, uint32_t height,
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800302 PixelFormat format, uint32_t usage) {
Dan Stoza29a3e902014-06-20 13:13:57 -0700303 Parcel data, reply;
304 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800305 data.writeUint32(width);
306 data.writeUint32(height);
Dan Stoza29a3e902014-06-20 13:13:57 -0700307 data.writeInt32(static_cast<int32_t>(format));
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800308 data.writeUint32(usage);
Dan Stoza29a3e902014-06-20 13:13:57 -0700309 status_t result = remote()->transact(ALLOCATE_BUFFERS, data, &reply);
310 if (result != NO_ERROR) {
311 ALOGE("allocateBuffers failed to transact: %d", result);
312 }
313 }
Dan Stoza9de72932015-04-16 17:28:43 -0700314
315 virtual status_t allowAllocation(bool allow) {
316 Parcel data, reply;
317 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
318 data.writeInt32(static_cast<int32_t>(allow));
319 status_t result = remote()->transact(ALLOW_ALLOCATION, data, &reply);
320 if (result != NO_ERROR) {
321 return result;
322 }
323 result = reply.readInt32();
324 return result;
325 }
Dan Stoza812ed062015-06-02 15:45:22 -0700326
327 virtual status_t setGenerationNumber(uint32_t generationNumber) {
328 Parcel data, reply;
329 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
330 data.writeUint32(generationNumber);
331 status_t result = remote()->transact(SET_GENERATION_NUMBER, data, &reply);
332 if (result == NO_ERROR) {
333 result = reply.readInt32();
334 }
335 return result;
336 }
Dan Stozac6f30bd2015-06-08 09:32:50 -0700337
338 virtual String8 getConsumerName() const {
339 Parcel data, reply;
340 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
341 status_t result = remote()->transact(GET_CONSUMER_NAME, data, &reply);
342 if (result != NO_ERROR) {
343 ALOGE("getConsumerName failed to transact: %d", result);
344 return String8("TransactFailed");
345 }
346 return reply.readString8();
347 }
Dan Stoza7dde5992015-05-22 09:51:44 -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();
Pablo Ceballos70636b32016-07-06 15:24:54 -0700564 status_t result = data.read(*buffer.get());
Naveen Leekha12ba0f52015-09-21 17:28:04 -0700565 int slot = 0;
Pablo Ceballos70636b32016-07-06 15:24:54 -0700566 if (result == NO_ERROR) {
567 result = attachBuffer(&slot, buffer);
568 }
Dan Stoza9f3053d2014-03-06 15:14:33 -0800569 reply->writeInt32(slot);
570 reply->writeInt32(result);
571 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800572 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800573 case QUEUE_BUFFER: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800574 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800575 int buf = data.readInt32();
Jesse Hallc777b0b2012-06-28 12:52:05 -0700576 QueueBufferInput input(data);
Mathias Agopianf0bc2f12012-04-09 16:14:01 -0700577 QueueBufferOutput* const output =
578 reinterpret_cast<QueueBufferOutput *>(
579 reply->writeInplace(sizeof(QueueBufferOutput)));
Robert Shihd06421f2016-01-11 15:02:12 -0800580 memset(output, 0, sizeof(QueueBufferOutput));
Jesse Hallc777b0b2012-06-28 12:52:05 -0700581 status_t result = queueBuffer(buf, input, output);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800582 reply->writeInt32(result);
583 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800584 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800585 case CANCEL_BUFFER: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800586 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800587 int buf = data.readInt32();
Jamie Gennis1df8c342012-12-20 14:05:45 -0800588 sp<Fence> fence = new Fence();
Pablo Ceballos70636b32016-07-06 15:24:54 -0700589 status_t result = data.read(*fence.get());
590 if (result == NO_ERROR) {
591 result = cancelBuffer(buf, fence);
592 }
Pablo Ceballos583b1b32015-09-03 18:23:52 -0700593 reply->writeInt32(result);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800594 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800595 }
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700596 case QUERY: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800597 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Naveen Leekha12ba0f52015-09-21 17:28:04 -0700598 int value = 0;
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700599 int what = data.readInt32();
600 int res = query(what, &value);
601 reply->writeInt32(value);
602 reply->writeInt32(res);
603 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800604 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700605 case CONNECT: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800606 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Dan Stozaf0eaf252014-03-21 13:05:51 -0700607 sp<IProducerListener> listener;
608 if (data.readInt32() == 1) {
609 listener = IProducerListener::asInterface(data.readStrongBinder());
610 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700611 int api = data.readInt32();
Mathias Agopian595264f2013-07-16 22:56:09 -0700612 bool producerControlledByApp = data.readInt32();
Mathias Agopian24202f52012-04-23 14:28:58 -0700613 QueueBufferOutput* const output =
614 reinterpret_cast<QueueBufferOutput *>(
615 reply->writeInplace(sizeof(QueueBufferOutput)));
Pablo Ceballos93c617f2016-03-15 18:10:49 -0700616 memset(output, 0, sizeof(QueueBufferOutput));
Dan Stozaf0eaf252014-03-21 13:05:51 -0700617 status_t res = connect(listener, api, producerControlledByApp, output);
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700618 reply->writeInt32(res);
619 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800620 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700621 case DISCONNECT: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800622 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700623 int api = data.readInt32();
Mathias Agopian27730042011-07-14 20:20:58 -0700624 status_t res = disconnect(api);
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700625 reply->writeInt32(res);
626 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800627 }
Jesse Hall399184a2014-03-03 15:42:54 -0800628 case SET_SIDEBAND_STREAM: {
629 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
630 sp<NativeHandle> stream;
631 if (data.readInt32()) {
Wonsik Kim0ec54e12014-03-21 10:46:24 +0900632 stream = NativeHandle::create(data.readNativeHandle(), true);
Jesse Hall399184a2014-03-03 15:42:54 -0800633 }
634 status_t result = setSidebandStream(stream);
635 reply->writeInt32(result);
636 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800637 }
Dan Stoza9de72932015-04-16 17:28:43 -0700638 case ALLOCATE_BUFFERS: {
Dan Stoza29a3e902014-06-20 13:13:57 -0700639 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800640 uint32_t width = data.readUint32();
641 uint32_t height = data.readUint32();
642 PixelFormat format = static_cast<PixelFormat>(data.readInt32());
643 uint32_t usage = data.readUint32();
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700644 allocateBuffers(width, height, format, usage);
Dan Stoza29a3e902014-06-20 13:13:57 -0700645 return NO_ERROR;
Dan Stoza9de72932015-04-16 17:28:43 -0700646 }
647 case ALLOW_ALLOCATION: {
648 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
649 bool allow = static_cast<bool>(data.readInt32());
650 status_t result = allowAllocation(allow);
651 reply->writeInt32(result);
652 return NO_ERROR;
653 }
Dan Stoza812ed062015-06-02 15:45:22 -0700654 case SET_GENERATION_NUMBER: {
655 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
656 uint32_t generationNumber = data.readUint32();
657 status_t result = setGenerationNumber(generationNumber);
658 reply->writeInt32(result);
659 return NO_ERROR;
660 }
Dan Stozac6f30bd2015-06-08 09:32:50 -0700661 case GET_CONSUMER_NAME: {
662 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
663 reply->writeString8(getConsumerName());
664 return NO_ERROR;
665 }
Pablo Ceballos3559fbf2016-03-17 15:50:23 -0700666 case SET_SHARED_BUFFER_MODE: {
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700667 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Pablo Ceballos3559fbf2016-03-17 15:50:23 -0700668 bool sharedBufferMode = data.readInt32();
669 status_t result = setSharedBufferMode(sharedBufferMode);
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700670 reply->writeInt32(result);
671 return NO_ERROR;
672 }
Pablo Ceballosff95aab2016-01-13 17:09:58 -0800673 case SET_AUTO_REFRESH: {
674 CHECK_INTERFACE(IGraphicBuffer, data, reply);
675 bool autoRefresh = data.readInt32();
676 status_t result = setAutoRefresh(autoRefresh);
677 reply->writeInt32(result);
678 return NO_ERROR;
679 }
Dan Stoza127fc632015-06-30 13:43:32 -0700680 case SET_DEQUEUE_TIMEOUT: {
681 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
682 nsecs_t timeout = data.readInt64();
683 status_t result = setDequeueTimeout(timeout);
684 reply->writeInt32(result);
685 return NO_ERROR;
686 }
Dan Stoza50101d02016-04-07 16:53:23 -0700687 case GET_LAST_QUEUED_BUFFER: {
688 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
689 sp<GraphicBuffer> buffer(nullptr);
690 sp<Fence> fence(Fence::NO_FENCE);
John Reck1a61da52016-04-28 13:18:15 -0700691 float transform[16] = {};
692 status_t result = getLastQueuedBuffer(&buffer, &fence, transform);
Dan Stoza50101d02016-04-07 16:53:23 -0700693 reply->writeInt32(result);
694 if (result != NO_ERROR) {
695 return result;
696 }
John Reckce8e5df2016-04-28 10:12:47 -0700697 if (!buffer.get()) {
698 reply->writeBool(false);
699 } else {
700 reply->writeBool(true);
701 result = reply->write(*buffer);
John Reck1a61da52016-04-28 13:18:15 -0700702 if (result == NO_ERROR) {
703 reply->write(transform, sizeof(float) * 16);
704 }
John Reckce8e5df2016-04-28 10:12:47 -0700705 }
Dan Stoza50101d02016-04-07 16:53:23 -0700706 if (result != NO_ERROR) {
707 ALOGE("getLastQueuedBuffer failed to write buffer: %d", result);
708 return result;
709 }
710 result = reply->write(*fence);
711 if (result != NO_ERROR) {
712 ALOGE("getLastQueuedBuffer failed to write fence: %d", result);
713 return result;
714 }
715 return NO_ERROR;
716 }
Pablo Ceballosce796e72016-02-04 19:10:51 -0800717 case GET_FRAME_TIMESTAMPS: {
718 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
719 uint64_t frameNumber = 0;
720 status_t result = data.readUint64(&frameNumber);
721 if (result != NO_ERROR) {
722 ALOGE("onTransact failed to read: %d", result);
723 return result;
724 }
725 FrameTimestamps timestamps;
726 bool found = getFrameTimestamps(frameNumber, &timestamps);
727 result = reply->writeBool(found);
728 if (result != NO_ERROR) {
729 ALOGE("onTransact failed to write: %d", result);
730 return result;
731 }
732 if (found) {
733 result = reply->write(timestamps);
734 if (result != NO_ERROR) {
735 ALOGE("onTransact failed to write timestamps: %d", result);
736 return result;
737 }
738 }
739 return NO_ERROR;
740 }
Pablo Ceballos8e3e92b2016-06-27 17:56:53 -0700741 case GET_UNIQUE_ID: {
742 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
743 uint64_t outId = 0;
744 status_t actualResult = getUniqueId(&outId);
745 status_t result = reply->writeInt32(actualResult);
746 if (result != NO_ERROR) {
747 return result;
748 }
749 result = reply->writeUint64(outId);
750 if (result != NO_ERROR) {
751 return result;
752 }
753 return NO_ERROR;
754 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800755 }
756 return BBinder::onTransact(code, data, reply, flags);
757}
758
759// ----------------------------------------------------------------------------
760
Andy McFadden2adaf042012-12-18 09:49:45 -0800761IGraphicBufferProducer::QueueBufferInput::QueueBufferInput(const Parcel& parcel) {
Jesse Hallc777b0b2012-06-28 12:52:05 -0700762 parcel.read(*this);
763}
764
Mathias Agopiane1424282013-07-29 21:24:40 -0700765size_t IGraphicBufferProducer::QueueBufferInput::getFlattenedSize() const {
Jesse Hallc777b0b2012-06-28 12:52:05 -0700766 return sizeof(timestamp)
Andy McFadden3c256212013-08-16 14:55:39 -0700767 + sizeof(isAutoTimestamp)
Eino-Ville Talvala82c6bcc2015-02-19 16:10:43 -0800768 + sizeof(dataSpace)
Jesse Hallc777b0b2012-06-28 12:52:05 -0700769 + sizeof(crop)
770 + sizeof(scalingMode)
771 + sizeof(transform)
Ruben Brunk1681d952014-06-27 15:51:55 -0700772 + sizeof(stickyTransform)
Dan Stoza5065a552015-03-17 16:23:42 -0700773 + fence->getFlattenedSize()
774 + surfaceDamage.getFlattenedSize();
Jesse Hallc777b0b2012-06-28 12:52:05 -0700775}
776
Mathias Agopiane1424282013-07-29 21:24:40 -0700777size_t IGraphicBufferProducer::QueueBufferInput::getFdCount() const {
Jamie Gennis1df8c342012-12-20 14:05:45 -0800778 return fence->getFdCount();
Jesse Hallc777b0b2012-06-28 12:52:05 -0700779}
780
Mathias Agopiane1424282013-07-29 21:24:40 -0700781status_t IGraphicBufferProducer::QueueBufferInput::flatten(
782 void*& buffer, size_t& size, int*& fds, size_t& count) const
Jesse Hallc777b0b2012-06-28 12:52:05 -0700783{
Mathias Agopiane1424282013-07-29 21:24:40 -0700784 if (size < getFlattenedSize()) {
785 return NO_MEMORY;
786 }
787 FlattenableUtils::write(buffer, size, timestamp);
Andy McFadden3c256212013-08-16 14:55:39 -0700788 FlattenableUtils::write(buffer, size, isAutoTimestamp);
Eino-Ville Talvala82c6bcc2015-02-19 16:10:43 -0800789 FlattenableUtils::write(buffer, size, dataSpace);
Mathias Agopiane1424282013-07-29 21:24:40 -0700790 FlattenableUtils::write(buffer, size, crop);
791 FlattenableUtils::write(buffer, size, scalingMode);
792 FlattenableUtils::write(buffer, size, transform);
Ruben Brunk1681d952014-06-27 15:51:55 -0700793 FlattenableUtils::write(buffer, size, stickyTransform);
Dan Stoza5065a552015-03-17 16:23:42 -0700794 status_t result = fence->flatten(buffer, size, fds, count);
795 if (result != NO_ERROR) {
796 return result;
797 }
798 return surfaceDamage.flatten(buffer, size);
Jesse Hallc777b0b2012-06-28 12:52:05 -0700799}
800
Mathias Agopiane1424282013-07-29 21:24:40 -0700801status_t IGraphicBufferProducer::QueueBufferInput::unflatten(
802 void const*& buffer, size_t& size, int const*& fds, size_t& count)
Jesse Hallc777b0b2012-06-28 12:52:05 -0700803{
Mathias Agopiane1424282013-07-29 21:24:40 -0700804 size_t minNeeded =
805 sizeof(timestamp)
Andy McFadden3c256212013-08-16 14:55:39 -0700806 + sizeof(isAutoTimestamp)
Eino-Ville Talvala82c6bcc2015-02-19 16:10:43 -0800807 + sizeof(dataSpace)
Mathias Agopiane1424282013-07-29 21:24:40 -0700808 + sizeof(crop)
809 + sizeof(scalingMode)
810 + sizeof(transform)
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700811 + sizeof(stickyTransform);
Mathias Agopiane1424282013-07-29 21:24:40 -0700812
813 if (size < minNeeded) {
814 return NO_MEMORY;
815 }
816
817 FlattenableUtils::read(buffer, size, timestamp);
Andy McFadden3c256212013-08-16 14:55:39 -0700818 FlattenableUtils::read(buffer, size, isAutoTimestamp);
Eino-Ville Talvala82c6bcc2015-02-19 16:10:43 -0800819 FlattenableUtils::read(buffer, size, dataSpace);
Mathias Agopiane1424282013-07-29 21:24:40 -0700820 FlattenableUtils::read(buffer, size, crop);
821 FlattenableUtils::read(buffer, size, scalingMode);
822 FlattenableUtils::read(buffer, size, transform);
Ruben Brunk1681d952014-06-27 15:51:55 -0700823 FlattenableUtils::read(buffer, size, stickyTransform);
Mathias Agopiane1424282013-07-29 21:24:40 -0700824
Jamie Gennis1df8c342012-12-20 14:05:45 -0800825 fence = new Fence();
Dan Stoza5065a552015-03-17 16:23:42 -0700826 status_t result = fence->unflatten(buffer, size, fds, count);
827 if (result != NO_ERROR) {
828 return result;
829 }
830 return surfaceDamage.unflatten(buffer, size);
Jesse Hallc777b0b2012-06-28 12:52:05 -0700831}
832
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800833}; // namespace android