Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (C) 2013 The Android Open Source Project |
michael@0 | 3 | * |
michael@0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 5 | * you may not use this file except in compliance with the License. |
michael@0 | 6 | * You may obtain a copy of the License at |
michael@0 | 7 | * |
michael@0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 9 | * |
michael@0 | 10 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 13 | * See the License for the specific language governing permissions and |
michael@0 | 14 | * limitations under the License. |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #define EGL_EGLEXT_PROTOTYPES |
michael@0 | 18 | |
michael@0 | 19 | #include <stdint.h> |
michael@0 | 20 | #include <sys/types.h> |
michael@0 | 21 | |
michael@0 | 22 | #include <utils/Errors.h> |
michael@0 | 23 | |
michael@0 | 24 | #include <binder/Parcel.h> |
michael@0 | 25 | #include <binder/IInterface.h> |
michael@0 | 26 | |
michael@0 | 27 | #include <gui/IConsumerListener.h> |
michael@0 | 28 | #include "IGonkGraphicBufferConsumer.h" |
michael@0 | 29 | |
michael@0 | 30 | #include <ui/GraphicBuffer.h> |
michael@0 | 31 | #include <ui/Fence.h> |
michael@0 | 32 | |
michael@0 | 33 | #include <system/window.h> |
michael@0 | 34 | |
michael@0 | 35 | namespace android { |
michael@0 | 36 | // --------------------------------------------------------------------------- |
michael@0 | 37 | |
michael@0 | 38 | IGonkGraphicBufferConsumer::BufferItem::BufferItem() : |
michael@0 | 39 | mTransform(0), |
michael@0 | 40 | mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE), |
michael@0 | 41 | mTimestamp(0), |
michael@0 | 42 | mIsAutoTimestamp(false), |
michael@0 | 43 | mFrameNumber(0), |
michael@0 | 44 | mBuf(INVALID_BUFFER_SLOT), |
michael@0 | 45 | mIsDroppable(false), |
michael@0 | 46 | mAcquireCalled(false), |
michael@0 | 47 | mTransformToDisplayInverse(false) { |
michael@0 | 48 | mCrop.makeInvalid(); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | size_t IGonkGraphicBufferConsumer::BufferItem::getPodSize() const { |
michael@0 | 52 | size_t c = sizeof(mCrop) + |
michael@0 | 53 | sizeof(mTransform) + |
michael@0 | 54 | sizeof(mScalingMode) + |
michael@0 | 55 | sizeof(mTimestamp) + |
michael@0 | 56 | sizeof(mIsAutoTimestamp) + |
michael@0 | 57 | sizeof(mFrameNumber) + |
michael@0 | 58 | sizeof(mBuf) + |
michael@0 | 59 | sizeof(mIsDroppable) + |
michael@0 | 60 | sizeof(mAcquireCalled) + |
michael@0 | 61 | sizeof(mTransformToDisplayInverse); |
michael@0 | 62 | return c; |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | size_t IGonkGraphicBufferConsumer::BufferItem::getFlattenedSize() const { |
michael@0 | 66 | size_t c = 0; |
michael@0 | 67 | if (mGraphicBuffer != 0) { |
michael@0 | 68 | c += mGraphicBuffer->getFlattenedSize(); |
michael@0 | 69 | FlattenableUtils::align<4>(c); |
michael@0 | 70 | } |
michael@0 | 71 | if (mFence != 0) { |
michael@0 | 72 | c += mFence->getFlattenedSize(); |
michael@0 | 73 | FlattenableUtils::align<4>(c); |
michael@0 | 74 | } |
michael@0 | 75 | return sizeof(int32_t) + c + getPodSize(); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | size_t IGonkGraphicBufferConsumer::BufferItem::getFdCount() const { |
michael@0 | 79 | size_t c = 0; |
michael@0 | 80 | if (mGraphicBuffer != 0) { |
michael@0 | 81 | c += mGraphicBuffer->getFdCount(); |
michael@0 | 82 | } |
michael@0 | 83 | if (mFence != 0) { |
michael@0 | 84 | c += mFence->getFdCount(); |
michael@0 | 85 | } |
michael@0 | 86 | return c; |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | status_t IGonkGraphicBufferConsumer::BufferItem::flatten( |
michael@0 | 90 | void*& buffer, size_t& size, int*& fds, size_t& count) const { |
michael@0 | 91 | |
michael@0 | 92 | // make sure we have enough space |
michael@0 | 93 | if (count < BufferItem::getFlattenedSize()) { |
michael@0 | 94 | return NO_MEMORY; |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | // content flags are stored first |
michael@0 | 98 | uint32_t& flags = *static_cast<uint32_t*>(buffer); |
michael@0 | 99 | |
michael@0 | 100 | // advance the pointer |
michael@0 | 101 | FlattenableUtils::advance(buffer, size, sizeof(uint32_t)); |
michael@0 | 102 | |
michael@0 | 103 | flags = 0; |
michael@0 | 104 | if (mGraphicBuffer != 0) { |
michael@0 | 105 | status_t err = mGraphicBuffer->flatten(buffer, size, fds, count); |
michael@0 | 106 | if (err) return err; |
michael@0 | 107 | size -= FlattenableUtils::align<4>(buffer); |
michael@0 | 108 | flags |= 1; |
michael@0 | 109 | } |
michael@0 | 110 | if (mFence != 0) { |
michael@0 | 111 | status_t err = mFence->flatten(buffer, size, fds, count); |
michael@0 | 112 | if (err) return err; |
michael@0 | 113 | size -= FlattenableUtils::align<4>(buffer); |
michael@0 | 114 | flags |= 2; |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | // check we have enough space (in case flattening the fence/graphicbuffer lied to us) |
michael@0 | 118 | if (size < getPodSize()) { |
michael@0 | 119 | return NO_MEMORY; |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | FlattenableUtils::write(buffer, size, mCrop); |
michael@0 | 123 | FlattenableUtils::write(buffer, size, mTransform); |
michael@0 | 124 | FlattenableUtils::write(buffer, size, mScalingMode); |
michael@0 | 125 | FlattenableUtils::write(buffer, size, mTimestamp); |
michael@0 | 126 | FlattenableUtils::write(buffer, size, mIsAutoTimestamp); |
michael@0 | 127 | FlattenableUtils::write(buffer, size, mFrameNumber); |
michael@0 | 128 | FlattenableUtils::write(buffer, size, mBuf); |
michael@0 | 129 | FlattenableUtils::write(buffer, size, mIsDroppable); |
michael@0 | 130 | FlattenableUtils::write(buffer, size, mAcquireCalled); |
michael@0 | 131 | FlattenableUtils::write(buffer, size, mTransformToDisplayInverse); |
michael@0 | 132 | |
michael@0 | 133 | return NO_ERROR; |
michael@0 | 134 | } |
michael@0 | 135 | |
michael@0 | 136 | status_t IGonkGraphicBufferConsumer::BufferItem::unflatten( |
michael@0 | 137 | void const*& buffer, size_t& size, int const*& fds, size_t& count) { |
michael@0 | 138 | |
michael@0 | 139 | if (size < sizeof(uint32_t)) |
michael@0 | 140 | return NO_MEMORY; |
michael@0 | 141 | |
michael@0 | 142 | uint32_t flags = 0; |
michael@0 | 143 | FlattenableUtils::read(buffer, size, flags); |
michael@0 | 144 | |
michael@0 | 145 | if (flags & 1) { |
michael@0 | 146 | mGraphicBuffer = new GraphicBuffer(); |
michael@0 | 147 | status_t err = mGraphicBuffer->unflatten(buffer, size, fds, count); |
michael@0 | 148 | if (err) return err; |
michael@0 | 149 | size -= FlattenableUtils::align<4>(buffer); |
michael@0 | 150 | } |
michael@0 | 151 | |
michael@0 | 152 | if (flags & 2) { |
michael@0 | 153 | mFence = new Fence(); |
michael@0 | 154 | status_t err = mFence->unflatten(buffer, size, fds, count); |
michael@0 | 155 | if (err) return err; |
michael@0 | 156 | size -= FlattenableUtils::align<4>(buffer); |
michael@0 | 157 | } |
michael@0 | 158 | |
michael@0 | 159 | // check we have enough space |
michael@0 | 160 | if (size < getPodSize()) { |
michael@0 | 161 | return NO_MEMORY; |
michael@0 | 162 | } |
michael@0 | 163 | |
michael@0 | 164 | FlattenableUtils::read(buffer, size, mCrop); |
michael@0 | 165 | FlattenableUtils::read(buffer, size, mTransform); |
michael@0 | 166 | FlattenableUtils::read(buffer, size, mScalingMode); |
michael@0 | 167 | FlattenableUtils::read(buffer, size, mTimestamp); |
michael@0 | 168 | FlattenableUtils::read(buffer, size, mIsAutoTimestamp); |
michael@0 | 169 | FlattenableUtils::read(buffer, size, mFrameNumber); |
michael@0 | 170 | FlattenableUtils::read(buffer, size, mBuf); |
michael@0 | 171 | FlattenableUtils::read(buffer, size, mIsDroppable); |
michael@0 | 172 | FlattenableUtils::read(buffer, size, mAcquireCalled); |
michael@0 | 173 | FlattenableUtils::read(buffer, size, mTransformToDisplayInverse); |
michael@0 | 174 | |
michael@0 | 175 | return NO_ERROR; |
michael@0 | 176 | } |
michael@0 | 177 | |
michael@0 | 178 | // --------------------------------------------------------------------------- |
michael@0 | 179 | |
michael@0 | 180 | enum { |
michael@0 | 181 | ACQUIRE_BUFFER = IBinder::FIRST_CALL_TRANSACTION, |
michael@0 | 182 | RELEASE_BUFFER, |
michael@0 | 183 | CONSUMER_CONNECT, |
michael@0 | 184 | CONSUMER_DISCONNECT, |
michael@0 | 185 | GET_RELEASED_BUFFERS, |
michael@0 | 186 | SET_DEFAULT_BUFFER_SIZE, |
michael@0 | 187 | SET_DEFAULT_MAX_BUFFER_COUNT, |
michael@0 | 188 | DISABLE_ASYNC_BUFFER, |
michael@0 | 189 | SET_MAX_ACQUIRED_BUFFER_COUNT, |
michael@0 | 190 | SET_CONSUMER_NAME, |
michael@0 | 191 | SET_DEFAULT_BUFFER_FORMAT, |
michael@0 | 192 | SET_CONSUMER_USAGE_BITS, |
michael@0 | 193 | SET_TRANSFORM_HINT, |
michael@0 | 194 | DUMP, |
michael@0 | 195 | }; |
michael@0 | 196 | |
michael@0 | 197 | class BpGonkGraphicBufferConsumer : public BpInterface<IGonkGraphicBufferConsumer> |
michael@0 | 198 | { |
michael@0 | 199 | public: |
michael@0 | 200 | BpGonkGraphicBufferConsumer(const sp<IBinder>& impl) |
michael@0 | 201 | : BpInterface<IGonkGraphicBufferConsumer>(impl) |
michael@0 | 202 | { |
michael@0 | 203 | } |
michael@0 | 204 | |
michael@0 | 205 | virtual status_t acquireBuffer(BufferItem *buffer, nsecs_t presentWhen) { |
michael@0 | 206 | Parcel data, reply; |
michael@0 | 207 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 208 | data.writeInt64(presentWhen); |
michael@0 | 209 | status_t result = remote()->transact(ACQUIRE_BUFFER, data, &reply); |
michael@0 | 210 | if (result != NO_ERROR) { |
michael@0 | 211 | return result; |
michael@0 | 212 | } |
michael@0 | 213 | result = reply.read(*buffer); |
michael@0 | 214 | if (result != NO_ERROR) { |
michael@0 | 215 | return result; |
michael@0 | 216 | } |
michael@0 | 217 | return reply.readInt32(); |
michael@0 | 218 | } |
michael@0 | 219 | |
michael@0 | 220 | virtual status_t releaseBuffer(int buf, uint64_t frameNumber, |
michael@0 | 221 | const sp<Fence>& releaseFence) { |
michael@0 | 222 | Parcel data, reply; |
michael@0 | 223 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 224 | data.writeInt32(buf); |
michael@0 | 225 | data.writeInt64(frameNumber); |
michael@0 | 226 | data.write(*releaseFence); |
michael@0 | 227 | status_t result = remote()->transact(RELEASE_BUFFER, data, &reply); |
michael@0 | 228 | if (result != NO_ERROR) { |
michael@0 | 229 | return result; |
michael@0 | 230 | } |
michael@0 | 231 | return reply.readInt32(); |
michael@0 | 232 | } |
michael@0 | 233 | |
michael@0 | 234 | virtual status_t consumerConnect(const sp<IConsumerListener>& consumer, bool controlledByApp) { |
michael@0 | 235 | Parcel data, reply; |
michael@0 | 236 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 237 | data.writeStrongBinder(consumer->asBinder()); |
michael@0 | 238 | data.writeInt32(controlledByApp); |
michael@0 | 239 | status_t result = remote()->transact(CONSUMER_CONNECT, data, &reply); |
michael@0 | 240 | if (result != NO_ERROR) { |
michael@0 | 241 | return result; |
michael@0 | 242 | } |
michael@0 | 243 | return reply.readInt32(); |
michael@0 | 244 | } |
michael@0 | 245 | |
michael@0 | 246 | virtual status_t consumerDisconnect() { |
michael@0 | 247 | Parcel data, reply; |
michael@0 | 248 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 249 | status_t result = remote()->transact(CONSUMER_DISCONNECT, data, &reply); |
michael@0 | 250 | if (result != NO_ERROR) { |
michael@0 | 251 | return result; |
michael@0 | 252 | } |
michael@0 | 253 | return reply.readInt32(); |
michael@0 | 254 | } |
michael@0 | 255 | |
michael@0 | 256 | virtual status_t getReleasedBuffers(uint32_t* slotMask) { |
michael@0 | 257 | Parcel data, reply; |
michael@0 | 258 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 259 | status_t result = remote()->transact(GET_RELEASED_BUFFERS, data, &reply); |
michael@0 | 260 | if (result != NO_ERROR) { |
michael@0 | 261 | return result; |
michael@0 | 262 | } |
michael@0 | 263 | *slotMask = reply.readInt32(); |
michael@0 | 264 | return reply.readInt32(); |
michael@0 | 265 | } |
michael@0 | 266 | |
michael@0 | 267 | virtual status_t setDefaultBufferSize(uint32_t w, uint32_t h) { |
michael@0 | 268 | Parcel data, reply; |
michael@0 | 269 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 270 | data.writeInt32(w); |
michael@0 | 271 | data.writeInt32(h); |
michael@0 | 272 | status_t result = remote()->transact(SET_DEFAULT_BUFFER_SIZE, data, &reply); |
michael@0 | 273 | if (result != NO_ERROR) { |
michael@0 | 274 | return result; |
michael@0 | 275 | } |
michael@0 | 276 | return reply.readInt32(); |
michael@0 | 277 | } |
michael@0 | 278 | |
michael@0 | 279 | virtual status_t setDefaultMaxBufferCount(int bufferCount) { |
michael@0 | 280 | Parcel data, reply; |
michael@0 | 281 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 282 | data.writeInt32(bufferCount); |
michael@0 | 283 | status_t result = remote()->transact(SET_DEFAULT_MAX_BUFFER_COUNT, data, &reply); |
michael@0 | 284 | if (result != NO_ERROR) { |
michael@0 | 285 | return result; |
michael@0 | 286 | } |
michael@0 | 287 | return reply.readInt32(); |
michael@0 | 288 | } |
michael@0 | 289 | |
michael@0 | 290 | virtual status_t disableAsyncBuffer() { |
michael@0 | 291 | Parcel data, reply; |
michael@0 | 292 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 293 | status_t result = remote()->transact(DISABLE_ASYNC_BUFFER, data, &reply); |
michael@0 | 294 | if (result != NO_ERROR) { |
michael@0 | 295 | return result; |
michael@0 | 296 | } |
michael@0 | 297 | return reply.readInt32(); |
michael@0 | 298 | } |
michael@0 | 299 | |
michael@0 | 300 | virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers) { |
michael@0 | 301 | Parcel data, reply; |
michael@0 | 302 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 303 | data.writeInt32(maxAcquiredBuffers); |
michael@0 | 304 | status_t result = remote()->transact(SET_MAX_ACQUIRED_BUFFER_COUNT, data, &reply); |
michael@0 | 305 | if (result != NO_ERROR) { |
michael@0 | 306 | return result; |
michael@0 | 307 | } |
michael@0 | 308 | return reply.readInt32(); |
michael@0 | 309 | } |
michael@0 | 310 | |
michael@0 | 311 | virtual void setConsumerName(const String8& name) { |
michael@0 | 312 | Parcel data, reply; |
michael@0 | 313 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 314 | data.writeString8(name); |
michael@0 | 315 | remote()->transact(SET_CONSUMER_NAME, data, &reply); |
michael@0 | 316 | } |
michael@0 | 317 | |
michael@0 | 318 | virtual status_t setDefaultBufferFormat(uint32_t defaultFormat) { |
michael@0 | 319 | Parcel data, reply; |
michael@0 | 320 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 321 | data.writeInt32(defaultFormat); |
michael@0 | 322 | status_t result = remote()->transact(SET_DEFAULT_BUFFER_FORMAT, data, &reply); |
michael@0 | 323 | if (result != NO_ERROR) { |
michael@0 | 324 | return result; |
michael@0 | 325 | } |
michael@0 | 326 | return reply.readInt32(); |
michael@0 | 327 | } |
michael@0 | 328 | |
michael@0 | 329 | virtual status_t setConsumerUsageBits(uint32_t usage) { |
michael@0 | 330 | Parcel data, reply; |
michael@0 | 331 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 332 | data.writeInt32(usage); |
michael@0 | 333 | status_t result = remote()->transact(SET_CONSUMER_USAGE_BITS, data, &reply); |
michael@0 | 334 | if (result != NO_ERROR) { |
michael@0 | 335 | return result; |
michael@0 | 336 | } |
michael@0 | 337 | return reply.readInt32(); |
michael@0 | 338 | } |
michael@0 | 339 | |
michael@0 | 340 | virtual status_t setTransformHint(uint32_t hint) { |
michael@0 | 341 | Parcel data, reply; |
michael@0 | 342 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 343 | data.writeInt32(hint); |
michael@0 | 344 | status_t result = remote()->transact(SET_TRANSFORM_HINT, data, &reply); |
michael@0 | 345 | if (result != NO_ERROR) { |
michael@0 | 346 | return result; |
michael@0 | 347 | } |
michael@0 | 348 | return reply.readInt32(); |
michael@0 | 349 | } |
michael@0 | 350 | |
michael@0 | 351 | virtual void dump(String8& result, const char* prefix) const { |
michael@0 | 352 | Parcel data, reply; |
michael@0 | 353 | data.writeInterfaceToken(IGonkGraphicBufferConsumer::getInterfaceDescriptor()); |
michael@0 | 354 | data.writeString8(result); |
michael@0 | 355 | data.writeString8(String8(prefix ? prefix : "")); |
michael@0 | 356 | remote()->transact(DUMP, data, &reply); |
michael@0 | 357 | reply.readString8(); |
michael@0 | 358 | } |
michael@0 | 359 | }; |
michael@0 | 360 | |
michael@0 | 361 | IMPLEMENT_META_INTERFACE(GonkGraphicBufferConsumer, "android.gui.IGonkGraphicBufferConsumer"); |
michael@0 | 362 | // ---------------------------------------------------------------------- |
michael@0 | 363 | |
michael@0 | 364 | status_t BnGonkGraphicBufferConsumer::onTransact( |
michael@0 | 365 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
michael@0 | 366 | { |
michael@0 | 367 | switch(code) { |
michael@0 | 368 | case ACQUIRE_BUFFER: { |
michael@0 | 369 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 370 | BufferItem item; |
michael@0 | 371 | int64_t presentWhen = data.readInt64(); |
michael@0 | 372 | status_t result = acquireBuffer(&item, presentWhen); |
michael@0 | 373 | status_t err = reply->write(item); |
michael@0 | 374 | if (err) return err; |
michael@0 | 375 | reply->writeInt32(result); |
michael@0 | 376 | return NO_ERROR; |
michael@0 | 377 | } break; |
michael@0 | 378 | case RELEASE_BUFFER: { |
michael@0 | 379 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 380 | int buf = data.readInt32(); |
michael@0 | 381 | uint64_t frameNumber = data.readInt64(); |
michael@0 | 382 | sp<Fence> releaseFence = new Fence(); |
michael@0 | 383 | status_t err = data.read(*releaseFence); |
michael@0 | 384 | if (err) return err; |
michael@0 | 385 | status_t result = releaseBuffer(buf, frameNumber, releaseFence); |
michael@0 | 386 | reply->writeInt32(result); |
michael@0 | 387 | return NO_ERROR; |
michael@0 | 388 | } break; |
michael@0 | 389 | |
michael@0 | 390 | case CONSUMER_CONNECT: { |
michael@0 | 391 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 392 | sp<IConsumerListener> consumer = IConsumerListener::asInterface( data.readStrongBinder() ); |
michael@0 | 393 | bool controlledByApp = data.readInt32(); |
michael@0 | 394 | status_t result = consumerConnect(consumer, controlledByApp); |
michael@0 | 395 | reply->writeInt32(result); |
michael@0 | 396 | return NO_ERROR; |
michael@0 | 397 | } break; |
michael@0 | 398 | |
michael@0 | 399 | case CONSUMER_DISCONNECT: { |
michael@0 | 400 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 401 | status_t result = consumerDisconnect(); |
michael@0 | 402 | reply->writeInt32(result); |
michael@0 | 403 | return NO_ERROR; |
michael@0 | 404 | } break; |
michael@0 | 405 | case GET_RELEASED_BUFFERS: { |
michael@0 | 406 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 407 | uint32_t slotMask; |
michael@0 | 408 | status_t result = getReleasedBuffers(&slotMask); |
michael@0 | 409 | reply->writeInt32(slotMask); |
michael@0 | 410 | reply->writeInt32(result); |
michael@0 | 411 | return NO_ERROR; |
michael@0 | 412 | } break; |
michael@0 | 413 | case SET_DEFAULT_BUFFER_SIZE: { |
michael@0 | 414 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 415 | uint32_t w = data.readInt32(); |
michael@0 | 416 | uint32_t h = data.readInt32(); |
michael@0 | 417 | status_t result = setDefaultBufferSize(w, h); |
michael@0 | 418 | reply->writeInt32(result); |
michael@0 | 419 | return NO_ERROR; |
michael@0 | 420 | } break; |
michael@0 | 421 | case SET_DEFAULT_MAX_BUFFER_COUNT: { |
michael@0 | 422 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 423 | uint32_t bufferCount = data.readInt32(); |
michael@0 | 424 | status_t result = setDefaultMaxBufferCount(bufferCount); |
michael@0 | 425 | reply->writeInt32(result); |
michael@0 | 426 | return NO_ERROR; |
michael@0 | 427 | } break; |
michael@0 | 428 | case DISABLE_ASYNC_BUFFER: { |
michael@0 | 429 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 430 | status_t result = disableAsyncBuffer(); |
michael@0 | 431 | reply->writeInt32(result); |
michael@0 | 432 | return NO_ERROR; |
michael@0 | 433 | } break; |
michael@0 | 434 | case SET_MAX_ACQUIRED_BUFFER_COUNT: { |
michael@0 | 435 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 436 | uint32_t maxAcquiredBuffers = data.readInt32(); |
michael@0 | 437 | status_t result = setMaxAcquiredBufferCount(maxAcquiredBuffers); |
michael@0 | 438 | reply->writeInt32(result); |
michael@0 | 439 | return NO_ERROR; |
michael@0 | 440 | } break; |
michael@0 | 441 | case SET_CONSUMER_NAME: { |
michael@0 | 442 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 443 | setConsumerName( data.readString8() ); |
michael@0 | 444 | return NO_ERROR; |
michael@0 | 445 | } break; |
michael@0 | 446 | case SET_DEFAULT_BUFFER_FORMAT: { |
michael@0 | 447 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 448 | uint32_t defaultFormat = data.readInt32(); |
michael@0 | 449 | status_t result = setDefaultBufferFormat(defaultFormat); |
michael@0 | 450 | reply->writeInt32(result); |
michael@0 | 451 | return NO_ERROR; |
michael@0 | 452 | } break; |
michael@0 | 453 | case SET_CONSUMER_USAGE_BITS: { |
michael@0 | 454 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 455 | uint32_t usage = data.readInt32(); |
michael@0 | 456 | status_t result = setConsumerUsageBits(usage); |
michael@0 | 457 | reply->writeInt32(result); |
michael@0 | 458 | return NO_ERROR; |
michael@0 | 459 | } break; |
michael@0 | 460 | case SET_TRANSFORM_HINT: { |
michael@0 | 461 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 462 | uint32_t hint = data.readInt32(); |
michael@0 | 463 | status_t result = setTransformHint(hint); |
michael@0 | 464 | reply->writeInt32(result); |
michael@0 | 465 | return NO_ERROR; |
michael@0 | 466 | } break; |
michael@0 | 467 | |
michael@0 | 468 | case DUMP: { |
michael@0 | 469 | CHECK_INTERFACE(IGonkGraphicBufferConsumer, data, reply); |
michael@0 | 470 | String8 result = data.readString8(); |
michael@0 | 471 | String8 prefix = data.readString8(); |
michael@0 | 472 | static_cast<IGonkGraphicBufferConsumer*>(this)->dump(result, prefix); |
michael@0 | 473 | reply->writeString8(result); |
michael@0 | 474 | return NO_ERROR; |
michael@0 | 475 | } |
michael@0 | 476 | } |
michael@0 | 477 | return BBinder::onTransact(code, data, reply, flags); |
michael@0 | 478 | } |
michael@0 | 479 | |
michael@0 | 480 | }; // namespace android |