blob: 27d86bb4e27b18574ee042476956b7255652c3a2 [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
Ady Abrahamdd5bfa92021-01-07 17:56:08 -080019#include <apex/window.h>
Garfield Tan8a3083e2018-12-03 13:21:07 -080020#include <inttypes.h>
21
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>
Andy McFadden2adaf042012-12-18 09:49:45 -080024#include <gui/IGraphicBufferProducer.h>
Pablo Gamito11dcc222020-09-12 15:49:39 +000025#include <gui/ISurfaceComposerClient.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070026#include <gui/LayerState.h>
Marin Shalamanov3b1f7bc2021-03-16 15:51:53 +010027#include <private/gui/ParcelUtils.h>
Pablo Gamito11dcc222020-09-12 15:49:39 +000028#include <utils/Errors.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080029
Steven Thomas62a4cf82020-01-31 12:04:03 -080030#include <cmath>
31
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080032namespace android {
33
chaviw98318de2021-05-19 16:45:23 -050034using gui::FocusRequest;
35using gui::WindowInfoHandle;
36
Pablo Gamito11dcc222020-09-12 15:49:39 +000037layer_state_t::layer_state_t()
38 : what(0),
39 x(0),
40 y(0),
41 z(0),
42 w(0),
43 h(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000044 alpha(0),
45 flags(0),
46 mask(0),
47 reserved(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000048 cornerRadius(0.0f),
49 backgroundBlurRadius(0),
Pablo Gamito11dcc222020-09-12 15:49:39 +000050 transform(0),
51 transformToDisplayInverse(false),
52 crop(Rect::INVALID_RECT),
Pablo Gamito11dcc222020-09-12 15:49:39 +000053 dataspace(ui::Dataspace::UNKNOWN),
54 surfaceDamageRegion(),
55 api(-1),
56 colorTransform(mat4()),
57 bgColorAlpha(0),
58 bgColorDataspace(ui::Dataspace::UNKNOWN),
59 colorSpaceAgnostic(false),
60 shadowRadius(0.0f),
61 frameRateSelectionPriority(-1),
62 frameRate(0.0f),
63 frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
Marin Shalamanovc5986772021-03-16 16:09:49 +010064 changeFrameRateStrategy(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS),
Pablo Gamito11dcc222020-09-12 15:49:39 +000065 fixedTransformHint(ui::Transform::ROT_INVALID),
Vishnu Nair1506b182021-02-22 14:35:15 -080066 autoRefresh(false),
Winson Chunga30f7c92021-06-29 15:42:56 -070067 isTrustedOverlay(false),
Vishnu Nair6bdec7d2021-05-10 15:01:13 -070068 bufferCrop(Rect::INVALID_RECT),
69 destinationFrame(Rect::INVALID_RECT),
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -070070 dropInputMode(gui::DropInputMode::NONE) {
Pablo Gamito11dcc222020-09-12 15:49:39 +000071 matrix.dsdx = matrix.dtdy = 1.0f;
72 matrix.dsdy = matrix.dtdx = 0.0f;
73 hdrMetadata.validTypes = 0;
74}
75
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080076status_t layer_state_t::write(Parcel& output) const
77{
chaviw308ddba2020-08-11 16:23:51 -070078 SAFE_PARCEL(output.writeStrongBinder, surface);
Pablo Gamitodbc31672020-09-01 18:28:58 +000079 SAFE_PARCEL(output.writeInt32, layerId);
chaviw308ddba2020-08-11 16:23:51 -070080 SAFE_PARCEL(output.writeUint64, what);
81 SAFE_PARCEL(output.writeFloat, x);
82 SAFE_PARCEL(output.writeFloat, y);
83 SAFE_PARCEL(output.writeInt32, z);
84 SAFE_PARCEL(output.writeUint32, w);
85 SAFE_PARCEL(output.writeUint32, h);
Dominik Laskowski29fa1462021-04-27 15:51:50 -070086 SAFE_PARCEL(output.writeUint32, layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -070087 SAFE_PARCEL(output.writeFloat, alpha);
88 SAFE_PARCEL(output.writeUint32, flags);
89 SAFE_PARCEL(output.writeUint32, mask);
90 SAFE_PARCEL(matrix.write, output);
chaviw25714502021-02-11 10:01:08 -080091 SAFE_PARCEL(output.write, crop);
Pablo Gamito11dcc222020-09-12 15:49:39 +000092 SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, reparentSurfaceControl);
Pablo Gamito11dcc222020-09-12 15:49:39 +000093 SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, relativeLayerSurfaceControl);
94 SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, parentSurfaceControlForChild);
chaviw308ddba2020-08-11 16:23:51 -070095 SAFE_PARCEL(output.writeFloat, color.r);
96 SAFE_PARCEL(output.writeFloat, color.g);
97 SAFE_PARCEL(output.writeFloat, color.b);
chaviw98318de2021-05-19 16:45:23 -050098 SAFE_PARCEL(windowInfoHandle->writeToParcel, &output);
chaviw308ddba2020-08-11 16:23:51 -070099 SAFE_PARCEL(output.write, transparentRegion);
100 SAFE_PARCEL(output.writeUint32, transform);
101 SAFE_PARCEL(output.writeBool, transformToDisplayInverse);
chaviw308ddba2020-08-11 16:23:51 -0700102
chaviw308ddba2020-08-11 16:23:51 -0700103 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dataspace));
104 SAFE_PARCEL(output.write, hdrMetadata);
105 SAFE_PARCEL(output.write, surfaceDamageRegion);
106 SAFE_PARCEL(output.writeInt32, api);
107
Marissa Wall61c58622018-07-18 10:12:20 -0700108 if (sidebandStream) {
chaviw308ddba2020-08-11 16:23:51 -0700109 SAFE_PARCEL(output.writeBool, true);
110 SAFE_PARCEL(output.writeNativeHandle, sidebandStream->handle());
Marissa Wall61c58622018-07-18 10:12:20 -0700111 } else {
chaviw308ddba2020-08-11 16:23:51 -0700112 SAFE_PARCEL(output.writeBool, false);
Marissa Wall61c58622018-07-18 10:12:20 -0700113 }
114
chaviw308ddba2020-08-11 16:23:51 -0700115 SAFE_PARCEL(output.write, colorTransform.asArray(), 16 * sizeof(float));
116 SAFE_PARCEL(output.writeFloat, cornerRadius);
117 SAFE_PARCEL(output.writeUint32, backgroundBlurRadius);
chaviw308ddba2020-08-11 16:23:51 -0700118 SAFE_PARCEL(output.writeParcelable, metadata);
119 SAFE_PARCEL(output.writeFloat, bgColorAlpha);
120 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(bgColorDataspace));
121 SAFE_PARCEL(output.writeBool, colorSpaceAgnostic);
122 SAFE_PARCEL(output.writeVectorSize, listeners);
Valerie Hau9dab9732019-08-20 09:29:25 -0700123
124 for (auto listener : listeners) {
chaviw308ddba2020-08-11 16:23:51 -0700125 SAFE_PARCEL(output.writeStrongBinder, listener.transactionCompletedListener);
Vishnu Nairfc46c1e2021-04-21 08:31:32 -0700126 SAFE_PARCEL(output.writeParcelableVector, listener.callbackIds);
Valerie Hau9dab9732019-08-20 09:29:25 -0700127 }
chaviw308ddba2020-08-11 16:23:51 -0700128 SAFE_PARCEL(output.writeFloat, shadowRadius);
129 SAFE_PARCEL(output.writeInt32, frameRateSelectionPriority);
130 SAFE_PARCEL(output.writeFloat, frameRate);
131 SAFE_PARCEL(output.writeByte, frameRateCompatibility);
Marin Shalamanovc5986772021-03-16 16:09:49 +0100132 SAFE_PARCEL(output.writeByte, changeFrameRateStrategy);
chaviw308ddba2020-08-11 16:23:51 -0700133 SAFE_PARCEL(output.writeUint32, fixedTransformHint);
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800134 SAFE_PARCEL(output.writeBool, autoRefresh);
Lucas Dupinc3800b82020-10-02 16:24:48 -0700135
136 SAFE_PARCEL(output.writeUint32, blurRegions.size());
137 for (auto region : blurRegions) {
138 SAFE_PARCEL(output.writeUint32, region.blurRadius);
139 SAFE_PARCEL(output.writeFloat, region.cornerRadiusTL);
140 SAFE_PARCEL(output.writeFloat, region.cornerRadiusTR);
141 SAFE_PARCEL(output.writeFloat, region.cornerRadiusBL);
142 SAFE_PARCEL(output.writeFloat, region.cornerRadiusBR);
143 SAFE_PARCEL(output.writeFloat, region.alpha);
144 SAFE_PARCEL(output.writeInt32, region.left);
145 SAFE_PARCEL(output.writeInt32, region.top);
146 SAFE_PARCEL(output.writeInt32, region.right);
147 SAFE_PARCEL(output.writeInt32, region.bottom);
148 }
John Reckcdb4ed72021-02-04 13:39:33 -0500149
150 SAFE_PARCEL(output.write, stretchEffect);
chaviwf3f40fe2021-04-27 15:54:02 -0500151 SAFE_PARCEL(output.write, bufferCrop);
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700152 SAFE_PARCEL(output.write, destinationFrame);
Winson Chunga30f7c92021-06-29 15:42:56 -0700153 SAFE_PARCEL(output.writeBool, isTrustedOverlay);
John Reckcdb4ed72021-02-04 13:39:33 -0500154
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700155 SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode));
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800156 SAFE_PARCEL(output.writeNullableParcelable,
157 bufferData ? std::make_optional<BufferData>(*bufferData) : std::nullopt);
Mathias Agopianac9fa422013-02-11 16:40:36 -0800158 return NO_ERROR;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800159}
160
161status_t layer_state_t::read(const Parcel& input)
162{
chaviw308ddba2020-08-11 16:23:51 -0700163 SAFE_PARCEL(input.readNullableStrongBinder, &surface);
Pablo Gamitodbc31672020-09-01 18:28:58 +0000164 SAFE_PARCEL(input.readInt32, &layerId);
chaviw308ddba2020-08-11 16:23:51 -0700165 SAFE_PARCEL(input.readUint64, &what);
166 SAFE_PARCEL(input.readFloat, &x);
167 SAFE_PARCEL(input.readFloat, &y);
168 SAFE_PARCEL(input.readInt32, &z);
169 SAFE_PARCEL(input.readUint32, &w);
170 SAFE_PARCEL(input.readUint32, &h);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700171 SAFE_PARCEL(input.readUint32, &layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700172 SAFE_PARCEL(input.readFloat, &alpha);
Robert Carr2c358bf2018-08-08 15:58:15 -0700173
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800174 SAFE_PARCEL(input.readUint32, &flags);
chaviw308ddba2020-08-11 16:23:51 -0700175
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800176 SAFE_PARCEL(input.readUint32, &mask);
chaviw308ddba2020-08-11 16:23:51 -0700177
178 SAFE_PARCEL(matrix.read, input);
chaviw25714502021-02-11 10:01:08 -0800179 SAFE_PARCEL(input.read, crop);
Pablo Gamito11dcc222020-09-12 15:49:39 +0000180 SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &reparentSurfaceControl);
chaviw308ddba2020-08-11 16:23:51 -0700181
Pablo Gamito11dcc222020-09-12 15:49:39 +0000182 SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &relativeLayerSurfaceControl);
183 SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &parentSurfaceControlForChild);
184
chaviw308ddba2020-08-11 16:23:51 -0700185 float tmpFloat = 0;
chaviw308ddba2020-08-11 16:23:51 -0700186 SAFE_PARCEL(input.readFloat, &tmpFloat);
187 color.r = tmpFloat;
188 SAFE_PARCEL(input.readFloat, &tmpFloat);
189 color.g = tmpFloat;
190 SAFE_PARCEL(input.readFloat, &tmpFloat);
191 color.b = tmpFloat;
chaviw98318de2021-05-19 16:45:23 -0500192 SAFE_PARCEL(windowInfoHandle->readFromParcel, &input);
Robert Carr2c358bf2018-08-08 15:58:15 -0700193
chaviw308ddba2020-08-11 16:23:51 -0700194 SAFE_PARCEL(input.read, transparentRegion);
195 SAFE_PARCEL(input.readUint32, &transform);
196 SAFE_PARCEL(input.readBool, &transformToDisplayInverse);
chaviw308ddba2020-08-11 16:23:51 -0700197
Vishnu Nairf6eddb62021-01-27 22:02:11 -0800198 uint32_t tmpUint32 = 0;
chaviw308ddba2020-08-11 16:23:51 -0700199 SAFE_PARCEL(input.readUint32, &tmpUint32);
200 dataspace = static_cast<ui::Dataspace>(tmpUint32);
201
202 SAFE_PARCEL(input.read, hdrMetadata);
203 SAFE_PARCEL(input.read, surfaceDamageRegion);
204 SAFE_PARCEL(input.readInt32, &api);
chaviwba4320c2021-09-15 15:20:53 -0500205
206 bool tmpBool = false;
chaviw308ddba2020-08-11 16:23:51 -0700207 SAFE_PARCEL(input.readBool, &tmpBool);
208 if (tmpBool) {
Marissa Wall61c58622018-07-18 10:12:20 -0700209 sidebandStream = NativeHandle::create(input.readNativeHandle(), true);
210 }
211
chaviw308ddba2020-08-11 16:23:51 -0700212 SAFE_PARCEL(input.read, &colorTransform, 16 * sizeof(float));
213 SAFE_PARCEL(input.readFloat, &cornerRadius);
214 SAFE_PARCEL(input.readUint32, &backgroundBlurRadius);
chaviw308ddba2020-08-11 16:23:51 -0700215 SAFE_PARCEL(input.readParcelable, &metadata);
Marissa Wallebc2c052019-01-16 19:16:55 -0800216
chaviw308ddba2020-08-11 16:23:51 -0700217 SAFE_PARCEL(input.readFloat, &bgColorAlpha);
218 SAFE_PARCEL(input.readUint32, &tmpUint32);
219 bgColorDataspace = static_cast<ui::Dataspace>(tmpUint32);
220 SAFE_PARCEL(input.readBool, &colorSpaceAgnostic);
Valerie Haued54efa2019-01-11 20:03:14 -0800221
chaviw308ddba2020-08-11 16:23:51 -0700222 int32_t numListeners = 0;
223 SAFE_PARCEL_READ_SIZE(input.readInt32, &numListeners, input.dataSize());
Valerie Hau9dab9732019-08-20 09:29:25 -0700224 listeners.clear();
225 for (int i = 0; i < numListeners; i++) {
chaviw308ddba2020-08-11 16:23:51 -0700226 sp<IBinder> listener;
Valerie Hau9dab9732019-08-20 09:29:25 -0700227 std::vector<CallbackId> callbackIds;
chaviw308ddba2020-08-11 16:23:51 -0700228 SAFE_PARCEL(input.readNullableStrongBinder, &listener);
Vishnu Nairfc46c1e2021-04-21 08:31:32 -0700229 SAFE_PARCEL(input.readParcelableVector, &callbackIds);
Valerie Hau9dab9732019-08-20 09:29:25 -0700230 listeners.emplace_back(listener, callbackIds);
231 }
chaviw308ddba2020-08-11 16:23:51 -0700232 SAFE_PARCEL(input.readFloat, &shadowRadius);
233 SAFE_PARCEL(input.readInt32, &frameRateSelectionPriority);
234 SAFE_PARCEL(input.readFloat, &frameRate);
235 SAFE_PARCEL(input.readByte, &frameRateCompatibility);
Marin Shalamanovc5986772021-03-16 16:09:49 +0100236 SAFE_PARCEL(input.readByte, &changeFrameRateStrategy);
chaviw308ddba2020-08-11 16:23:51 -0700237 SAFE_PARCEL(input.readUint32, &tmpUint32);
238 fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32);
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800239 SAFE_PARCEL(input.readBool, &autoRefresh);
Lucas Dupinc3800b82020-10-02 16:24:48 -0700240
241 uint32_t numRegions = 0;
242 SAFE_PARCEL(input.readUint32, &numRegions);
243 blurRegions.clear();
244 for (uint32_t i = 0; i < numRegions; i++) {
245 BlurRegion region;
246 SAFE_PARCEL(input.readUint32, &region.blurRadius);
247 SAFE_PARCEL(input.readFloat, &region.cornerRadiusTL);
248 SAFE_PARCEL(input.readFloat, &region.cornerRadiusTR);
249 SAFE_PARCEL(input.readFloat, &region.cornerRadiusBL);
250 SAFE_PARCEL(input.readFloat, &region.cornerRadiusBR);
251 SAFE_PARCEL(input.readFloat, &region.alpha);
252 SAFE_PARCEL(input.readInt32, &region.left);
253 SAFE_PARCEL(input.readInt32, &region.top);
254 SAFE_PARCEL(input.readInt32, &region.right);
255 SAFE_PARCEL(input.readInt32, &region.bottom);
256 blurRegions.push_back(region);
257 }
John Reckcdb4ed72021-02-04 13:39:33 -0500258
259 SAFE_PARCEL(input.read, stretchEffect);
chaviwf3f40fe2021-04-27 15:54:02 -0500260 SAFE_PARCEL(input.read, bufferCrop);
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700261 SAFE_PARCEL(input.read, destinationFrame);
Winson Chunga30f7c92021-06-29 15:42:56 -0700262 SAFE_PARCEL(input.readBool, &isTrustedOverlay);
John Reckcdb4ed72021-02-04 13:39:33 -0500263
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700264 uint32_t mode;
265 SAFE_PARCEL(input.readUint32, &mode);
266 dropInputMode = static_cast<gui::DropInputMode>(mode);
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800267 std::optional<BufferData> tmpBufferData;
268 SAFE_PARCEL(input.readParcelable, &tmpBufferData);
269 bufferData = tmpBufferData ? std::make_shared<BufferData>(*tmpBufferData) : nullptr;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800270 return NO_ERROR;
271}
272
Mathias Agopian698c0872011-06-28 19:09:31 -0700273status_t ComposerState::write(Parcel& output) const {
Mathias Agopian698c0872011-06-28 19:09:31 -0700274 return state.write(output);
275}
276
277status_t ComposerState::read(const Parcel& input) {
Mathias Agopian698c0872011-06-28 19:09:31 -0700278 return state.read(input);
279}
280
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700281DisplayState::DisplayState() = default;
Pablo Ceballos60d69222015-08-07 14:47:20 -0700282
Mathias Agopian8b33f032012-07-24 20:43:54 -0700283status_t DisplayState::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700284 SAFE_PARCEL(output.writeStrongBinder, token);
285 SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(surface));
286 SAFE_PARCEL(output.writeUint32, what);
Evan Rosky2239b372021-05-20 13:43:47 -0700287 SAFE_PARCEL(output.writeUint32, flags);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700288 SAFE_PARCEL(output.writeUint32, layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700289 SAFE_PARCEL(output.writeUint32, toRotationInt(orientation));
290 SAFE_PARCEL(output.write, layerStackSpaceRect);
291 SAFE_PARCEL(output.write, orientedDisplaySpaceRect);
292 SAFE_PARCEL(output.writeUint32, width);
293 SAFE_PARCEL(output.writeUint32, height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700294 return NO_ERROR;
295}
296
297status_t DisplayState::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700298 SAFE_PARCEL(input.readStrongBinder, &token);
299 sp<IBinder> tmpBinder;
300 SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder);
301 surface = interface_cast<IGraphicBufferProducer>(tmpBinder);
302
303 SAFE_PARCEL(input.readUint32, &what);
Evan Rosky2239b372021-05-20 13:43:47 -0700304 SAFE_PARCEL(input.readUint32, &flags);
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700305 SAFE_PARCEL(input.readUint32, &layerStack.id);
chaviw308ddba2020-08-11 16:23:51 -0700306 uint32_t tmpUint = 0;
307 SAFE_PARCEL(input.readUint32, &tmpUint);
308 orientation = ui::toRotation(tmpUint);
309
310 SAFE_PARCEL(input.read, layerStackSpaceRect);
311 SAFE_PARCEL(input.read, orientedDisplaySpaceRect);
312 SAFE_PARCEL(input.readUint32, &width);
313 SAFE_PARCEL(input.readUint32, &height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700314 return NO_ERROR;
315}
316
Robert Carr2c5f6d22017-09-26 12:30:35 -0700317void DisplayState::merge(const DisplayState& other) {
318 if (other.what & eSurfaceChanged) {
319 what |= eSurfaceChanged;
320 surface = other.surface;
321 }
322 if (other.what & eLayerStackChanged) {
323 what |= eLayerStackChanged;
324 layerStack = other.layerStack;
325 }
Evan Rosky2239b372021-05-20 13:43:47 -0700326 if (other.what & eFlagsChanged) {
327 what |= eFlagsChanged;
328 flags = other.flags;
329 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700330 if (other.what & eDisplayProjectionChanged) {
331 what |= eDisplayProjectionChanged;
332 orientation = other.orientation;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200333 layerStackSpaceRect = other.layerStackSpaceRect;
334 orientedDisplaySpaceRect = other.orientedDisplaySpaceRect;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700335 }
336 if (other.what & eDisplaySizeChanged) {
337 what |= eDisplaySizeChanged;
338 width = other.width;
339 height = other.height;
340 }
341}
342
343void layer_state_t::merge(const layer_state_t& other) {
344 if (other.what & ePositionChanged) {
345 what |= ePositionChanged;
346 x = other.x;
347 y = other.y;
348 }
349 if (other.what & eLayerChanged) {
350 what |= eLayerChanged;
chaviw32377582019-05-13 11:15:19 -0700351 what &= ~eRelativeLayerChanged;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700352 z = other.z;
353 }
354 if (other.what & eSizeChanged) {
355 what |= eSizeChanged;
356 w = other.w;
357 h = other.h;
358 }
359 if (other.what & eAlphaChanged) {
360 what |= eAlphaChanged;
361 alpha = other.alpha;
362 }
363 if (other.what & eMatrixChanged) {
364 what |= eMatrixChanged;
365 matrix = other.matrix;
366 }
367 if (other.what & eTransparentRegionChanged) {
368 what |= eTransparentRegionChanged;
369 transparentRegion = other.transparentRegion;
370 }
371 if (other.what & eFlagsChanged) {
372 what |= eFlagsChanged;
Vishnu Nair996bc422019-07-16 14:15:33 -0700373 flags &= ~other.mask;
374 flags |= (other.flags & other.mask);
375 mask |= other.mask;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700376 }
377 if (other.what & eLayerStackChanged) {
378 what |= eLayerStackChanged;
379 layerStack = other.layerStack;
380 }
Lucas Dupin1b6531c2018-07-05 17:18:21 -0700381 if (other.what & eCornerRadiusChanged) {
382 what |= eCornerRadiusChanged;
383 cornerRadius = other.cornerRadius;
384 }
Lucas Dupin19c8f0e2019-11-25 17:55:44 -0800385 if (other.what & eBackgroundBlurRadiusChanged) {
386 what |= eBackgroundBlurRadiusChanged;
387 backgroundBlurRadius = other.backgroundBlurRadius;
388 }
Lucas Dupinc3800b82020-10-02 16:24:48 -0700389 if (other.what & eBlurRegionsChanged) {
390 what |= eBlurRegionsChanged;
391 blurRegions = other.blurRegions;
392 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700393 if (other.what & eRelativeLayerChanged) {
394 what |= eRelativeLayerChanged;
chaviw32377582019-05-13 11:15:19 -0700395 what &= ~eLayerChanged;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700396 z = other.z;
Pablo Gamito11dcc222020-09-12 15:49:39 +0000397 relativeLayerSurfaceControl = other.relativeLayerSurfaceControl;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700398 }
399 if (other.what & eReparent) {
400 what |= eReparent;
Pablo Gamito11dcc222020-09-12 15:49:39 +0000401 parentSurfaceControlForChild = other.parentSurfaceControlForChild;
Robert Carr2c5f6d22017-09-26 12:30:35 -0700402 }
chaviwca27f252018-02-06 16:46:39 -0800403 if (other.what & eDestroySurface) {
404 what |= eDestroySurface;
405 }
Marissa Wall61c58622018-07-18 10:12:20 -0700406 if (other.what & eTransformChanged) {
407 what |= eTransformChanged;
408 transform = other.transform;
409 }
410 if (other.what & eTransformToDisplayInverseChanged) {
411 what |= eTransformToDisplayInverseChanged;
412 transformToDisplayInverse = other.transformToDisplayInverse;
413 }
414 if (other.what & eCropChanged) {
415 what |= eCropChanged;
416 crop = other.crop;
417 }
418 if (other.what & eBufferChanged) {
419 what |= eBufferChanged;
chaviwba4320c2021-09-15 15:20:53 -0500420 bufferData = other.bufferData;
Marissa Wall61c58622018-07-18 10:12:20 -0700421 }
422 if (other.what & eDataspaceChanged) {
423 what |= eDataspaceChanged;
424 dataspace = other.dataspace;
425 }
426 if (other.what & eHdrMetadataChanged) {
427 what |= eHdrMetadataChanged;
428 hdrMetadata = other.hdrMetadata;
429 }
430 if (other.what & eSurfaceDamageRegionChanged) {
431 what |= eSurfaceDamageRegionChanged;
432 surfaceDamageRegion = other.surfaceDamageRegion;
433 }
434 if (other.what & eApiChanged) {
435 what |= eApiChanged;
436 api = other.api;
437 }
438 if (other.what & eSidebandStreamChanged) {
439 what |= eSidebandStreamChanged;
440 sidebandStream = other.sidebandStream;
441 }
Peiyong Lind3788632018-09-18 16:01:31 -0700442 if (other.what & eColorTransformChanged) {
443 what |= eColorTransformChanged;
444 colorTransform = other.colorTransform;
445 }
Marissa Wall3dad52d2019-03-22 14:03:19 -0700446 if (other.what & eHasListenerCallbacksChanged) {
447 what |= eHasListenerCallbacksChanged;
Marissa Wallc837b5e2018-10-12 10:04:44 -0700448 }
Robert Carr2c358bf2018-08-08 15:58:15 -0700449 if (other.what & eInputInfoChanged) {
450 what |= eInputInfoChanged;
chaviw98318de2021-05-19 16:45:23 -0500451 windowInfoHandle = new WindowInfoHandle(*other.windowInfoHandle);
Robert Carr2c358bf2018-08-08 15:58:15 -0700452 }
Valerie Haudd0b7572019-01-29 14:59:27 -0800453 if (other.what & eBackgroundColorChanged) {
454 what |= eBackgroundColorChanged;
455 color = other.color;
456 bgColorAlpha = other.bgColorAlpha;
457 bgColorDataspace = other.bgColorDataspace;
Valerie Haued54efa2019-01-11 20:03:14 -0800458 }
Evan Rosky1f6d6d52018-12-06 10:47:26 -0800459 if (other.what & eMetadataChanged) {
460 what |= eMetadataChanged;
461 metadata.merge(other.metadata);
462 }
Vishnu Nairc97b8db2019-10-29 18:19:35 -0700463 if (other.what & eShadowRadiusChanged) {
464 what |= eShadowRadiusChanged;
465 shadowRadius = other.shadowRadius;
466 }
Ana Krulecc84d09b2019-11-02 23:10:29 +0100467 if (other.what & eFrameRateSelectionPriority) {
468 what |= eFrameRateSelectionPriority;
469 frameRateSelectionPriority = other.frameRateSelectionPriority;
470 }
Steven Thomas3172e202020-01-06 19:25:30 -0800471 if (other.what & eFrameRateChanged) {
472 what |= eFrameRateChanged;
473 frameRate = other.frameRate;
Steven Thomas62a4cf82020-01-31 12:04:03 -0800474 frameRateCompatibility = other.frameRateCompatibility;
Marin Shalamanovc5986772021-03-16 16:09:49 +0100475 changeFrameRateStrategy = other.changeFrameRateStrategy;
Steven Thomas3172e202020-01-06 19:25:30 -0800476 }
Vishnu Nair6213bd92020-05-08 17:42:25 -0700477 if (other.what & eFixedTransformHintChanged) {
478 what |= eFixedTransformHintChanged;
479 fixedTransformHint = other.fixedTransformHint;
480 }
Vishnu Naircf26a0a2020-11-13 12:56:20 -0800481 if (other.what & eAutoRefreshChanged) {
482 what |= eAutoRefreshChanged;
483 autoRefresh = other.autoRefresh;
484 }
Winson Chunga30f7c92021-06-29 15:42:56 -0700485 if (other.what & eTrustedOverlayChanged) {
486 what |= eTrustedOverlayChanged;
487 isTrustedOverlay = other.isTrustedOverlay;
488 }
John Reckc00c6692021-02-16 11:37:33 -0500489 if (other.what & eStretchChanged) {
490 what |= eStretchChanged;
491 stretchEffect = other.stretchEffect;
492 }
chaviwf3f40fe2021-04-27 15:54:02 -0500493 if (other.what & eBufferCropChanged) {
494 what |= eBufferCropChanged;
495 bufferCrop = other.bufferCrop;
496 }
Vishnu Nair6bdec7d2021-05-10 15:01:13 -0700497 if (other.what & eDestinationFrameChanged) {
498 what |= eDestinationFrameChanged;
499 destinationFrame = other.destinationFrame;
500 }
Vishnu Nair0e816872021-07-14 10:53:04 -0700501 if (other.what & eProducerDisconnect) {
502 what |= eProducerDisconnect;
503 }
Vishnu Nair9cf4a4d2021-09-17 12:16:08 -0700504 if (other.what & eDropInputModeChanged) {
505 what |= eDropInputModeChanged;
506 dropInputMode = other.dropInputMode;
507 }
chaviw4c36cd82021-11-18 10:37:33 -0600508 if (other.what & eColorChanged) {
509 what |= eColorChanged;
510 color = other.color;
511 }
Vishnu Nair217d8e62018-09-12 16:34:49 -0700512 if ((other.what & what) != other.what) {
513 ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
Vishnu Nair0e816872021-07-14 10:53:04 -0700514 "other.what=0x%" PRIX64 " what=0x%" PRIX64 " unmerged flags=0x%" PRIX64,
515 other.what, what, (other.what & what) ^ other.what);
Robert Carrd314f162018-08-15 13:12:42 -0700516 }
Robert Carr2c5f6d22017-09-26 12:30:35 -0700517}
Mathias Agopian8b33f032012-07-24 20:43:54 -0700518
Vishnu Nairddf9b5c2021-03-29 18:53:41 -0700519bool layer_state_t::hasBufferChanges() const {
chaviwba4320c2021-09-15 15:20:53 -0500520 return what & layer_state_t::eBufferChanged;
Vishnu Nairddf9b5c2021-03-29 18:53:41 -0700521}
522
Ady Abraham6e8e3642021-07-08 19:44:07 -0700523bool layer_state_t::hasValidBuffer() const {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800524 return bufferData && (bufferData->buffer || bufferData->cachedBuffer.isValid());
Ady Abraham6e8e3642021-07-08 19:44:07 -0700525}
526
chaviw308ddba2020-08-11 16:23:51 -0700527status_t layer_state_t::matrix22_t::write(Parcel& output) const {
528 SAFE_PARCEL(output.writeFloat, dsdx);
529 SAFE_PARCEL(output.writeFloat, dtdx);
530 SAFE_PARCEL(output.writeFloat, dtdy);
531 SAFE_PARCEL(output.writeFloat, dsdy);
532 return NO_ERROR;
533}
534
535status_t layer_state_t::matrix22_t::read(const Parcel& input) {
536 SAFE_PARCEL(input.readFloat, &dsdx);
537 SAFE_PARCEL(input.readFloat, &dtdx);
538 SAFE_PARCEL(input.readFloat, &dtdy);
539 SAFE_PARCEL(input.readFloat, &dsdy);
540 return NO_ERROR;
541}
542
chaviw273171b2018-12-26 11:46:30 -0800543// ------------------------------- InputWindowCommands ----------------------------------------
544
Vishnu Naire798b472020-07-23 13:52:21 -0700545bool InputWindowCommands::merge(const InputWindowCommands& other) {
546 bool changes = false;
Vishnu Naire798b472020-07-23 13:52:21 -0700547 changes |= !other.focusRequests.empty();
548 focusRequests.insert(focusRequests.end(), std::make_move_iterator(other.focusRequests.begin()),
549 std::make_move_iterator(other.focusRequests.end()));
Vishnu Naire798b472020-07-23 13:52:21 -0700550 changes |= other.syncInputWindows && !syncInputWindows;
chaviwa911b102019-02-14 10:18:33 -0800551 syncInputWindows |= other.syncInputWindows;
Vishnu Naire798b472020-07-23 13:52:21 -0700552 return changes;
chaviw273171b2018-12-26 11:46:30 -0800553}
554
Vishnu Nair958da932020-08-21 17:12:37 -0700555bool InputWindowCommands::empty() const {
Vishnu Nair03ccbd62021-12-01 17:21:16 -0800556 return focusRequests.empty() && !syncInputWindows;
Vishnu Nair958da932020-08-21 17:12:37 -0700557}
558
chaviw273171b2018-12-26 11:46:30 -0800559void InputWindowCommands::clear() {
Vishnu Naire798b472020-07-23 13:52:21 -0700560 focusRequests.clear();
chaviwa911b102019-02-14 10:18:33 -0800561 syncInputWindows = false;
chaviw273171b2018-12-26 11:46:30 -0800562}
563
chaviw308ddba2020-08-11 16:23:51 -0700564status_t InputWindowCommands::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700565 SAFE_PARCEL(output.writeParcelableVector, focusRequests);
chaviw308ddba2020-08-11 16:23:51 -0700566 SAFE_PARCEL(output.writeBool, syncInputWindows);
567 return NO_ERROR;
chaviw273171b2018-12-26 11:46:30 -0800568}
569
chaviw308ddba2020-08-11 16:23:51 -0700570status_t InputWindowCommands::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700571 SAFE_PARCEL(input.readParcelableVector, &focusRequests);
chaviw308ddba2020-08-11 16:23:51 -0700572 SAFE_PARCEL(input.readBool, &syncInputWindows);
573 return NO_ERROR;
chaviw273171b2018-12-26 11:46:30 -0800574}
575
Marin Shalamanovc5986772021-03-16 16:09:49 +0100576bool ValidateFrameRate(float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy,
577 const char* inFunctionName, bool privileged) {
Steven Thomas62a4cf82020-01-31 12:04:03 -0800578 const char* functionName = inFunctionName != nullptr ? inFunctionName : "call";
579 int floatClassification = std::fpclassify(frameRate);
580 if (frameRate < 0 || floatClassification == FP_INFINITE || floatClassification == FP_NAN) {
581 ALOGE("%s failed - invalid frame rate %f", functionName, frameRate);
582 return false;
583 }
584
585 if (compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT &&
Ady Abrahamdd5bfa92021-01-07 17:56:08 -0800586 compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE &&
587 (!privileged || compatibility != ANATIVEWINDOW_FRAME_RATE_EXACT)) {
588 ALOGE("%s failed - invalid compatibility value %d privileged: %s", functionName,
589 compatibility, privileged ? "yes" : "no");
Steven Thomas62a4cf82020-01-31 12:04:03 -0800590 return false;
591 }
592
Marin Shalamanovc5986772021-03-16 16:09:49 +0100593 if (changeFrameRateStrategy != ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS &&
594 changeFrameRateStrategy != ANATIVEWINDOW_CHANGE_FRAME_RATE_ALWAYS) {
595 ALOGE("%s failed - invalid change frame rate strategy value %d", functionName,
596 changeFrameRateStrategy);
597 }
598
Steven Thomas62a4cf82020-01-31 12:04:03 -0800599 return true;
600}
601
chaviw618c42d2020-07-24 15:25:08 -0700602// ----------------------------------------------------------------------------
603
604status_t CaptureArgs::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700605 SAFE_PARCEL(output.writeInt32, static_cast<int32_t>(pixelFormat));
606 SAFE_PARCEL(output.write, sourceCrop);
chaviw17ac24b2021-01-28 18:50:05 -0800607 SAFE_PARCEL(output.writeFloat, frameScaleX);
608 SAFE_PARCEL(output.writeFloat, frameScaleY);
chaviw308ddba2020-08-11 16:23:51 -0700609 SAFE_PARCEL(output.writeBool, captureSecureLayers);
610 SAFE_PARCEL(output.writeInt32, uid);
Peiyong Lincd261472020-10-06 18:05:25 -0700611 SAFE_PARCEL(output.writeInt32, static_cast<int32_t>(dataspace));
Peiyong Lin05cc0112020-10-14 16:16:37 -0700612 SAFE_PARCEL(output.writeBool, allowProtected);
chaviw17ac24b2021-01-28 18:50:05 -0800613 SAFE_PARCEL(output.writeBool, grayscale);
chaviw308ddba2020-08-11 16:23:51 -0700614 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700615}
616
617status_t CaptureArgs::read(const Parcel& input) {
Peiyong Lincd261472020-10-06 18:05:25 -0700618 int32_t value = 0;
619 SAFE_PARCEL(input.readInt32, &value);
620 pixelFormat = static_cast<ui::PixelFormat>(value);
chaviw308ddba2020-08-11 16:23:51 -0700621 SAFE_PARCEL(input.read, sourceCrop);
chaviw17ac24b2021-01-28 18:50:05 -0800622 SAFE_PARCEL(input.readFloat, &frameScaleX);
623 SAFE_PARCEL(input.readFloat, &frameScaleY);
chaviw308ddba2020-08-11 16:23:51 -0700624 SAFE_PARCEL(input.readBool, &captureSecureLayers);
625 SAFE_PARCEL(input.readInt32, &uid);
Peiyong Lincd261472020-10-06 18:05:25 -0700626 SAFE_PARCEL(input.readInt32, &value);
627 dataspace = static_cast<ui::Dataspace>(value);
Peiyong Lin05cc0112020-10-14 16:16:37 -0700628 SAFE_PARCEL(input.readBool, &allowProtected);
chaviw17ac24b2021-01-28 18:50:05 -0800629 SAFE_PARCEL(input.readBool, &grayscale);
chaviw308ddba2020-08-11 16:23:51 -0700630 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700631}
632
633status_t DisplayCaptureArgs::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700634 SAFE_PARCEL(CaptureArgs::write, output);
chaviw618c42d2020-07-24 15:25:08 -0700635
chaviw308ddba2020-08-11 16:23:51 -0700636 SAFE_PARCEL(output.writeStrongBinder, displayToken);
637 SAFE_PARCEL(output.writeUint32, width);
638 SAFE_PARCEL(output.writeUint32, height);
639 SAFE_PARCEL(output.writeBool, useIdentityTransform);
640 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700641}
642
643status_t DisplayCaptureArgs::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700644 SAFE_PARCEL(CaptureArgs::read, input);
chaviw618c42d2020-07-24 15:25:08 -0700645
chaviw308ddba2020-08-11 16:23:51 -0700646 SAFE_PARCEL(input.readStrongBinder, &displayToken);
647 SAFE_PARCEL(input.readUint32, &width);
648 SAFE_PARCEL(input.readUint32, &height);
649 SAFE_PARCEL(input.readBool, &useIdentityTransform);
650 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700651}
652
653status_t LayerCaptureArgs::write(Parcel& output) const {
chaviw308ddba2020-08-11 16:23:51 -0700654 SAFE_PARCEL(CaptureArgs::write, output);
chaviw618c42d2020-07-24 15:25:08 -0700655
chaviw308ddba2020-08-11 16:23:51 -0700656 SAFE_PARCEL(output.writeStrongBinder, layerHandle);
657 SAFE_PARCEL(output.writeInt32, excludeHandles.size());
chaviw618c42d2020-07-24 15:25:08 -0700658 for (auto el : excludeHandles) {
chaviw308ddba2020-08-11 16:23:51 -0700659 SAFE_PARCEL(output.writeStrongBinder, el);
chaviw618c42d2020-07-24 15:25:08 -0700660 }
chaviw308ddba2020-08-11 16:23:51 -0700661 SAFE_PARCEL(output.writeBool, childrenOnly);
662 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700663}
664
665status_t LayerCaptureArgs::read(const Parcel& input) {
chaviw308ddba2020-08-11 16:23:51 -0700666 SAFE_PARCEL(CaptureArgs::read, input);
chaviw618c42d2020-07-24 15:25:08 -0700667
chaviw308ddba2020-08-11 16:23:51 -0700668 SAFE_PARCEL(input.readStrongBinder, &layerHandle);
chaviw618c42d2020-07-24 15:25:08 -0700669
George Burgess IV4d7aceb2020-07-30 10:01:56 -0700670 int32_t numExcludeHandles = 0;
chaviw308ddba2020-08-11 16:23:51 -0700671 SAFE_PARCEL_READ_SIZE(input.readInt32, &numExcludeHandles, input.dataSize());
chaviw618c42d2020-07-24 15:25:08 -0700672 excludeHandles.reserve(numExcludeHandles);
673 for (int i = 0; i < numExcludeHandles; i++) {
674 sp<IBinder> binder;
chaviw308ddba2020-08-11 16:23:51 -0700675 SAFE_PARCEL(input.readStrongBinder, &binder);
chaviw618c42d2020-07-24 15:25:08 -0700676 excludeHandles.emplace(binder);
677 }
678
chaviw308ddba2020-08-11 16:23:51 -0700679 SAFE_PARCEL(input.readBool, &childrenOnly);
680 return NO_ERROR;
chaviw618c42d2020-07-24 15:25:08 -0700681}
682
chaviw8dd181f2022-01-05 18:36:46 -0600683ReleaseCallbackId BufferData::generateReleaseCallbackId() const {
684 return {buffer->getId(), frameNumber};
685}
686
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800687status_t BufferData::writeToParcel(Parcel* output) const {
688 SAFE_PARCEL(output->writeInt32, flags.get());
chaviwba4320c2021-09-15 15:20:53 -0500689
690 if (buffer) {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800691 SAFE_PARCEL(output->writeBool, true);
692 SAFE_PARCEL(output->write, *buffer);
chaviwba4320c2021-09-15 15:20:53 -0500693 } else {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800694 SAFE_PARCEL(output->writeBool, false);
chaviwba4320c2021-09-15 15:20:53 -0500695 }
696
697 if (acquireFence) {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800698 SAFE_PARCEL(output->writeBool, true);
699 SAFE_PARCEL(output->write, *acquireFence);
chaviwba4320c2021-09-15 15:20:53 -0500700 } else {
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800701 SAFE_PARCEL(output->writeBool, false);
chaviwba4320c2021-09-15 15:20:53 -0500702 }
703
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800704 SAFE_PARCEL(output->writeUint64, frameNumber);
705 SAFE_PARCEL(output->writeStrongBinder, IInterface::asBinder(releaseBufferListener));
706 SAFE_PARCEL(output->writeStrongBinder, releaseBufferEndpoint);
chaviwba4320c2021-09-15 15:20:53 -0500707
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800708 SAFE_PARCEL(output->writeStrongBinder, cachedBuffer.token.promote());
709 SAFE_PARCEL(output->writeUint64, cachedBuffer.id);
chaviwba4320c2021-09-15 15:20:53 -0500710
711 return NO_ERROR;
712}
713
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800714status_t BufferData::readFromParcel(const Parcel* input) {
chaviwba4320c2021-09-15 15:20:53 -0500715 int32_t tmpInt32;
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800716 SAFE_PARCEL(input->readInt32, &tmpInt32);
chaviwba4320c2021-09-15 15:20:53 -0500717 flags = Flags<BufferDataChange>(tmpInt32);
718
719 bool tmpBool = false;
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800720 SAFE_PARCEL(input->readBool, &tmpBool);
chaviwba4320c2021-09-15 15:20:53 -0500721 if (tmpBool) {
722 buffer = new GraphicBuffer();
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800723 SAFE_PARCEL(input->read, *buffer);
chaviwba4320c2021-09-15 15:20:53 -0500724 }
725
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800726 SAFE_PARCEL(input->readBool, &tmpBool);
chaviwba4320c2021-09-15 15:20:53 -0500727 if (tmpBool) {
728 acquireFence = new Fence();
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800729 SAFE_PARCEL(input->read, *acquireFence);
chaviwba4320c2021-09-15 15:20:53 -0500730 }
731
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800732 SAFE_PARCEL(input->readUint64, &frameNumber);
chaviwba4320c2021-09-15 15:20:53 -0500733
734 sp<IBinder> tmpBinder = nullptr;
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800735 SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder);
chaviwba4320c2021-09-15 15:20:53 -0500736 if (tmpBinder) {
737 releaseBufferListener = checked_interface_cast<ITransactionCompletedListener>(tmpBinder);
738 }
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800739 SAFE_PARCEL(input->readNullableStrongBinder, &releaseBufferEndpoint);
chaviwba4320c2021-09-15 15:20:53 -0500740
741 tmpBinder = nullptr;
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800742 SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder);
chaviwba4320c2021-09-15 15:20:53 -0500743 cachedBuffer.token = tmpBinder;
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800744 SAFE_PARCEL(input->readUint64, &cachedBuffer.id);
chaviwba4320c2021-09-15 15:20:53 -0500745
746 return NO_ERROR;
747}
748
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800749}; // namespace android