| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 1 | /* | 
|  | 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 Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 17 | #include <stdint.h> | 
|  | 18 | #include <sys/types.h> | 
|  | 19 |  | 
|  | 20 | #include <utils/Errors.h> | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 21 | #include <utils/NativeHandle.h> | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 22 |  | 
|  | 23 | #include <binder/Parcel.h> | 
|  | 24 | #include <binder/IInterface.h> | 
|  | 25 |  | 
| Dan Stoza | de7100a | 2015-03-11 16:38:47 -0700 | [diff] [blame] | 26 | #include <gui/BufferItem.h> | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 27 | #include <gui/IConsumerListener.h> | 
|  | 28 | #include <gui/IGraphicBufferConsumer.h> | 
|  | 29 |  | 
|  | 30 | #include <ui/GraphicBuffer.h> | 
|  | 31 | #include <ui/Fence.h> | 
|  | 32 |  | 
|  | 33 | #include <system/window.h> | 
|  | 34 |  | 
|  | 35 | namespace android { | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 36 |  | 
|  | 37 | enum { | 
|  | 38 | ACQUIRE_BUFFER = IBinder::FIRST_CALL_TRANSACTION, | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 39 | DETACH_BUFFER, | 
|  | 40 | ATTACH_BUFFER, | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 41 | RELEASE_BUFFER, | 
|  | 42 | CONSUMER_CONNECT, | 
|  | 43 | CONSUMER_DISCONNECT, | 
|  | 44 | GET_RELEASED_BUFFERS, | 
|  | 45 | SET_DEFAULT_BUFFER_SIZE, | 
| Pablo Ceballos | 19e3e06 | 2015-08-19 16:16:06 -0700 | [diff] [blame] | 46 | SET_MAX_BUFFER_COUNT, | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 47 | SET_MAX_ACQUIRED_BUFFER_COUNT, | 
|  | 48 | SET_CONSUMER_NAME, | 
|  | 49 | SET_DEFAULT_BUFFER_FORMAT, | 
| Eino-Ville Talvala | 5b75a51 | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 50 | SET_DEFAULT_BUFFER_DATA_SPACE, | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 51 | SET_CONSUMER_USAGE_BITS, | 
| Mathias Agopian | db89edc | 2013-08-02 01:40:18 -0700 | [diff] [blame] | 52 | SET_TRANSFORM_HINT, | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 53 | GET_SIDEBAND_STREAM, | 
| Mathias Agopian | db89edc | 2013-08-02 01:40:18 -0700 | [diff] [blame] | 54 | DUMP, | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 55 | }; | 
|  | 56 |  | 
|  | 57 |  | 
|  | 58 | class BpGraphicBufferConsumer : public BpInterface<IGraphicBufferConsumer> | 
|  | 59 | { | 
|  | 60 | public: | 
|  | 61 | BpGraphicBufferConsumer(const sp<IBinder>& impl) | 
|  | 62 | : BpInterface<IGraphicBufferConsumer>(impl) | 
|  | 63 | { | 
|  | 64 | } | 
|  | 65 |  | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 66 | virtual ~BpGraphicBufferConsumer(); | 
|  | 67 |  | 
| Dan Stoza | a4650a5 | 2015-05-12 12:56:16 -0700 | [diff] [blame] | 68 | virtual status_t acquireBuffer(BufferItem *buffer, nsecs_t presentWhen, | 
|  | 69 | uint64_t maxFrameNumber) { | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 70 | Parcel data, reply; | 
|  | 71 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
|  | 72 | data.writeInt64(presentWhen); | 
| Dan Stoza | a4650a5 | 2015-05-12 12:56:16 -0700 | [diff] [blame] | 73 | data.writeUint64(maxFrameNumber); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 74 | status_t result = remote()->transact(ACQUIRE_BUFFER, data, &reply); | 
|  | 75 | if (result != NO_ERROR) { | 
|  | 76 | return result; | 
|  | 77 | } | 
|  | 78 | result = reply.read(*buffer); | 
|  | 79 | if (result != NO_ERROR) { | 
|  | 80 | return result; | 
|  | 81 | } | 
|  | 82 | return reply.readInt32(); | 
|  | 83 | } | 
|  | 84 |  | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 85 | virtual status_t detachBuffer(int slot) { | 
|  | 86 | Parcel data, reply; | 
|  | 87 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
|  | 88 | data.writeInt32(slot); | 
|  | 89 | status_t result = remote()->transact(DETACH_BUFFER, data, &reply); | 
|  | 90 | if (result != NO_ERROR) { | 
|  | 91 | return result; | 
|  | 92 | } | 
|  | 93 | result = reply.readInt32(); | 
|  | 94 | return result; | 
|  | 95 | } | 
|  | 96 |  | 
|  | 97 | virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer) { | 
|  | 98 | Parcel data, reply; | 
|  | 99 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
|  | 100 | data.write(*buffer.get()); | 
|  | 101 | status_t result = remote()->transact(ATTACH_BUFFER, data, &reply); | 
|  | 102 | if (result != NO_ERROR) { | 
|  | 103 | return result; | 
|  | 104 | } | 
|  | 105 | *slot = reply.readInt32(); | 
|  | 106 | result = reply.readInt32(); | 
|  | 107 | return result; | 
|  | 108 | } | 
|  | 109 |  | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 110 | virtual status_t releaseBuffer(int buf, uint64_t frameNumber, | 
| Igor Murashkin | 7d2d160 | 2013-11-12 18:02:20 -0800 | [diff] [blame] | 111 | EGLDisplay display __attribute__((unused)), EGLSyncKHR fence __attribute__((unused)), | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 112 | const sp<Fence>& releaseFence) { | 
|  | 113 | Parcel data, reply; | 
|  | 114 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
|  | 115 | data.writeInt32(buf); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 116 | data.writeInt64(static_cast<int64_t>(frameNumber)); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 117 | data.write(*releaseFence); | 
|  | 118 | status_t result = remote()->transact(RELEASE_BUFFER, data, &reply); | 
|  | 119 | if (result != NO_ERROR) { | 
|  | 120 | return result; | 
|  | 121 | } | 
|  | 122 | return reply.readInt32(); | 
|  | 123 | } | 
|  | 124 |  | 
|  | 125 | virtual status_t consumerConnect(const sp<IConsumerListener>& consumer, bool controlledByApp) { | 
|  | 126 | Parcel data, reply; | 
|  | 127 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
| Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 128 | data.writeStrongBinder(IInterface::asBinder(consumer)); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 129 | data.writeInt32(controlledByApp); | 
|  | 130 | status_t result = remote()->transact(CONSUMER_CONNECT, data, &reply); | 
|  | 131 | if (result != NO_ERROR) { | 
|  | 132 | return result; | 
|  | 133 | } | 
|  | 134 | return reply.readInt32(); | 
|  | 135 | } | 
|  | 136 |  | 
|  | 137 | virtual status_t consumerDisconnect() { | 
|  | 138 | Parcel data, reply; | 
|  | 139 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
|  | 140 | status_t result = remote()->transact(CONSUMER_DISCONNECT, data, &reply); | 
|  | 141 | if (result != NO_ERROR) { | 
|  | 142 | return result; | 
|  | 143 | } | 
|  | 144 | return reply.readInt32(); | 
|  | 145 | } | 
|  | 146 |  | 
| Dan Stoza | febd4f4 | 2014-04-09 16:14:51 -0700 | [diff] [blame] | 147 | virtual status_t getReleasedBuffers(uint64_t* slotMask) { | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 148 | Parcel data, reply; | 
| Dan Stoza | febd4f4 | 2014-04-09 16:14:51 -0700 | [diff] [blame] | 149 | if (slotMask == NULL) { | 
|  | 150 | ALOGE("getReleasedBuffers: slotMask must not be NULL"); | 
|  | 151 | return BAD_VALUE; | 
|  | 152 | } | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 153 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
|  | 154 | status_t result = remote()->transact(GET_RELEASED_BUFFERS, data, &reply); | 
|  | 155 | if (result != NO_ERROR) { | 
|  | 156 | return result; | 
|  | 157 | } | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 158 | *slotMask = static_cast<uint64_t>(reply.readInt64()); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 159 | return reply.readInt32(); | 
|  | 160 | } | 
|  | 161 |  | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 162 | virtual status_t setDefaultBufferSize(uint32_t width, uint32_t height) { | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 163 | Parcel data, reply; | 
|  | 164 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 165 | data.writeUint32(width); | 
|  | 166 | data.writeUint32(height); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 167 | status_t result = remote()->transact(SET_DEFAULT_BUFFER_SIZE, data, &reply); | 
|  | 168 | if (result != NO_ERROR) { | 
|  | 169 | return result; | 
|  | 170 | } | 
|  | 171 | return reply.readInt32(); | 
|  | 172 | } | 
|  | 173 |  | 
| Pablo Ceballos | 19e3e06 | 2015-08-19 16:16:06 -0700 | [diff] [blame] | 174 | virtual status_t setMaxBufferCount(int bufferCount) { | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 175 | Parcel data, reply; | 
|  | 176 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
|  | 177 | data.writeInt32(bufferCount); | 
| Pablo Ceballos | 19e3e06 | 2015-08-19 16:16:06 -0700 | [diff] [blame] | 178 | status_t result = remote()->transact(SET_MAX_BUFFER_COUNT, data, &reply); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 179 | if (result != NO_ERROR) { | 
|  | 180 | return result; | 
|  | 181 | } | 
|  | 182 | return reply.readInt32(); | 
|  | 183 | } | 
|  | 184 |  | 
|  | 185 | virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers) { | 
|  | 186 | Parcel data, reply; | 
|  | 187 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
|  | 188 | data.writeInt32(maxAcquiredBuffers); | 
|  | 189 | status_t result = remote()->transact(SET_MAX_ACQUIRED_BUFFER_COUNT, data, &reply); | 
|  | 190 | if (result != NO_ERROR) { | 
|  | 191 | return result; | 
|  | 192 | } | 
|  | 193 | return reply.readInt32(); | 
|  | 194 | } | 
|  | 195 |  | 
|  | 196 | virtual void setConsumerName(const String8& name) { | 
|  | 197 | Parcel data, reply; | 
|  | 198 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
|  | 199 | data.writeString8(name); | 
|  | 200 | remote()->transact(SET_CONSUMER_NAME, data, &reply); | 
|  | 201 | } | 
|  | 202 |  | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 203 | virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat) { | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 204 | Parcel data, reply; | 
|  | 205 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 206 | data.writeInt32(static_cast<int32_t>(defaultFormat)); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 207 | status_t result = remote()->transact(SET_DEFAULT_BUFFER_FORMAT, data, &reply); | 
|  | 208 | if (result != NO_ERROR) { | 
|  | 209 | return result; | 
|  | 210 | } | 
|  | 211 | return reply.readInt32(); | 
|  | 212 | } | 
|  | 213 |  | 
| Eino-Ville Talvala | 5b75a51 | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 214 | virtual status_t setDefaultBufferDataSpace( | 
|  | 215 | android_dataspace defaultDataSpace) { | 
|  | 216 | Parcel data, reply; | 
|  | 217 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
|  | 218 | data.writeInt32(static_cast<int32_t>(defaultDataSpace)); | 
|  | 219 | status_t result = remote()->transact(SET_DEFAULT_BUFFER_DATA_SPACE, | 
|  | 220 | data, &reply); | 
|  | 221 | if (result != NO_ERROR) { | 
|  | 222 | return result; | 
|  | 223 | } | 
|  | 224 | return reply.readInt32(); | 
|  | 225 | } | 
|  | 226 |  | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 227 | virtual status_t setConsumerUsageBits(uint32_t usage) { | 
|  | 228 | Parcel data, reply; | 
|  | 229 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 230 | data.writeUint32(usage); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 231 | status_t result = remote()->transact(SET_CONSUMER_USAGE_BITS, data, &reply); | 
|  | 232 | if (result != NO_ERROR) { | 
|  | 233 | return result; | 
|  | 234 | } | 
|  | 235 | return reply.readInt32(); | 
|  | 236 | } | 
|  | 237 |  | 
|  | 238 | virtual status_t setTransformHint(uint32_t hint) { | 
|  | 239 | Parcel data, reply; | 
|  | 240 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 241 | data.writeUint32(hint); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 242 | status_t result = remote()->transact(SET_TRANSFORM_HINT, data, &reply); | 
|  | 243 | if (result != NO_ERROR) { | 
|  | 244 | return result; | 
|  | 245 | } | 
|  | 246 | return reply.readInt32(); | 
|  | 247 | } | 
| Mathias Agopian | db89edc | 2013-08-02 01:40:18 -0700 | [diff] [blame] | 248 |  | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 249 | virtual sp<NativeHandle> getSidebandStream() const { | 
|  | 250 | Parcel data, reply; | 
|  | 251 | status_t err; | 
|  | 252 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
|  | 253 | if ((err = remote()->transact(GET_SIDEBAND_STREAM, data, &reply)) != NO_ERROR) { | 
|  | 254 | return NULL; | 
|  | 255 | } | 
|  | 256 | sp<NativeHandle> stream; | 
|  | 257 | if (reply.readInt32()) { | 
| Wonsik Kim | 0ec54e1 | 2014-03-21 10:46:24 +0900 | [diff] [blame] | 258 | stream = NativeHandle::create(reply.readNativeHandle(), true); | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 259 | } | 
|  | 260 | return stream; | 
|  | 261 | } | 
|  | 262 |  | 
| Mathias Agopian | db89edc | 2013-08-02 01:40:18 -0700 | [diff] [blame] | 263 | virtual void dump(String8& result, const char* prefix) const { | 
|  | 264 | Parcel data, reply; | 
|  | 265 | data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); | 
|  | 266 | data.writeString8(result); | 
|  | 267 | data.writeString8(String8(prefix ? prefix : "")); | 
|  | 268 | remote()->transact(DUMP, data, &reply); | 
|  | 269 | reply.readString8(); | 
|  | 270 | } | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 271 | }; | 
|  | 272 |  | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 273 | // Out-of-line virtual method definition to trigger vtable emission in this | 
|  | 274 | // translation unit (see clang warning -Wweak-vtables) | 
|  | 275 | BpGraphicBufferConsumer::~BpGraphicBufferConsumer() {} | 
|  | 276 |  | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 277 | IMPLEMENT_META_INTERFACE(GraphicBufferConsumer, "android.gui.IGraphicBufferConsumer"); | 
|  | 278 |  | 
|  | 279 | // ---------------------------------------------------------------------- | 
|  | 280 |  | 
|  | 281 | status_t BnGraphicBufferConsumer::onTransact( | 
|  | 282 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) | 
|  | 283 | { | 
|  | 284 | switch(code) { | 
|  | 285 | case ACQUIRE_BUFFER: { | 
|  | 286 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
|  | 287 | BufferItem item; | 
|  | 288 | int64_t presentWhen = data.readInt64(); | 
| Dan Stoza | a4650a5 | 2015-05-12 12:56:16 -0700 | [diff] [blame] | 289 | uint64_t maxFrameNumber = data.readUint64(); | 
|  | 290 | status_t result = acquireBuffer(&item, presentWhen, maxFrameNumber); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 291 | status_t err = reply->write(item); | 
|  | 292 | if (err) return err; | 
|  | 293 | reply->writeInt32(result); | 
|  | 294 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 295 | } | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 296 | case DETACH_BUFFER: { | 
|  | 297 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
|  | 298 | int slot = data.readInt32(); | 
|  | 299 | int result = detachBuffer(slot); | 
|  | 300 | reply->writeInt32(result); | 
|  | 301 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 302 | } | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 303 | case ATTACH_BUFFER: { | 
|  | 304 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
|  | 305 | sp<GraphicBuffer> buffer = new GraphicBuffer(); | 
|  | 306 | data.read(*buffer.get()); | 
| Robert Shih | dded8fd | 2016-01-11 11:42:48 -0800 | [diff] [blame] | 307 | int slot = -1; | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 308 | int result = attachBuffer(&slot, buffer); | 
|  | 309 | reply->writeInt32(slot); | 
|  | 310 | reply->writeInt32(result); | 
|  | 311 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 312 | } | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 313 | case RELEASE_BUFFER: { | 
|  | 314 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
|  | 315 | int buf = data.readInt32(); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 316 | uint64_t frameNumber = static_cast<uint64_t>(data.readInt64()); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 317 | sp<Fence> releaseFence = new Fence(); | 
|  | 318 | status_t err = data.read(*releaseFence); | 
|  | 319 | if (err) return err; | 
|  | 320 | status_t result = releaseBuffer(buf, frameNumber, | 
|  | 321 | EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, releaseFence); | 
|  | 322 | reply->writeInt32(result); | 
|  | 323 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 324 | } | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 325 | case CONSUMER_CONNECT: { | 
|  | 326 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
|  | 327 | sp<IConsumerListener> consumer = IConsumerListener::asInterface( data.readStrongBinder() ); | 
|  | 328 | bool controlledByApp = data.readInt32(); | 
|  | 329 | status_t result = consumerConnect(consumer, controlledByApp); | 
|  | 330 | reply->writeInt32(result); | 
|  | 331 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 332 | } | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 333 | case CONSUMER_DISCONNECT: { | 
|  | 334 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
|  | 335 | status_t result = consumerDisconnect(); | 
|  | 336 | reply->writeInt32(result); | 
|  | 337 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 338 | } | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 339 | case GET_RELEASED_BUFFERS: { | 
|  | 340 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
| Pablo Ceballos | 93c617f | 2016-03-15 18:10:49 -0700 | [diff] [blame] | 341 | uint64_t slotMask = 0; | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 342 | status_t result = getReleasedBuffers(&slotMask); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 343 | reply->writeInt64(static_cast<int64_t>(slotMask)); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 344 | reply->writeInt32(result); | 
|  | 345 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 346 | } | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 347 | case SET_DEFAULT_BUFFER_SIZE: { | 
|  | 348 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 349 | uint32_t width = data.readUint32(); | 
|  | 350 | uint32_t height = data.readUint32(); | 
|  | 351 | status_t result = setDefaultBufferSize(width, height); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 352 | reply->writeInt32(result); | 
|  | 353 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 354 | } | 
| Pablo Ceballos | 19e3e06 | 2015-08-19 16:16:06 -0700 | [diff] [blame] | 355 | case SET_MAX_BUFFER_COUNT: { | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 356 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 357 | int bufferCount = data.readInt32(); | 
| Pablo Ceballos | 19e3e06 | 2015-08-19 16:16:06 -0700 | [diff] [blame] | 358 | status_t result = setMaxBufferCount(bufferCount); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 359 | reply->writeInt32(result); | 
|  | 360 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 361 | } | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 362 | case SET_MAX_ACQUIRED_BUFFER_COUNT: { | 
|  | 363 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 364 | int maxAcquiredBuffers = data.readInt32(); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 365 | status_t result = setMaxAcquiredBufferCount(maxAcquiredBuffers); | 
|  | 366 | reply->writeInt32(result); | 
|  | 367 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 368 | } | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 369 | case SET_CONSUMER_NAME: { | 
|  | 370 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
|  | 371 | setConsumerName( data.readString8() ); | 
|  | 372 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 373 | } | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 374 | case SET_DEFAULT_BUFFER_FORMAT: { | 
|  | 375 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 376 | PixelFormat defaultFormat = static_cast<PixelFormat>(data.readInt32()); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 377 | status_t result = setDefaultBufferFormat(defaultFormat); | 
|  | 378 | reply->writeInt32(result); | 
|  | 379 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 380 | } | 
| Eino-Ville Talvala | 5b75a51 | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 381 | case SET_DEFAULT_BUFFER_DATA_SPACE: { | 
|  | 382 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
|  | 383 | android_dataspace defaultDataSpace = | 
|  | 384 | static_cast<android_dataspace>(data.readInt32()); | 
|  | 385 | status_t result = setDefaultBufferDataSpace(defaultDataSpace); | 
|  | 386 | reply->writeInt32(result); | 
|  | 387 | return NO_ERROR; | 
|  | 388 | } | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 389 | case SET_CONSUMER_USAGE_BITS: { | 
|  | 390 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 391 | uint32_t usage = data.readUint32(); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 392 | status_t result = setConsumerUsageBits(usage); | 
|  | 393 | reply->writeInt32(result); | 
|  | 394 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 395 | } | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 396 | case SET_TRANSFORM_HINT: { | 
|  | 397 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 398 | uint32_t hint = data.readUint32(); | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 399 | status_t result = setTransformHint(hint); | 
|  | 400 | reply->writeInt32(result); | 
|  | 401 | return NO_ERROR; | 
| Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 402 | } | 
| Dan Stoza | 80640fc | 2015-04-28 13:18:07 -0700 | [diff] [blame] | 403 | case GET_SIDEBAND_STREAM: { | 
|  | 404 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
|  | 405 | sp<NativeHandle> stream = getSidebandStream(); | 
|  | 406 | reply->writeInt32(static_cast<int32_t>(stream != NULL)); | 
|  | 407 | if (stream != NULL) { | 
|  | 408 | reply->writeNativeHandle(stream->handle()); | 
|  | 409 | } | 
|  | 410 | return NO_ERROR; | 
|  | 411 | } | 
| Mathias Agopian | db89edc | 2013-08-02 01:40:18 -0700 | [diff] [blame] | 412 | case DUMP: { | 
|  | 413 | CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); | 
|  | 414 | String8 result = data.readString8(); | 
|  | 415 | String8 prefix = data.readString8(); | 
|  | 416 | static_cast<IGraphicBufferConsumer*>(this)->dump(result, prefix); | 
|  | 417 | reply->writeString8(result); | 
|  | 418 | return NO_ERROR; | 
|  | 419 | } | 
| Mathias Agopian | a4e1952 | 2013-07-31 20:09:53 -0700 | [diff] [blame] | 420 | } | 
|  | 421 | return BBinder::onTransact(code, data, reply, flags); | 
|  | 422 | } | 
|  | 423 |  | 
|  | 424 | }; // namespace android |