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