blob: 27b1d8b09bab3560f6dca90c118380bf4cf772d3 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
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 Nair217d8e62018-09-12 16:34:49 -070017#define LOG_TAG "LayerState"
18
Dominik Laskowski1f6fc702022-03-21 08:34:50 -070019#include <cinttypes>
20#include <cmath>
Garfield Tan8a3083e2018-12-03 13:21:07 -080021
Huihong Luod3d8f8e2022-03-08 14:48:46 -080022#include <android/gui/ISurfaceComposerClient.h>
Marin Shalamanovc5986772021-03-16 16:09:49 +010023#include <android/native_window.h>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070024#include <binder/Parcel.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080025#include <gui/IGraphicBufferProducer.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070026#include <gui/LayerState.h>
Vishnu Nairaa799bd2022-11-16 23:09:09 +000027#include <gui/SurfaceControl.h>
Marin Shalamanov3b1f7bc2021-03-16 15:51:53 +010028#include <private/gui/ParcelUtils.h>
Dominik Laskowski1f6fc702022-03-21 08:34:50 -070029#include <system/window.h>
Pablo Gamito11dcc222020-09-12 15:49:39 +000030#include <utils/Errors.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080031
Vishnu Nairaa799bd2022-11-16 23:09:09 +000032#define CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD) \
33 { \
34 if ((OTHER.what & CHANGE_FLAG) && (FIELD != OTHER.FIELD)) { \
35 DIFF_RESULT |= CHANGE_FLAG; \
36 } \
37 }
38
39#define CHECK_DIFF2(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1, FIELD2) \
40 { \
41 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1) \
42 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD2) \
43 }
44
45#define CHECK_DIFF3(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1, FIELD2, FIELD3) \
46 { \
47 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1) \
48 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD2) \
49 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD3) \
50 }
51
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080052namespace android {
53
chaviw98318de2021-05-19 16:45:23 -050054using gui::FocusRequest;
55using gui::WindowInfoHandle;
56
Pablo Gamito11dcc222020-09-12 15:49:39 +000057layer_state_t::layer_state_t()
Vishnu Nair685cfef2022-02-02 10:01:25 -080058 : surface(nullptr),
59 layerId(-1),
60 what(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000061 x(0),
62 y(0),
63 z(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000064 flags(0),
65 mask(0),
66 reserved(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000067 cornerRadius(0.0f),
68 backgroundBlurRadius(0),
Vishnu Nairbbceb462022-10-10 04:52:13 +000069 color(0),
70 bufferTransform(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000071 transformToDisplayInverse(false),
72 crop(Rect::INVALID_RECT),
Pablo Gamito11dcc222020-09-12 15:49:39 +000073 dataspace(ui::Dataspace::UNKNOWN),
74 surfaceDamageRegion(),
75 api(-1),
76 colorTransform(mat4()),
Vishnu Naird47bcee2023-02-24 18:08:51 +000077 bgColor(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000078 bgColorDataspace(ui::Dataspace::UNKNOWN),
79 colorSpaceAgnostic(false),
80 shadowRadius(0.0f),
81 frameRateSelectionPriority(-1),
82 frameRate(0.0f),
83 frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
Marin Shalamanovc5986772021-03-16 16:09:49 +010084 changeFrameRateStrategy(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS),
Andy Labrada096227e2022-06-15 16:58:11 +000085 defaultFrameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
Rachel Leece6e0042023-06-27 11:22:54 -070086 frameRateCategory(ANATIVEWINDOW_FRAME_RATE_CATEGORY_DEFAULT),
Rachel Lee58cc90d2023-09-05 18:50:20 -070087 frameRateSelectionStrategy(ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_SELF),
Pablo Gamito11dcc222020-09-12 15:49:39 +000088 fixedTransformHint(ui::Transform::ROT_INVALID),
Vishnu Nair1506b182021-02-22 14:35:15 -080089 autoRefresh(false),
Winson Chunga30f7c92021-06-29 15:42:56 -070090 isTrustedOverlay(false),
Tianhao Yao67dd7122022-02-22 17:48:33 +000091 borderEnabled(false),
Vishnu Nair6bdec7d2021-05-10 15:01:13 -070092 bufferCrop(Rect::INVALID_RECT),
93 destinationFrame(Rect::INVALID_RECT),
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -070094 dropInputMode(gui::DropInputMode::NONE) {
Pablo Gamito11dcc222020-09-12 15:49:39 +000095 matrix.dsdx = matrix.dtdy = 1.0f;
96 matrix.dsdy = matrix.dtdx = 0.0f;
97 hdrMetadata.validTypes = 0;
98}
99
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800100status_t layer_state_t::write(Parcel& output) const
101{
chaviw308ddba2020-08-11 16:23:51 -0700102 SAFE_PARCEL(output.writeStrongBinder, surface);
Pablo Gamitodbc31672020-09-01 18:28:58 +0000103 SAFE_PARCEL(output.writeInt32, layerId);
chaviw308ddba2020-08-11 16:23:51 -0700104 SAFE_PARCEL(output.writeUint64, what);
105 SAFE_PARCEL(output.writeFloat, x);
106 SAFE_PARCEL(output.writeFloat, y);
107 SAFE_PARCEL(output.writeInt32, z);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700108 SAFE_PARCEL(output.writeUint32, layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700109 SAFE_PARCEL(output.writeUint32, flags);
110 SAFE_PARCEL(output.writeUint32, mask);
111 SAFE_PARCEL(matrix.write, output);
chaviw25714502021-02-11 10:01:08 -0800112 SAFE_PARCEL(output.write, crop);
Pablo Gamito11dcc222020-09-12 15:49:39 +0000113 SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, relativeLayerSurfaceControl);
114 SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, parentSurfaceControlForChild);
chaviw308ddba2020-08-11 16:23:51 -0700115 SAFE_PARCEL(output.writeFloat, color.r);
116 SAFE_PARCEL(output.writeFloat, color.g);
117 SAFE_PARCEL(output.writeFloat, color.b);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000118 SAFE_PARCEL(output.writeFloat, color.a);
chaviw98318de2021-05-19 16:45:23 -0500119 SAFE_PARCEL(windowInfoHandle->writeToParcel, &output);
chaviw308ddba2020-08-11 16:23:51 -0700120 SAFE_PARCEL(output.write, transparentRegion);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000121 SAFE_PARCEL(output.writeUint32, bufferTransform);
chaviw308ddba2020-08-11 16:23:51 -0700122 SAFE_PARCEL(output.writeBool, transformToDisplayInverse);
Tianhao Yao67dd7122022-02-22 17:48:33 +0000123 SAFE_PARCEL(output.writeBool, borderEnabled);
Tianhao Yao10cea3c2022-03-30 01:37:22 +0000124 SAFE_PARCEL(output.writeFloat, borderWidth);
125 SAFE_PARCEL(output.writeFloat, borderColor.r);
126 SAFE_PARCEL(output.writeFloat, borderColor.g);
127 SAFE_PARCEL(output.writeFloat, borderColor.b);
128 SAFE_PARCEL(output.writeFloat, borderColor.a);
chaviw308ddba2020-08-11 16:23:51 -0700129 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dataspace));
130 SAFE_PARCEL(output.write, hdrMetadata);
131 SAFE_PARCEL(output.write, surfaceDamageRegion);
132 SAFE_PARCEL(output.writeInt32, api);
133
Marissa Wall61c58622018-07-18 10:12:20 -0700134 if (sidebandStream) {
chaviw308ddba2020-08-11 16:23:51 -0700135 SAFE_PARCEL(output.writeBool, true);
136 SAFE_PARCEL(output.writeNativeHandle, sidebandStream->handle());
Marissa Wall61c58622018-07-18 10:12:20 -0700137 } else {
chaviw308ddba2020-08-11 16:23:51 -0700138 SAFE_PARCEL(output.writeBool, false);
Marissa Wall61c58622018-07-18 10:12:20 -0700139 }
140
chaviw308ddba2020-08-11 16:23:51 -0700141 SAFE_PARCEL(output.write, colorTransform.asArray(), 16 * sizeof(float));
142 SAFE_PARCEL(output.writeFloat, cornerRadius);
143 SAFE_PARCEL(output.writeUint32, backgroundBlurRadius);
chaviw308ddba2020-08-11 16:23:51 -0700144 SAFE_PARCEL(output.writeParcelable, metadata);
Vishnu Naird47bcee2023-02-24 18:08:51 +0000145 SAFE_PARCEL(output.writeFloat, bgColor.r);
146 SAFE_PARCEL(output.writeFloat, bgColor.g);
147 SAFE_PARCEL(output.writeFloat, bgColor.b);
148 SAFE_PARCEL(output.writeFloat, bgColor.a);
chaviw308ddba2020-08-11 16:23:51 -0700149 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(bgColorDataspace));
150 SAFE_PARCEL(output.writeBool, colorSpaceAgnostic);
151 SAFE_PARCEL(output.writeVectorSize, listeners);
Valerie Hau9dab9732019-08-20 09:29:25 -0700152
153 for (auto listener : listeners) {
chaviw308ddba2020-08-11 16:23:51 -0700154 SAFE_PARCEL(output.writeStrongBinder, listener.transactionCompletedListener);
Vishnu Nairfc46c1e2021-04-21 08:31:32 -0700155 SAFE_PARCEL(output.writeParcelableVector, listener.callbackIds);
Valerie Hau9dab9732019-08-20 09:29:25 -0700156 }
chaviw308ddba2020-08-11 16:23:51 -0700157 SAFE_PARCEL(output.writeFloat, shadowRadius);
158 SAFE_PARCEL(output.writeInt32, frameRateSelectionPriority);
159 SAFE_PARCEL(output.writeFloat, frameRate);
160 SAFE_PARCEL(output.writeByte, frameRateCompatibility);
Marin Shalamanovc5986772021-03-16 16:09:49 +0100161 SAFE_PARCEL(output.writeByte, changeFrameRateStrategy);
Andy Labrada096227e2022-06-15 16:58:11 +0000162 SAFE_PARCEL(output.writeByte, defaultFrameRateCompatibility);
Rachel Leece6e0042023-06-27 11:22:54 -0700163 SAFE_PARCEL(output.writeByte, frameRateCategory);
Rachel Lee58cc90d2023-09-05 18:50:20 -0700164 SAFE_PARCEL(output.writeByte, frameRateSelectionStrategy);
chaviw308ddba2020-08-11 16:23:51 -0700165 SAFE_PARCEL(output.writeUint32, fixedTransformHint);
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800166 SAFE_PARCEL(output.writeBool, autoRefresh);
Sally Qi81d95e62022-03-21 19:41:33 -0700167 SAFE_PARCEL(output.writeBool, dimmingEnabled);
Lucas Dupinc3800b82020-10-02 16:24:48 -0700168
169 SAFE_PARCEL(output.writeUint32, blurRegions.size());
170 for (auto region : blurRegions) {
171 SAFE_PARCEL(output.writeUint32, region.blurRadius);
172 SAFE_PARCEL(output.writeFloat, region.cornerRadiusTL);
173 SAFE_PARCEL(output.writeFloat, region.cornerRadiusTR);
174 SAFE_PARCEL(output.writeFloat, region.cornerRadiusBL);
175 SAFE_PARCEL(output.writeFloat, region.cornerRadiusBR);
176 SAFE_PARCEL(output.writeFloat, region.alpha);
177 SAFE_PARCEL(output.writeInt32, region.left);
178 SAFE_PARCEL(output.writeInt32, region.top);
179 SAFE_PARCEL(output.writeInt32, region.right);
180 SAFE_PARCEL(output.writeInt32, region.bottom);
181 }
John Reckcdb4ed72021-02-04 13:39:33 -0500182
183 SAFE_PARCEL(output.write, stretchEffect);
chaviwf3f40fe2021-04-27 15:54:02 -0500184 SAFE_PARCEL(output.write, bufferCrop);
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700185 SAFE_PARCEL(output.write, destinationFrame);
Winson Chunga30f7c92021-06-29 15:42:56 -0700186 SAFE_PARCEL(output.writeBool, isTrustedOverlay);
John Reckcdb4ed72021-02-04 13:39:33 -0500187
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700188 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode));
Vishnu Nair685cfef2022-02-02 10:01:25 -0800189
190 const bool hasBufferData = (bufferData != nullptr);
191 SAFE_PARCEL(output.writeBool, hasBufferData);
192 if (hasBufferData) {
193 SAFE_PARCEL(output.writeParcelable, *bufferData);
194 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000195 SAFE_PARCEL(output.writeParcelable, trustedPresentationThresholds);
196 SAFE_PARCEL(output.writeParcelable, trustedPresentationListener);
Sally Qi963049b2023-03-23 14:06:21 -0700197 SAFE_PARCEL(output.writeFloat, currentHdrSdrRatio);
198 SAFE_PARCEL(output.writeFloat, desiredHdrSdrRatio);
Alec Mourif4af03e2023-02-11 00:25:24 +0000199 SAFE_PARCEL(output.writeInt32, static_cast<int32_t>(cachingHint))
Mathias Agopianac9fa422013-02-11 16:40:36 -0800200 return NO_ERROR;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800201}
202
203status_t layer_state_t::read(const Parcel& input)
204{
chaviw308ddba2020-08-11 16:23:51 -0700205 SAFE_PARCEL(input.readNullableStrongBinder, &surface);
Pablo Gamitodbc31672020-09-01 18:28:58 +0000206 SAFE_PARCEL(input.readInt32, &layerId);
chaviw308ddba2020-08-11 16:23:51 -0700207 SAFE_PARCEL(input.readUint64, &what);
208 SAFE_PARCEL(input.readFloat, &x);
209 SAFE_PARCEL(input.readFloat, &y);
210 SAFE_PARCEL(input.readInt32, &z);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700211 SAFE_PARCEL(input.readUint32, &layerStack.id);
Robert Carr2c358bf2018-08-08 15:58:15 -0700212
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800213 SAFE_PARCEL(input.readUint32, &flags);
chaviw308ddba2020-08-11 16:23:51 -0700214
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800215 SAFE_PARCEL(input.readUint32, &mask);
chaviw308ddba2020-08-11 16:23:51 -0700216
217 SAFE_PARCEL(matrix.read, input);
chaviw25714502021-02-11 10:01:08 -0800218 SAFE_PARCEL(input.read, crop);
chaviw308ddba2020-08-11 16:23:51 -0700219
Pablo Gamito11dcc222020-09-12 15:49:39 +0000220 SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &relativeLayerSurfaceControl);
221 SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &parentSurfaceControlForChild);
222
chaviw308ddba2020-08-11 16:23:51 -0700223 float tmpFloat = 0;
chaviw308ddba2020-08-11 16:23:51 -0700224 SAFE_PARCEL(input.readFloat, &tmpFloat);
225 color.r = tmpFloat;
226 SAFE_PARCEL(input.readFloat, &tmpFloat);
227 color.g = tmpFloat;
228 SAFE_PARCEL(input.readFloat, &tmpFloat);
229 color.b = tmpFloat;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000230 SAFE_PARCEL(input.readFloat, &tmpFloat);
231 color.a = tmpFloat;
232
chaviw98318de2021-05-19 16:45:23 -0500233 SAFE_PARCEL(windowInfoHandle->readFromParcel, &input);
Robert Carr2c358bf2018-08-08 15:58:15 -0700234
chaviw308ddba2020-08-11 16:23:51 -0700235 SAFE_PARCEL(input.read, transparentRegion);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000236 SAFE_PARCEL(input.readUint32, &bufferTransform);
chaviw308ddba2020-08-11 16:23:51 -0700237 SAFE_PARCEL(input.readBool, &transformToDisplayInverse);
Tianhao Yao67dd7122022-02-22 17:48:33 +0000238 SAFE_PARCEL(input.readBool, &borderEnabled);
Tianhao Yao10cea3c2022-03-30 01:37:22 +0000239 SAFE_PARCEL(input.readFloat, &tmpFloat);
240 borderWidth = tmpFloat;
241 SAFE_PARCEL(input.readFloat, &tmpFloat);
242 borderColor.r = tmpFloat;
243 SAFE_PARCEL(input.readFloat, &tmpFloat);
244 borderColor.g = tmpFloat;
245 SAFE_PARCEL(input.readFloat, &tmpFloat);
246 borderColor.b = tmpFloat;
247 SAFE_PARCEL(input.readFloat, &tmpFloat);
248 borderColor.a = tmpFloat;
chaviw308ddba2020-08-11 16:23:51 -0700249
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800250 uint32_t tmpUint32 = 0;
chaviw308ddba2020-08-11 16:23:51 -0700251 SAFE_PARCEL(input.readUint32, &tmpUint32);
252 dataspace = static_cast<ui::Dataspace>(tmpUint32);
253
254 SAFE_PARCEL(input.read, hdrMetadata);
255 SAFE_PARCEL(input.read, surfaceDamageRegion);
256 SAFE_PARCEL(input.readInt32, &api);
chaviwba4320c2021-09-15 15:20:53 -0500257
258 bool tmpBool = false;
chaviw308ddba2020-08-11 16:23:51 -0700259 SAFE_PARCEL(input.readBool, &tmpBool);
260 if (tmpBool) {
Marissa Wall61c58622018-07-18 10:12:20 -0700261 sidebandStream = NativeHandle::create(input.readNativeHandle(), true);
262 }
263
chaviw308ddba2020-08-11 16:23:51 -0700264 SAFE_PARCEL(input.read, &colorTransform, 16 * sizeof(float));
265 SAFE_PARCEL(input.readFloat, &cornerRadius);
266 SAFE_PARCEL(input.readUint32, &backgroundBlurRadius);
chaviw308ddba2020-08-11 16:23:51 -0700267 SAFE_PARCEL(input.readParcelable, &metadata);
Marissa Wallebc2c052019-01-16 19:16:55 -0800268
Vishnu Naird47bcee2023-02-24 18:08:51 +0000269 SAFE_PARCEL(input.readFloat, &tmpFloat);
270 bgColor.r = tmpFloat;
271 SAFE_PARCEL(input.readFloat, &tmpFloat);
272 bgColor.g = tmpFloat;
273 SAFE_PARCEL(input.readFloat, &tmpFloat);
274 bgColor.b = tmpFloat;
275 SAFE_PARCEL(input.readFloat, &tmpFloat);
276 bgColor.a = tmpFloat;
chaviw308ddba2020-08-11 16:23:51 -0700277 SAFE_PARCEL(input.readUint32, &tmpUint32);
278 bgColorDataspace = static_cast<ui::Dataspace>(tmpUint32);
279 SAFE_PARCEL(input.readBool, &colorSpaceAgnostic);
Valerie Haued54efa2019-01-11 20:03:14 -0800280
chaviw308ddba2020-08-11 16:23:51 -0700281 int32_t numListeners = 0;
282 SAFE_PARCEL_READ_SIZE(input.readInt32, &numListeners, input.dataSize());
Valerie Hau9dab9732019-08-20 09:29:25 -0700283 listeners.clear();
284 for (int i = 0; i < numListeners; i++) {
chaviw308ddba2020-08-11 16:23:51 -0700285 sp<IBinder> listener;
Valerie Hau9dab9732019-08-20 09:29:25 -0700286 std::vector<CallbackId> callbackIds;
chaviw308ddba2020-08-11 16:23:51 -0700287 SAFE_PARCEL(input.readNullableStrongBinder, &listener);
Vishnu Nairfc46c1e2021-04-21 08:31:32 -0700288 SAFE_PARCEL(input.readParcelableVector, &callbackIds);
Valerie Hau9dab9732019-08-20 09:29:25 -0700289 listeners.emplace_back(listener, callbackIds);
290 }
chaviw308ddba2020-08-11 16:23:51 -0700291 SAFE_PARCEL(input.readFloat, &shadowRadius);
292 SAFE_PARCEL(input.readInt32, &frameRateSelectionPriority);
293 SAFE_PARCEL(input.readFloat, &frameRate);
294 SAFE_PARCEL(input.readByte, &frameRateCompatibility);
Marin Shalamanovc5986772021-03-16 16:09:49 +0100295 SAFE_PARCEL(input.readByte, &changeFrameRateStrategy);
Andy Labrada096227e2022-06-15 16:58:11 +0000296 SAFE_PARCEL(input.readByte, &defaultFrameRateCompatibility);
Rachel Leece6e0042023-06-27 11:22:54 -0700297 SAFE_PARCEL(input.readByte, &frameRateCategory);
Rachel Lee58cc90d2023-09-05 18:50:20 -0700298 SAFE_PARCEL(input.readByte, &frameRateSelectionStrategy);
chaviw308ddba2020-08-11 16:23:51 -0700299 SAFE_PARCEL(input.readUint32, &tmpUint32);
300 fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32);
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800301 SAFE_PARCEL(input.readBool, &autoRefresh);
Sally Qi81d95e62022-03-21 19:41:33 -0700302 SAFE_PARCEL(input.readBool, &dimmingEnabled);
Lucas Dupinc3800b82020-10-02 16:24:48 -0700303
304 uint32_t numRegions = 0;
305 SAFE_PARCEL(input.readUint32, &numRegions);
306 blurRegions.clear();
307 for (uint32_t i = 0; i < numRegions; i++) {
308 BlurRegion region;
309 SAFE_PARCEL(input.readUint32, &region.blurRadius);
310 SAFE_PARCEL(input.readFloat, &region.cornerRadiusTL);
311 SAFE_PARCEL(input.readFloat, &region.cornerRadiusTR);
312 SAFE_PARCEL(input.readFloat, &region.cornerRadiusBL);
313 SAFE_PARCEL(input.readFloat, &region.cornerRadiusBR);
314 SAFE_PARCEL(input.readFloat, &region.alpha);
315 SAFE_PARCEL(input.readInt32, &region.left);
316 SAFE_PARCEL(input.readInt32, &region.top);
317 SAFE_PARCEL(input.readInt32, &region.right);
318 SAFE_PARCEL(input.readInt32, &region.bottom);
319 blurRegions.push_back(region);
320 }
John Reckcdb4ed72021-02-04 13:39:33 -0500321
322 SAFE_PARCEL(input.read, stretchEffect);
chaviwf3f40fe2021-04-27 15:54:02 -0500323 SAFE_PARCEL(input.read, bufferCrop);
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700324 SAFE_PARCEL(input.read, destinationFrame);
Winson Chunga30f7c92021-06-29 15:42:56 -0700325 SAFE_PARCEL(input.readBool, &isTrustedOverlay);
John Reckcdb4ed72021-02-04 13:39:33 -0500326
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700327 uint32_t mode;
328 SAFE_PARCEL(input.readUint32, &mode);
329 dropInputMode = static_cast<gui::DropInputMode>(mode);
Vishnu Nair685cfef2022-02-02 10:01:25 -0800330
331 bool hasBufferData;
332 SAFE_PARCEL(input.readBool, &hasBufferData);
333 if (hasBufferData) {
334 bufferData = std::make_shared<BufferData>();
335 SAFE_PARCEL(input.readParcelable, bufferData.get());
336 } else {
337 bufferData = nullptr;
338 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000339
340 SAFE_PARCEL(input.readParcelable, &trustedPresentationThresholds);
341 SAFE_PARCEL(input.readParcelable, &trustedPresentationListener);
342
John Reck68796592023-01-25 13:47:12 -0500343 SAFE_PARCEL(input.readFloat, &tmpFloat);
Sally Qi963049b2023-03-23 14:06:21 -0700344 currentHdrSdrRatio = tmpFloat;
John Reck68796592023-01-25 13:47:12 -0500345 SAFE_PARCEL(input.readFloat, &tmpFloat);
Sally Qi963049b2023-03-23 14:06:21 -0700346 desiredHdrSdrRatio = tmpFloat;
John Reck68796592023-01-25 13:47:12 -0500347
Alec Mourif4af03e2023-02-11 00:25:24 +0000348 int32_t tmpInt32;
349 SAFE_PARCEL(input.readInt32, &tmpInt32);
350 cachingHint = static_cast<gui::CachingHint>(tmpInt32);
351
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800352 return NO_ERROR;
353}
354
Mathias Agopian698c0872011-06-28 19:09:31 -0700355status_t ComposerState::write(Parcel& output) const {
Mathias Agopian698c0872011-06-28 19:09:31 -0700356 return state.write(output);
357}
358
359status_t ComposerState::read(const Parcel& input) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700360 return state.read(input);
361}
362
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700363DisplayState::DisplayState() = default;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700364
Mathias Agopian8b33f032012-07-24 20:43:54 -0700365status_t DisplayState::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700366 SAFE_PARCEL(output.writeStrongBinder, token);
367 SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(surface));
368 SAFE_PARCEL(output.writeUint32, what);
Evan Rosky2239b372021-05-20 13:43:47 -0700369 SAFE_PARCEL(output.writeUint32, flags);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700370 SAFE_PARCEL(output.writeUint32, layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700371 SAFE_PARCEL(output.writeUint32, toRotationInt(orientation));
372 SAFE_PARCEL(output.write, layerStackSpaceRect);
373 SAFE_PARCEL(output.write, orientedDisplaySpaceRect);
374 SAFE_PARCEL(output.writeUint32, width);
375 SAFE_PARCEL(output.writeUint32, height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700376 return NO_ERROR;
377}
378
379status_t DisplayState::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700380 SAFE_PARCEL(input.readStrongBinder, &token);
381 sp<IBinder> tmpBinder;
382 SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder);
383 surface = interface_cast<IGraphicBufferProducer>(tmpBinder);
384
385 SAFE_PARCEL(input.readUint32, &what);
Evan Rosky2239b372021-05-20 13:43:47 -0700386 SAFE_PARCEL(input.readUint32, &flags);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700387 SAFE_PARCEL(input.readUint32, &layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700388 uint32_t tmpUint = 0;
389 SAFE_PARCEL(input.readUint32, &tmpUint);
390 orientation = ui::toRotation(tmpUint);
391
392 SAFE_PARCEL(input.read, layerStackSpaceRect);
393 SAFE_PARCEL(input.read, orientedDisplaySpaceRect);
394 SAFE_PARCEL(input.readUint32, &width);
395 SAFE_PARCEL(input.readUint32, &height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700396 return NO_ERROR;
397}
398
Robert Carr2c5f6d22017-09-26 12:30:35 -0700399void DisplayState::merge(const DisplayState& other) {
400 if (other.what & eSurfaceChanged) {
401 what |= eSurfaceChanged;
402 surface = other.surface;
403 }
404 if (other.what & eLayerStackChanged) {
405 what |= eLayerStackChanged;
406 layerStack = other.layerStack;
407 }
Evan Rosky2239b372021-05-20 13:43:47 -0700408 if (other.what & eFlagsChanged) {
409 what |= eFlagsChanged;
410 flags = other.flags;
411 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700412 if (other.what & eDisplayProjectionChanged) {
413 what |= eDisplayProjectionChanged;
414 orientation = other.orientation;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200415 layerStackSpaceRect = other.layerStackSpaceRect;
416 orientedDisplaySpaceRect = other.orientedDisplaySpaceRect;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700417 }
418 if (other.what & eDisplaySizeChanged) {
419 what |= eDisplaySizeChanged;
420 width = other.width;
421 height = other.height;
422 }
423}
424
Sally Qi6bb12822022-10-05 11:42:30 -0700425void DisplayState::sanitize(int32_t permissions) {
426 if (what & DisplayState::eLayerStackChanged) {
427 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
428 what &= ~DisplayState::eLayerStackChanged;
429 ALOGE("Stripped attempt to set eLayerStackChanged in sanitize");
430 }
431 }
432 if (what & DisplayState::eDisplayProjectionChanged) {
433 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
434 what &= ~DisplayState::eDisplayProjectionChanged;
435 ALOGE("Stripped attempt to set eDisplayProjectionChanged in sanitize");
436 }
437 }
438 if (what & DisplayState::eSurfaceChanged) {
439 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
440 what &= ~DisplayState::eSurfaceChanged;
441 ALOGE("Stripped attempt to set eSurfaceChanged in sanitize");
442 }
443 }
444}
445
Robert Carrde6d7b42022-01-07 18:23:06 -0800446void layer_state_t::sanitize(int32_t permissions) {
447 // TODO: b/109894387
448 //
449 // SurfaceFlinger's renderer is not prepared to handle cropping in the face of arbitrary
450 // rotation. To see the problem observe that if we have a square parent, and a child
451 // of the same size, then we rotate the child 45 degrees around its center, the child
452 // must now be cropped to a non rectangular 8 sided region.
453 //
454 // Of course we can fix this in the future. For now, we are lucky, SurfaceControl is
455 // private API, and arbitrary rotation is used in limited use cases, for instance:
456 // - WindowManager only uses rotation in one case, which is on a top level layer in which
457 // cropping is not an issue.
458 // - Launcher, as a privileged app, uses this to transition an application to PiP
459 // (picture-in-picture) mode.
460 //
461 // However given that abuse of rotation matrices could lead to surfaces extending outside
462 // of cropped areas, we need to prevent non-root clients without permission
463 // ACCESS_SURFACE_FLINGER nor ROTATE_SURFACE_FLINGER
464 // (a.k.a. everyone except WindowManager / tests / Launcher) from setting non rectangle
465 // preserving transformations.
466 if (what & eMatrixChanged) {
467 if (!(permissions & Permission::ROTATE_SURFACE_FLINGER)) {
468 ui::Transform t;
469 t.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy);
470 if (!t.preserveRects()) {
471 what &= ~eMatrixChanged;
472 ALOGE("Stripped non rect preserving matrix in sanitize");
473 }
474 }
475 }
476
477 if (what & eFlagsChanged) {
478 if ((flags & eLayerIsDisplayDecoration) &&
479 !(permissions & Permission::INTERNAL_SYSTEM_WINDOW)) {
480 flags &= ~eLayerIsDisplayDecoration;
481 ALOGE("Stripped attempt to set LayerIsDisplayDecoration in sanitize");
482 }
483 }
484
485 if (what & layer_state_t::eInputInfoChanged) {
486 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
487 what &= ~eInputInfoChanged;
488 ALOGE("Stripped attempt to set eInputInfoChanged in sanitize");
489 }
490 }
491 if (what & layer_state_t::eTrustedOverlayChanged) {
492 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
493 what &= ~eTrustedOverlayChanged;
494 ALOGE("Stripped attempt to set eTrustedOverlay in sanitize");
495 }
496 }
497 if (what & layer_state_t::eDropInputModeChanged) {
498 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
499 what &= ~eDropInputModeChanged;
500 ALOGE("Stripped attempt to set eDropInputModeChanged in sanitize");
501 }
502 }
503 if (what & layer_state_t::eFrameRateSelectionPriority) {
504 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
505 what &= ~eFrameRateSelectionPriority;
506 ALOGE("Stripped attempt to set eFrameRateSelectionPriority in sanitize");
507 }
508 }
509 if (what & layer_state_t::eFrameRateChanged) {
510 if (!ValidateFrameRate(frameRate, frameRateCompatibility,
511 changeFrameRateStrategy,
512 "layer_state_t::sanitize",
513 permissions & Permission::ACCESS_SURFACE_FLINGER)) {
514 what &= ~eFrameRateChanged; // logged in ValidateFrameRate
515 }
516 }
517}
518
Robert Carr2c5f6d22017-09-26 12:30:35 -0700519void layer_state_t::merge(const layer_state_t& other) {
520 if (other.what & ePositionChanged) {
521 what |= ePositionChanged;
522 x = other.x;
523 y = other.y;
524 }
525 if (other.what & eLayerChanged) {
526 what |= eLayerChanged;
chaviw32377582019-05-13 11:15:19 -0700527 what &= ~eRelativeLayerChanged;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700528 z = other.z;
529 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700530 if (other.what & eAlphaChanged) {
531 what |= eAlphaChanged;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000532 color.a = other.color.a;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700533 }
534 if (other.what & eMatrixChanged) {
535 what |= eMatrixChanged;
536 matrix = other.matrix;
537 }
538 if (other.what & eTransparentRegionChanged) {
539 what |= eTransparentRegionChanged;
540 transparentRegion = other.transparentRegion;
541 }
542 if (other.what & eFlagsChanged) {
543 what |= eFlagsChanged;
Vishnu Nair996bc422019-07-16 14:15:33 -0700544 flags &= ~other.mask;
545 flags |= (other.flags & other.mask);
546 mask |= other.mask;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700547 }
548 if (other.what & eLayerStackChanged) {
549 what |= eLayerStackChanged;
550 layerStack = other.layerStack;
551 }
Lucas Dupin1b6531c2018-07-05 17:18:21 -0700552 if (other.what & eCornerRadiusChanged) {
553 what |= eCornerRadiusChanged;
554 cornerRadius = other.cornerRadius;
555 }
Lucas Dupin19c8f0e2019-11-25 17:55:44 -0800556 if (other.what & eBackgroundBlurRadiusChanged) {
557 what |= eBackgroundBlurRadiusChanged;
558 backgroundBlurRadius = other.backgroundBlurRadius;
559 }
Lucas Dupinc3800b82020-10-02 16:24:48 -0700560 if (other.what & eBlurRegionsChanged) {
561 what |= eBlurRegionsChanged;
562 blurRegions = other.blurRegions;
563 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700564 if (other.what & eRelativeLayerChanged) {
565 what |= eRelativeLayerChanged;
chaviw32377582019-05-13 11:15:19 -0700566 what &= ~eLayerChanged;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700567 z = other.z;
Pablo Gamito11dcc222020-09-12 15:49:39 +0000568 relativeLayerSurfaceControl = other.relativeLayerSurfaceControl;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700569 }
570 if (other.what & eReparent) {
571 what |= eReparent;
Pablo Gamito11dcc222020-09-12 15:49:39 +0000572 parentSurfaceControlForChild = other.parentSurfaceControlForChild;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700573 }
Vishnu Nairbbceb462022-10-10 04:52:13 +0000574 if (other.what & eBufferTransformChanged) {
575 what |= eBufferTransformChanged;
576 bufferTransform = other.bufferTransform;
Marissa Wall61c58622018-07-18 10:12:20 -0700577 }
578 if (other.what & eTransformToDisplayInverseChanged) {
579 what |= eTransformToDisplayInverseChanged;
580 transformToDisplayInverse = other.transformToDisplayInverse;
581 }
582 if (other.what & eCropChanged) {
583 what |= eCropChanged;
584 crop = other.crop;
585 }
586 if (other.what & eBufferChanged) {
587 what |= eBufferChanged;
chaviwba4320c2021-09-15 15:20:53 -0500588 bufferData = other.bufferData;
Marissa Wall61c58622018-07-18 10:12:20 -0700589 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000590 if (other.what & eTrustedPresentationInfoChanged) {
591 what |= eTrustedPresentationInfoChanged;
592 trustedPresentationListener = other.trustedPresentationListener;
593 trustedPresentationThresholds = other.trustedPresentationThresholds;
594 }
Marissa Wall61c58622018-07-18 10:12:20 -0700595 if (other.what & eDataspaceChanged) {
596 what |= eDataspaceChanged;
597 dataspace = other.dataspace;
598 }
John Reck68796592023-01-25 13:47:12 -0500599 if (other.what & eExtendedRangeBrightnessChanged) {
600 what |= eExtendedRangeBrightnessChanged;
Sally Qi963049b2023-03-23 14:06:21 -0700601 desiredHdrSdrRatio = other.desiredHdrSdrRatio;
602 currentHdrSdrRatio = other.currentHdrSdrRatio;
John Reck68796592023-01-25 13:47:12 -0500603 }
Alec Mourif4af03e2023-02-11 00:25:24 +0000604 if (other.what & eCachingHintChanged) {
605 what |= eCachingHintChanged;
606 cachingHint = other.cachingHint;
607 }
Marissa Wall61c58622018-07-18 10:12:20 -0700608 if (other.what & eHdrMetadataChanged) {
609 what |= eHdrMetadataChanged;
610 hdrMetadata = other.hdrMetadata;
611 }
612 if (other.what & eSurfaceDamageRegionChanged) {
613 what |= eSurfaceDamageRegionChanged;
614 surfaceDamageRegion = other.surfaceDamageRegion;
615 }
616 if (other.what & eApiChanged) {
617 what |= eApiChanged;
618 api = other.api;
619 }
620 if (other.what & eSidebandStreamChanged) {
621 what |= eSidebandStreamChanged;
622 sidebandStream = other.sidebandStream;
623 }
Peiyong Lind3788632018-09-18 16:01:31 -0700624 if (other.what & eColorTransformChanged) {
625 what |= eColorTransformChanged;
626 colorTransform = other.colorTransform;
627 }
Marissa Wall3dad52d2019-03-22 14:03:19 -0700628 if (other.what & eHasListenerCallbacksChanged) {
629 what |= eHasListenerCallbacksChanged;
Marissa Wallc837b5e2018-10-12 10:04:44 -0700630 }
Robert Carr2c358bf2018-08-08 15:58:15 -0700631 if (other.what & eInputInfoChanged) {
632 what |= eInputInfoChanged;
chaviw98318de2021-05-19 16:45:23 -0500633 windowInfoHandle = new WindowInfoHandle(*other.windowInfoHandle);
Robert Carr2c358bf2018-08-08 15:58:15 -0700634 }
Valerie Haudd0b7572019-01-29 14:59:27 -0800635 if (other.what & eBackgroundColorChanged) {
636 what |= eBackgroundColorChanged;
Vishnu Naird47bcee2023-02-24 18:08:51 +0000637 bgColor = other.bgColor;
Valerie Haudd0b7572019-01-29 14:59:27 -0800638 bgColorDataspace = other.bgColorDataspace;
Valerie Haued54efa2019-01-11 20:03:14 -0800639 }
Evan Rosky1f6d6d52018-12-06 10:47:26 -0800640 if (other.what & eMetadataChanged) {
641 what |= eMetadataChanged;
642 metadata.merge(other.metadata);
643 }
Vishnu Nairc97b8db2019-10-29 18:19:35 -0700644 if (other.what & eShadowRadiusChanged) {
645 what |= eShadowRadiusChanged;
646 shadowRadius = other.shadowRadius;
647 }
Tianhao Yao67dd7122022-02-22 17:48:33 +0000648 if (other.what & eRenderBorderChanged) {
649 what |= eRenderBorderChanged;
650 borderEnabled = other.borderEnabled;
Tianhao Yao10cea3c2022-03-30 01:37:22 +0000651 borderWidth = other.borderWidth;
652 borderColor = other.borderColor;
Tianhao Yao67dd7122022-02-22 17:48:33 +0000653 }
Andy Labrada096227e2022-06-15 16:58:11 +0000654 if (other.what & eDefaultFrameRateCompatibilityChanged) {
655 what |= eDefaultFrameRateCompatibilityChanged;
656 defaultFrameRateCompatibility = other.defaultFrameRateCompatibility;
657 }
Ana Krulecc84d09b2019-11-02 23:10:29 +0100658 if (other.what & eFrameRateSelectionPriority) {
659 what |= eFrameRateSelectionPriority;
660 frameRateSelectionPriority = other.frameRateSelectionPriority;
661 }
Steven Thomas3172e202020-01-06 19:25:30 -0800662 if (other.what & eFrameRateChanged) {
663 what |= eFrameRateChanged;
664 frameRate = other.frameRate;
Steven Thomas62a4cf82020-01-31 12:04:03 -0800665 frameRateCompatibility = other.frameRateCompatibility;
Marin Shalamanovc5986772021-03-16 16:09:49 +0100666 changeFrameRateStrategy = other.changeFrameRateStrategy;
Steven Thomas3172e202020-01-06 19:25:30 -0800667 }
Rachel Leece6e0042023-06-27 11:22:54 -0700668 if (other.what & eFrameRateCategoryChanged) {
669 what |= eFrameRateCategoryChanged;
670 frameRateCategory = other.frameRateCategory;
671 }
Rachel Lee58cc90d2023-09-05 18:50:20 -0700672 if (other.what & eFrameRateSelectionStrategyChanged) {
673 what |= eFrameRateSelectionStrategyChanged;
674 frameRateSelectionStrategy = other.frameRateSelectionStrategy;
675 }
Vishnu Nair6213bd92020-05-08 17:42:25 -0700676 if (other.what & eFixedTransformHintChanged) {
677 what |= eFixedTransformHintChanged;
678 fixedTransformHint = other.fixedTransformHint;
679 }
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800680 if (other.what & eAutoRefreshChanged) {
681 what |= eAutoRefreshChanged;
682 autoRefresh = other.autoRefresh;
683 }
Winson Chunga30f7c92021-06-29 15:42:56 -0700684 if (other.what & eTrustedOverlayChanged) {
685 what |= eTrustedOverlayChanged;
686 isTrustedOverlay = other.isTrustedOverlay;
687 }
John Reckc00c6692021-02-16 11:37:33 -0500688 if (other.what & eStretchChanged) {
689 what |= eStretchChanged;
690 stretchEffect = other.stretchEffect;
691 }
chaviwf3f40fe2021-04-27 15:54:02 -0500692 if (other.what & eBufferCropChanged) {
693 what |= eBufferCropChanged;
694 bufferCrop = other.bufferCrop;
695 }
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700696 if (other.what & eDestinationFrameChanged) {
697 what |= eDestinationFrameChanged;
698 destinationFrame = other.destinationFrame;
699 }
Vishnu Nair0e816872021-07-14 10:53:04 -0700700 if (other.what & eProducerDisconnect) {
701 what |= eProducerDisconnect;
702 }
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700703 if (other.what & eDropInputModeChanged) {
704 what |= eDropInputModeChanged;
705 dropInputMode = other.dropInputMode;
706 }
chaviw4c36cd82021-11-18 10:37:33 -0600707 if (other.what & eColorChanged) {
708 what |= eColorChanged;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000709 color.rgb = other.color.rgb;
chaviw4c36cd82021-11-18 10:37:33 -0600710 }
Arthur Hung91b346a2022-03-14 21:36:22 +0800711 if (other.what & eColorSpaceAgnosticChanged) {
712 what |= eColorSpaceAgnosticChanged;
713 colorSpaceAgnostic = other.colorSpaceAgnostic;
714 }
Sally Qi81d95e62022-03-21 19:41:33 -0700715 if (other.what & eDimmingEnabledChanged) {
716 what |= eDimmingEnabledChanged;
717 dimmingEnabled = other.dimmingEnabled;
718 }
Pascal Muetschardb39918f2023-01-27 11:36:11 +0100719 if (other.what & eFlushJankData) {
720 what |= eFlushJankData;
721 }
Vishnu Nair217d8e62018-09-12 16:34:49 -0700722 if ((other.what & what) != other.what) {
723 ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
Vishnu Nair0e816872021-07-14 10:53:04 -0700724 "other.what=0x%" PRIX64 " what=0x%" PRIX64 " unmerged flags=0x%" PRIX64,
725 other.what, what, (other.what & what) ^ other.what);
Robert Carrd314f162018-08-15 13:12:42 -0700726 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700727}
Mathias Agopian8b33f032012-07-24 20:43:54 -0700728
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000729uint64_t layer_state_t::diff(const layer_state_t& other) const {
730 uint64_t diff = 0;
731 CHECK_DIFF2(diff, ePositionChanged, other, x, y);
732 if (other.what & eLayerChanged) {
733 diff |= eLayerChanged;
734 diff &= ~eRelativeLayerChanged;
735 }
736 CHECK_DIFF(diff, eAlphaChanged, other, color.a);
737 CHECK_DIFF(diff, eMatrixChanged, other, matrix);
738 if (other.what & eTransparentRegionChanged &&
739 (!transparentRegion.hasSameRects(other.transparentRegion))) {
740 diff |= eTransparentRegionChanged;
741 }
742 if (other.what & eFlagsChanged) {
743 uint64_t changedFlags = (flags & other.mask) ^ (other.flags & other.mask);
744 if (changedFlags) diff |= eFlagsChanged;
745 }
746 CHECK_DIFF(diff, eLayerStackChanged, other, layerStack);
747 CHECK_DIFF(diff, eCornerRadiusChanged, other, cornerRadius);
748 CHECK_DIFF(diff, eBackgroundBlurRadiusChanged, other, backgroundBlurRadius);
749 if (other.what & eBlurRegionsChanged) diff |= eBlurRegionsChanged;
750 if (other.what & eRelativeLayerChanged) {
751 diff |= eRelativeLayerChanged;
752 diff &= ~eLayerChanged;
753 }
754 if (other.what & eReparent &&
755 !SurfaceControl::isSameSurface(parentSurfaceControlForChild,
756 other.parentSurfaceControlForChild)) {
757 diff |= eReparent;
758 }
759 CHECK_DIFF(diff, eBufferTransformChanged, other, bufferTransform);
760 CHECK_DIFF(diff, eTransformToDisplayInverseChanged, other, transformToDisplayInverse);
761 CHECK_DIFF(diff, eCropChanged, other, crop);
762 if (other.what & eBufferChanged) diff |= eBufferChanged;
763 CHECK_DIFF(diff, eDataspaceChanged, other, dataspace);
Sally Qi963049b2023-03-23 14:06:21 -0700764 CHECK_DIFF2(diff, eExtendedRangeBrightnessChanged, other, currentHdrSdrRatio,
765 desiredHdrSdrRatio);
Alec Mourif4af03e2023-02-11 00:25:24 +0000766 CHECK_DIFF(diff, eCachingHintChanged, other, cachingHint);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000767 CHECK_DIFF(diff, eHdrMetadataChanged, other, hdrMetadata);
768 if (other.what & eSurfaceDamageRegionChanged &&
769 (!surfaceDamageRegion.hasSameRects(other.surfaceDamageRegion))) {
770 diff |= eSurfaceDamageRegionChanged;
771 }
772 CHECK_DIFF(diff, eApiChanged, other, api);
773 if (other.what & eSidebandStreamChanged) diff |= eSidebandStreamChanged;
774 CHECK_DIFF(diff, eApiChanged, other, api);
775 CHECK_DIFF(diff, eColorTransformChanged, other, colorTransform);
776 if (other.what & eHasListenerCallbacksChanged) diff |= eHasListenerCallbacksChanged;
777 if (other.what & eInputInfoChanged) diff |= eInputInfoChanged;
Vishnu Naird47bcee2023-02-24 18:08:51 +0000778 CHECK_DIFF2(diff, eBackgroundColorChanged, other, bgColor, bgColorDataspace);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000779 if (other.what & eMetadataChanged) diff |= eMetadataChanged;
780 CHECK_DIFF(diff, eShadowRadiusChanged, other, shadowRadius);
781 CHECK_DIFF3(diff, eRenderBorderChanged, other, borderEnabled, borderWidth, borderColor);
782 CHECK_DIFF(diff, eDefaultFrameRateCompatibilityChanged, other, defaultFrameRateCompatibility);
783 CHECK_DIFF(diff, eFrameRateSelectionPriority, other, frameRateSelectionPriority);
784 CHECK_DIFF3(diff, eFrameRateChanged, other, frameRate, frameRateCompatibility,
785 changeFrameRateStrategy);
Rachel Leece6e0042023-06-27 11:22:54 -0700786 CHECK_DIFF(diff, eFrameRateCategoryChanged, other, frameRateCategory);
Rachel Lee58cc90d2023-09-05 18:50:20 -0700787 CHECK_DIFF(diff, eFrameRateSelectionStrategyChanged, other, frameRateSelectionStrategy);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000788 CHECK_DIFF(diff, eFixedTransformHintChanged, other, fixedTransformHint);
789 CHECK_DIFF(diff, eAutoRefreshChanged, other, autoRefresh);
790 CHECK_DIFF(diff, eTrustedOverlayChanged, other, isTrustedOverlay);
791 CHECK_DIFF(diff, eStretchChanged, other, stretchEffect);
792 CHECK_DIFF(diff, eBufferCropChanged, other, bufferCrop);
793 CHECK_DIFF(diff, eDestinationFrameChanged, other, destinationFrame);
794 if (other.what & eProducerDisconnect) diff |= eProducerDisconnect;
795 CHECK_DIFF(diff, eDropInputModeChanged, other, dropInputMode);
796 CHECK_DIFF(diff, eColorChanged, other, color.rgb);
797 CHECK_DIFF(diff, eColorSpaceAgnosticChanged, other, colorSpaceAgnostic);
798 CHECK_DIFF(diff, eDimmingEnabledChanged, other, dimmingEnabled);
799 return diff;
800}
801
Vishnu Nairddf9b5c2021-03-29 18:53:41 -0700802bool layer_state_t::hasBufferChanges() const {
chaviwba4320c2021-09-15 15:20:53 -0500803 return what & layer_state_t::eBufferChanged;
Vishnu Nairddf9b5c2021-03-29 18:53:41 -0700804}
805
Ady Abraham6e8e3642021-07-08 19:44:07 -0700806bool layer_state_t::hasValidBuffer() const {
Vishnu Nair59f6d2d2022-10-05 16:59:56 -0700807 return bufferData && (bufferData->hasBuffer() || bufferData->cachedBuffer.isValid());
Ady Abraham6e8e3642021-07-08 19:44:07 -0700808}
809
chaviw308ddba2020-08-11 16:23:51 -0700810status_t layer_state_t::matrix22_t::write(Parcel& output) const {
811 SAFE_PARCEL(output.writeFloat, dsdx);
812 SAFE_PARCEL(output.writeFloat, dtdx);
813 SAFE_PARCEL(output.writeFloat, dtdy);
814 SAFE_PARCEL(output.writeFloat, dsdy);
815 return NO_ERROR;
816}
817
818status_t layer_state_t::matrix22_t::read(const Parcel& input) {
819 SAFE_PARCEL(input.readFloat, &dsdx);
820 SAFE_PARCEL(input.readFloat, &dtdx);
821 SAFE_PARCEL(input.readFloat, &dtdy);
822 SAFE_PARCEL(input.readFloat, &dsdy);
823 return NO_ERROR;
824}
825
chaviw273171b2018-12-26 11:46:30 -0800826// ------------------------------- InputWindowCommands ----------------------------------------
827
Vishnu Naire798b472020-07-23 13:52:21 -0700828bool InputWindowCommands::merge(const InputWindowCommands& other) {
829 bool changes = false;
Vishnu Naire798b472020-07-23 13:52:21 -0700830 changes |= !other.focusRequests.empty();
831 focusRequests.insert(focusRequests.end(), std::make_move_iterator(other.focusRequests.begin()),
832 std::make_move_iterator(other.focusRequests.end()));
Patrick Williams641f7f22022-06-22 19:25:35 +0000833 changes |= !other.windowInfosReportedListeners.empty();
834 windowInfosReportedListeners.insert(other.windowInfosReportedListeners.begin(),
835 other.windowInfosReportedListeners.end());
Vishnu Naire798b472020-07-23 13:52:21 -0700836 return changes;
chaviw273171b2018-12-26 11:46:30 -0800837}
838
Vishnu Nair958da932020-08-21 17:12:37 -0700839bool InputWindowCommands::empty() const {
Patrick Williams641f7f22022-06-22 19:25:35 +0000840 return focusRequests.empty() && windowInfosReportedListeners.empty();
Vishnu Nair958da932020-08-21 17:12:37 -0700841}
842
chaviw273171b2018-12-26 11:46:30 -0800843void InputWindowCommands::clear() {
Vishnu Naire798b472020-07-23 13:52:21 -0700844 focusRequests.clear();
Patrick Williams641f7f22022-06-22 19:25:35 +0000845 windowInfosReportedListeners.clear();
chaviw273171b2018-12-26 11:46:30 -0800846}
847
chaviw308ddba2020-08-11 16:23:51 -0700848status_t InputWindowCommands::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700849 SAFE_PARCEL(output.writeParcelableVector, focusRequests);
Patrick Williams641f7f22022-06-22 19:25:35 +0000850
851 SAFE_PARCEL(output.writeInt32, windowInfosReportedListeners.size());
852 for (const auto& listener : windowInfosReportedListeners) {
853 SAFE_PARCEL(output.writeStrongBinder, listener);
854 }
855
chaviw308ddba2020-08-11 16:23:51 -0700856 return NO_ERROR;
chaviw273171b2018-12-26 11:46:30 -0800857}
858
chaviw308ddba2020-08-11 16:23:51 -0700859status_t InputWindowCommands::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700860 SAFE_PARCEL(input.readParcelableVector, &focusRequests);
Patrick Williams641f7f22022-06-22 19:25:35 +0000861
862 int listenerSize = 0;
863 SAFE_PARCEL_READ_SIZE(input.readInt32, &listenerSize, input.dataSize());
864 windowInfosReportedListeners.reserve(listenerSize);
865 for (int i = 0; i < listenerSize; i++) {
866 sp<gui::IWindowInfosReportedListener> listener;
867 SAFE_PARCEL(input.readStrongBinder, &listener);
868 windowInfosReportedListeners.insert(listener);
869 }
870
chaviw308ddba2020-08-11 16:23:51 -0700871 return NO_ERROR;
chaviw273171b2018-12-26 11:46:30 -0800872}
873
Marin Shalamanovc5986772021-03-16 16:09:49 +0100874bool ValidateFrameRate(float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy,
875 const char* inFunctionName, bool privileged) {
Steven Thomas62a4cf82020-01-31 12:04:03 -0800876 const char* functionName = inFunctionName != nullptr ? inFunctionName : "call";
877 int floatClassification = std::fpclassify(frameRate);
878 if (frameRate < 0 || floatClassification == FP_INFINITE || floatClassification == FP_NAN) {
879 ALOGE("%s failed - invalid frame rate %f", functionName, frameRate);
880 return false;
881 }
882
883 if (compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT &&
Ady Abrahamdd5bfa92021-01-07 17:56:08 -0800884 compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE &&
Dominik Laskowski1f6fc702022-03-21 08:34:50 -0700885 (!privileged ||
886 (compatibility != ANATIVEWINDOW_FRAME_RATE_EXACT &&
887 compatibility != ANATIVEWINDOW_FRAME_RATE_NO_VOTE))) {
Ady Abrahamdd5bfa92021-01-07 17:56:08 -0800888 ALOGE("%s failed - invalid compatibility value %d privileged: %s", functionName,
889 compatibility, privileged ? "yes" : "no");
Steven Thomas62a4cf82020-01-31 12:04:03 -0800890 return false;
891 }
892
Marin Shalamanovc5986772021-03-16 16:09:49 +0100893 if (changeFrameRateStrategy != ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS &&
894 changeFrameRateStrategy != ANATIVEWINDOW_CHANGE_FRAME_RATE_ALWAYS) {
895 ALOGE("%s failed - invalid change frame rate strategy value %d", functionName,
896 changeFrameRateStrategy);
897 }
898
Steven Thomas62a4cf82020-01-31 12:04:03 -0800899 return true;
900}
901
chaviw618c42d2020-07-24 15:25:08 -0700902// ----------------------------------------------------------------------------
903
Huihong Luo9e84f332021-12-16 14:33:46 -0800904namespace gui {
905
906status_t CaptureArgs::writeToParcel(Parcel* output) const {
907 SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(pixelFormat));
908 SAFE_PARCEL(output->write, sourceCrop);
909 SAFE_PARCEL(output->writeFloat, frameScaleX);
910 SAFE_PARCEL(output->writeFloat, frameScaleY);
911 SAFE_PARCEL(output->writeBool, captureSecureLayers);
912 SAFE_PARCEL(output->writeInt32, uid);
913 SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(dataspace));
914 SAFE_PARCEL(output->writeBool, allowProtected);
915 SAFE_PARCEL(output->writeBool, grayscale);
Ajinkya Chalke02844632023-03-01 12:10:14 +0000916 SAFE_PARCEL(output->writeInt32, excludeHandles.size());
917 for (auto& excludeHandle : excludeHandles) {
918 SAFE_PARCEL(output->writeStrongBinder, excludeHandle);
919 }
Alec Mouri3e5965f2023-04-07 18:00:58 +0000920 SAFE_PARCEL(output->writeBool, hintForSeamlessTransition);
chaviw308ddba2020-08-11 16:23:51 -0700921 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700922}
923
Huihong Luo9e84f332021-12-16 14:33:46 -0800924status_t CaptureArgs::readFromParcel(const Parcel* input) {
Peiyong Lincd261472020-10-06 18:05:25 -0700925 int32_t value = 0;
Huihong Luo9e84f332021-12-16 14:33:46 -0800926 SAFE_PARCEL(input->readInt32, &value);
Peiyong Lincd261472020-10-06 18:05:25 -0700927 pixelFormat = static_cast<ui::PixelFormat>(value);
Huihong Luo9e84f332021-12-16 14:33:46 -0800928 SAFE_PARCEL(input->read, sourceCrop);
929 SAFE_PARCEL(input->readFloat, &frameScaleX);
930 SAFE_PARCEL(input->readFloat, &frameScaleY);
931 SAFE_PARCEL(input->readBool, &captureSecureLayers);
932 SAFE_PARCEL(input->readInt32, &uid);
933 SAFE_PARCEL(input->readInt32, &value);
Peiyong Lincd261472020-10-06 18:05:25 -0700934 dataspace = static_cast<ui::Dataspace>(value);
Huihong Luo9e84f332021-12-16 14:33:46 -0800935 SAFE_PARCEL(input->readBool, &allowProtected);
936 SAFE_PARCEL(input->readBool, &grayscale);
Ajinkya Chalke02844632023-03-01 12:10:14 +0000937 int32_t numExcludeHandles = 0;
938 SAFE_PARCEL_READ_SIZE(input->readInt32, &numExcludeHandles, input->dataSize());
939 excludeHandles.reserve(numExcludeHandles);
940 for (int i = 0; i < numExcludeHandles; i++) {
941 sp<IBinder> binder;
942 SAFE_PARCEL(input->readStrongBinder, &binder);
943 excludeHandles.emplace(binder);
944 }
Alec Mouri3e5965f2023-04-07 18:00:58 +0000945 SAFE_PARCEL(input->readBool, &hintForSeamlessTransition);
chaviw308ddba2020-08-11 16:23:51 -0700946 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700947}
948
Huihong Luo9e84f332021-12-16 14:33:46 -0800949status_t DisplayCaptureArgs::writeToParcel(Parcel* output) const {
950 SAFE_PARCEL(CaptureArgs::writeToParcel, output);
chaviw618c42d2020-07-24 15:25:08 -0700951
Huihong Luo9e84f332021-12-16 14:33:46 -0800952 SAFE_PARCEL(output->writeStrongBinder, displayToken);
953 SAFE_PARCEL(output->writeUint32, width);
954 SAFE_PARCEL(output->writeUint32, height);
955 SAFE_PARCEL(output->writeBool, useIdentityTransform);
chaviw308ddba2020-08-11 16:23:51 -0700956 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700957}
958
Huihong Luo9e84f332021-12-16 14:33:46 -0800959status_t DisplayCaptureArgs::readFromParcel(const Parcel* input) {
960 SAFE_PARCEL(CaptureArgs::readFromParcel, input);
chaviw618c42d2020-07-24 15:25:08 -0700961
Huihong Luo9e84f332021-12-16 14:33:46 -0800962 SAFE_PARCEL(input->readStrongBinder, &displayToken);
963 SAFE_PARCEL(input->readUint32, &width);
964 SAFE_PARCEL(input->readUint32, &height);
965 SAFE_PARCEL(input->readBool, &useIdentityTransform);
chaviw308ddba2020-08-11 16:23:51 -0700966 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700967}
968
Huihong Luo9e84f332021-12-16 14:33:46 -0800969status_t LayerCaptureArgs::writeToParcel(Parcel* output) const {
970 SAFE_PARCEL(CaptureArgs::writeToParcel, output);
chaviw618c42d2020-07-24 15:25:08 -0700971
Huihong Luo9e84f332021-12-16 14:33:46 -0800972 SAFE_PARCEL(output->writeStrongBinder, layerHandle);
Huihong Luo9e84f332021-12-16 14:33:46 -0800973 SAFE_PARCEL(output->writeBool, childrenOnly);
chaviw308ddba2020-08-11 16:23:51 -0700974 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700975}
976
Huihong Luo9e84f332021-12-16 14:33:46 -0800977status_t LayerCaptureArgs::readFromParcel(const Parcel* input) {
978 SAFE_PARCEL(CaptureArgs::readFromParcel, input);
chaviw618c42d2020-07-24 15:25:08 -0700979
Huihong Luo9e84f332021-12-16 14:33:46 -0800980 SAFE_PARCEL(input->readStrongBinder, &layerHandle);
chaviw618c42d2020-07-24 15:25:08 -0700981
Huihong Luo9e84f332021-12-16 14:33:46 -0800982 SAFE_PARCEL(input->readBool, &childrenOnly);
chaviw308ddba2020-08-11 16:23:51 -0700983 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700984}
985
Huihong Luo9e84f332021-12-16 14:33:46 -0800986}; // namespace gui
987
chaviw8dd181f2022-01-05 18:36:46 -0600988ReleaseCallbackId BufferData::generateReleaseCallbackId() const {
chaviwdcba9e02022-03-21 17:54:23 -0500989 uint64_t bufferId;
990 if (buffer) {
991 bufferId = buffer->getId();
992 } else {
993 bufferId = cachedBuffer.id;
994 }
995 return {bufferId, frameNumber};
chaviw8dd181f2022-01-05 18:36:46 -0600996}
997
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800998status_t BufferData::writeToParcel(Parcel* output) const {
999 SAFE_PARCEL(output->writeInt32, flags.get());
chaviwba4320c2021-09-15 15:20:53 -05001000
1001 if (buffer) {
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001002 SAFE_PARCEL(output->writeBool, true);
1003 SAFE_PARCEL(output->write, *buffer);
chaviwba4320c2021-09-15 15:20:53 -05001004 } else {
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001005 SAFE_PARCEL(output->writeBool, false);
chaviwba4320c2021-09-15 15:20:53 -05001006 }
1007
1008 if (acquireFence) {
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001009 SAFE_PARCEL(output->writeBool, true);
1010 SAFE_PARCEL(output->write, *acquireFence);
chaviwba4320c2021-09-15 15:20:53 -05001011 } else {
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001012 SAFE_PARCEL(output->writeBool, false);
chaviwba4320c2021-09-15 15:20:53 -05001013 }
1014
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001015 SAFE_PARCEL(output->writeUint64, frameNumber);
1016 SAFE_PARCEL(output->writeStrongBinder, IInterface::asBinder(releaseBufferListener));
1017 SAFE_PARCEL(output->writeStrongBinder, releaseBufferEndpoint);
chaviwba4320c2021-09-15 15:20:53 -05001018
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001019 SAFE_PARCEL(output->writeStrongBinder, cachedBuffer.token.promote());
1020 SAFE_PARCEL(output->writeUint64, cachedBuffer.id);
Robert Carr79dc06a2022-02-22 15:28:59 -08001021 SAFE_PARCEL(output->writeBool, hasBarrier);
1022 SAFE_PARCEL(output->writeUint64, barrierFrameNumber);
liulijuneb489f62022-10-17 22:02:14 +08001023 SAFE_PARCEL(output->writeUint32, producerId);
chaviwba4320c2021-09-15 15:20:53 -05001024
1025 return NO_ERROR;
1026}
1027
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001028status_t BufferData::readFromParcel(const Parcel* input) {
chaviwba4320c2021-09-15 15:20:53 -05001029 int32_t tmpInt32;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001030 SAFE_PARCEL(input->readInt32, &tmpInt32);
Dominik Laskowski2f01d772022-03-23 16:01:29 -07001031 flags = ftl::Flags<BufferDataChange>(tmpInt32);
chaviwba4320c2021-09-15 15:20:53 -05001032
1033 bool tmpBool = false;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001034 SAFE_PARCEL(input->readBool, &tmpBool);
chaviwba4320c2021-09-15 15:20:53 -05001035 if (tmpBool) {
1036 buffer = new GraphicBuffer();
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001037 SAFE_PARCEL(input->read, *buffer);
chaviwba4320c2021-09-15 15:20:53 -05001038 }
1039
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001040 SAFE_PARCEL(input->readBool, &tmpBool);
chaviwba4320c2021-09-15 15:20:53 -05001041 if (tmpBool) {
1042 acquireFence = new Fence();
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001043 SAFE_PARCEL(input->read, *acquireFence);
chaviwba4320c2021-09-15 15:20:53 -05001044 }
1045
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001046 SAFE_PARCEL(input->readUint64, &frameNumber);
chaviwba4320c2021-09-15 15:20:53 -05001047
1048 sp<IBinder> tmpBinder = nullptr;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001049 SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder);
chaviwba4320c2021-09-15 15:20:53 -05001050 if (tmpBinder) {
1051 releaseBufferListener = checked_interface_cast<ITransactionCompletedListener>(tmpBinder);
1052 }
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001053 SAFE_PARCEL(input->readNullableStrongBinder, &releaseBufferEndpoint);
chaviwba4320c2021-09-15 15:20:53 -05001054
1055 tmpBinder = nullptr;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001056 SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder);
chaviwba4320c2021-09-15 15:20:53 -05001057 cachedBuffer.token = tmpBinder;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001058 SAFE_PARCEL(input->readUint64, &cachedBuffer.id);
chaviwba4320c2021-09-15 15:20:53 -05001059
Robert Carr79dc06a2022-02-22 15:28:59 -08001060 SAFE_PARCEL(input->readBool, &hasBarrier);
1061 SAFE_PARCEL(input->readUint64, &barrierFrameNumber);
liulijuneb489f62022-10-17 22:02:14 +08001062 SAFE_PARCEL(input->readUint32, &producerId);
Robert Carr79dc06a2022-02-22 15:28:59 -08001063
chaviwba4320c2021-09-15 15:20:53 -05001064 return NO_ERROR;
1065}
1066
Chavi Weingarten076acac2023-01-19 17:20:43 +00001067status_t TrustedPresentationListener::writeToParcel(Parcel* parcel) const {
1068 SAFE_PARCEL(parcel->writeStrongBinder, callbackInterface);
1069 SAFE_PARCEL(parcel->writeInt32, callbackId);
1070 return NO_ERROR;
1071}
1072
1073status_t TrustedPresentationListener::readFromParcel(const Parcel* parcel) {
1074 sp<IBinder> tmpBinder = nullptr;
1075 SAFE_PARCEL(parcel->readNullableStrongBinder, &tmpBinder);
1076 if (tmpBinder) {
1077 callbackInterface = checked_interface_cast<ITransactionCompletedListener>(tmpBinder);
1078 }
1079 SAFE_PARCEL(parcel->readInt32, &callbackId);
1080 return NO_ERROR;
1081}
1082
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001083}; // namespace android