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