Vishnu Nair | 04f8969 | 2022-11-16 23:21:05 +0000 | [diff] [blame^] | 1 | /* |
| 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 | #include <gmock/gmock.h> |
| 18 | #include <gtest/gtest.h> |
| 19 | |
| 20 | #include "FrontEnd/LayerHandle.h" |
| 21 | #include "FrontEnd/LayerHierarchy.h" |
| 22 | #include "FrontEnd/LayerLifecycleManager.h" |
| 23 | #include "Layer.h" |
| 24 | #include "gui/SurfaceComposerClient.h" |
| 25 | |
| 26 | #define UPDATE_AND_VERIFY(HIERARCHY) \ |
| 27 | ({ \ |
| 28 | SCOPED_TRACE(""); \ |
| 29 | updateAndVerify((HIERARCHY)); \ |
| 30 | }) |
| 31 | |
| 32 | namespace android::surfaceflinger::frontend { |
| 33 | |
| 34 | namespace { |
| 35 | LayerCreationArgs createArgs(uint32_t id, bool canBeRoot, wp<IBinder> parent, wp<IBinder> mirror) { |
| 36 | LayerCreationArgs args(nullptr, nullptr, "testlayer", 0, {}, std::make_optional(id)); |
| 37 | args.addToRoot = canBeRoot; |
| 38 | args.parentHandle = parent; |
| 39 | args.mirrorLayerHandle = mirror; |
| 40 | return args; |
| 41 | } |
| 42 | } // namespace |
| 43 | |
| 44 | // To run test: |
| 45 | /** |
| 46 | mp :libsurfaceflinger_unittest && adb sync; adb shell \ |
| 47 | /data/nativetest/libsurfaceflinger_unittest/libsurfaceflinger_unittest \ |
| 48 | --gtest_filter="LayerHierarchyTest.*" --gtest_repeat=100 \ |
| 49 | --gtest_shuffle \ |
| 50 | --gtest_brief=1 |
| 51 | */ |
| 52 | |
| 53 | class LayerHierarchyTest : public testing::Test { |
| 54 | protected: |
| 55 | LayerHierarchyTest() { |
| 56 | // tree with 3 levels of children |
| 57 | // ROOT |
| 58 | // ├── 1 |
| 59 | // │ ├── 11 |
| 60 | // │ │ └── 111 |
| 61 | // │ ├── 12 |
| 62 | // │ │ ├── 121 |
| 63 | // │ │ └── 122 |
| 64 | // │ │ └── 1221 |
| 65 | // │ └── 13 |
| 66 | // └── 2 |
| 67 | |
| 68 | createRootLayer(1); |
| 69 | createRootLayer(2); |
| 70 | createLayer(11, 1); |
| 71 | createLayer(12, 1); |
| 72 | createLayer(13, 1); |
| 73 | createLayer(111, 11); |
| 74 | createLayer(121, 12); |
| 75 | createLayer(122, 12); |
| 76 | createLayer(1221, 122); |
| 77 | mLifecycleManager.commitChanges(); |
| 78 | } |
| 79 | std::vector<uint32_t> getTraversalPath(const LayerHierarchy& hierarchy) const { |
| 80 | std::vector<uint32_t> layerIds; |
| 81 | hierarchy.traverse([&layerIds = layerIds](const LayerHierarchy& hierarchy, |
| 82 | const LayerHierarchy::TraversalPath&) -> bool { |
| 83 | layerIds.emplace_back(hierarchy.getLayer()->id); |
| 84 | return true; |
| 85 | }); |
| 86 | return layerIds; |
| 87 | } |
| 88 | |
| 89 | std::vector<uint32_t> getTraversalPathInZOrder(const LayerHierarchy& hierarchy) const { |
| 90 | std::vector<uint32_t> layerIds; |
| 91 | hierarchy.traverseInZOrder( |
| 92 | [&layerIds = layerIds](const LayerHierarchy& hierarchy, |
| 93 | const LayerHierarchy::TraversalPath&) -> bool { |
| 94 | layerIds.emplace_back(hierarchy.getLayer()->id); |
| 95 | return true; |
| 96 | }); |
| 97 | return layerIds; |
| 98 | } |
| 99 | |
| 100 | void createRootLayer(uint32_t id) { |
| 101 | sp<LayerHandle> handle = sp<LayerHandle>::make(id); |
| 102 | mHandles[id] = handle; |
| 103 | std::vector<std::unique_ptr<RequestedLayerState>> layers; |
| 104 | layers.emplace_back(std::make_unique<RequestedLayerState>( |
| 105 | createArgs(/*id=*/id, /*canBeRoot=*/true, /*parent=*/nullptr, /*mirror=*/nullptr))); |
| 106 | mLifecycleManager.addLayers(std::move(layers)); |
| 107 | } |
| 108 | |
| 109 | void createLayer(uint32_t id, uint32_t parentId) { |
| 110 | sp<LayerHandle> handle = sp<LayerHandle>::make(id); |
| 111 | mHandles[id] = handle; |
| 112 | std::vector<std::unique_ptr<RequestedLayerState>> layers; |
| 113 | layers.emplace_back(std::make_unique<RequestedLayerState>( |
| 114 | createArgs(/*id=*/id, /*canBeRoot=*/false, /*parent=*/mHandles[parentId], |
| 115 | /*mirror=*/nullptr))); |
| 116 | mLifecycleManager.addLayers(std::move(layers)); |
| 117 | } |
| 118 | |
| 119 | void reparentLayer(uint32_t id, uint32_t newParentId) { |
| 120 | std::vector<TransactionState> transactions; |
| 121 | transactions.emplace_back(); |
| 122 | transactions.back().states.push_back({}); |
| 123 | |
| 124 | if (newParentId == UNASSIGNED_LAYER_ID) { |
| 125 | transactions.back().states.front().state.parentSurfaceControlForChild = nullptr; |
| 126 | } else { |
| 127 | auto parentHandle = mHandles[newParentId]; |
| 128 | transactions.back().states.front().state.parentSurfaceControlForChild = |
| 129 | sp<SurfaceControl>::make(SurfaceComposerClient::getDefault(), parentHandle, |
| 130 | static_cast<int32_t>(newParentId), "Test"); |
| 131 | } |
| 132 | transactions.back().states.front().state.what = layer_state_t::eReparent; |
| 133 | transactions.back().states.front().state.surface = mHandles[id]; |
| 134 | mLifecycleManager.applyTransactions(transactions); |
| 135 | } |
| 136 | |
| 137 | void reparentRelativeLayer(uint32_t id, uint32_t relativeParentId) { |
| 138 | std::vector<TransactionState> transactions; |
| 139 | transactions.emplace_back(); |
| 140 | transactions.back().states.push_back({}); |
| 141 | |
| 142 | if (relativeParentId == UNASSIGNED_LAYER_ID) { |
| 143 | transactions.back().states.front().state.what = layer_state_t::eLayerChanged; |
| 144 | } else { |
| 145 | auto parentHandle = mHandles[relativeParentId]; |
| 146 | transactions.back().states.front().state.relativeLayerSurfaceControl = |
| 147 | sp<SurfaceControl>::make(SurfaceComposerClient::getDefault(), parentHandle, |
| 148 | static_cast<int32_t>(relativeParentId), "test"); |
| 149 | transactions.back().states.front().state.what = layer_state_t::eRelativeLayerChanged; |
| 150 | } |
| 151 | transactions.back().states.front().state.surface = mHandles[id]; |
| 152 | mLifecycleManager.applyTransactions(transactions); |
| 153 | } |
| 154 | |
| 155 | void mirrorLayer(uint32_t id, uint32_t parent, uint32_t layerToMirror) { |
| 156 | auto parentHandle = (parent == UNASSIGNED_LAYER_ID) ? nullptr : mHandles[parent]; |
| 157 | auto mirrorHandle = |
| 158 | (layerToMirror == UNASSIGNED_LAYER_ID) ? nullptr : mHandles[layerToMirror]; |
| 159 | |
| 160 | sp<LayerHandle> handle = sp<LayerHandle>::make(id); |
| 161 | mHandles[id] = handle; |
| 162 | std::vector<std::unique_ptr<RequestedLayerState>> layers; |
| 163 | layers.emplace_back(std::make_unique<RequestedLayerState>( |
| 164 | createArgs(/*id=*/id, /*canBeRoot=*/false, /*parent=*/parentHandle, |
| 165 | /*mirror=*/mHandles[layerToMirror]))); |
| 166 | mLifecycleManager.addLayers(std::move(layers)); |
| 167 | } |
| 168 | |
| 169 | void updateBackgroundColor(uint32_t id, half alpha) { |
| 170 | std::vector<TransactionState> transactions; |
| 171 | transactions.emplace_back(); |
| 172 | transactions.back().states.push_back({}); |
| 173 | transactions.back().states.front().state.what = layer_state_t::eBackgroundColorChanged; |
| 174 | transactions.back().states.front().state.bgColorAlpha = alpha; |
| 175 | transactions.back().states.front().state.surface = mHandles[id]; |
| 176 | mLifecycleManager.applyTransactions(transactions); |
| 177 | } |
| 178 | |
| 179 | void destroyLayerHandle(uint32_t id) { mLifecycleManager.onHandlesDestroyed({id}); } |
| 180 | |
| 181 | void updateAndVerify(LayerHierarchyBuilder& hierarchyBuilder) { |
| 182 | if (mLifecycleManager.getGlobalChanges().test(RequestedLayerState::Changes::Hierarchy)) { |
| 183 | hierarchyBuilder.update(mLifecycleManager.getLayers(), |
| 184 | mLifecycleManager.getDestroyedLayers()); |
| 185 | } |
| 186 | mLifecycleManager.commitChanges(); |
| 187 | |
| 188 | // rebuild layer hierarchy from scratch and verify that it matches the updated state. |
| 189 | LayerHierarchyBuilder newBuilder(mLifecycleManager.getLayers()); |
| 190 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), |
| 191 | getTraversalPath(newBuilder.getHierarchy())); |
| 192 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), |
| 193 | getTraversalPathInZOrder(newBuilder.getHierarchy())); |
| 194 | EXPECT_FALSE( |
| 195 | mLifecycleManager.getGlobalChanges().test(RequestedLayerState::Changes::Hierarchy)); |
| 196 | } |
| 197 | |
| 198 | void setZ(uint32_t id, int32_t z) { |
| 199 | std::vector<TransactionState> transactions; |
| 200 | transactions.emplace_back(); |
| 201 | transactions.back().states.push_back({}); |
| 202 | |
| 203 | transactions.back().states.front().state.what = layer_state_t::eLayerChanged; |
| 204 | transactions.back().states.front().state.layerId = static_cast<int32_t>(id); |
| 205 | transactions.back().states.front().state.z = z; |
| 206 | mLifecycleManager.applyTransactions(transactions); |
| 207 | } |
| 208 | LayerLifecycleManager mLifecycleManager; |
| 209 | std::unordered_map<uint32_t, sp<LayerHandle>> mHandles; |
| 210 | }; |
| 211 | |
| 212 | // reparenting tests |
| 213 | TEST_F(LayerHierarchyTest, addLayer) { |
| 214 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 215 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 13, 2}; |
| 216 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 217 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 218 | expectedTraversalPath = {}; |
| 219 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 220 | |
| 221 | createRootLayer(3); |
| 222 | createLayer(112, 11); |
| 223 | createLayer(12211, 1221); |
| 224 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 225 | expectedTraversalPath = {1, 11, 111, 112, 12, 121, 122, 1221, 12211, 13, 2, 3}; |
| 226 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 227 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 228 | expectedTraversalPath = {}; |
| 229 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 230 | } |
| 231 | |
| 232 | TEST_F(LayerHierarchyTest, reparentLayer) { |
| 233 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 234 | reparentLayer(2, 11); |
| 235 | reparentLayer(111, 12); |
| 236 | reparentLayer(1221, 1); |
| 237 | reparentLayer(1221, 13); |
| 238 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 239 | |
| 240 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 2, 12, 111, 121, 122, 13, 1221}; |
| 241 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 242 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 243 | expectedTraversalPath = {}; |
| 244 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 245 | } |
| 246 | |
| 247 | TEST_F(LayerHierarchyTest, reparentLayerToNull) { |
| 248 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 249 | |
| 250 | reparentLayer(2, UNASSIGNED_LAYER_ID); |
| 251 | reparentLayer(11, UNASSIGNED_LAYER_ID); |
| 252 | reparentLayer(1221, 13); |
| 253 | reparentLayer(1221, UNASSIGNED_LAYER_ID); |
| 254 | |
| 255 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 256 | |
| 257 | std::vector<uint32_t> expectedTraversalPath = {1, 12, 121, 122, 13}; |
| 258 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 259 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 260 | expectedTraversalPath = {2, 11, 111, 1221}; |
| 261 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 262 | } |
| 263 | |
| 264 | TEST_F(LayerHierarchyTest, reparentLayerToNullAndDestroyHandles) { |
| 265 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 266 | reparentLayer(2, UNASSIGNED_LAYER_ID); |
| 267 | reparentLayer(11, UNASSIGNED_LAYER_ID); |
| 268 | reparentLayer(1221, UNASSIGNED_LAYER_ID); |
| 269 | |
| 270 | destroyLayerHandle(2); |
| 271 | destroyLayerHandle(11); |
| 272 | destroyLayerHandle(1221); |
| 273 | |
| 274 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 275 | |
| 276 | std::vector<uint32_t> expectedTraversalPath = {1, 12, 121, 122, 13}; |
| 277 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 278 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 279 | expectedTraversalPath = {111}; |
| 280 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 281 | } |
| 282 | |
| 283 | TEST_F(LayerHierarchyTest, destroyHandleThenDestroyParentLayer) { |
| 284 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 285 | destroyLayerHandle(111); |
| 286 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 287 | |
| 288 | // handle is destroyed but layer is kept alive and reachable by parent |
| 289 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 13, 2}; |
| 290 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 291 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 292 | expectedTraversalPath = {}; |
| 293 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 294 | |
| 295 | // destroy parent layer and the child gets destroyed |
| 296 | reparentLayer(11, UNASSIGNED_LAYER_ID); |
| 297 | destroyLayerHandle(11); |
| 298 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 299 | |
| 300 | expectedTraversalPath = {1, 12, 121, 122, 1221, 13, 2}; |
| 301 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 302 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 303 | expectedTraversalPath = {}; |
| 304 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 305 | } |
| 306 | |
| 307 | TEST_F(LayerHierarchyTest, layerSurvivesTemporaryReparentToNull) { |
| 308 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 309 | reparentLayer(11, UNASSIGNED_LAYER_ID); |
| 310 | reparentLayer(11, 1); |
| 311 | |
| 312 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 313 | |
| 314 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 13, 2}; |
| 315 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 316 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 317 | expectedTraversalPath = {}; |
| 318 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 319 | } |
| 320 | |
| 321 | // offscreen tests |
| 322 | TEST_F(LayerHierarchyTest, layerMovesOnscreen) { |
| 323 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 324 | |
| 325 | reparentLayer(11, UNASSIGNED_LAYER_ID); |
| 326 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 327 | |
| 328 | reparentLayer(11, 1); |
| 329 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 330 | |
| 331 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 13, 2}; |
| 332 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 333 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 334 | expectedTraversalPath = {}; |
| 335 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 336 | } |
| 337 | |
| 338 | TEST_F(LayerHierarchyTest, addLayerToOffscreenParent) { |
| 339 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 340 | |
| 341 | reparentLayer(11, UNASSIGNED_LAYER_ID); |
| 342 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 343 | |
| 344 | createLayer(112, 11); |
| 345 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 346 | |
| 347 | std::vector<uint32_t> expectedTraversalPath = {1, 12, 121, 122, 1221, 13, 2}; |
| 348 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 349 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 350 | expectedTraversalPath = {11, 111, 112}; |
| 351 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 352 | } |
| 353 | |
| 354 | // rel-z tests |
| 355 | TEST_F(LayerHierarchyTest, setRelativeParent) { |
| 356 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 357 | reparentRelativeLayer(11, 2); |
| 358 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 359 | |
| 360 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 13, 2, 11, 111}; |
| 361 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 362 | expectedTraversalPath = {1, 12, 121, 122, 1221, 13, 2, 11, 111}; |
| 363 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 364 | expectedTraversalPath = {}; |
| 365 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 366 | } |
| 367 | |
| 368 | TEST_F(LayerHierarchyTest, reparentFromRelativeParentWithSetLayer) { |
| 369 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 370 | reparentRelativeLayer(11, 2); |
| 371 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 372 | |
| 373 | reparentRelativeLayer(11, UNASSIGNED_LAYER_ID); |
| 374 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 375 | |
| 376 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 13, 2}; |
| 377 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 378 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 379 | expectedTraversalPath = {}; |
| 380 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 381 | } |
| 382 | |
| 383 | TEST_F(LayerHierarchyTest, reparentToRelativeParent) { |
| 384 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 385 | reparentRelativeLayer(11, 2); |
| 386 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 387 | |
| 388 | reparentLayer(11, 2); |
| 389 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 390 | |
| 391 | std::vector<uint32_t> expectedTraversalPath = {1, 12, 121, 122, 1221, 13, 2, 11, 111}; |
| 392 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 393 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 394 | expectedTraversalPath = {}; |
| 395 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 396 | } |
| 397 | |
| 398 | TEST_F(LayerHierarchyTest, setParentAsRelativeParent) { |
| 399 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 400 | reparentLayer(11, 2); |
| 401 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 402 | |
| 403 | reparentRelativeLayer(11, 2); |
| 404 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 405 | |
| 406 | std::vector<uint32_t> expectedTraversalPath = {1, 12, 121, 122, 1221, 13, 2, 11, 111}; |
| 407 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 408 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 409 | expectedTraversalPath = {}; |
| 410 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 411 | } |
| 412 | |
| 413 | TEST_F(LayerHierarchyTest, relativeChildMovesOffscreenIsNotTraversable) { |
| 414 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 415 | reparentRelativeLayer(11, 2); |
| 416 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 417 | |
| 418 | reparentLayer(2, UNASSIGNED_LAYER_ID); |
| 419 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 420 | |
| 421 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 13}; |
| 422 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 423 | expectedTraversalPath = {1, 12, 121, 122, 1221, 13}; |
| 424 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 425 | expectedTraversalPath = {2, 11, 111}; |
| 426 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 427 | } |
| 428 | |
| 429 | // mirror tests |
| 430 | TEST_F(LayerHierarchyTest, canTraverseMirrorLayer) { |
| 431 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 432 | |
| 433 | mirrorLayer(/*layer*/ 14, /*parent*/ 1, /*layerToMirror*/ 11); |
| 434 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 435 | |
| 436 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 12, 121, 122, |
| 437 | 1221, 13, 14, 11, 111, 2}; |
| 438 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 439 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 440 | expectedTraversalPath = {}; |
| 441 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 442 | } |
| 443 | |
| 444 | TEST_F(LayerHierarchyTest, canMirrorOffscreenLayer) { |
| 445 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 446 | |
| 447 | reparentLayer(11, UNASSIGNED_LAYER_ID); |
| 448 | mirrorLayer(/*layer*/ 14, /*parent*/ 1, /*layerToMirror*/ 11); |
| 449 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 450 | |
| 451 | std::vector<uint32_t> expectedTraversalPath = {1, 12, 121, 122, 1221, 13, 14, 11, 111, 2}; |
| 452 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 453 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 454 | expectedTraversalPath = {11, 111}; |
| 455 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 456 | } |
| 457 | |
| 458 | TEST_F(LayerHierarchyTest, newChildLayerIsUpdatedInMirrorHierarchy) { |
| 459 | mirrorLayer(/*layer*/ 14, /*parent*/ 1, /*layerToMirror*/ 11); |
| 460 | mLifecycleManager.commitChanges(); |
| 461 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 462 | |
| 463 | createLayer(1111, 111); |
| 464 | createLayer(112, 11); |
| 465 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 466 | |
| 467 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 1111, 112, 12, 121, 122, |
| 468 | 1221, 13, 14, 11, 111, 1111, 112, 2}; |
| 469 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 470 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 471 | expectedTraversalPath = {}; |
| 472 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 473 | } |
| 474 | |
| 475 | // mirror & relatives tests |
| 476 | TEST_F(LayerHierarchyTest, mirrorWithRelativeOutsideMirrorHierarchy) { |
| 477 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 478 | reparentRelativeLayer(111, 12); |
| 479 | mirrorLayer(/*layer*/ 14, /*parent*/ 1, /*layerToMirror*/ 11); |
| 480 | |
| 481 | // ROOT |
| 482 | // ├── 1 |
| 483 | // │ ├── 11 |
| 484 | // │ │ └── 111 |
| 485 | // │ ├── 12 |
| 486 | // │ │ ├── 121 |
| 487 | // │ │ ├── 122 |
| 488 | // │ │ │ └── 1221 |
| 489 | // │ │ └ - 111 (relative) |
| 490 | // │ ├── 13 |
| 491 | // │ └── 14 |
| 492 | // │ └ * 11 (mirroring) |
| 493 | // └── 2 |
| 494 | |
| 495 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 496 | |
| 497 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 12, 111, 121, 122, |
| 498 | 1221, 13, 14, 11, 111, 2}; |
| 499 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 500 | // 111 is not reachable in the mirror |
| 501 | expectedTraversalPath = {1, 11, 12, 111, 121, 122, 1221, 13, 14, 11, 2}; |
| 502 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 503 | expectedTraversalPath = {}; |
| 504 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 505 | } |
| 506 | |
| 507 | TEST_F(LayerHierarchyTest, mirrorWithRelativeInsideMirrorHierarchy) { |
| 508 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 509 | reparentRelativeLayer(1221, 12); |
| 510 | mirrorLayer(/*layer*/ 14, /*parent*/ 1, /*layerToMirror*/ 12); |
| 511 | |
| 512 | // ROOT |
| 513 | // ├── 1 |
| 514 | // │ ├── 11 |
| 515 | // │ │ └── 111 |
| 516 | // │ ├── 12 |
| 517 | // │ │ ├── 121 |
| 518 | // │ │ ├── 122 |
| 519 | // │ │ │ └── 1221 |
| 520 | // │ │ └ - 1221 (relative) |
| 521 | // │ ├── 13 |
| 522 | // │ └── 14 |
| 523 | // │ └ * 12 (mirroring) |
| 524 | // └── 2 |
| 525 | |
| 526 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 527 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 1221, |
| 528 | 13, 14, 12, 121, 122, 1221, 1221, 2}; |
| 529 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 530 | // relative layer 1221 is traversable in the mirrored hierarchy as well |
| 531 | expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 13, 14, 12, 121, 122, 1221, 2}; |
| 532 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 533 | expectedTraversalPath = {}; |
| 534 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 535 | } |
| 536 | |
| 537 | TEST_F(LayerHierarchyTest, childMovesOffscreenWhenRelativeParentDies) { |
| 538 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 539 | |
| 540 | reparentRelativeLayer(11, 2); |
| 541 | reparentLayer(2, UNASSIGNED_LAYER_ID); |
| 542 | destroyLayerHandle(2); |
| 543 | |
| 544 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 545 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 13}; |
| 546 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 547 | expectedTraversalPath = {1, 12, 121, 122, 1221, 13}; |
| 548 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 549 | expectedTraversalPath = {11, 111}; |
| 550 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 551 | |
| 552 | // remove relative parent so layer becomes onscreen again |
| 553 | reparentRelativeLayer(11, UNASSIGNED_LAYER_ID); |
| 554 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 555 | |
| 556 | expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 13}; |
| 557 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 558 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 559 | expectedTraversalPath = {}; |
| 560 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 561 | } |
| 562 | |
| 563 | TEST_F(LayerHierarchyTest, offscreenLayerCannotBeRelativeToOnscreenLayer) { |
| 564 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 565 | reparentRelativeLayer(1221, 2); |
| 566 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 567 | |
| 568 | // verify relz path |
| 569 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 13, 2, 1221}; |
| 570 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 571 | expectedTraversalPath = {1, 11, 111, 12, 121, 122, 13, 2, 1221}; |
| 572 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 573 | expectedTraversalPath = {}; |
| 574 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 575 | |
| 576 | // offscreen layer cannot be reached as a relative child |
| 577 | reparentLayer(12, UNASSIGNED_LAYER_ID); |
| 578 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 579 | |
| 580 | expectedTraversalPath = {1, 11, 111, 13, 2}; |
| 581 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 582 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 583 | expectedTraversalPath = {12, 121, 122, 1221}; |
| 584 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 585 | |
| 586 | // layer when onscreen can be reached as a relative child again |
| 587 | reparentLayer(12, 1); |
| 588 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 589 | |
| 590 | expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 13, 2, 1221}; |
| 591 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 592 | expectedTraversalPath = {1, 11, 111, 12, 121, 122, 13, 2, 1221}; |
| 593 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 594 | expectedTraversalPath = {}; |
| 595 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 596 | } |
| 597 | |
| 598 | TEST_F(LayerHierarchyTest, backgroundLayersAreBehindParentLayer) { |
| 599 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 600 | |
| 601 | updateBackgroundColor(1, 0.5); |
| 602 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 603 | |
| 604 | std::vector<uint32_t> expectedTraversalPath = {1, 1222, 11, 111, 12, 121, 122, 1221, 13, 2}; |
| 605 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 606 | expectedTraversalPath = {1222, 1, 11, 111, 12, 121, 122, 1221, 13, 2}; |
| 607 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 608 | expectedTraversalPath = {}; |
| 609 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 610 | } |
| 611 | |
| 612 | // cycle tests |
| 613 | TEST_F(LayerHierarchyTest, ParentBecomesTheChild) { |
| 614 | // remove default hierarchy |
| 615 | mLifecycleManager = LayerLifecycleManager(); |
| 616 | createRootLayer(1); |
| 617 | createLayer(11, 1); |
| 618 | reparentLayer(1, 11); |
| 619 | mLifecycleManager.commitChanges(); |
| 620 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 621 | |
| 622 | std::vector<uint32_t> expectedTraversalPath = {}; |
| 623 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 624 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 625 | expectedTraversalPath = {}; |
| 626 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 627 | } |
| 628 | |
| 629 | TEST_F(LayerHierarchyTest, RelativeLoops) { |
| 630 | // remove default hierarchy |
| 631 | mLifecycleManager = LayerLifecycleManager(); |
| 632 | createRootLayer(1); |
| 633 | createRootLayer(2); |
| 634 | createLayer(11, 1); |
| 635 | reparentRelativeLayer(11, 2); |
| 636 | reparentRelativeLayer(2, 11); |
| 637 | mLifecycleManager.commitChanges(); |
| 638 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 639 | |
| 640 | // fix loop |
| 641 | uint32_t invalidRelativeRoot; |
| 642 | bool hasRelZLoop = hierarchyBuilder.getHierarchy().hasRelZLoop(invalidRelativeRoot); |
| 643 | EXPECT_TRUE(hasRelZLoop); |
| 644 | mLifecycleManager.fixRelativeZLoop(invalidRelativeRoot); |
| 645 | hierarchyBuilder.update(mLifecycleManager.getLayers(), mLifecycleManager.getDestroyedLayers()); |
| 646 | EXPECT_EQ(invalidRelativeRoot, 11u); |
| 647 | EXPECT_FALSE(hierarchyBuilder.getHierarchy().hasRelZLoop(invalidRelativeRoot)); |
| 648 | |
| 649 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 2, 2}; |
| 650 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 651 | expectedTraversalPath = {1}; |
| 652 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 653 | expectedTraversalPath = {11, 2}; |
| 654 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 655 | } |
| 656 | |
| 657 | TEST_F(LayerHierarchyTest, IndirectRelativeLoops) { |
| 658 | // remove default hierarchy |
| 659 | mLifecycleManager = LayerLifecycleManager(); |
| 660 | createRootLayer(1); |
| 661 | createRootLayer(2); |
| 662 | createLayer(11, 1); |
| 663 | createLayer(111, 11); |
| 664 | createLayer(21, 2); |
| 665 | createLayer(22, 2); |
| 666 | createLayer(221, 22); |
| 667 | reparentRelativeLayer(22, 111); |
| 668 | reparentRelativeLayer(11, 221); |
| 669 | mLifecycleManager.commitChanges(); |
| 670 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 671 | |
| 672 | // fix loop |
| 673 | uint32_t invalidRelativeRoot; |
| 674 | bool hasRelZLoop = hierarchyBuilder.getHierarchy().hasRelZLoop(invalidRelativeRoot); |
| 675 | EXPECT_TRUE(hasRelZLoop); |
| 676 | mLifecycleManager.fixRelativeZLoop(invalidRelativeRoot); |
| 677 | hierarchyBuilder.update(mLifecycleManager.getLayers(), mLifecycleManager.getDestroyedLayers()); |
| 678 | EXPECT_FALSE(hierarchyBuilder.getHierarchy().hasRelZLoop(invalidRelativeRoot)); |
| 679 | |
| 680 | std::vector<uint32_t> expectedTraversalPath = {1, 11, 111, 22, 221, 2, 21, 22, 221}; |
| 681 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 682 | expectedTraversalPath = {1, 2, 21}; |
| 683 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 684 | expectedTraversalPath = {11, 111, 22, 221}; |
| 685 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 686 | } |
| 687 | |
| 688 | TEST_F(LayerHierarchyTest, ReparentRootLayerToNull) { |
| 689 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 690 | reparentLayer(1, UNASSIGNED_LAYER_ID); |
| 691 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 692 | |
| 693 | std::vector<uint32_t> expectedTraversalPath = {2}; |
| 694 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 695 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 696 | expectedTraversalPath = {1, 11, 111, 12, 121, 122, 1221, 13}; |
| 697 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 698 | } |
| 699 | |
| 700 | TEST_F(LayerHierarchyTest, AddRemoveLayerInSameTransaction) { |
| 701 | // remove default hierarchy |
| 702 | mLifecycleManager = LayerLifecycleManager(); |
| 703 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 704 | createRootLayer(1); |
| 705 | destroyLayerHandle(1); |
| 706 | UPDATE_AND_VERIFY(hierarchyBuilder); |
| 707 | |
| 708 | std::vector<uint32_t> expectedTraversalPath = {}; |
| 709 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 710 | EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); |
| 711 | EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); |
| 712 | } |
| 713 | |
| 714 | // traversal path test |
| 715 | TEST_F(LayerHierarchyTest, traversalPathId) { |
| 716 | setZ(122, -1); |
| 717 | LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); |
| 718 | auto checkTraversalPathIdVisitor = |
| 719 | [](const LayerHierarchy& hierarchy, |
| 720 | const LayerHierarchy::TraversalPath& traversalPath) -> bool { |
| 721 | EXPECT_EQ(hierarchy.getLayer()->id, traversalPath.id); |
| 722 | return true; |
| 723 | }; |
| 724 | hierarchyBuilder.getHierarchy().traverse(checkTraversalPathIdVisitor); |
| 725 | hierarchyBuilder.getHierarchy().traverseInZOrder(checkTraversalPathIdVisitor); |
| 726 | } |
| 727 | |
| 728 | } // namespace android::surfaceflinger::frontend |