The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | // tag as surfaceflinger |
| 18 | #define LOG_TAG "SurfaceFlinger" |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 23 | #include <binder/Parcel.h> |
| 24 | #include <binder/IMemory.h> |
| 25 | #include <binder/IPCThreadState.h> |
| 26 | #include <binder/IServiceManager.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 28 | #include <gui/BitTube.h> |
| 29 | #include <gui/IDisplayEventConnection.h> |
Mathias Agopian | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 30 | #include <gui/ISurfaceComposer.h> |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 31 | #include <gui/IGraphicBufferProducer.h> |
Mathias Agopian | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 32 | |
| 33 | #include <private/gui/LayerState.h> |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 34 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | #include <ui/DisplayInfo.h> |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 36 | #include <ui/DisplayStatInfo.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 38 | #include <utils/Log.h> |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 39 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | // --------------------------------------------------------------------------- |
| 41 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | namespace android { |
| 43 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 44 | class IDisplayEventConnection; |
| 45 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | class BpSurfaceComposer : public BpInterface<ISurfaceComposer> |
| 47 | { |
| 48 | public: |
| 49 | BpSurfaceComposer(const sp<IBinder>& impl) |
| 50 | : BpInterface<ISurfaceComposer>(impl) |
| 51 | { |
| 52 | } |
| 53 | |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 54 | virtual sp<ISurfaceComposerClient> createConnection() |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | { |
| 56 | uint32_t n; |
| 57 | Parcel data, reply; |
| 58 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 59 | remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply); |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 60 | return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | } |
| 62 | |
Jamie Gennis | 9a78c90 | 2011-01-12 18:30:40 -0800 | [diff] [blame] | 63 | virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() |
| 64 | { |
| 65 | uint32_t n; |
| 66 | Parcel data, reply; |
| 67 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 68 | remote()->transact(BnSurfaceComposer::CREATE_GRAPHIC_BUFFER_ALLOC, data, &reply); |
| 69 | return interface_cast<IGraphicBufferAlloc>(reply.readStrongBinder()); |
| 70 | } |
| 71 | |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 72 | virtual void setTransactionState( |
| 73 | const Vector<ComposerState>& state, |
| 74 | const Vector<DisplayState>& displays, |
| 75 | uint32_t flags) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | { |
| 77 | Parcel data, reply; |
| 78 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 79 | { |
| 80 | Vector<ComposerState>::const_iterator b(state.begin()); |
| 81 | Vector<ComposerState>::const_iterator e(state.end()); |
| 82 | data.writeInt32(state.size()); |
| 83 | for ( ; b != e ; ++b ) { |
| 84 | b->write(data); |
| 85 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 86 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 87 | { |
| 88 | Vector<DisplayState>::const_iterator b(displays.begin()); |
| 89 | Vector<DisplayState>::const_iterator e(displays.end()); |
| 90 | data.writeInt32(displays.size()); |
| 91 | for ( ; b != e ; ++b ) { |
| 92 | b->write(data); |
| 93 | } |
| 94 | } |
Jamie Gennis | 2837839 | 2011-10-12 17:39:00 -0700 | [diff] [blame] | 95 | data.writeInt32(flags); |
Jamie Gennis | b8d69a5 | 2011-10-10 15:48:06 -0700 | [diff] [blame] | 96 | remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | virtual void bootFinished() |
| 100 | { |
| 101 | Parcel data, reply; |
| 102 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 103 | remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply); |
| 104 | } |
| 105 | |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 106 | virtual status_t captureScreen(const sp<IBinder>& display, |
| 107 | const sp<IGraphicBufferProducer>& producer, |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 108 | Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 109 | uint32_t minLayerZ, uint32_t maxLayerZ, |
Riley Andrews | c3ebe66 | 2014-09-04 16:20:31 -0700 | [diff] [blame] | 110 | bool useIdentityTransform, |
| 111 | ISurfaceComposer::Rotation rotation) |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 112 | { |
| 113 | Parcel data, reply; |
| 114 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 115 | data.writeStrongBinder(display); |
| 116 | data.writeStrongBinder(producer->asBinder()); |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 117 | data.write(sourceCrop); |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 118 | data.writeInt32(reqWidth); |
| 119 | data.writeInt32(reqHeight); |
| 120 | data.writeInt32(minLayerZ); |
| 121 | data.writeInt32(maxLayerZ); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 122 | data.writeInt32(static_cast<int32_t>(useIdentityTransform)); |
Riley Andrews | c3ebe66 | 2014-09-04 16:20:31 -0700 | [diff] [blame] | 123 | data.writeInt32(static_cast<int32_t>(rotation)); |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 124 | remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply); |
| 125 | return reply.readInt32(); |
| 126 | } |
| 127 | |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 128 | virtual bool authenticateSurfaceTexture( |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 129 | const sp<IGraphicBufferProducer>& bufferProducer) const |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 130 | { |
| 131 | Parcel data, reply; |
| 132 | int err = NO_ERROR; |
| 133 | err = data.writeInterfaceToken( |
| 134 | ISurfaceComposer::getInterfaceDescriptor()); |
| 135 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 136 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 137 | "interface descriptor: %s (%d)", strerror(-err), -err); |
| 138 | return false; |
| 139 | } |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 140 | err = data.writeStrongBinder(bufferProducer->asBinder()); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 141 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 142 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 143 | "strong binder to parcel: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 144 | return false; |
| 145 | } |
| 146 | err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data, |
| 147 | &reply); |
| 148 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 149 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 150 | "performing transaction: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 151 | return false; |
| 152 | } |
| 153 | int32_t result = 0; |
| 154 | err = reply.readInt32(&result); |
| 155 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 156 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 157 | "retrieving result: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 158 | return false; |
| 159 | } |
| 160 | return result != 0; |
| 161 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 162 | |
| 163 | virtual sp<IDisplayEventConnection> createDisplayEventConnection() |
| 164 | { |
| 165 | Parcel data, reply; |
| 166 | sp<IDisplayEventConnection> result; |
| 167 | int err = data.writeInterfaceToken( |
| 168 | ISurfaceComposer::getInterfaceDescriptor()); |
| 169 | if (err != NO_ERROR) { |
| 170 | return result; |
| 171 | } |
| 172 | err = remote()->transact( |
| 173 | BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION, |
| 174 | data, &reply); |
| 175 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 176 | ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing " |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 177 | "transaction: %s (%d)", strerror(-err), -err); |
| 178 | return result; |
| 179 | } |
| 180 | result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder()); |
| 181 | return result; |
| 182 | } |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 183 | |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 184 | virtual sp<IBinder> createDisplay(const String8& displayName, bool secure) |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 185 | { |
| 186 | Parcel data, reply; |
| 187 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 188 | data.writeString8(displayName); |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 189 | data.writeInt32(secure ? 1 : 0); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 190 | remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply); |
| 191 | return reply.readStrongBinder(); |
| 192 | } |
| 193 | |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 194 | virtual void destroyDisplay(const sp<IBinder>& display) |
| 195 | { |
| 196 | Parcel data, reply; |
| 197 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 198 | data.writeStrongBinder(display); |
| 199 | remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply); |
| 200 | } |
| 201 | |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 202 | virtual sp<IBinder> getBuiltInDisplay(int32_t id) |
| 203 | { |
| 204 | Parcel data, reply; |
| 205 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 206 | data.writeInt32(id); |
| 207 | remote()->transact(BnSurfaceComposer::GET_BUILT_IN_DISPLAY, data, &reply); |
| 208 | return reply.readStrongBinder(); |
| 209 | } |
| 210 | |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 211 | virtual void setPowerMode(const sp<IBinder>& display, int mode) |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 212 | { |
| 213 | Parcel data, reply; |
| 214 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Andy McFadden | c01a79d | 2012-09-27 16:02:06 -0700 | [diff] [blame] | 215 | data.writeStrongBinder(display); |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 216 | data.writeInt32(mode); |
| 217 | remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply); |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 218 | } |
Mathias Agopian | 3094df3 | 2012-06-18 18:06:45 -0700 | [diff] [blame] | 219 | |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 220 | virtual status_t getDisplayConfigs(const sp<IBinder>& display, |
| 221 | Vector<DisplayInfo>* configs) |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 222 | { |
| 223 | Parcel data, reply; |
| 224 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 225 | data.writeStrongBinder(display); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 226 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply); |
| 227 | status_t result = reply.readInt32(); |
| 228 | if (result == NO_ERROR) { |
| 229 | size_t numConfigs = static_cast<size_t>(reply.readInt32()); |
| 230 | configs->clear(); |
| 231 | configs->resize(numConfigs); |
| 232 | for (size_t c = 0; c < numConfigs; ++c) { |
| 233 | memcpy(&(configs->editItemAt(c)), |
| 234 | reply.readInplace(sizeof(DisplayInfo)), |
| 235 | sizeof(DisplayInfo)); |
| 236 | } |
| 237 | } |
| 238 | return result; |
| 239 | } |
| 240 | |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 241 | virtual status_t getDisplayStats(const sp<IBinder>& display, |
| 242 | DisplayStatInfo* stats) |
| 243 | { |
| 244 | Parcel data, reply; |
| 245 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 246 | data.writeStrongBinder(display); |
| 247 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply); |
| 248 | status_t result = reply.readInt32(); |
| 249 | if (result == NO_ERROR) { |
| 250 | memcpy(stats, |
| 251 | reply.readInplace(sizeof(DisplayStatInfo)), |
| 252 | sizeof(DisplayStatInfo)); |
| 253 | } |
| 254 | return result; |
| 255 | } |
| 256 | |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 257 | virtual int getActiveConfig(const sp<IBinder>& display) |
| 258 | { |
| 259 | Parcel data, reply; |
| 260 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 261 | data.writeStrongBinder(display); |
| 262 | remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply); |
| 263 | return reply.readInt32(); |
| 264 | } |
| 265 | |
| 266 | virtual status_t setActiveConfig(const sp<IBinder>& display, int id) |
| 267 | { |
| 268 | Parcel data, reply; |
| 269 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 270 | data.writeStrongBinder(display); |
| 271 | data.writeInt32(id); |
| 272 | remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply); |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 273 | return reply.readInt32(); |
| 274 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 275 | |
| 276 | virtual status_t clearAnimationFrameStats() { |
| 277 | Parcel data, reply; |
| 278 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 279 | remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply); |
| 280 | return reply.readInt32(); |
| 281 | } |
| 282 | |
| 283 | virtual status_t getAnimationFrameStats(FrameStats* outStats) const { |
| 284 | Parcel data, reply; |
| 285 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 286 | remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply); |
| 287 | reply.read(*outStats); |
| 288 | return reply.readInt32(); |
| 289 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 290 | }; |
| 291 | |
| 292 | IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer"); |
| 293 | |
| 294 | // ---------------------------------------------------------------------- |
| 295 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 296 | status_t BnSurfaceComposer::onTransact( |
| 297 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 298 | { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 299 | switch(code) { |
| 300 | case CREATE_CONNECTION: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 301 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 302 | sp<IBinder> b = createConnection()->asBinder(); |
| 303 | reply->writeStrongBinder(b); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 304 | return NO_ERROR; |
| 305 | } |
Jamie Gennis | 9a78c90 | 2011-01-12 18:30:40 -0800 | [diff] [blame] | 306 | case CREATE_GRAPHIC_BUFFER_ALLOC: { |
| 307 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 308 | sp<IBinder> b = createGraphicBufferAlloc()->asBinder(); |
| 309 | reply->writeStrongBinder(b); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 310 | return NO_ERROR; |
| 311 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 312 | case SET_TRANSACTION_STATE: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 313 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 314 | size_t count = data.readInt32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame^] | 315 | if (count > data.dataSize()) { |
| 316 | return BAD_VALUE; |
| 317 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 318 | ComposerState s; |
| 319 | Vector<ComposerState> state; |
| 320 | state.setCapacity(count); |
| 321 | for (size_t i=0 ; i<count ; i++) { |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame^] | 322 | if (s.read(data) == BAD_VALUE) { |
| 323 | return BAD_VALUE; |
| 324 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 325 | state.add(s); |
| 326 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 327 | count = data.readInt32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame^] | 328 | if (count > data.dataSize()) { |
| 329 | return BAD_VALUE; |
| 330 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 331 | DisplayState d; |
| 332 | Vector<DisplayState> displays; |
| 333 | displays.setCapacity(count); |
| 334 | for (size_t i=0 ; i<count ; i++) { |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame^] | 335 | if (d.read(data) == BAD_VALUE) { |
| 336 | return BAD_VALUE; |
| 337 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 338 | displays.add(d); |
| 339 | } |
Jamie Gennis | 2837839 | 2011-10-12 17:39:00 -0700 | [diff] [blame] | 340 | uint32_t flags = data.readInt32(); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 341 | setTransactionState(state, displays, flags); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 342 | return NO_ERROR; |
| 343 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 344 | case BOOT_FINISHED: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 345 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 346 | bootFinished(); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 347 | return NO_ERROR; |
| 348 | } |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 349 | case CAPTURE_SCREEN: { |
| 350 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 351 | sp<IBinder> display = data.readStrongBinder(); |
| 352 | sp<IGraphicBufferProducer> producer = |
| 353 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 354 | Rect sourceCrop; |
| 355 | data.read(sourceCrop); |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 356 | uint32_t reqWidth = data.readInt32(); |
| 357 | uint32_t reqHeight = data.readInt32(); |
| 358 | uint32_t minLayerZ = data.readInt32(); |
| 359 | uint32_t maxLayerZ = data.readInt32(); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 360 | bool useIdentityTransform = static_cast<bool>(data.readInt32()); |
Riley Andrews | c3ebe66 | 2014-09-04 16:20:31 -0700 | [diff] [blame] | 361 | uint32_t rotation = data.readInt32(); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 362 | |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 363 | status_t res = captureScreen(display, producer, |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 364 | sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ, |
Riley Andrews | c3ebe66 | 2014-09-04 16:20:31 -0700 | [diff] [blame] | 365 | useIdentityTransform, |
| 366 | static_cast<ISurfaceComposer::Rotation>(rotation)); |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 367 | reply->writeInt32(res); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 368 | return NO_ERROR; |
| 369 | } |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 370 | case AUTHENTICATE_SURFACE: { |
| 371 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 372 | sp<IGraphicBufferProducer> bufferProducer = |
| 373 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); |
| 374 | int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0; |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 375 | reply->writeInt32(result); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 376 | return NO_ERROR; |
| 377 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 378 | case CREATE_DISPLAY_EVENT_CONNECTION: { |
| 379 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 380 | sp<IDisplayEventConnection> connection(createDisplayEventConnection()); |
| 381 | reply->writeStrongBinder(connection->asBinder()); |
| 382 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 383 | } |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 384 | case CREATE_DISPLAY: { |
| 385 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 386 | String8 displayName = data.readString8(); |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 387 | bool secure = bool(data.readInt32()); |
| 388 | sp<IBinder> display(createDisplay(displayName, secure)); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 389 | reply->writeStrongBinder(display); |
| 390 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 391 | } |
| 392 | case DESTROY_DISPLAY: { |
| 393 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 394 | sp<IBinder> display = data.readStrongBinder(); |
| 395 | destroyDisplay(display); |
| 396 | return NO_ERROR; |
| 397 | } |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 398 | case GET_BUILT_IN_DISPLAY: { |
| 399 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 400 | int32_t id = data.readInt32(); |
| 401 | sp<IBinder> display(getBuiltInDisplay(id)); |
| 402 | reply->writeStrongBinder(display); |
| 403 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 404 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 405 | case GET_DISPLAY_CONFIGS: { |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 406 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 407 | Vector<DisplayInfo> configs; |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 408 | sp<IBinder> display = data.readStrongBinder(); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 409 | status_t result = getDisplayConfigs(display, &configs); |
| 410 | reply->writeInt32(result); |
| 411 | if (result == NO_ERROR) { |
| 412 | reply->writeInt32(static_cast<int32_t>(configs.size())); |
| 413 | for (size_t c = 0; c < configs.size(); ++c) { |
| 414 | memcpy(reply->writeInplace(sizeof(DisplayInfo)), |
| 415 | &configs[c], sizeof(DisplayInfo)); |
| 416 | } |
| 417 | } |
| 418 | return NO_ERROR; |
| 419 | } |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 420 | case GET_DISPLAY_STATS: { |
| 421 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 422 | DisplayStatInfo stats; |
| 423 | sp<IBinder> display = data.readStrongBinder(); |
| 424 | status_t result = getDisplayStats(display, &stats); |
| 425 | reply->writeInt32(result); |
| 426 | if (result == NO_ERROR) { |
| 427 | memcpy(reply->writeInplace(sizeof(DisplayStatInfo)), |
| 428 | &stats, sizeof(DisplayStatInfo)); |
| 429 | } |
| 430 | return NO_ERROR; |
| 431 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 432 | case GET_ACTIVE_CONFIG: { |
| 433 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 434 | sp<IBinder> display = data.readStrongBinder(); |
| 435 | int id = getActiveConfig(display); |
| 436 | reply->writeInt32(id); |
| 437 | return NO_ERROR; |
| 438 | } |
| 439 | case SET_ACTIVE_CONFIG: { |
| 440 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 441 | sp<IBinder> display = data.readStrongBinder(); |
| 442 | int id = data.readInt32(); |
| 443 | status_t result = setActiveConfig(display, id); |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 444 | reply->writeInt32(result); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 445 | return NO_ERROR; |
| 446 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 447 | case CLEAR_ANIMATION_FRAME_STATS: { |
| 448 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 449 | status_t result = clearAnimationFrameStats(); |
| 450 | reply->writeInt32(result); |
| 451 | return NO_ERROR; |
| 452 | } |
| 453 | case GET_ANIMATION_FRAME_STATS: { |
| 454 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 455 | FrameStats stats; |
| 456 | status_t result = getAnimationFrameStats(&stats); |
| 457 | reply->write(stats); |
| 458 | reply->writeInt32(result); |
| 459 | return NO_ERROR; |
| 460 | } |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 461 | case SET_POWER_MODE: { |
| 462 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 463 | sp<IBinder> display = data.readStrongBinder(); |
| 464 | int32_t mode = data.readInt32(); |
| 465 | setPowerMode(display, mode); |
| 466 | return NO_ERROR; |
| 467 | } |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 468 | default: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 469 | return BBinder::onTransact(code, data, reply, flags); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 470 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 471 | } |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 472 | // should be unreachable |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 473 | return NO_ERROR; |
| 474 | } |
| 475 | |
| 476 | // ---------------------------------------------------------------------------- |
| 477 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 478 | }; |