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 | |
Dominik Laskowski | 1f6fc70 | 2022-03-21 08:34:50 -0700 | [diff] [blame] | 19 | #include <cinttypes> |
| 20 | #include <cmath> |
Garfield Tan | 8a3083e | 2018-12-03 13:21:07 -0800 | [diff] [blame] | 21 | |
Huihong Luo | d3d8f8e | 2022-03-08 14:48:46 -0800 | [diff] [blame] | 22 | #include <android/gui/ISurfaceComposerClient.h> |
Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 23 | #include <android/native_window.h> |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 24 | #include <binder/Parcel.h> |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 25 | #include <gui/IGraphicBufferProducer.h> |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 26 | #include <gui/LayerState.h> |
Vishnu Nair | aa799bd | 2022-11-16 23:09:09 +0000 | [diff] [blame^] | 27 | #include <gui/SurfaceControl.h> |
Marin Shalamanov | 3b1f7bc | 2021-03-16 15:51:53 +0100 | [diff] [blame] | 28 | #include <private/gui/ParcelUtils.h> |
Dominik Laskowski | 1f6fc70 | 2022-03-21 08:34:50 -0700 | [diff] [blame] | 29 | #include <system/window.h> |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 30 | #include <utils/Errors.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | |
Vishnu Nair | aa799bd | 2022-11-16 23:09:09 +0000 | [diff] [blame^] | 32 | #define CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD) \ |
| 33 | { \ |
| 34 | if ((OTHER.what & CHANGE_FLAG) && (FIELD != OTHER.FIELD)) { \ |
| 35 | DIFF_RESULT |= CHANGE_FLAG; \ |
| 36 | } \ |
| 37 | } |
| 38 | |
| 39 | #define CHECK_DIFF2(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1, FIELD2) \ |
| 40 | { \ |
| 41 | CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1) \ |
| 42 | CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD2) \ |
| 43 | } |
| 44 | |
| 45 | #define CHECK_DIFF3(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1, FIELD2, FIELD3) \ |
| 46 | { \ |
| 47 | CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1) \ |
| 48 | CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD2) \ |
| 49 | CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD3) \ |
| 50 | } |
| 51 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | namespace android { |
| 53 | |
chaviw | 98318de | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 54 | using gui::FocusRequest; |
| 55 | using gui::WindowInfoHandle; |
| 56 | |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 57 | layer_state_t::layer_state_t() |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 58 | : surface(nullptr), |
| 59 | layerId(-1), |
| 60 | what(0), |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 61 | x(0), |
| 62 | y(0), |
| 63 | z(0), |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 64 | flags(0), |
| 65 | mask(0), |
| 66 | reserved(0), |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 67 | cornerRadius(0.0f), |
| 68 | backgroundBlurRadius(0), |
Vishnu Nair | bbceb46 | 2022-10-10 04:52:13 +0000 | [diff] [blame] | 69 | color(0), |
| 70 | bufferTransform(0), |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 71 | transformToDisplayInverse(false), |
| 72 | crop(Rect::INVALID_RECT), |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 73 | dataspace(ui::Dataspace::UNKNOWN), |
| 74 | surfaceDamageRegion(), |
| 75 | api(-1), |
| 76 | colorTransform(mat4()), |
| 77 | bgColorAlpha(0), |
| 78 | bgColorDataspace(ui::Dataspace::UNKNOWN), |
| 79 | colorSpaceAgnostic(false), |
| 80 | shadowRadius(0.0f), |
| 81 | frameRateSelectionPriority(-1), |
| 82 | frameRate(0.0f), |
| 83 | frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT), |
Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 84 | changeFrameRateStrategy(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS), |
Andy Labrada | 096227e | 2022-06-15 16:58:11 +0000 | [diff] [blame] | 85 | defaultFrameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT), |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 86 | fixedTransformHint(ui::Transform::ROT_INVALID), |
Vishnu Nair | 1506b18 | 2021-02-22 14:35:15 -0800 | [diff] [blame] | 87 | autoRefresh(false), |
Winson Chung | a30f7c9 | 2021-06-29 15:42:56 -0700 | [diff] [blame] | 88 | isTrustedOverlay(false), |
Tianhao Yao | 67dd712 | 2022-02-22 17:48:33 +0000 | [diff] [blame] | 89 | borderEnabled(false), |
Vishnu Nair | 6bdec7d | 2021-05-10 15:01:13 -0700 | [diff] [blame] | 90 | bufferCrop(Rect::INVALID_RECT), |
| 91 | destinationFrame(Rect::INVALID_RECT), |
Vishnu Nair | 9cf4a4d | 2021-09-17 12:16:08 -0700 | [diff] [blame] | 92 | dropInputMode(gui::DropInputMode::NONE) { |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 93 | matrix.dsdx = matrix.dtdy = 1.0f; |
| 94 | matrix.dsdy = matrix.dtdx = 0.0f; |
| 95 | hdrMetadata.validTypes = 0; |
| 96 | } |
| 97 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 98 | status_t layer_state_t::write(Parcel& output) const |
| 99 | { |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 100 | SAFE_PARCEL(output.writeStrongBinder, surface); |
Pablo Gamito | dbc3167 | 2020-09-01 18:28:58 +0000 | [diff] [blame] | 101 | SAFE_PARCEL(output.writeInt32, layerId); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 102 | SAFE_PARCEL(output.writeUint64, what); |
| 103 | SAFE_PARCEL(output.writeFloat, x); |
| 104 | SAFE_PARCEL(output.writeFloat, y); |
| 105 | SAFE_PARCEL(output.writeInt32, z); |
Dominik Laskowski | 29fa146 | 2021-04-27 15:51:50 -0700 | [diff] [blame] | 106 | SAFE_PARCEL(output.writeUint32, layerStack.id); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 107 | SAFE_PARCEL(output.writeUint32, flags); |
| 108 | SAFE_PARCEL(output.writeUint32, mask); |
| 109 | SAFE_PARCEL(matrix.write, output); |
chaviw | 2571450 | 2021-02-11 10:01:08 -0800 | [diff] [blame] | 110 | SAFE_PARCEL(output.write, crop); |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 111 | SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, relativeLayerSurfaceControl); |
| 112 | SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, parentSurfaceControlForChild); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 113 | SAFE_PARCEL(output.writeFloat, color.r); |
| 114 | SAFE_PARCEL(output.writeFloat, color.g); |
| 115 | SAFE_PARCEL(output.writeFloat, color.b); |
Vishnu Nair | bbceb46 | 2022-10-10 04:52:13 +0000 | [diff] [blame] | 116 | SAFE_PARCEL(output.writeFloat, color.a); |
chaviw | 98318de | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 117 | SAFE_PARCEL(windowInfoHandle->writeToParcel, &output); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 118 | SAFE_PARCEL(output.write, transparentRegion); |
Vishnu Nair | bbceb46 | 2022-10-10 04:52:13 +0000 | [diff] [blame] | 119 | SAFE_PARCEL(output.writeUint32, bufferTransform); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 120 | SAFE_PARCEL(output.writeBool, transformToDisplayInverse); |
Tianhao Yao | 67dd712 | 2022-02-22 17:48:33 +0000 | [diff] [blame] | 121 | SAFE_PARCEL(output.writeBool, borderEnabled); |
Tianhao Yao | 10cea3c | 2022-03-30 01:37:22 +0000 | [diff] [blame] | 122 | SAFE_PARCEL(output.writeFloat, borderWidth); |
| 123 | SAFE_PARCEL(output.writeFloat, borderColor.r); |
| 124 | SAFE_PARCEL(output.writeFloat, borderColor.g); |
| 125 | SAFE_PARCEL(output.writeFloat, borderColor.b); |
| 126 | SAFE_PARCEL(output.writeFloat, borderColor.a); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 127 | SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dataspace)); |
| 128 | SAFE_PARCEL(output.write, hdrMetadata); |
| 129 | SAFE_PARCEL(output.write, surfaceDamageRegion); |
| 130 | SAFE_PARCEL(output.writeInt32, api); |
| 131 | |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 132 | if (sidebandStream) { |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 133 | SAFE_PARCEL(output.writeBool, true); |
| 134 | SAFE_PARCEL(output.writeNativeHandle, sidebandStream->handle()); |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 135 | } else { |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 136 | SAFE_PARCEL(output.writeBool, false); |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 137 | } |
| 138 | |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 139 | SAFE_PARCEL(output.write, colorTransform.asArray(), 16 * sizeof(float)); |
| 140 | SAFE_PARCEL(output.writeFloat, cornerRadius); |
| 141 | SAFE_PARCEL(output.writeUint32, backgroundBlurRadius); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 142 | SAFE_PARCEL(output.writeParcelable, metadata); |
| 143 | SAFE_PARCEL(output.writeFloat, bgColorAlpha); |
| 144 | SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(bgColorDataspace)); |
| 145 | SAFE_PARCEL(output.writeBool, colorSpaceAgnostic); |
| 146 | SAFE_PARCEL(output.writeVectorSize, listeners); |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 147 | |
| 148 | for (auto listener : listeners) { |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 149 | SAFE_PARCEL(output.writeStrongBinder, listener.transactionCompletedListener); |
Vishnu Nair | fc46c1e | 2021-04-21 08:31:32 -0700 | [diff] [blame] | 150 | SAFE_PARCEL(output.writeParcelableVector, listener.callbackIds); |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 151 | } |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 152 | SAFE_PARCEL(output.writeFloat, shadowRadius); |
| 153 | SAFE_PARCEL(output.writeInt32, frameRateSelectionPriority); |
| 154 | SAFE_PARCEL(output.writeFloat, frameRate); |
| 155 | SAFE_PARCEL(output.writeByte, frameRateCompatibility); |
Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 156 | SAFE_PARCEL(output.writeByte, changeFrameRateStrategy); |
Andy Labrada | 096227e | 2022-06-15 16:58:11 +0000 | [diff] [blame] | 157 | SAFE_PARCEL(output.writeByte, defaultFrameRateCompatibility); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 158 | SAFE_PARCEL(output.writeUint32, fixedTransformHint); |
Vishnu Nair | cf26a0a | 2020-11-13 12:56:20 -0800 | [diff] [blame] | 159 | SAFE_PARCEL(output.writeBool, autoRefresh); |
Sally Qi | 81d95e6 | 2022-03-21 19:41:33 -0700 | [diff] [blame] | 160 | SAFE_PARCEL(output.writeBool, dimmingEnabled); |
Lucas Dupin | c3800b8 | 2020-10-02 16:24:48 -0700 | [diff] [blame] | 161 | |
| 162 | SAFE_PARCEL(output.writeUint32, blurRegions.size()); |
| 163 | for (auto region : blurRegions) { |
| 164 | SAFE_PARCEL(output.writeUint32, region.blurRadius); |
| 165 | SAFE_PARCEL(output.writeFloat, region.cornerRadiusTL); |
| 166 | SAFE_PARCEL(output.writeFloat, region.cornerRadiusTR); |
| 167 | SAFE_PARCEL(output.writeFloat, region.cornerRadiusBL); |
| 168 | SAFE_PARCEL(output.writeFloat, region.cornerRadiusBR); |
| 169 | SAFE_PARCEL(output.writeFloat, region.alpha); |
| 170 | SAFE_PARCEL(output.writeInt32, region.left); |
| 171 | SAFE_PARCEL(output.writeInt32, region.top); |
| 172 | SAFE_PARCEL(output.writeInt32, region.right); |
| 173 | SAFE_PARCEL(output.writeInt32, region.bottom); |
| 174 | } |
John Reck | cdb4ed7 | 2021-02-04 13:39:33 -0500 | [diff] [blame] | 175 | |
| 176 | SAFE_PARCEL(output.write, stretchEffect); |
chaviw | f3f40fe | 2021-04-27 15:54:02 -0500 | [diff] [blame] | 177 | SAFE_PARCEL(output.write, bufferCrop); |
Vishnu Nair | 6bdec7d | 2021-05-10 15:01:13 -0700 | [diff] [blame] | 178 | SAFE_PARCEL(output.write, destinationFrame); |
Winson Chung | a30f7c9 | 2021-06-29 15:42:56 -0700 | [diff] [blame] | 179 | SAFE_PARCEL(output.writeBool, isTrustedOverlay); |
John Reck | cdb4ed7 | 2021-02-04 13:39:33 -0500 | [diff] [blame] | 180 | |
Vishnu Nair | 9cf4a4d | 2021-09-17 12:16:08 -0700 | [diff] [blame] | 181 | SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode)); |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 182 | |
| 183 | const bool hasBufferData = (bufferData != nullptr); |
| 184 | SAFE_PARCEL(output.writeBool, hasBufferData); |
| 185 | if (hasBufferData) { |
| 186 | SAFE_PARCEL(output.writeParcelable, *bufferData); |
| 187 | } |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 188 | return NO_ERROR; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | status_t layer_state_t::read(const Parcel& input) |
| 192 | { |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 193 | SAFE_PARCEL(input.readNullableStrongBinder, &surface); |
Pablo Gamito | dbc3167 | 2020-09-01 18:28:58 +0000 | [diff] [blame] | 194 | SAFE_PARCEL(input.readInt32, &layerId); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 195 | SAFE_PARCEL(input.readUint64, &what); |
| 196 | SAFE_PARCEL(input.readFloat, &x); |
| 197 | SAFE_PARCEL(input.readFloat, &y); |
| 198 | SAFE_PARCEL(input.readInt32, &z); |
Dominik Laskowski | 29fa146 | 2021-04-27 15:51:50 -0700 | [diff] [blame] | 199 | SAFE_PARCEL(input.readUint32, &layerStack.id); |
Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 200 | |
Vishnu Nair | f6eddb6 | 2021-01-27 22:02:11 -0800 | [diff] [blame] | 201 | SAFE_PARCEL(input.readUint32, &flags); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 202 | |
Vishnu Nair | f6eddb6 | 2021-01-27 22:02:11 -0800 | [diff] [blame] | 203 | SAFE_PARCEL(input.readUint32, &mask); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 204 | |
| 205 | SAFE_PARCEL(matrix.read, input); |
chaviw | 2571450 | 2021-02-11 10:01:08 -0800 | [diff] [blame] | 206 | SAFE_PARCEL(input.read, crop); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 207 | |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 208 | SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &relativeLayerSurfaceControl); |
| 209 | SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &parentSurfaceControlForChild); |
| 210 | |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 211 | float tmpFloat = 0; |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 212 | SAFE_PARCEL(input.readFloat, &tmpFloat); |
| 213 | color.r = tmpFloat; |
| 214 | SAFE_PARCEL(input.readFloat, &tmpFloat); |
| 215 | color.g = tmpFloat; |
| 216 | SAFE_PARCEL(input.readFloat, &tmpFloat); |
| 217 | color.b = tmpFloat; |
Vishnu Nair | bbceb46 | 2022-10-10 04:52:13 +0000 | [diff] [blame] | 218 | SAFE_PARCEL(input.readFloat, &tmpFloat); |
| 219 | color.a = tmpFloat; |
| 220 | |
chaviw | 98318de | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 221 | SAFE_PARCEL(windowInfoHandle->readFromParcel, &input); |
Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 222 | |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 223 | SAFE_PARCEL(input.read, transparentRegion); |
Vishnu Nair | bbceb46 | 2022-10-10 04:52:13 +0000 | [diff] [blame] | 224 | SAFE_PARCEL(input.readUint32, &bufferTransform); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 225 | SAFE_PARCEL(input.readBool, &transformToDisplayInverse); |
Tianhao Yao | 67dd712 | 2022-02-22 17:48:33 +0000 | [diff] [blame] | 226 | SAFE_PARCEL(input.readBool, &borderEnabled); |
Tianhao Yao | 10cea3c | 2022-03-30 01:37:22 +0000 | [diff] [blame] | 227 | SAFE_PARCEL(input.readFloat, &tmpFloat); |
| 228 | borderWidth = tmpFloat; |
| 229 | SAFE_PARCEL(input.readFloat, &tmpFloat); |
| 230 | borderColor.r = tmpFloat; |
| 231 | SAFE_PARCEL(input.readFloat, &tmpFloat); |
| 232 | borderColor.g = tmpFloat; |
| 233 | SAFE_PARCEL(input.readFloat, &tmpFloat); |
| 234 | borderColor.b = tmpFloat; |
| 235 | SAFE_PARCEL(input.readFloat, &tmpFloat); |
| 236 | borderColor.a = tmpFloat; |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 237 | |
Vishnu Nair | f6eddb6 | 2021-01-27 22:02:11 -0800 | [diff] [blame] | 238 | uint32_t tmpUint32 = 0; |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 239 | SAFE_PARCEL(input.readUint32, &tmpUint32); |
| 240 | dataspace = static_cast<ui::Dataspace>(tmpUint32); |
| 241 | |
| 242 | SAFE_PARCEL(input.read, hdrMetadata); |
| 243 | SAFE_PARCEL(input.read, surfaceDamageRegion); |
| 244 | SAFE_PARCEL(input.readInt32, &api); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 245 | |
| 246 | bool tmpBool = false; |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 247 | SAFE_PARCEL(input.readBool, &tmpBool); |
| 248 | if (tmpBool) { |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 249 | sidebandStream = NativeHandle::create(input.readNativeHandle(), true); |
| 250 | } |
| 251 | |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 252 | SAFE_PARCEL(input.read, &colorTransform, 16 * sizeof(float)); |
| 253 | SAFE_PARCEL(input.readFloat, &cornerRadius); |
| 254 | SAFE_PARCEL(input.readUint32, &backgroundBlurRadius); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 255 | SAFE_PARCEL(input.readParcelable, &metadata); |
Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 256 | |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 257 | SAFE_PARCEL(input.readFloat, &bgColorAlpha); |
| 258 | SAFE_PARCEL(input.readUint32, &tmpUint32); |
| 259 | bgColorDataspace = static_cast<ui::Dataspace>(tmpUint32); |
| 260 | SAFE_PARCEL(input.readBool, &colorSpaceAgnostic); |
Valerie Hau | ed54efa | 2019-01-11 20:03:14 -0800 | [diff] [blame] | 261 | |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 262 | int32_t numListeners = 0; |
| 263 | SAFE_PARCEL_READ_SIZE(input.readInt32, &numListeners, input.dataSize()); |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 264 | listeners.clear(); |
| 265 | for (int i = 0; i < numListeners; i++) { |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 266 | sp<IBinder> listener; |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 267 | std::vector<CallbackId> callbackIds; |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 268 | SAFE_PARCEL(input.readNullableStrongBinder, &listener); |
Vishnu Nair | fc46c1e | 2021-04-21 08:31:32 -0700 | [diff] [blame] | 269 | SAFE_PARCEL(input.readParcelableVector, &callbackIds); |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 270 | listeners.emplace_back(listener, callbackIds); |
| 271 | } |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 272 | SAFE_PARCEL(input.readFloat, &shadowRadius); |
| 273 | SAFE_PARCEL(input.readInt32, &frameRateSelectionPriority); |
| 274 | SAFE_PARCEL(input.readFloat, &frameRate); |
| 275 | SAFE_PARCEL(input.readByte, &frameRateCompatibility); |
Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 276 | SAFE_PARCEL(input.readByte, &changeFrameRateStrategy); |
Andy Labrada | 096227e | 2022-06-15 16:58:11 +0000 | [diff] [blame] | 277 | SAFE_PARCEL(input.readByte, &defaultFrameRateCompatibility); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 278 | SAFE_PARCEL(input.readUint32, &tmpUint32); |
| 279 | fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32); |
Vishnu Nair | cf26a0a | 2020-11-13 12:56:20 -0800 | [diff] [blame] | 280 | SAFE_PARCEL(input.readBool, &autoRefresh); |
Sally Qi | 81d95e6 | 2022-03-21 19:41:33 -0700 | [diff] [blame] | 281 | SAFE_PARCEL(input.readBool, &dimmingEnabled); |
Lucas Dupin | c3800b8 | 2020-10-02 16:24:48 -0700 | [diff] [blame] | 282 | |
| 283 | uint32_t numRegions = 0; |
| 284 | SAFE_PARCEL(input.readUint32, &numRegions); |
| 285 | blurRegions.clear(); |
| 286 | for (uint32_t i = 0; i < numRegions; i++) { |
| 287 | BlurRegion region; |
| 288 | SAFE_PARCEL(input.readUint32, ®ion.blurRadius); |
| 289 | SAFE_PARCEL(input.readFloat, ®ion.cornerRadiusTL); |
| 290 | SAFE_PARCEL(input.readFloat, ®ion.cornerRadiusTR); |
| 291 | SAFE_PARCEL(input.readFloat, ®ion.cornerRadiusBL); |
| 292 | SAFE_PARCEL(input.readFloat, ®ion.cornerRadiusBR); |
| 293 | SAFE_PARCEL(input.readFloat, ®ion.alpha); |
| 294 | SAFE_PARCEL(input.readInt32, ®ion.left); |
| 295 | SAFE_PARCEL(input.readInt32, ®ion.top); |
| 296 | SAFE_PARCEL(input.readInt32, ®ion.right); |
| 297 | SAFE_PARCEL(input.readInt32, ®ion.bottom); |
| 298 | blurRegions.push_back(region); |
| 299 | } |
John Reck | cdb4ed7 | 2021-02-04 13:39:33 -0500 | [diff] [blame] | 300 | |
| 301 | SAFE_PARCEL(input.read, stretchEffect); |
chaviw | f3f40fe | 2021-04-27 15:54:02 -0500 | [diff] [blame] | 302 | SAFE_PARCEL(input.read, bufferCrop); |
Vishnu Nair | 6bdec7d | 2021-05-10 15:01:13 -0700 | [diff] [blame] | 303 | SAFE_PARCEL(input.read, destinationFrame); |
Winson Chung | a30f7c9 | 2021-06-29 15:42:56 -0700 | [diff] [blame] | 304 | SAFE_PARCEL(input.readBool, &isTrustedOverlay); |
John Reck | cdb4ed7 | 2021-02-04 13:39:33 -0500 | [diff] [blame] | 305 | |
Vishnu Nair | 9cf4a4d | 2021-09-17 12:16:08 -0700 | [diff] [blame] | 306 | uint32_t mode; |
| 307 | SAFE_PARCEL(input.readUint32, &mode); |
| 308 | dropInputMode = static_cast<gui::DropInputMode>(mode); |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 309 | |
| 310 | bool hasBufferData; |
| 311 | SAFE_PARCEL(input.readBool, &hasBufferData); |
| 312 | if (hasBufferData) { |
| 313 | bufferData = std::make_shared<BufferData>(); |
| 314 | SAFE_PARCEL(input.readParcelable, bufferData.get()); |
| 315 | } else { |
| 316 | bufferData = nullptr; |
| 317 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 318 | return NO_ERROR; |
| 319 | } |
| 320 | |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 321 | status_t ComposerState::write(Parcel& output) const { |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 322 | return state.write(output); |
| 323 | } |
| 324 | |
| 325 | status_t ComposerState::read(const Parcel& input) { |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 326 | return state.read(input); |
| 327 | } |
| 328 | |
Dominik Laskowski | 29fa146 | 2021-04-27 15:51:50 -0700 | [diff] [blame] | 329 | DisplayState::DisplayState() = default; |
Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 330 | |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 331 | status_t DisplayState::write(Parcel& output) const { |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 332 | SAFE_PARCEL(output.writeStrongBinder, token); |
| 333 | SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(surface)); |
| 334 | SAFE_PARCEL(output.writeUint32, what); |
Evan Rosky | 2239b37 | 2021-05-20 13:43:47 -0700 | [diff] [blame] | 335 | SAFE_PARCEL(output.writeUint32, flags); |
Dominik Laskowski | 29fa146 | 2021-04-27 15:51:50 -0700 | [diff] [blame] | 336 | SAFE_PARCEL(output.writeUint32, layerStack.id); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 337 | SAFE_PARCEL(output.writeUint32, toRotationInt(orientation)); |
| 338 | SAFE_PARCEL(output.write, layerStackSpaceRect); |
| 339 | SAFE_PARCEL(output.write, orientedDisplaySpaceRect); |
| 340 | SAFE_PARCEL(output.writeUint32, width); |
| 341 | SAFE_PARCEL(output.writeUint32, height); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 342 | return NO_ERROR; |
| 343 | } |
| 344 | |
| 345 | status_t DisplayState::read(const Parcel& input) { |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 346 | SAFE_PARCEL(input.readStrongBinder, &token); |
| 347 | sp<IBinder> tmpBinder; |
| 348 | SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder); |
| 349 | surface = interface_cast<IGraphicBufferProducer>(tmpBinder); |
| 350 | |
| 351 | SAFE_PARCEL(input.readUint32, &what); |
Evan Rosky | 2239b37 | 2021-05-20 13:43:47 -0700 | [diff] [blame] | 352 | SAFE_PARCEL(input.readUint32, &flags); |
Dominik Laskowski | 29fa146 | 2021-04-27 15:51:50 -0700 | [diff] [blame] | 353 | SAFE_PARCEL(input.readUint32, &layerStack.id); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 354 | uint32_t tmpUint = 0; |
| 355 | SAFE_PARCEL(input.readUint32, &tmpUint); |
| 356 | orientation = ui::toRotation(tmpUint); |
| 357 | |
| 358 | SAFE_PARCEL(input.read, layerStackSpaceRect); |
| 359 | SAFE_PARCEL(input.read, orientedDisplaySpaceRect); |
| 360 | SAFE_PARCEL(input.readUint32, &width); |
| 361 | SAFE_PARCEL(input.readUint32, &height); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 362 | return NO_ERROR; |
| 363 | } |
| 364 | |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 365 | void DisplayState::merge(const DisplayState& other) { |
| 366 | if (other.what & eSurfaceChanged) { |
| 367 | what |= eSurfaceChanged; |
| 368 | surface = other.surface; |
| 369 | } |
| 370 | if (other.what & eLayerStackChanged) { |
| 371 | what |= eLayerStackChanged; |
| 372 | layerStack = other.layerStack; |
| 373 | } |
Evan Rosky | 2239b37 | 2021-05-20 13:43:47 -0700 | [diff] [blame] | 374 | if (other.what & eFlagsChanged) { |
| 375 | what |= eFlagsChanged; |
| 376 | flags = other.flags; |
| 377 | } |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 378 | if (other.what & eDisplayProjectionChanged) { |
| 379 | what |= eDisplayProjectionChanged; |
| 380 | orientation = other.orientation; |
Marin Shalamanov | 6ad317c | 2020-07-29 23:34:07 +0200 | [diff] [blame] | 381 | layerStackSpaceRect = other.layerStackSpaceRect; |
| 382 | orientedDisplaySpaceRect = other.orientedDisplaySpaceRect; |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 383 | } |
| 384 | if (other.what & eDisplaySizeChanged) { |
| 385 | what |= eDisplaySizeChanged; |
| 386 | width = other.width; |
| 387 | height = other.height; |
| 388 | } |
| 389 | } |
| 390 | |
Robert Carr | de6d7b4 | 2022-01-07 18:23:06 -0800 | [diff] [blame] | 391 | void layer_state_t::sanitize(int32_t permissions) { |
| 392 | // TODO: b/109894387 |
| 393 | // |
| 394 | // SurfaceFlinger's renderer is not prepared to handle cropping in the face of arbitrary |
| 395 | // rotation. To see the problem observe that if we have a square parent, and a child |
| 396 | // of the same size, then we rotate the child 45 degrees around its center, the child |
| 397 | // must now be cropped to a non rectangular 8 sided region. |
| 398 | // |
| 399 | // Of course we can fix this in the future. For now, we are lucky, SurfaceControl is |
| 400 | // private API, and arbitrary rotation is used in limited use cases, for instance: |
| 401 | // - WindowManager only uses rotation in one case, which is on a top level layer in which |
| 402 | // cropping is not an issue. |
| 403 | // - Launcher, as a privileged app, uses this to transition an application to PiP |
| 404 | // (picture-in-picture) mode. |
| 405 | // |
| 406 | // However given that abuse of rotation matrices could lead to surfaces extending outside |
| 407 | // of cropped areas, we need to prevent non-root clients without permission |
| 408 | // ACCESS_SURFACE_FLINGER nor ROTATE_SURFACE_FLINGER |
| 409 | // (a.k.a. everyone except WindowManager / tests / Launcher) from setting non rectangle |
| 410 | // preserving transformations. |
| 411 | if (what & eMatrixChanged) { |
| 412 | if (!(permissions & Permission::ROTATE_SURFACE_FLINGER)) { |
| 413 | ui::Transform t; |
| 414 | t.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy); |
| 415 | if (!t.preserveRects()) { |
| 416 | what &= ~eMatrixChanged; |
| 417 | ALOGE("Stripped non rect preserving matrix in sanitize"); |
| 418 | } |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | if (what & eFlagsChanged) { |
| 423 | if ((flags & eLayerIsDisplayDecoration) && |
| 424 | !(permissions & Permission::INTERNAL_SYSTEM_WINDOW)) { |
| 425 | flags &= ~eLayerIsDisplayDecoration; |
| 426 | ALOGE("Stripped attempt to set LayerIsDisplayDecoration in sanitize"); |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | if (what & layer_state_t::eInputInfoChanged) { |
| 431 | if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) { |
| 432 | what &= ~eInputInfoChanged; |
| 433 | ALOGE("Stripped attempt to set eInputInfoChanged in sanitize"); |
| 434 | } |
| 435 | } |
| 436 | if (what & layer_state_t::eTrustedOverlayChanged) { |
| 437 | if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) { |
| 438 | what &= ~eTrustedOverlayChanged; |
| 439 | ALOGE("Stripped attempt to set eTrustedOverlay in sanitize"); |
| 440 | } |
| 441 | } |
| 442 | if (what & layer_state_t::eDropInputModeChanged) { |
| 443 | if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) { |
| 444 | what &= ~eDropInputModeChanged; |
| 445 | ALOGE("Stripped attempt to set eDropInputModeChanged in sanitize"); |
| 446 | } |
| 447 | } |
| 448 | if (what & layer_state_t::eFrameRateSelectionPriority) { |
| 449 | if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) { |
| 450 | what &= ~eFrameRateSelectionPriority; |
| 451 | ALOGE("Stripped attempt to set eFrameRateSelectionPriority in sanitize"); |
| 452 | } |
| 453 | } |
| 454 | if (what & layer_state_t::eFrameRateChanged) { |
| 455 | if (!ValidateFrameRate(frameRate, frameRateCompatibility, |
| 456 | changeFrameRateStrategy, |
| 457 | "layer_state_t::sanitize", |
| 458 | permissions & Permission::ACCESS_SURFACE_FLINGER)) { |
| 459 | what &= ~eFrameRateChanged; // logged in ValidateFrameRate |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 464 | void layer_state_t::merge(const layer_state_t& other) { |
| 465 | if (other.what & ePositionChanged) { |
| 466 | what |= ePositionChanged; |
| 467 | x = other.x; |
| 468 | y = other.y; |
| 469 | } |
| 470 | if (other.what & eLayerChanged) { |
| 471 | what |= eLayerChanged; |
chaviw | 3237758 | 2019-05-13 11:15:19 -0700 | [diff] [blame] | 472 | what &= ~eRelativeLayerChanged; |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 473 | z = other.z; |
| 474 | } |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 475 | if (other.what & eAlphaChanged) { |
| 476 | what |= eAlphaChanged; |
Vishnu Nair | bbceb46 | 2022-10-10 04:52:13 +0000 | [diff] [blame] | 477 | color.a = other.color.a; |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 478 | } |
| 479 | if (other.what & eMatrixChanged) { |
| 480 | what |= eMatrixChanged; |
| 481 | matrix = other.matrix; |
| 482 | } |
| 483 | if (other.what & eTransparentRegionChanged) { |
| 484 | what |= eTransparentRegionChanged; |
| 485 | transparentRegion = other.transparentRegion; |
| 486 | } |
| 487 | if (other.what & eFlagsChanged) { |
| 488 | what |= eFlagsChanged; |
Vishnu Nair | 996bc42 | 2019-07-16 14:15:33 -0700 | [diff] [blame] | 489 | flags &= ~other.mask; |
| 490 | flags |= (other.flags & other.mask); |
| 491 | mask |= other.mask; |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 492 | } |
| 493 | if (other.what & eLayerStackChanged) { |
| 494 | what |= eLayerStackChanged; |
| 495 | layerStack = other.layerStack; |
| 496 | } |
Lucas Dupin | 1b6531c | 2018-07-05 17:18:21 -0700 | [diff] [blame] | 497 | if (other.what & eCornerRadiusChanged) { |
| 498 | what |= eCornerRadiusChanged; |
| 499 | cornerRadius = other.cornerRadius; |
| 500 | } |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame] | 501 | if (other.what & eBackgroundBlurRadiusChanged) { |
| 502 | what |= eBackgroundBlurRadiusChanged; |
| 503 | backgroundBlurRadius = other.backgroundBlurRadius; |
| 504 | } |
Lucas Dupin | c3800b8 | 2020-10-02 16:24:48 -0700 | [diff] [blame] | 505 | if (other.what & eBlurRegionsChanged) { |
| 506 | what |= eBlurRegionsChanged; |
| 507 | blurRegions = other.blurRegions; |
| 508 | } |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 509 | if (other.what & eRelativeLayerChanged) { |
| 510 | what |= eRelativeLayerChanged; |
chaviw | 3237758 | 2019-05-13 11:15:19 -0700 | [diff] [blame] | 511 | what &= ~eLayerChanged; |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 512 | z = other.z; |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 513 | relativeLayerSurfaceControl = other.relativeLayerSurfaceControl; |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 514 | } |
| 515 | if (other.what & eReparent) { |
| 516 | what |= eReparent; |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 517 | parentSurfaceControlForChild = other.parentSurfaceControlForChild; |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 518 | } |
Vishnu Nair | bbceb46 | 2022-10-10 04:52:13 +0000 | [diff] [blame] | 519 | if (other.what & eBufferTransformChanged) { |
| 520 | what |= eBufferTransformChanged; |
| 521 | bufferTransform = other.bufferTransform; |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 522 | } |
| 523 | if (other.what & eTransformToDisplayInverseChanged) { |
| 524 | what |= eTransformToDisplayInverseChanged; |
| 525 | transformToDisplayInverse = other.transformToDisplayInverse; |
| 526 | } |
| 527 | if (other.what & eCropChanged) { |
| 528 | what |= eCropChanged; |
| 529 | crop = other.crop; |
| 530 | } |
| 531 | if (other.what & eBufferChanged) { |
| 532 | what |= eBufferChanged; |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 533 | bufferData = other.bufferData; |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 534 | } |
| 535 | if (other.what & eDataspaceChanged) { |
| 536 | what |= eDataspaceChanged; |
| 537 | dataspace = other.dataspace; |
| 538 | } |
| 539 | if (other.what & eHdrMetadataChanged) { |
| 540 | what |= eHdrMetadataChanged; |
| 541 | hdrMetadata = other.hdrMetadata; |
| 542 | } |
| 543 | if (other.what & eSurfaceDamageRegionChanged) { |
| 544 | what |= eSurfaceDamageRegionChanged; |
| 545 | surfaceDamageRegion = other.surfaceDamageRegion; |
| 546 | } |
| 547 | if (other.what & eApiChanged) { |
| 548 | what |= eApiChanged; |
| 549 | api = other.api; |
| 550 | } |
| 551 | if (other.what & eSidebandStreamChanged) { |
| 552 | what |= eSidebandStreamChanged; |
| 553 | sidebandStream = other.sidebandStream; |
| 554 | } |
Peiyong Lin | d378863 | 2018-09-18 16:01:31 -0700 | [diff] [blame] | 555 | if (other.what & eColorTransformChanged) { |
| 556 | what |= eColorTransformChanged; |
| 557 | colorTransform = other.colorTransform; |
| 558 | } |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame] | 559 | if (other.what & eHasListenerCallbacksChanged) { |
| 560 | what |= eHasListenerCallbacksChanged; |
Marissa Wall | c837b5e | 2018-10-12 10:04:44 -0700 | [diff] [blame] | 561 | } |
Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 562 | if (other.what & eInputInfoChanged) { |
| 563 | what |= eInputInfoChanged; |
chaviw | 98318de | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 564 | windowInfoHandle = new WindowInfoHandle(*other.windowInfoHandle); |
Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 565 | } |
Valerie Hau | dd0b757 | 2019-01-29 14:59:27 -0800 | [diff] [blame] | 566 | if (other.what & eBackgroundColorChanged) { |
| 567 | what |= eBackgroundColorChanged; |
Vishnu Nair | bbceb46 | 2022-10-10 04:52:13 +0000 | [diff] [blame] | 568 | color.rgb = other.color.rgb; |
Valerie Hau | dd0b757 | 2019-01-29 14:59:27 -0800 | [diff] [blame] | 569 | bgColorAlpha = other.bgColorAlpha; |
| 570 | bgColorDataspace = other.bgColorDataspace; |
Valerie Hau | ed54efa | 2019-01-11 20:03:14 -0800 | [diff] [blame] | 571 | } |
Evan Rosky | 1f6d6d5 | 2018-12-06 10:47:26 -0800 | [diff] [blame] | 572 | if (other.what & eMetadataChanged) { |
| 573 | what |= eMetadataChanged; |
| 574 | metadata.merge(other.metadata); |
| 575 | } |
Vishnu Nair | c97b8db | 2019-10-29 18:19:35 -0700 | [diff] [blame] | 576 | if (other.what & eShadowRadiusChanged) { |
| 577 | what |= eShadowRadiusChanged; |
| 578 | shadowRadius = other.shadowRadius; |
| 579 | } |
Tianhao Yao | 67dd712 | 2022-02-22 17:48:33 +0000 | [diff] [blame] | 580 | if (other.what & eRenderBorderChanged) { |
| 581 | what |= eRenderBorderChanged; |
| 582 | borderEnabled = other.borderEnabled; |
Tianhao Yao | 10cea3c | 2022-03-30 01:37:22 +0000 | [diff] [blame] | 583 | borderWidth = other.borderWidth; |
| 584 | borderColor = other.borderColor; |
Tianhao Yao | 67dd712 | 2022-02-22 17:48:33 +0000 | [diff] [blame] | 585 | } |
Andy Labrada | 096227e | 2022-06-15 16:58:11 +0000 | [diff] [blame] | 586 | if (other.what & eDefaultFrameRateCompatibilityChanged) { |
| 587 | what |= eDefaultFrameRateCompatibilityChanged; |
| 588 | defaultFrameRateCompatibility = other.defaultFrameRateCompatibility; |
| 589 | } |
Ana Krulec | c84d09b | 2019-11-02 23:10:29 +0100 | [diff] [blame] | 590 | if (other.what & eFrameRateSelectionPriority) { |
| 591 | what |= eFrameRateSelectionPriority; |
| 592 | frameRateSelectionPriority = other.frameRateSelectionPriority; |
| 593 | } |
Steven Thomas | 3172e20 | 2020-01-06 19:25:30 -0800 | [diff] [blame] | 594 | if (other.what & eFrameRateChanged) { |
| 595 | what |= eFrameRateChanged; |
| 596 | frameRate = other.frameRate; |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 597 | frameRateCompatibility = other.frameRateCompatibility; |
Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 598 | changeFrameRateStrategy = other.changeFrameRateStrategy; |
Steven Thomas | 3172e20 | 2020-01-06 19:25:30 -0800 | [diff] [blame] | 599 | } |
Vishnu Nair | 6213bd9 | 2020-05-08 17:42:25 -0700 | [diff] [blame] | 600 | if (other.what & eFixedTransformHintChanged) { |
| 601 | what |= eFixedTransformHintChanged; |
| 602 | fixedTransformHint = other.fixedTransformHint; |
| 603 | } |
Vishnu Nair | cf26a0a | 2020-11-13 12:56:20 -0800 | [diff] [blame] | 604 | if (other.what & eAutoRefreshChanged) { |
| 605 | what |= eAutoRefreshChanged; |
| 606 | autoRefresh = other.autoRefresh; |
| 607 | } |
Winson Chung | a30f7c9 | 2021-06-29 15:42:56 -0700 | [diff] [blame] | 608 | if (other.what & eTrustedOverlayChanged) { |
| 609 | what |= eTrustedOverlayChanged; |
| 610 | isTrustedOverlay = other.isTrustedOverlay; |
| 611 | } |
John Reck | c00c669 | 2021-02-16 11:37:33 -0500 | [diff] [blame] | 612 | if (other.what & eStretchChanged) { |
| 613 | what |= eStretchChanged; |
| 614 | stretchEffect = other.stretchEffect; |
| 615 | } |
chaviw | f3f40fe | 2021-04-27 15:54:02 -0500 | [diff] [blame] | 616 | if (other.what & eBufferCropChanged) { |
| 617 | what |= eBufferCropChanged; |
| 618 | bufferCrop = other.bufferCrop; |
| 619 | } |
Vishnu Nair | 6bdec7d | 2021-05-10 15:01:13 -0700 | [diff] [blame] | 620 | if (other.what & eDestinationFrameChanged) { |
| 621 | what |= eDestinationFrameChanged; |
| 622 | destinationFrame = other.destinationFrame; |
| 623 | } |
Vishnu Nair | 0e81687 | 2021-07-14 10:53:04 -0700 | [diff] [blame] | 624 | if (other.what & eProducerDisconnect) { |
| 625 | what |= eProducerDisconnect; |
| 626 | } |
Vishnu Nair | 9cf4a4d | 2021-09-17 12:16:08 -0700 | [diff] [blame] | 627 | if (other.what & eDropInputModeChanged) { |
| 628 | what |= eDropInputModeChanged; |
| 629 | dropInputMode = other.dropInputMode; |
| 630 | } |
chaviw | 4c36cd8 | 2021-11-18 10:37:33 -0600 | [diff] [blame] | 631 | if (other.what & eColorChanged) { |
| 632 | what |= eColorChanged; |
Vishnu Nair | bbceb46 | 2022-10-10 04:52:13 +0000 | [diff] [blame] | 633 | color.rgb = other.color.rgb; |
chaviw | 4c36cd8 | 2021-11-18 10:37:33 -0600 | [diff] [blame] | 634 | } |
Arthur Hung | 91b346a | 2022-03-14 21:36:22 +0800 | [diff] [blame] | 635 | if (other.what & eColorSpaceAgnosticChanged) { |
| 636 | what |= eColorSpaceAgnosticChanged; |
| 637 | colorSpaceAgnostic = other.colorSpaceAgnostic; |
| 638 | } |
Sally Qi | 81d95e6 | 2022-03-21 19:41:33 -0700 | [diff] [blame] | 639 | if (other.what & eDimmingEnabledChanged) { |
| 640 | what |= eDimmingEnabledChanged; |
| 641 | dimmingEnabled = other.dimmingEnabled; |
| 642 | } |
Vishnu Nair | 217d8e6 | 2018-09-12 16:34:49 -0700 | [diff] [blame] | 643 | if ((other.what & what) != other.what) { |
| 644 | ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? " |
Vishnu Nair | 0e81687 | 2021-07-14 10:53:04 -0700 | [diff] [blame] | 645 | "other.what=0x%" PRIX64 " what=0x%" PRIX64 " unmerged flags=0x%" PRIX64, |
| 646 | other.what, what, (other.what & what) ^ other.what); |
Robert Carr | d314f16 | 2018-08-15 13:12:42 -0700 | [diff] [blame] | 647 | } |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 648 | } |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 649 | |
Vishnu Nair | aa799bd | 2022-11-16 23:09:09 +0000 | [diff] [blame^] | 650 | uint64_t layer_state_t::diff(const layer_state_t& other) const { |
| 651 | uint64_t diff = 0; |
| 652 | CHECK_DIFF2(diff, ePositionChanged, other, x, y); |
| 653 | if (other.what & eLayerChanged) { |
| 654 | diff |= eLayerChanged; |
| 655 | diff &= ~eRelativeLayerChanged; |
| 656 | } |
| 657 | CHECK_DIFF(diff, eAlphaChanged, other, color.a); |
| 658 | CHECK_DIFF(diff, eMatrixChanged, other, matrix); |
| 659 | if (other.what & eTransparentRegionChanged && |
| 660 | (!transparentRegion.hasSameRects(other.transparentRegion))) { |
| 661 | diff |= eTransparentRegionChanged; |
| 662 | } |
| 663 | if (other.what & eFlagsChanged) { |
| 664 | uint64_t changedFlags = (flags & other.mask) ^ (other.flags & other.mask); |
| 665 | if (changedFlags) diff |= eFlagsChanged; |
| 666 | } |
| 667 | CHECK_DIFF(diff, eLayerStackChanged, other, layerStack); |
| 668 | CHECK_DIFF(diff, eCornerRadiusChanged, other, cornerRadius); |
| 669 | CHECK_DIFF(diff, eBackgroundBlurRadiusChanged, other, backgroundBlurRadius); |
| 670 | if (other.what & eBlurRegionsChanged) diff |= eBlurRegionsChanged; |
| 671 | if (other.what & eRelativeLayerChanged) { |
| 672 | diff |= eRelativeLayerChanged; |
| 673 | diff &= ~eLayerChanged; |
| 674 | } |
| 675 | if (other.what & eReparent && |
| 676 | !SurfaceControl::isSameSurface(parentSurfaceControlForChild, |
| 677 | other.parentSurfaceControlForChild)) { |
| 678 | diff |= eReparent; |
| 679 | } |
| 680 | CHECK_DIFF(diff, eBufferTransformChanged, other, bufferTransform); |
| 681 | CHECK_DIFF(diff, eTransformToDisplayInverseChanged, other, transformToDisplayInverse); |
| 682 | CHECK_DIFF(diff, eCropChanged, other, crop); |
| 683 | if (other.what & eBufferChanged) diff |= eBufferChanged; |
| 684 | CHECK_DIFF(diff, eDataspaceChanged, other, dataspace); |
| 685 | CHECK_DIFF(diff, eHdrMetadataChanged, other, hdrMetadata); |
| 686 | if (other.what & eSurfaceDamageRegionChanged && |
| 687 | (!surfaceDamageRegion.hasSameRects(other.surfaceDamageRegion))) { |
| 688 | diff |= eSurfaceDamageRegionChanged; |
| 689 | } |
| 690 | CHECK_DIFF(diff, eApiChanged, other, api); |
| 691 | if (other.what & eSidebandStreamChanged) diff |= eSidebandStreamChanged; |
| 692 | CHECK_DIFF(diff, eApiChanged, other, api); |
| 693 | CHECK_DIFF(diff, eColorTransformChanged, other, colorTransform); |
| 694 | if (other.what & eHasListenerCallbacksChanged) diff |= eHasListenerCallbacksChanged; |
| 695 | if (other.what & eInputInfoChanged) diff |= eInputInfoChanged; |
| 696 | CHECK_DIFF3(diff, eBackgroundColorChanged, other, color.rgb, bgColorAlpha, bgColorDataspace); |
| 697 | if (other.what & eMetadataChanged) diff |= eMetadataChanged; |
| 698 | CHECK_DIFF(diff, eShadowRadiusChanged, other, shadowRadius); |
| 699 | CHECK_DIFF3(diff, eRenderBorderChanged, other, borderEnabled, borderWidth, borderColor); |
| 700 | CHECK_DIFF(diff, eDefaultFrameRateCompatibilityChanged, other, defaultFrameRateCompatibility); |
| 701 | CHECK_DIFF(diff, eFrameRateSelectionPriority, other, frameRateSelectionPriority); |
| 702 | CHECK_DIFF3(diff, eFrameRateChanged, other, frameRate, frameRateCompatibility, |
| 703 | changeFrameRateStrategy); |
| 704 | CHECK_DIFF(diff, eFixedTransformHintChanged, other, fixedTransformHint); |
| 705 | CHECK_DIFF(diff, eAutoRefreshChanged, other, autoRefresh); |
| 706 | CHECK_DIFF(diff, eTrustedOverlayChanged, other, isTrustedOverlay); |
| 707 | CHECK_DIFF(diff, eStretchChanged, other, stretchEffect); |
| 708 | CHECK_DIFF(diff, eBufferCropChanged, other, bufferCrop); |
| 709 | CHECK_DIFF(diff, eDestinationFrameChanged, other, destinationFrame); |
| 710 | if (other.what & eProducerDisconnect) diff |= eProducerDisconnect; |
| 711 | CHECK_DIFF(diff, eDropInputModeChanged, other, dropInputMode); |
| 712 | CHECK_DIFF(diff, eColorChanged, other, color.rgb); |
| 713 | CHECK_DIFF(diff, eColorSpaceAgnosticChanged, other, colorSpaceAgnostic); |
| 714 | CHECK_DIFF(diff, eDimmingEnabledChanged, other, dimmingEnabled); |
| 715 | return diff; |
| 716 | } |
| 717 | |
Vishnu Nair | ddf9b5c | 2021-03-29 18:53:41 -0700 | [diff] [blame] | 718 | bool layer_state_t::hasBufferChanges() const { |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 719 | return what & layer_state_t::eBufferChanged; |
Vishnu Nair | ddf9b5c | 2021-03-29 18:53:41 -0700 | [diff] [blame] | 720 | } |
| 721 | |
Ady Abraham | 6e8e364 | 2021-07-08 19:44:07 -0700 | [diff] [blame] | 722 | bool layer_state_t::hasValidBuffer() const { |
Vishnu Nair | 59f6d2d | 2022-10-05 16:59:56 -0700 | [diff] [blame] | 723 | return bufferData && (bufferData->hasBuffer() || bufferData->cachedBuffer.isValid()); |
Ady Abraham | 6e8e364 | 2021-07-08 19:44:07 -0700 | [diff] [blame] | 724 | } |
| 725 | |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 726 | status_t layer_state_t::matrix22_t::write(Parcel& output) const { |
| 727 | SAFE_PARCEL(output.writeFloat, dsdx); |
| 728 | SAFE_PARCEL(output.writeFloat, dtdx); |
| 729 | SAFE_PARCEL(output.writeFloat, dtdy); |
| 730 | SAFE_PARCEL(output.writeFloat, dsdy); |
| 731 | return NO_ERROR; |
| 732 | } |
| 733 | |
| 734 | status_t layer_state_t::matrix22_t::read(const Parcel& input) { |
| 735 | SAFE_PARCEL(input.readFloat, &dsdx); |
| 736 | SAFE_PARCEL(input.readFloat, &dtdx); |
| 737 | SAFE_PARCEL(input.readFloat, &dtdy); |
| 738 | SAFE_PARCEL(input.readFloat, &dsdy); |
| 739 | return NO_ERROR; |
| 740 | } |
| 741 | |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 742 | // ------------------------------- InputWindowCommands ---------------------------------------- |
| 743 | |
Vishnu Nair | e798b47 | 2020-07-23 13:52:21 -0700 | [diff] [blame] | 744 | bool InputWindowCommands::merge(const InputWindowCommands& other) { |
| 745 | bool changes = false; |
Vishnu Nair | e798b47 | 2020-07-23 13:52:21 -0700 | [diff] [blame] | 746 | changes |= !other.focusRequests.empty(); |
| 747 | focusRequests.insert(focusRequests.end(), std::make_move_iterator(other.focusRequests.begin()), |
| 748 | std::make_move_iterator(other.focusRequests.end())); |
Patrick Williams | 641f7f2 | 2022-06-22 19:25:35 +0000 | [diff] [blame] | 749 | changes |= !other.windowInfosReportedListeners.empty(); |
| 750 | windowInfosReportedListeners.insert(other.windowInfosReportedListeners.begin(), |
| 751 | other.windowInfosReportedListeners.end()); |
Vishnu Nair | e798b47 | 2020-07-23 13:52:21 -0700 | [diff] [blame] | 752 | return changes; |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 753 | } |
| 754 | |
Vishnu Nair | 958da93 | 2020-08-21 17:12:37 -0700 | [diff] [blame] | 755 | bool InputWindowCommands::empty() const { |
Patrick Williams | 641f7f2 | 2022-06-22 19:25:35 +0000 | [diff] [blame] | 756 | return focusRequests.empty() && windowInfosReportedListeners.empty(); |
Vishnu Nair | 958da93 | 2020-08-21 17:12:37 -0700 | [diff] [blame] | 757 | } |
| 758 | |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 759 | void InputWindowCommands::clear() { |
Vishnu Nair | e798b47 | 2020-07-23 13:52:21 -0700 | [diff] [blame] | 760 | focusRequests.clear(); |
Patrick Williams | 641f7f2 | 2022-06-22 19:25:35 +0000 | [diff] [blame] | 761 | windowInfosReportedListeners.clear(); |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 762 | } |
| 763 | |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 764 | status_t InputWindowCommands::write(Parcel& output) const { |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 765 | SAFE_PARCEL(output.writeParcelableVector, focusRequests); |
Patrick Williams | 641f7f2 | 2022-06-22 19:25:35 +0000 | [diff] [blame] | 766 | |
| 767 | SAFE_PARCEL(output.writeInt32, windowInfosReportedListeners.size()); |
| 768 | for (const auto& listener : windowInfosReportedListeners) { |
| 769 | SAFE_PARCEL(output.writeStrongBinder, listener); |
| 770 | } |
| 771 | |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 772 | return NO_ERROR; |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 773 | } |
| 774 | |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 775 | status_t InputWindowCommands::read(const Parcel& input) { |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 776 | SAFE_PARCEL(input.readParcelableVector, &focusRequests); |
Patrick Williams | 641f7f2 | 2022-06-22 19:25:35 +0000 | [diff] [blame] | 777 | |
| 778 | int listenerSize = 0; |
| 779 | SAFE_PARCEL_READ_SIZE(input.readInt32, &listenerSize, input.dataSize()); |
| 780 | windowInfosReportedListeners.reserve(listenerSize); |
| 781 | for (int i = 0; i < listenerSize; i++) { |
| 782 | sp<gui::IWindowInfosReportedListener> listener; |
| 783 | SAFE_PARCEL(input.readStrongBinder, &listener); |
| 784 | windowInfosReportedListeners.insert(listener); |
| 785 | } |
| 786 | |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 787 | return NO_ERROR; |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 788 | } |
| 789 | |
Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 790 | bool ValidateFrameRate(float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy, |
| 791 | const char* inFunctionName, bool privileged) { |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 792 | const char* functionName = inFunctionName != nullptr ? inFunctionName : "call"; |
| 793 | int floatClassification = std::fpclassify(frameRate); |
| 794 | if (frameRate < 0 || floatClassification == FP_INFINITE || floatClassification == FP_NAN) { |
| 795 | ALOGE("%s failed - invalid frame rate %f", functionName, frameRate); |
| 796 | return false; |
| 797 | } |
| 798 | |
| 799 | if (compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT && |
Ady Abraham | dd5bfa9 | 2021-01-07 17:56:08 -0800 | [diff] [blame] | 800 | compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE && |
Dominik Laskowski | 1f6fc70 | 2022-03-21 08:34:50 -0700 | [diff] [blame] | 801 | (!privileged || |
| 802 | (compatibility != ANATIVEWINDOW_FRAME_RATE_EXACT && |
| 803 | compatibility != ANATIVEWINDOW_FRAME_RATE_NO_VOTE))) { |
Ady Abraham | dd5bfa9 | 2021-01-07 17:56:08 -0800 | [diff] [blame] | 804 | ALOGE("%s failed - invalid compatibility value %d privileged: %s", functionName, |
| 805 | compatibility, privileged ? "yes" : "no"); |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 806 | return false; |
| 807 | } |
| 808 | |
Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 809 | if (changeFrameRateStrategy != ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS && |
| 810 | changeFrameRateStrategy != ANATIVEWINDOW_CHANGE_FRAME_RATE_ALWAYS) { |
| 811 | ALOGE("%s failed - invalid change frame rate strategy value %d", functionName, |
| 812 | changeFrameRateStrategy); |
| 813 | } |
| 814 | |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 815 | return true; |
| 816 | } |
| 817 | |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 818 | // ---------------------------------------------------------------------------- |
| 819 | |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 820 | namespace gui { |
| 821 | |
| 822 | status_t CaptureArgs::writeToParcel(Parcel* output) const { |
| 823 | SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(pixelFormat)); |
| 824 | SAFE_PARCEL(output->write, sourceCrop); |
| 825 | SAFE_PARCEL(output->writeFloat, frameScaleX); |
| 826 | SAFE_PARCEL(output->writeFloat, frameScaleY); |
| 827 | SAFE_PARCEL(output->writeBool, captureSecureLayers); |
| 828 | SAFE_PARCEL(output->writeInt32, uid); |
| 829 | SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(dataspace)); |
| 830 | SAFE_PARCEL(output->writeBool, allowProtected); |
| 831 | SAFE_PARCEL(output->writeBool, grayscale); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 832 | return NO_ERROR; |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 833 | } |
| 834 | |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 835 | status_t CaptureArgs::readFromParcel(const Parcel* input) { |
Peiyong Lin | cd26147 | 2020-10-06 18:05:25 -0700 | [diff] [blame] | 836 | int32_t value = 0; |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 837 | SAFE_PARCEL(input->readInt32, &value); |
Peiyong Lin | cd26147 | 2020-10-06 18:05:25 -0700 | [diff] [blame] | 838 | pixelFormat = static_cast<ui::PixelFormat>(value); |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 839 | SAFE_PARCEL(input->read, sourceCrop); |
| 840 | SAFE_PARCEL(input->readFloat, &frameScaleX); |
| 841 | SAFE_PARCEL(input->readFloat, &frameScaleY); |
| 842 | SAFE_PARCEL(input->readBool, &captureSecureLayers); |
| 843 | SAFE_PARCEL(input->readInt32, &uid); |
| 844 | SAFE_PARCEL(input->readInt32, &value); |
Peiyong Lin | cd26147 | 2020-10-06 18:05:25 -0700 | [diff] [blame] | 845 | dataspace = static_cast<ui::Dataspace>(value); |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 846 | SAFE_PARCEL(input->readBool, &allowProtected); |
| 847 | SAFE_PARCEL(input->readBool, &grayscale); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 848 | return NO_ERROR; |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 849 | } |
| 850 | |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 851 | status_t DisplayCaptureArgs::writeToParcel(Parcel* output) const { |
| 852 | SAFE_PARCEL(CaptureArgs::writeToParcel, output); |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 853 | |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 854 | SAFE_PARCEL(output->writeStrongBinder, displayToken); |
| 855 | SAFE_PARCEL(output->writeUint32, width); |
| 856 | SAFE_PARCEL(output->writeUint32, height); |
| 857 | SAFE_PARCEL(output->writeBool, useIdentityTransform); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 858 | return NO_ERROR; |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 859 | } |
| 860 | |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 861 | status_t DisplayCaptureArgs::readFromParcel(const Parcel* input) { |
| 862 | SAFE_PARCEL(CaptureArgs::readFromParcel, input); |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 863 | |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 864 | SAFE_PARCEL(input->readStrongBinder, &displayToken); |
| 865 | SAFE_PARCEL(input->readUint32, &width); |
| 866 | SAFE_PARCEL(input->readUint32, &height); |
| 867 | SAFE_PARCEL(input->readBool, &useIdentityTransform); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 868 | return NO_ERROR; |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 869 | } |
| 870 | |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 871 | status_t LayerCaptureArgs::writeToParcel(Parcel* output) const { |
| 872 | SAFE_PARCEL(CaptureArgs::writeToParcel, output); |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 873 | |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 874 | SAFE_PARCEL(output->writeStrongBinder, layerHandle); |
| 875 | SAFE_PARCEL(output->writeInt32, excludeHandles.size()); |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 876 | for (auto el : excludeHandles) { |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 877 | SAFE_PARCEL(output->writeStrongBinder, el); |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 878 | } |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 879 | SAFE_PARCEL(output->writeBool, childrenOnly); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 880 | return NO_ERROR; |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 881 | } |
| 882 | |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 883 | status_t LayerCaptureArgs::readFromParcel(const Parcel* input) { |
| 884 | SAFE_PARCEL(CaptureArgs::readFromParcel, input); |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 885 | |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 886 | SAFE_PARCEL(input->readStrongBinder, &layerHandle); |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 887 | |
George Burgess IV | 4d7aceb | 2020-07-30 10:01:56 -0700 | [diff] [blame] | 888 | int32_t numExcludeHandles = 0; |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 889 | SAFE_PARCEL_READ_SIZE(input->readInt32, &numExcludeHandles, input->dataSize()); |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 890 | excludeHandles.reserve(numExcludeHandles); |
| 891 | for (int i = 0; i < numExcludeHandles; i++) { |
| 892 | sp<IBinder> binder; |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 893 | SAFE_PARCEL(input->readStrongBinder, &binder); |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 894 | excludeHandles.emplace(binder); |
| 895 | } |
| 896 | |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 897 | SAFE_PARCEL(input->readBool, &childrenOnly); |
chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 898 | return NO_ERROR; |
chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 899 | } |
| 900 | |
Huihong Luo | 9e84f33 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 901 | }; // namespace gui |
| 902 | |
chaviw | 8dd181f | 2022-01-05 18:36:46 -0600 | [diff] [blame] | 903 | ReleaseCallbackId BufferData::generateReleaseCallbackId() const { |
chaviw | dcba9e0 | 2022-03-21 17:54:23 -0500 | [diff] [blame] | 904 | uint64_t bufferId; |
| 905 | if (buffer) { |
| 906 | bufferId = buffer->getId(); |
| 907 | } else { |
| 908 | bufferId = cachedBuffer.id; |
| 909 | } |
| 910 | return {bufferId, frameNumber}; |
chaviw | 8dd181f | 2022-01-05 18:36:46 -0600 | [diff] [blame] | 911 | } |
| 912 | |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 913 | status_t BufferData::writeToParcel(Parcel* output) const { |
| 914 | SAFE_PARCEL(output->writeInt32, flags.get()); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 915 | |
| 916 | if (buffer) { |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 917 | SAFE_PARCEL(output->writeBool, true); |
| 918 | SAFE_PARCEL(output->write, *buffer); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 919 | } else { |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 920 | SAFE_PARCEL(output->writeBool, false); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 921 | } |
| 922 | |
| 923 | if (acquireFence) { |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 924 | SAFE_PARCEL(output->writeBool, true); |
| 925 | SAFE_PARCEL(output->write, *acquireFence); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 926 | } else { |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 927 | SAFE_PARCEL(output->writeBool, false); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 928 | } |
| 929 | |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 930 | SAFE_PARCEL(output->writeUint64, frameNumber); |
| 931 | SAFE_PARCEL(output->writeStrongBinder, IInterface::asBinder(releaseBufferListener)); |
| 932 | SAFE_PARCEL(output->writeStrongBinder, releaseBufferEndpoint); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 933 | |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 934 | SAFE_PARCEL(output->writeStrongBinder, cachedBuffer.token.promote()); |
| 935 | SAFE_PARCEL(output->writeUint64, cachedBuffer.id); |
Robert Carr | 79dc06a | 2022-02-22 15:28:59 -0800 | [diff] [blame] | 936 | SAFE_PARCEL(output->writeBool, hasBarrier); |
| 937 | SAFE_PARCEL(output->writeUint64, barrierFrameNumber); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 938 | |
| 939 | return NO_ERROR; |
| 940 | } |
| 941 | |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 942 | status_t BufferData::readFromParcel(const Parcel* input) { |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 943 | int32_t tmpInt32; |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 944 | SAFE_PARCEL(input->readInt32, &tmpInt32); |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 945 | flags = ftl::Flags<BufferDataChange>(tmpInt32); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 946 | |
| 947 | bool tmpBool = false; |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 948 | SAFE_PARCEL(input->readBool, &tmpBool); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 949 | if (tmpBool) { |
| 950 | buffer = new GraphicBuffer(); |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 951 | SAFE_PARCEL(input->read, *buffer); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 952 | } |
| 953 | |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 954 | SAFE_PARCEL(input->readBool, &tmpBool); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 955 | if (tmpBool) { |
| 956 | acquireFence = new Fence(); |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 957 | SAFE_PARCEL(input->read, *acquireFence); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 958 | } |
| 959 | |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 960 | SAFE_PARCEL(input->readUint64, &frameNumber); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 961 | |
| 962 | sp<IBinder> tmpBinder = nullptr; |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 963 | SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 964 | if (tmpBinder) { |
| 965 | releaseBufferListener = checked_interface_cast<ITransactionCompletedListener>(tmpBinder); |
| 966 | } |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 967 | SAFE_PARCEL(input->readNullableStrongBinder, &releaseBufferEndpoint); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 968 | |
| 969 | tmpBinder = nullptr; |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 970 | SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 971 | cachedBuffer.token = tmpBinder; |
Vishnu Nair | 9f0835e | 2022-01-07 09:33:19 -0800 | [diff] [blame] | 972 | SAFE_PARCEL(input->readUint64, &cachedBuffer.id); |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 973 | |
Robert Carr | 79dc06a | 2022-02-22 15:28:59 -0800 | [diff] [blame] | 974 | SAFE_PARCEL(input->readBool, &hasBarrier); |
| 975 | SAFE_PARCEL(input->readUint64, &barrierFrameNumber); |
| 976 | |
chaviw | ba4320c | 2021-09-15 15:20:53 -0500 | [diff] [blame] | 977 | return NO_ERROR; |
| 978 | } |
| 979 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 980 | }; // namespace android |