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