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