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