summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vishnu Nair <vishnun@google.com> 2023-10-05 17:48:31 +0000
committer Vishnu Nair <vishnun@google.com> 2023-10-06 04:06:09 +0000
commitbefd3e2f1b09d94c4c668f469e6fb1aa501b87e6 (patch)
tree8e8c1a7bc18dbdb15316573bf8b04496c9fd765f
parentecba2dca9fd212be94499ed5eee3805f3251fd8a (diff)
[sf] fix shadow radius propagation
Fixes an issue where shadow radius was not being set on the snapshot. Bug: 302551905 Test: presubmit Change-Id: Ifc4019d67b0c20dccb913dcb36c4a3ee21ec9f47
-rw-r--r--services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp1
-rw-r--r--services/surfaceflinger/tests/unittests/LayerHierarchyTest.h11
-rw-r--r--services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp9
3 files changed, 21 insertions, 0 deletions
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
index 55be398bd0..a1796e1eb0 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
@@ -1006,6 +1006,7 @@ void LayerSnapshotBuilder::updateShadows(LayerSnapshot& snapshot, const Requeste
snapshot.shadowSettings.ambientColor *= snapshot.alpha;
snapshot.shadowSettings.spotColor *= snapshot.alpha;
}
+ snapshot.shadowSettings.length = snapshot.shadowRadius;
}
void LayerSnapshotBuilder::updateInput(LayerSnapshot& snapshot,
diff --git a/services/surfaceflinger/tests/unittests/LayerHierarchyTest.h b/services/surfaceflinger/tests/unittests/LayerHierarchyTest.h
index d7ac038a84..1898f43dcc 100644
--- a/services/surfaceflinger/tests/unittests/LayerHierarchyTest.h
+++ b/services/surfaceflinger/tests/unittests/LayerHierarchyTest.h
@@ -406,6 +406,17 @@ protected:
mLifecycleManager.applyTransactions(transactions);
}
+ void setShadowRadius(uint32_t id, float shadowRadius) {
+ std::vector<TransactionState> transactions;
+ transactions.emplace_back();
+ transactions.back().states.push_back({});
+
+ transactions.back().states.front().state.what = layer_state_t::eShadowRadiusChanged;
+ transactions.back().states.front().layerId = id;
+ transactions.back().states.front().state.shadowRadius = shadowRadius;
+ mLifecycleManager.applyTransactions(transactions);
+ }
+
LayerLifecycleManager mLifecycleManager;
};
diff --git a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
index 69316bf4e5..2ae01312ae 100644
--- a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
+++ b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
@@ -872,4 +872,13 @@ TEST_F(LayerSnapshotTest, setBufferCrop) {
UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
EXPECT_EQ(getSnapshot(1)->geomContentCrop, Rect(0, 0, 100, 100));
}
+
+TEST_F(LayerSnapshotTest, setShadowRadius) {
+ static constexpr float SHADOW_RADIUS = 123.f;
+ setShadowRadius(1, SHADOW_RADIUS);
+ UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
+ EXPECT_EQ(getSnapshot(1)->shadowSettings.length, SHADOW_RADIUS);
+ EXPECT_EQ(getSnapshot(1)->shadowRadius, SHADOW_RADIUS);
+}
+
} // namespace android::surfaceflinger::frontend