The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
Vishnu Nair | 217d8e6 | 2018-09-12 16:34:49 -0700 | [diff] [blame] | 17 | #define LOG_TAG "LayerState" |
| 18 | |
Garfield Tan | 8a3083e | 2018-12-03 13:21:07 -0800 | [diff] [blame] | 19 | #include <inttypes.h> |
| 20 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | #include <utils/Errors.h> |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 22 | #include <binder/Parcel.h> |
Mathias Agopian | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 23 | #include <gui/ISurfaceComposerClient.h> |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 24 | #include <gui/IGraphicBufferProducer.h> |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 25 | #include <gui/LayerState.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 27 | #include <cmath> |
| 28 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | namespace android { |
| 30 | |
| 31 | status_t layer_state_t::write(Parcel& output) const |
| 32 | { |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 33 | output.writeStrongBinder(surface); |
Garfield Tan | 8a3083e | 2018-12-03 13:21:07 -0800 | [diff] [blame] | 34 | output.writeUint64(what); |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 35 | output.writeFloat(x); |
| 36 | output.writeFloat(y); |
Robert Carr | ae06083 | 2016-11-28 10:51:00 -0800 | [diff] [blame] | 37 | output.writeInt32(z); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 38 | output.writeUint32(w); |
| 39 | output.writeUint32(h); |
| 40 | output.writeUint32(layerStack); |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 41 | output.writeFloat(alpha); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 42 | output.writeUint32(flags); |
| 43 | output.writeUint32(mask); |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 44 | *reinterpret_cast<layer_state_t::matrix22_t *>( |
| 45 | output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix; |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 46 | output.write(crop_legacy); |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 47 | output.writeStrongBinder(barrierHandle_legacy); |
Robert Carr | 1db73f6 | 2016-12-21 12:58:51 -0800 | [diff] [blame] | 48 | output.writeStrongBinder(reparentHandle); |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 49 | output.writeUint64(frameNumber_legacy); |
Robert Carr | c3574f7 | 2016-03-24 12:19:32 -0700 | [diff] [blame] | 50 | output.writeInt32(overrideScalingMode); |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 51 | output.writeStrongBinder(IInterface::asBinder(barrierGbp_legacy)); |
Robert Carr | db66e62 | 2017-04-10 16:55:57 -0700 | [diff] [blame] | 52 | output.writeStrongBinder(relativeLayerHandle); |
chaviw | 0617894 | 2017-07-27 10:25:59 -0700 | [diff] [blame] | 53 | output.writeStrongBinder(parentHandleForChild); |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 54 | output.writeFloat(color.r); |
| 55 | output.writeFloat(color.g); |
| 56 | output.writeFloat(color.b); |
Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 57 | #ifndef NO_INPUT |
| 58 | inputInfo.write(output); |
| 59 | #endif |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 60 | output.write(transparentRegion); |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 61 | output.writeUint32(transform); |
| 62 | output.writeBool(transformToDisplayInverse); |
| 63 | output.write(crop); |
Marissa Wall | 861616d | 2018-10-22 12:52:23 -0700 | [diff] [blame] | 64 | output.write(frame); |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 65 | if (buffer) { |
| 66 | output.writeBool(true); |
| 67 | output.write(*buffer); |
| 68 | } else { |
| 69 | output.writeBool(false); |
| 70 | } |
| 71 | if (acquireFence) { |
| 72 | output.writeBool(true); |
| 73 | output.write(*acquireFence); |
| 74 | } else { |
| 75 | output.writeBool(false); |
| 76 | } |
| 77 | output.writeUint32(static_cast<uint32_t>(dataspace)); |
| 78 | output.write(hdrMetadata); |
| 79 | output.write(surfaceDamageRegion); |
| 80 | output.writeInt32(api); |
| 81 | if (sidebandStream) { |
| 82 | output.writeBool(true); |
| 83 | output.writeNativeHandle(sidebandStream->handle()); |
| 84 | } else { |
| 85 | output.writeBool(false); |
| 86 | } |
| 87 | |
Peiyong Lin | d378863 | 2018-09-18 16:01:31 -0700 | [diff] [blame] | 88 | memcpy(output.writeInplace(16 * sizeof(float)), |
| 89 | colorTransform.asArray(), 16 * sizeof(float)); |
Lucas Dupin | 1b6531c | 2018-07-05 17:18:21 -0700 | [diff] [blame] | 90 | output.writeFloat(cornerRadius); |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame] | 91 | output.writeUint32(backgroundBlurRadius); |
Steven Moreland | 9d4ce9b | 2019-07-17 15:23:38 -0700 | [diff] [blame] | 92 | output.writeStrongBinder(cachedBuffer.token.promote()); |
Marissa Wall | 947d34e | 2019-03-29 14:03:53 -0700 | [diff] [blame] | 93 | output.writeUint64(cachedBuffer.id); |
Evan Rosky | 1f6d6d5 | 2018-12-06 10:47:26 -0800 | [diff] [blame] | 94 | output.writeParcelable(metadata); |
Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 95 | |
Valerie Hau | dd0b757 | 2019-01-29 14:59:27 -0800 | [diff] [blame] | 96 | output.writeFloat(bgColorAlpha); |
| 97 | output.writeUint32(static_cast<uint32_t>(bgColorDataspace)); |
Peiyong Lin | c502cb7 | 2019-03-01 15:00:23 -0800 | [diff] [blame] | 98 | output.writeBool(colorSpaceAgnostic); |
Valerie Hau | ed54efa | 2019-01-11 20:03:14 -0800 | [diff] [blame] | 99 | |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 100 | auto err = output.writeVectorSize(listeners); |
| 101 | if (err) { |
| 102 | return err; |
| 103 | } |
| 104 | |
| 105 | for (auto listener : listeners) { |
| 106 | err = output.writeStrongBinder(listener.transactionCompletedListener); |
| 107 | if (err) { |
| 108 | return err; |
| 109 | } |
| 110 | err = output.writeInt64Vector(listener.callbackIds); |
| 111 | if (err) { |
| 112 | return err; |
| 113 | } |
| 114 | } |
Vishnu Nair | 440992f | 2019-12-09 19:53:19 -0800 | [diff] [blame] | 115 | output.writeFloat(shadowRadius); |
Ana Krulec | c84d09b | 2019-11-02 23:10:29 +0100 | [diff] [blame] | 116 | output.writeInt32(frameRateSelectionPriority); |
Steven Thomas | 3172e20 | 2020-01-06 19:25:30 -0800 | [diff] [blame] | 117 | output.writeFloat(frameRate); |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 118 | output.writeByte(frameRateCompatibility); |
Vishnu Nair | 6213bd9 | 2020-05-08 17:42:25 -0700 | [diff] [blame] | 119 | output.writeUint32(fixedTransformHint); |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 120 | return NO_ERROR; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | status_t layer_state_t::read(const Parcel& input) |
| 124 | { |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 125 | surface = input.readStrongBinder(); |
Garfield Tan | 8a3083e | 2018-12-03 13:21:07 -0800 | [diff] [blame] | 126 | what = input.readUint64(); |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 127 | x = input.readFloat(); |
| 128 | y = input.readFloat(); |
Robert Carr | ae06083 | 2016-11-28 10:51:00 -0800 | [diff] [blame] | 129 | z = input.readInt32(); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 130 | w = input.readUint32(); |
| 131 | h = input.readUint32(); |
| 132 | layerStack = input.readUint32(); |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 133 | alpha = input.readFloat(); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 134 | flags = static_cast<uint8_t>(input.readUint32()); |
| 135 | mask = static_cast<uint8_t>(input.readUint32()); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 136 | const void* matrix_data = input.readInplace(sizeof(layer_state_t::matrix22_t)); |
| 137 | if (matrix_data) { |
| 138 | matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(matrix_data); |
| 139 | } else { |
| 140 | return BAD_VALUE; |
| 141 | } |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 142 | input.read(crop_legacy); |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 143 | barrierHandle_legacy = input.readStrongBinder(); |
Robert Carr | 1db73f6 | 2016-12-21 12:58:51 -0800 | [diff] [blame] | 144 | reparentHandle = input.readStrongBinder(); |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 145 | frameNumber_legacy = input.readUint64(); |
Robert Carr | c3574f7 | 2016-03-24 12:19:32 -0700 | [diff] [blame] | 146 | overrideScalingMode = input.readInt32(); |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 147 | barrierGbp_legacy = interface_cast<IGraphicBufferProducer>(input.readStrongBinder()); |
Robert Carr | db66e62 | 2017-04-10 16:55:57 -0700 | [diff] [blame] | 148 | relativeLayerHandle = input.readStrongBinder(); |
chaviw | 0617894 | 2017-07-27 10:25:59 -0700 | [diff] [blame] | 149 | parentHandleForChild = input.readStrongBinder(); |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 150 | color.r = input.readFloat(); |
| 151 | color.g = input.readFloat(); |
| 152 | color.b = input.readFloat(); |
Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 153 | |
| 154 | #ifndef NO_INPUT |
| 155 | inputInfo = InputWindowInfo::read(input); |
| 156 | #endif |
| 157 | |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 158 | input.read(transparentRegion); |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 159 | transform = input.readUint32(); |
| 160 | transformToDisplayInverse = input.readBool(); |
| 161 | input.read(crop); |
Marissa Wall | 861616d | 2018-10-22 12:52:23 -0700 | [diff] [blame] | 162 | input.read(frame); |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 163 | buffer = new GraphicBuffer(); |
| 164 | if (input.readBool()) { |
| 165 | input.read(*buffer); |
| 166 | } |
| 167 | acquireFence = new Fence(); |
| 168 | if (input.readBool()) { |
| 169 | input.read(*acquireFence); |
| 170 | } |
| 171 | dataspace = static_cast<ui::Dataspace>(input.readUint32()); |
| 172 | input.read(hdrMetadata); |
| 173 | input.read(surfaceDamageRegion); |
| 174 | api = input.readInt32(); |
| 175 | if (input.readBool()) { |
| 176 | sidebandStream = NativeHandle::create(input.readNativeHandle(), true); |
| 177 | } |
| 178 | |
Denis Hsu | 8f3da5e | 2020-07-15 09:31:21 +0800 | [diff] [blame^] | 179 | const void* color_transform_data = input.readInplace(16 * sizeof(float)); |
| 180 | if (color_transform_data) { |
| 181 | colorTransform = mat4(static_cast<const float*>(color_transform_data)); |
| 182 | } else { |
| 183 | return BAD_VALUE; |
| 184 | } |
Lucas Dupin | 1b6531c | 2018-07-05 17:18:21 -0700 | [diff] [blame] | 185 | cornerRadius = input.readFloat(); |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame] | 186 | backgroundBlurRadius = input.readUint32(); |
Steven Moreland | 9d4ce9b | 2019-07-17 15:23:38 -0700 | [diff] [blame] | 187 | cachedBuffer.token = input.readStrongBinder(); |
Marissa Wall | 947d34e | 2019-03-29 14:03:53 -0700 | [diff] [blame] | 188 | cachedBuffer.id = input.readUint64(); |
Evan Rosky | 1f6d6d5 | 2018-12-06 10:47:26 -0800 | [diff] [blame] | 189 | input.readParcelable(&metadata); |
Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 190 | |
Valerie Hau | dd0b757 | 2019-01-29 14:59:27 -0800 | [diff] [blame] | 191 | bgColorAlpha = input.readFloat(); |
| 192 | bgColorDataspace = static_cast<ui::Dataspace>(input.readUint32()); |
Peiyong Lin | c502cb7 | 2019-03-01 15:00:23 -0800 | [diff] [blame] | 193 | colorSpaceAgnostic = input.readBool(); |
Valerie Hau | ed54efa | 2019-01-11 20:03:14 -0800 | [diff] [blame] | 194 | |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 195 | int32_t numListeners = input.readInt32(); |
| 196 | listeners.clear(); |
| 197 | for (int i = 0; i < numListeners; i++) { |
| 198 | auto listener = input.readStrongBinder(); |
| 199 | std::vector<CallbackId> callbackIds; |
| 200 | input.readInt64Vector(&callbackIds); |
| 201 | listeners.emplace_back(listener, callbackIds); |
| 202 | } |
Vishnu Nair | 440992f | 2019-12-09 19:53:19 -0800 | [diff] [blame] | 203 | shadowRadius = input.readFloat(); |
Ana Krulec | c84d09b | 2019-11-02 23:10:29 +0100 | [diff] [blame] | 204 | frameRateSelectionPriority = input.readInt32(); |
Steven Thomas | 3172e20 | 2020-01-06 19:25:30 -0800 | [diff] [blame] | 205 | frameRate = input.readFloat(); |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 206 | frameRateCompatibility = input.readByte(); |
Vishnu Nair | 6213bd9 | 2020-05-08 17:42:25 -0700 | [diff] [blame] | 207 | fixedTransformHint = static_cast<ui::Transform::RotationFlags>(input.readUint32()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 208 | return NO_ERROR; |
| 209 | } |
| 210 | |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 211 | status_t ComposerState::write(Parcel& output) const { |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 212 | return state.write(output); |
| 213 | } |
| 214 | |
| 215 | status_t ComposerState::read(const Parcel& input) { |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 216 | return state.read(input); |
| 217 | } |
| 218 | |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 219 | |
Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 220 | DisplayState::DisplayState() : |
| 221 | what(0), |
| 222 | layerStack(0), |
Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 223 | viewport(Rect::EMPTY_RECT), |
| 224 | frame(Rect::EMPTY_RECT), |
| 225 | width(0), |
| 226 | height(0) { |
| 227 | } |
| 228 | |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 229 | status_t DisplayState::write(Parcel& output) const { |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 230 | output.writeStrongBinder(token); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 231 | output.writeStrongBinder(IInterface::asBinder(surface)); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 232 | output.writeUint32(what); |
| 233 | output.writeUint32(layerStack); |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 234 | output.writeUint32(toRotationInt(orientation)); |
Mathias Agopian | 8683fca | 2012-08-12 19:37:16 -0700 | [diff] [blame] | 235 | output.write(viewport); |
| 236 | output.write(frame); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 237 | output.writeUint32(width); |
| 238 | output.writeUint32(height); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 239 | return NO_ERROR; |
| 240 | } |
| 241 | |
| 242 | status_t DisplayState::read(const Parcel& input) { |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 243 | token = input.readStrongBinder(); |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 244 | surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder()); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 245 | what = input.readUint32(); |
| 246 | layerStack = input.readUint32(); |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 247 | orientation = ui::toRotation(input.readUint32()); |
Mathias Agopian | 8683fca | 2012-08-12 19:37:16 -0700 | [diff] [blame] | 248 | input.read(viewport); |
| 249 | input.read(frame); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 250 | width = input.readUint32(); |
| 251 | height = input.readUint32(); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 252 | return NO_ERROR; |
| 253 | } |
| 254 | |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 255 | void DisplayState::merge(const DisplayState& other) { |
| 256 | if (other.what & eSurfaceChanged) { |
| 257 | what |= eSurfaceChanged; |
| 258 | surface = other.surface; |
| 259 | } |
| 260 | if (other.what & eLayerStackChanged) { |
| 261 | what |= eLayerStackChanged; |
| 262 | layerStack = other.layerStack; |
| 263 | } |
| 264 | if (other.what & eDisplayProjectionChanged) { |
| 265 | what |= eDisplayProjectionChanged; |
| 266 | orientation = other.orientation; |
| 267 | viewport = other.viewport; |
| 268 | frame = other.frame; |
| 269 | } |
| 270 | if (other.what & eDisplaySizeChanged) { |
| 271 | what |= eDisplaySizeChanged; |
| 272 | width = other.width; |
| 273 | height = other.height; |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | void layer_state_t::merge(const layer_state_t& other) { |
| 278 | if (other.what & ePositionChanged) { |
| 279 | what |= ePositionChanged; |
| 280 | x = other.x; |
| 281 | y = other.y; |
| 282 | } |
| 283 | if (other.what & eLayerChanged) { |
| 284 | what |= eLayerChanged; |
chaviw | 3237758 | 2019-05-13 11:15:19 -0700 | [diff] [blame] | 285 | what &= ~eRelativeLayerChanged; |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 286 | z = other.z; |
| 287 | } |
| 288 | if (other.what & eSizeChanged) { |
| 289 | what |= eSizeChanged; |
| 290 | w = other.w; |
| 291 | h = other.h; |
| 292 | } |
| 293 | if (other.what & eAlphaChanged) { |
| 294 | what |= eAlphaChanged; |
| 295 | alpha = other.alpha; |
| 296 | } |
| 297 | if (other.what & eMatrixChanged) { |
| 298 | what |= eMatrixChanged; |
| 299 | matrix = other.matrix; |
| 300 | } |
| 301 | if (other.what & eTransparentRegionChanged) { |
| 302 | what |= eTransparentRegionChanged; |
| 303 | transparentRegion = other.transparentRegion; |
| 304 | } |
| 305 | if (other.what & eFlagsChanged) { |
| 306 | what |= eFlagsChanged; |
Vishnu Nair | 996bc42 | 2019-07-16 14:15:33 -0700 | [diff] [blame] | 307 | flags &= ~other.mask; |
| 308 | flags |= (other.flags & other.mask); |
| 309 | mask |= other.mask; |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 310 | } |
| 311 | if (other.what & eLayerStackChanged) { |
| 312 | what |= eLayerStackChanged; |
| 313 | layerStack = other.layerStack; |
| 314 | } |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 315 | if (other.what & eCropChanged_legacy) { |
| 316 | what |= eCropChanged_legacy; |
| 317 | crop_legacy = other.crop_legacy; |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 318 | } |
Lucas Dupin | 1b6531c | 2018-07-05 17:18:21 -0700 | [diff] [blame] | 319 | if (other.what & eCornerRadiusChanged) { |
| 320 | what |= eCornerRadiusChanged; |
| 321 | cornerRadius = other.cornerRadius; |
| 322 | } |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame] | 323 | if (other.what & eBackgroundBlurRadiusChanged) { |
| 324 | what |= eBackgroundBlurRadiusChanged; |
| 325 | backgroundBlurRadius = other.backgroundBlurRadius; |
| 326 | } |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 327 | if (other.what & eDeferTransaction_legacy) { |
| 328 | what |= eDeferTransaction_legacy; |
| 329 | barrierHandle_legacy = other.barrierHandle_legacy; |
| 330 | barrierGbp_legacy = other.barrierGbp_legacy; |
| 331 | frameNumber_legacy = other.frameNumber_legacy; |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 332 | } |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 333 | if (other.what & eOverrideScalingModeChanged) { |
| 334 | what |= eOverrideScalingModeChanged; |
| 335 | overrideScalingMode = other.overrideScalingMode; |
| 336 | } |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 337 | if (other.what & eReparentChildren) { |
| 338 | what |= eReparentChildren; |
| 339 | reparentHandle = other.reparentHandle; |
| 340 | } |
| 341 | if (other.what & eDetachChildren) { |
| 342 | what |= eDetachChildren; |
| 343 | } |
| 344 | if (other.what & eRelativeLayerChanged) { |
| 345 | what |= eRelativeLayerChanged; |
chaviw | 3237758 | 2019-05-13 11:15:19 -0700 | [diff] [blame] | 346 | what &= ~eLayerChanged; |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 347 | z = other.z; |
| 348 | relativeLayerHandle = other.relativeLayerHandle; |
| 349 | } |
| 350 | if (other.what & eReparent) { |
| 351 | what |= eReparent; |
| 352 | parentHandleForChild = other.parentHandleForChild; |
| 353 | } |
chaviw | ca27f25 | 2018-02-06 16:46:39 -0800 | [diff] [blame] | 354 | if (other.what & eDestroySurface) { |
| 355 | what |= eDestroySurface; |
| 356 | } |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 357 | if (other.what & eTransformChanged) { |
| 358 | what |= eTransformChanged; |
| 359 | transform = other.transform; |
| 360 | } |
| 361 | if (other.what & eTransformToDisplayInverseChanged) { |
| 362 | what |= eTransformToDisplayInverseChanged; |
| 363 | transformToDisplayInverse = other.transformToDisplayInverse; |
| 364 | } |
| 365 | if (other.what & eCropChanged) { |
| 366 | what |= eCropChanged; |
| 367 | crop = other.crop; |
| 368 | } |
Marissa Wall | 861616d | 2018-10-22 12:52:23 -0700 | [diff] [blame] | 369 | if (other.what & eFrameChanged) { |
| 370 | what |= eFrameChanged; |
| 371 | frame = other.frame; |
| 372 | } |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 373 | if (other.what & eBufferChanged) { |
| 374 | what |= eBufferChanged; |
| 375 | buffer = other.buffer; |
| 376 | } |
| 377 | if (other.what & eAcquireFenceChanged) { |
| 378 | what |= eAcquireFenceChanged; |
| 379 | acquireFence = other.acquireFence; |
| 380 | } |
| 381 | if (other.what & eDataspaceChanged) { |
| 382 | what |= eDataspaceChanged; |
| 383 | dataspace = other.dataspace; |
| 384 | } |
| 385 | if (other.what & eHdrMetadataChanged) { |
| 386 | what |= eHdrMetadataChanged; |
| 387 | hdrMetadata = other.hdrMetadata; |
| 388 | } |
| 389 | if (other.what & eSurfaceDamageRegionChanged) { |
| 390 | what |= eSurfaceDamageRegionChanged; |
| 391 | surfaceDamageRegion = other.surfaceDamageRegion; |
| 392 | } |
| 393 | if (other.what & eApiChanged) { |
| 394 | what |= eApiChanged; |
| 395 | api = other.api; |
| 396 | } |
| 397 | if (other.what & eSidebandStreamChanged) { |
| 398 | what |= eSidebandStreamChanged; |
| 399 | sidebandStream = other.sidebandStream; |
| 400 | } |
Peiyong Lin | d378863 | 2018-09-18 16:01:31 -0700 | [diff] [blame] | 401 | if (other.what & eColorTransformChanged) { |
| 402 | what |= eColorTransformChanged; |
| 403 | colorTransform = other.colorTransform; |
| 404 | } |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame] | 405 | if (other.what & eHasListenerCallbacksChanged) { |
| 406 | what |= eHasListenerCallbacksChanged; |
Marissa Wall | c837b5e | 2018-10-12 10:04:44 -0700 | [diff] [blame] | 407 | } |
Robert Carr | d314f16 | 2018-08-15 13:12:42 -0700 | [diff] [blame] | 408 | |
Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 409 | #ifndef NO_INPUT |
| 410 | if (other.what & eInputInfoChanged) { |
| 411 | what |= eInputInfoChanged; |
| 412 | inputInfo = other.inputInfo; |
| 413 | } |
| 414 | #endif |
| 415 | |
Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 416 | if (other.what & eCachedBufferChanged) { |
| 417 | what |= eCachedBufferChanged; |
| 418 | cachedBuffer = other.cachedBuffer; |
| 419 | } |
Valerie Hau | dd0b757 | 2019-01-29 14:59:27 -0800 | [diff] [blame] | 420 | if (other.what & eBackgroundColorChanged) { |
| 421 | what |= eBackgroundColorChanged; |
| 422 | color = other.color; |
| 423 | bgColorAlpha = other.bgColorAlpha; |
| 424 | bgColorDataspace = other.bgColorDataspace; |
Valerie Hau | ed54efa | 2019-01-11 20:03:14 -0800 | [diff] [blame] | 425 | } |
Evan Rosky | 1f6d6d5 | 2018-12-06 10:47:26 -0800 | [diff] [blame] | 426 | if (other.what & eMetadataChanged) { |
| 427 | what |= eMetadataChanged; |
| 428 | metadata.merge(other.metadata); |
| 429 | } |
Vishnu Nair | c97b8db | 2019-10-29 18:19:35 -0700 | [diff] [blame] | 430 | if (other.what & eShadowRadiusChanged) { |
| 431 | what |= eShadowRadiusChanged; |
| 432 | shadowRadius = other.shadowRadius; |
| 433 | } |
Ana Krulec | c84d09b | 2019-11-02 23:10:29 +0100 | [diff] [blame] | 434 | if (other.what & eFrameRateSelectionPriority) { |
| 435 | what |= eFrameRateSelectionPriority; |
| 436 | frameRateSelectionPriority = other.frameRateSelectionPriority; |
| 437 | } |
Steven Thomas | 3172e20 | 2020-01-06 19:25:30 -0800 | [diff] [blame] | 438 | if (other.what & eFrameRateChanged) { |
| 439 | what |= eFrameRateChanged; |
| 440 | frameRate = other.frameRate; |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 441 | frameRateCompatibility = other.frameRateCompatibility; |
Steven Thomas | 3172e20 | 2020-01-06 19:25:30 -0800 | [diff] [blame] | 442 | } |
Vishnu Nair | 6213bd9 | 2020-05-08 17:42:25 -0700 | [diff] [blame] | 443 | if (other.what & eFixedTransformHintChanged) { |
| 444 | what |= eFixedTransformHintChanged; |
| 445 | fixedTransformHint = other.fixedTransformHint; |
| 446 | } |
Vishnu Nair | 217d8e6 | 2018-09-12 16:34:49 -0700 | [diff] [blame] | 447 | if ((other.what & what) != other.what) { |
| 448 | ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? " |
Garfield Tan | 8a3083e | 2018-12-03 13:21:07 -0800 | [diff] [blame] | 449 | "other.what=0x%" PRIu64 " what=0x%" PRIu64, |
Vishnu Nair | 217d8e6 | 2018-09-12 16:34:49 -0700 | [diff] [blame] | 450 | other.what, what); |
Robert Carr | d314f16 | 2018-08-15 13:12:42 -0700 | [diff] [blame] | 451 | } |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 452 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 453 | |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 454 | // ------------------------------- InputWindowCommands ---------------------------------------- |
| 455 | |
| 456 | void InputWindowCommands::merge(const InputWindowCommands& other) { |
chaviw | a911b10 | 2019-02-14 10:18:33 -0800 | [diff] [blame] | 457 | syncInputWindows |= other.syncInputWindows; |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | void InputWindowCommands::clear() { |
chaviw | a911b10 | 2019-02-14 10:18:33 -0800 | [diff] [blame] | 461 | syncInputWindows = false; |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | void InputWindowCommands::write(Parcel& output) const { |
chaviw | a911b10 | 2019-02-14 10:18:33 -0800 | [diff] [blame] | 465 | output.writeBool(syncInputWindows); |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | void InputWindowCommands::read(const Parcel& input) { |
chaviw | a911b10 | 2019-02-14 10:18:33 -0800 | [diff] [blame] | 469 | syncInputWindows = input.readBool(); |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 470 | } |
| 471 | |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 472 | bool ValidateFrameRate(float frameRate, int8_t compatibility, const char* inFunctionName) { |
| 473 | const char* functionName = inFunctionName != nullptr ? inFunctionName : "call"; |
| 474 | int floatClassification = std::fpclassify(frameRate); |
| 475 | if (frameRate < 0 || floatClassification == FP_INFINITE || floatClassification == FP_NAN) { |
| 476 | ALOGE("%s failed - invalid frame rate %f", functionName, frameRate); |
| 477 | return false; |
| 478 | } |
| 479 | |
| 480 | if (compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT && |
| 481 | compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE) { |
| 482 | ALOGE("%s failed - invalid compatibility value %d", functionName, compatibility); |
| 483 | return false; |
| 484 | } |
| 485 | |
| 486 | return true; |
| 487 | } |
| 488 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 489 | }; // namespace android |