blob: 44aac9bfae65f52e1bf0f9aaf65a5e6882366b95 [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>
Garfield Tan8a3083e2018-12-03 13:21:07 -080020
Huihong Luod3d8f8e2022-03-08 14:48:46 -080021#include <android/gui/ISurfaceComposerClient.h>
Marin Shalamanovc5986772021-03-16 16:09:49 +010022#include <android/native_window.h>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070023#include <binder/Parcel.h>
Brian Lindahl07dcd492024-10-30 11:43:23 -060024#include <com_android_graphics_libgui_flags.h>
Ady Abraham6cdd3fd2023-09-07 18:45:58 -070025#include <gui/FrameRateUtils.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080026#include <gui/IGraphicBufferProducer.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070027#include <gui/LayerState.h>
Vishnu Nairaa799bd2022-11-16 23:09:09 +000028#include <gui/SurfaceControl.h>
Marin Shalamanov3b1f7bc2021-03-16 15:51:53 +010029#include <private/gui/ParcelUtils.h>
Dominik Laskowski1f6fc702022-03-21 08:34:50 -070030#include <system/window.h>
Pablo Gamito11dcc222020-09-12 15:49:39 +000031#include <utils/Errors.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080032
Vishnu Nairaa799bd2022-11-16 23:09:09 +000033#define CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD) \
34 { \
35 if ((OTHER.what & CHANGE_FLAG) && (FIELD != OTHER.FIELD)) { \
36 DIFF_RESULT |= CHANGE_FLAG; \
37 } \
38 }
39
40#define CHECK_DIFF2(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1, FIELD2) \
41 { \
42 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1) \
43 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD2) \
44 }
45
46#define CHECK_DIFF3(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1, FIELD2, FIELD3) \
47 { \
48 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD1) \
49 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD2) \
50 CHECK_DIFF(DIFF_RESULT, CHANGE_FLAG, OTHER, FIELD3) \
51 }
52
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053namespace android {
54
chaviw98318de2021-05-19 16:45:23 -050055using gui::FocusRequest;
56using gui::WindowInfoHandle;
57
Pablo Gamito11dcc222020-09-12 15:49:39 +000058layer_state_t::layer_state_t()
Vishnu Nair685cfef2022-02-02 10:01:25 -080059 : surface(nullptr),
60 layerId(-1),
61 what(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000062 x(0),
63 y(0),
64 z(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000065 flags(0),
66 mask(0),
67 reserved(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000068 cornerRadius(0.0f),
Surbhi Kadam9674ffa2024-11-14 23:06:27 +000069 clientDrawnCornerRadius(0.0f),
70 clientDrawnShadowRadius(0.0f),
Pablo Gamito11dcc222020-09-12 15:49:39 +000071 backgroundBlurRadius(0),
Vishnu Nairbbceb462022-10-10 04:52:13 +000072 color(0),
73 bufferTransform(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000074 transformToDisplayInverse(false),
Vishnu Naira9123c82024-10-03 03:56:44 +000075 crop({0, 0, -1, -1}),
Pablo Gamito11dcc222020-09-12 15:49:39 +000076 dataspace(ui::Dataspace::UNKNOWN),
77 surfaceDamageRegion(),
78 api(-1),
79 colorTransform(mat4()),
Vishnu Naird47bcee2023-02-24 18:08:51 +000080 bgColor(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000081 bgColorDataspace(ui::Dataspace::UNKNOWN),
82 colorSpaceAgnostic(false),
83 shadowRadius(0.0f),
84 frameRateSelectionPriority(-1),
85 frameRate(0.0f),
86 frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
Marin Shalamanovc5986772021-03-16 16:09:49 +010087 changeFrameRateStrategy(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS),
Andy Labrada096227e2022-06-15 16:58:11 +000088 defaultFrameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
Rachel Leece6e0042023-06-27 11:22:54 -070089 frameRateCategory(ANATIVEWINDOW_FRAME_RATE_CATEGORY_DEFAULT),
Rachel Lee67afbea2023-09-28 15:35:07 -070090 frameRateCategorySmoothSwitchOnly(false),
Rachel Lee70f7b692023-11-22 11:24:02 -080091 frameRateSelectionStrategy(ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_PROPAGATE),
Pablo Gamito11dcc222020-09-12 15:49:39 +000092 fixedTransformHint(ui::Transform::ROT_INVALID),
Vishnu Nair1506b182021-02-22 14:35:15 -080093 autoRefresh(false),
Vishnu Nair9e0017e2024-05-22 19:02:44 +000094 trustedOverlay(gui::TrustedOverlay::UNSET),
Vishnu Nair6bdec7d2021-05-10 15:01:13 -070095 bufferCrop(Rect::INVALID_RECT),
96 destinationFrame(Rect::INVALID_RECT),
Brian Lindahl07dcd492024-10-30 11:43:23 -060097 dropInputMode(gui::DropInputMode::NONE),
98 pictureProfileHandle(PictureProfileHandle::NONE),
99 appContentPriority(0) {
Pablo Gamito11dcc222020-09-12 15:49:39 +0000100 matrix.dsdx = matrix.dtdy = 1.0f;
101 matrix.dsdy = matrix.dtdx = 0.0f;
102 hdrMetadata.validTypes = 0;
103}
104
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800105status_t layer_state_t::write(Parcel& output) const
106{
chaviw308ddba2020-08-11 16:23:51 -0700107 SAFE_PARCEL(output.writeStrongBinder, surface);
Pablo Gamitodbc31672020-09-01 18:28:58 +0000108 SAFE_PARCEL(output.writeInt32, layerId);
chaviw308ddba2020-08-11 16:23:51 -0700109 SAFE_PARCEL(output.writeUint64, what);
110 SAFE_PARCEL(output.writeFloat, x);
111 SAFE_PARCEL(output.writeFloat, y);
112 SAFE_PARCEL(output.writeInt32, z);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700113 SAFE_PARCEL(output.writeUint32, layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700114 SAFE_PARCEL(output.writeUint32, flags);
115 SAFE_PARCEL(output.writeUint32, mask);
116 SAFE_PARCEL(matrix.write, output);
Vishnu Naira9123c82024-10-03 03:56:44 +0000117 SAFE_PARCEL(output.writeFloat, crop.top);
118 SAFE_PARCEL(output.writeFloat, crop.left);
119 SAFE_PARCEL(output.writeFloat, crop.bottom);
120 SAFE_PARCEL(output.writeFloat, crop.right);
Pablo Gamito11dcc222020-09-12 15:49:39 +0000121 SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, relativeLayerSurfaceControl);
122 SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, parentSurfaceControlForChild);
chaviw308ddba2020-08-11 16:23:51 -0700123 SAFE_PARCEL(output.writeFloat, color.r);
124 SAFE_PARCEL(output.writeFloat, color.g);
125 SAFE_PARCEL(output.writeFloat, color.b);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000126 SAFE_PARCEL(output.writeFloat, color.a);
chaviw98318de2021-05-19 16:45:23 -0500127 SAFE_PARCEL(windowInfoHandle->writeToParcel, &output);
chaviw308ddba2020-08-11 16:23:51 -0700128 SAFE_PARCEL(output.write, transparentRegion);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000129 SAFE_PARCEL(output.writeUint32, bufferTransform);
chaviw308ddba2020-08-11 16:23:51 -0700130 SAFE_PARCEL(output.writeBool, transformToDisplayInverse);
chaviw308ddba2020-08-11 16:23:51 -0700131 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dataspace));
132 SAFE_PARCEL(output.write, hdrMetadata);
133 SAFE_PARCEL(output.write, surfaceDamageRegion);
134 SAFE_PARCEL(output.writeInt32, api);
135
Marissa Wall61c58622018-07-18 10:12:20 -0700136 if (sidebandStream) {
chaviw308ddba2020-08-11 16:23:51 -0700137 SAFE_PARCEL(output.writeBool, true);
138 SAFE_PARCEL(output.writeNativeHandle, sidebandStream->handle());
Marissa Wall61c58622018-07-18 10:12:20 -0700139 } else {
chaviw308ddba2020-08-11 16:23:51 -0700140 SAFE_PARCEL(output.writeBool, false);
Marissa Wall61c58622018-07-18 10:12:20 -0700141 }
142
chaviw308ddba2020-08-11 16:23:51 -0700143 SAFE_PARCEL(output.write, colorTransform.asArray(), 16 * sizeof(float));
144 SAFE_PARCEL(output.writeFloat, cornerRadius);
Surbhi Kadam9674ffa2024-11-14 23:06:27 +0000145 SAFE_PARCEL(output.writeFloat, clientDrawnCornerRadius);
146 SAFE_PARCEL(output.writeFloat, clientDrawnShadowRadius);
chaviw308ddba2020-08-11 16:23:51 -0700147 SAFE_PARCEL(output.writeUint32, backgroundBlurRadius);
chaviw308ddba2020-08-11 16:23:51 -0700148 SAFE_PARCEL(output.writeParcelable, metadata);
Vishnu Naird47bcee2023-02-24 18:08:51 +0000149 SAFE_PARCEL(output.writeFloat, bgColor.r);
150 SAFE_PARCEL(output.writeFloat, bgColor.g);
151 SAFE_PARCEL(output.writeFloat, bgColor.b);
152 SAFE_PARCEL(output.writeFloat, bgColor.a);
chaviw308ddba2020-08-11 16:23:51 -0700153 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(bgColorDataspace));
154 SAFE_PARCEL(output.writeBool, colorSpaceAgnostic);
155 SAFE_PARCEL(output.writeVectorSize, listeners);
Valerie Hau9dab9732019-08-20 09:29:25 -0700156
157 for (auto listener : listeners) {
chaviw308ddba2020-08-11 16:23:51 -0700158 SAFE_PARCEL(output.writeStrongBinder, listener.transactionCompletedListener);
Vishnu Nairfc46c1e2021-04-21 08:31:32 -0700159 SAFE_PARCEL(output.writeParcelableVector, listener.callbackIds);
Valerie Hau9dab9732019-08-20 09:29:25 -0700160 }
chaviw308ddba2020-08-11 16:23:51 -0700161 SAFE_PARCEL(output.writeFloat, shadowRadius);
162 SAFE_PARCEL(output.writeInt32, frameRateSelectionPriority);
163 SAFE_PARCEL(output.writeFloat, frameRate);
164 SAFE_PARCEL(output.writeByte, frameRateCompatibility);
Marin Shalamanovc5986772021-03-16 16:09:49 +0100165 SAFE_PARCEL(output.writeByte, changeFrameRateStrategy);
Andy Labrada096227e2022-06-15 16:58:11 +0000166 SAFE_PARCEL(output.writeByte, defaultFrameRateCompatibility);
Rachel Leece6e0042023-06-27 11:22:54 -0700167 SAFE_PARCEL(output.writeByte, frameRateCategory);
Rachel Lee67afbea2023-09-28 15:35:07 -0700168 SAFE_PARCEL(output.writeBool, frameRateCategorySmoothSwitchOnly);
Rachel Lee58cc90d2023-09-05 18:50:20 -0700169 SAFE_PARCEL(output.writeByte, frameRateSelectionStrategy);
chaviw308ddba2020-08-11 16:23:51 -0700170 SAFE_PARCEL(output.writeUint32, fixedTransformHint);
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800171 SAFE_PARCEL(output.writeBool, autoRefresh);
Sally Qi81d95e62022-03-21 19:41:33 -0700172 SAFE_PARCEL(output.writeBool, dimmingEnabled);
Lucas Dupinc3800b82020-10-02 16:24:48 -0700173
174 SAFE_PARCEL(output.writeUint32, blurRegions.size());
175 for (auto region : blurRegions) {
176 SAFE_PARCEL(output.writeUint32, region.blurRadius);
177 SAFE_PARCEL(output.writeFloat, region.cornerRadiusTL);
178 SAFE_PARCEL(output.writeFloat, region.cornerRadiusTR);
179 SAFE_PARCEL(output.writeFloat, region.cornerRadiusBL);
180 SAFE_PARCEL(output.writeFloat, region.cornerRadiusBR);
181 SAFE_PARCEL(output.writeFloat, region.alpha);
182 SAFE_PARCEL(output.writeInt32, region.left);
183 SAFE_PARCEL(output.writeInt32, region.top);
184 SAFE_PARCEL(output.writeInt32, region.right);
185 SAFE_PARCEL(output.writeInt32, region.bottom);
186 }
John Reckcdb4ed72021-02-04 13:39:33 -0500187
188 SAFE_PARCEL(output.write, stretchEffect);
Marzia Favarodcc9d9b2024-01-10 10:17:00 +0000189 SAFE_PARCEL(output.writeParcelable, edgeExtensionParameters);
chaviwf3f40fe2021-04-27 15:54:02 -0500190 SAFE_PARCEL(output.write, bufferCrop);
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700191 SAFE_PARCEL(output.write, destinationFrame);
Vishnu Nair9e0017e2024-05-22 19:02:44 +0000192 SAFE_PARCEL(output.writeInt32, static_cast<uint32_t>(trustedOverlay));
John Reckcdb4ed72021-02-04 13:39:33 -0500193
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700194 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode));
Vishnu Nair685cfef2022-02-02 10:01:25 -0800195
196 const bool hasBufferData = (bufferData != nullptr);
197 SAFE_PARCEL(output.writeBool, hasBufferData);
198 if (hasBufferData) {
199 SAFE_PARCEL(output.writeParcelable, *bufferData);
200 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000201 SAFE_PARCEL(output.writeParcelable, trustedPresentationThresholds);
202 SAFE_PARCEL(output.writeParcelable, trustedPresentationListener);
Sally Qi963049b2023-03-23 14:06:21 -0700203 SAFE_PARCEL(output.writeFloat, currentHdrSdrRatio);
204 SAFE_PARCEL(output.writeFloat, desiredHdrSdrRatio);
Vishnu Nair59a6be32024-01-29 10:26:21 -0800205 SAFE_PARCEL(output.writeInt32, static_cast<int32_t>(cachingHint));
Patrick Williamsf693bcf2024-08-02 09:55:23 -0500206
207 const bool hasBufferReleaseChannel = (bufferReleaseChannel != nullptr);
208 SAFE_PARCEL(output.writeBool, hasBufferReleaseChannel);
209 if (hasBufferReleaseChannel) {
210 SAFE_PARCEL(output.writeParcelable, *bufferReleaseChannel);
211 }
Brian Lindahl07dcd492024-10-30 11:43:23 -0600212#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES
213 SAFE_PARCEL(output.writeInt64, pictureProfileHandle.getId());
214 SAFE_PARCEL(output.writeInt32, appContentPriority);
215#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES
Patrick Williamsf693bcf2024-08-02 09:55:23 -0500216
Sally Qief006582024-10-11 13:23:09 -0700217 const bool hasLuts = (luts != nullptr);
218 SAFE_PARCEL(output.writeBool, hasLuts);
219 if (hasLuts) {
220 SAFE_PARCEL(output.writeParcelable, *luts);
221 }
222
Mathias Agopianac9fa422013-02-11 16:40:36 -0800223 return NO_ERROR;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800224}
225
226status_t layer_state_t::read(const Parcel& input)
227{
chaviw308ddba2020-08-11 16:23:51 -0700228 SAFE_PARCEL(input.readNullableStrongBinder, &surface);
Pablo Gamitodbc31672020-09-01 18:28:58 +0000229 SAFE_PARCEL(input.readInt32, &layerId);
chaviw308ddba2020-08-11 16:23:51 -0700230 SAFE_PARCEL(input.readUint64, &what);
231 SAFE_PARCEL(input.readFloat, &x);
232 SAFE_PARCEL(input.readFloat, &y);
233 SAFE_PARCEL(input.readInt32, &z);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700234 SAFE_PARCEL(input.readUint32, &layerStack.id);
Robert Carr2c358bf2018-08-08 15:58:15 -0700235
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800236 SAFE_PARCEL(input.readUint32, &flags);
chaviw308ddba2020-08-11 16:23:51 -0700237
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800238 SAFE_PARCEL(input.readUint32, &mask);
chaviw308ddba2020-08-11 16:23:51 -0700239
240 SAFE_PARCEL(matrix.read, input);
Vishnu Naira9123c82024-10-03 03:56:44 +0000241 SAFE_PARCEL(input.readFloat, &crop.top);
242 SAFE_PARCEL(input.readFloat, &crop.left);
243 SAFE_PARCEL(input.readFloat, &crop.bottom);
244 SAFE_PARCEL(input.readFloat, &crop.right);
chaviw308ddba2020-08-11 16:23:51 -0700245
Pablo Gamito11dcc222020-09-12 15:49:39 +0000246 SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &relativeLayerSurfaceControl);
247 SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &parentSurfaceControlForChild);
248
chaviw308ddba2020-08-11 16:23:51 -0700249 float tmpFloat = 0;
chaviw308ddba2020-08-11 16:23:51 -0700250 SAFE_PARCEL(input.readFloat, &tmpFloat);
251 color.r = tmpFloat;
252 SAFE_PARCEL(input.readFloat, &tmpFloat);
253 color.g = tmpFloat;
254 SAFE_PARCEL(input.readFloat, &tmpFloat);
255 color.b = tmpFloat;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000256 SAFE_PARCEL(input.readFloat, &tmpFloat);
257 color.a = tmpFloat;
258
chaviw98318de2021-05-19 16:45:23 -0500259 SAFE_PARCEL(windowInfoHandle->readFromParcel, &input);
Robert Carr2c358bf2018-08-08 15:58:15 -0700260
chaviw308ddba2020-08-11 16:23:51 -0700261 SAFE_PARCEL(input.read, transparentRegion);
Vishnu Nairbbceb462022-10-10 04:52:13 +0000262 SAFE_PARCEL(input.readUint32, &bufferTransform);
chaviw308ddba2020-08-11 16:23:51 -0700263 SAFE_PARCEL(input.readBool, &transformToDisplayInverse);
chaviw308ddba2020-08-11 16:23:51 -0700264
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800265 uint32_t tmpUint32 = 0;
chaviw308ddba2020-08-11 16:23:51 -0700266 SAFE_PARCEL(input.readUint32, &tmpUint32);
267 dataspace = static_cast<ui::Dataspace>(tmpUint32);
268
269 SAFE_PARCEL(input.read, hdrMetadata);
270 SAFE_PARCEL(input.read, surfaceDamageRegion);
271 SAFE_PARCEL(input.readInt32, &api);
chaviwba4320c2021-09-15 15:20:53 -0500272
273 bool tmpBool = false;
chaviw308ddba2020-08-11 16:23:51 -0700274 SAFE_PARCEL(input.readBool, &tmpBool);
275 if (tmpBool) {
Marissa Wall61c58622018-07-18 10:12:20 -0700276 sidebandStream = NativeHandle::create(input.readNativeHandle(), true);
277 }
278
chaviw308ddba2020-08-11 16:23:51 -0700279 SAFE_PARCEL(input.read, &colorTransform, 16 * sizeof(float));
280 SAFE_PARCEL(input.readFloat, &cornerRadius);
Surbhi Kadam9674ffa2024-11-14 23:06:27 +0000281 SAFE_PARCEL(input.readFloat, &clientDrawnCornerRadius);
282 SAFE_PARCEL(input.readFloat, &clientDrawnShadowRadius);
chaviw308ddba2020-08-11 16:23:51 -0700283 SAFE_PARCEL(input.readUint32, &backgroundBlurRadius);
chaviw308ddba2020-08-11 16:23:51 -0700284 SAFE_PARCEL(input.readParcelable, &metadata);
Marissa Wallebc2c052019-01-16 19:16:55 -0800285
Vishnu Naird47bcee2023-02-24 18:08:51 +0000286 SAFE_PARCEL(input.readFloat, &tmpFloat);
287 bgColor.r = tmpFloat;
288 SAFE_PARCEL(input.readFloat, &tmpFloat);
289 bgColor.g = tmpFloat;
290 SAFE_PARCEL(input.readFloat, &tmpFloat);
291 bgColor.b = tmpFloat;
292 SAFE_PARCEL(input.readFloat, &tmpFloat);
293 bgColor.a = tmpFloat;
chaviw308ddba2020-08-11 16:23:51 -0700294 SAFE_PARCEL(input.readUint32, &tmpUint32);
295 bgColorDataspace = static_cast<ui::Dataspace>(tmpUint32);
296 SAFE_PARCEL(input.readBool, &colorSpaceAgnostic);
Valerie Haued54efa2019-01-11 20:03:14 -0800297
chaviw308ddba2020-08-11 16:23:51 -0700298 int32_t numListeners = 0;
299 SAFE_PARCEL_READ_SIZE(input.readInt32, &numListeners, input.dataSize());
Valerie Hau9dab9732019-08-20 09:29:25 -0700300 listeners.clear();
301 for (int i = 0; i < numListeners; i++) {
chaviw308ddba2020-08-11 16:23:51 -0700302 sp<IBinder> listener;
Valerie Hau9dab9732019-08-20 09:29:25 -0700303 std::vector<CallbackId> callbackIds;
chaviw308ddba2020-08-11 16:23:51 -0700304 SAFE_PARCEL(input.readNullableStrongBinder, &listener);
Vishnu Nairfc46c1e2021-04-21 08:31:32 -0700305 SAFE_PARCEL(input.readParcelableVector, &callbackIds);
Valerie Hau9dab9732019-08-20 09:29:25 -0700306 listeners.emplace_back(listener, callbackIds);
307 }
chaviw308ddba2020-08-11 16:23:51 -0700308 SAFE_PARCEL(input.readFloat, &shadowRadius);
309 SAFE_PARCEL(input.readInt32, &frameRateSelectionPriority);
310 SAFE_PARCEL(input.readFloat, &frameRate);
311 SAFE_PARCEL(input.readByte, &frameRateCompatibility);
Marin Shalamanovc5986772021-03-16 16:09:49 +0100312 SAFE_PARCEL(input.readByte, &changeFrameRateStrategy);
Andy Labrada096227e2022-06-15 16:58:11 +0000313 SAFE_PARCEL(input.readByte, &defaultFrameRateCompatibility);
Rachel Leece6e0042023-06-27 11:22:54 -0700314 SAFE_PARCEL(input.readByte, &frameRateCategory);
Rachel Lee67afbea2023-09-28 15:35:07 -0700315 SAFE_PARCEL(input.readBool, &frameRateCategorySmoothSwitchOnly);
Rachel Lee58cc90d2023-09-05 18:50:20 -0700316 SAFE_PARCEL(input.readByte, &frameRateSelectionStrategy);
chaviw308ddba2020-08-11 16:23:51 -0700317 SAFE_PARCEL(input.readUint32, &tmpUint32);
318 fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32);
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800319 SAFE_PARCEL(input.readBool, &autoRefresh);
Sally Qi81d95e62022-03-21 19:41:33 -0700320 SAFE_PARCEL(input.readBool, &dimmingEnabled);
Lucas Dupinc3800b82020-10-02 16:24:48 -0700321
322 uint32_t numRegions = 0;
323 SAFE_PARCEL(input.readUint32, &numRegions);
324 blurRegions.clear();
325 for (uint32_t i = 0; i < numRegions; i++) {
326 BlurRegion region;
327 SAFE_PARCEL(input.readUint32, &region.blurRadius);
328 SAFE_PARCEL(input.readFloat, &region.cornerRadiusTL);
329 SAFE_PARCEL(input.readFloat, &region.cornerRadiusTR);
330 SAFE_PARCEL(input.readFloat, &region.cornerRadiusBL);
331 SAFE_PARCEL(input.readFloat, &region.cornerRadiusBR);
332 SAFE_PARCEL(input.readFloat, &region.alpha);
333 SAFE_PARCEL(input.readInt32, &region.left);
334 SAFE_PARCEL(input.readInt32, &region.top);
335 SAFE_PARCEL(input.readInt32, &region.right);
336 SAFE_PARCEL(input.readInt32, &region.bottom);
337 blurRegions.push_back(region);
338 }
John Reckcdb4ed72021-02-04 13:39:33 -0500339
340 SAFE_PARCEL(input.read, stretchEffect);
Marzia Favarodcc9d9b2024-01-10 10:17:00 +0000341 SAFE_PARCEL(input.readParcelable, &edgeExtensionParameters);
chaviwf3f40fe2021-04-27 15:54:02 -0500342 SAFE_PARCEL(input.read, bufferCrop);
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700343 SAFE_PARCEL(input.read, destinationFrame);
Vishnu Nair9e0017e2024-05-22 19:02:44 +0000344 uint32_t trustedOverlayInt;
345 SAFE_PARCEL(input.readUint32, &trustedOverlayInt);
346 trustedOverlay = static_cast<gui::TrustedOverlay>(trustedOverlayInt);
John Reckcdb4ed72021-02-04 13:39:33 -0500347
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700348 uint32_t mode;
349 SAFE_PARCEL(input.readUint32, &mode);
350 dropInputMode = static_cast<gui::DropInputMode>(mode);
Vishnu Nair685cfef2022-02-02 10:01:25 -0800351
352 bool hasBufferData;
353 SAFE_PARCEL(input.readBool, &hasBufferData);
354 if (hasBufferData) {
355 bufferData = std::make_shared<BufferData>();
356 SAFE_PARCEL(input.readParcelable, bufferData.get());
357 } else {
358 bufferData = nullptr;
359 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000360
361 SAFE_PARCEL(input.readParcelable, &trustedPresentationThresholds);
362 SAFE_PARCEL(input.readParcelable, &trustedPresentationListener);
363
John Reck68796592023-01-25 13:47:12 -0500364 SAFE_PARCEL(input.readFloat, &tmpFloat);
Sally Qi963049b2023-03-23 14:06:21 -0700365 currentHdrSdrRatio = tmpFloat;
John Reck68796592023-01-25 13:47:12 -0500366 SAFE_PARCEL(input.readFloat, &tmpFloat);
Sally Qi963049b2023-03-23 14:06:21 -0700367 desiredHdrSdrRatio = tmpFloat;
John Reck68796592023-01-25 13:47:12 -0500368
Alec Mourif4af03e2023-02-11 00:25:24 +0000369 int32_t tmpInt32;
370 SAFE_PARCEL(input.readInt32, &tmpInt32);
371 cachingHint = static_cast<gui::CachingHint>(tmpInt32);
372
Patrick Williamsf693bcf2024-08-02 09:55:23 -0500373 bool hasBufferReleaseChannel;
374 SAFE_PARCEL(input.readBool, &hasBufferReleaseChannel);
375 if (hasBufferReleaseChannel) {
376 bufferReleaseChannel = std::make_shared<gui::BufferReleaseChannel::ProducerEndpoint>();
377 SAFE_PARCEL(input.readParcelable, bufferReleaseChannel.get());
378 }
Brian Lindahl07dcd492024-10-30 11:43:23 -0600379#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES
380 int64_t pictureProfileId;
381 SAFE_PARCEL(input.readInt64, &pictureProfileId);
382 pictureProfileHandle = PictureProfileHandle(pictureProfileId);
383 SAFE_PARCEL(input.readInt32, &appContentPriority);
384#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES
Patrick Williamsf693bcf2024-08-02 09:55:23 -0500385
Sally Qief006582024-10-11 13:23:09 -0700386 bool hasLuts;
387 SAFE_PARCEL(input.readBool, &hasLuts);
388 if (hasLuts) {
389 luts = std::make_shared<gui::DisplayLuts>();
390 SAFE_PARCEL(input.readParcelable, luts.get());
391 } else {
392 luts = nullptr;
393 }
394
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800395 return NO_ERROR;
396}
397
Mathias Agopian698c0872011-06-28 19:09:31 -0700398status_t ComposerState::write(Parcel& output) const {
Mathias Agopian698c0872011-06-28 19:09:31 -0700399 return state.write(output);
400}
401
402status_t ComposerState::read(const Parcel& input) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700403 return state.read(input);
404}
405
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700406DisplayState::DisplayState() = default;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700407
Mathias Agopian8b33f032012-07-24 20:43:54 -0700408status_t DisplayState::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700409 SAFE_PARCEL(output.writeStrongBinder, token);
410 SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(surface));
411 SAFE_PARCEL(output.writeUint32, what);
Evan Rosky2239b372021-05-20 13:43:47 -0700412 SAFE_PARCEL(output.writeUint32, flags);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700413 SAFE_PARCEL(output.writeUint32, layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700414 SAFE_PARCEL(output.writeUint32, toRotationInt(orientation));
415 SAFE_PARCEL(output.write, layerStackSpaceRect);
416 SAFE_PARCEL(output.write, orientedDisplaySpaceRect);
417 SAFE_PARCEL(output.writeUint32, width);
418 SAFE_PARCEL(output.writeUint32, height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700419 return NO_ERROR;
420}
421
422status_t DisplayState::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700423 SAFE_PARCEL(input.readStrongBinder, &token);
424 sp<IBinder> tmpBinder;
425 SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder);
426 surface = interface_cast<IGraphicBufferProducer>(tmpBinder);
427
428 SAFE_PARCEL(input.readUint32, &what);
Evan Rosky2239b372021-05-20 13:43:47 -0700429 SAFE_PARCEL(input.readUint32, &flags);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700430 SAFE_PARCEL(input.readUint32, &layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700431 uint32_t tmpUint = 0;
432 SAFE_PARCEL(input.readUint32, &tmpUint);
433 orientation = ui::toRotation(tmpUint);
434
435 SAFE_PARCEL(input.read, layerStackSpaceRect);
436 SAFE_PARCEL(input.read, orientedDisplaySpaceRect);
437 SAFE_PARCEL(input.readUint32, &width);
438 SAFE_PARCEL(input.readUint32, &height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700439 return NO_ERROR;
440}
441
Robert Carr2c5f6d22017-09-26 12:30:35 -0700442void DisplayState::merge(const DisplayState& other) {
443 if (other.what & eSurfaceChanged) {
444 what |= eSurfaceChanged;
445 surface = other.surface;
446 }
447 if (other.what & eLayerStackChanged) {
448 what |= eLayerStackChanged;
449 layerStack = other.layerStack;
450 }
Evan Rosky2239b372021-05-20 13:43:47 -0700451 if (other.what & eFlagsChanged) {
452 what |= eFlagsChanged;
453 flags = other.flags;
454 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700455 if (other.what & eDisplayProjectionChanged) {
456 what |= eDisplayProjectionChanged;
457 orientation = other.orientation;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200458 layerStackSpaceRect = other.layerStackSpaceRect;
459 orientedDisplaySpaceRect = other.orientedDisplaySpaceRect;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700460 }
461 if (other.what & eDisplaySizeChanged) {
462 what |= eDisplaySizeChanged;
463 width = other.width;
464 height = other.height;
465 }
466}
467
Sally Qi6bb12822022-10-05 11:42:30 -0700468void DisplayState::sanitize(int32_t permissions) {
469 if (what & DisplayState::eLayerStackChanged) {
470 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
471 what &= ~DisplayState::eLayerStackChanged;
472 ALOGE("Stripped attempt to set eLayerStackChanged in sanitize");
473 }
474 }
475 if (what & DisplayState::eDisplayProjectionChanged) {
476 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
477 what &= ~DisplayState::eDisplayProjectionChanged;
478 ALOGE("Stripped attempt to set eDisplayProjectionChanged in sanitize");
479 }
480 }
481 if (what & DisplayState::eSurfaceChanged) {
482 if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
483 what &= ~DisplayState::eSurfaceChanged;
484 ALOGE("Stripped attempt to set eSurfaceChanged in sanitize");
485 }
486 }
487}
488
Robert Carrde6d7b42022-01-07 18:23:06 -0800489void layer_state_t::sanitize(int32_t permissions) {
490 // TODO: b/109894387
491 //
492 // SurfaceFlinger's renderer is not prepared to handle cropping in the face of arbitrary
493 // rotation. To see the problem observe that if we have a square parent, and a child
494 // of the same size, then we rotate the child 45 degrees around its center, the child
495 // must now be cropped to a non rectangular 8 sided region.
496 //
497 // Of course we can fix this in the future. For now, we are lucky, SurfaceControl is
498 // private API, and arbitrary rotation is used in limited use cases, for instance:
499 // - WindowManager only uses rotation in one case, which is on a top level layer in which
500 // cropping is not an issue.
501 // - Launcher, as a privileged app, uses this to transition an application to PiP
502 // (picture-in-picture) mode.
503 //
504 // However given that abuse of rotation matrices could lead to surfaces extending outside
505 // of cropped areas, we need to prevent non-root clients without permission
506 // ACCESS_SURFACE_FLINGER nor ROTATE_SURFACE_FLINGER
507 // (a.k.a. everyone except WindowManager / tests / Launcher) from setting non rectangle
508 // preserving transformations.
509 if (what & eMatrixChanged) {
510 if (!(permissions & Permission::ROTATE_SURFACE_FLINGER)) {
511 ui::Transform t;
512 t.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy);
513 if (!t.preserveRects()) {
514 what &= ~eMatrixChanged;
515 ALOGE("Stripped non rect preserving matrix in sanitize");
516 }
517 }
518 }
519
520 if (what & eFlagsChanged) {
521 if ((flags & eLayerIsDisplayDecoration) &&
522 !(permissions & Permission::INTERNAL_SYSTEM_WINDOW)) {
523 flags &= ~eLayerIsDisplayDecoration;
524 ALOGE("Stripped attempt to set LayerIsDisplayDecoration in sanitize");
525 }
Vishnu Nair59a6be32024-01-29 10:26:21 -0800526 if ((mask & eCanOccludePresentation) &&
527 !(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
528 flags &= ~eCanOccludePresentation;
529 mask &= ~eCanOccludePresentation;
530 ALOGE("Stripped attempt to set eCanOccludePresentation in sanitize");
531 }
Robert Carrde6d7b42022-01-07 18:23:06 -0800532 }
533
534 if (what & layer_state_t::eInputInfoChanged) {
535 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
536 what &= ~eInputInfoChanged;
537 ALOGE("Stripped attempt to set eInputInfoChanged in sanitize");
538 }
539 }
540 if (what & layer_state_t::eTrustedOverlayChanged) {
541 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
542 what &= ~eTrustedOverlayChanged;
543 ALOGE("Stripped attempt to set eTrustedOverlay in sanitize");
544 }
545 }
546 if (what & layer_state_t::eDropInputModeChanged) {
547 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
548 what &= ~eDropInputModeChanged;
549 ALOGE("Stripped attempt to set eDropInputModeChanged in sanitize");
550 }
551 }
552 if (what & layer_state_t::eFrameRateSelectionPriority) {
553 if (!(permissions & Permission::ACCESS_SURFACE_FLINGER)) {
554 what &= ~eFrameRateSelectionPriority;
555 ALOGE("Stripped attempt to set eFrameRateSelectionPriority in sanitize");
556 }
557 }
558 if (what & layer_state_t::eFrameRateChanged) {
559 if (!ValidateFrameRate(frameRate, frameRateCompatibility,
560 changeFrameRateStrategy,
561 "layer_state_t::sanitize",
562 permissions & Permission::ACCESS_SURFACE_FLINGER)) {
563 what &= ~eFrameRateChanged; // logged in ValidateFrameRate
564 }
565 }
566}
567
Robert Carr2c5f6d22017-09-26 12:30:35 -0700568void layer_state_t::merge(const layer_state_t& other) {
569 if (other.what & ePositionChanged) {
570 what |= ePositionChanged;
571 x = other.x;
572 y = other.y;
573 }
574 if (other.what & eLayerChanged) {
575 what |= eLayerChanged;
chaviw32377582019-05-13 11:15:19 -0700576 what &= ~eRelativeLayerChanged;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700577 z = other.z;
578 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700579 if (other.what & eAlphaChanged) {
580 what |= eAlphaChanged;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000581 color.a = other.color.a;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700582 }
583 if (other.what & eMatrixChanged) {
584 what |= eMatrixChanged;
585 matrix = other.matrix;
586 }
587 if (other.what & eTransparentRegionChanged) {
588 what |= eTransparentRegionChanged;
589 transparentRegion = other.transparentRegion;
590 }
591 if (other.what & eFlagsChanged) {
592 what |= eFlagsChanged;
Vishnu Nair996bc422019-07-16 14:15:33 -0700593 flags &= ~other.mask;
594 flags |= (other.flags & other.mask);
595 mask |= other.mask;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700596 }
597 if (other.what & eLayerStackChanged) {
598 what |= eLayerStackChanged;
599 layerStack = other.layerStack;
600 }
Lucas Dupin1b6531c2018-07-05 17:18:21 -0700601 if (other.what & eCornerRadiusChanged) {
602 what |= eCornerRadiusChanged;
603 cornerRadius = other.cornerRadius;
604 }
Surbhi Kadam9674ffa2024-11-14 23:06:27 +0000605 if (other.what & eClientDrawnCornerRadiusChanged) {
606 what |= eClientDrawnCornerRadiusChanged;
607 clientDrawnCornerRadius = other.clientDrawnCornerRadius;
608 }
609 if (other.what & eClientDrawnShadowsChanged) {
610 what |= eClientDrawnShadowsChanged;
611 clientDrawnShadowRadius = other.clientDrawnShadowRadius;
612 }
Lucas Dupin19c8f0e2019-11-25 17:55:44 -0800613 if (other.what & eBackgroundBlurRadiusChanged) {
614 what |= eBackgroundBlurRadiusChanged;
615 backgroundBlurRadius = other.backgroundBlurRadius;
616 }
Lucas Dupinc3800b82020-10-02 16:24:48 -0700617 if (other.what & eBlurRegionsChanged) {
618 what |= eBlurRegionsChanged;
619 blurRegions = other.blurRegions;
620 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700621 if (other.what & eRelativeLayerChanged) {
622 what |= eRelativeLayerChanged;
chaviw32377582019-05-13 11:15:19 -0700623 what &= ~eLayerChanged;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700624 z = other.z;
Pablo Gamito11dcc222020-09-12 15:49:39 +0000625 relativeLayerSurfaceControl = other.relativeLayerSurfaceControl;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700626 }
627 if (other.what & eReparent) {
628 what |= eReparent;
Pablo Gamito11dcc222020-09-12 15:49:39 +0000629 parentSurfaceControlForChild = other.parentSurfaceControlForChild;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700630 }
Vishnu Nairbbceb462022-10-10 04:52:13 +0000631 if (other.what & eBufferTransformChanged) {
632 what |= eBufferTransformChanged;
633 bufferTransform = other.bufferTransform;
Marissa Wall61c58622018-07-18 10:12:20 -0700634 }
635 if (other.what & eTransformToDisplayInverseChanged) {
636 what |= eTransformToDisplayInverseChanged;
637 transformToDisplayInverse = other.transformToDisplayInverse;
638 }
639 if (other.what & eCropChanged) {
640 what |= eCropChanged;
641 crop = other.crop;
642 }
643 if (other.what & eBufferChanged) {
644 what |= eBufferChanged;
chaviwba4320c2021-09-15 15:20:53 -0500645 bufferData = other.bufferData;
Marissa Wall61c58622018-07-18 10:12:20 -0700646 }
Chavi Weingarten076acac2023-01-19 17:20:43 +0000647 if (other.what & eTrustedPresentationInfoChanged) {
648 what |= eTrustedPresentationInfoChanged;
649 trustedPresentationListener = other.trustedPresentationListener;
650 trustedPresentationThresholds = other.trustedPresentationThresholds;
651 }
Marissa Wall61c58622018-07-18 10:12:20 -0700652 if (other.what & eDataspaceChanged) {
653 what |= eDataspaceChanged;
654 dataspace = other.dataspace;
655 }
John Reck68796592023-01-25 13:47:12 -0500656 if (other.what & eExtendedRangeBrightnessChanged) {
657 what |= eExtendedRangeBrightnessChanged;
Sally Qi963049b2023-03-23 14:06:21 -0700658 desiredHdrSdrRatio = other.desiredHdrSdrRatio;
659 currentHdrSdrRatio = other.currentHdrSdrRatio;
John Reck68796592023-01-25 13:47:12 -0500660 }
Alec Mouri1b0d4e12024-02-12 22:27:19 +0000661 if (other.what & eDesiredHdrHeadroomChanged) {
662 what |= eDesiredHdrHeadroomChanged;
663 desiredHdrSdrRatio = other.desiredHdrSdrRatio;
664 }
Alec Mourif4af03e2023-02-11 00:25:24 +0000665 if (other.what & eCachingHintChanged) {
666 what |= eCachingHintChanged;
667 cachingHint = other.cachingHint;
668 }
Marissa Wall61c58622018-07-18 10:12:20 -0700669 if (other.what & eHdrMetadataChanged) {
670 what |= eHdrMetadataChanged;
671 hdrMetadata = other.hdrMetadata;
672 }
673 if (other.what & eSurfaceDamageRegionChanged) {
674 what |= eSurfaceDamageRegionChanged;
675 surfaceDamageRegion = other.surfaceDamageRegion;
676 }
677 if (other.what & eApiChanged) {
678 what |= eApiChanged;
679 api = other.api;
680 }
681 if (other.what & eSidebandStreamChanged) {
682 what |= eSidebandStreamChanged;
683 sidebandStream = other.sidebandStream;
684 }
Peiyong Lind3788632018-09-18 16:01:31 -0700685 if (other.what & eColorTransformChanged) {
686 what |= eColorTransformChanged;
687 colorTransform = other.colorTransform;
688 }
Marissa Wall3dad52d2019-03-22 14:03:19 -0700689 if (other.what & eHasListenerCallbacksChanged) {
690 what |= eHasListenerCallbacksChanged;
Marissa Wallc837b5e2018-10-12 10:04:44 -0700691 }
Robert Carr2c358bf2018-08-08 15:58:15 -0700692 if (other.what & eInputInfoChanged) {
693 what |= eInputInfoChanged;
chaviw98318de2021-05-19 16:45:23 -0500694 windowInfoHandle = new WindowInfoHandle(*other.windowInfoHandle);
Robert Carr2c358bf2018-08-08 15:58:15 -0700695 }
Valerie Haudd0b7572019-01-29 14:59:27 -0800696 if (other.what & eBackgroundColorChanged) {
697 what |= eBackgroundColorChanged;
Vishnu Naird47bcee2023-02-24 18:08:51 +0000698 bgColor = other.bgColor;
Valerie Haudd0b7572019-01-29 14:59:27 -0800699 bgColorDataspace = other.bgColorDataspace;
Valerie Haued54efa2019-01-11 20:03:14 -0800700 }
Evan Rosky1f6d6d52018-12-06 10:47:26 -0800701 if (other.what & eMetadataChanged) {
702 what |= eMetadataChanged;
703 metadata.merge(other.metadata);
704 }
Vishnu Nairc97b8db2019-10-29 18:19:35 -0700705 if (other.what & eShadowRadiusChanged) {
706 what |= eShadowRadiusChanged;
707 shadowRadius = other.shadowRadius;
708 }
Sally Qi0abc4a52024-09-26 16:13:06 -0700709 if (other.what & eLutsChanged) {
710 what |= eLutsChanged;
711 luts = other.luts;
712 }
Andy Labrada096227e2022-06-15 16:58:11 +0000713 if (other.what & eDefaultFrameRateCompatibilityChanged) {
714 what |= eDefaultFrameRateCompatibilityChanged;
715 defaultFrameRateCompatibility = other.defaultFrameRateCompatibility;
716 }
Ana Krulecc84d09b2019-11-02 23:10:29 +0100717 if (other.what & eFrameRateSelectionPriority) {
718 what |= eFrameRateSelectionPriority;
719 frameRateSelectionPriority = other.frameRateSelectionPriority;
720 }
Steven Thomas3172e202020-01-06 19:25:30 -0800721 if (other.what & eFrameRateChanged) {
722 what |= eFrameRateChanged;
723 frameRate = other.frameRate;
Steven Thomas62a4cf82020-01-31 12:04:03 -0800724 frameRateCompatibility = other.frameRateCompatibility;
Marin Shalamanovc5986772021-03-16 16:09:49 +0100725 changeFrameRateStrategy = other.changeFrameRateStrategy;
Steven Thomas3172e202020-01-06 19:25:30 -0800726 }
Rachel Leece6e0042023-06-27 11:22:54 -0700727 if (other.what & eFrameRateCategoryChanged) {
728 what |= eFrameRateCategoryChanged;
729 frameRateCategory = other.frameRateCategory;
Rachel Lee67afbea2023-09-28 15:35:07 -0700730 frameRateCategorySmoothSwitchOnly = other.frameRateCategorySmoothSwitchOnly;
Rachel Leece6e0042023-06-27 11:22:54 -0700731 }
Rachel Lee58cc90d2023-09-05 18:50:20 -0700732 if (other.what & eFrameRateSelectionStrategyChanged) {
733 what |= eFrameRateSelectionStrategyChanged;
734 frameRateSelectionStrategy = other.frameRateSelectionStrategy;
735 }
Vishnu Nair6213bd92020-05-08 17:42:25 -0700736 if (other.what & eFixedTransformHintChanged) {
737 what |= eFixedTransformHintChanged;
738 fixedTransformHint = other.fixedTransformHint;
739 }
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800740 if (other.what & eAutoRefreshChanged) {
741 what |= eAutoRefreshChanged;
742 autoRefresh = other.autoRefresh;
743 }
Winson Chunga30f7c92021-06-29 15:42:56 -0700744 if (other.what & eTrustedOverlayChanged) {
745 what |= eTrustedOverlayChanged;
Vishnu Nair9e0017e2024-05-22 19:02:44 +0000746 trustedOverlay = other.trustedOverlay;
Winson Chunga30f7c92021-06-29 15:42:56 -0700747 }
John Reckc00c6692021-02-16 11:37:33 -0500748 if (other.what & eStretchChanged) {
749 what |= eStretchChanged;
750 stretchEffect = other.stretchEffect;
751 }
Marzia Favarodcc9d9b2024-01-10 10:17:00 +0000752 if (other.what & eEdgeExtensionChanged) {
753 what |= eEdgeExtensionChanged;
754 edgeExtensionParameters = other.edgeExtensionParameters;
755 }
chaviwf3f40fe2021-04-27 15:54:02 -0500756 if (other.what & eBufferCropChanged) {
757 what |= eBufferCropChanged;
758 bufferCrop = other.bufferCrop;
759 }
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700760 if (other.what & eDestinationFrameChanged) {
761 what |= eDestinationFrameChanged;
762 destinationFrame = other.destinationFrame;
763 }
Vishnu Nair0e816872021-07-14 10:53:04 -0700764 if (other.what & eProducerDisconnect) {
765 what |= eProducerDisconnect;
766 }
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700767 if (other.what & eDropInputModeChanged) {
768 what |= eDropInputModeChanged;
769 dropInputMode = other.dropInputMode;
770 }
chaviw4c36cd82021-11-18 10:37:33 -0600771 if (other.what & eColorChanged) {
772 what |= eColorChanged;
Vishnu Nairbbceb462022-10-10 04:52:13 +0000773 color.rgb = other.color.rgb;
chaviw4c36cd82021-11-18 10:37:33 -0600774 }
Arthur Hung91b346a2022-03-14 21:36:22 +0800775 if (other.what & eColorSpaceAgnosticChanged) {
776 what |= eColorSpaceAgnosticChanged;
777 colorSpaceAgnostic = other.colorSpaceAgnostic;
778 }
Sally Qi81d95e62022-03-21 19:41:33 -0700779 if (other.what & eDimmingEnabledChanged) {
780 what |= eDimmingEnabledChanged;
781 dimmingEnabled = other.dimmingEnabled;
782 }
Pascal Muetschardb39918f2023-01-27 11:36:11 +0100783 if (other.what & eFlushJankData) {
784 what |= eFlushJankData;
785 }
Patrick Williamsf693bcf2024-08-02 09:55:23 -0500786 if (other.what & eBufferReleaseChannelChanged) {
787 what |= eBufferReleaseChannelChanged;
788 bufferReleaseChannel = other.bufferReleaseChannel;
789 }
Brian Lindahl07dcd492024-10-30 11:43:23 -0600790 if (com_android_graphics_libgui_flags_apply_picture_profiles()) {
791 if (other.what & ePictureProfileHandleChanged) {
792 what |= ePictureProfileHandleChanged;
793 pictureProfileHandle = other.pictureProfileHandle;
794 }
795 if (other.what & eAppContentPriorityChanged) {
796 what |= eAppContentPriorityChanged;
797 appContentPriority = other.appContentPriority;
798 }
799 }
Vishnu Nair217d8e62018-09-12 16:34:49 -0700800 if ((other.what & what) != other.what) {
801 ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
Vishnu Nair0e816872021-07-14 10:53:04 -0700802 "other.what=0x%" PRIX64 " what=0x%" PRIX64 " unmerged flags=0x%" PRIX64,
803 other.what, what, (other.what & what) ^ other.what);
Robert Carrd314f162018-08-15 13:12:42 -0700804 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700805}
Mathias Agopian8b33f032012-07-24 20:43:54 -0700806
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000807uint64_t layer_state_t::diff(const layer_state_t& other) const {
808 uint64_t diff = 0;
809 CHECK_DIFF2(diff, ePositionChanged, other, x, y);
810 if (other.what & eLayerChanged) {
811 diff |= eLayerChanged;
812 diff &= ~eRelativeLayerChanged;
813 }
814 CHECK_DIFF(diff, eAlphaChanged, other, color.a);
815 CHECK_DIFF(diff, eMatrixChanged, other, matrix);
816 if (other.what & eTransparentRegionChanged &&
817 (!transparentRegion.hasSameRects(other.transparentRegion))) {
818 diff |= eTransparentRegionChanged;
819 }
820 if (other.what & eFlagsChanged) {
821 uint64_t changedFlags = (flags & other.mask) ^ (other.flags & other.mask);
822 if (changedFlags) diff |= eFlagsChanged;
823 }
824 CHECK_DIFF(diff, eLayerStackChanged, other, layerStack);
825 CHECK_DIFF(diff, eCornerRadiusChanged, other, cornerRadius);
Surbhi Kadam9674ffa2024-11-14 23:06:27 +0000826 CHECK_DIFF(diff, eClientDrawnCornerRadiusChanged, other, clientDrawnCornerRadius);
827 CHECK_DIFF(diff, eClientDrawnShadowsChanged, other, clientDrawnShadowRadius);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000828 CHECK_DIFF(diff, eBackgroundBlurRadiusChanged, other, backgroundBlurRadius);
829 if (other.what & eBlurRegionsChanged) diff |= eBlurRegionsChanged;
830 if (other.what & eRelativeLayerChanged) {
831 diff |= eRelativeLayerChanged;
832 diff &= ~eLayerChanged;
833 }
834 if (other.what & eReparent &&
835 !SurfaceControl::isSameSurface(parentSurfaceControlForChild,
836 other.parentSurfaceControlForChild)) {
837 diff |= eReparent;
838 }
839 CHECK_DIFF(diff, eBufferTransformChanged, other, bufferTransform);
840 CHECK_DIFF(diff, eTransformToDisplayInverseChanged, other, transformToDisplayInverse);
841 CHECK_DIFF(diff, eCropChanged, other, crop);
842 if (other.what & eBufferChanged) diff |= eBufferChanged;
843 CHECK_DIFF(diff, eDataspaceChanged, other, dataspace);
Sally Qi963049b2023-03-23 14:06:21 -0700844 CHECK_DIFF2(diff, eExtendedRangeBrightnessChanged, other, currentHdrSdrRatio,
845 desiredHdrSdrRatio);
Alec Mouri1b0d4e12024-02-12 22:27:19 +0000846 CHECK_DIFF(diff, eDesiredHdrHeadroomChanged, other, desiredHdrSdrRatio);
Alec Mourif4af03e2023-02-11 00:25:24 +0000847 CHECK_DIFF(diff, eCachingHintChanged, other, cachingHint);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000848 CHECK_DIFF(diff, eHdrMetadataChanged, other, hdrMetadata);
849 if (other.what & eSurfaceDamageRegionChanged &&
850 (!surfaceDamageRegion.hasSameRects(other.surfaceDamageRegion))) {
851 diff |= eSurfaceDamageRegionChanged;
852 }
853 CHECK_DIFF(diff, eApiChanged, other, api);
854 if (other.what & eSidebandStreamChanged) diff |= eSidebandStreamChanged;
855 CHECK_DIFF(diff, eApiChanged, other, api);
856 CHECK_DIFF(diff, eColorTransformChanged, other, colorTransform);
857 if (other.what & eHasListenerCallbacksChanged) diff |= eHasListenerCallbacksChanged;
858 if (other.what & eInputInfoChanged) diff |= eInputInfoChanged;
Vishnu Naird47bcee2023-02-24 18:08:51 +0000859 CHECK_DIFF2(diff, eBackgroundColorChanged, other, bgColor, bgColorDataspace);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000860 if (other.what & eMetadataChanged) diff |= eMetadataChanged;
861 CHECK_DIFF(diff, eShadowRadiusChanged, other, shadowRadius);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000862 CHECK_DIFF(diff, eDefaultFrameRateCompatibilityChanged, other, defaultFrameRateCompatibility);
863 CHECK_DIFF(diff, eFrameRateSelectionPriority, other, frameRateSelectionPriority);
864 CHECK_DIFF3(diff, eFrameRateChanged, other, frameRate, frameRateCompatibility,
865 changeFrameRateStrategy);
Rachel Lee67afbea2023-09-28 15:35:07 -0700866 CHECK_DIFF2(diff, eFrameRateCategoryChanged, other, frameRateCategory,
867 frameRateCategorySmoothSwitchOnly);
Rachel Lee58cc90d2023-09-05 18:50:20 -0700868 CHECK_DIFF(diff, eFrameRateSelectionStrategyChanged, other, frameRateSelectionStrategy);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000869 CHECK_DIFF(diff, eFixedTransformHintChanged, other, fixedTransformHint);
870 CHECK_DIFF(diff, eAutoRefreshChanged, other, autoRefresh);
Vishnu Nair9e0017e2024-05-22 19:02:44 +0000871 CHECK_DIFF(diff, eTrustedOverlayChanged, other, trustedOverlay);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000872 CHECK_DIFF(diff, eStretchChanged, other, stretchEffect);
Marzia Favarodcc9d9b2024-01-10 10:17:00 +0000873 CHECK_DIFF(diff, eEdgeExtensionChanged, other, edgeExtensionParameters);
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000874 CHECK_DIFF(diff, eBufferCropChanged, other, bufferCrop);
875 CHECK_DIFF(diff, eDestinationFrameChanged, other, destinationFrame);
876 if (other.what & eProducerDisconnect) diff |= eProducerDisconnect;
877 CHECK_DIFF(diff, eDropInputModeChanged, other, dropInputMode);
878 CHECK_DIFF(diff, eColorChanged, other, color.rgb);
879 CHECK_DIFF(diff, eColorSpaceAgnosticChanged, other, colorSpaceAgnostic);
880 CHECK_DIFF(diff, eDimmingEnabledChanged, other, dimmingEnabled);
Patrick Williamsf693bcf2024-08-02 09:55:23 -0500881 if (other.what & eBufferReleaseChannelChanged) diff |= eBufferReleaseChannelChanged;
Sally Qi0abc4a52024-09-26 16:13:06 -0700882 if (other.what & eLutsChanged) diff |= eLutsChanged;
Brian Lindahl07dcd492024-10-30 11:43:23 -0600883 CHECK_DIFF(diff, ePictureProfileHandleChanged, other, pictureProfileHandle);
884 CHECK_DIFF(diff, eAppContentPriorityChanged, other, appContentPriority);
Sally Qi0abc4a52024-09-26 16:13:06 -0700885
Vishnu Nairaa799bd2022-11-16 23:09:09 +0000886 return diff;
887}
888
Vishnu Nairddf9b5c2021-03-29 18:53:41 -0700889bool layer_state_t::hasBufferChanges() const {
chaviwba4320c2021-09-15 15:20:53 -0500890 return what & layer_state_t::eBufferChanged;
Vishnu Nairddf9b5c2021-03-29 18:53:41 -0700891}
892
Ady Abraham6e8e3642021-07-08 19:44:07 -0700893bool layer_state_t::hasValidBuffer() const {
Vishnu Nair59f6d2d2022-10-05 16:59:56 -0700894 return bufferData && (bufferData->hasBuffer() || bufferData->cachedBuffer.isValid());
Ady Abraham6e8e3642021-07-08 19:44:07 -0700895}
896
chaviw308ddba2020-08-11 16:23:51 -0700897status_t layer_state_t::matrix22_t::write(Parcel& output) const {
898 SAFE_PARCEL(output.writeFloat, dsdx);
899 SAFE_PARCEL(output.writeFloat, dtdx);
900 SAFE_PARCEL(output.writeFloat, dtdy);
901 SAFE_PARCEL(output.writeFloat, dsdy);
902 return NO_ERROR;
903}
904
905status_t layer_state_t::matrix22_t::read(const Parcel& input) {
906 SAFE_PARCEL(input.readFloat, &dsdx);
907 SAFE_PARCEL(input.readFloat, &dtdx);
908 SAFE_PARCEL(input.readFloat, &dtdy);
909 SAFE_PARCEL(input.readFloat, &dsdy);
910 return NO_ERROR;
911}
912
chaviw273171b2018-12-26 11:46:30 -0800913// ------------------------------- InputWindowCommands ----------------------------------------
914
Vishnu Naire798b472020-07-23 13:52:21 -0700915bool InputWindowCommands::merge(const InputWindowCommands& other) {
916 bool changes = false;
Vishnu Naire798b472020-07-23 13:52:21 -0700917 changes |= !other.focusRequests.empty();
918 focusRequests.insert(focusRequests.end(), std::make_move_iterator(other.focusRequests.begin()),
919 std::make_move_iterator(other.focusRequests.end()));
Patrick Williams641f7f22022-06-22 19:25:35 +0000920 changes |= !other.windowInfosReportedListeners.empty();
921 windowInfosReportedListeners.insert(other.windowInfosReportedListeners.begin(),
922 other.windowInfosReportedListeners.end());
Vishnu Naire798b472020-07-23 13:52:21 -0700923 return changes;
chaviw273171b2018-12-26 11:46:30 -0800924}
925
Vishnu Nair958da932020-08-21 17:12:37 -0700926bool InputWindowCommands::empty() const {
Patrick Williams641f7f22022-06-22 19:25:35 +0000927 return focusRequests.empty() && windowInfosReportedListeners.empty();
Vishnu Nair958da932020-08-21 17:12:37 -0700928}
929
chaviw273171b2018-12-26 11:46:30 -0800930void InputWindowCommands::clear() {
Vishnu Naire798b472020-07-23 13:52:21 -0700931 focusRequests.clear();
Patrick Williams641f7f22022-06-22 19:25:35 +0000932 windowInfosReportedListeners.clear();
chaviw273171b2018-12-26 11:46:30 -0800933}
934
chaviw308ddba2020-08-11 16:23:51 -0700935status_t InputWindowCommands::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700936 SAFE_PARCEL(output.writeParcelableVector, focusRequests);
Patrick Williams641f7f22022-06-22 19:25:35 +0000937
938 SAFE_PARCEL(output.writeInt32, windowInfosReportedListeners.size());
939 for (const auto& listener : windowInfosReportedListeners) {
940 SAFE_PARCEL(output.writeStrongBinder, listener);
941 }
942
chaviw308ddba2020-08-11 16:23:51 -0700943 return NO_ERROR;
chaviw273171b2018-12-26 11:46:30 -0800944}
945
chaviw308ddba2020-08-11 16:23:51 -0700946status_t InputWindowCommands::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700947 SAFE_PARCEL(input.readParcelableVector, &focusRequests);
Patrick Williams641f7f22022-06-22 19:25:35 +0000948
949 int listenerSize = 0;
950 SAFE_PARCEL_READ_SIZE(input.readInt32, &listenerSize, input.dataSize());
951 windowInfosReportedListeners.reserve(listenerSize);
952 for (int i = 0; i < listenerSize; i++) {
953 sp<gui::IWindowInfosReportedListener> listener;
954 SAFE_PARCEL(input.readStrongBinder, &listener);
955 windowInfosReportedListeners.insert(listener);
956 }
957
chaviw308ddba2020-08-11 16:23:51 -0700958 return NO_ERROR;
chaviw273171b2018-12-26 11:46:30 -0800959}
960
chaviw618c42d2020-07-24 15:25:08 -0700961// ----------------------------------------------------------------------------
962
chaviw8dd181f2022-01-05 18:36:46 -0600963ReleaseCallbackId BufferData::generateReleaseCallbackId() const {
chaviwdcba9e02022-03-21 17:54:23 -0500964 uint64_t bufferId;
965 if (buffer) {
966 bufferId = buffer->getId();
967 } else {
968 bufferId = cachedBuffer.id;
969 }
970 return {bufferId, frameNumber};
chaviw8dd181f2022-01-05 18:36:46 -0600971}
972
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800973status_t BufferData::writeToParcel(Parcel* output) const {
974 SAFE_PARCEL(output->writeInt32, flags.get());
chaviwba4320c2021-09-15 15:20:53 -0500975
976 if (buffer) {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800977 SAFE_PARCEL(output->writeBool, true);
978 SAFE_PARCEL(output->write, *buffer);
chaviwba4320c2021-09-15 15:20:53 -0500979 } else {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800980 SAFE_PARCEL(output->writeBool, false);
chaviwba4320c2021-09-15 15:20:53 -0500981 }
982
983 if (acquireFence) {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800984 SAFE_PARCEL(output->writeBool, true);
985 SAFE_PARCEL(output->write, *acquireFence);
chaviwba4320c2021-09-15 15:20:53 -0500986 } else {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800987 SAFE_PARCEL(output->writeBool, false);
chaviwba4320c2021-09-15 15:20:53 -0500988 }
989
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800990 SAFE_PARCEL(output->writeUint64, frameNumber);
991 SAFE_PARCEL(output->writeStrongBinder, IInterface::asBinder(releaseBufferListener));
992 SAFE_PARCEL(output->writeStrongBinder, releaseBufferEndpoint);
chaviwba4320c2021-09-15 15:20:53 -0500993
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800994 SAFE_PARCEL(output->writeStrongBinder, cachedBuffer.token.promote());
995 SAFE_PARCEL(output->writeUint64, cachedBuffer.id);
Robert Carr79dc06a2022-02-22 15:28:59 -0800996 SAFE_PARCEL(output->writeBool, hasBarrier);
997 SAFE_PARCEL(output->writeUint64, barrierFrameNumber);
liulijuneb489f62022-10-17 22:02:14 +0800998 SAFE_PARCEL(output->writeUint32, producerId);
Nergi Rahardi39f510f2024-05-23 15:16:54 +0900999 SAFE_PARCEL(output->writeInt64, dequeueTime);
chaviwba4320c2021-09-15 15:20:53 -05001000
1001 return NO_ERROR;
1002}
1003
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001004status_t BufferData::readFromParcel(const Parcel* input) {
chaviwba4320c2021-09-15 15:20:53 -05001005 int32_t tmpInt32;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001006 SAFE_PARCEL(input->readInt32, &tmpInt32);
Dominik Laskowski2f01d772022-03-23 16:01:29 -07001007 flags = ftl::Flags<BufferDataChange>(tmpInt32);
chaviwba4320c2021-09-15 15:20:53 -05001008
1009 bool tmpBool = false;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001010 SAFE_PARCEL(input->readBool, &tmpBool);
chaviwba4320c2021-09-15 15:20:53 -05001011 if (tmpBool) {
1012 buffer = new GraphicBuffer();
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001013 SAFE_PARCEL(input->read, *buffer);
chaviwba4320c2021-09-15 15:20:53 -05001014 }
1015
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001016 SAFE_PARCEL(input->readBool, &tmpBool);
chaviwba4320c2021-09-15 15:20:53 -05001017 if (tmpBool) {
1018 acquireFence = new Fence();
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001019 SAFE_PARCEL(input->read, *acquireFence);
chaviwba4320c2021-09-15 15:20:53 -05001020 }
1021
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001022 SAFE_PARCEL(input->readUint64, &frameNumber);
chaviwba4320c2021-09-15 15:20:53 -05001023
1024 sp<IBinder> tmpBinder = nullptr;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001025 SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder);
chaviwba4320c2021-09-15 15:20:53 -05001026 if (tmpBinder) {
1027 releaseBufferListener = checked_interface_cast<ITransactionCompletedListener>(tmpBinder);
1028 }
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001029 SAFE_PARCEL(input->readNullableStrongBinder, &releaseBufferEndpoint);
chaviwba4320c2021-09-15 15:20:53 -05001030
1031 tmpBinder = nullptr;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001032 SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder);
chaviwba4320c2021-09-15 15:20:53 -05001033 cachedBuffer.token = tmpBinder;
Vishnu Nair9f0835e2022-01-07 09:33:19 -08001034 SAFE_PARCEL(input->readUint64, &cachedBuffer.id);
chaviwba4320c2021-09-15 15:20:53 -05001035
Robert Carr79dc06a2022-02-22 15:28:59 -08001036 SAFE_PARCEL(input->readBool, &hasBarrier);
1037 SAFE_PARCEL(input->readUint64, &barrierFrameNumber);
liulijuneb489f62022-10-17 22:02:14 +08001038 SAFE_PARCEL(input->readUint32, &producerId);
Nergi Rahardi39f510f2024-05-23 15:16:54 +09001039 SAFE_PARCEL(input->readInt64, &dequeueTime);
Robert Carr79dc06a2022-02-22 15:28:59 -08001040
chaviwba4320c2021-09-15 15:20:53 -05001041 return NO_ERROR;
1042}
1043
Chavi Weingarten076acac2023-01-19 17:20:43 +00001044status_t TrustedPresentationListener::writeToParcel(Parcel* parcel) const {
1045 SAFE_PARCEL(parcel->writeStrongBinder, callbackInterface);
1046 SAFE_PARCEL(parcel->writeInt32, callbackId);
1047 return NO_ERROR;
1048}
1049
1050status_t TrustedPresentationListener::readFromParcel(const Parcel* parcel) {
1051 sp<IBinder> tmpBinder = nullptr;
1052 SAFE_PARCEL(parcel->readNullableStrongBinder, &tmpBinder);
1053 if (tmpBinder) {
1054 callbackInterface = checked_interface_cast<ITransactionCompletedListener>(tmpBinder);
1055 }
1056 SAFE_PARCEL(parcel->readInt32, &callbackId);
1057 return NO_ERROR;
1058}
1059
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001060}; // namespace android