| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2008 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
| Vishnu Nair | 217d8e6 | 2018-09-12 16:34:49 -0700 | [diff] [blame] | 17 | #define LOG_TAG "LayerState" | 
|  | 18 |  | 
| Ady Abraham | dd5bfa9 | 2021-01-07 17:56:08 -0800 | [diff] [blame] | 19 | #include <apex/window.h> | 
| Garfield Tan | 8a3083e | 2018-12-03 13:21:07 -0800 | [diff] [blame] | 20 | #include <inttypes.h> | 
|  | 21 |  | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 22 | #include <android/native_window.h> | 
| Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 23 | #include <binder/Parcel.h> | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 24 | #include <gui/IGraphicBufferProducer.h> | 
| Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 25 | #include <gui/ISurfaceComposerClient.h> | 
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 26 | #include <gui/LayerState.h> | 
| Marin Shalamanov | 3b1f7bc | 2021-03-16 15:51:53 +0100 | [diff] [blame] | 27 | #include <private/gui/ParcelUtils.h> | 
| Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 28 | #include <utils/Errors.h> | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 |  | 
| Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 30 | #include <cmath> | 
|  | 31 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | namespace android { | 
|  | 33 |  | 
| chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 34 | using gui::FocusRequest; | 
|  | 35 | using gui::WindowInfoHandle; | 
|  | 36 |  | 
| Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 37 | layer_state_t::layer_state_t() | 
|  | 38 | : what(0), | 
|  | 39 | x(0), | 
|  | 40 | y(0), | 
|  | 41 | z(0), | 
|  | 42 | w(0), | 
|  | 43 | h(0), | 
|  | 44 | layerStack(0), | 
|  | 45 | alpha(0), | 
|  | 46 | flags(0), | 
|  | 47 | mask(0), | 
|  | 48 | reserved(0), | 
| Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 49 | cornerRadius(0.0f), | 
|  | 50 | backgroundBlurRadius(0), | 
| Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 51 | transform(0), | 
|  | 52 | transformToDisplayInverse(false), | 
|  | 53 | crop(Rect::INVALID_RECT), | 
|  | 54 | orientedDisplaySpaceRect(Rect::INVALID_RECT), | 
|  | 55 | dataspace(ui::Dataspace::UNKNOWN), | 
|  | 56 | surfaceDamageRegion(), | 
|  | 57 | api(-1), | 
|  | 58 | colorTransform(mat4()), | 
|  | 59 | bgColorAlpha(0), | 
|  | 60 | bgColorDataspace(ui::Dataspace::UNKNOWN), | 
|  | 61 | colorSpaceAgnostic(false), | 
|  | 62 | shadowRadius(0.0f), | 
|  | 63 | frameRateSelectionPriority(-1), | 
|  | 64 | frameRate(0.0f), | 
|  | 65 | frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT), | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 66 | changeFrameRateStrategy(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS), | 
| Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 67 | fixedTransformHint(ui::Transform::ROT_INVALID), | 
| Vishnu Nair | cf26a0a | 2020-11-13 12:56:20 -0800 | [diff] [blame] | 68 | frameNumber(0), | 
| Vishnu Nair | 1506b18 | 2021-02-22 14:35:15 -0800 | [diff] [blame] | 69 | autoRefresh(false), | 
| Winson Chung | a30f7c9 | 2021-06-29 15:42:56 -0700 | [diff] [blame] | 70 | isTrustedOverlay(false), | 
| Vishnu Nair | 6bdec7d | 2021-05-10 15:01:13 -0700 | [diff] [blame] | 71 | bufferCrop(Rect::INVALID_RECT), | 
|  | 72 | destinationFrame(Rect::INVALID_RECT), | 
| Vishnu Nair | 1506b18 | 2021-02-22 14:35:15 -0800 | [diff] [blame] | 73 | releaseBufferListener(nullptr) { | 
| Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 74 | matrix.dsdx = matrix.dtdy = 1.0f; | 
|  | 75 | matrix.dsdy = matrix.dtdx = 0.0f; | 
|  | 76 | hdrMetadata.validTypes = 0; | 
|  | 77 | } | 
|  | 78 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 79 | status_t layer_state_t::write(Parcel& output) const | 
|  | 80 | { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 81 | SAFE_PARCEL(output.writeStrongBinder, surface); | 
| Pablo Gamito | dbc3167 | 2020-09-01 18:28:58 +0000 | [diff] [blame] | 82 | SAFE_PARCEL(output.writeInt32, layerId); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 83 | SAFE_PARCEL(output.writeUint64, what); | 
|  | 84 | SAFE_PARCEL(output.writeFloat, x); | 
|  | 85 | SAFE_PARCEL(output.writeFloat, y); | 
|  | 86 | SAFE_PARCEL(output.writeInt32, z); | 
|  | 87 | SAFE_PARCEL(output.writeUint32, w); | 
|  | 88 | SAFE_PARCEL(output.writeUint32, h); | 
|  | 89 | SAFE_PARCEL(output.writeUint32, layerStack); | 
|  | 90 | SAFE_PARCEL(output.writeFloat, alpha); | 
|  | 91 | SAFE_PARCEL(output.writeUint32, flags); | 
|  | 92 | SAFE_PARCEL(output.writeUint32, mask); | 
|  | 93 | SAFE_PARCEL(matrix.write, output); | 
| chaviw | 2571450 | 2021-02-11 10:01:08 -0800 | [diff] [blame] | 94 | SAFE_PARCEL(output.write, crop); | 
| Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 95 | SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, reparentSurfaceControl); | 
| Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 96 | SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, relativeLayerSurfaceControl); | 
|  | 97 | SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, parentSurfaceControlForChild); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 98 | SAFE_PARCEL(output.writeFloat, color.r); | 
|  | 99 | SAFE_PARCEL(output.writeFloat, color.g); | 
|  | 100 | SAFE_PARCEL(output.writeFloat, color.b); | 
| chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 101 | SAFE_PARCEL(windowInfoHandle->writeToParcel, &output); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 102 | SAFE_PARCEL(output.write, transparentRegion); | 
|  | 103 | SAFE_PARCEL(output.writeUint32, transform); | 
|  | 104 | SAFE_PARCEL(output.writeBool, transformToDisplayInverse); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 105 | SAFE_PARCEL(output.write, orientedDisplaySpaceRect); | 
|  | 106 |  | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 107 | if (buffer) { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 108 | SAFE_PARCEL(output.writeBool, true); | 
|  | 109 | SAFE_PARCEL(output.write, *buffer); | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 110 | } else { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 111 | SAFE_PARCEL(output.writeBool, false); | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 112 | } | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 113 |  | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 114 | if (acquireFence) { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 115 | SAFE_PARCEL(output.writeBool, true); | 
|  | 116 | SAFE_PARCEL(output.write, *acquireFence); | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 117 | } else { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 118 | SAFE_PARCEL(output.writeBool, false); | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 119 | } | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 120 |  | 
|  | 121 | SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dataspace)); | 
|  | 122 | SAFE_PARCEL(output.write, hdrMetadata); | 
|  | 123 | SAFE_PARCEL(output.write, surfaceDamageRegion); | 
|  | 124 | SAFE_PARCEL(output.writeInt32, api); | 
|  | 125 |  | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 126 | if (sidebandStream) { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 127 | SAFE_PARCEL(output.writeBool, true); | 
|  | 128 | SAFE_PARCEL(output.writeNativeHandle, sidebandStream->handle()); | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 129 | } else { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 130 | SAFE_PARCEL(output.writeBool, false); | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 131 | } | 
|  | 132 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 133 | SAFE_PARCEL(output.write, colorTransform.asArray(), 16 * sizeof(float)); | 
|  | 134 | SAFE_PARCEL(output.writeFloat, cornerRadius); | 
|  | 135 | SAFE_PARCEL(output.writeUint32, backgroundBlurRadius); | 
|  | 136 | SAFE_PARCEL(output.writeStrongBinder, cachedBuffer.token.promote()); | 
|  | 137 | SAFE_PARCEL(output.writeUint64, cachedBuffer.id); | 
|  | 138 | SAFE_PARCEL(output.writeParcelable, metadata); | 
|  | 139 | SAFE_PARCEL(output.writeFloat, bgColorAlpha); | 
|  | 140 | SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(bgColorDataspace)); | 
|  | 141 | SAFE_PARCEL(output.writeBool, colorSpaceAgnostic); | 
|  | 142 | SAFE_PARCEL(output.writeVectorSize, listeners); | 
| Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 143 |  | 
|  | 144 | for (auto listener : listeners) { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 145 | SAFE_PARCEL(output.writeStrongBinder, listener.transactionCompletedListener); | 
| Vishnu Nair | fc46c1e | 2021-04-21 08:31:32 -0700 | [diff] [blame] | 146 | SAFE_PARCEL(output.writeParcelableVector, listener.callbackIds); | 
| Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 147 | } | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 148 | SAFE_PARCEL(output.writeFloat, shadowRadius); | 
|  | 149 | SAFE_PARCEL(output.writeInt32, frameRateSelectionPriority); | 
|  | 150 | SAFE_PARCEL(output.writeFloat, frameRate); | 
|  | 151 | SAFE_PARCEL(output.writeByte, frameRateCompatibility); | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 152 | SAFE_PARCEL(output.writeByte, changeFrameRateStrategy); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 153 | SAFE_PARCEL(output.writeUint32, fixedTransformHint); | 
| Vishnu Nair | 6b7c5c9 | 2020-09-29 17:27:05 -0700 | [diff] [blame] | 154 | SAFE_PARCEL(output.writeUint64, frameNumber); | 
| Vishnu Nair | cf26a0a | 2020-11-13 12:56:20 -0800 | [diff] [blame] | 155 | SAFE_PARCEL(output.writeBool, autoRefresh); | 
| Vishnu Nair | 1506b18 | 2021-02-22 14:35:15 -0800 | [diff] [blame] | 156 | SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(releaseBufferListener)); | 
| Lucas Dupin | c3800b8 | 2020-10-02 16:24:48 -0700 | [diff] [blame] | 157 |  | 
|  | 158 | SAFE_PARCEL(output.writeUint32, blurRegions.size()); | 
|  | 159 | for (auto region : blurRegions) { | 
|  | 160 | SAFE_PARCEL(output.writeUint32, region.blurRadius); | 
|  | 161 | SAFE_PARCEL(output.writeFloat, region.cornerRadiusTL); | 
|  | 162 | SAFE_PARCEL(output.writeFloat, region.cornerRadiusTR); | 
|  | 163 | SAFE_PARCEL(output.writeFloat, region.cornerRadiusBL); | 
|  | 164 | SAFE_PARCEL(output.writeFloat, region.cornerRadiusBR); | 
|  | 165 | SAFE_PARCEL(output.writeFloat, region.alpha); | 
|  | 166 | SAFE_PARCEL(output.writeInt32, region.left); | 
|  | 167 | SAFE_PARCEL(output.writeInt32, region.top); | 
|  | 168 | SAFE_PARCEL(output.writeInt32, region.right); | 
|  | 169 | SAFE_PARCEL(output.writeInt32, region.bottom); | 
|  | 170 | } | 
| John Reck | cdb4ed7 | 2021-02-04 13:39:33 -0500 | [diff] [blame] | 171 |  | 
|  | 172 | SAFE_PARCEL(output.write, stretchEffect); | 
| chaviw | f3f40fe | 2021-04-27 15:54:02 -0500 | [diff] [blame] | 173 | SAFE_PARCEL(output.write, bufferCrop); | 
| Vishnu Nair | 6bdec7d | 2021-05-10 15:01:13 -0700 | [diff] [blame] | 174 | SAFE_PARCEL(output.write, destinationFrame); | 
| Winson Chung | a30f7c9 | 2021-06-29 15:42:56 -0700 | [diff] [blame] | 175 | SAFE_PARCEL(output.writeBool, isTrustedOverlay); | 
| John Reck | cdb4ed7 | 2021-02-04 13:39:33 -0500 | [diff] [blame] | 176 |  | 
| chaviw | 0b06a8d | 2021-08-06 11:49:08 -0500 | [diff] [blame] | 177 | SAFE_PARCEL(output.writeStrongBinder, releaseBufferEndpoint); | 
| Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 178 | return NO_ERROR; | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 179 | } | 
|  | 180 |  | 
|  | 181 | status_t layer_state_t::read(const Parcel& input) | 
|  | 182 | { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 183 | SAFE_PARCEL(input.readNullableStrongBinder, &surface); | 
| Pablo Gamito | dbc3167 | 2020-09-01 18:28:58 +0000 | [diff] [blame] | 184 | SAFE_PARCEL(input.readInt32, &layerId); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 185 | SAFE_PARCEL(input.readUint64, &what); | 
|  | 186 | SAFE_PARCEL(input.readFloat, &x); | 
|  | 187 | SAFE_PARCEL(input.readFloat, &y); | 
|  | 188 | SAFE_PARCEL(input.readInt32, &z); | 
|  | 189 | SAFE_PARCEL(input.readUint32, &w); | 
|  | 190 | SAFE_PARCEL(input.readUint32, &h); | 
|  | 191 | SAFE_PARCEL(input.readUint32, &layerStack); | 
|  | 192 | SAFE_PARCEL(input.readFloat, &alpha); | 
| Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 193 |  | 
| Vishnu Nair | f6eddb6 | 2021-01-27 22:02:11 -0800 | [diff] [blame] | 194 | SAFE_PARCEL(input.readUint32, &flags); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 195 |  | 
| Vishnu Nair | f6eddb6 | 2021-01-27 22:02:11 -0800 | [diff] [blame] | 196 | SAFE_PARCEL(input.readUint32, &mask); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 197 |  | 
|  | 198 | SAFE_PARCEL(matrix.read, input); | 
| chaviw | 2571450 | 2021-02-11 10:01:08 -0800 | [diff] [blame] | 199 | SAFE_PARCEL(input.read, crop); | 
| Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 200 | SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &reparentSurfaceControl); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 201 |  | 
| Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 202 | SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &relativeLayerSurfaceControl); | 
|  | 203 | SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &parentSurfaceControlForChild); | 
|  | 204 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 205 | float tmpFloat = 0; | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 206 | SAFE_PARCEL(input.readFloat, &tmpFloat); | 
|  | 207 | color.r = tmpFloat; | 
|  | 208 | SAFE_PARCEL(input.readFloat, &tmpFloat); | 
|  | 209 | color.g = tmpFloat; | 
|  | 210 | SAFE_PARCEL(input.readFloat, &tmpFloat); | 
|  | 211 | color.b = tmpFloat; | 
| chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 212 | SAFE_PARCEL(windowInfoHandle->readFromParcel, &input); | 
| Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 213 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 214 | SAFE_PARCEL(input.read, transparentRegion); | 
|  | 215 | SAFE_PARCEL(input.readUint32, &transform); | 
|  | 216 | SAFE_PARCEL(input.readBool, &transformToDisplayInverse); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 217 | SAFE_PARCEL(input.read, orientedDisplaySpaceRect); | 
|  | 218 |  | 
|  | 219 | bool tmpBool = false; | 
|  | 220 | SAFE_PARCEL(input.readBool, &tmpBool); | 
|  | 221 | if (tmpBool) { | 
|  | 222 | buffer = new GraphicBuffer(); | 
|  | 223 | SAFE_PARCEL(input.read, *buffer); | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 224 | } | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 225 |  | 
|  | 226 | SAFE_PARCEL(input.readBool, &tmpBool); | 
|  | 227 | if (tmpBool) { | 
|  | 228 | acquireFence = new Fence(); | 
|  | 229 | SAFE_PARCEL(input.read, *acquireFence); | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 230 | } | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 231 |  | 
| Vishnu Nair | f6eddb6 | 2021-01-27 22:02:11 -0800 | [diff] [blame] | 232 | uint32_t tmpUint32 = 0; | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 233 | SAFE_PARCEL(input.readUint32, &tmpUint32); | 
|  | 234 | dataspace = static_cast<ui::Dataspace>(tmpUint32); | 
|  | 235 |  | 
|  | 236 | SAFE_PARCEL(input.read, hdrMetadata); | 
|  | 237 | SAFE_PARCEL(input.read, surfaceDamageRegion); | 
|  | 238 | SAFE_PARCEL(input.readInt32, &api); | 
|  | 239 | SAFE_PARCEL(input.readBool, &tmpBool); | 
|  | 240 | if (tmpBool) { | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 241 | sidebandStream = NativeHandle::create(input.readNativeHandle(), true); | 
|  | 242 | } | 
|  | 243 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 244 | SAFE_PARCEL(input.read, &colorTransform, 16 * sizeof(float)); | 
|  | 245 | SAFE_PARCEL(input.readFloat, &cornerRadius); | 
|  | 246 | SAFE_PARCEL(input.readUint32, &backgroundBlurRadius); | 
| Pablo Gamito | c351d6f | 2020-09-17 15:34:26 +0000 | [diff] [blame] | 247 | sp<IBinder> tmpBinder; | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 248 | SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder); | 
|  | 249 | cachedBuffer.token = tmpBinder; | 
|  | 250 | SAFE_PARCEL(input.readUint64, &cachedBuffer.id); | 
|  | 251 | SAFE_PARCEL(input.readParcelable, &metadata); | 
| Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 252 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 253 | SAFE_PARCEL(input.readFloat, &bgColorAlpha); | 
|  | 254 | SAFE_PARCEL(input.readUint32, &tmpUint32); | 
|  | 255 | bgColorDataspace = static_cast<ui::Dataspace>(tmpUint32); | 
|  | 256 | SAFE_PARCEL(input.readBool, &colorSpaceAgnostic); | 
| Valerie Hau | ed54efa | 2019-01-11 20:03:14 -0800 | [diff] [blame] | 257 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 258 | int32_t numListeners = 0; | 
|  | 259 | SAFE_PARCEL_READ_SIZE(input.readInt32, &numListeners, input.dataSize()); | 
| Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 260 | listeners.clear(); | 
|  | 261 | for (int i = 0; i < numListeners; i++) { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 262 | sp<IBinder> listener; | 
| Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 263 | std::vector<CallbackId> callbackIds; | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 264 | SAFE_PARCEL(input.readNullableStrongBinder, &listener); | 
| Vishnu Nair | fc46c1e | 2021-04-21 08:31:32 -0700 | [diff] [blame] | 265 | SAFE_PARCEL(input.readParcelableVector, &callbackIds); | 
| Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 266 | listeners.emplace_back(listener, callbackIds); | 
|  | 267 | } | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 268 | SAFE_PARCEL(input.readFloat, &shadowRadius); | 
|  | 269 | SAFE_PARCEL(input.readInt32, &frameRateSelectionPriority); | 
|  | 270 | SAFE_PARCEL(input.readFloat, &frameRate); | 
|  | 271 | SAFE_PARCEL(input.readByte, &frameRateCompatibility); | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 272 | SAFE_PARCEL(input.readByte, &changeFrameRateStrategy); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 273 | SAFE_PARCEL(input.readUint32, &tmpUint32); | 
|  | 274 | fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32); | 
| Vishnu Nair | 6b7c5c9 | 2020-09-29 17:27:05 -0700 | [diff] [blame] | 275 | SAFE_PARCEL(input.readUint64, &frameNumber); | 
| Vishnu Nair | cf26a0a | 2020-11-13 12:56:20 -0800 | [diff] [blame] | 276 | SAFE_PARCEL(input.readBool, &autoRefresh); | 
| Lucas Dupin | c3800b8 | 2020-10-02 16:24:48 -0700 | [diff] [blame] | 277 |  | 
| Vishnu Nair | 1506b18 | 2021-02-22 14:35:15 -0800 | [diff] [blame] | 278 | tmpBinder = nullptr; | 
|  | 279 | SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder); | 
|  | 280 | if (tmpBinder) { | 
|  | 281 | releaseBufferListener = checked_interface_cast<ITransactionCompletedListener>(tmpBinder); | 
|  | 282 | } | 
|  | 283 |  | 
| Lucas Dupin | c3800b8 | 2020-10-02 16:24:48 -0700 | [diff] [blame] | 284 | uint32_t numRegions = 0; | 
|  | 285 | SAFE_PARCEL(input.readUint32, &numRegions); | 
|  | 286 | blurRegions.clear(); | 
|  | 287 | for (uint32_t i = 0; i < numRegions; i++) { | 
|  | 288 | BlurRegion region; | 
|  | 289 | SAFE_PARCEL(input.readUint32, ®ion.blurRadius); | 
|  | 290 | SAFE_PARCEL(input.readFloat, ®ion.cornerRadiusTL); | 
|  | 291 | SAFE_PARCEL(input.readFloat, ®ion.cornerRadiusTR); | 
|  | 292 | SAFE_PARCEL(input.readFloat, ®ion.cornerRadiusBL); | 
|  | 293 | SAFE_PARCEL(input.readFloat, ®ion.cornerRadiusBR); | 
|  | 294 | SAFE_PARCEL(input.readFloat, ®ion.alpha); | 
|  | 295 | SAFE_PARCEL(input.readInt32, ®ion.left); | 
|  | 296 | SAFE_PARCEL(input.readInt32, ®ion.top); | 
|  | 297 | SAFE_PARCEL(input.readInt32, ®ion.right); | 
|  | 298 | SAFE_PARCEL(input.readInt32, ®ion.bottom); | 
|  | 299 | blurRegions.push_back(region); | 
|  | 300 | } | 
| John Reck | cdb4ed7 | 2021-02-04 13:39:33 -0500 | [diff] [blame] | 301 |  | 
|  | 302 | SAFE_PARCEL(input.read, stretchEffect); | 
| chaviw | f3f40fe | 2021-04-27 15:54:02 -0500 | [diff] [blame] | 303 | SAFE_PARCEL(input.read, bufferCrop); | 
| Vishnu Nair | 6bdec7d | 2021-05-10 15:01:13 -0700 | [diff] [blame] | 304 | SAFE_PARCEL(input.read, destinationFrame); | 
| Winson Chung | a30f7c9 | 2021-06-29 15:42:56 -0700 | [diff] [blame] | 305 | SAFE_PARCEL(input.readBool, &isTrustedOverlay); | 
| John Reck | cdb4ed7 | 2021-02-04 13:39:33 -0500 | [diff] [blame] | 306 |  | 
| chaviw | 0b06a8d | 2021-08-06 11:49:08 -0500 | [diff] [blame] | 307 | SAFE_PARCEL(input.readNullableStrongBinder, &releaseBufferEndpoint); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 308 | return NO_ERROR; | 
|  | 309 | } | 
|  | 310 |  | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 311 | status_t ComposerState::write(Parcel& output) const { | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 312 | return state.write(output); | 
|  | 313 | } | 
|  | 314 |  | 
|  | 315 | status_t ComposerState::read(const Parcel& input) { | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 316 | return state.read(input); | 
|  | 317 | } | 
|  | 318 |  | 
| Marin Shalamanov | 6ad317c | 2020-07-29 23:34:07 +0200 | [diff] [blame] | 319 | DisplayState::DisplayState() | 
|  | 320 | : what(0), | 
|  | 321 | layerStack(0), | 
| Evan Rosky | 2239b37 | 2021-05-20 13:43:47 -0700 | [diff] [blame] | 322 | flags(0), | 
| Marin Shalamanov | 6ad317c | 2020-07-29 23:34:07 +0200 | [diff] [blame] | 323 | layerStackSpaceRect(Rect::EMPTY_RECT), | 
|  | 324 | orientedDisplaySpaceRect(Rect::EMPTY_RECT), | 
|  | 325 | width(0), | 
|  | 326 | height(0) {} | 
| Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 327 |  | 
| Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 328 | status_t DisplayState::write(Parcel& output) const { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 329 | SAFE_PARCEL(output.writeStrongBinder, token); | 
|  | 330 | SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(surface)); | 
|  | 331 | SAFE_PARCEL(output.writeUint32, what); | 
|  | 332 | SAFE_PARCEL(output.writeUint32, layerStack); | 
| Evan Rosky | 2239b37 | 2021-05-20 13:43:47 -0700 | [diff] [blame] | 333 | SAFE_PARCEL(output.writeUint32, flags); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 334 | SAFE_PARCEL(output.writeUint32, toRotationInt(orientation)); | 
|  | 335 | SAFE_PARCEL(output.write, layerStackSpaceRect); | 
|  | 336 | SAFE_PARCEL(output.write, orientedDisplaySpaceRect); | 
|  | 337 | SAFE_PARCEL(output.writeUint32, width); | 
|  | 338 | SAFE_PARCEL(output.writeUint32, height); | 
| Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 339 | return NO_ERROR; | 
|  | 340 | } | 
|  | 341 |  | 
|  | 342 | status_t DisplayState::read(const Parcel& input) { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 343 | SAFE_PARCEL(input.readStrongBinder, &token); | 
|  | 344 | sp<IBinder> tmpBinder; | 
|  | 345 | SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder); | 
|  | 346 | surface = interface_cast<IGraphicBufferProducer>(tmpBinder); | 
|  | 347 |  | 
|  | 348 | SAFE_PARCEL(input.readUint32, &what); | 
|  | 349 | SAFE_PARCEL(input.readUint32, &layerStack); | 
| Evan Rosky | 2239b37 | 2021-05-20 13:43:47 -0700 | [diff] [blame] | 350 | SAFE_PARCEL(input.readUint32, &flags); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 351 | uint32_t tmpUint = 0; | 
|  | 352 | SAFE_PARCEL(input.readUint32, &tmpUint); | 
|  | 353 | orientation = ui::toRotation(tmpUint); | 
|  | 354 |  | 
|  | 355 | SAFE_PARCEL(input.read, layerStackSpaceRect); | 
|  | 356 | SAFE_PARCEL(input.read, orientedDisplaySpaceRect); | 
|  | 357 | SAFE_PARCEL(input.readUint32, &width); | 
|  | 358 | SAFE_PARCEL(input.readUint32, &height); | 
| Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 359 | return NO_ERROR; | 
|  | 360 | } | 
|  | 361 |  | 
| Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 362 | void DisplayState::merge(const DisplayState& other) { | 
|  | 363 | if (other.what & eSurfaceChanged) { | 
|  | 364 | what |= eSurfaceChanged; | 
|  | 365 | surface = other.surface; | 
|  | 366 | } | 
|  | 367 | if (other.what & eLayerStackChanged) { | 
|  | 368 | what |= eLayerStackChanged; | 
|  | 369 | layerStack = other.layerStack; | 
|  | 370 | } | 
| Evan Rosky | 2239b37 | 2021-05-20 13:43:47 -0700 | [diff] [blame] | 371 | if (other.what & eFlagsChanged) { | 
|  | 372 | what |= eFlagsChanged; | 
|  | 373 | flags = other.flags; | 
|  | 374 | } | 
| Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 375 | if (other.what & eDisplayProjectionChanged) { | 
|  | 376 | what |= eDisplayProjectionChanged; | 
|  | 377 | orientation = other.orientation; | 
| Marin Shalamanov | 6ad317c | 2020-07-29 23:34:07 +0200 | [diff] [blame] | 378 | layerStackSpaceRect = other.layerStackSpaceRect; | 
|  | 379 | orientedDisplaySpaceRect = other.orientedDisplaySpaceRect; | 
| Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 380 | } | 
|  | 381 | if (other.what & eDisplaySizeChanged) { | 
|  | 382 | what |= eDisplaySizeChanged; | 
|  | 383 | width = other.width; | 
|  | 384 | height = other.height; | 
|  | 385 | } | 
|  | 386 | } | 
|  | 387 |  | 
|  | 388 | void layer_state_t::merge(const layer_state_t& other) { | 
|  | 389 | if (other.what & ePositionChanged) { | 
|  | 390 | what |= ePositionChanged; | 
|  | 391 | x = other.x; | 
|  | 392 | y = other.y; | 
|  | 393 | } | 
|  | 394 | if (other.what & eLayerChanged) { | 
|  | 395 | what |= eLayerChanged; | 
| chaviw | 3237758 | 2019-05-13 11:15:19 -0700 | [diff] [blame] | 396 | what &= ~eRelativeLayerChanged; | 
| Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 397 | z = other.z; | 
|  | 398 | } | 
|  | 399 | if (other.what & eSizeChanged) { | 
|  | 400 | what |= eSizeChanged; | 
|  | 401 | w = other.w; | 
|  | 402 | h = other.h; | 
|  | 403 | } | 
|  | 404 | if (other.what & eAlphaChanged) { | 
|  | 405 | what |= eAlphaChanged; | 
|  | 406 | alpha = other.alpha; | 
|  | 407 | } | 
|  | 408 | if (other.what & eMatrixChanged) { | 
|  | 409 | what |= eMatrixChanged; | 
|  | 410 | matrix = other.matrix; | 
|  | 411 | } | 
|  | 412 | if (other.what & eTransparentRegionChanged) { | 
|  | 413 | what |= eTransparentRegionChanged; | 
|  | 414 | transparentRegion = other.transparentRegion; | 
|  | 415 | } | 
|  | 416 | if (other.what & eFlagsChanged) { | 
|  | 417 | what |= eFlagsChanged; | 
| Vishnu Nair | 996bc42 | 2019-07-16 14:15:33 -0700 | [diff] [blame] | 418 | flags &= ~other.mask; | 
|  | 419 | flags |= (other.flags & other.mask); | 
|  | 420 | mask |= other.mask; | 
| Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 421 | } | 
|  | 422 | if (other.what & eLayerStackChanged) { | 
|  | 423 | what |= eLayerStackChanged; | 
|  | 424 | layerStack = other.layerStack; | 
|  | 425 | } | 
| Lucas Dupin | 1b6531c | 2018-07-05 17:18:21 -0700 | [diff] [blame] | 426 | if (other.what & eCornerRadiusChanged) { | 
|  | 427 | what |= eCornerRadiusChanged; | 
|  | 428 | cornerRadius = other.cornerRadius; | 
|  | 429 | } | 
| Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame] | 430 | if (other.what & eBackgroundBlurRadiusChanged) { | 
|  | 431 | what |= eBackgroundBlurRadiusChanged; | 
|  | 432 | backgroundBlurRadius = other.backgroundBlurRadius; | 
|  | 433 | } | 
| Lucas Dupin | c3800b8 | 2020-10-02 16:24:48 -0700 | [diff] [blame] | 434 | if (other.what & eBlurRegionsChanged) { | 
|  | 435 | what |= eBlurRegionsChanged; | 
|  | 436 | blurRegions = other.blurRegions; | 
|  | 437 | } | 
| Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 438 | if (other.what & eRelativeLayerChanged) { | 
|  | 439 | what |= eRelativeLayerChanged; | 
| chaviw | 3237758 | 2019-05-13 11:15:19 -0700 | [diff] [blame] | 440 | what &= ~eLayerChanged; | 
| Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 441 | z = other.z; | 
| Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 442 | relativeLayerSurfaceControl = other.relativeLayerSurfaceControl; | 
| Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 443 | } | 
|  | 444 | if (other.what & eReparent) { | 
|  | 445 | what |= eReparent; | 
| Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 446 | parentSurfaceControlForChild = other.parentSurfaceControlForChild; | 
| Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 447 | } | 
| chaviw | ca27f25 | 2018-02-06 16:46:39 -0800 | [diff] [blame] | 448 | if (other.what & eDestroySurface) { | 
|  | 449 | what |= eDestroySurface; | 
|  | 450 | } | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 451 | if (other.what & eTransformChanged) { | 
|  | 452 | what |= eTransformChanged; | 
|  | 453 | transform = other.transform; | 
|  | 454 | } | 
|  | 455 | if (other.what & eTransformToDisplayInverseChanged) { | 
|  | 456 | what |= eTransformToDisplayInverseChanged; | 
|  | 457 | transformToDisplayInverse = other.transformToDisplayInverse; | 
|  | 458 | } | 
|  | 459 | if (other.what & eCropChanged) { | 
|  | 460 | what |= eCropChanged; | 
|  | 461 | crop = other.crop; | 
|  | 462 | } | 
|  | 463 | if (other.what & eBufferChanged) { | 
|  | 464 | what |= eBufferChanged; | 
|  | 465 | buffer = other.buffer; | 
| chaviw | 9c3cb1a | 2021-08-11 11:33:34 -0500 | [diff] [blame] | 466 | releaseBufferEndpoint = other.releaseBufferEndpoint; | 
| Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 467 | } | 
|  | 468 | if (other.what & eAcquireFenceChanged) { | 
|  | 469 | what |= eAcquireFenceChanged; | 
|  | 470 | acquireFence = other.acquireFence; | 
|  | 471 | } | 
|  | 472 | if (other.what & eDataspaceChanged) { | 
|  | 473 | what |= eDataspaceChanged; | 
|  | 474 | dataspace = other.dataspace; | 
|  | 475 | } | 
|  | 476 | if (other.what & eHdrMetadataChanged) { | 
|  | 477 | what |= eHdrMetadataChanged; | 
|  | 478 | hdrMetadata = other.hdrMetadata; | 
|  | 479 | } | 
|  | 480 | if (other.what & eSurfaceDamageRegionChanged) { | 
|  | 481 | what |= eSurfaceDamageRegionChanged; | 
|  | 482 | surfaceDamageRegion = other.surfaceDamageRegion; | 
|  | 483 | } | 
|  | 484 | if (other.what & eApiChanged) { | 
|  | 485 | what |= eApiChanged; | 
|  | 486 | api = other.api; | 
|  | 487 | } | 
|  | 488 | if (other.what & eSidebandStreamChanged) { | 
|  | 489 | what |= eSidebandStreamChanged; | 
|  | 490 | sidebandStream = other.sidebandStream; | 
|  | 491 | } | 
| Peiyong Lin | d378863 | 2018-09-18 16:01:31 -0700 | [diff] [blame] | 492 | if (other.what & eColorTransformChanged) { | 
|  | 493 | what |= eColorTransformChanged; | 
|  | 494 | colorTransform = other.colorTransform; | 
|  | 495 | } | 
| Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame] | 496 | if (other.what & eHasListenerCallbacksChanged) { | 
|  | 497 | what |= eHasListenerCallbacksChanged; | 
| Marissa Wall | c837b5e | 2018-10-12 10:04:44 -0700 | [diff] [blame] | 498 | } | 
| Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 499 | if (other.what & eInputInfoChanged) { | 
|  | 500 | what |= eInputInfoChanged; | 
| chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 501 | windowInfoHandle = new WindowInfoHandle(*other.windowInfoHandle); | 
| Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 502 | } | 
| Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 503 | if (other.what & eCachedBufferChanged) { | 
|  | 504 | what |= eCachedBufferChanged; | 
|  | 505 | cachedBuffer = other.cachedBuffer; | 
|  | 506 | } | 
| Valerie Hau | dd0b757 | 2019-01-29 14:59:27 -0800 | [diff] [blame] | 507 | if (other.what & eBackgroundColorChanged) { | 
|  | 508 | what |= eBackgroundColorChanged; | 
|  | 509 | color = other.color; | 
|  | 510 | bgColorAlpha = other.bgColorAlpha; | 
|  | 511 | bgColorDataspace = other.bgColorDataspace; | 
| Valerie Hau | ed54efa | 2019-01-11 20:03:14 -0800 | [diff] [blame] | 512 | } | 
| Evan Rosky | 1f6d6d5 | 2018-12-06 10:47:26 -0800 | [diff] [blame] | 513 | if (other.what & eMetadataChanged) { | 
|  | 514 | what |= eMetadataChanged; | 
|  | 515 | metadata.merge(other.metadata); | 
|  | 516 | } | 
| Vishnu Nair | c97b8db | 2019-10-29 18:19:35 -0700 | [diff] [blame] | 517 | if (other.what & eShadowRadiusChanged) { | 
|  | 518 | what |= eShadowRadiusChanged; | 
|  | 519 | shadowRadius = other.shadowRadius; | 
|  | 520 | } | 
| Ana Krulec | c84d09b | 2019-11-02 23:10:29 +0100 | [diff] [blame] | 521 | if (other.what & eFrameRateSelectionPriority) { | 
|  | 522 | what |= eFrameRateSelectionPriority; | 
|  | 523 | frameRateSelectionPriority = other.frameRateSelectionPriority; | 
|  | 524 | } | 
| Steven Thomas | 3172e20 | 2020-01-06 19:25:30 -0800 | [diff] [blame] | 525 | if (other.what & eFrameRateChanged) { | 
|  | 526 | what |= eFrameRateChanged; | 
|  | 527 | frameRate = other.frameRate; | 
| Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 528 | frameRateCompatibility = other.frameRateCompatibility; | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 529 | changeFrameRateStrategy = other.changeFrameRateStrategy; | 
| Steven Thomas | 3172e20 | 2020-01-06 19:25:30 -0800 | [diff] [blame] | 530 | } | 
| Vishnu Nair | 6213bd9 | 2020-05-08 17:42:25 -0700 | [diff] [blame] | 531 | if (other.what & eFixedTransformHintChanged) { | 
|  | 532 | what |= eFixedTransformHintChanged; | 
|  | 533 | fixedTransformHint = other.fixedTransformHint; | 
|  | 534 | } | 
| Vishnu Nair | 6b7c5c9 | 2020-09-29 17:27:05 -0700 | [diff] [blame] | 535 | if (other.what & eFrameNumberChanged) { | 
|  | 536 | what |= eFrameNumberChanged; | 
|  | 537 | frameNumber = other.frameNumber; | 
|  | 538 | } | 
| Vishnu Nair | cf26a0a | 2020-11-13 12:56:20 -0800 | [diff] [blame] | 539 | if (other.what & eAutoRefreshChanged) { | 
|  | 540 | what |= eAutoRefreshChanged; | 
|  | 541 | autoRefresh = other.autoRefresh; | 
|  | 542 | } | 
| Winson Chung | a30f7c9 | 2021-06-29 15:42:56 -0700 | [diff] [blame] | 543 | if (other.what & eTrustedOverlayChanged) { | 
|  | 544 | what |= eTrustedOverlayChanged; | 
|  | 545 | isTrustedOverlay = other.isTrustedOverlay; | 
|  | 546 | } | 
| Vishnu Nair | 1506b18 | 2021-02-22 14:35:15 -0800 | [diff] [blame] | 547 | if (other.what & eReleaseBufferListenerChanged) { | 
|  | 548 | if (releaseBufferListener) { | 
|  | 549 | ALOGW("Overriding releaseBufferListener"); | 
|  | 550 | } | 
|  | 551 | what |= eReleaseBufferListenerChanged; | 
|  | 552 | releaseBufferListener = other.releaseBufferListener; | 
|  | 553 | } | 
| John Reck | c00c669 | 2021-02-16 11:37:33 -0500 | [diff] [blame] | 554 | if (other.what & eStretchChanged) { | 
|  | 555 | what |= eStretchChanged; | 
|  | 556 | stretchEffect = other.stretchEffect; | 
|  | 557 | } | 
| chaviw | f3f40fe | 2021-04-27 15:54:02 -0500 | [diff] [blame] | 558 | if (other.what & eBufferCropChanged) { | 
|  | 559 | what |= eBufferCropChanged; | 
|  | 560 | bufferCrop = other.bufferCrop; | 
|  | 561 | } | 
| Vishnu Nair | 6bdec7d | 2021-05-10 15:01:13 -0700 | [diff] [blame] | 562 | if (other.what & eDestinationFrameChanged) { | 
|  | 563 | what |= eDestinationFrameChanged; | 
|  | 564 | destinationFrame = other.destinationFrame; | 
|  | 565 | } | 
| Vishnu Nair | 217d8e6 | 2018-09-12 16:34:49 -0700 | [diff] [blame] | 566 | if ((other.what & what) != other.what) { | 
|  | 567 | ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? " | 
| Garfield Tan | 8a3083e | 2018-12-03 13:21:07 -0800 | [diff] [blame] | 568 | "other.what=0x%" PRIu64 " what=0x%" PRIu64, | 
| Vishnu Nair | 217d8e6 | 2018-09-12 16:34:49 -0700 | [diff] [blame] | 569 | other.what, what); | 
| Robert Carr | d314f16 | 2018-08-15 13:12:42 -0700 | [diff] [blame] | 570 | } | 
| Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 571 | } | 
| Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 572 |  | 
| Vishnu Nair | ddf9b5c | 2021-03-29 18:53:41 -0700 | [diff] [blame] | 573 | bool layer_state_t::hasBufferChanges() const { | 
|  | 574 | return (what & layer_state_t::eBufferChanged) || (what & layer_state_t::eCachedBufferChanged); | 
|  | 575 | } | 
|  | 576 |  | 
| Ady Abraham | 6e8e364 | 2021-07-08 19:44:07 -0700 | [diff] [blame] | 577 | bool layer_state_t::hasValidBuffer() const { | 
|  | 578 | return buffer || cachedBuffer.isValid(); | 
|  | 579 | } | 
|  | 580 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 581 | status_t layer_state_t::matrix22_t::write(Parcel& output) const { | 
|  | 582 | SAFE_PARCEL(output.writeFloat, dsdx); | 
|  | 583 | SAFE_PARCEL(output.writeFloat, dtdx); | 
|  | 584 | SAFE_PARCEL(output.writeFloat, dtdy); | 
|  | 585 | SAFE_PARCEL(output.writeFloat, dsdy); | 
|  | 586 | return NO_ERROR; | 
|  | 587 | } | 
|  | 588 |  | 
|  | 589 | status_t layer_state_t::matrix22_t::read(const Parcel& input) { | 
|  | 590 | SAFE_PARCEL(input.readFloat, &dsdx); | 
|  | 591 | SAFE_PARCEL(input.readFloat, &dtdx); | 
|  | 592 | SAFE_PARCEL(input.readFloat, &dtdy); | 
|  | 593 | SAFE_PARCEL(input.readFloat, &dsdy); | 
|  | 594 | return NO_ERROR; | 
|  | 595 | } | 
|  | 596 |  | 
| chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 597 | // ------------------------------- InputWindowCommands ---------------------------------------- | 
|  | 598 |  | 
| Vishnu Nair | e798b47 | 2020-07-23 13:52:21 -0700 | [diff] [blame] | 599 | bool InputWindowCommands::merge(const InputWindowCommands& other) { | 
|  | 600 | bool changes = false; | 
| Vishnu Nair | e798b47 | 2020-07-23 13:52:21 -0700 | [diff] [blame] | 601 | changes |= !other.focusRequests.empty(); | 
|  | 602 | focusRequests.insert(focusRequests.end(), std::make_move_iterator(other.focusRequests.begin()), | 
|  | 603 | std::make_move_iterator(other.focusRequests.end())); | 
| Vishnu Nair | e798b47 | 2020-07-23 13:52:21 -0700 | [diff] [blame] | 604 | changes |= other.syncInputWindows && !syncInputWindows; | 
| chaviw | a911b10 | 2019-02-14 10:18:33 -0800 | [diff] [blame] | 605 | syncInputWindows |= other.syncInputWindows; | 
| Vishnu Nair | e798b47 | 2020-07-23 13:52:21 -0700 | [diff] [blame] | 606 | return changes; | 
| chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 607 | } | 
|  | 608 |  | 
| Vishnu Nair | 958da93 | 2020-08-21 17:12:37 -0700 | [diff] [blame] | 609 | bool InputWindowCommands::empty() const { | 
|  | 610 | bool empty = true; | 
| Vishnu Nair | 958da93 | 2020-08-21 17:12:37 -0700 | [diff] [blame] | 611 | empty = focusRequests.empty() && !syncInputWindows; | 
| Vishnu Nair | 958da93 | 2020-08-21 17:12:37 -0700 | [diff] [blame] | 612 | return empty; | 
|  | 613 | } | 
|  | 614 |  | 
| chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 615 | void InputWindowCommands::clear() { | 
| Vishnu Nair | e798b47 | 2020-07-23 13:52:21 -0700 | [diff] [blame] | 616 | focusRequests.clear(); | 
| chaviw | a911b10 | 2019-02-14 10:18:33 -0800 | [diff] [blame] | 617 | syncInputWindows = false; | 
| chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 618 | } | 
|  | 619 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 620 | status_t InputWindowCommands::write(Parcel& output) const { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 621 | SAFE_PARCEL(output.writeParcelableVector, focusRequests); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 622 | SAFE_PARCEL(output.writeBool, syncInputWindows); | 
|  | 623 | return NO_ERROR; | 
| chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 624 | } | 
|  | 625 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 626 | status_t InputWindowCommands::read(const Parcel& input) { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 627 | SAFE_PARCEL(input.readParcelableVector, &focusRequests); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 628 | SAFE_PARCEL(input.readBool, &syncInputWindows); | 
|  | 629 | return NO_ERROR; | 
| chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 630 | } | 
|  | 631 |  | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 632 | bool ValidateFrameRate(float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy, | 
|  | 633 | const char* inFunctionName, bool privileged) { | 
| Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 634 | const char* functionName = inFunctionName != nullptr ? inFunctionName : "call"; | 
|  | 635 | int floatClassification = std::fpclassify(frameRate); | 
|  | 636 | if (frameRate < 0 || floatClassification == FP_INFINITE || floatClassification == FP_NAN) { | 
|  | 637 | ALOGE("%s failed - invalid frame rate %f", functionName, frameRate); | 
|  | 638 | return false; | 
|  | 639 | } | 
|  | 640 |  | 
|  | 641 | if (compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT && | 
| Ady Abraham | dd5bfa9 | 2021-01-07 17:56:08 -0800 | [diff] [blame] | 642 | compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE && | 
|  | 643 | (!privileged || compatibility != ANATIVEWINDOW_FRAME_RATE_EXACT)) { | 
|  | 644 | ALOGE("%s failed - invalid compatibility value %d privileged: %s", functionName, | 
|  | 645 | compatibility, privileged ? "yes" : "no"); | 
| Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 646 | return false; | 
|  | 647 | } | 
|  | 648 |  | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 649 | if (changeFrameRateStrategy != ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS && | 
|  | 650 | changeFrameRateStrategy != ANATIVEWINDOW_CHANGE_FRAME_RATE_ALWAYS) { | 
|  | 651 | ALOGE("%s failed - invalid change frame rate strategy value %d", functionName, | 
|  | 652 | changeFrameRateStrategy); | 
|  | 653 | } | 
|  | 654 |  | 
| Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 655 | return true; | 
|  | 656 | } | 
|  | 657 |  | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 658 | // ---------------------------------------------------------------------------- | 
|  | 659 |  | 
|  | 660 | status_t CaptureArgs::write(Parcel& output) const { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 661 | SAFE_PARCEL(output.writeInt32, static_cast<int32_t>(pixelFormat)); | 
|  | 662 | SAFE_PARCEL(output.write, sourceCrop); | 
| chaviw | 17ac24b | 2021-01-28 18:50:05 -0800 | [diff] [blame] | 663 | SAFE_PARCEL(output.writeFloat, frameScaleX); | 
|  | 664 | SAFE_PARCEL(output.writeFloat, frameScaleY); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 665 | SAFE_PARCEL(output.writeBool, captureSecureLayers); | 
|  | 666 | SAFE_PARCEL(output.writeInt32, uid); | 
| Peiyong Lin | cd26147 | 2020-10-06 18:05:25 -0700 | [diff] [blame] | 667 | SAFE_PARCEL(output.writeInt32, static_cast<int32_t>(dataspace)); | 
| Peiyong Lin | 05cc011 | 2020-10-14 16:16:37 -0700 | [diff] [blame] | 668 | SAFE_PARCEL(output.writeBool, allowProtected); | 
| chaviw | 17ac24b | 2021-01-28 18:50:05 -0800 | [diff] [blame] | 669 | SAFE_PARCEL(output.writeBool, grayscale); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 670 | return NO_ERROR; | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 671 | } | 
|  | 672 |  | 
|  | 673 | status_t CaptureArgs::read(const Parcel& input) { | 
| Peiyong Lin | cd26147 | 2020-10-06 18:05:25 -0700 | [diff] [blame] | 674 | int32_t value = 0; | 
|  | 675 | SAFE_PARCEL(input.readInt32, &value); | 
|  | 676 | pixelFormat = static_cast<ui::PixelFormat>(value); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 677 | SAFE_PARCEL(input.read, sourceCrop); | 
| chaviw | 17ac24b | 2021-01-28 18:50:05 -0800 | [diff] [blame] | 678 | SAFE_PARCEL(input.readFloat, &frameScaleX); | 
|  | 679 | SAFE_PARCEL(input.readFloat, &frameScaleY); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 680 | SAFE_PARCEL(input.readBool, &captureSecureLayers); | 
|  | 681 | SAFE_PARCEL(input.readInt32, &uid); | 
| Peiyong Lin | cd26147 | 2020-10-06 18:05:25 -0700 | [diff] [blame] | 682 | SAFE_PARCEL(input.readInt32, &value); | 
|  | 683 | dataspace = static_cast<ui::Dataspace>(value); | 
| Peiyong Lin | 05cc011 | 2020-10-14 16:16:37 -0700 | [diff] [blame] | 684 | SAFE_PARCEL(input.readBool, &allowProtected); | 
| chaviw | 17ac24b | 2021-01-28 18:50:05 -0800 | [diff] [blame] | 685 | SAFE_PARCEL(input.readBool, &grayscale); | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 686 | return NO_ERROR; | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 687 | } | 
|  | 688 |  | 
|  | 689 | status_t DisplayCaptureArgs::write(Parcel& output) const { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 690 | SAFE_PARCEL(CaptureArgs::write, output); | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 691 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 692 | SAFE_PARCEL(output.writeStrongBinder, displayToken); | 
|  | 693 | SAFE_PARCEL(output.writeUint32, width); | 
|  | 694 | SAFE_PARCEL(output.writeUint32, height); | 
|  | 695 | SAFE_PARCEL(output.writeBool, useIdentityTransform); | 
|  | 696 | return NO_ERROR; | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 697 | } | 
|  | 698 |  | 
|  | 699 | status_t DisplayCaptureArgs::read(const Parcel& input) { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 700 | SAFE_PARCEL(CaptureArgs::read, input); | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 701 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 702 | SAFE_PARCEL(input.readStrongBinder, &displayToken); | 
|  | 703 | SAFE_PARCEL(input.readUint32, &width); | 
|  | 704 | SAFE_PARCEL(input.readUint32, &height); | 
|  | 705 | SAFE_PARCEL(input.readBool, &useIdentityTransform); | 
|  | 706 | return NO_ERROR; | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 707 | } | 
|  | 708 |  | 
|  | 709 | status_t LayerCaptureArgs::write(Parcel& output) const { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 710 | SAFE_PARCEL(CaptureArgs::write, output); | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 711 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 712 | SAFE_PARCEL(output.writeStrongBinder, layerHandle); | 
|  | 713 | SAFE_PARCEL(output.writeInt32, excludeHandles.size()); | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 714 | for (auto el : excludeHandles) { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 715 | SAFE_PARCEL(output.writeStrongBinder, el); | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 716 | } | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 717 | SAFE_PARCEL(output.writeBool, childrenOnly); | 
|  | 718 | return NO_ERROR; | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 719 | } | 
|  | 720 |  | 
|  | 721 | status_t LayerCaptureArgs::read(const Parcel& input) { | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 722 | SAFE_PARCEL(CaptureArgs::read, input); | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 723 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 724 | SAFE_PARCEL(input.readStrongBinder, &layerHandle); | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 725 |  | 
| George Burgess IV | 4d7aceb | 2020-07-30 10:01:56 -0700 | [diff] [blame] | 726 | int32_t numExcludeHandles = 0; | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 727 | SAFE_PARCEL_READ_SIZE(input.readInt32, &numExcludeHandles, input.dataSize()); | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 728 | excludeHandles.reserve(numExcludeHandles); | 
|  | 729 | for (int i = 0; i < numExcludeHandles; i++) { | 
|  | 730 | sp<IBinder> binder; | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 731 | SAFE_PARCEL(input.readStrongBinder, &binder); | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 732 | excludeHandles.emplace(binder); | 
|  | 733 | } | 
|  | 734 |  | 
| chaviw | 308ddba | 2020-08-11 16:23:51 -0700 | [diff] [blame] | 735 | SAFE_PARCEL(input.readBool, &childrenOnly); | 
|  | 736 | return NO_ERROR; | 
| chaviw | 618c42d | 2020-07-24 15:25:08 -0700 | [diff] [blame] | 737 | } | 
|  | 738 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 739 | }; // namespace android |