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