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