blob: 846c205c00502fee6844fa0ed472f9c2244baacd [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 Ceballosfc352582016-06-30 17:22:20 -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:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070064 explicit BpGraphicBufferProducer(const sp<IBinder>& impl)
Andy McFadden2adaf042012-12-18 09:49:45 -080065 : 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
Robert Carr97b9c862016-09-08 13:54:35 -0700273 virtual status_t disconnect(int api, DisconnectMode mode) {
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700274 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);
Robert Carr97b9c862016-09-08 13:54:35 -0700277 data.writeInt32(static_cast<int32_t>(mode));
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
Pablo Ceballos3559fbf2016-03-17 15:50:23 -0700350 virtual status_t setSharedBufferMode(bool sharedBufferMode) {
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700351 Parcel data, reply;
352 data.writeInterfaceToken(
353 IGraphicBufferProducer::getInterfaceDescriptor());
Pablo Ceballos3559fbf2016-03-17 15:50:23 -0700354 data.writeInt32(sharedBufferMode);
355 status_t result = remote()->transact(SET_SHARED_BUFFER_MODE, data,
Pablo Ceballosccdfd602015-10-07 15:05:45 -0700356 &reply);
357 if (result == NO_ERROR) {
358 result = reply.readInt32();
359 }
360 return result;
361 }
Dan Stoza127fc632015-06-30 13:43:32 -0700362
Pablo Ceballosff95aab2016-01-13 17:09:58 -0800363 virtual status_t setAutoRefresh(bool autoRefresh) {
364 Parcel data, reply;
365 data.writeInterfaceToken(
366 IGraphicBufferProducer::getInterfaceDescriptor());
367 data.writeInt32(autoRefresh);
368 status_t result = remote()->transact(SET_AUTO_REFRESH, data, &reply);
369 if (result == NO_ERROR) {
370 result = reply.readInt32();
371 }
372 return result;
373 }
374
Dan Stoza127fc632015-06-30 13:43:32 -0700375 virtual status_t setDequeueTimeout(nsecs_t timeout) {
376 Parcel data, reply;
377 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
378 data.writeInt64(timeout);
379 status_t result = remote()->transact(SET_DEQUEUE_TIMEOUT, data, &reply);
380 if (result != NO_ERROR) {
381 ALOGE("setDequeueTimeout failed to transact: %d", result);
382 return result;
383 }
384 return reply.readInt32();
385 }
Dan Stoza50101d02016-04-07 16:53:23 -0700386
387 virtual status_t getLastQueuedBuffer(sp<GraphicBuffer>* outBuffer,
John Reck1a61da52016-04-28 13:18:15 -0700388 sp<Fence>* outFence, float outTransformMatrix[16]) override {
Dan Stoza50101d02016-04-07 16:53:23 -0700389 Parcel data, reply;
390 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
391 status_t result = remote()->transact(GET_LAST_QUEUED_BUFFER, data,
392 &reply);
393 if (result != NO_ERROR) {
394 ALOGE("getLastQueuedBuffer failed to transact: %d", result);
395 return result;
396 }
397 result = reply.readInt32();
398 if (result != NO_ERROR) {
399 return result;
400 }
John Reckce8e5df2016-04-28 10:12:47 -0700401 bool hasBuffer = reply.readBool();
402 sp<GraphicBuffer> buffer;
403 if (hasBuffer) {
404 buffer = new GraphicBuffer();
405 result = reply.read(*buffer);
John Reck1a61da52016-04-28 13:18:15 -0700406 if (result == NO_ERROR) {
407 result = reply.read(outTransformMatrix, sizeof(float) * 16);
408 }
John Reckce8e5df2016-04-28 10:12:47 -0700409 }
Dan Stoza50101d02016-04-07 16:53:23 -0700410 if (result != NO_ERROR) {
411 ALOGE("getLastQueuedBuffer failed to read buffer: %d", result);
412 return result;
413 }
414 sp<Fence> fence(new Fence);
415 result = reply.read(*fence);
416 if (result != NO_ERROR) {
417 ALOGE("getLastQueuedBuffer failed to read fence: %d", result);
418 return result;
419 }
420 *outBuffer = buffer;
421 *outFence = fence;
422 return result;
423 }
Pablo Ceballosce796e72016-02-04 19:10:51 -0800424
425 virtual bool getFrameTimestamps(uint64_t frameNumber,
426 FrameTimestamps* outTimestamps) const {
427 Parcel data, reply;
428 status_t result = data.writeInterfaceToken(
429 IGraphicBufferProducer::getInterfaceDescriptor());
430 if (result != NO_ERROR) {
431 ALOGE("getFrameTimestamps failed to write token: %d", result);
432 return false;
433 }
434 result = data.writeUint64(frameNumber);
435 if (result != NO_ERROR) {
436 ALOGE("getFrameTimestamps failed to write: %d", result);
437 return false;
438 }
439 result = remote()->transact(GET_FRAME_TIMESTAMPS, data, &reply);
440 if (result != NO_ERROR) {
441 ALOGE("getFrameTimestamps failed to transact: %d", result);
442 return false;
443 }
444 bool found = false;
445 result = reply.readBool(&found);
446 if (result != NO_ERROR) {
447 ALOGE("getFrameTimestamps failed to read: %d", result);
448 return false;
449 }
450 if (found) {
451 result = reply.read(*outTimestamps);
452 if (result != NO_ERROR) {
453 ALOGE("getFrameTimestamps failed to read timestamps: %d",
454 result);
455 return false;
456 }
457 }
458 return found;
459 }
Pablo Ceballos6155b402016-06-30 17:01:49 -0700460
Pablo Ceballos8e3e92b2016-06-27 17:56:53 -0700461 virtual status_t getUniqueId(uint64_t* outId) const {
462 Parcel data, reply;
463 data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
464 status_t result = remote()->transact(GET_UNIQUE_ID, data, &reply);
465 if (result != NO_ERROR) {
466 ALOGE("getUniqueId failed to transact: %d", result);
467 }
468 status_t actualResult = NO_ERROR;
469 result = reply.readInt32(&actualResult);
470 if (result != NO_ERROR) {
471 return result;
472 }
473 result = reply.readUint64(outId);
474 if (result != NO_ERROR) {
475 return result;
476 }
477 return actualResult;
478 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800479};
480
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800481// Out-of-line virtual method definition to trigger vtable emission in this
482// translation unit (see clang warning -Wweak-vtables)
483BpGraphicBufferProducer::~BpGraphicBufferProducer() {}
484
Andy McFadden466a1922013-01-08 11:25:51 -0800485IMPLEMENT_META_INTERFACE(GraphicBufferProducer, "android.gui.IGraphicBufferProducer");
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800486
487// ----------------------------------------------------------------------
488
Andy McFadden2adaf042012-12-18 09:49:45 -0800489status_t BnGraphicBufferProducer::onTransact(
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800490 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
491{
492 switch(code) {
493 case REQUEST_BUFFER: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800494 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800495 int bufferIdx = data.readInt32();
Jamie Gennis7b305ff2011-07-19 12:08:33 -0700496 sp<GraphicBuffer> buffer;
497 int result = requestBuffer(bufferIdx, &buffer);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800498 reply->writeInt32(buffer != 0);
499 if (buffer != 0) {
500 reply->write(*buffer);
501 }
Jamie Gennis7b305ff2011-07-19 12:08:33 -0700502 reply->writeInt32(result);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800503 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800504 }
Pablo Ceballosfa455352015-08-12 17:47:47 -0700505 case SET_MAX_DEQUEUED_BUFFER_COUNT: {
506 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
507 int maxDequeuedBuffers = data.readInt32();
508 int result = setMaxDequeuedBufferCount(maxDequeuedBuffers);
509 reply->writeInt32(result);
510 return NO_ERROR;
511 }
512 case SET_ASYNC_MODE: {
513 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
514 bool async = data.readInt32();
515 int result = setAsyncMode(async);
516 reply->writeInt32(result);
517 return NO_ERROR;
518 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800519 case DEQUEUE_BUFFER: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800520 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800521 uint32_t width = data.readUint32();
522 uint32_t height = data.readUint32();
523 PixelFormat format = static_cast<PixelFormat>(data.readInt32());
524 uint32_t usage = data.readUint32();
Naveen Leekha12ba0f52015-09-21 17:28:04 -0700525 int buf = 0;
Jesse Hallf7857542012-06-14 15:26:33 -0700526 sp<Fence> fence;
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700527 int result = dequeueBuffer(&buf, &fence, width, height, format,
528 usage);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800529 reply->writeInt32(buf);
Jamie Gennis1df8c342012-12-20 14:05:45 -0800530 reply->writeInt32(fence != NULL);
531 if (fence != NULL) {
Mathias Agopianba93b3f2013-08-01 15:48:40 -0700532 reply->write(*fence);
Jesse Hallf7857542012-06-14 15:26:33 -0700533 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800534 reply->writeInt32(result);
535 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800536 }
Dan Stoza9f3053d2014-03-06 15:14:33 -0800537 case DETACH_BUFFER: {
538 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
539 int slot = data.readInt32();
540 int result = detachBuffer(slot);
541 reply->writeInt32(result);
542 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800543 }
Dan Stozad9822a32014-03-28 15:25:31 -0700544 case DETACH_NEXT_BUFFER: {
545 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
546 sp<GraphicBuffer> buffer;
547 sp<Fence> fence;
548 int32_t result = detachNextBuffer(&buffer, &fence);
549 reply->writeInt32(result);
550 if (result == NO_ERROR) {
551 reply->writeInt32(buffer != NULL);
552 if (buffer != NULL) {
553 reply->write(*buffer);
554 }
555 reply->writeInt32(fence != NULL);
556 if (fence != NULL) {
557 reply->write(*fence);
558 }
559 }
560 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800561 }
Dan Stoza9f3053d2014-03-06 15:14:33 -0800562 case ATTACH_BUFFER: {
563 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
564 sp<GraphicBuffer> buffer = new GraphicBuffer();
Pablo Ceballos70636b32016-07-06 15:24:54 -0700565 status_t result = data.read(*buffer.get());
Naveen Leekha12ba0f52015-09-21 17:28:04 -0700566 int slot = 0;
Pablo Ceballos70636b32016-07-06 15:24:54 -0700567 if (result == NO_ERROR) {
568 result = attachBuffer(&slot, buffer);
569 }
Dan Stoza9f3053d2014-03-06 15:14:33 -0800570 reply->writeInt32(slot);
571 reply->writeInt32(result);
572 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800573 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800574 case QUEUE_BUFFER: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800575 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800576 int buf = data.readInt32();
Jesse Hallc777b0b2012-06-28 12:52:05 -0700577 QueueBufferInput input(data);
Mathias Agopianf0bc2f12012-04-09 16:14:01 -0700578 QueueBufferOutput* const output =
579 reinterpret_cast<QueueBufferOutput *>(
580 reply->writeInplace(sizeof(QueueBufferOutput)));
Robert Shihd06421f2016-01-11 15:02:12 -0800581 memset(output, 0, sizeof(QueueBufferOutput));
Jesse Hallc777b0b2012-06-28 12:52:05 -0700582 status_t result = queueBuffer(buf, input, output);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800583 reply->writeInt32(result);
584 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800585 }
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800586 case CANCEL_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();
Jamie Gennis1df8c342012-12-20 14:05:45 -0800589 sp<Fence> fence = new Fence();
Pablo Ceballos70636b32016-07-06 15:24:54 -0700590 status_t result = data.read(*fence.get());
591 if (result == NO_ERROR) {
592 result = cancelBuffer(buf, fence);
593 }
Pablo Ceballos583b1b32015-09-03 18:23:52 -0700594 reply->writeInt32(result);
Jamie Gennis8ba32fa2010-12-20 11:27:26 -0800595 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800596 }
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700597 case QUERY: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800598 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Naveen Leekha12ba0f52015-09-21 17:28:04 -0700599 int value = 0;
Mathias Agopianeafabcd2011-04-20 14:20:59 -0700600 int what = data.readInt32();
601 int res = query(what, &value);
602 reply->writeInt32(value);
603 reply->writeInt32(res);
604 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800605 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700606 case CONNECT: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800607 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Dan Stozaf0eaf252014-03-21 13:05:51 -0700608 sp<IProducerListener> listener;
609 if (data.readInt32() == 1) {
610 listener = IProducerListener::asInterface(data.readStrongBinder());
611 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700612 int api = data.readInt32();
Mathias Agopian595264f2013-07-16 22:56:09 -0700613 bool producerControlledByApp = data.readInt32();
Mathias Agopian24202f52012-04-23 14:28:58 -0700614 QueueBufferOutput* const output =
615 reinterpret_cast<QueueBufferOutput *>(
616 reply->writeInplace(sizeof(QueueBufferOutput)));
Pablo Ceballos93c617f2016-03-15 18:10:49 -0700617 memset(output, 0, sizeof(QueueBufferOutput));
Dan Stozaf0eaf252014-03-21 13:05:51 -0700618 status_t res = connect(listener, api, producerControlledByApp, output);
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700619 reply->writeInt32(res);
620 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800621 }
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700622 case DISCONNECT: {
Andy McFadden2adaf042012-12-18 09:49:45 -0800623 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700624 int api = data.readInt32();
Robert Carr97b9c862016-09-08 13:54:35 -0700625 DisconnectMode mode = static_cast<DisconnectMode>(data.readInt32());
626 status_t res = disconnect(api, mode);
Jamie Gennisfe0a87b2011-07-13 19:12:20 -0700627 reply->writeInt32(res);
628 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800629 }
Jesse Hall399184a2014-03-03 15:42:54 -0800630 case SET_SIDEBAND_STREAM: {
631 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
632 sp<NativeHandle> stream;
633 if (data.readInt32()) {
Wonsik Kim0ec54e12014-03-21 10:46:24 +0900634 stream = NativeHandle::create(data.readNativeHandle(), true);
Jesse Hall399184a2014-03-03 15:42:54 -0800635 }
636 status_t result = setSidebandStream(stream);
637 reply->writeInt32(result);
638 return NO_ERROR;
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800639 }
Dan Stoza9de72932015-04-16 17:28:43 -0700640 case ALLOCATE_BUFFERS: {
Dan Stoza29a3e902014-06-20 13:13:57 -0700641 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
Dan Stoza3be1c6b2014-11-18 10:24:03 -0800642 uint32_t width = data.readUint32();
643 uint32_t height = data.readUint32();
644 PixelFormat format = static_cast<PixelFormat>(data.readInt32());
645 uint32_t usage = data.readUint32();
Pablo Ceballos567dbbb2015-08-26 18:59:08 -0700646 allocateBuffers(width, height, format, usage);
Dan Stoza29a3e902014-06-20 13:13:57 -0700647 return NO_ERROR;
Dan Stoza9de72932015-04-16 17:28:43 -0700648 }
649 case ALLOW_ALLOCATION: {
650 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
651 bool allow = static_cast<bool>(data.readInt32());
652 status_t result = allowAllocation(allow);
653 reply->writeInt32(result);
654 return NO_ERROR;
655 }
Dan Stoza812ed062015-06-02 15:45:22 -0700656 case SET_GENERATION_NUMBER: {
657 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
658 uint32_t generationNumber = data.readUint32();
659 status_t result = setGenerationNumber(generationNumber);
660 reply->writeInt32(result);
661 return NO_ERROR;
662 }
Dan Stozac6f30bd2015-06-08 09:32:50 -0700663 case GET_CONSUMER_NAME: {
664 CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
665 reply->writeString8(getConsumerName());
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