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