blob: e2cbe28893df81569078805a8bc0800b4156dd9f [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 Nairdc4d31b2022-11-17 03:20:58 +000027#include "LayerHandle.h"
Vishnu Naircfb2d252023-01-19 04:44:02 +000028#include "LayerLog.h"
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000029#include "RequestedLayerState.h"
30
31namespace android::surfaceflinger::frontend {
32using ftl::Flags;
33using namespace ftl::flag_operators;
34
35namespace {
36uint32_t getLayerIdFromSurfaceControl(sp<SurfaceControl> surfaceControl) {
37 if (!surfaceControl) {
38 return UNASSIGNED_LAYER_ID;
39 }
40
41 return LayerHandle::getLayerId(surfaceControl->getHandle());
42}
43
44std::string layerIdToString(uint32_t layerId) {
Vishnu Nair04f89692022-11-16 23:21:05 +000045 return layerId == UNASSIGNED_LAYER_ID ? "none" : std::to_string(layerId);
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000046}
47
Vishnu Naira9c43762023-01-27 19:10:25 +000048std::string layerIdsToString(const std::vector<uint32_t>& layerIds) {
49 std::stringstream stream;
50 stream << "{";
51 for (auto layerId : layerIds) {
52 stream << layerId << ",";
53 }
54 stream << "}";
55 return stream.str();
56}
57
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000058} // namespace
59
60RequestedLayerState::RequestedLayerState(const LayerCreationArgs& args)
61 : id(args.sequence),
Vishnu Naircfb2d252023-01-19 04:44:02 +000062 name(args.name + "#" + std::to_string(args.sequence)),
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000063 canBeRoot(args.addToRoot),
64 layerCreationFlags(args.flags),
65 textureName(args.textureName),
66 ownerUid(args.ownerUid),
67 ownerPid(args.ownerPid) {
68 layerId = static_cast<int32_t>(args.sequence);
69 changes |= RequestedLayerState::Changes::Created;
70 metadata.merge(args.metadata);
71 changes |= RequestedLayerState::Changes::Metadata;
72 handleAlive = true;
73 parentId = LayerHandle::getLayerId(args.parentHandle.promote());
Vishnu Naircfb2d252023-01-19 04:44:02 +000074 if (args.parentHandle != nullptr) {
75 canBeRoot = false;
76 }
Vishnu Naira9c43762023-01-27 19:10:25 +000077 layerIdToMirror = LayerHandle::getLayerId(args.mirrorLayerHandle.promote());
78 if (layerIdToMirror != UNASSIGNED_LAYER_ID) {
79 changes |= RequestedLayerState::Changes::Mirror;
80 } else if (args.layerStackToMirror != ui::INVALID_LAYER_STACK) {
81 layerStackToMirror = args.layerStackToMirror;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +000082 changes |= RequestedLayerState::Changes::Mirror;
83 }
84
85 flags = 0;
86 if (args.flags & ISurfaceComposerClient::eHidden) flags |= layer_state_t::eLayerHidden;
87 if (args.flags & ISurfaceComposerClient::eOpaque) flags |= layer_state_t::eLayerOpaque;
88 if (args.flags & ISurfaceComposerClient::eSecure) flags |= layer_state_t::eLayerSecure;
89 if (args.flags & ISurfaceComposerClient::eSkipScreenshot) {
90 flags |= layer_state_t::eLayerSkipScreenshot;
91 }
92 premultipliedAlpha = !(args.flags & ISurfaceComposerClient::eNonPremultiplied);
93 potentialCursor = args.flags & ISurfaceComposerClient::eCursorWindow;
94 protectedByApp = args.flags & ISurfaceComposerClient::eProtectedByApp;
95 if (args.flags & ISurfaceComposerClient::eNoColorFill) {
96 // Set an invalid color so there is no color fill.
97 // (b/259981098) use an explicit flag instead of relying on invalid values.
98 color.r = -1.0_hf;
99 color.g = -1.0_hf;
100 color.b = -1.0_hf;
101 } else {
102 color.rgb = {0.0_hf, 0.0_hf, 0.0_hf};
103 }
Vishnu Naircfb2d252023-01-19 04:44:02 +0000104 LLOGV(layerId, "Created %s flags=%d", getDebugString().c_str(), flags);
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000105 color.a = 1.0f;
106
107 crop.makeInvalid();
108 z = 0;
109 layerStack = ui::DEFAULT_LAYER_STACK;
110 transformToDisplayInverse = false;
111 dataspace = ui::Dataspace::UNKNOWN;
John Reck68796592023-01-25 13:47:12 -0500112 desiredSdrHdrRatio = 1.f;
113 currentSdrHdrRatio = 1.f;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000114 dataspaceRequested = false;
115 hdrMetadata.validTypes = 0;
116 surfaceDamageRegion = Region::INVALID_REGION;
117 cornerRadius = 0.0f;
118 backgroundBlurRadius = 0;
119 api = -1;
120 hasColorTransform = false;
121 bufferTransform = 0;
122 requestedTransform.reset();
123 bufferData = std::make_shared<BufferData>();
124 bufferData->frameNumber = 0;
125 bufferData->acquireFence = sp<Fence>::make(-1);
126 acquireFenceTime = std::make_shared<FenceTime>(bufferData->acquireFence);
127 colorSpaceAgnostic = false;
128 frameRateSelectionPriority = Layer::PRIORITY_UNSET;
129 shadowRadius = 0.f;
130 fixedTransformHint = ui::Transform::ROT_INVALID;
131 destinationFrame.makeInvalid();
132 isTrustedOverlay = false;
133 dropInputMode = gui::DropInputMode::NONE;
134 dimmingEnabled = true;
135 defaultFrameRateCompatibility =
136 static_cast<int8_t>(scheduler::LayerInfo::FrameRateCompatibility::Default);
137 dataspace = ui::Dataspace::V0_SRGB;
Vishnu Naircfb2d252023-01-19 04:44:02 +0000138 gameMode = gui::GameMode::Unsupported;
139 requestedFrameRate = {};
Alec Mourif4af03e2023-02-11 00:25:24 +0000140 cachingHint = gui::CachingHint::Enabled;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000141}
142
143void RequestedLayerState::merge(const ResolvedComposerState& resolvedComposerState) {
Vishnu Naircfb2d252023-01-19 04:44:02 +0000144 const uint32_t oldFlags = flags;
145 const half oldAlpha = color.a;
146 const bool hadBufferOrSideStream = hasValidBuffer() || sidebandStream != nullptr;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000147 const layer_state_t& clientState = resolvedComposerState.state;
Vishnu Nair80a5a702023-02-11 01:21:51 +0000148 const bool hadBlur = hasBlur();
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000149 uint64_t clientChanges = what | layer_state_t::diff(clientState);
150 layer_state_t::merge(clientState);
151 what = clientChanges;
152
153 if (clientState.what & layer_state_t::eFlagsChanged) {
154 if ((oldFlags ^ flags) & layer_state_t::eLayerHidden) {
Vishnu Naircfb2d252023-01-19 04:44:02 +0000155 changes |= RequestedLayerState::Changes::Visibility |
156 RequestedLayerState::Changes::VisibleRegion;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000157 }
158 if ((oldFlags ^ flags) & layer_state_t::eIgnoreDestinationFrame) {
159 changes |= RequestedLayerState::Changes::Geometry;
160 }
161 }
Vishnu Naircfb2d252023-01-19 04:44:02 +0000162 if (clientState.what &
163 (layer_state_t::eBufferChanged | layer_state_t::eSidebandStreamChanged)) {
164 const bool hasBufferOrSideStream = hasValidBuffer() || sidebandStream != nullptr;
165 if (hadBufferOrSideStream != hasBufferOrSideStream) {
166 changes |= RequestedLayerState::Changes::Geometry |
167 RequestedLayerState::Changes::VisibleRegion |
Vishnu Naird47bcee2023-02-24 18:08:51 +0000168 RequestedLayerState::Changes::Visibility | RequestedLayerState::Changes::Input;
169 }
170 if (clientState.what & layer_state_t::eBufferChanged) {
171 changes |= RequestedLayerState::Changes::Buffer;
172 }
173 if (clientState.what & layer_state_t::eSidebandStreamChanged) {
174 changes |= RequestedLayerState::Changes::SidebandStream;
Vishnu Naircfb2d252023-01-19 04:44:02 +0000175 }
176 }
177 if (what & (layer_state_t::eAlphaChanged)) {
178 if (oldAlpha == 0 || color.a == 0) {
179 changes |= RequestedLayerState::Changes::Visibility |
180 RequestedLayerState::Changes::VisibleRegion;
181 }
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000182 }
Vishnu Nair80a5a702023-02-11 01:21:51 +0000183 if (what & (layer_state_t::eBackgroundBlurRadiusChanged | layer_state_t::eBlurRegionsChanged)) {
184 if (hadBlur != hasBlur()) {
185 changes |= RequestedLayerState::Changes::Visibility |
186 RequestedLayerState::Changes::VisibleRegion;
187 }
188 }
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000189 if (clientChanges & layer_state_t::HIERARCHY_CHANGES)
190 changes |= RequestedLayerState::Changes::Hierarchy;
191 if (clientChanges & layer_state_t::CONTENT_CHANGES)
192 changes |= RequestedLayerState::Changes::Content;
193 if (clientChanges & layer_state_t::GEOMETRY_CHANGES)
194 changes |= RequestedLayerState::Changes::Geometry;
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000195 if (clientChanges & layer_state_t::AFFECTS_CHILDREN)
196 changes |= RequestedLayerState::Changes::AffectsChildren;
Vishnu Naircfb2d252023-01-19 04:44:02 +0000197 if (clientChanges & layer_state_t::INPUT_CHANGES)
198 changes |= RequestedLayerState::Changes::Input;
199 if (clientChanges & layer_state_t::VISIBLE_REGION_CHANGES)
200 changes |= RequestedLayerState::Changes::VisibleRegion;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000201 if (clientState.what & layer_state_t::eColorTransformChanged) {
202 static const mat4 identityMatrix = mat4();
203 hasColorTransform = colorTransform != identityMatrix;
204 }
Vishnu Naird47bcee2023-02-24 18:08:51 +0000205 if (clientState.what &
206 (layer_state_t::eLayerChanged | layer_state_t::eRelativeLayerChanged |
207 layer_state_t::eLayerStackChanged)) {
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000208 changes |= RequestedLayerState::Changes::Z;
209 }
210 if (clientState.what & layer_state_t::eReparent) {
211 changes |= RequestedLayerState::Changes::Parent;
212 parentId = getLayerIdFromSurfaceControl(clientState.parentSurfaceControlForChild);
213 parentSurfaceControlForChild = nullptr;
Vishnu Nair04f89692022-11-16 23:21:05 +0000214 // Once a layer has be reparented, it cannot be placed at the root. It sounds odd
215 // but thats the existing logic and until we make this behavior more explicit, we need
216 // to maintain this logic.
217 canBeRoot = false;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000218 }
219 if (clientState.what & layer_state_t::eRelativeLayerChanged) {
220 changes |= RequestedLayerState::Changes::RelativeParent;
221 relativeParentId = getLayerIdFromSurfaceControl(clientState.relativeLayerSurfaceControl);
222 isRelativeOf = true;
223 relativeLayerSurfaceControl = nullptr;
224 }
225 if ((clientState.what & layer_state_t::eLayerChanged ||
226 (clientState.what & layer_state_t::eReparent && parentId == UNASSIGNED_LAYER_ID)) &&
227 isRelativeOf) {
228 // clear out relz data
229 relativeParentId = UNASSIGNED_LAYER_ID;
230 isRelativeOf = false;
231 changes |= RequestedLayerState::Changes::RelativeParent;
232 }
233 if (clientState.what & layer_state_t::eReparent && parentId == relativeParentId) {
234 // provide a hint that we are are now a direct child and not a relative child.
235 changes |= RequestedLayerState::Changes::RelativeParent;
236 }
237 if (clientState.what & layer_state_t::eInputInfoChanged) {
238 wp<IBinder>& touchableRegionCropHandle =
239 windowInfoHandle->editInfo()->touchableRegionCropHandle;
240 touchCropId = LayerHandle::getLayerId(touchableRegionCropHandle.promote());
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000241 touchableRegionCropHandle.clear();
242 }
243 if (clientState.what & layer_state_t::eStretchChanged) {
244 stretchEffect.sanitize();
245 }
246
247 if (clientState.what & layer_state_t::eHasListenerCallbacksChanged) {
248 // TODO(b/238781169) handle callbacks
249 }
250
251 if (clientState.what & layer_state_t::eBufferChanged) {
252 externalTexture = resolvedComposerState.externalTexture;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000253 }
254
255 if (clientState.what & layer_state_t::ePositionChanged) {
256 requestedTransform.set(x, y);
257 }
258
259 if (clientState.what & layer_state_t::eMatrixChanged) {
260 requestedTransform.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy);
261 }
Vishnu Naircfb2d252023-01-19 04:44:02 +0000262 if (clientState.what & layer_state_t::eMetadataChanged) {
263 const int32_t requestedGameMode =
264 clientState.metadata.getInt32(gui::METADATA_GAME_MODE, -1);
265 if (requestedGameMode != -1) {
266 // The transaction will be received on the Task layer and needs to be applied to all
267 // child layers.
268 if (static_cast<int32_t>(gameMode) != requestedGameMode) {
269 gameMode = static_cast<gui::GameMode>(requestedGameMode);
270 changes |= RequestedLayerState::Changes::AffectsChildren;
271 }
272 }
273 }
274 if (clientState.what & layer_state_t::eFrameRateChanged) {
275 const auto compatibility =
276 Layer::FrameRate::convertCompatibility(clientState.frameRateCompatibility);
277 const auto strategy = Layer::FrameRate::convertChangeFrameRateStrategy(
278 clientState.changeFrameRateStrategy);
279 requestedFrameRate =
280 Layer::FrameRate(Fps::fromValue(clientState.frameRate), compatibility, strategy);
281 changes |= RequestedLayerState::Changes::FrameRate;
282 }
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000283}
284
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000285ui::Size RequestedLayerState::getUnrotatedBufferSize(uint32_t displayRotationFlags) const {
286 uint32_t bufferWidth = externalTexture->getWidth();
287 uint32_t bufferHeight = externalTexture->getHeight();
288 // Undo any transformations on the buffer.
289 if (bufferTransform & ui::Transform::ROT_90) {
290 std::swap(bufferWidth, bufferHeight);
291 }
292 if (transformToDisplayInverse) {
293 if (displayRotationFlags & ui::Transform::ROT_90) {
294 std::swap(bufferWidth, bufferHeight);
295 }
296 }
297 return {bufferWidth, bufferHeight};
298}
299
300ui::Transform RequestedLayerState::getTransform(uint32_t displayRotationFlags) const {
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000301 if ((flags & layer_state_t::eIgnoreDestinationFrame) || destinationFrame.isEmpty()) {
302 // If destination frame is not set, use the requested transform set via
303 // Transaction::setPosition and Transaction::setMatrix.
304 return requestedTransform;
305 }
306
307 Rect destRect = destinationFrame;
308 int32_t destW = destRect.width();
309 int32_t destH = destRect.height();
310 if (destRect.left < 0) {
311 destRect.left = 0;
312 destRect.right = destW;
313 }
314 if (destRect.top < 0) {
315 destRect.top = 0;
316 destRect.bottom = destH;
317 }
318
319 if (!externalTexture) {
320 ui::Transform transform;
321 transform.set(static_cast<float>(destRect.left), static_cast<float>(destRect.top));
322 return transform;
323 }
324
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000325 ui::Size bufferSize = getUnrotatedBufferSize(displayRotationFlags);
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000326
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000327 float sx = static_cast<float>(destW) / static_cast<float>(bufferSize.width);
328 float sy = static_cast<float>(destH) / static_cast<float>(bufferSize.height);
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000329 ui::Transform transform;
330 transform.set(sx, 0, 0, sy);
331 transform.set(static_cast<float>(destRect.left), static_cast<float>(destRect.top));
332 return transform;
333}
334
335std::string RequestedLayerState::getDebugString() const {
Vishnu Nair80a5a702023-02-11 01:21:51 +0000336 std::stringstream debug;
337 debug << "RequestedLayerState{" << name << " parent=" << layerIdToString(parentId)
338 << " relativeParent=" << layerIdToString(relativeParentId)
339 << " mirrorId=" << layerIdsToString(mirrorIds) << " handle=" << handleAlive << " z=" << z;
340 return debug.str();
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000341}
342
343std::string RequestedLayerState::getDebugStringShort() const {
344 return "[" + std::to_string(id) + "]" + name;
345}
346
347bool RequestedLayerState::canBeDestroyed() const {
348 return !handleAlive && parentId == UNASSIGNED_LAYER_ID;
349}
350bool RequestedLayerState::isRoot() const {
351 return canBeRoot && parentId == UNASSIGNED_LAYER_ID;
352}
353bool RequestedLayerState::isHiddenByPolicy() const {
354 return (flags & layer_state_t::eLayerHidden) == layer_state_t::eLayerHidden;
355};
356half4 RequestedLayerState::getColor() const {
357 if ((sidebandStream != nullptr) || (externalTexture != nullptr)) {
358 return {0._hf, 0._hf, 0._hf, color.a};
359 }
360 return color;
361}
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000362Rect RequestedLayerState::getBufferSize(uint32_t displayRotationFlags) const {
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000363 // for buffer state layers we use the display frame size as the buffer size.
364 if (!externalTexture) {
365 return Rect::INVALID_RECT;
366 }
367
368 uint32_t bufWidth = externalTexture->getWidth();
369 uint32_t bufHeight = externalTexture->getHeight();
370
371 // Undo any transformations on the buffer and return the result.
372 if (bufferTransform & ui::Transform::ROT_90) {
373 std::swap(bufWidth, bufHeight);
374 }
375
376 if (transformToDisplayInverse) {
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000377 uint32_t invTransform = displayRotationFlags;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000378 if (invTransform & ui::Transform::ROT_90) {
379 std::swap(bufWidth, bufHeight);
380 }
381 }
382
383 return Rect(0, 0, static_cast<int32_t>(bufWidth), static_cast<int32_t>(bufHeight));
384}
385
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000386Rect RequestedLayerState::getCroppedBufferSize(const Rect& bufferSize) const {
387 Rect size = bufferSize;
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000388 if (!crop.isEmpty() && size.isValid()) {
389 size.intersect(crop, &size);
390 } else if (!crop.isEmpty()) {
391 size = crop;
392 }
393 return size;
394}
395
396Rect RequestedLayerState::getBufferCrop() const {
397 // this is the crop rectangle that applies to the buffer
398 // itself (as opposed to the window)
399 if (!bufferCrop.isEmpty()) {
400 // if the buffer crop is defined, we use that
401 return bufferCrop;
402 } else if (externalTexture != nullptr) {
403 // otherwise we use the whole buffer
404 return externalTexture->getBounds();
405 } else {
406 // if we don't have a buffer yet, we use an empty/invalid crop
407 return Rect();
408 }
409}
410
411aidl::android::hardware::graphics::composer3::Composition RequestedLayerState::getCompositionType()
412 const {
413 using aidl::android::hardware::graphics::composer3::Composition;
414 // TODO(b/238781169) check about sidestream ready flag
415 if (sidebandStream.get()) {
416 return Composition::SIDEBAND;
417 }
418 if (!externalTexture) {
419 return Composition::SOLID_COLOR;
420 }
421 if (flags & layer_state_t::eLayerIsDisplayDecoration) {
422 return Composition::DISPLAY_DECORATION;
423 }
424 if (potentialCursor) {
425 return Composition::CURSOR;
426 }
427 return Composition::DEVICE;
428}
429
430Rect RequestedLayerState::reduce(const Rect& win, const Region& exclude) {
431 if (CC_LIKELY(exclude.isEmpty())) {
432 return win;
433 }
434 if (exclude.isRect()) {
435 return win.reduce(exclude.getBounds());
436 }
437 return Region(win).subtract(exclude).getBounds();
438}
439
Vishnu Nair04f89692022-11-16 23:21:05 +0000440// Returns true if the layer has a relative parent that is not its own parent. This is an input
441// error from the client, and this check allows us to handle it gracefully. If both parentId and
442// relativeParentId is unassigned then the layer does not have a valid relative parent.
443// If the relative parentid is unassigned, the layer will be considered relative but won't be
444// reachable.
445bool RequestedLayerState::hasValidRelativeParent() const {
Vishnu Naircfb2d252023-01-19 04:44:02 +0000446 return isRelativeOf &&
447 (parentId != relativeParentId || relativeParentId == UNASSIGNED_LAYER_ID);
Vishnu Nair04f89692022-11-16 23:21:05 +0000448}
449
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000450bool RequestedLayerState::hasInputInfo() const {
451 if (!windowInfoHandle) {
452 return false;
453 }
454 const auto windowInfo = windowInfoHandle->getInfo();
455 return windowInfo->token != nullptr ||
456 windowInfo->inputConfig.test(gui::WindowInfo::InputConfig::NO_INPUT_CHANNEL);
457}
458
Vishnu Nair80a5a702023-02-11 01:21:51 +0000459bool RequestedLayerState::hasBlur() const {
460 return backgroundBlurRadius > 0 || blurRegions.size() > 0;
461}
462
Vishnu Naird47bcee2023-02-24 18:08:51 +0000463bool RequestedLayerState::hasFrameUpdate() const {
464 return what & layer_state_t::CONTENT_DIRTY &&
465 (externalTexture || bgColorLayerId != UNASSIGNED_LAYER_ID);
466}
467
468bool RequestedLayerState::hasReadyFrame() const {
469 return hasFrameUpdate() || changes.test(Changes::SidebandStream) || autoRefresh;
470}
471
472bool RequestedLayerState::hasSidebandStreamFrame() const {
473 return hasFrameUpdate() && sidebandStream.get();
474}
475
476void RequestedLayerState::clearChanges() {
477 what = 0;
478 changes.clear();
479}
480
Vishnu Nairdc4d31b2022-11-17 03:20:58 +0000481} // namespace android::surfaceflinger::frontend