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