blob: 1f670c81df5f27e85f17c2cfde5a1e2472753461 [file] [log] [blame]
Vishnu Nairdc4d31b2022-11-17 03:20:58 +00001/*
2 * Copyright 2022 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 Nairdc4d31b2022-11-17 03:20:58 +000017#define ATRACE_TAG ATRACE_TAG_GRAPHICS
18#undef LOG_TAG
19#define LOG_TAG "RequestedLayerState"
20
Vishnu Naircfb2d252023-01-19 04:44:02 +000021#include <log/log.h>
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000022#include <private/android_filesystem_config.h>
23#include <sys/types.h>
24
25#include "Layer.h"
Vishnu Naircfb2d252023-01-19 04:44:02 +000026#include "LayerCreationArgs.h"
Vishnu Naircfb2d252023-01-19 04:44:02 +000027#include "LayerLog.h"
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000028#include "RequestedLayerState.h"
29
30namespace android::surfaceflinger::frontend {
31using ftl::Flags;
32using namespace ftl::flag_operators;
33
34namespace {
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000035std::string layerIdToString(uint32_t layerId) {
Vishnu Nair04f89692022-11-16 23:21:05 +000036 return layerId == UNASSIGNED_LAYER_ID ? "none" : std::to_string(layerId);
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000037}
38
Vishnu Naira9c43762023-01-27 19:10:25 +000039std::string layerIdsToString(const std::vector<uint32_t>& layerIds) {
40 std::stringstream stream;
41 stream << "{";
42 for (auto layerId : layerIds) {
43 stream << layerId << ",";
44 }
45 stream << "}";
46 return stream.str();
47}
48
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000049} // namespace
50
51RequestedLayerState::RequestedLayerState(const LayerCreationArgs& args)
52 : id(args.sequence),
Vishnu Naircfb2d252023-01-19 04:44:02 +000053 name(args.name + "#" + std::to_string(args.sequence)),
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000054 canBeRoot(args.addToRoot),
55 layerCreationFlags(args.flags),
56 textureName(args.textureName),
57 ownerUid(args.ownerUid),
Vishnu Nair1391de22023-03-05 19:56:14 -080058 ownerPid(args.ownerPid),
59 parentId(args.parentId),
60 layerIdToMirror(args.layerIdToMirror) {
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000061 layerId = static_cast<int32_t>(args.sequence);
62 changes |= RequestedLayerState::Changes::Created;
63 metadata.merge(args.metadata);
64 changes |= RequestedLayerState::Changes::Metadata;
65 handleAlive = true;
Vishnu Nair1391de22023-03-05 19:56:14 -080066 if (parentId != UNASSIGNED_LAYER_ID) {
Vishnu Naircfb2d252023-01-19 04:44:02 +000067 canBeRoot = false;
68 }
Vishnu Naira9c43762023-01-27 19:10:25 +000069 if (layerIdToMirror != UNASSIGNED_LAYER_ID) {
70 changes |= RequestedLayerState::Changes::Mirror;
71 } else if (args.layerStackToMirror != ui::INVALID_LAYER_STACK) {
72 layerStackToMirror = args.layerStackToMirror;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000073 changes |= RequestedLayerState::Changes::Mirror;
74 }
75
76 flags = 0;
77 if (args.flags & ISurfaceComposerClient::eHidden) flags |= layer_state_t::eLayerHidden;
78 if (args.flags & ISurfaceComposerClient::eOpaque) flags |= layer_state_t::eLayerOpaque;
79 if (args.flags & ISurfaceComposerClient::eSecure) flags |= layer_state_t::eLayerSecure;
80 if (args.flags & ISurfaceComposerClient::eSkipScreenshot) {
81 flags |= layer_state_t::eLayerSkipScreenshot;
82 }
83 premultipliedAlpha = !(args.flags & ISurfaceComposerClient::eNonPremultiplied);
84 potentialCursor = args.flags & ISurfaceComposerClient::eCursorWindow;
85 protectedByApp = args.flags & ISurfaceComposerClient::eProtectedByApp;
86 if (args.flags & ISurfaceComposerClient::eNoColorFill) {
87 // Set an invalid color so there is no color fill.
88 // (b/259981098) use an explicit flag instead of relying on invalid values.
89 color.r = -1.0_hf;
90 color.g = -1.0_hf;
91 color.b = -1.0_hf;
92 } else {
93 color.rgb = {0.0_hf, 0.0_hf, 0.0_hf};
94 }
Vishnu Naircfb2d252023-01-19 04:44:02 +000095 LLOGV(layerId, "Created %s flags=%d", getDebugString().c_str(), flags);
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000096 color.a = 1.0f;
97
98 crop.makeInvalid();
99 z = 0;
100 layerStack = ui::DEFAULT_LAYER_STACK;
101 transformToDisplayInverse = false;
102 dataspace = ui::Dataspace::UNKNOWN;
Sally Qi963049b2023-03-23 14:06:21 -0700103 desiredHdrSdrRatio = 1.f;
104 currentHdrSdrRatio = 1.f;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000105 dataspaceRequested = false;
106 hdrMetadata.validTypes = 0;
107 surfaceDamageRegion = Region::INVALID_REGION;
108 cornerRadius = 0.0f;
109 backgroundBlurRadius = 0;
110 api = -1;
111 hasColorTransform = false;
112 bufferTransform = 0;
113 requestedTransform.reset();
114 bufferData = std::make_shared<BufferData>();
115 bufferData->frameNumber = 0;
116 bufferData->acquireFence = sp<Fence>::make(-1);
117 acquireFenceTime = std::make_shared<FenceTime>(bufferData->acquireFence);
118 colorSpaceAgnostic = false;
119 frameRateSelectionPriority = Layer::PRIORITY_UNSET;
120 shadowRadius = 0.f;
121 fixedTransformHint = ui::Transform::ROT_INVALID;
122 destinationFrame.makeInvalid();
123 isTrustedOverlay = false;
124 dropInputMode = gui::DropInputMode::NONE;
125 dimmingEnabled = true;
126 defaultFrameRateCompatibility =
127 static_cast<int8_t>(scheduler::LayerInfo::FrameRateCompatibility::Default);
128 dataspace = ui::Dataspace::V0_SRGB;
Vishnu Naircfb2d252023-01-19 04:44:02 +0000129 gameMode = gui::GameMode::Unsupported;
130 requestedFrameRate = {};
Alec Mourif4af03e2023-02-11 00:25:24 +0000131 cachingHint = gui::CachingHint::Enabled;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000132}
133
134void RequestedLayerState::merge(const ResolvedComposerState& resolvedComposerState) {
Vishnu Naircfb2d252023-01-19 04:44:02 +0000135 const uint32_t oldFlags = flags;
136 const half oldAlpha = color.a;
137 const bool hadBufferOrSideStream = hasValidBuffer() || sidebandStream != nullptr;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000138 const layer_state_t& clientState = resolvedComposerState.state;
Vishnu Nair80a5a702023-02-11 01:21:51 +0000139 const bool hadBlur = hasBlur();
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000140 uint64_t clientChanges = what | layer_state_t::diff(clientState);
141 layer_state_t::merge(clientState);
142 what = clientChanges;
143
144 if (clientState.what & layer_state_t::eFlagsChanged) {
145 if ((oldFlags ^ flags) & layer_state_t::eLayerHidden) {
Vishnu Naircfb2d252023-01-19 04:44:02 +0000146 changes |= RequestedLayerState::Changes::Visibility |
147 RequestedLayerState::Changes::VisibleRegion;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000148 }
149 if ((oldFlags ^ flags) & layer_state_t::eIgnoreDestinationFrame) {
150 changes |= RequestedLayerState::Changes::Geometry;
151 }
152 }
Vishnu Naircfb2d252023-01-19 04:44:02 +0000153 if (clientState.what &
154 (layer_state_t::eBufferChanged | layer_state_t::eSidebandStreamChanged)) {
155 const bool hasBufferOrSideStream = hasValidBuffer() || sidebandStream != nullptr;
156 if (hadBufferOrSideStream != hasBufferOrSideStream) {
157 changes |= RequestedLayerState::Changes::Geometry |
158 RequestedLayerState::Changes::VisibleRegion |
Vishnu Naird47bcee2023-02-24 18:08:51 +0000159 RequestedLayerState::Changes::Visibility | RequestedLayerState::Changes::Input;
160 }
161 if (clientState.what & layer_state_t::eBufferChanged) {
162 changes |= RequestedLayerState::Changes::Buffer;
163 }
164 if (clientState.what & layer_state_t::eSidebandStreamChanged) {
165 changes |= RequestedLayerState::Changes::SidebandStream;
Vishnu Naircfb2d252023-01-19 04:44:02 +0000166 }
167 }
168 if (what & (layer_state_t::eAlphaChanged)) {
169 if (oldAlpha == 0 || color.a == 0) {
170 changes |= RequestedLayerState::Changes::Visibility |
171 RequestedLayerState::Changes::VisibleRegion;
172 }
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000173 }
Vishnu Nair80a5a702023-02-11 01:21:51 +0000174 if (what & (layer_state_t::eBackgroundBlurRadiusChanged | layer_state_t::eBlurRegionsChanged)) {
175 if (hadBlur != hasBlur()) {
176 changes |= RequestedLayerState::Changes::Visibility |
177 RequestedLayerState::Changes::VisibleRegion;
178 }
179 }
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000180 if (clientChanges & layer_state_t::HIERARCHY_CHANGES)
181 changes |= RequestedLayerState::Changes::Hierarchy;
182 if (clientChanges & layer_state_t::CONTENT_CHANGES)
183 changes |= RequestedLayerState::Changes::Content;
184 if (clientChanges & layer_state_t::GEOMETRY_CHANGES)
185 changes |= RequestedLayerState::Changes::Geometry;
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000186 if (clientChanges & layer_state_t::AFFECTS_CHILDREN)
187 changes |= RequestedLayerState::Changes::AffectsChildren;
Vishnu Naircfb2d252023-01-19 04:44:02 +0000188 if (clientChanges & layer_state_t::INPUT_CHANGES)
189 changes |= RequestedLayerState::Changes::Input;
190 if (clientChanges & layer_state_t::VISIBLE_REGION_CHANGES)
191 changes |= RequestedLayerState::Changes::VisibleRegion;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000192 if (clientState.what & layer_state_t::eColorTransformChanged) {
193 static const mat4 identityMatrix = mat4();
194 hasColorTransform = colorTransform != identityMatrix;
195 }
Vishnu Naird47bcee2023-02-24 18:08:51 +0000196 if (clientState.what &
197 (layer_state_t::eLayerChanged | layer_state_t::eRelativeLayerChanged |
198 layer_state_t::eLayerStackChanged)) {
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000199 changes |= RequestedLayerState::Changes::Z;
200 }
201 if (clientState.what & layer_state_t::eReparent) {
202 changes |= RequestedLayerState::Changes::Parent;
Vishnu Nair1391de22023-03-05 19:56:14 -0800203 parentId = resolvedComposerState.parentId;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000204 parentSurfaceControlForChild = nullptr;
Vishnu Nair04f89692022-11-16 23:21:05 +0000205 // Once a layer has be reparented, it cannot be placed at the root. It sounds odd
206 // but thats the existing logic and until we make this behavior more explicit, we need
207 // to maintain this logic.
208 canBeRoot = false;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000209 }
210 if (clientState.what & layer_state_t::eRelativeLayerChanged) {
211 changes |= RequestedLayerState::Changes::RelativeParent;
Vishnu Nair1391de22023-03-05 19:56:14 -0800212 relativeParentId = resolvedComposerState.relativeParentId;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000213 isRelativeOf = true;
214 relativeLayerSurfaceControl = nullptr;
215 }
216 if ((clientState.what & layer_state_t::eLayerChanged ||
217 (clientState.what & layer_state_t::eReparent && parentId == UNASSIGNED_LAYER_ID)) &&
218 isRelativeOf) {
219 // clear out relz data
220 relativeParentId = UNASSIGNED_LAYER_ID;
221 isRelativeOf = false;
222 changes |= RequestedLayerState::Changes::RelativeParent;
223 }
224 if (clientState.what & layer_state_t::eReparent && parentId == relativeParentId) {
225 // provide a hint that we are are now a direct child and not a relative child.
226 changes |= RequestedLayerState::Changes::RelativeParent;
227 }
228 if (clientState.what & layer_state_t::eInputInfoChanged) {
Vishnu Nair1391de22023-03-05 19:56:14 -0800229 touchCropId = resolvedComposerState.touchCropId;
230 windowInfoHandle->editInfo()->touchableRegionCropHandle.clear();
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000231 }
232 if (clientState.what & layer_state_t::eStretchChanged) {
233 stretchEffect.sanitize();
234 }
235
236 if (clientState.what & layer_state_t::eHasListenerCallbacksChanged) {
237 // TODO(b/238781169) handle callbacks
238 }
239
240 if (clientState.what & layer_state_t::eBufferChanged) {
241 externalTexture = resolvedComposerState.externalTexture;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000242 }
243
244 if (clientState.what & layer_state_t::ePositionChanged) {
245 requestedTransform.set(x, y);
246 }
247
248 if (clientState.what & layer_state_t::eMatrixChanged) {
249 requestedTransform.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy);
250 }
Vishnu Naircfb2d252023-01-19 04:44:02 +0000251 if (clientState.what & layer_state_t::eMetadataChanged) {
252 const int32_t requestedGameMode =
253 clientState.metadata.getInt32(gui::METADATA_GAME_MODE, -1);
254 if (requestedGameMode != -1) {
255 // The transaction will be received on the Task layer and needs to be applied to all
256 // child layers.
257 if (static_cast<int32_t>(gameMode) != requestedGameMode) {
258 gameMode = static_cast<gui::GameMode>(requestedGameMode);
259 changes |= RequestedLayerState::Changes::AffectsChildren;
260 }
261 }
262 }
263 if (clientState.what & layer_state_t::eFrameRateChanged) {
264 const auto compatibility =
265 Layer::FrameRate::convertCompatibility(clientState.frameRateCompatibility);
266 const auto strategy = Layer::FrameRate::convertChangeFrameRateStrategy(
267 clientState.changeFrameRateStrategy);
268 requestedFrameRate =
269 Layer::FrameRate(Fps::fromValue(clientState.frameRate), compatibility, strategy);
270 changes |= RequestedLayerState::Changes::FrameRate;
271 }
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000272}
273
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000274ui::Size RequestedLayerState::getUnrotatedBufferSize(uint32_t displayRotationFlags) const {
275 uint32_t bufferWidth = externalTexture->getWidth();
276 uint32_t bufferHeight = externalTexture->getHeight();
277 // Undo any transformations on the buffer.
278 if (bufferTransform & ui::Transform::ROT_90) {
279 std::swap(bufferWidth, bufferHeight);
280 }
281 if (transformToDisplayInverse) {
282 if (displayRotationFlags & ui::Transform::ROT_90) {
283 std::swap(bufferWidth, bufferHeight);
284 }
285 }
286 return {bufferWidth, bufferHeight};
287}
288
289ui::Transform RequestedLayerState::getTransform(uint32_t displayRotationFlags) const {
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000290 if ((flags & layer_state_t::eIgnoreDestinationFrame) || destinationFrame.isEmpty()) {
291 // If destination frame is not set, use the requested transform set via
292 // Transaction::setPosition and Transaction::setMatrix.
293 return requestedTransform;
294 }
295
296 Rect destRect = destinationFrame;
297 int32_t destW = destRect.width();
298 int32_t destH = destRect.height();
299 if (destRect.left < 0) {
300 destRect.left = 0;
301 destRect.right = destW;
302 }
303 if (destRect.top < 0) {
304 destRect.top = 0;
305 destRect.bottom = destH;
306 }
307
308 if (!externalTexture) {
309 ui::Transform transform;
310 transform.set(static_cast<float>(destRect.left), static_cast<float>(destRect.top));
311 return transform;
312 }
313
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000314 ui::Size bufferSize = getUnrotatedBufferSize(displayRotationFlags);
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000315
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000316 float sx = static_cast<float>(destW) / static_cast<float>(bufferSize.width);
317 float sy = static_cast<float>(destH) / static_cast<float>(bufferSize.height);
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000318 ui::Transform transform;
319 transform.set(sx, 0, 0, sy);
320 transform.set(static_cast<float>(destRect.left), static_cast<float>(destRect.top));
321 return transform;
322}
323
324std::string RequestedLayerState::getDebugString() const {
Vishnu Nair80a5a702023-02-11 01:21:51 +0000325 std::stringstream debug;
326 debug << "RequestedLayerState{" << name << " parent=" << layerIdToString(parentId)
327 << " relativeParent=" << layerIdToString(relativeParentId)
328 << " mirrorId=" << layerIdsToString(mirrorIds) << " handle=" << handleAlive << " z=" << z;
329 return debug.str();
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000330}
331
332std::string RequestedLayerState::getDebugStringShort() const {
333 return "[" + std::to_string(id) + "]" + name;
334}
335
336bool RequestedLayerState::canBeDestroyed() const {
337 return !handleAlive && parentId == UNASSIGNED_LAYER_ID;
338}
339bool RequestedLayerState::isRoot() const {
340 return canBeRoot && parentId == UNASSIGNED_LAYER_ID;
341}
342bool RequestedLayerState::isHiddenByPolicy() const {
343 return (flags & layer_state_t::eLayerHidden) == layer_state_t::eLayerHidden;
344};
345half4 RequestedLayerState::getColor() const {
346 if ((sidebandStream != nullptr) || (externalTexture != nullptr)) {
347 return {0._hf, 0._hf, 0._hf, color.a};
348 }
349 return color;
350}
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000351Rect RequestedLayerState::getBufferSize(uint32_t displayRotationFlags) const {
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000352 // for buffer state layers we use the display frame size as the buffer size.
353 if (!externalTexture) {
354 return Rect::INVALID_RECT;
355 }
356
357 uint32_t bufWidth = externalTexture->getWidth();
358 uint32_t bufHeight = externalTexture->getHeight();
359
360 // Undo any transformations on the buffer and return the result.
361 if (bufferTransform & ui::Transform::ROT_90) {
362 std::swap(bufWidth, bufHeight);
363 }
364
365 if (transformToDisplayInverse) {
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000366 uint32_t invTransform = displayRotationFlags;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000367 if (invTransform & ui::Transform::ROT_90) {
368 std::swap(bufWidth, bufHeight);
369 }
370 }
371
372 return Rect(0, 0, static_cast<int32_t>(bufWidth), static_cast<int32_t>(bufHeight));
373}
374
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000375Rect RequestedLayerState::getCroppedBufferSize(const Rect& bufferSize) const {
376 Rect size = bufferSize;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000377 if (!crop.isEmpty() && size.isValid()) {
378 size.intersect(crop, &size);
379 } else if (!crop.isEmpty()) {
380 size = crop;
381 }
382 return size;
383}
384
385Rect RequestedLayerState::getBufferCrop() const {
386 // this is the crop rectangle that applies to the buffer
387 // itself (as opposed to the window)
388 if (!bufferCrop.isEmpty()) {
389 // if the buffer crop is defined, we use that
390 return bufferCrop;
391 } else if (externalTexture != nullptr) {
392 // otherwise we use the whole buffer
393 return externalTexture->getBounds();
394 } else {
395 // if we don't have a buffer yet, we use an empty/invalid crop
396 return Rect();
397 }
398}
399
400aidl::android::hardware::graphics::composer3::Composition RequestedLayerState::getCompositionType()
401 const {
402 using aidl::android::hardware::graphics::composer3::Composition;
403 // TODO(b/238781169) check about sidestream ready flag
404 if (sidebandStream.get()) {
405 return Composition::SIDEBAND;
406 }
407 if (!externalTexture) {
408 return Composition::SOLID_COLOR;
409 }
410 if (flags & layer_state_t::eLayerIsDisplayDecoration) {
411 return Composition::DISPLAY_DECORATION;
412 }
413 if (potentialCursor) {
414 return Composition::CURSOR;
415 }
416 return Composition::DEVICE;
417}
418
419Rect RequestedLayerState::reduce(const Rect& win, const Region& exclude) {
420 if (CC_LIKELY(exclude.isEmpty())) {
421 return win;
422 }
423 if (exclude.isRect()) {
424 return win.reduce(exclude.getBounds());
425 }
426 return Region(win).subtract(exclude).getBounds();
427}
428
Vishnu Nair04f89692022-11-16 23:21:05 +0000429// Returns true if the layer has a relative parent that is not its own parent. This is an input
430// error from the client, and this check allows us to handle it gracefully. If both parentId and
431// relativeParentId is unassigned then the layer does not have a valid relative parent.
432// If the relative parentid is unassigned, the layer will be considered relative but won't be
433// reachable.
434bool RequestedLayerState::hasValidRelativeParent() const {
Vishnu Naircfb2d252023-01-19 04:44:02 +0000435 return isRelativeOf &&
436 (parentId != relativeParentId || relativeParentId == UNASSIGNED_LAYER_ID);
Vishnu Nair04f89692022-11-16 23:21:05 +0000437}
438
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000439bool RequestedLayerState::hasInputInfo() const {
440 if (!windowInfoHandle) {
441 return false;
442 }
443 const auto windowInfo = windowInfoHandle->getInfo();
444 return windowInfo->token != nullptr ||
445 windowInfo->inputConfig.test(gui::WindowInfo::InputConfig::NO_INPUT_CHANNEL);
446}
447
Vishnu Nair80a5a702023-02-11 01:21:51 +0000448bool RequestedLayerState::hasBlur() const {
449 return backgroundBlurRadius > 0 || blurRegions.size() > 0;
450}
451
Vishnu Naird47bcee2023-02-24 18:08:51 +0000452bool RequestedLayerState::hasFrameUpdate() const {
453 return what & layer_state_t::CONTENT_DIRTY &&
454 (externalTexture || bgColorLayerId != UNASSIGNED_LAYER_ID);
455}
456
457bool RequestedLayerState::hasReadyFrame() const {
458 return hasFrameUpdate() || changes.test(Changes::SidebandStream) || autoRefresh;
459}
460
461bool RequestedLayerState::hasSidebandStreamFrame() const {
462 return hasFrameUpdate() && sidebandStream.get();
463}
464
465void RequestedLayerState::clearChanges() {
466 what = 0;
467 changes.clear();
468}
469
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000470} // namespace android::surfaceflinger::frontend