Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1 | /* |
| 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> |
| 21 | #include <utils/RefBase.h> |
| 22 | #include <utils/Vector.h> |
| 23 | #include <utils/Timers.h> |
| 24 | |
| 25 | #include <binder/Parcel.h> |
| 26 | #include <binder/IInterface.h> |
| 27 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 28 | #include <gui/IGraphicBufferProducer.h> |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 29 | |
| 30 | namespace android { |
| 31 | // ---------------------------------------------------------------------------- |
| 32 | |
| 33 | enum { |
| 34 | REQUEST_BUFFER = IBinder::FIRST_CALL_TRANSACTION, |
| 35 | SET_BUFFER_COUNT, |
| 36 | DEQUEUE_BUFFER, |
| 37 | QUEUE_BUFFER, |
| 38 | CANCEL_BUFFER, |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 39 | QUERY, |
Mathias Agopian | 8072711 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 40 | SET_SYNCHRONOUS_MODE, |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 41 | CONNECT, |
| 42 | DISCONNECT, |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 46 | class BpGraphicBufferProducer : public BpInterface<IGraphicBufferProducer> |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 47 | { |
| 48 | public: |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 49 | BpGraphicBufferProducer(const sp<IBinder>& impl) |
| 50 | : BpInterface<IGraphicBufferProducer>(impl) |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 51 | { |
| 52 | } |
| 53 | |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 54 | virtual status_t requestBuffer(int bufferIdx, sp<GraphicBuffer>* buf) { |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 55 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 56 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 57 | data.writeInt32(bufferIdx); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 58 | status_t result =remote()->transact(REQUEST_BUFFER, data, &reply); |
| 59 | if (result != NO_ERROR) { |
| 60 | return result; |
| 61 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 62 | bool nonNull = reply.readInt32(); |
| 63 | if (nonNull) { |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 64 | *buf = new GraphicBuffer(); |
| 65 | reply.read(**buf); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 66 | } |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 67 | result = reply.readInt32(); |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 68 | return result; |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | virtual status_t setBufferCount(int bufferCount) |
| 72 | { |
| 73 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 74 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 75 | data.writeInt32(bufferCount); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 76 | status_t result =remote()->transact(SET_BUFFER_COUNT, data, &reply); |
| 77 | if (result != NO_ERROR) { |
| 78 | return result; |
| 79 | } |
| 80 | result = reply.readInt32(); |
| 81 | return result; |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 82 | } |
| 83 | |
Jesse Hall | f785754 | 2012-06-14 15:26:33 -0700 | [diff] [blame] | 84 | virtual status_t dequeueBuffer(int *buf, sp<Fence>& fence, |
| 85 | uint32_t w, uint32_t h, uint32_t format, uint32_t usage) { |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 86 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 87 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Mathias Agopian | c04f153 | 2011-04-25 20:22:14 -0700 | [diff] [blame] | 88 | data.writeInt32(w); |
| 89 | data.writeInt32(h); |
| 90 | data.writeInt32(format); |
| 91 | data.writeInt32(usage); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 92 | status_t result = remote()->transact(DEQUEUE_BUFFER, data, &reply); |
| 93 | if (result != NO_ERROR) { |
| 94 | return result; |
| 95 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 96 | *buf = reply.readInt32(); |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame^] | 97 | bool fenceWasWritten = reply.readInt32(); |
| 98 | if (fenceWasWritten) { |
| 99 | // If the fence was written by the callee, then overwrite the |
| 100 | // caller's fence here. If it wasn't written then don't touch the |
| 101 | // caller's fence. |
Jesse Hall | f785754 | 2012-06-14 15:26:33 -0700 | [diff] [blame] | 102 | fence = new Fence(); |
| 103 | reply.read(*fence.get()); |
| 104 | } |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 105 | result = reply.readInt32(); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 106 | return result; |
| 107 | } |
| 108 | |
Mathias Agopian | f0bc2f1 | 2012-04-09 16:14:01 -0700 | [diff] [blame] | 109 | virtual status_t queueBuffer(int buf, |
| 110 | const QueueBufferInput& input, QueueBufferOutput* output) { |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 111 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 112 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 113 | data.writeInt32(buf); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 114 | data.write(input); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 115 | status_t result = remote()->transact(QUEUE_BUFFER, data, &reply); |
| 116 | if (result != NO_ERROR) { |
| 117 | return result; |
| 118 | } |
Mathias Agopian | f0bc2f1 | 2012-04-09 16:14:01 -0700 | [diff] [blame] | 119 | memcpy(output, reply.readInplace(sizeof(*output)), sizeof(*output)); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 120 | result = reply.readInt32(); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 121 | return result; |
| 122 | } |
| 123 | |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 124 | virtual void cancelBuffer(int buf, sp<Fence> fence) { |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 125 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 126 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 127 | data.writeInt32(buf); |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame^] | 128 | data.write(*fence.get()); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 129 | remote()->transact(CANCEL_BUFFER, data, &reply); |
| 130 | } |
| 131 | |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 132 | virtual int query(int what, int* value) { |
| 133 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 134 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 135 | data.writeInt32(what); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 136 | status_t result = remote()->transact(QUERY, data, &reply); |
| 137 | if (result != NO_ERROR) { |
| 138 | return result; |
| 139 | } |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 140 | value[0] = reply.readInt32(); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 141 | result = reply.readInt32(); |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 142 | return result; |
| 143 | } |
| 144 | |
Mathias Agopian | 8072711 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 145 | virtual status_t setSynchronousMode(bool enabled) { |
| 146 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 147 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Mathias Agopian | 8072711 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 148 | data.writeInt32(enabled); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 149 | status_t result = remote()->transact(SET_SYNCHRONOUS_MODE, data, &reply); |
| 150 | if (result != NO_ERROR) { |
| 151 | return result; |
| 152 | } |
| 153 | result = reply.readInt32(); |
Mathias Agopian | 8072711 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 154 | return result; |
| 155 | } |
| 156 | |
Mathias Agopian | 24202f5 | 2012-04-23 14:28:58 -0700 | [diff] [blame] | 157 | virtual status_t connect(int api, QueueBufferOutput* output) { |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 158 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 159 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 160 | data.writeInt32(api); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 161 | status_t result = remote()->transact(CONNECT, data, &reply); |
| 162 | if (result != NO_ERROR) { |
| 163 | return result; |
| 164 | } |
Mathias Agopian | 24202f5 | 2012-04-23 14:28:58 -0700 | [diff] [blame] | 165 | memcpy(output, reply.readInplace(sizeof(*output)), sizeof(*output)); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 166 | result = reply.readInt32(); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 167 | return result; |
| 168 | } |
Mathias Agopian | 8072711 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 169 | |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 170 | virtual status_t disconnect(int api) { |
| 171 | Parcel data, reply; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 172 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 173 | data.writeInt32(api); |
Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 174 | status_t result =remote()->transact(DISCONNECT, data, &reply); |
| 175 | if (result != NO_ERROR) { |
| 176 | return result; |
| 177 | } |
| 178 | result = reply.readInt32(); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 179 | return result; |
| 180 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 181 | }; |
| 182 | |
Andy McFadden | 466a192 | 2013-01-08 11:25:51 -0800 | [diff] [blame] | 183 | IMPLEMENT_META_INTERFACE(GraphicBufferProducer, "android.gui.IGraphicBufferProducer"); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 184 | |
| 185 | // ---------------------------------------------------------------------- |
| 186 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 187 | status_t BnGraphicBufferProducer::onTransact( |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 188 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 189 | { |
| 190 | switch(code) { |
| 191 | case REQUEST_BUFFER: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 192 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 193 | int bufferIdx = data.readInt32(); |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 194 | sp<GraphicBuffer> buffer; |
| 195 | int result = requestBuffer(bufferIdx, &buffer); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 196 | reply->writeInt32(buffer != 0); |
| 197 | if (buffer != 0) { |
| 198 | reply->write(*buffer); |
| 199 | } |
Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 200 | reply->writeInt32(result); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 201 | return NO_ERROR; |
| 202 | } break; |
| 203 | case SET_BUFFER_COUNT: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 204 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 205 | int bufferCount = data.readInt32(); |
| 206 | int result = setBufferCount(bufferCount); |
| 207 | reply->writeInt32(result); |
| 208 | return NO_ERROR; |
| 209 | } break; |
| 210 | case DEQUEUE_BUFFER: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 211 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Mathias Agopian | c04f153 | 2011-04-25 20:22:14 -0700 | [diff] [blame] | 212 | uint32_t w = data.readInt32(); |
| 213 | uint32_t h = data.readInt32(); |
| 214 | uint32_t format = data.readInt32(); |
| 215 | uint32_t usage = data.readInt32(); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 216 | int buf; |
Jesse Hall | f785754 | 2012-06-14 15:26:33 -0700 | [diff] [blame] | 217 | sp<Fence> fence; |
| 218 | int result = dequeueBuffer(&buf, fence, w, h, format, usage); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 219 | reply->writeInt32(buf); |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame^] | 220 | reply->writeInt32(fence != NULL); |
| 221 | if (fence != NULL) { |
Jesse Hall | f785754 | 2012-06-14 15:26:33 -0700 | [diff] [blame] | 222 | reply->write(*fence.get()); |
| 223 | } |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 224 | reply->writeInt32(result); |
| 225 | return NO_ERROR; |
| 226 | } break; |
| 227 | case QUEUE_BUFFER: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 228 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 229 | int buf = data.readInt32(); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 230 | QueueBufferInput input(data); |
Mathias Agopian | f0bc2f1 | 2012-04-09 16:14:01 -0700 | [diff] [blame] | 231 | QueueBufferOutput* const output = |
| 232 | reinterpret_cast<QueueBufferOutput *>( |
| 233 | reply->writeInplace(sizeof(QueueBufferOutput))); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 234 | status_t result = queueBuffer(buf, input, output); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 235 | reply->writeInt32(result); |
| 236 | return NO_ERROR; |
| 237 | } break; |
| 238 | case CANCEL_BUFFER: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 239 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 240 | int buf = data.readInt32(); |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame^] | 241 | sp<Fence> fence = new Fence(); |
| 242 | data.read(*fence.get()); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 243 | cancelBuffer(buf, fence); |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 244 | return NO_ERROR; |
| 245 | } break; |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 246 | case QUERY: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 247 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 248 | int value; |
| 249 | int what = data.readInt32(); |
| 250 | int res = query(what, &value); |
| 251 | reply->writeInt32(value); |
| 252 | reply->writeInt32(res); |
| 253 | return NO_ERROR; |
| 254 | } break; |
Mathias Agopian | 8072711 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 255 | case SET_SYNCHRONOUS_MODE: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 256 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Mathias Agopian | 8072711 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 257 | bool enabled = data.readInt32(); |
| 258 | status_t res = setSynchronousMode(enabled); |
| 259 | reply->writeInt32(res); |
| 260 | return NO_ERROR; |
| 261 | } break; |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 262 | case CONNECT: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 263 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 264 | int api = data.readInt32(); |
Mathias Agopian | 24202f5 | 2012-04-23 14:28:58 -0700 | [diff] [blame] | 265 | QueueBufferOutput* const output = |
| 266 | reinterpret_cast<QueueBufferOutput *>( |
| 267 | reply->writeInplace(sizeof(QueueBufferOutput))); |
| 268 | status_t res = connect(api, output); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 269 | reply->writeInt32(res); |
| 270 | return NO_ERROR; |
| 271 | } break; |
| 272 | case DISCONNECT: { |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 273 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 274 | int api = data.readInt32(); |
Mathias Agopian | 2773004 | 2011-07-14 20:20:58 -0700 | [diff] [blame] | 275 | status_t res = disconnect(api); |
Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 276 | reply->writeInt32(res); |
| 277 | return NO_ERROR; |
| 278 | } break; |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 279 | } |
| 280 | return BBinder::onTransact(code, data, reply, flags); |
| 281 | } |
| 282 | |
| 283 | // ---------------------------------------------------------------------------- |
| 284 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 285 | IGraphicBufferProducer::QueueBufferInput::QueueBufferInput(const Parcel& parcel) { |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 286 | parcel.read(*this); |
| 287 | } |
| 288 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 289 | size_t IGraphicBufferProducer::QueueBufferInput::getFlattenedSize() const |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 290 | { |
| 291 | return sizeof(timestamp) |
| 292 | + sizeof(crop) |
| 293 | + sizeof(scalingMode) |
| 294 | + sizeof(transform) |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame^] | 295 | + fence->getFlattenedSize(); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 296 | } |
| 297 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 298 | size_t IGraphicBufferProducer::QueueBufferInput::getFdCount() const |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 299 | { |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame^] | 300 | return fence->getFdCount(); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 301 | } |
| 302 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 303 | status_t IGraphicBufferProducer::QueueBufferInput::flatten(void* buffer, size_t size, |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 304 | int fds[], size_t count) const |
| 305 | { |
| 306 | status_t err = NO_ERROR; |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 307 | char* p = (char*)buffer; |
| 308 | memcpy(p, ×tamp, sizeof(timestamp)); p += sizeof(timestamp); |
| 309 | memcpy(p, &crop, sizeof(crop)); p += sizeof(crop); |
| 310 | memcpy(p, &scalingMode, sizeof(scalingMode)); p += sizeof(scalingMode); |
| 311 | memcpy(p, &transform, sizeof(transform)); p += sizeof(transform); |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame^] | 312 | err = fence->flatten(p, size - (p - (char*)buffer), fds, count); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 313 | return err; |
| 314 | } |
| 315 | |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 316 | status_t IGraphicBufferProducer::QueueBufferInput::unflatten(void const* buffer, |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 317 | size_t size, int fds[], size_t count) |
| 318 | { |
| 319 | status_t err = NO_ERROR; |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 320 | const char* p = (const char*)buffer; |
| 321 | memcpy(×tamp, p, sizeof(timestamp)); p += sizeof(timestamp); |
| 322 | memcpy(&crop, p, sizeof(crop)); p += sizeof(crop); |
| 323 | memcpy(&scalingMode, p, sizeof(scalingMode)); p += sizeof(scalingMode); |
| 324 | memcpy(&transform, p, sizeof(transform)); p += sizeof(transform); |
Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame^] | 325 | fence = new Fence(); |
| 326 | err = fence->unflatten(p, size - (p - (const char*)buffer), fds, count); |
Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 327 | return err; |
| 328 | } |
| 329 | |
Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 330 | }; // namespace android |