[Shadows] Add shadow radius to sf layer state (2/n)
Bug: 136561771
Test: atest SurfaceFlinger_Test
Change-Id: Icafe852eaad195163b48b802db2a4b092aa30926
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index e004e95..e392bc5 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -406,6 +406,12 @@
what |= eMetadataChanged;
metadata.merge(other.metadata);
}
+
+ if (other.what & eShadowRadiusChanged) {
+ what |= eShadowRadiusChanged;
+ shadowRadius = other.shadowRadius;
+ }
+
if ((other.what & what) != other.what) {
ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
"other.what=0x%" PRIu64 " what=0x%" PRIu64,
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index e9079ef..14f47c3 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1335,6 +1335,18 @@
return *this;
}
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setShadowRadius(
+ const sp<SurfaceControl>& sc, float shadowRadius) {
+ layer_state_t* s = getLayerState(sc);
+ if (!s) {
+ mStatus = BAD_INDEX;
+ return *this;
+ }
+ s->what |= layer_state_t::eShadowRadiusChanged;
+ s->shadowRadius = shadowRadius;
+ return *this;
+}
+
// ---------------------------------------------------------------------------
DisplayState& SurfaceComposerClient::Transaction::getDisplayState(const sp<IBinder>& token) {
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index a49ed52..c2b5119 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -72,7 +72,7 @@
eCropChanged_legacy = 0x00000100,
eDeferTransaction_legacy = 0x00000200,
eOverrideScalingModeChanged = 0x00000400,
- // AVAILABLE 0x00000800,
+ eShadowRadiusChanged = 0x00000800,
eReparentChildren = 0x00001000,
eDetachChildren = 0x00002000,
eRelativeLayerChanged = 0x00004000,
@@ -126,7 +126,8 @@
colorTransform(mat4()),
bgColorAlpha(0),
bgColorDataspace(ui::Dataspace::UNKNOWN),
- colorSpaceAgnostic(false) {
+ colorSpaceAgnostic(false),
+ shadowRadius(0.0f) {
matrix.dsdx = matrix.dtdy = 1.0f;
matrix.dsdy = matrix.dtdx = 0.0f;
hdrMetadata.validTypes = 0;
@@ -204,6 +205,9 @@
bool colorSpaceAgnostic;
std::vector<ListenerCallbacks> listeners;
+
+ // Draws a shadow around the surface.
+ float shadowRadius;
};
struct ComposerState {
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 08f4e9e..a140142 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -474,6 +474,7 @@
Transaction& setGeometry(const sp<SurfaceControl>& sc,
const Rect& source, const Rect& dst, int transform);
+ Transaction& setShadowRadius(const sp<SurfaceControl>& sc, float cornerRadius);
status_t setDisplaySurface(const sp<IBinder>& token,
const sp<IGraphicBufferProducer>& bufferProducer);