diff options
6 files changed, 53 insertions, 24 deletions
diff --git a/services/surfaceflinger/FrontEnd/LayerHierarchy.cpp b/services/surfaceflinger/FrontEnd/LayerHierarchy.cpp index c30465fbd4..5913d4b589 100644 --- a/services/surfaceflinger/FrontEnd/LayerHierarchy.cpp +++ b/services/surfaceflinger/FrontEnd/LayerHierarchy.cpp @@ -30,7 +30,7 @@ auto layerZCompare = [](const std::pair<LayerHierarchy*, LayerHierarchy::Variant auto lhsLayer = lhs.first->getLayer(); auto rhsLayer = rhs.first->getLayer(); if (lhsLayer->layerStack.id != rhsLayer->layerStack.id) { - return lhsLayer->layerStack.id > rhsLayer->layerStack.id; + return lhsLayer->layerStack.id < rhsLayer->layerStack.id; } if (lhsLayer->z != rhsLayer->z) { return lhsLayer->z < rhsLayer->z; diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp index 25cbe7ae54..ce7d37e69b 100644 --- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp +++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp @@ -817,7 +817,8 @@ void LayerSnapshotBuilder::updateSnapshot(LayerSnapshot& snapshot, const Args& a snapshot.frameRateSelectionPriority = requested.frameRateSelectionPriority; } - if (forceUpdate || snapshot.changes.any(RequestedLayerState::Changes::Content)) { + if (forceUpdate || snapshot.changes.any(RequestedLayerState::Changes::Content) || + snapshot.changes.any(RequestedLayerState::Changes::AffectsChildren)) { snapshot.color.rgb = requested.getColor().rgb; snapshot.isColorspaceAgnostic = requested.colorSpaceAgnostic; snapshot.backgroundBlurRadius = args.supportsBlur @@ -1069,6 +1070,10 @@ void LayerSnapshotBuilder::updateInput(LayerSnapshot& snapshot, // touches from going outside the cloned area. if (path.isClone()) { snapshot.inputInfo.inputConfig |= gui::WindowInfo::InputConfig::CLONE; + // Cloned layers shouldn't handle watch outside since their z order is not determined by + // WM or the client. + snapshot.inputInfo.inputConfig.clear(gui::WindowInfo::InputConfig::WATCH_OUTSIDE_TOUCH); + mNeedsTouchableRegionCrop.insert(path); } } diff --git a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp index 1f670c81df..beb69a6035 100644 --- a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp +++ b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp @@ -32,10 +32,6 @@ using ftl::Flags; using namespace ftl::flag_operators; namespace { -std::string layerIdToString(uint32_t layerId) { - return layerId == UNASSIGNED_LAYER_ID ? "none" : std::to_string(layerId); -} - std::string layerIdsToString(const std::vector<uint32_t>& layerIds) { std::stringstream stream; stream << "{"; @@ -323,9 +319,13 @@ ui::Transform RequestedLayerState::getTransform(uint32_t displayRotationFlags) c std::string RequestedLayerState::getDebugString() const { std::stringstream debug; - debug << "RequestedLayerState{" << name << " parent=" << layerIdToString(parentId) - << " relativeParent=" << layerIdToString(relativeParentId) - << " mirrorId=" << layerIdsToString(mirrorIds) << " handle=" << handleAlive << " z=" << z; + debug << "RequestedLayerState{" << name; + if (parentId != UNASSIGNED_LAYER_ID) debug << " parentId=" << parentId; + if (relativeParentId != UNASSIGNED_LAYER_ID) debug << " relativeParentId=" << relativeParentId; + if (!mirrorIds.empty()) debug << " mirrorId=" << layerIdsToString(mirrorIds); + if (!handleAlive) debug << " !handle"; + if (z != 0) debug << " z=" << z; + if (layerStack.id != 0) debug << " layerStack=" << layerStack.id; return debug.str(); } diff --git a/services/surfaceflinger/tests/unittests/LayerHierarchyTest.cpp b/services/surfaceflinger/tests/unittests/LayerHierarchyTest.cpp index ddf3363244..88d39db17d 100644 --- a/services/surfaceflinger/tests/unittests/LayerHierarchyTest.cpp +++ b/services/surfaceflinger/tests/unittests/LayerHierarchyTest.cpp @@ -662,10 +662,9 @@ TEST_F(LayerHierarchyTest, zorderRespectsLayerStack) { mLifecycleManager.commitChanges(); LayerHierarchyBuilder hierarchyBuilder(mLifecycleManager.getLayers()); UPDATE_AND_VERIFY(hierarchyBuilder); - std::vector<uint32_t> expectedTraversalPath = {1, 11, 2, 21}; + std::vector<uint32_t> expectedTraversalPath = {2, 21, 1, 11}; EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expectedTraversalPath); - expectedTraversalPath = {1, 11, 2, 21}; EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expectedTraversalPath); expectedTraversalPath = {}; EXPECT_EQ(getTraversalPath(hierarchyBuilder.getOffscreenHierarchy()), expectedTraversalPath); @@ -678,8 +677,8 @@ TEST_F(LayerHierarchyTest, canMirrorDisplay) { setLayerStack(3, 1); UPDATE_AND_VERIFY(hierarchyBuilder); - std::vector<uint32_t> expected = {3, 1, 11, 111, 12, 121, 122, 1221, 13, 2, - 1, 11, 111, 12, 121, 122, 1221, 13, 2}; + std::vector<uint32_t> expected = {1, 11, 111, 12, 121, 122, 1221, 13, 2, 3, + 1, 11, 111, 12, 121, 122, 1221, 13, 2}; EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expected); EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expected); expected = {}; @@ -693,7 +692,7 @@ TEST_F(LayerHierarchyTest, mirrorNonExistingDisplay) { setLayerStack(3, 1); UPDATE_AND_VERIFY(hierarchyBuilder); - std::vector<uint32_t> expected = {3, 1, 11, 111, 12, 121, 122, 1221, 13, 2}; + std::vector<uint32_t> expected = {1, 11, 111, 12, 121, 122, 1221, 13, 2, 3}; EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expected); EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expected); expected = {}; @@ -710,8 +709,8 @@ TEST_F(LayerHierarchyTest, newRootLayerIsMirrored) { createRootLayer(4); UPDATE_AND_VERIFY(hierarchyBuilder); - std::vector<uint32_t> expected = {3, 1, 11, 111, 12, 121, 122, 1221, 13, 2, 4, - 1, 11, 111, 12, 121, 122, 1221, 13, 2, 4}; + std::vector<uint32_t> expected = {1, 11, 111, 12, 121, 122, 1221, 13, 2, 4, 3, + 1, 11, 111, 12, 121, 122, 1221, 13, 2, 4}; EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expected); EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expected); expected = {}; @@ -729,7 +728,7 @@ TEST_F(LayerHierarchyTest, removedRootLayerIsNoLongerMirrored) { destroyLayerHandle(1); UPDATE_AND_VERIFY(hierarchyBuilder); - std::vector<uint32_t> expected = {3, 2, 2}; + std::vector<uint32_t> expected = {2, 3, 2}; EXPECT_EQ(getTraversalPath(hierarchyBuilder.getHierarchy()), expected); EXPECT_EQ(getTraversalPathInZOrder(hierarchyBuilder.getHierarchy()), expected); expected = {11, 111, 12, 121, 122, 1221, 13}; diff --git a/services/surfaceflinger/tests/unittests/LayerHierarchyTest.h b/services/surfaceflinger/tests/unittests/LayerHierarchyTest.h index 79cfd6a891..43011863ff 100644 --- a/services/surfaceflinger/tests/unittests/LayerHierarchyTest.h +++ b/services/surfaceflinger/tests/unittests/LayerHierarchyTest.h @@ -297,6 +297,17 @@ protected: mLifecycleManager.applyTransactions(transactions); } + void setBackgroundBlurRadius(uint32_t id, uint32_t backgroundBlurRadius) { + std::vector<TransactionState> transactions; + transactions.emplace_back(); + transactions.back().states.push_back({}); + + transactions.back().states.front().state.what = layer_state_t::eBackgroundBlurRadiusChanged; + transactions.back().states.front().layerId = id; + transactions.back().states.front().state.backgroundBlurRadius = backgroundBlurRadius; + mLifecycleManager.applyTransactions(transactions); + } + LayerLifecycleManager mLifecycleManager; }; diff --git a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp index 5a066a6482..b8a7446b3a 100644 --- a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp +++ b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp @@ -79,6 +79,7 @@ protected: .displays = mFrontEndDisplayInfos, .displayChanges = hasDisplayChanges, .globalShadowSettings = globalShadowSettings, + .supportsBlur = true, .supportedLayerGenericMetadata = {}, .genericLayerMetadataKeyMap = {}}; actualBuilder.update(args); @@ -333,6 +334,19 @@ TEST_F(LayerSnapshotTest, canCropTouchableRegion) { EXPECT_EQ(getSnapshot({.id = 111})->inputInfo.touchableRegion.bounds(), modifiedTouchCrop); } +TEST_F(LayerSnapshotTest, blurUpdatesWhenAlphaChanges) { + static constexpr int blurRadius = 42; + setBackgroundBlurRadius(1221, blurRadius); + + UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER); + EXPECT_EQ(getSnapshot({.id = 1221})->backgroundBlurRadius, blurRadius); + + static constexpr float alpha = 0.5; + setAlpha(12, alpha); + UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER); + EXPECT_EQ(getSnapshot({.id = 1221})->backgroundBlurRadius, blurRadius * alpha); +} + // Display Mirroring Tests // tree with 3 levels of children // ROOT (DISPLAY 0) @@ -352,7 +366,7 @@ TEST_F(LayerSnapshotTest, displayMirrorRespectsLayerSkipScreenshotFlag) { createDisplayMirrorLayer(3, ui::LayerStack::fromValue(0)); setLayerStack(3, 1); - std::vector<uint32_t> expected = {3, 1, 11, 111, 13, 2, 1, 11, 111, 12, 121, 122, 1221, 13, 2}; + std::vector<uint32_t> expected = {1, 11, 111, 12, 121, 122, 1221, 13, 2, 3, 1, 11, 111, 13, 2}; UPDATE_AND_VERIFY(mSnapshotBuilder, expected); } @@ -371,8 +385,8 @@ TEST_F(LayerSnapshotTest, mirrorLayerGetsCorrectLayerStack) { createDisplayMirrorLayer(4, ui::LayerStack::fromValue(0)); setLayerStack(4, 4); - std::vector<uint32_t> expected = {4, 1, 11, 111, 13, 2, 3, 1, 11, - 111, 13, 2, 1, 11, 111, 13, 2}; + std::vector<uint32_t> expected = {1, 11, 111, 13, 2, 3, 1, 11, 111, + 13, 2, 4, 1, 11, 111, 13, 2}; UPDATE_AND_VERIFY(mSnapshotBuilder, expected); EXPECT_EQ(getSnapshot({.id = 111, .mirrorRootId = 3})->outputFilter.layerStack.id, 3u); EXPECT_EQ(getSnapshot({.id = 111, .mirrorRootId = 4})->outputFilter.layerStack.id, 4u); @@ -395,7 +409,7 @@ TEST_F(LayerSnapshotTest, mirrorLayerTouchIsCroppedByMirrorRoot) { setCrop(111, Rect{200, 200}); Region touch{Rect{0, 0, 1000, 1000}}; setTouchableRegion(111, touch); - std::vector<uint32_t> expected = {3, 1, 11, 111, 13, 2, 1, 11, 111, 13, 2}; + std::vector<uint32_t> expected = {1, 11, 111, 13, 2, 3, 1, 11, 111, 13, 2}; UPDATE_AND_VERIFY(mSnapshotBuilder, expected); EXPECT_TRUE(getSnapshot({.id = 111})->inputInfo.touchableRegion.hasSameRects(touch)); Region touchCroppedByMirrorRoot{Rect{0, 0, 50, 50}}; @@ -407,7 +421,7 @@ TEST_F(LayerSnapshotTest, canRemoveDisplayMirror) { setFlags(12, layer_state_t::eLayerSkipScreenshot, layer_state_t::eLayerSkipScreenshot); createDisplayMirrorLayer(3, ui::LayerStack::fromValue(0)); setLayerStack(3, 1); - std::vector<uint32_t> expected = {3, 1, 11, 111, 13, 2, 1, 11, 111, 12, 121, 122, 1221, 13, 2}; + std::vector<uint32_t> expected = {1, 11, 111, 12, 121, 122, 1221, 13, 2, 3, 1, 11, 111, 13, 2}; UPDATE_AND_VERIFY(mSnapshotBuilder, expected); destroyLayerHandle(3); UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER); @@ -417,8 +431,8 @@ TEST_F(LayerSnapshotTest, cleanUpUnreachableSnapshotsAfterMirroring) { size_t startingNumSnapshots = mSnapshotBuilder.getSnapshots().size(); createDisplayMirrorLayer(3, ui::LayerStack::fromValue(0)); setLayerStack(3, 1); - std::vector<uint32_t> expected = {3, 1, 11, 111, 12, 121, 122, 1221, 13, 2, - 1, 11, 111, 12, 121, 122, 1221, 13, 2}; + std::vector<uint32_t> expected = {1, 11, 111, 12, 121, 122, 1221, 13, 2, 3, + 1, 11, 111, 12, 121, 122, 1221, 13, 2}; UPDATE_AND_VERIFY(mSnapshotBuilder, expected); destroyLayerHandle(3); UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER); |