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