blob: 260288447ae56231c995051a0358f5c18068f10b [file] [log] [blame]
Mathias Agopiana4e19522013-07-31 20:09:53 -07001/*
2 * Copyright (C) 2013 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
Mathias Agopiana4e19522013-07-31 20:09:53 -070017#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>
Mathias Agopiana4e19522013-07-31 20:09:53 -070022
23#include <binder/Parcel.h>
24#include <binder/IInterface.h>
25
26#include <gui/IConsumerListener.h>
27#include <gui/IGraphicBufferConsumer.h>
28
29#include <ui/GraphicBuffer.h>
30#include <ui/Fence.h>
31
32#include <system/window.h>
33
34namespace android {
35// ---------------------------------------------------------------------------
36
37IGraphicBufferConsumer::BufferItem::BufferItem() :
38 mTransform(0),
39 mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
40 mTimestamp(0),
Andy McFadden3c256212013-08-16 14:55:39 -070041 mIsAutoTimestamp(false),
Mathias Agopiana4e19522013-07-31 20:09:53 -070042 mFrameNumber(0),
43 mBuf(INVALID_BUFFER_SLOT),
44 mIsDroppable(false),
Mathias Agopianc1c05de2013-09-17 23:45:22 -070045 mAcquireCalled(false),
46 mTransformToDisplayInverse(false) {
Mathias Agopiana4e19522013-07-31 20:09:53 -070047 mCrop.makeInvalid();
48}
49
50size_t IGraphicBufferConsumer::BufferItem::getPodSize() const {
51 size_t c = sizeof(mCrop) +
52 sizeof(mTransform) +
53 sizeof(mScalingMode) +
54 sizeof(mTimestamp) +
Andy McFadden3c256212013-08-16 14:55:39 -070055 sizeof(mIsAutoTimestamp) +
Mathias Agopiana4e19522013-07-31 20:09:53 -070056 sizeof(mFrameNumber) +
57 sizeof(mBuf) +
58 sizeof(mIsDroppable) +
Mathias Agopianc1c05de2013-09-17 23:45:22 -070059 sizeof(mAcquireCalled) +
60 sizeof(mTransformToDisplayInverse);
Mathias Agopiana4e19522013-07-31 20:09:53 -070061 return c;
62}
63
64size_t IGraphicBufferConsumer::BufferItem::getFlattenedSize() const {
65 size_t c = 0;
66 if (mGraphicBuffer != 0) {
67 c += mGraphicBuffer->getFlattenedSize();
Dan Stoza1a0b8612014-03-20 15:36:31 -070068 c = FlattenableUtils::align<4>(c);
Mathias Agopiana4e19522013-07-31 20:09:53 -070069 }
70 if (mFence != 0) {
71 c += mFence->getFlattenedSize();
Dan Stoza1a0b8612014-03-20 15:36:31 -070072 c = FlattenableUtils::align<4>(c);
Mathias Agopiana4e19522013-07-31 20:09:53 -070073 }
74 return sizeof(int32_t) + c + getPodSize();
75}
76
77size_t IGraphicBufferConsumer::BufferItem::getFdCount() const {
78 size_t c = 0;
79 if (mGraphicBuffer != 0) {
80 c += mGraphicBuffer->getFdCount();
81 }
82 if (mFence != 0) {
83 c += mFence->getFdCount();
84 }
85 return c;
86}
87
Dan Stoza1a0b8612014-03-20 15:36:31 -070088static void writeBoolAsInt(void*& buffer, size_t& size, bool b) {
89 FlattenableUtils::write(buffer, size, static_cast<int32_t>(b));
90}
91
92static bool readBoolFromInt(void const*& buffer, size_t& size) {
93 int32_t i;
94 FlattenableUtils::read(buffer, size, i);
95 return static_cast<bool>(i);
96}
97
Mathias Agopiana4e19522013-07-31 20:09:53 -070098status_t IGraphicBufferConsumer::BufferItem::flatten(
99 void*& buffer, size_t& size, int*& fds, size_t& count) const {
100
101 // make sure we have enough space
Dan Stoza1a0b8612014-03-20 15:36:31 -0700102 if (size < BufferItem::getFlattenedSize()) {
Mathias Agopiana4e19522013-07-31 20:09:53 -0700103 return NO_MEMORY;
104 }
105
106 // content flags are stored first
107 uint32_t& flags = *static_cast<uint32_t*>(buffer);
108
109 // advance the pointer
110 FlattenableUtils::advance(buffer, size, sizeof(uint32_t));
111
112 flags = 0;
113 if (mGraphicBuffer != 0) {
114 status_t err = mGraphicBuffer->flatten(buffer, size, fds, count);
115 if (err) return err;
116 size -= FlattenableUtils::align<4>(buffer);
117 flags |= 1;
118 }
119 if (mFence != 0) {
120 status_t err = mFence->flatten(buffer, size, fds, count);
121 if (err) return err;
122 size -= FlattenableUtils::align<4>(buffer);
123 flags |= 2;
124 }
125
126 // check we have enough space (in case flattening the fence/graphicbuffer lied to us)
127 if (size < getPodSize()) {
128 return NO_MEMORY;
129 }
130
131 FlattenableUtils::write(buffer, size, mCrop);
132 FlattenableUtils::write(buffer, size, mTransform);
133 FlattenableUtils::write(buffer, size, mScalingMode);
134 FlattenableUtils::write(buffer, size, mTimestamp);
Dan Stoza1a0b8612014-03-20 15:36:31 -0700135 writeBoolAsInt(buffer, size, mIsAutoTimestamp);
Mathias Agopiana4e19522013-07-31 20:09:53 -0700136 FlattenableUtils::write(buffer, size, mFrameNumber);
137 FlattenableUtils::write(buffer, size, mBuf);
Dan Stoza1a0b8612014-03-20 15:36:31 -0700138 writeBoolAsInt(buffer, size, mIsDroppable);
139 writeBoolAsInt(buffer, size, mAcquireCalled);
140 writeBoolAsInt(buffer, size, mTransformToDisplayInverse);
Mathias Agopiana4e19522013-07-31 20:09:53 -0700141
142 return NO_ERROR;
143}
144
145status_t IGraphicBufferConsumer::BufferItem::unflatten(
146 void const*& buffer, size_t& size, int const*& fds, size_t& count) {
147
148 if (size < sizeof(uint32_t))
149 return NO_MEMORY;
150
151 uint32_t flags = 0;
152 FlattenableUtils::read(buffer, size, flags);
153
154 if (flags & 1) {
155 mGraphicBuffer = new GraphicBuffer();
156 status_t err = mGraphicBuffer->unflatten(buffer, size, fds, count);
157 if (err) return err;
158 size -= FlattenableUtils::align<4>(buffer);
159 }
160
161 if (flags & 2) {
162 mFence = new Fence();
163 status_t err = mFence->unflatten(buffer, size, fds, count);
164 if (err) return err;
165 size -= FlattenableUtils::align<4>(buffer);
166 }
167
168 // check we have enough space
169 if (size < getPodSize()) {
170 return NO_MEMORY;
171 }
172
173 FlattenableUtils::read(buffer, size, mCrop);
174 FlattenableUtils::read(buffer, size, mTransform);
175 FlattenableUtils::read(buffer, size, mScalingMode);
176 FlattenableUtils::read(buffer, size, mTimestamp);
Dan Stoza1a0b8612014-03-20 15:36:31 -0700177 mIsAutoTimestamp = readBoolFromInt(buffer, size);
Mathias Agopiana4e19522013-07-31 20:09:53 -0700178 FlattenableUtils::read(buffer, size, mFrameNumber);
179 FlattenableUtils::read(buffer, size, mBuf);
Dan Stoza1a0b8612014-03-20 15:36:31 -0700180 mIsDroppable = readBoolFromInt(buffer, size);
181 mAcquireCalled = readBoolFromInt(buffer, size);
182 mTransformToDisplayInverse = readBoolFromInt(buffer, size);
Mathias Agopiana4e19522013-07-31 20:09:53 -0700183
184 return NO_ERROR;
185}
186
187// ---------------------------------------------------------------------------
188
189enum {
190 ACQUIRE_BUFFER = IBinder::FIRST_CALL_TRANSACTION,
Dan Stoza9f3053d2014-03-06 15:14:33 -0800191 DETACH_BUFFER,
192 ATTACH_BUFFER,
Mathias Agopiana4e19522013-07-31 20:09:53 -0700193 RELEASE_BUFFER,
194 CONSUMER_CONNECT,
195 CONSUMER_DISCONNECT,
196 GET_RELEASED_BUFFERS,
197 SET_DEFAULT_BUFFER_SIZE,
198 SET_DEFAULT_MAX_BUFFER_COUNT,
199 DISABLE_ASYNC_BUFFER,
200 SET_MAX_ACQUIRED_BUFFER_COUNT,
201 SET_CONSUMER_NAME,
202 SET_DEFAULT_BUFFER_FORMAT,
203 SET_CONSUMER_USAGE_BITS,
Mathias Agopiandb89edc2013-08-02 01:40:18 -0700204 SET_TRANSFORM_HINT,
Jesse Hall399184a2014-03-03 15:42:54 -0800205 GET_SIDEBAND_STREAM,
Mathias Agopiandb89edc2013-08-02 01:40:18 -0700206 DUMP,
Mathias Agopiana4e19522013-07-31 20:09:53 -0700207};
208
209
210class BpGraphicBufferConsumer : public BpInterface<IGraphicBufferConsumer>
211{
212public:
213 BpGraphicBufferConsumer(const sp<IBinder>& impl)
214 : BpInterface<IGraphicBufferConsumer>(impl)
215 {
216 }
217
Dan Stozadd883c02014-11-18 10:24:03 -0800218 virtual ~BpGraphicBufferConsumer();
219
Mathias Agopiana4e19522013-07-31 20:09:53 -0700220 virtual status_t acquireBuffer(BufferItem *buffer, nsecs_t presentWhen) {
221 Parcel data, reply;
222 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
223 data.writeInt64(presentWhen);
224 status_t result = remote()->transact(ACQUIRE_BUFFER, data, &reply);
225 if (result != NO_ERROR) {
226 return result;
227 }
228 result = reply.read(*buffer);
229 if (result != NO_ERROR) {
230 return result;
231 }
232 return reply.readInt32();
233 }
234
Dan Stoza9f3053d2014-03-06 15:14:33 -0800235 virtual status_t detachBuffer(int slot) {
236 Parcel data, reply;
237 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
238 data.writeInt32(slot);
239 status_t result = remote()->transact(DETACH_BUFFER, data, &reply);
240 if (result != NO_ERROR) {
241 return result;
242 }
243 result = reply.readInt32();
244 return result;
245 }
246
247 virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer) {
248 Parcel data, reply;
249 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
250 data.write(*buffer.get());
251 status_t result = remote()->transact(ATTACH_BUFFER, data, &reply);
252 if (result != NO_ERROR) {
253 return result;
254 }
255 *slot = reply.readInt32();
256 result = reply.readInt32();
257 return result;
258 }
259
Mathias Agopiana4e19522013-07-31 20:09:53 -0700260 virtual status_t releaseBuffer(int buf, uint64_t frameNumber,
Igor Murashkin7d2d1602013-11-12 18:02:20 -0800261 EGLDisplay display __attribute__((unused)), EGLSyncKHR fence __attribute__((unused)),
Mathias Agopiana4e19522013-07-31 20:09:53 -0700262 const sp<Fence>& releaseFence) {
263 Parcel data, reply;
264 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
265 data.writeInt32(buf);
Dan Stozadd883c02014-11-18 10:24:03 -0800266 data.writeInt64(static_cast<int64_t>(frameNumber));
Mathias Agopiana4e19522013-07-31 20:09:53 -0700267 data.write(*releaseFence);
268 status_t result = remote()->transact(RELEASE_BUFFER, data, &reply);
269 if (result != NO_ERROR) {
270 return result;
271 }
272 return reply.readInt32();
273 }
274
275 virtual status_t consumerConnect(const sp<IConsumerListener>& consumer, bool controlledByApp) {
276 Parcel data, reply;
277 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
Marco Nelissen097ca272014-11-14 08:01:01 -0800278 data.writeStrongBinder(IInterface::asBinder(consumer));
Mathias Agopiana4e19522013-07-31 20:09:53 -0700279 data.writeInt32(controlledByApp);
280 status_t result = remote()->transact(CONSUMER_CONNECT, data, &reply);
281 if (result != NO_ERROR) {
282 return result;
283 }
284 return reply.readInt32();
285 }
286
287 virtual status_t consumerDisconnect() {
288 Parcel data, reply;
289 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
290 status_t result = remote()->transact(CONSUMER_DISCONNECT, data, &reply);
291 if (result != NO_ERROR) {
292 return result;
293 }
294 return reply.readInt32();
295 }
296
Dan Stozafebd4f42014-04-09 16:14:51 -0700297 virtual status_t getReleasedBuffers(uint64_t* slotMask) {
Mathias Agopiana4e19522013-07-31 20:09:53 -0700298 Parcel data, reply;
Dan Stozafebd4f42014-04-09 16:14:51 -0700299 if (slotMask == NULL) {
300 ALOGE("getReleasedBuffers: slotMask must not be NULL");
301 return BAD_VALUE;
302 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700303 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
304 status_t result = remote()->transact(GET_RELEASED_BUFFERS, data, &reply);
305 if (result != NO_ERROR) {
306 return result;
307 }
Dan Stozadd883c02014-11-18 10:24:03 -0800308 *slotMask = static_cast<uint64_t>(reply.readInt64());
Mathias Agopiana4e19522013-07-31 20:09:53 -0700309 return reply.readInt32();
310 }
311
Dan Stozadd883c02014-11-18 10:24:03 -0800312 virtual status_t setDefaultBufferSize(uint32_t width, uint32_t height) {
Mathias Agopiana4e19522013-07-31 20:09:53 -0700313 Parcel data, reply;
314 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
Dan Stozadd883c02014-11-18 10:24:03 -0800315 data.writeUint32(width);
316 data.writeUint32(height);
Mathias Agopiana4e19522013-07-31 20:09:53 -0700317 status_t result = remote()->transact(SET_DEFAULT_BUFFER_SIZE, data, &reply);
318 if (result != NO_ERROR) {
319 return result;
320 }
321 return reply.readInt32();
322 }
323
324 virtual status_t setDefaultMaxBufferCount(int bufferCount) {
325 Parcel data, reply;
326 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
327 data.writeInt32(bufferCount);
328 status_t result = remote()->transact(SET_DEFAULT_MAX_BUFFER_COUNT, data, &reply);
329 if (result != NO_ERROR) {
330 return result;
331 }
332 return reply.readInt32();
333 }
334
335 virtual status_t disableAsyncBuffer() {
336 Parcel data, reply;
337 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
338 status_t result = remote()->transact(DISABLE_ASYNC_BUFFER, data, &reply);
339 if (result != NO_ERROR) {
340 return result;
341 }
342 return reply.readInt32();
343 }
344
345 virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers) {
346 Parcel data, reply;
347 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
348 data.writeInt32(maxAcquiredBuffers);
349 status_t result = remote()->transact(SET_MAX_ACQUIRED_BUFFER_COUNT, data, &reply);
350 if (result != NO_ERROR) {
351 return result;
352 }
353 return reply.readInt32();
354 }
355
356 virtual void setConsumerName(const String8& name) {
357 Parcel data, reply;
358 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
359 data.writeString8(name);
360 remote()->transact(SET_CONSUMER_NAME, data, &reply);
361 }
362
Dan Stozadd883c02014-11-18 10:24:03 -0800363 virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat) {
Mathias Agopiana4e19522013-07-31 20:09:53 -0700364 Parcel data, reply;
365 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
Dan Stozadd883c02014-11-18 10:24:03 -0800366 data.writeInt32(static_cast<int32_t>(defaultFormat));
Mathias Agopiana4e19522013-07-31 20:09:53 -0700367 status_t result = remote()->transact(SET_DEFAULT_BUFFER_FORMAT, data, &reply);
368 if (result != NO_ERROR) {
369 return result;
370 }
371 return reply.readInt32();
372 }
373
374 virtual status_t setConsumerUsageBits(uint32_t usage) {
375 Parcel data, reply;
376 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
Dan Stozadd883c02014-11-18 10:24:03 -0800377 data.writeUint32(usage);
Mathias Agopiana4e19522013-07-31 20:09:53 -0700378 status_t result = remote()->transact(SET_CONSUMER_USAGE_BITS, data, &reply);
379 if (result != NO_ERROR) {
380 return result;
381 }
382 return reply.readInt32();
383 }
384
385 virtual status_t setTransformHint(uint32_t hint) {
386 Parcel data, reply;
387 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
Dan Stozadd883c02014-11-18 10:24:03 -0800388 data.writeUint32(hint);
Mathias Agopiana4e19522013-07-31 20:09:53 -0700389 status_t result = remote()->transact(SET_TRANSFORM_HINT, data, &reply);
390 if (result != NO_ERROR) {
391 return result;
392 }
393 return reply.readInt32();
394 }
Mathias Agopiandb89edc2013-08-02 01:40:18 -0700395
Jesse Hall399184a2014-03-03 15:42:54 -0800396 virtual sp<NativeHandle> getSidebandStream() const {
397 Parcel data, reply;
398 status_t err;
399 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
400 if ((err = remote()->transact(GET_SIDEBAND_STREAM, data, &reply)) != NO_ERROR) {
401 return NULL;
402 }
403 sp<NativeHandle> stream;
404 if (reply.readInt32()) {
Wonsik Kim0ec54e12014-03-21 10:46:24 +0900405 stream = NativeHandle::create(reply.readNativeHandle(), true);
Jesse Hall399184a2014-03-03 15:42:54 -0800406 }
407 return stream;
408 }
409
Mathias Agopiandb89edc2013-08-02 01:40:18 -0700410 virtual void dump(String8& result, const char* prefix) const {
411 Parcel data, reply;
412 data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
413 data.writeString8(result);
414 data.writeString8(String8(prefix ? prefix : ""));
415 remote()->transact(DUMP, data, &reply);
416 reply.readString8();
417 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700418};
419
Dan Stozadd883c02014-11-18 10:24:03 -0800420// Out-of-line virtual method definition to trigger vtable emission in this
421// translation unit (see clang warning -Wweak-vtables)
422BpGraphicBufferConsumer::~BpGraphicBufferConsumer() {}
423
Mathias Agopiana4e19522013-07-31 20:09:53 -0700424IMPLEMENT_META_INTERFACE(GraphicBufferConsumer, "android.gui.IGraphicBufferConsumer");
425
426// ----------------------------------------------------------------------
427
428status_t BnGraphicBufferConsumer::onTransact(
429 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
430{
431 switch(code) {
432 case ACQUIRE_BUFFER: {
433 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
434 BufferItem item;
435 int64_t presentWhen = data.readInt64();
436 status_t result = acquireBuffer(&item, presentWhen);
437 status_t err = reply->write(item);
438 if (err) return err;
439 reply->writeInt32(result);
440 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800441 }
Dan Stoza9f3053d2014-03-06 15:14:33 -0800442 case DETACH_BUFFER: {
443 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
444 int slot = data.readInt32();
445 int result = detachBuffer(slot);
446 reply->writeInt32(result);
447 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800448 }
Dan Stoza9f3053d2014-03-06 15:14:33 -0800449 case ATTACH_BUFFER: {
450 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
451 sp<GraphicBuffer> buffer = new GraphicBuffer();
452 data.read(*buffer.get());
453 int slot;
454 int result = attachBuffer(&slot, buffer);
455 reply->writeInt32(slot);
456 reply->writeInt32(result);
457 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800458 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700459 case RELEASE_BUFFER: {
460 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
461 int buf = data.readInt32();
Dan Stozadd883c02014-11-18 10:24:03 -0800462 uint64_t frameNumber = static_cast<uint64_t>(data.readInt64());
Mathias Agopiana4e19522013-07-31 20:09:53 -0700463 sp<Fence> releaseFence = new Fence();
464 status_t err = data.read(*releaseFence);
465 if (err) return err;
466 status_t result = releaseBuffer(buf, frameNumber,
467 EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, releaseFence);
468 reply->writeInt32(result);
469 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800470 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700471 case CONSUMER_CONNECT: {
472 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
473 sp<IConsumerListener> consumer = IConsumerListener::asInterface( data.readStrongBinder() );
474 bool controlledByApp = data.readInt32();
475 status_t result = consumerConnect(consumer, controlledByApp);
476 reply->writeInt32(result);
477 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800478 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700479 case CONSUMER_DISCONNECT: {
480 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
481 status_t result = consumerDisconnect();
482 reply->writeInt32(result);
483 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800484 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700485 case GET_RELEASED_BUFFERS: {
486 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
Dan Stozafebd4f42014-04-09 16:14:51 -0700487 uint64_t slotMask;
Mathias Agopiana4e19522013-07-31 20:09:53 -0700488 status_t result = getReleasedBuffers(&slotMask);
Dan Stozadd883c02014-11-18 10:24:03 -0800489 reply->writeInt64(static_cast<int64_t>(slotMask));
Mathias Agopiana4e19522013-07-31 20:09:53 -0700490 reply->writeInt32(result);
491 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800492 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700493 case SET_DEFAULT_BUFFER_SIZE: {
494 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
Dan Stozadd883c02014-11-18 10:24:03 -0800495 uint32_t width = data.readUint32();
496 uint32_t height = data.readUint32();
497 status_t result = setDefaultBufferSize(width, height);
Mathias Agopiana4e19522013-07-31 20:09:53 -0700498 reply->writeInt32(result);
499 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800500 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700501 case SET_DEFAULT_MAX_BUFFER_COUNT: {
502 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
Dan Stozadd883c02014-11-18 10:24:03 -0800503 int bufferCount = data.readInt32();
Mathias Agopiana4e19522013-07-31 20:09:53 -0700504 status_t result = setDefaultMaxBufferCount(bufferCount);
505 reply->writeInt32(result);
506 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800507 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700508 case DISABLE_ASYNC_BUFFER: {
509 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
510 status_t result = disableAsyncBuffer();
511 reply->writeInt32(result);
512 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800513 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700514 case SET_MAX_ACQUIRED_BUFFER_COUNT: {
515 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
Dan Stozadd883c02014-11-18 10:24:03 -0800516 int maxAcquiredBuffers = data.readInt32();
Mathias Agopiana4e19522013-07-31 20:09:53 -0700517 status_t result = setMaxAcquiredBufferCount(maxAcquiredBuffers);
518 reply->writeInt32(result);
519 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800520 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700521 case SET_CONSUMER_NAME: {
522 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
523 setConsumerName( data.readString8() );
524 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800525 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700526 case SET_DEFAULT_BUFFER_FORMAT: {
527 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
Dan Stozadd883c02014-11-18 10:24:03 -0800528 PixelFormat defaultFormat = static_cast<PixelFormat>(data.readInt32());
Mathias Agopiana4e19522013-07-31 20:09:53 -0700529 status_t result = setDefaultBufferFormat(defaultFormat);
530 reply->writeInt32(result);
531 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800532 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700533 case SET_CONSUMER_USAGE_BITS: {
534 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
Dan Stozadd883c02014-11-18 10:24:03 -0800535 uint32_t usage = data.readUint32();
Mathias Agopiana4e19522013-07-31 20:09:53 -0700536 status_t result = setConsumerUsageBits(usage);
537 reply->writeInt32(result);
538 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800539 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700540 case SET_TRANSFORM_HINT: {
541 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
Dan Stozadd883c02014-11-18 10:24:03 -0800542 uint32_t hint = data.readUint32();
Mathias Agopiana4e19522013-07-31 20:09:53 -0700543 status_t result = setTransformHint(hint);
544 reply->writeInt32(result);
545 return NO_ERROR;
Dan Stozadd883c02014-11-18 10:24:03 -0800546 }
Mathias Agopiandb89edc2013-08-02 01:40:18 -0700547 case DUMP: {
548 CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
549 String8 result = data.readString8();
550 String8 prefix = data.readString8();
551 static_cast<IGraphicBufferConsumer*>(this)->dump(result, prefix);
552 reply->writeString8(result);
553 return NO_ERROR;
554 }
Mathias Agopiana4e19522013-07-31 20:09:53 -0700555 }
556 return BBinder::onTransact(code, data, reply, flags);
557}
558
559}; // namespace android