Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit befd3e2f authored by Vishnu Nair's avatar Vishnu Nair
Browse files

[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
parent ecba2dca
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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,
+11 −0
Original line number Diff line number Diff line
@@ -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;
};

+9 −0
Original line number Diff line number Diff line
@@ -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