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> |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 24 | #include <binder/IPCThreadState.h> |
| 25 | #include <binder/IServiceManager.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 27 | #include <gui/IDisplayEventConnection.h> |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 28 | #include <gui/IGraphicBufferProducer.h> |
Mathias Agopian | 2b5dd40 | 2017-02-07 17:36:19 -0800 | [diff] [blame] | 29 | #include <gui/ISurfaceComposer.h> |
| 30 | #include <gui/ISurfaceComposerClient.h> |
Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 31 | #include <gui/LayerDebugInfo.h> |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 32 | #include <gui/LayerState.h> |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 33 | |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 34 | #include <system/graphics.h> |
| 35 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | #include <ui/DisplayInfo.h> |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 37 | #include <ui/DisplayStatInfo.h> |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 38 | #include <ui/HdrCapabilities.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 40 | #include <utils/Log.h> |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 41 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | // --------------------------------------------------------------------------- |
| 43 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | namespace android { |
| 45 | |
Peiyong Lin | 9f03447 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 46 | using ui::ColorMode; |
| 47 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | class BpSurfaceComposer : public BpInterface<ISurfaceComposer> |
| 49 | { |
| 50 | public: |
Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame] | 51 | explicit BpSurfaceComposer(const sp<IBinder>& impl) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | : BpInterface<ISurfaceComposer>(impl) |
| 53 | { |
| 54 | } |
| 55 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 56 | virtual ~BpSurfaceComposer(); |
| 57 | |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 58 | virtual sp<ISurfaceComposerClient> createConnection() |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | Parcel data, reply; |
| 61 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 62 | remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply); |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 63 | return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | } |
| 65 | |
Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 66 | virtual void setTransactionState(const Vector<ComposerState>& state, |
| 67 | const Vector<DisplayState>& displays, uint32_t flags, |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 68 | const sp<IBinder>& applyToken, |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 69 | const InputWindowCommands& commands, |
| 70 | int64_t desiredPresentTime) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | Parcel data, reply; |
| 72 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 73 | |
| 74 | data.writeUint32(static_cast<uint32_t>(state.size())); |
| 75 | for (const auto& s : state) { |
| 76 | s.write(data); |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 77 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 78 | |
| 79 | data.writeUint32(static_cast<uint32_t>(displays.size())); |
| 80 | for (const auto& d : displays) { |
| 81 | d.write(data); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 82 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 83 | |
| 84 | data.writeUint32(flags); |
Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 85 | data.writeStrongBinder(applyToken); |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 86 | commands.write(data); |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 87 | data.writeInt64(desiredPresentTime); |
Jamie Gennis | b8d69a5 | 2011-10-10 15:48:06 -0700 | [diff] [blame] | 88 | remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | virtual void bootFinished() |
| 92 | { |
| 93 | Parcel data, reply; |
| 94 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 95 | remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply); |
| 96 | } |
| 97 | |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 98 | virtual status_t captureScreen(const sp<IBinder>& display, sp<GraphicBuffer>* outBuffer, |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 99 | const ui::Dataspace reqDataspace, |
| 100 | const ui::PixelFormat reqPixelFormat, Rect sourceCrop, |
| 101 | uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform, |
| 102 | ISurfaceComposer::Rotation rotation) { |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 103 | Parcel data, reply; |
| 104 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 105 | data.writeStrongBinder(display); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 106 | data.writeInt32(static_cast<int32_t>(reqDataspace)); |
| 107 | data.writeInt32(static_cast<int32_t>(reqPixelFormat)); |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 108 | data.write(sourceCrop); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 109 | data.writeUint32(reqWidth); |
| 110 | data.writeUint32(reqHeight); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 111 | data.writeInt32(static_cast<int32_t>(useIdentityTransform)); |
Riley Andrews | c3ebe66 | 2014-09-04 16:20:31 -0700 | [diff] [blame] | 112 | data.writeInt32(static_cast<int32_t>(rotation)); |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 113 | status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply); |
| 114 | if (result != NO_ERROR) { |
| 115 | ALOGE("captureScreen failed to transact: %d", result); |
| 116 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 117 | } |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 118 | result = reply.readInt32(); |
| 119 | if (result != NO_ERROR) { |
| 120 | ALOGE("captureScreen failed to readInt32: %d", result); |
| 121 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | *outBuffer = new GraphicBuffer(); |
| 125 | reply.read(**outBuffer); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 126 | |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 127 | return result; |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 128 | } |
| 129 | |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 130 | virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder, |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 131 | sp<GraphicBuffer>* outBuffer, const ui::Dataspace reqDataspace, |
| 132 | const ui::PixelFormat reqPixelFormat, const Rect& sourceCrop, |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 133 | float frameScale, bool childrenOnly) { |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 134 | Parcel data, reply; |
| 135 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 136 | data.writeStrongBinder(layerHandleBinder); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 137 | data.writeInt32(static_cast<int32_t>(reqDataspace)); |
| 138 | data.writeInt32(static_cast<int32_t>(reqPixelFormat)); |
chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 139 | data.write(sourceCrop); |
| 140 | data.writeFloat(frameScale); |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 141 | data.writeBool(childrenOnly); |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 142 | status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply); |
| 143 | if (result != NO_ERROR) { |
| 144 | ALOGE("captureLayers failed to transact: %d", result); |
| 145 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 146 | } |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 147 | result = reply.readInt32(); |
| 148 | if (result != NO_ERROR) { |
| 149 | ALOGE("captureLayers failed to readInt32: %d", result); |
| 150 | return result; |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 151 | } |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 152 | |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 153 | *outBuffer = new GraphicBuffer(); |
| 154 | reply.read(**outBuffer); |
| 155 | |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 156 | return result; |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 157 | } |
| 158 | |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 159 | virtual bool authenticateSurfaceTexture( |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 160 | const sp<IGraphicBufferProducer>& bufferProducer) const |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 161 | { |
| 162 | Parcel data, reply; |
| 163 | int err = NO_ERROR; |
| 164 | err = data.writeInterfaceToken( |
| 165 | ISurfaceComposer::getInterfaceDescriptor()); |
| 166 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 167 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 168 | "interface descriptor: %s (%d)", strerror(-err), -err); |
| 169 | return false; |
| 170 | } |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 171 | err = data.writeStrongBinder(IInterface::asBinder(bufferProducer)); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 172 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 173 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 174 | "strong binder to parcel: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 175 | return false; |
| 176 | } |
| 177 | err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data, |
| 178 | &reply); |
| 179 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 180 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 181 | "performing transaction: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 182 | return false; |
| 183 | } |
| 184 | int32_t result = 0; |
| 185 | err = reply.readInt32(&result); |
| 186 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 187 | ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error " |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 188 | "retrieving result: %s (%d)", strerror(-err), -err); |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 189 | return false; |
| 190 | } |
| 191 | return result != 0; |
| 192 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 193 | |
Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 194 | virtual status_t getSupportedFrameTimestamps( |
| 195 | std::vector<FrameEvent>* outSupported) const { |
| 196 | if (!outSupported) { |
| 197 | return UNEXPECTED_NULL; |
| 198 | } |
| 199 | outSupported->clear(); |
| 200 | |
| 201 | Parcel data, reply; |
| 202 | |
| 203 | status_t err = data.writeInterfaceToken( |
| 204 | ISurfaceComposer::getInterfaceDescriptor()); |
| 205 | if (err != NO_ERROR) { |
| 206 | return err; |
| 207 | } |
| 208 | |
| 209 | err = remote()->transact( |
| 210 | BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS, |
| 211 | data, &reply); |
| 212 | if (err != NO_ERROR) { |
| 213 | return err; |
| 214 | } |
| 215 | |
| 216 | int32_t result = 0; |
| 217 | err = reply.readInt32(&result); |
| 218 | if (err != NO_ERROR) { |
| 219 | return err; |
| 220 | } |
| 221 | if (result != NO_ERROR) { |
| 222 | return result; |
| 223 | } |
| 224 | |
| 225 | std::vector<int32_t> supported; |
| 226 | err = reply.readInt32Vector(&supported); |
| 227 | if (err != NO_ERROR) { |
| 228 | return err; |
| 229 | } |
| 230 | |
| 231 | outSupported->reserve(supported.size()); |
| 232 | for (int32_t s : supported) { |
| 233 | outSupported->push_back(static_cast<FrameEvent>(s)); |
| 234 | } |
| 235 | return NO_ERROR; |
| 236 | } |
| 237 | |
Jorim Jaggi | b1e2f8d | 2017-06-08 15:43:59 -0700 | [diff] [blame] | 238 | virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource) |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 239 | { |
| 240 | Parcel data, reply; |
| 241 | sp<IDisplayEventConnection> result; |
| 242 | int err = data.writeInterfaceToken( |
| 243 | ISurfaceComposer::getInterfaceDescriptor()); |
| 244 | if (err != NO_ERROR) { |
| 245 | return result; |
| 246 | } |
Jorim Jaggi | b1e2f8d | 2017-06-08 15:43:59 -0700 | [diff] [blame] | 247 | data.writeInt32(static_cast<int32_t>(vsyncSource)); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 248 | err = remote()->transact( |
| 249 | BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION, |
| 250 | data, &reply); |
| 251 | if (err != NO_ERROR) { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 252 | ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing " |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 253 | "transaction: %s (%d)", strerror(-err), -err); |
| 254 | return result; |
| 255 | } |
| 256 | result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder()); |
| 257 | return result; |
| 258 | } |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 259 | |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 260 | virtual sp<IBinder> createDisplay(const String8& displayName, bool secure) |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 261 | { |
| 262 | Parcel data, reply; |
| 263 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 264 | data.writeString8(displayName); |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 265 | data.writeInt32(secure ? 1 : 0); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 266 | remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply); |
| 267 | return reply.readStrongBinder(); |
| 268 | } |
| 269 | |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 270 | virtual void destroyDisplay(const sp<IBinder>& display) |
| 271 | { |
| 272 | Parcel data, reply; |
| 273 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 274 | data.writeStrongBinder(display); |
| 275 | remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply); |
| 276 | } |
| 277 | |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame^] | 278 | virtual std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const { |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 279 | Parcel data, reply; |
| 280 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame^] | 281 | if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) == |
| 282 | NO_ERROR) { |
| 283 | std::vector<PhysicalDisplayId> displayIds; |
| 284 | if (reply.readUint64Vector(&displayIds) == NO_ERROR) { |
| 285 | return displayIds; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | return {}; |
| 290 | } |
| 291 | |
| 292 | virtual sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const { |
| 293 | Parcel data, reply; |
| 294 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 295 | data.writeUint64(displayId); |
| 296 | remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 297 | return reply.readStrongBinder(); |
| 298 | } |
| 299 | |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 300 | virtual void setPowerMode(const sp<IBinder>& display, int mode) |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 301 | { |
| 302 | Parcel data, reply; |
| 303 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Andy McFadden | c01a79d | 2012-09-27 16:02:06 -0700 | [diff] [blame] | 304 | data.writeStrongBinder(display); |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 305 | data.writeInt32(mode); |
| 306 | remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply); |
Colin Cross | 8e53306 | 2012-06-07 13:17:52 -0700 | [diff] [blame] | 307 | } |
Mathias Agopian | 3094df3 | 2012-06-18 18:06:45 -0700 | [diff] [blame] | 308 | |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 309 | virtual status_t getDisplayConfigs(const sp<IBinder>& display, |
| 310 | Vector<DisplayInfo>* configs) |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 311 | { |
| 312 | Parcel data, reply; |
| 313 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 314 | data.writeStrongBinder(display); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 315 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply); |
| 316 | status_t result = reply.readInt32(); |
| 317 | if (result == NO_ERROR) { |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 318 | size_t numConfigs = reply.readUint32(); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 319 | configs->clear(); |
| 320 | configs->resize(numConfigs); |
| 321 | for (size_t c = 0; c < numConfigs; ++c) { |
| 322 | memcpy(&(configs->editItemAt(c)), |
| 323 | reply.readInplace(sizeof(DisplayInfo)), |
| 324 | sizeof(DisplayInfo)); |
| 325 | } |
| 326 | } |
| 327 | return result; |
| 328 | } |
| 329 | |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 330 | virtual status_t getDisplayStats(const sp<IBinder>& display, |
| 331 | DisplayStatInfo* stats) |
| 332 | { |
| 333 | Parcel data, reply; |
| 334 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 335 | data.writeStrongBinder(display); |
| 336 | remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply); |
| 337 | status_t result = reply.readInt32(); |
| 338 | if (result == NO_ERROR) { |
| 339 | memcpy(stats, |
| 340 | reply.readInplace(sizeof(DisplayStatInfo)), |
| 341 | sizeof(DisplayStatInfo)); |
| 342 | } |
| 343 | return result; |
| 344 | } |
| 345 | |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 346 | virtual int getActiveConfig(const sp<IBinder>& display) |
| 347 | { |
| 348 | Parcel data, reply; |
| 349 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 350 | data.writeStrongBinder(display); |
| 351 | remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply); |
| 352 | return reply.readInt32(); |
| 353 | } |
| 354 | |
| 355 | virtual status_t setActiveConfig(const sp<IBinder>& display, int id) |
| 356 | { |
| 357 | Parcel data, reply; |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 358 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 359 | if (result != NO_ERROR) { |
| 360 | ALOGE("setActiveConfig failed to writeInterfaceToken: %d", result); |
| 361 | return result; |
| 362 | } |
| 363 | result = data.writeStrongBinder(display); |
| 364 | if (result != NO_ERROR) { |
| 365 | ALOGE("setActiveConfig failed to writeStrongBinder: %d", result); |
| 366 | return result; |
| 367 | } |
| 368 | result = data.writeInt32(id); |
| 369 | if (result != NO_ERROR) { |
| 370 | ALOGE("setActiveConfig failed to writeInt32: %d", result); |
| 371 | return result; |
| 372 | } |
| 373 | result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply); |
| 374 | if (result != NO_ERROR) { |
| 375 | ALOGE("setActiveConfig failed to transact: %d", result); |
| 376 | return result; |
| 377 | } |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 378 | return reply.readInt32(); |
| 379 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 380 | |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 381 | virtual status_t getDisplayColorModes(const sp<IBinder>& display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 382 | Vector<ColorMode>* outColorModes) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 383 | Parcel data, reply; |
| 384 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 385 | if (result != NO_ERROR) { |
| 386 | ALOGE("getDisplayColorModes failed to writeInterfaceToken: %d", result); |
| 387 | return result; |
| 388 | } |
| 389 | result = data.writeStrongBinder(display); |
| 390 | if (result != NO_ERROR) { |
| 391 | ALOGE("getDisplayColorModes failed to writeStrongBinder: %d", result); |
| 392 | return result; |
| 393 | } |
| 394 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_COLOR_MODES, data, &reply); |
| 395 | if (result != NO_ERROR) { |
| 396 | ALOGE("getDisplayColorModes failed to transact: %d", result); |
| 397 | return result; |
| 398 | } |
| 399 | result = static_cast<status_t>(reply.readInt32()); |
| 400 | if (result == NO_ERROR) { |
| 401 | size_t numModes = reply.readUint32(); |
| 402 | outColorModes->clear(); |
| 403 | outColorModes->resize(numModes); |
| 404 | for (size_t i = 0; i < numModes; ++i) { |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 405 | outColorModes->replaceAt(static_cast<ColorMode>(reply.readInt32()), i); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 406 | } |
| 407 | } |
| 408 | return result; |
| 409 | } |
| 410 | |
Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame] | 411 | virtual status_t getDisplayNativePrimaries(const sp<IBinder>& display, |
| 412 | ui::DisplayPrimaries& primaries) { |
| 413 | Parcel data, reply; |
| 414 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 415 | if (result != NO_ERROR) { |
| 416 | ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result); |
| 417 | return result; |
| 418 | } |
| 419 | result = data.writeStrongBinder(display); |
| 420 | if (result != NO_ERROR) { |
| 421 | ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result); |
| 422 | return result; |
| 423 | } |
| 424 | result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply); |
| 425 | if (result != NO_ERROR) { |
| 426 | ALOGE("getDisplayNativePrimaries failed to transact: %d", result); |
| 427 | return result; |
| 428 | } |
| 429 | result = reply.readInt32(); |
| 430 | if (result == NO_ERROR) { |
| 431 | memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)), |
| 432 | sizeof(ui::DisplayPrimaries)); |
| 433 | } |
| 434 | return result; |
| 435 | } |
| 436 | |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 437 | virtual ColorMode getActiveColorMode(const sp<IBinder>& display) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 438 | Parcel data, reply; |
| 439 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 440 | if (result != NO_ERROR) { |
| 441 | ALOGE("getActiveColorMode failed to writeInterfaceToken: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 442 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 443 | } |
| 444 | result = data.writeStrongBinder(display); |
| 445 | if (result != NO_ERROR) { |
| 446 | ALOGE("getActiveColorMode failed to writeStrongBinder: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 447 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 448 | } |
| 449 | result = remote()->transact(BnSurfaceComposer::GET_ACTIVE_COLOR_MODE, data, &reply); |
| 450 | if (result != NO_ERROR) { |
| 451 | ALOGE("getActiveColorMode failed to transact: %d", result); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 452 | return static_cast<ColorMode>(result); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 453 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 454 | return static_cast<ColorMode>(reply.readInt32()); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | virtual status_t setActiveColorMode(const sp<IBinder>& display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 458 | ColorMode colorMode) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 459 | Parcel data, reply; |
| 460 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 461 | if (result != NO_ERROR) { |
| 462 | ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result); |
| 463 | return result; |
| 464 | } |
| 465 | result = data.writeStrongBinder(display); |
| 466 | if (result != NO_ERROR) { |
| 467 | ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result); |
| 468 | return result; |
| 469 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 470 | result = data.writeInt32(static_cast<int32_t>(colorMode)); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 471 | if (result != NO_ERROR) { |
| 472 | ALOGE("setActiveColorMode failed to writeInt32: %d", result); |
| 473 | return result; |
| 474 | } |
| 475 | result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply); |
| 476 | if (result != NO_ERROR) { |
| 477 | ALOGE("setActiveColorMode failed to transact: %d", result); |
| 478 | return result; |
| 479 | } |
| 480 | return static_cast<status_t>(reply.readInt32()); |
| 481 | } |
| 482 | |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 483 | virtual status_t clearAnimationFrameStats() { |
| 484 | Parcel data, reply; |
Ana Krulec | 2d41e42 | 2018-07-26 12:07:43 -0700 | [diff] [blame] | 485 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 486 | if (result != NO_ERROR) { |
| 487 | ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result); |
| 488 | return result; |
| 489 | } |
| 490 | result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply); |
| 491 | if (result != NO_ERROR) { |
| 492 | ALOGE("clearAnimationFrameStats failed to transact: %d", result); |
| 493 | return result; |
| 494 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 495 | return reply.readInt32(); |
| 496 | } |
| 497 | |
| 498 | virtual status_t getAnimationFrameStats(FrameStats* outStats) const { |
| 499 | Parcel data, reply; |
| 500 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 501 | remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply); |
| 502 | reply.read(*outStats); |
| 503 | return reply.readInt32(); |
| 504 | } |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 505 | |
| 506 | virtual status_t getHdrCapabilities(const sp<IBinder>& display, |
| 507 | HdrCapabilities* outCapabilities) const { |
| 508 | Parcel data, reply; |
| 509 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 510 | status_t result = data.writeStrongBinder(display); |
| 511 | if (result != NO_ERROR) { |
| 512 | ALOGE("getHdrCapabilities failed to writeStrongBinder: %d", result); |
| 513 | return result; |
| 514 | } |
| 515 | result = remote()->transact(BnSurfaceComposer::GET_HDR_CAPABILITIES, |
| 516 | data, &reply); |
| 517 | if (result != NO_ERROR) { |
| 518 | ALOGE("getHdrCapabilities failed to transact: %d", result); |
| 519 | return result; |
| 520 | } |
| 521 | result = reply.readInt32(); |
| 522 | if (result == NO_ERROR) { |
Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 523 | result = reply.read(*outCapabilities); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 524 | } |
| 525 | return result; |
| 526 | } |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 527 | |
| 528 | virtual status_t enableVSyncInjections(bool enable) { |
| 529 | Parcel data, reply; |
| 530 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 531 | if (result != NO_ERROR) { |
| 532 | ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result); |
| 533 | return result; |
| 534 | } |
| 535 | result = data.writeBool(enable); |
| 536 | if (result != NO_ERROR) { |
| 537 | ALOGE("enableVSyncInjections failed to writeBool: %d", result); |
| 538 | return result; |
| 539 | } |
| 540 | result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, |
| 541 | data, &reply, TF_ONE_WAY); |
| 542 | if (result != NO_ERROR) { |
| 543 | ALOGE("enableVSyncInjections failed to transact: %d", result); |
| 544 | return result; |
| 545 | } |
| 546 | return result; |
| 547 | } |
| 548 | |
| 549 | virtual status_t injectVSync(nsecs_t when) { |
| 550 | Parcel data, reply; |
| 551 | status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 552 | if (result != NO_ERROR) { |
| 553 | ALOGE("injectVSync failed to writeInterfaceToken: %d", result); |
| 554 | return result; |
| 555 | } |
| 556 | result = data.writeInt64(when); |
| 557 | if (result != NO_ERROR) { |
| 558 | ALOGE("injectVSync failed to writeInt64: %d", result); |
| 559 | return result; |
| 560 | } |
| 561 | result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply, TF_ONE_WAY); |
| 562 | if (result != NO_ERROR) { |
| 563 | ALOGE("injectVSync failed to transact: %d", result); |
| 564 | return result; |
| 565 | } |
| 566 | return result; |
| 567 | } |
| 568 | |
Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 569 | virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const |
| 570 | { |
| 571 | if (!outLayers) { |
| 572 | return UNEXPECTED_NULL; |
| 573 | } |
| 574 | |
| 575 | Parcel data, reply; |
| 576 | |
| 577 | status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 578 | if (err != NO_ERROR) { |
| 579 | return err; |
| 580 | } |
| 581 | |
| 582 | err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply); |
| 583 | if (err != NO_ERROR) { |
| 584 | return err; |
| 585 | } |
| 586 | |
| 587 | int32_t result = 0; |
| 588 | err = reply.readInt32(&result); |
| 589 | if (err != NO_ERROR) { |
| 590 | return err; |
| 591 | } |
| 592 | if (result != NO_ERROR) { |
| 593 | return result; |
| 594 | } |
| 595 | |
| 596 | outLayers->clear(); |
| 597 | return reply.readParcelableVector(outLayers); |
| 598 | } |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 599 | |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 600 | virtual status_t getCompositionPreference(ui::Dataspace* defaultDataspace, |
| 601 | ui::PixelFormat* defaultPixelFormat, |
| 602 | ui::Dataspace* wideColorGamutDataspace, |
| 603 | ui::PixelFormat* wideColorGamutPixelFormat) const { |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 604 | Parcel data, reply; |
| 605 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 606 | if (error != NO_ERROR) { |
| 607 | return error; |
| 608 | } |
| 609 | error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply); |
| 610 | if (error != NO_ERROR) { |
| 611 | return error; |
| 612 | } |
| 613 | error = static_cast<status_t>(reply.readInt32()); |
| 614 | if (error == NO_ERROR) { |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 615 | *defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32()); |
| 616 | *defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); |
| 617 | *wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32()); |
| 618 | *wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 619 | } |
| 620 | return error; |
| 621 | } |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 622 | |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 623 | virtual status_t getColorManagement(bool* outGetColorManagement) const { |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 624 | Parcel data, reply; |
| 625 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 626 | remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply); |
| 627 | bool result; |
| 628 | status_t err = reply.readBool(&result); |
| 629 | if (err == NO_ERROR) { |
| 630 | *outGetColorManagement = result; |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 631 | } |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 632 | return err; |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 633 | } |
Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 634 | |
| 635 | virtual status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display, |
| 636 | ui::PixelFormat* outFormat, |
| 637 | ui::Dataspace* outDataspace, |
| 638 | uint8_t* outComponentMask) const { |
| 639 | if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE; |
| 640 | Parcel data, reply; |
| 641 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 642 | data.writeStrongBinder(display); |
| 643 | |
| 644 | status_t error = |
| 645 | remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES, |
| 646 | data, &reply); |
| 647 | if (error != NO_ERROR) { |
| 648 | return error; |
| 649 | } |
| 650 | |
| 651 | uint32_t value = 0; |
| 652 | error = reply.readUint32(&value); |
| 653 | if (error != NO_ERROR) { |
| 654 | return error; |
| 655 | } |
| 656 | *outFormat = static_cast<ui::PixelFormat>(value); |
| 657 | |
| 658 | error = reply.readUint32(&value); |
| 659 | if (error != NO_ERROR) { |
| 660 | return error; |
| 661 | } |
| 662 | *outDataspace = static_cast<ui::Dataspace>(value); |
| 663 | |
| 664 | error = reply.readUint32(&value); |
| 665 | if (error != NO_ERROR) { |
| 666 | return error; |
| 667 | } |
| 668 | *outComponentMask = static_cast<uint8_t>(value); |
| 669 | return error; |
| 670 | } |
Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 671 | |
| 672 | virtual status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable, |
| 673 | uint8_t componentMask, |
| 674 | uint64_t maxFrames) const { |
| 675 | Parcel data, reply; |
| 676 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 677 | data.writeStrongBinder(display); |
| 678 | data.writeBool(enable); |
| 679 | data.writeByte(static_cast<int8_t>(componentMask)); |
| 680 | data.writeUint64(maxFrames); |
| 681 | status_t result = |
| 682 | remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data, |
| 683 | &reply); |
| 684 | return result; |
| 685 | } |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 686 | |
| 687 | virtual status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames, |
| 688 | uint64_t timestamp, |
| 689 | DisplayedFrameStats* outStats) const { |
| 690 | if (!outStats) return BAD_VALUE; |
| 691 | |
| 692 | Parcel data, reply; |
| 693 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 694 | data.writeStrongBinder(display); |
| 695 | data.writeUint64(maxFrames); |
| 696 | data.writeUint64(timestamp); |
| 697 | |
| 698 | status_t result = |
| 699 | remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply); |
| 700 | |
| 701 | if (result != NO_ERROR) { |
| 702 | return result; |
| 703 | } |
| 704 | |
| 705 | result = reply.readUint64(&outStats->numFrames); |
| 706 | if (result != NO_ERROR) { |
| 707 | return result; |
| 708 | } |
| 709 | |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 710 | result = reply.readUint64Vector(&outStats->component_0_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 711 | if (result != NO_ERROR) { |
| 712 | return result; |
| 713 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 714 | result = reply.readUint64Vector(&outStats->component_1_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 715 | if (result != NO_ERROR) { |
| 716 | return result; |
| 717 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 718 | result = reply.readUint64Vector(&outStats->component_2_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 719 | if (result != NO_ERROR) { |
| 720 | return result; |
| 721 | } |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 722 | result = reply.readUint64Vector(&outStats->component_3_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 723 | return result; |
| 724 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 725 | |
| 726 | virtual status_t getProtectedContentSupport(bool* outSupported) const { |
| 727 | Parcel data, reply; |
| 728 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Peiyong Lin | b6888fa | 2019-01-28 13:20:58 -0800 | [diff] [blame] | 729 | status_t error = |
| 730 | remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply); |
| 731 | if (error != NO_ERROR) { |
| 732 | return error; |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 733 | } |
Peiyong Lin | b6888fa | 2019-01-28 13:20:58 -0800 | [diff] [blame] | 734 | error = reply.readBool(outSupported); |
| 735 | return error; |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 736 | } |
Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 737 | |
| 738 | virtual status_t cacheBuffer(const sp<IBinder>& token, const sp<GraphicBuffer>& buffer, |
| 739 | int32_t* outBufferId) { |
| 740 | Parcel data, reply; |
| 741 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 742 | |
| 743 | data.writeStrongBinder(token); |
| 744 | if (buffer) { |
| 745 | data.writeBool(true); |
| 746 | data.write(*buffer); |
| 747 | } else { |
| 748 | data.writeBool(false); |
| 749 | } |
| 750 | |
| 751 | status_t result = remote()->transact(BnSurfaceComposer::CACHE_BUFFER, data, &reply); |
| 752 | if (result != NO_ERROR) { |
| 753 | return result; |
| 754 | } |
| 755 | |
| 756 | int32_t id = -1; |
| 757 | result = reply.readInt32(&id); |
| 758 | if (result == NO_ERROR) { |
| 759 | *outBufferId = id; |
| 760 | } |
| 761 | return result; |
| 762 | } |
| 763 | |
| 764 | virtual status_t uncacheBuffer(const sp<IBinder>& token, int32_t bufferId) { |
| 765 | Parcel data, reply; |
| 766 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 767 | |
| 768 | data.writeStrongBinder(token); |
| 769 | data.writeInt32(bufferId); |
| 770 | |
| 771 | return remote()->transact(BnSurfaceComposer::UNCACHE_BUFFER, data, &reply); |
| 772 | } |
Peiyong Lin | 4f3fddf | 2019-01-24 17:21:24 -0800 | [diff] [blame] | 773 | |
| 774 | virtual status_t isWideColorDisplay(const sp<IBinder>& token, |
| 775 | bool* outIsWideColorDisplay) const { |
| 776 | Parcel data, reply; |
| 777 | status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
| 778 | if (error != NO_ERROR) { |
| 779 | return error; |
| 780 | } |
| 781 | error = data.writeStrongBinder(token); |
| 782 | if (error != NO_ERROR) { |
| 783 | return error; |
| 784 | } |
| 785 | |
| 786 | error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply); |
| 787 | if (error != NO_ERROR) { |
| 788 | return error; |
| 789 | } |
| 790 | error = reply.readBool(outIsWideColorDisplay); |
| 791 | return error; |
| 792 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 793 | }; |
| 794 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 795 | // Out-of-line virtual method definition to trigger vtable emission in this |
| 796 | // translation unit (see clang warning -Wweak-vtables) |
| 797 | BpSurfaceComposer::~BpSurfaceComposer() {} |
| 798 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 799 | IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer"); |
| 800 | |
| 801 | // ---------------------------------------------------------------------- |
| 802 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 803 | status_t BnSurfaceComposer::onTransact( |
| 804 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 805 | { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 806 | switch(code) { |
| 807 | case CREATE_CONNECTION: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 808 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 809 | sp<IBinder> b = IInterface::asBinder(createConnection()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 810 | reply->writeStrongBinder(b); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 811 | return NO_ERROR; |
| 812 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 813 | case SET_TRANSACTION_STATE: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 814 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 815 | |
| 816 | size_t count = data.readUint32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 817 | if (count > data.dataSize()) { |
| 818 | return BAD_VALUE; |
| 819 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 820 | Vector<ComposerState> state; |
| 821 | state.setCapacity(count); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 822 | for (size_t i = 0; i < count; i++) { |
Marissa Wall | c837b5e | 2018-10-12 10:04:44 -0700 | [diff] [blame] | 823 | ComposerState s; |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 824 | if (s.read(data) == BAD_VALUE) { |
| 825 | return BAD_VALUE; |
| 826 | } |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 827 | state.add(s); |
| 828 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 829 | |
| 830 | count = data.readUint32(); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 831 | if (count > data.dataSize()) { |
| 832 | return BAD_VALUE; |
| 833 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 834 | DisplayState d; |
| 835 | Vector<DisplayState> displays; |
| 836 | displays.setCapacity(count); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 837 | for (size_t i = 0; i < count; i++) { |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 838 | if (d.read(data) == BAD_VALUE) { |
| 839 | return BAD_VALUE; |
| 840 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 841 | displays.add(d); |
| 842 | } |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 843 | |
| 844 | uint32_t stateFlags = data.readUint32(); |
Marissa Wall | 713b63f | 2018-10-17 15:42:43 -0700 | [diff] [blame] | 845 | sp<IBinder> applyToken = data.readStrongBinder(); |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 846 | InputWindowCommands inputWindowCommands; |
| 847 | inputWindowCommands.read(data); |
Marissa Wall | 17b4e45 | 2018-12-26 16:32:34 -0800 | [diff] [blame] | 848 | |
| 849 | int64_t desiredPresentTime = data.readInt64(); |
| 850 | setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands, |
| 851 | desiredPresentTime); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 852 | return NO_ERROR; |
| 853 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 854 | case BOOT_FINISHED: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 855 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 856 | bootFinished(); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 857 | return NO_ERROR; |
| 858 | } |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 859 | case CAPTURE_SCREEN: { |
| 860 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 861 | sp<IBinder> display = data.readStrongBinder(); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 862 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); |
| 863 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 864 | sp<GraphicBuffer> outBuffer; |
Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 865 | Rect sourceCrop(Rect::EMPTY_RECT); |
Dan Stoza | c187900 | 2014-05-22 15:59:05 -0700 | [diff] [blame] | 866 | data.read(sourceCrop); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 867 | uint32_t reqWidth = data.readUint32(); |
| 868 | uint32_t reqHeight = data.readUint32(); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 869 | bool useIdentityTransform = static_cast<bool>(data.readInt32()); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 870 | int32_t rotation = data.readInt32(); |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 871 | |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 872 | status_t res = captureScreen(display, &outBuffer, reqDataspace, reqPixelFormat, |
| 873 | sourceCrop, reqWidth, reqHeight, useIdentityTransform, |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 874 | static_cast<ISurfaceComposer::Rotation>(rotation)); |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 875 | reply->writeInt32(res); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 876 | if (res == NO_ERROR) { |
| 877 | reply->write(*outBuffer); |
| 878 | } |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 879 | return NO_ERROR; |
| 880 | } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 881 | case CAPTURE_LAYERS: { |
| 882 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 883 | sp<IBinder> layerHandleBinder = data.readStrongBinder(); |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 884 | ui::Dataspace reqDataspace = static_cast<ui::Dataspace>(data.readInt32()); |
| 885 | ui::PixelFormat reqPixelFormat = static_cast<ui::PixelFormat>(data.readInt32()); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 886 | sp<GraphicBuffer> outBuffer; |
chaviw | 7206d49 | 2017-11-10 16:16:12 -0800 | [diff] [blame] | 887 | Rect sourceCrop(Rect::EMPTY_RECT); |
| 888 | data.read(sourceCrop); |
| 889 | float frameScale = data.readFloat(); |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 890 | bool childrenOnly = data.readBool(); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 891 | |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 892 | status_t res = captureLayers(layerHandleBinder, &outBuffer, reqDataspace, |
| 893 | reqPixelFormat, sourceCrop, frameScale, childrenOnly); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 894 | reply->writeInt32(res); |
Chavi Weingarten | 40482ff | 2017-11-30 01:51:40 +0000 | [diff] [blame] | 895 | if (res == NO_ERROR) { |
| 896 | reply->write(*outBuffer); |
| 897 | } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 898 | return NO_ERROR; |
| 899 | } |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 900 | case AUTHENTICATE_SURFACE: { |
| 901 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 902 | sp<IGraphicBufferProducer> bufferProducer = |
| 903 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); |
| 904 | int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0; |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 905 | reply->writeInt32(result); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 906 | return NO_ERROR; |
| 907 | } |
Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 908 | case GET_SUPPORTED_FRAME_TIMESTAMPS: { |
| 909 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 910 | std::vector<FrameEvent> supportedTimestamps; |
| 911 | status_t result = getSupportedFrameTimestamps(&supportedTimestamps); |
| 912 | status_t err = reply->writeInt32(result); |
| 913 | if (err != NO_ERROR) { |
| 914 | return err; |
| 915 | } |
| 916 | if (result != NO_ERROR) { |
| 917 | return result; |
| 918 | } |
| 919 | |
| 920 | std::vector<int32_t> supported; |
| 921 | supported.reserve(supportedTimestamps.size()); |
| 922 | for (FrameEvent s : supportedTimestamps) { |
| 923 | supported.push_back(static_cast<int32_t>(s)); |
| 924 | } |
| 925 | return reply->writeInt32Vector(supported); |
| 926 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 927 | case CREATE_DISPLAY_EVENT_CONNECTION: { |
| 928 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Jorim Jaggi | b1e2f8d | 2017-06-08 15:43:59 -0700 | [diff] [blame] | 929 | sp<IDisplayEventConnection> connection(createDisplayEventConnection( |
| 930 | static_cast<ISurfaceComposer::VsyncSource>(data.readInt32()))); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 931 | reply->writeStrongBinder(IInterface::asBinder(connection)); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 932 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 933 | } |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 934 | case CREATE_DISPLAY: { |
| 935 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 936 | String8 displayName = data.readString8(); |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 937 | bool secure = bool(data.readInt32()); |
| 938 | sp<IBinder> display(createDisplay(displayName, secure)); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 939 | reply->writeStrongBinder(display); |
| 940 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 941 | } |
| 942 | case DESTROY_DISPLAY: { |
| 943 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 944 | sp<IBinder> display = data.readStrongBinder(); |
| 945 | destroyDisplay(display); |
| 946 | return NO_ERROR; |
| 947 | } |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame^] | 948 | case GET_PHYSICAL_DISPLAY_TOKEN: { |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 949 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame^] | 950 | PhysicalDisplayId displayId = data.readUint64(); |
| 951 | sp<IBinder> display = getPhysicalDisplayToken(displayId); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 952 | reply->writeStrongBinder(display); |
| 953 | return NO_ERROR; |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 954 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 955 | case GET_DISPLAY_CONFIGS: { |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 956 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 957 | Vector<DisplayInfo> configs; |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 958 | sp<IBinder> display = data.readStrongBinder(); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 959 | status_t result = getDisplayConfigs(display, &configs); |
| 960 | reply->writeInt32(result); |
| 961 | if (result == NO_ERROR) { |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 962 | reply->writeUint32(static_cast<uint32_t>(configs.size())); |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 963 | for (size_t c = 0; c < configs.size(); ++c) { |
| 964 | memcpy(reply->writeInplace(sizeof(DisplayInfo)), |
| 965 | &configs[c], sizeof(DisplayInfo)); |
| 966 | } |
| 967 | } |
| 968 | return NO_ERROR; |
| 969 | } |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 970 | case GET_DISPLAY_STATS: { |
| 971 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 972 | DisplayStatInfo stats; |
| 973 | sp<IBinder> display = data.readStrongBinder(); |
| 974 | status_t result = getDisplayStats(display, &stats); |
| 975 | reply->writeInt32(result); |
| 976 | if (result == NO_ERROR) { |
| 977 | memcpy(reply->writeInplace(sizeof(DisplayStatInfo)), |
| 978 | &stats, sizeof(DisplayStatInfo)); |
| 979 | } |
| 980 | return NO_ERROR; |
| 981 | } |
Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 982 | case GET_ACTIVE_CONFIG: { |
| 983 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 984 | sp<IBinder> display = data.readStrongBinder(); |
| 985 | int id = getActiveConfig(display); |
| 986 | reply->writeInt32(id); |
| 987 | return NO_ERROR; |
| 988 | } |
| 989 | case SET_ACTIVE_CONFIG: { |
| 990 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 991 | sp<IBinder> display = data.readStrongBinder(); |
| 992 | int id = data.readInt32(); |
| 993 | status_t result = setActiveConfig(display, id); |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 994 | reply->writeInt32(result); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 995 | return NO_ERROR; |
| 996 | } |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 997 | case GET_DISPLAY_COLOR_MODES: { |
| 998 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 999 | Vector<ColorMode> colorModes; |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1000 | sp<IBinder> display = nullptr; |
| 1001 | status_t result = data.readStrongBinder(&display); |
| 1002 | if (result != NO_ERROR) { |
| 1003 | ALOGE("getDisplayColorModes failed to readStrongBinder: %d", result); |
| 1004 | return result; |
| 1005 | } |
| 1006 | result = getDisplayColorModes(display, &colorModes); |
| 1007 | reply->writeInt32(result); |
| 1008 | if (result == NO_ERROR) { |
| 1009 | reply->writeUint32(static_cast<uint32_t>(colorModes.size())); |
| 1010 | for (size_t i = 0; i < colorModes.size(); ++i) { |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1011 | reply->writeInt32(static_cast<int32_t>(colorModes[i])); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1012 | } |
| 1013 | } |
| 1014 | return NO_ERROR; |
| 1015 | } |
Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame] | 1016 | case GET_DISPLAY_NATIVE_PRIMARIES: { |
| 1017 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1018 | ui::DisplayPrimaries primaries; |
| 1019 | sp<IBinder> display = nullptr; |
| 1020 | |
| 1021 | status_t result = data.readStrongBinder(&display); |
| 1022 | if (result != NO_ERROR) { |
| 1023 | ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result); |
| 1024 | return result; |
| 1025 | } |
| 1026 | |
| 1027 | result = getDisplayNativePrimaries(display, primaries); |
| 1028 | reply->writeInt32(result); |
| 1029 | if (result == NO_ERROR) { |
| 1030 | memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries, |
| 1031 | sizeof(ui::DisplayPrimaries)); |
| 1032 | } |
| 1033 | |
| 1034 | return NO_ERROR; |
| 1035 | } |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1036 | case GET_ACTIVE_COLOR_MODE: { |
| 1037 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1038 | sp<IBinder> display = nullptr; |
| 1039 | status_t result = data.readStrongBinder(&display); |
| 1040 | if (result != NO_ERROR) { |
| 1041 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); |
| 1042 | return result; |
| 1043 | } |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1044 | ColorMode colorMode = getActiveColorMode(display); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1045 | result = reply->writeInt32(static_cast<int32_t>(colorMode)); |
| 1046 | return result; |
| 1047 | } |
| 1048 | case SET_ACTIVE_COLOR_MODE: { |
| 1049 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1050 | sp<IBinder> display = nullptr; |
| 1051 | status_t result = data.readStrongBinder(&display); |
| 1052 | if (result != NO_ERROR) { |
| 1053 | ALOGE("getActiveColorMode failed to readStrongBinder: %d", result); |
| 1054 | return result; |
| 1055 | } |
| 1056 | int32_t colorModeInt = 0; |
| 1057 | result = data.readInt32(&colorModeInt); |
| 1058 | if (result != NO_ERROR) { |
| 1059 | ALOGE("setActiveColorMode failed to readInt32: %d", result); |
| 1060 | return result; |
| 1061 | } |
| 1062 | result = setActiveColorMode(display, |
Peiyong Lin | a52f029 | 2018-03-14 17:26:31 -0700 | [diff] [blame] | 1063 | static_cast<ColorMode>(colorModeInt)); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 1064 | result = reply->writeInt32(result); |
| 1065 | return result; |
| 1066 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 1067 | case CLEAR_ANIMATION_FRAME_STATS: { |
| 1068 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1069 | status_t result = clearAnimationFrameStats(); |
| 1070 | reply->writeInt32(result); |
| 1071 | return NO_ERROR; |
| 1072 | } |
| 1073 | case GET_ANIMATION_FRAME_STATS: { |
| 1074 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1075 | FrameStats stats; |
| 1076 | status_t result = getAnimationFrameStats(&stats); |
| 1077 | reply->write(stats); |
| 1078 | reply->writeInt32(result); |
| 1079 | return NO_ERROR; |
| 1080 | } |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 1081 | case SET_POWER_MODE: { |
| 1082 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1083 | sp<IBinder> display = data.readStrongBinder(); |
| 1084 | int32_t mode = data.readInt32(); |
| 1085 | setPowerMode(display, mode); |
| 1086 | return NO_ERROR; |
| 1087 | } |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 1088 | case GET_HDR_CAPABILITIES: { |
| 1089 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1090 | sp<IBinder> display = nullptr; |
| 1091 | status_t result = data.readStrongBinder(&display); |
| 1092 | if (result != NO_ERROR) { |
| 1093 | ALOGE("getHdrCapabilities failed to readStrongBinder: %d", |
| 1094 | result); |
| 1095 | return result; |
| 1096 | } |
| 1097 | HdrCapabilities capabilities; |
| 1098 | result = getHdrCapabilities(display, &capabilities); |
| 1099 | reply->writeInt32(result); |
| 1100 | if (result == NO_ERROR) { |
Mathias Agopian | e1f5e6f | 2017-02-06 16:34:41 -0800 | [diff] [blame] | 1101 | reply->write(capabilities); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 1102 | } |
| 1103 | return NO_ERROR; |
| 1104 | } |
Sahil Dhanju | c1ba5c4 | 2016-06-07 20:09:20 -0700 | [diff] [blame] | 1105 | case ENABLE_VSYNC_INJECTIONS: { |
| 1106 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1107 | bool enable = false; |
| 1108 | status_t result = data.readBool(&enable); |
| 1109 | if (result != NO_ERROR) { |
| 1110 | ALOGE("enableVSyncInjections failed to readBool: %d", result); |
| 1111 | return result; |
| 1112 | } |
| 1113 | return enableVSyncInjections(enable); |
| 1114 | } |
| 1115 | case INJECT_VSYNC: { |
| 1116 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1117 | int64_t when = 0; |
| 1118 | status_t result = data.readInt64(&when); |
| 1119 | if (result != NO_ERROR) { |
| 1120 | ALOGE("enableVSyncInjections failed to readInt64: %d", result); |
| 1121 | return result; |
| 1122 | } |
| 1123 | return injectVSync(when); |
| 1124 | } |
Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 1125 | case GET_LAYER_DEBUG_INFO: { |
| 1126 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1127 | std::vector<LayerDebugInfo> outLayers; |
| 1128 | status_t result = getLayerDebugInfo(&outLayers); |
| 1129 | reply->writeInt32(result); |
| 1130 | if (result == NO_ERROR) |
| 1131 | { |
| 1132 | result = reply->writeParcelableVector(outLayers); |
| 1133 | } |
| 1134 | return result; |
| 1135 | } |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1136 | case GET_COMPOSITION_PREFERENCE: { |
| 1137 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1138 | ui::Dataspace defaultDataspace; |
| 1139 | ui::PixelFormat defaultPixelFormat; |
| 1140 | ui::Dataspace wideColorGamutDataspace; |
| 1141 | ui::PixelFormat wideColorGamutPixelFormat; |
| 1142 | status_t error = |
| 1143 | getCompositionPreference(&defaultDataspace, &defaultPixelFormat, |
| 1144 | &wideColorGamutDataspace, &wideColorGamutPixelFormat); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1145 | reply->writeInt32(error); |
| 1146 | if (error == NO_ERROR) { |
Peiyong Lin | c678097 | 2018-10-28 15:24:08 -0700 | [diff] [blame] | 1147 | reply->writeInt32(static_cast<int32_t>(defaultDataspace)); |
| 1148 | reply->writeInt32(static_cast<int32_t>(defaultPixelFormat)); |
| 1149 | reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace)); |
Peiyong Lin | aa3da6a | 2018-12-12 02:48:43 -0800 | [diff] [blame] | 1150 | reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat)); |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1151 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1152 | return error; |
Peiyong Lin | 0256f72 | 2018-08-31 15:45:10 -0700 | [diff] [blame] | 1153 | } |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1154 | case GET_COLOR_MANAGEMENT: { |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1155 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Ady Abraham | 37965d4 | 2018-11-01 13:43:32 -0700 | [diff] [blame] | 1156 | bool result; |
| 1157 | status_t error = getColorManagement(&result); |
| 1158 | if (error == NO_ERROR) { |
| 1159 | reply->writeBool(result); |
| 1160 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1161 | return error; |
Ady Abraham | 2a6ab2a | 2018-10-26 14:25:30 -0700 | [diff] [blame] | 1162 | } |
Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 1163 | case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: { |
| 1164 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1165 | |
| 1166 | sp<IBinder> display = data.readStrongBinder(); |
| 1167 | ui::PixelFormat format; |
| 1168 | ui::Dataspace dataspace; |
| 1169 | uint8_t component = 0; |
| 1170 | auto result = |
| 1171 | getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component); |
| 1172 | if (result == NO_ERROR) { |
| 1173 | reply->writeUint32(static_cast<uint32_t>(format)); |
| 1174 | reply->writeUint32(static_cast<uint32_t>(dataspace)); |
| 1175 | reply->writeUint32(static_cast<uint32_t>(component)); |
| 1176 | } |
| 1177 | return result; |
| 1178 | } |
Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 1179 | case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: { |
| 1180 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1181 | |
| 1182 | sp<IBinder> display = nullptr; |
| 1183 | bool enable = false; |
| 1184 | int8_t componentMask = 0; |
| 1185 | uint64_t maxFrames = 0; |
| 1186 | status_t result = data.readStrongBinder(&display); |
| 1187 | if (result != NO_ERROR) { |
| 1188 | ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d", |
| 1189 | result); |
| 1190 | return result; |
| 1191 | } |
| 1192 | |
| 1193 | result = data.readBool(&enable); |
| 1194 | if (result != NO_ERROR) { |
| 1195 | ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result); |
| 1196 | return result; |
| 1197 | } |
| 1198 | |
| 1199 | result = data.readByte(static_cast<int8_t*>(&componentMask)); |
| 1200 | if (result != NO_ERROR) { |
| 1201 | ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d", |
| 1202 | result); |
| 1203 | return result; |
| 1204 | } |
| 1205 | |
| 1206 | result = data.readUint64(&maxFrames); |
| 1207 | if (result != NO_ERROR) { |
| 1208 | ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result); |
| 1209 | return result; |
| 1210 | } |
| 1211 | |
| 1212 | return setDisplayContentSamplingEnabled(display, enable, |
| 1213 | static_cast<uint8_t>(componentMask), maxFrames); |
| 1214 | } |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1215 | case GET_DISPLAYED_CONTENT_SAMPLE: { |
| 1216 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1217 | |
| 1218 | sp<IBinder> display = data.readStrongBinder(); |
| 1219 | uint64_t maxFrames = 0; |
| 1220 | uint64_t timestamp = 0; |
| 1221 | |
| 1222 | status_t result = data.readUint64(&maxFrames); |
| 1223 | if (result != NO_ERROR) { |
| 1224 | ALOGE("getDisplayedContentSample failure in reading max frames: %d", result); |
| 1225 | return result; |
| 1226 | } |
| 1227 | |
| 1228 | result = data.readUint64(×tamp); |
| 1229 | if (result != NO_ERROR) { |
| 1230 | ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result); |
| 1231 | return result; |
| 1232 | } |
| 1233 | |
| 1234 | DisplayedFrameStats stats; |
| 1235 | result = getDisplayedContentSample(display, maxFrames, timestamp, &stats); |
| 1236 | if (result == NO_ERROR) { |
| 1237 | reply->writeUint64(stats.numFrames); |
Kevin DuBois | 1d4c6a6 | 2018-12-12 13:59:46 -0800 | [diff] [blame] | 1238 | reply->writeUint64Vector(stats.component_0_sample); |
| 1239 | reply->writeUint64Vector(stats.component_1_sample); |
| 1240 | reply->writeUint64Vector(stats.component_2_sample); |
| 1241 | reply->writeUint64Vector(stats.component_3_sample); |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 1242 | } |
| 1243 | return result; |
| 1244 | } |
Peiyong Lin | 3c2791e | 2019-01-14 17:05:18 -0800 | [diff] [blame] | 1245 | case GET_PROTECTED_CONTENT_SUPPORT: { |
| 1246 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1247 | bool result; |
| 1248 | status_t error = getProtectedContentSupport(&result); |
| 1249 | if (error == NO_ERROR) { |
| 1250 | reply->writeBool(result); |
| 1251 | } |
| 1252 | return error; |
| 1253 | } |
Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 1254 | case CACHE_BUFFER: { |
| 1255 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1256 | sp<IBinder> token; |
| 1257 | status_t result = data.readStrongBinder(&token); |
| 1258 | if (result != NO_ERROR) { |
| 1259 | ALOGE("cache buffer failure in reading token: %d", result); |
| 1260 | return result; |
| 1261 | } |
| 1262 | |
| 1263 | sp<GraphicBuffer> buffer = new GraphicBuffer(); |
| 1264 | if (data.readBool()) { |
| 1265 | result = data.read(*buffer); |
| 1266 | if (result != NO_ERROR) { |
| 1267 | ALOGE("cache buffer failure in reading buffer: %d", result); |
| 1268 | return result; |
| 1269 | } |
| 1270 | } |
| 1271 | int32_t bufferId = -1; |
| 1272 | status_t error = cacheBuffer(token, buffer, &bufferId); |
| 1273 | if (error == NO_ERROR) { |
| 1274 | reply->writeInt32(bufferId); |
| 1275 | } |
| 1276 | return error; |
| 1277 | } |
| 1278 | case UNCACHE_BUFFER: { |
| 1279 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1280 | sp<IBinder> token; |
| 1281 | status_t result = data.readStrongBinder(&token); |
| 1282 | if (result != NO_ERROR) { |
| 1283 | ALOGE("uncache buffer failure in reading token: %d", result); |
| 1284 | return result; |
| 1285 | } |
| 1286 | |
| 1287 | int32_t bufferId = -1; |
| 1288 | result = data.readInt32(&bufferId); |
| 1289 | if (result != NO_ERROR) { |
| 1290 | ALOGE("uncache buffer failure in reading buffer id: %d", result); |
| 1291 | return result; |
| 1292 | } |
| 1293 | |
| 1294 | return uncacheBuffer(token, bufferId); |
| 1295 | } |
Peiyong Lin | 4f3fddf | 2019-01-24 17:21:24 -0800 | [diff] [blame] | 1296 | case IS_WIDE_COLOR_DISPLAY: { |
| 1297 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1298 | sp<IBinder> display = nullptr; |
| 1299 | status_t error = data.readStrongBinder(&display); |
| 1300 | if (error != NO_ERROR) { |
| 1301 | return error; |
| 1302 | } |
| 1303 | bool result; |
| 1304 | error = isWideColorDisplay(display, &result); |
| 1305 | if (error == NO_ERROR) { |
| 1306 | reply->writeBool(result); |
| 1307 | } |
| 1308 | return error; |
| 1309 | } |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame^] | 1310 | case GET_PHYSICAL_DISPLAY_IDS: { |
| 1311 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
| 1312 | return reply->writeUint64Vector(getPhysicalDisplayIds()); |
| 1313 | } |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1314 | default: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 1315 | return BBinder::onTransact(code, data, reply, flags); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 1316 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1317 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1318 | } |
| 1319 | |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame^] | 1320 | } // namespace android |