blob: 962dc096803901074b303d5b4779ce853ea3fe4f [file] [log] [blame]
Vishnu Nair04f89692022-11-16 23:21:05 +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
17#define ATRACE_TAG ATRACE_TAG_GRAPHICS
18#undef LOG_TAG
Vishnu Naira02943f2023-06-03 13:44:46 -070019#define LOG_TAG "SurfaceFlinger"
Vishnu Nair04f89692022-11-16 23:21:05 +000020
21#include "LayerHierarchy.h"
Vishnu Nair80a5a702023-02-11 01:21:51 +000022#include "LayerLog.h"
Vishnu Nair04f89692022-11-16 23:21:05 +000023#include "SwapErase.h"
24
25namespace android::surfaceflinger::frontend {
26
27namespace {
28auto layerZCompare = [](const std::pair<LayerHierarchy*, LayerHierarchy::Variant>& lhs,
29 const std::pair<LayerHierarchy*, LayerHierarchy::Variant>& rhs) {
30 auto lhsLayer = lhs.first->getLayer();
31 auto rhsLayer = rhs.first->getLayer();
Vishnu Naircfb2d252023-01-19 04:44:02 +000032 if (lhsLayer->layerStack.id != rhsLayer->layerStack.id) {
Vishnu Nair444f3952023-04-11 13:01:02 -070033 return lhsLayer->layerStack.id < rhsLayer->layerStack.id;
Vishnu Nair04f89692022-11-16 23:21:05 +000034 }
35 if (lhsLayer->z != rhsLayer->z) {
36 return lhsLayer->z < rhsLayer->z;
37 }
38 return lhsLayer->id < rhsLayer->id;
39};
40
41void insertSorted(std::vector<std::pair<LayerHierarchy*, LayerHierarchy::Variant>>& vec,
42 std::pair<LayerHierarchy*, LayerHierarchy::Variant> value) {
43 auto it = std::upper_bound(vec.begin(), vec.end(), value, layerZCompare);
44 vec.insert(it, std::move(value));
45}
46} // namespace
47
48LayerHierarchy::LayerHierarchy(RequestedLayerState* layer) : mLayer(layer) {}
49
50LayerHierarchy::LayerHierarchy(const LayerHierarchy& hierarchy, bool childrenOnly) {
51 mLayer = (childrenOnly) ? nullptr : hierarchy.mLayer;
52 mChildren = hierarchy.mChildren;
53}
54
55void LayerHierarchy::traverse(const Visitor& visitor,
56 LayerHierarchy::TraversalPath& traversalPath) const {
57 if (mLayer) {
58 bool breakTraversal = !visitor(*this, traversalPath);
59 if (breakTraversal) {
60 return;
61 }
62 }
Vishnu Nair606d9d02023-08-19 14:20:18 -070063
64 LLOG_ALWAYS_FATAL_WITH_TRACE_IF(traversalPath.hasRelZLoop(), "Found relative z loop layerId:%d",
65 traversalPath.invalidRelativeRootId);
Vishnu Nair04f89692022-11-16 23:21:05 +000066 for (auto& [child, childVariant] : mChildren) {
67 ScopedAddToTraversalPath addChildToTraversalPath(traversalPath, child->mLayer->id,
68 childVariant);
69 child->traverse(visitor, traversalPath);
70 }
71}
72
73void LayerHierarchy::traverseInZOrder(const Visitor& visitor,
74 LayerHierarchy::TraversalPath& traversalPath) const {
75 bool traverseThisLayer = (mLayer != nullptr);
76 for (auto it = mChildren.begin(); it < mChildren.end(); it++) {
77 auto& [child, childVariant] = *it;
78 if (traverseThisLayer && child->getLayer()->z >= 0) {
Vishnu Naircfb2d252023-01-19 04:44:02 +000079 traverseThisLayer = false;
Vishnu Nair04f89692022-11-16 23:21:05 +000080 bool breakTraversal = !visitor(*this, traversalPath);
81 if (breakTraversal) {
82 return;
83 }
Vishnu Nair04f89692022-11-16 23:21:05 +000084 }
85 if (childVariant == LayerHierarchy::Variant::Detached) {
86 continue;
87 }
88 ScopedAddToTraversalPath addChildToTraversalPath(traversalPath, child->mLayer->id,
89 childVariant);
90 child->traverseInZOrder(visitor, traversalPath);
91 }
92
93 if (traverseThisLayer) {
94 visitor(*this, traversalPath);
95 }
96}
97
98void LayerHierarchy::addChild(LayerHierarchy* child, LayerHierarchy::Variant variant) {
99 insertSorted(mChildren, {child, variant});
100}
101
102void LayerHierarchy::removeChild(LayerHierarchy* child) {
103 auto it = std::find_if(mChildren.begin(), mChildren.end(),
104 [child](const std::pair<LayerHierarchy*, Variant>& x) {
105 return x.first == child;
106 });
Vishnu Nair606d9d02023-08-19 14:20:18 -0700107 LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mChildren.end(), "Could not find child!");
Vishnu Nair04f89692022-11-16 23:21:05 +0000108 mChildren.erase(it);
109}
110
111void LayerHierarchy::sortChildrenByZOrder() {
112 std::sort(mChildren.begin(), mChildren.end(), layerZCompare);
113}
114
115void LayerHierarchy::updateChild(LayerHierarchy* hierarchy, LayerHierarchy::Variant variant) {
116 auto it = std::find_if(mChildren.begin(), mChildren.end(),
117 [hierarchy](std::pair<LayerHierarchy*, Variant>& child) {
118 return child.first == hierarchy;
119 });
Vishnu Nair606d9d02023-08-19 14:20:18 -0700120 LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mChildren.end(), "Could not find child!");
121 it->second = variant;
Vishnu Nair04f89692022-11-16 23:21:05 +0000122}
123
124const RequestedLayerState* LayerHierarchy::getLayer() const {
125 return mLayer;
126}
127
Vishnu Nairea6ff812023-02-27 17:41:39 +0000128const LayerHierarchy* LayerHierarchy::getRelativeParent() const {
129 return mRelativeParent;
130}
131
132const LayerHierarchy* LayerHierarchy::getParent() const {
133 return mParent;
134}
135
Vishnu Nair04f89692022-11-16 23:21:05 +0000136std::string LayerHierarchy::getDebugStringShort() const {
137 std::string debug = "LayerHierarchy{";
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000138 debug += ((mLayer) ? mLayer->getDebugString() : "root") + " ";
Vishnu Nair04f89692022-11-16 23:21:05 +0000139 if (mChildren.empty()) {
140 debug += "no children";
141 } else {
142 debug += std::to_string(mChildren.size()) + " children";
143 }
144 return debug + "}";
145}
146
Vishnu Nair3cc15a42023-06-30 06:20:22 +0000147void LayerHierarchy::dump(std::ostream& out, const std::string& prefix,
148 LayerHierarchy::Variant variant, bool isLastChild) const {
149 if (!mLayer) {
150 out << " ROOT";
151 } else {
152 out << prefix + (isLastChild ? "└─ " : "├─ ");
153 if (variant == LayerHierarchy::Variant::Relative) {
154 out << "(Relative) ";
155 } else if (variant == LayerHierarchy::Variant::Mirror) {
156 out << "(Mirroring) " << *mLayer << "\n" + prefix + " └─ ...";
157 return;
158 }
159 out << *mLayer;
Vishnu Nair04f89692022-11-16 23:21:05 +0000160 }
Vishnu Nair3cc15a42023-06-30 06:20:22 +0000161
162 for (size_t i = 0; i < mChildren.size(); i++) {
163 auto& [child, childVariant] = mChildren[i];
164 if (childVariant == LayerHierarchy::Variant::Detached) continue;
165 const bool lastChild = i == (mChildren.size() - 1);
166 std::string childPrefix = prefix;
167 if (mLayer) {
168 childPrefix += (isLastChild ? " " : "│ ");
169 }
170 out << "\n";
171 child->dump(out, childPrefix, childVariant, lastChild);
172 }
173 return;
Vishnu Nair04f89692022-11-16 23:21:05 +0000174}
175
176bool LayerHierarchy::hasRelZLoop(uint32_t& outInvalidRelativeRoot) const {
177 outInvalidRelativeRoot = UNASSIGNED_LAYER_ID;
178 traverse([&outInvalidRelativeRoot](const LayerHierarchy&,
179 const LayerHierarchy::TraversalPath& traversalPath) -> bool {
180 if (traversalPath.hasRelZLoop()) {
181 outInvalidRelativeRoot = traversalPath.invalidRelativeRootId;
182 return false;
183 }
184 return true;
185 });
186 return outInvalidRelativeRoot != UNASSIGNED_LAYER_ID;
187}
188
189LayerHierarchyBuilder::LayerHierarchyBuilder(
190 const std::vector<std::unique_ptr<RequestedLayerState>>& layers) {
191 mHierarchies.reserve(layers.size());
192 mLayerIdToHierarchy.reserve(layers.size());
193 for (auto& layer : layers) {
194 mHierarchies.emplace_back(std::make_unique<LayerHierarchy>(layer.get()));
195 mLayerIdToHierarchy[layer->id] = mHierarchies.back().get();
196 }
197 for (const auto& layer : layers) {
198 onLayerAdded(layer.get());
199 }
200 detachHierarchyFromRelativeParent(&mOffscreenRoot);
201}
202
203void LayerHierarchyBuilder::attachToParent(LayerHierarchy* hierarchy) {
204 auto layer = hierarchy->mLayer;
205 LayerHierarchy::Variant type = layer->hasValidRelativeParent()
206 ? LayerHierarchy::Variant::Detached
207 : LayerHierarchy::Variant::Attached;
208
209 LayerHierarchy* parent;
210
211 if (layer->parentId != UNASSIGNED_LAYER_ID) {
212 parent = getHierarchyFromId(layer->parentId);
213 } else if (layer->canBeRoot) {
214 parent = &mRoot;
215 } else {
216 parent = &mOffscreenRoot;
217 }
218 parent->addChild(hierarchy, type);
219 hierarchy->mParent = parent;
220}
221
222void LayerHierarchyBuilder::detachFromParent(LayerHierarchy* hierarchy) {
223 hierarchy->mParent->removeChild(hierarchy);
224 hierarchy->mParent = nullptr;
225}
226
227void LayerHierarchyBuilder::attachToRelativeParent(LayerHierarchy* hierarchy) {
228 auto layer = hierarchy->mLayer;
229 if (!layer->hasValidRelativeParent() || hierarchy->mRelativeParent) {
230 return;
231 }
232
233 if (layer->relativeParentId != UNASSIGNED_LAYER_ID) {
234 hierarchy->mRelativeParent = getHierarchyFromId(layer->relativeParentId);
235 } else {
236 hierarchy->mRelativeParent = &mOffscreenRoot;
237 }
238 hierarchy->mRelativeParent->addChild(hierarchy, LayerHierarchy::Variant::Relative);
239 hierarchy->mParent->updateChild(hierarchy, LayerHierarchy::Variant::Detached);
240}
241
242void LayerHierarchyBuilder::detachFromRelativeParent(LayerHierarchy* hierarchy) {
243 if (hierarchy->mRelativeParent) {
244 hierarchy->mRelativeParent->removeChild(hierarchy);
245 }
246 hierarchy->mRelativeParent = nullptr;
247 hierarchy->mParent->updateChild(hierarchy, LayerHierarchy::Variant::Attached);
248}
249
250void LayerHierarchyBuilder::attachHierarchyToRelativeParent(LayerHierarchy* root) {
251 if (root->mLayer) {
252 attachToRelativeParent(root);
253 }
254 for (auto& [child, childVariant] : root->mChildren) {
255 if (childVariant == LayerHierarchy::Variant::Detached ||
256 childVariant == LayerHierarchy::Variant::Attached) {
257 attachHierarchyToRelativeParent(child);
258 }
259 }
260}
261
262void LayerHierarchyBuilder::detachHierarchyFromRelativeParent(LayerHierarchy* root) {
263 if (root->mLayer) {
264 detachFromRelativeParent(root);
265 }
266 for (auto& [child, childVariant] : root->mChildren) {
267 if (childVariant == LayerHierarchy::Variant::Detached ||
268 childVariant == LayerHierarchy::Variant::Attached) {
269 detachHierarchyFromRelativeParent(child);
270 }
271 }
272}
273
274void LayerHierarchyBuilder::onLayerAdded(RequestedLayerState* layer) {
275 LayerHierarchy* hierarchy = getHierarchyFromId(layer->id);
276 attachToParent(hierarchy);
277 attachToRelativeParent(hierarchy);
278
Vishnu Naira9c43762023-01-27 19:10:25 +0000279 for (uint32_t mirrorId : layer->mirrorIds) {
280 LayerHierarchy* mirror = getHierarchyFromId(mirrorId);
Vishnu Nair04f89692022-11-16 23:21:05 +0000281 hierarchy->addChild(mirror, LayerHierarchy::Variant::Mirror);
282 }
283}
284
285void LayerHierarchyBuilder::onLayerDestroyed(RequestedLayerState* layer) {
Vishnu Nair80a5a702023-02-11 01:21:51 +0000286 LLOGV(layer->id, "");
Vishnu Nair04f89692022-11-16 23:21:05 +0000287 LayerHierarchy* hierarchy = getHierarchyFromId(layer->id, /*crashOnFailure=*/false);
288 if (!hierarchy) {
289 // Layer was never part of the hierarchy if it was created and destroyed in the same
290 // transaction.
291 return;
292 }
293 // detach from parent
294 detachFromRelativeParent(hierarchy);
295 detachFromParent(hierarchy);
296
297 // detach children
298 for (auto& [child, variant] : hierarchy->mChildren) {
299 if (variant == LayerHierarchy::Variant::Attached ||
300 variant == LayerHierarchy::Variant::Detached) {
301 mOffscreenRoot.addChild(child, LayerHierarchy::Variant::Attached);
302 child->mParent = &mOffscreenRoot;
303 } else if (variant == LayerHierarchy::Variant::Relative) {
304 mOffscreenRoot.addChild(child, LayerHierarchy::Variant::Attached);
305 child->mRelativeParent = &mOffscreenRoot;
306 }
307 }
308
309 swapErase(mHierarchies, [hierarchy](std::unique_ptr<LayerHierarchy>& layerHierarchy) {
310 return layerHierarchy.get() == hierarchy;
311 });
312 mLayerIdToHierarchy.erase(layer->id);
313}
314
315void LayerHierarchyBuilder::updateMirrorLayer(RequestedLayerState* layer) {
316 LayerHierarchy* hierarchy = getHierarchyFromId(layer->id);
317 auto it = hierarchy->mChildren.begin();
318 while (it != hierarchy->mChildren.end()) {
319 if (it->second == LayerHierarchy::Variant::Mirror) {
Vishnu Naira9c43762023-01-27 19:10:25 +0000320 it = hierarchy->mChildren.erase(it);
321 } else {
322 it++;
Vishnu Nair04f89692022-11-16 23:21:05 +0000323 }
Vishnu Nair04f89692022-11-16 23:21:05 +0000324 }
325
Vishnu Naira9c43762023-01-27 19:10:25 +0000326 for (uint32_t mirrorId : layer->mirrorIds) {
327 hierarchy->addChild(getHierarchyFromId(mirrorId), LayerHierarchy::Variant::Mirror);
Vishnu Nair04f89692022-11-16 23:21:05 +0000328 }
329}
330
331void LayerHierarchyBuilder::update(
332 const std::vector<std::unique_ptr<RequestedLayerState>>& layers,
333 const std::vector<std::unique_ptr<RequestedLayerState>>& destroyedLayers) {
334 // rebuild map
335 for (auto& layer : layers) {
336 if (layer->changes.test(RequestedLayerState::Changes::Created)) {
337 mHierarchies.emplace_back(std::make_unique<LayerHierarchy>(layer.get()));
338 mLayerIdToHierarchy[layer->id] = mHierarchies.back().get();
339 }
340 }
341
342 for (auto& layer : layers) {
343 if (layer->changes.get() == 0) {
344 continue;
345 }
346 if (layer->changes.test(RequestedLayerState::Changes::Created)) {
347 onLayerAdded(layer.get());
348 continue;
349 }
350 LayerHierarchy* hierarchy = getHierarchyFromId(layer->id);
351 if (layer->changes.test(RequestedLayerState::Changes::Parent)) {
352 detachFromParent(hierarchy);
353 attachToParent(hierarchy);
354 }
355 if (layer->changes.test(RequestedLayerState::Changes::RelativeParent)) {
356 detachFromRelativeParent(hierarchy);
357 attachToRelativeParent(hierarchy);
358 }
359 if (layer->changes.test(RequestedLayerState::Changes::Z)) {
360 hierarchy->mParent->sortChildrenByZOrder();
361 if (hierarchy->mRelativeParent) {
362 hierarchy->mRelativeParent->sortChildrenByZOrder();
363 }
364 }
365 if (layer->changes.test(RequestedLayerState::Changes::Mirror)) {
366 updateMirrorLayer(layer.get());
367 }
368 }
369
370 for (auto& layer : destroyedLayers) {
371 onLayerDestroyed(layer.get());
372 }
373 // When moving from onscreen to offscreen and vice versa, we need to attach and detach
374 // from our relative parents. This walks down both trees to do so. We can optimize this
375 // further by tracking onscreen, offscreen state in LayerHierarchy.
376 detachHierarchyFromRelativeParent(&mOffscreenRoot);
377 attachHierarchyToRelativeParent(&mRoot);
378}
379
380const LayerHierarchy& LayerHierarchyBuilder::getHierarchy() const {
381 return mRoot;
382}
383
384const LayerHierarchy& LayerHierarchyBuilder::getOffscreenHierarchy() const {
385 return mOffscreenRoot;
386}
387
388std::string LayerHierarchyBuilder::getDebugString(uint32_t layerId, uint32_t depth) const {
389 if (depth > 10) return "too deep, loop?";
390 if (layerId == UNASSIGNED_LAYER_ID) return "";
391 auto it = mLayerIdToHierarchy.find(layerId);
392 if (it == mLayerIdToHierarchy.end()) return "not found";
393
394 LayerHierarchy* hierarchy = it->second;
395 if (!hierarchy->mLayer) return "none";
396
397 std::string debug =
398 "[" + std::to_string(hierarchy->mLayer->id) + "] " + hierarchy->mLayer->name;
399 if (hierarchy->mRelativeParent) {
400 debug += " Relative:" + hierarchy->mRelativeParent->getDebugStringShort();
401 }
402 if (hierarchy->mParent) {
403 debug += " Parent:" + hierarchy->mParent->getDebugStringShort();
404 }
405 return debug;
406}
407
408LayerHierarchy LayerHierarchyBuilder::getPartialHierarchy(uint32_t layerId,
409 bool childrenOnly) const {
410 auto it = mLayerIdToHierarchy.find(layerId);
411 if (it == mLayerIdToHierarchy.end()) return {nullptr};
412
413 LayerHierarchy hierarchy(*it->second, childrenOnly);
414 return hierarchy;
415}
416
417LayerHierarchy* LayerHierarchyBuilder::getHierarchyFromId(uint32_t layerId, bool crashOnFailure) {
418 auto it = mLayerIdToHierarchy.find(layerId);
419 if (it == mLayerIdToHierarchy.end()) {
Vishnu Nair606d9d02023-08-19 14:20:18 -0700420 LLOG_ALWAYS_FATAL_WITH_TRACE_IF(crashOnFailure, "Could not find hierarchy for layer id %d",
421 layerId);
Vishnu Nair04f89692022-11-16 23:21:05 +0000422 return nullptr;
423 };
424
425 return it->second;
426}
427
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000428const LayerHierarchy::TraversalPath LayerHierarchy::TraversalPath::ROOT =
Vishnu Nair04f89692022-11-16 23:21:05 +0000429 {.id = UNASSIGNED_LAYER_ID, .variant = LayerHierarchy::Attached};
430
431std::string LayerHierarchy::TraversalPath::toString() const {
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000432 if (id == UNASSIGNED_LAYER_ID) {
433 return "TraversalPath{ROOT}";
434 }
Vishnu Nair80a5a702023-02-11 01:21:51 +0000435 std::stringstream ss;
436 ss << "TraversalPath{.id = " << id;
Vishnu Nair04f89692022-11-16 23:21:05 +0000437
Vishnu Nair80a5a702023-02-11 01:21:51 +0000438 if (mirrorRootId != UNASSIGNED_LAYER_ID) {
439 ss << ", .mirrorRootId=" << mirrorRootId;
Vishnu Nair04f89692022-11-16 23:21:05 +0000440 }
441
442 if (!relativeRootIds.empty()) {
Vishnu Nair80a5a702023-02-11 01:21:51 +0000443 ss << ", .relativeRootIds=";
Vishnu Nair04f89692022-11-16 23:21:05 +0000444 for (auto rootId : relativeRootIds) {
Vishnu Nair80a5a702023-02-11 01:21:51 +0000445 ss << rootId << ",";
Vishnu Nair04f89692022-11-16 23:21:05 +0000446 }
447 }
448
449 if (hasRelZLoop()) {
Vishnu Nair80a5a702023-02-11 01:21:51 +0000450 ss << "hasRelZLoop=true invalidRelativeRootId=" << invalidRelativeRootId << ",";
Vishnu Nair04f89692022-11-16 23:21:05 +0000451 }
Vishnu Nair80a5a702023-02-11 01:21:51 +0000452 ss << "}";
453 return ss.str();
454}
Vishnu Nair04f89692022-11-16 23:21:05 +0000455
Vishnu Nair80a5a702023-02-11 01:21:51 +0000456LayerHierarchy::TraversalPath LayerHierarchy::TraversalPath::getMirrorRoot() const {
Vishnu Nair606d9d02023-08-19 14:20:18 -0700457 LLOG_ALWAYS_FATAL_WITH_TRACE_IF(!isClone(), "Cannot get mirror root of a non cloned node");
Vishnu Nair80a5a702023-02-11 01:21:51 +0000458 TraversalPath mirrorRootPath = *this;
459 mirrorRootPath.id = mirrorRootId;
460 return mirrorRootPath;
Vishnu Nair04f89692022-11-16 23:21:05 +0000461}
462
463// Helper class to update a passed in TraversalPath when visiting a child. When the object goes out
464// of scope the TraversalPath is reset to its original state.
465LayerHierarchy::ScopedAddToTraversalPath::ScopedAddToTraversalPath(TraversalPath& traversalPath,
466 uint32_t layerId,
467 LayerHierarchy::Variant variant)
Vishnu Nair80a5a702023-02-11 01:21:51 +0000468 : mTraversalPath(traversalPath), mParentPath(traversalPath) {
Vishnu Nair04f89692022-11-16 23:21:05 +0000469 // Update the traversal id with the child layer id and variant. Parent id and variant are
470 // stored to reset the id upon destruction.
471 traversalPath.id = layerId;
472 traversalPath.variant = variant;
473 if (variant == LayerHierarchy::Variant::Mirror) {
Vishnu Nair92990e22023-02-24 20:01:05 +0000474 traversalPath.mirrorRootId = mParentPath.id;
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000475 } else if (variant == LayerHierarchy::Variant::Relative) {
Vishnu Nair04f89692022-11-16 23:21:05 +0000476 if (std::find(traversalPath.relativeRootIds.begin(), traversalPath.relativeRootIds.end(),
477 layerId) != traversalPath.relativeRootIds.end()) {
478 traversalPath.invalidRelativeRootId = layerId;
479 }
480 traversalPath.relativeRootIds.emplace_back(layerId);
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000481 } else if (variant == LayerHierarchy::Variant::Detached) {
482 traversalPath.detached = true;
Vishnu Nair04f89692022-11-16 23:21:05 +0000483 }
484}
485LayerHierarchy::ScopedAddToTraversalPath::~ScopedAddToTraversalPath() {
486 // Reset the traversal id to its original parent state using the state that was saved in
487 // the constructor.
488 if (mTraversalPath.variant == LayerHierarchy::Variant::Mirror) {
Vishnu Nair80a5a702023-02-11 01:21:51 +0000489 mTraversalPath.mirrorRootId = mParentPath.mirrorRootId;
Vishnu Nair8fc721b2022-12-22 20:06:32 +0000490 } else if (mTraversalPath.variant == LayerHierarchy::Variant::Relative) {
Vishnu Nair04f89692022-11-16 23:21:05 +0000491 mTraversalPath.relativeRootIds.pop_back();
492 }
493 if (mTraversalPath.invalidRelativeRootId == mTraversalPath.id) {
494 mTraversalPath.invalidRelativeRootId = UNASSIGNED_LAYER_ID;
495 }
Vishnu Nair80a5a702023-02-11 01:21:51 +0000496 mTraversalPath.id = mParentPath.id;
497 mTraversalPath.variant = mParentPath.variant;
498 mTraversalPath.detached = mParentPath.detached;
Vishnu Nair04f89692022-11-16 23:21:05 +0000499}
500
501} // namespace android::surfaceflinger::frontend