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