blob: 725d3cdfd57047df665afc613bd31128450344cf [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-04 03:31:441/*
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 23:34:4917#define LOG_TAG "LayerState"
18
Garfield Tan8a3083e2018-12-03 21:21:0719#include <inttypes.h>
20
The Android Open Source Projectedbf3b62009-03-04 03:31:4421#include <utils/Errors.h>
Mathias Agopianc5b2c0b2009-05-20 02:08:1022#include <binder/Parcel.h>
Mathias Agopian90ac7992012-02-26 02:48:3523#include <gui/ISurfaceComposerClient.h>
Andy McFadden2adaf042012-12-18 17:49:4524#include <gui/IGraphicBufferProducer.h>
Robert Carr4cdc58f2017-08-23 21:22:2025#include <gui/LayerState.h>
The Android Open Source Projectedbf3b62009-03-04 03:31:4426
Steven Thomas62a4cf82020-01-31 20:04:0327#include <cmath>
28
The Android Open Source Projectedbf3b62009-03-04 03:31:4429namespace android {
30
31status_t layer_state_t::write(Parcel& output) const
32{
Mathias Agopianac9fa422013-02-12 00:40:3633 output.writeStrongBinder(surface);
Garfield Tan8a3083e2018-12-03 21:21:0734 output.writeUint64(what);
Mathias Agopianac9fa422013-02-12 00:40:3635 output.writeFloat(x);
36 output.writeFloat(y);
Robert Carrae060832016-11-28 18:51:0037 output.writeInt32(z);
Dan Stozad723bd72014-11-18 18:24:0338 output.writeUint32(w);
39 output.writeUint32(h);
40 output.writeUint32(layerStack);
Mathias Agopianac9fa422013-02-12 00:40:3641 output.writeFloat(alpha);
Dan Stozad723bd72014-11-18 18:24:0342 output.writeUint32(flags);
43 output.writeUint32(mask);
Mathias Agopianac9fa422013-02-12 00:40:3644 *reinterpret_cast<layer_state_t::matrix22_t *>(
45 output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix;
Marissa Wallf58c14b2018-07-24 17:50:4346 output.write(crop_legacy);
Marissa Wallf58c14b2018-07-24 17:50:4347 output.writeStrongBinder(barrierHandle_legacy);
Robert Carr1db73f62016-12-21 20:58:5148 output.writeStrongBinder(reparentHandle);
Marissa Wallf58c14b2018-07-24 17:50:4349 output.writeUint64(frameNumber_legacy);
Robert Carrc3574f72016-03-24 19:19:3250 output.writeInt32(overrideScalingMode);
Marissa Wallf58c14b2018-07-24 17:50:4351 output.writeStrongBinder(IInterface::asBinder(barrierGbp_legacy));
Robert Carrdb66e622017-04-10 23:55:5752 output.writeStrongBinder(relativeLayerHandle);
chaviw06178942017-07-27 17:25:5953 output.writeStrongBinder(parentHandleForChild);
chaviw13fdc492017-06-27 19:40:1854 output.writeFloat(color.r);
55 output.writeFloat(color.g);
56 output.writeFloat(color.b);
Robert Carr2c358bf2018-08-08 22:58:1557#ifndef NO_INPUT
Chris Ye0783e992020-06-03 04:34:4958 inputHandle->writeToParcel(&output);
Robert Carr2c358bf2018-08-08 22:58:1559#endif
Mathias Agopianac9fa422013-02-12 00:40:3660 output.write(transparentRegion);
Marissa Wall61c58622018-07-18 17:12:2061 output.writeUint32(transform);
62 output.writeBool(transformToDisplayInverse);
63 output.write(crop);
Marin Shalamanov6ad317c2020-07-29 21:34:0764 output.write(orientedDisplaySpaceRect);
Marissa Wall61c58622018-07-18 17:12:2065 if (buffer) {
66 output.writeBool(true);
67 output.write(*buffer);
68 } else {
69 output.writeBool(false);
70 }
71 if (acquireFence) {
72 output.writeBool(true);
73 output.write(*acquireFence);
74 } else {
75 output.writeBool(false);
76 }
77 output.writeUint32(static_cast<uint32_t>(dataspace));
78 output.write(hdrMetadata);
79 output.write(surfaceDamageRegion);
80 output.writeInt32(api);
81 if (sidebandStream) {
82 output.writeBool(true);
83 output.writeNativeHandle(sidebandStream->handle());
84 } else {
85 output.writeBool(false);
86 }
87
Peiyong Lind3788632018-09-18 23:01:3188 memcpy(output.writeInplace(16 * sizeof(float)),
89 colorTransform.asArray(), 16 * sizeof(float));
Lucas Dupin1b6531c2018-07-06 00:18:2190 output.writeFloat(cornerRadius);
Lucas Dupin19c8f0e2019-11-26 01:55:4491 output.writeUint32(backgroundBlurRadius);
Steven Moreland9d4ce9b2019-07-17 22:23:3892 output.writeStrongBinder(cachedBuffer.token.promote());
Marissa Wall947d34e2019-03-29 21:03:5393 output.writeUint64(cachedBuffer.id);
Evan Rosky1f6d6d52018-12-06 18:47:2694 output.writeParcelable(metadata);
Marissa Wallebc2c052019-01-17 03:16:5595
Valerie Haudd0b7572019-01-29 22:59:2796 output.writeFloat(bgColorAlpha);
97 output.writeUint32(static_cast<uint32_t>(bgColorDataspace));
Peiyong Linc502cb72019-03-01 23:00:2398 output.writeBool(colorSpaceAgnostic);
Valerie Haued54efa2019-01-12 04:03:1499
Valerie Hau9dab9732019-08-20 16:29:25100 auto err = output.writeVectorSize(listeners);
101 if (err) {
102 return err;
103 }
104
105 for (auto listener : listeners) {
106 err = output.writeStrongBinder(listener.transactionCompletedListener);
107 if (err) {
108 return err;
109 }
110 err = output.writeInt64Vector(listener.callbackIds);
111 if (err) {
112 return err;
113 }
114 }
Vishnu Nair440992f2019-12-10 03:53:19115 output.writeFloat(shadowRadius);
Ana Krulecc84d09b2019-11-02 22:10:29116 output.writeInt32(frameRateSelectionPriority);
Steven Thomas3172e202020-01-07 03:25:30117 output.writeFloat(frameRate);
Steven Thomas62a4cf82020-01-31 20:04:03118 output.writeByte(frameRateCompatibility);
Vishnu Nair6213bd92020-05-09 00:42:25119 output.writeUint32(fixedTransformHint);
Mathias Agopianac9fa422013-02-12 00:40:36120 return NO_ERROR;
The Android Open Source Projectedbf3b62009-03-04 03:31:44121}
122
123status_t layer_state_t::read(const Parcel& input)
124{
Mathias Agopianac9fa422013-02-12 00:40:36125 surface = input.readStrongBinder();
Garfield Tan8a3083e2018-12-03 21:21:07126 what = input.readUint64();
Mathias Agopianac9fa422013-02-12 00:40:36127 x = input.readFloat();
128 y = input.readFloat();
Robert Carrae060832016-11-28 18:51:00129 z = input.readInt32();
Dan Stozad723bd72014-11-18 18:24:03130 w = input.readUint32();
131 h = input.readUint32();
132 layerStack = input.readUint32();
Mathias Agopianac9fa422013-02-12 00:40:36133 alpha = input.readFloat();
Dan Stozad723bd72014-11-18 18:24:03134 flags = static_cast<uint8_t>(input.readUint32());
135 mask = static_cast<uint8_t>(input.readUint32());
Michael Lentine8afa1c42014-10-31 18:10:13136 const void* matrix_data = input.readInplace(sizeof(layer_state_t::matrix22_t));
137 if (matrix_data) {
138 matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(matrix_data);
139 } else {
140 return BAD_VALUE;
141 }
Marissa Wallf58c14b2018-07-24 17:50:43142 input.read(crop_legacy);
Marissa Wallf58c14b2018-07-24 17:50:43143 barrierHandle_legacy = input.readStrongBinder();
Robert Carr1db73f62016-12-21 20:58:51144 reparentHandle = input.readStrongBinder();
Marissa Wallf58c14b2018-07-24 17:50:43145 frameNumber_legacy = input.readUint64();
Robert Carrc3574f72016-03-24 19:19:32146 overrideScalingMode = input.readInt32();
Marissa Wallf58c14b2018-07-24 17:50:43147 barrierGbp_legacy = interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
Robert Carrdb66e622017-04-10 23:55:57148 relativeLayerHandle = input.readStrongBinder();
chaviw06178942017-07-27 17:25:59149 parentHandleForChild = input.readStrongBinder();
chaviw13fdc492017-06-27 19:40:18150 color.r = input.readFloat();
151 color.g = input.readFloat();
152 color.b = input.readFloat();
Robert Carr2c358bf2018-08-08 22:58:15153
154#ifndef NO_INPUT
Chris Ye0783e992020-06-03 04:34:49155 inputHandle->readFromParcel(&input);
Robert Carr2c358bf2018-08-08 22:58:15156#endif
157
Mathias Agopianac9fa422013-02-12 00:40:36158 input.read(transparentRegion);
Marissa Wall61c58622018-07-18 17:12:20159 transform = input.readUint32();
160 transformToDisplayInverse = input.readBool();
161 input.read(crop);
Marin Shalamanov6ad317c2020-07-29 21:34:07162 input.read(orientedDisplaySpaceRect);
Marissa Wall61c58622018-07-18 17:12:20163 buffer = new GraphicBuffer();
164 if (input.readBool()) {
165 input.read(*buffer);
166 }
167 acquireFence = new Fence();
168 if (input.readBool()) {
169 input.read(*acquireFence);
170 }
171 dataspace = static_cast<ui::Dataspace>(input.readUint32());
172 input.read(hdrMetadata);
173 input.read(surfaceDamageRegion);
174 api = input.readInt32();
175 if (input.readBool()) {
176 sidebandStream = NativeHandle::create(input.readNativeHandle(), true);
177 }
178
Denis Hsu8f3da5e2020-07-15 01:31:21179 const void* color_transform_data = input.readInplace(16 * sizeof(float));
180 if (color_transform_data) {
181 colorTransform = mat4(static_cast<const float*>(color_transform_data));
182 } else {
183 return BAD_VALUE;
184 }
Lucas Dupin1b6531c2018-07-06 00:18:21185 cornerRadius = input.readFloat();
Lucas Dupin19c8f0e2019-11-26 01:55:44186 backgroundBlurRadius = input.readUint32();
Steven Moreland9d4ce9b2019-07-17 22:23:38187 cachedBuffer.token = input.readStrongBinder();
Marissa Wall947d34e2019-03-29 21:03:53188 cachedBuffer.id = input.readUint64();
Evan Rosky1f6d6d52018-12-06 18:47:26189 input.readParcelable(&metadata);
Marissa Wallebc2c052019-01-17 03:16:55190
Valerie Haudd0b7572019-01-29 22:59:27191 bgColorAlpha = input.readFloat();
192 bgColorDataspace = static_cast<ui::Dataspace>(input.readUint32());
Peiyong Linc502cb72019-03-01 23:00:23193 colorSpaceAgnostic = input.readBool();
Valerie Haued54efa2019-01-12 04:03:14194
Valerie Hau9dab9732019-08-20 16:29:25195 int32_t numListeners = input.readInt32();
196 listeners.clear();
197 for (int i = 0; i < numListeners; i++) {
198 auto listener = input.readStrongBinder();
199 std::vector<CallbackId> callbackIds;
200 input.readInt64Vector(&callbackIds);
201 listeners.emplace_back(listener, callbackIds);
202 }
Vishnu Nair440992f2019-12-10 03:53:19203 shadowRadius = input.readFloat();
Ana Krulecc84d09b2019-11-02 22:10:29204 frameRateSelectionPriority = input.readInt32();
Steven Thomas3172e202020-01-07 03:25:30205 frameRate = input.readFloat();
Steven Thomas62a4cf82020-01-31 20:04:03206 frameRateCompatibility = input.readByte();
Vishnu Nair6213bd92020-05-09 00:42:25207 fixedTransformHint = static_cast<ui::Transform::RotationFlags>(input.readUint32());
The Android Open Source Projectedbf3b62009-03-04 03:31:44208 return NO_ERROR;
209}
210
Mathias Agopian698c0872011-06-29 02:09:31211status_t ComposerState::write(Parcel& output) const {
Mathias Agopian698c0872011-06-29 02:09:31212 return state.write(output);
213}
214
215status_t ComposerState::read(const Parcel& input) {
Mathias Agopian698c0872011-06-29 02:09:31216 return state.read(input);
217}
218
Marin Shalamanov6ad317c2020-07-29 21:34:07219DisplayState::DisplayState()
220 : what(0),
221 layerStack(0),
222 layerStackSpaceRect(Rect::EMPTY_RECT),
223 orientedDisplaySpaceRect(Rect::EMPTY_RECT),
224 width(0),
225 height(0) {}
Pablo Ceballos60d69222015-08-07 21:47:20226
Mathias Agopian8b33f032012-07-25 03:43:54227status_t DisplayState::write(Parcel& output) const {
Mathias Agopiane57f2922012-08-09 23:29:12228 output.writeStrongBinder(token);
Marco Nelissen2ea926b2014-11-14 16:01:01229 output.writeStrongBinder(IInterface::asBinder(surface));
Dan Stozad723bd72014-11-18 18:24:03230 output.writeUint32(what);
231 output.writeUint32(layerStack);
Dominik Laskowski718f9602019-11-10 04:01:35232 output.writeUint32(toRotationInt(orientation));
Marin Shalamanov6ad317c2020-07-29 21:34:07233 output.write(layerStackSpaceRect);
234 output.write(orientedDisplaySpaceRect);
Dan Stozad723bd72014-11-18 18:24:03235 output.writeUint32(width);
236 output.writeUint32(height);
Mathias Agopian8b33f032012-07-25 03:43:54237 return NO_ERROR;
238}
239
240status_t DisplayState::read(const Parcel& input) {
Mathias Agopiane57f2922012-08-09 23:29:12241 token = input.readStrongBinder();
Andy McFadden2adaf042012-12-18 17:49:45242 surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
Dan Stozad723bd72014-11-18 18:24:03243 what = input.readUint32();
244 layerStack = input.readUint32();
Dominik Laskowski718f9602019-11-10 04:01:35245 orientation = ui::toRotation(input.readUint32());
Marin Shalamanov6ad317c2020-07-29 21:34:07246 input.read(layerStackSpaceRect);
247 input.read(orientedDisplaySpaceRect);
Dan Stozad723bd72014-11-18 18:24:03248 width = input.readUint32();
249 height = input.readUint32();
Mathias Agopian8b33f032012-07-25 03:43:54250 return NO_ERROR;
251}
252
Robert Carr2c5f6d22017-09-26 19:30:35253void DisplayState::merge(const DisplayState& other) {
254 if (other.what & eSurfaceChanged) {
255 what |= eSurfaceChanged;
256 surface = other.surface;
257 }
258 if (other.what & eLayerStackChanged) {
259 what |= eLayerStackChanged;
260 layerStack = other.layerStack;
261 }
262 if (other.what & eDisplayProjectionChanged) {
263 what |= eDisplayProjectionChanged;
264 orientation = other.orientation;
Marin Shalamanov6ad317c2020-07-29 21:34:07265 layerStackSpaceRect = other.layerStackSpaceRect;
266 orientedDisplaySpaceRect = other.orientedDisplaySpaceRect;
Robert Carr2c5f6d22017-09-26 19:30:35267 }
268 if (other.what & eDisplaySizeChanged) {
269 what |= eDisplaySizeChanged;
270 width = other.width;
271 height = other.height;
272 }
273}
274
275void layer_state_t::merge(const layer_state_t& other) {
276 if (other.what & ePositionChanged) {
277 what |= ePositionChanged;
278 x = other.x;
279 y = other.y;
280 }
281 if (other.what & eLayerChanged) {
282 what |= eLayerChanged;
chaviw32377582019-05-13 18:15:19283 what &= ~eRelativeLayerChanged;
Robert Carr2c5f6d22017-09-26 19:30:35284 z = other.z;
285 }
286 if (other.what & eSizeChanged) {
287 what |= eSizeChanged;
288 w = other.w;
289 h = other.h;
290 }
291 if (other.what & eAlphaChanged) {
292 what |= eAlphaChanged;
293 alpha = other.alpha;
294 }
295 if (other.what & eMatrixChanged) {
296 what |= eMatrixChanged;
297 matrix = other.matrix;
298 }
299 if (other.what & eTransparentRegionChanged) {
300 what |= eTransparentRegionChanged;
301 transparentRegion = other.transparentRegion;
302 }
303 if (other.what & eFlagsChanged) {
304 what |= eFlagsChanged;
Vishnu Nair996bc422019-07-16 21:15:33305 flags &= ~other.mask;
306 flags |= (other.flags & other.mask);
307 mask |= other.mask;
Robert Carr2c5f6d22017-09-26 19:30:35308 }
309 if (other.what & eLayerStackChanged) {
310 what |= eLayerStackChanged;
311 layerStack = other.layerStack;
312 }
Marissa Wallf58c14b2018-07-24 17:50:43313 if (other.what & eCropChanged_legacy) {
314 what |= eCropChanged_legacy;
315 crop_legacy = other.crop_legacy;
Robert Carr2c5f6d22017-09-26 19:30:35316 }
Lucas Dupin1b6531c2018-07-06 00:18:21317 if (other.what & eCornerRadiusChanged) {
318 what |= eCornerRadiusChanged;
319 cornerRadius = other.cornerRadius;
320 }
Lucas Dupin19c8f0e2019-11-26 01:55:44321 if (other.what & eBackgroundBlurRadiusChanged) {
322 what |= eBackgroundBlurRadiusChanged;
323 backgroundBlurRadius = other.backgroundBlurRadius;
324 }
Marissa Wallf58c14b2018-07-24 17:50:43325 if (other.what & eDeferTransaction_legacy) {
326 what |= eDeferTransaction_legacy;
327 barrierHandle_legacy = other.barrierHandle_legacy;
328 barrierGbp_legacy = other.barrierGbp_legacy;
329 frameNumber_legacy = other.frameNumber_legacy;
Robert Carr2c5f6d22017-09-26 19:30:35330 }
Robert Carr2c5f6d22017-09-26 19:30:35331 if (other.what & eOverrideScalingModeChanged) {
332 what |= eOverrideScalingModeChanged;
333 overrideScalingMode = other.overrideScalingMode;
334 }
Robert Carr2c5f6d22017-09-26 19:30:35335 if (other.what & eReparentChildren) {
336 what |= eReparentChildren;
337 reparentHandle = other.reparentHandle;
338 }
339 if (other.what & eDetachChildren) {
340 what |= eDetachChildren;
341 }
342 if (other.what & eRelativeLayerChanged) {
343 what |= eRelativeLayerChanged;
chaviw32377582019-05-13 18:15:19344 what &= ~eLayerChanged;
Robert Carr2c5f6d22017-09-26 19:30:35345 z = other.z;
346 relativeLayerHandle = other.relativeLayerHandle;
347 }
348 if (other.what & eReparent) {
349 what |= eReparent;
350 parentHandleForChild = other.parentHandleForChild;
351 }
chaviwca27f252018-02-07 00:46:39352 if (other.what & eDestroySurface) {
353 what |= eDestroySurface;
354 }
Marissa Wall61c58622018-07-18 17:12:20355 if (other.what & eTransformChanged) {
356 what |= eTransformChanged;
357 transform = other.transform;
358 }
359 if (other.what & eTransformToDisplayInverseChanged) {
360 what |= eTransformToDisplayInverseChanged;
361 transformToDisplayInverse = other.transformToDisplayInverse;
362 }
363 if (other.what & eCropChanged) {
364 what |= eCropChanged;
365 crop = other.crop;
366 }
Marissa Wall861616d2018-10-22 19:52:23367 if (other.what & eFrameChanged) {
368 what |= eFrameChanged;
Marin Shalamanov6ad317c2020-07-29 21:34:07369 orientedDisplaySpaceRect = other.orientedDisplaySpaceRect;
Marissa Wall861616d2018-10-22 19:52:23370 }
Marissa Wall61c58622018-07-18 17:12:20371 if (other.what & eBufferChanged) {
372 what |= eBufferChanged;
373 buffer = other.buffer;
374 }
375 if (other.what & eAcquireFenceChanged) {
376 what |= eAcquireFenceChanged;
377 acquireFence = other.acquireFence;
378 }
379 if (other.what & eDataspaceChanged) {
380 what |= eDataspaceChanged;
381 dataspace = other.dataspace;
382 }
383 if (other.what & eHdrMetadataChanged) {
384 what |= eHdrMetadataChanged;
385 hdrMetadata = other.hdrMetadata;
386 }
387 if (other.what & eSurfaceDamageRegionChanged) {
388 what |= eSurfaceDamageRegionChanged;
389 surfaceDamageRegion = other.surfaceDamageRegion;
390 }
391 if (other.what & eApiChanged) {
392 what |= eApiChanged;
393 api = other.api;
394 }
395 if (other.what & eSidebandStreamChanged) {
396 what |= eSidebandStreamChanged;
397 sidebandStream = other.sidebandStream;
398 }
Peiyong Lind3788632018-09-18 23:01:31399 if (other.what & eColorTransformChanged) {
400 what |= eColorTransformChanged;
401 colorTransform = other.colorTransform;
402 }
Marissa Wall3dad52d2019-03-22 21:03:19403 if (other.what & eHasListenerCallbacksChanged) {
404 what |= eHasListenerCallbacksChanged;
Marissa Wallc837b5e2018-10-12 17:04:44405 }
Robert Carrd314f162018-08-15 20:12:42406
Robert Carr2c358bf2018-08-08 22:58:15407#ifndef NO_INPUT
408 if (other.what & eInputInfoChanged) {
409 what |= eInputInfoChanged;
Chris Ye0783e992020-06-03 04:34:49410 inputHandle = new InputWindowHandle(*other.inputHandle);
Robert Carr2c358bf2018-08-08 22:58:15411 }
412#endif
413
Marissa Wallebc2c052019-01-17 03:16:55414 if (other.what & eCachedBufferChanged) {
415 what |= eCachedBufferChanged;
416 cachedBuffer = other.cachedBuffer;
417 }
Valerie Haudd0b7572019-01-29 22:59:27418 if (other.what & eBackgroundColorChanged) {
419 what |= eBackgroundColorChanged;
420 color = other.color;
421 bgColorAlpha = other.bgColorAlpha;
422 bgColorDataspace = other.bgColorDataspace;
Valerie Haued54efa2019-01-12 04:03:14423 }
Evan Rosky1f6d6d52018-12-06 18:47:26424 if (other.what & eMetadataChanged) {
425 what |= eMetadataChanged;
426 metadata.merge(other.metadata);
427 }
Vishnu Nairc97b8db2019-10-30 01:19:35428 if (other.what & eShadowRadiusChanged) {
429 what |= eShadowRadiusChanged;
430 shadowRadius = other.shadowRadius;
431 }
Ana Krulecc84d09b2019-11-02 22:10:29432 if (other.what & eFrameRateSelectionPriority) {
433 what |= eFrameRateSelectionPriority;
434 frameRateSelectionPriority = other.frameRateSelectionPriority;
435 }
Steven Thomas3172e202020-01-07 03:25:30436 if (other.what & eFrameRateChanged) {
437 what |= eFrameRateChanged;
438 frameRate = other.frameRate;
Steven Thomas62a4cf82020-01-31 20:04:03439 frameRateCompatibility = other.frameRateCompatibility;
Steven Thomas3172e202020-01-07 03:25:30440 }
Vishnu Nair6213bd92020-05-09 00:42:25441 if (other.what & eFixedTransformHintChanged) {
442 what |= eFixedTransformHintChanged;
443 fixedTransformHint = other.fixedTransformHint;
444 }
Vishnu Nair217d8e62018-09-12 23:34:49445 if ((other.what & what) != other.what) {
446 ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
Garfield Tan8a3083e2018-12-03 21:21:07447 "other.what=0x%" PRIu64 " what=0x%" PRIu64,
Vishnu Nair217d8e62018-09-12 23:34:49448 other.what, what);
Robert Carrd314f162018-08-15 20:12:42449 }
Robert Carr2c5f6d22017-09-26 19:30:35450}
Mathias Agopian8b33f032012-07-25 03:43:54451
chaviw273171b2018-12-26 19:46:30452// ------------------------------- InputWindowCommands ----------------------------------------
453
Vishnu Naire798b472020-07-23 20:52:21454bool InputWindowCommands::merge(const InputWindowCommands& other) {
455 bool changes = false;
456#ifndef NO_INPUT
457 changes |= !other.focusRequests.empty();
458 focusRequests.insert(focusRequests.end(), std::make_move_iterator(other.focusRequests.begin()),
459 std::make_move_iterator(other.focusRequests.end()));
460#endif
461 changes |= other.syncInputWindows && !syncInputWindows;
chaviwa911b102019-02-14 18:18:33462 syncInputWindows |= other.syncInputWindows;
Vishnu Naire798b472020-07-23 20:52:21463 return changes;
chaviw273171b2018-12-26 19:46:30464}
465
466void InputWindowCommands::clear() {
Vishnu Naire798b472020-07-23 20:52:21467#ifndef NO_INPUT
468 focusRequests.clear();
469#endif
chaviwa911b102019-02-14 18:18:33470 syncInputWindows = false;
chaviw273171b2018-12-26 19:46:30471}
472
473void InputWindowCommands::write(Parcel& output) const {
Vishnu Naire798b472020-07-23 20:52:21474#ifndef NO_INPUT
475 output.writeParcelableVector(focusRequests);
476#endif
chaviwa911b102019-02-14 18:18:33477 output.writeBool(syncInputWindows);
chaviw273171b2018-12-26 19:46:30478}
479
480void InputWindowCommands::read(const Parcel& input) {
Vishnu Naire798b472020-07-23 20:52:21481#ifndef NO_INPUT
482 input.readParcelableVector(&focusRequests);
483#endif
chaviwa911b102019-02-14 18:18:33484 syncInputWindows = input.readBool();
chaviw273171b2018-12-26 19:46:30485}
486
Steven Thomas62a4cf82020-01-31 20:04:03487bool ValidateFrameRate(float frameRate, int8_t compatibility, const char* inFunctionName) {
488 const char* functionName = inFunctionName != nullptr ? inFunctionName : "call";
489 int floatClassification = std::fpclassify(frameRate);
490 if (frameRate < 0 || floatClassification == FP_INFINITE || floatClassification == FP_NAN) {
491 ALOGE("%s failed - invalid frame rate %f", functionName, frameRate);
492 return false;
493 }
494
495 if (compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT &&
496 compatibility != ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE) {
497 ALOGE("%s failed - invalid compatibility value %d", functionName, compatibility);
498 return false;
499 }
500
501 return true;
502}
503
chaviw618c42d2020-07-24 22:25:08504// ----------------------------------------------------------------------------
505
506status_t CaptureArgs::write(Parcel& output) const {
507 status_t status = output.writeInt32(static_cast<int32_t>(pixelFormat)) ?:
508 output.write(sourceCrop) ?:
509 output.writeFloat(frameScale) ?:
chaviw4b9d5e12020-08-05 01:30:35510 output.writeBool(captureSecureLayers) ?:
511 output.writeInt32(uid);
chaviw618c42d2020-07-24 22:25:08512 return status;
513}
514
515status_t CaptureArgs::read(const Parcel& input) {
George Burgess IV4d7aceb2020-07-30 17:01:56516 int32_t format = 0;
chaviw618c42d2020-07-24 22:25:08517 status_t status = input.readInt32(&format) ?:
518 input.read(sourceCrop) ?:
519 input.readFloat(&frameScale) ?:
chaviw4b9d5e12020-08-05 01:30:35520 input.readBool(&captureSecureLayers) ?:
521 input.readInt32(&uid);
chaviw618c42d2020-07-24 22:25:08522
523 pixelFormat = static_cast<ui::PixelFormat>(format);
524 return status;
525}
526
527status_t DisplayCaptureArgs::write(Parcel& output) const {
528 status_t status = CaptureArgs::write(output);
529
530 status |= output.writeStrongBinder(displayToken) ?:
531 output.writeUint32(width) ?:
532 output.writeUint32(height) ?:
chaviwc6ad8af2020-08-03 18:33:30533 output.writeBool(useIdentityTransform);
chaviw618c42d2020-07-24 22:25:08534 return status;
535}
536
537status_t DisplayCaptureArgs::read(const Parcel& input) {
538 status_t status = CaptureArgs::read(input);
539
chaviw618c42d2020-07-24 22:25:08540 status |= input.readStrongBinder(&displayToken) ?:
541 input.readUint32(&width) ?:
542 input.readUint32(&height) ?:
chaviwc6ad8af2020-08-03 18:33:30543 input.readBool(&useIdentityTransform);
chaviw618c42d2020-07-24 22:25:08544 return status;
545}
546
547status_t LayerCaptureArgs::write(Parcel& output) const {
548 status_t status = CaptureArgs::write(output);
549
550 status |= output.writeStrongBinder(layerHandle);
551 status |= output.writeInt32(excludeHandles.size());
552 for (auto el : excludeHandles) {
553 status |= output.writeStrongBinder(el);
554 }
555 status |= output.writeBool(childrenOnly);
556 return status;
557}
558
559status_t LayerCaptureArgs::read(const Parcel& input) {
560 status_t status = CaptureArgs::read(input);
561
562 status |= input.readStrongBinder(&layerHandle);
563
George Burgess IV4d7aceb2020-07-30 17:01:56564 int32_t numExcludeHandles = 0;
chaviw618c42d2020-07-24 22:25:08565 status |= input.readInt32(&numExcludeHandles);
566 excludeHandles.reserve(numExcludeHandles);
567 for (int i = 0; i < numExcludeHandles; i++) {
568 sp<IBinder> binder;
569 status |= input.readStrongBinder(&binder);
570 excludeHandles.emplace(binder);
571 }
572
573 status |= input.readBool(&childrenOnly);
574 return status;
575}
576
577status_t ScreenCaptureResults::write(Parcel& output) const {
578 status_t status = output.write(*buffer) ?:
579 output.writeBool(capturedSecureLayers) ?:
580 output.writeUint32(static_cast<uint32_t>(capturedDataspace));
581 return status;
582}
583
584status_t ScreenCaptureResults::read(const Parcel& input) {
585 buffer = new GraphicBuffer();
George Burgess IV4d7aceb2020-07-30 17:01:56586 uint32_t dataspace = 0;
chaviw618c42d2020-07-24 22:25:08587 status_t status = input.read(*buffer) ?:
588 input.readBool(&capturedSecureLayers) ?:
589 input.readUint32(&dataspace);
590
591 capturedDataspace = static_cast<ui::Dataspace>(dataspace);
592
593 return status;
594}
595
The Android Open Source Projectedbf3b62009-03-04 03:31:44596}; // namespace android