@@ -29,22 +29,6 @@ enum class FilterType {
2929 DropShadow
3030};
3131
32- struct DropShadowParams {
33- bool operator ==(const DropShadowParams& other) const = default ;
34-
35- Float offsetX{};
36- Float offsetY{};
37- Float standardDeviation{};
38- SharedColor color{};
39- };
40-
41- struct FilterFunction {
42- bool operator ==(const FilterFunction& other) const = default ;
43-
44- FilterType type{};
45- std::variant<Float, DropShadowParams> parameters{};
46- };
47-
4832inline FilterType filterTypeFromString (std::string_view filterName) {
4933 if (filterName == " blur" ) {
5034 return FilterType::Blur;
@@ -96,4 +80,51 @@ inline std::string toString(const FilterType& filterType) {
9680 }
9781}
9882
83+ struct DropShadowParams {
84+ bool operator ==(const DropShadowParams& other) const = default ;
85+
86+ Float offsetX{};
87+ Float offsetY{};
88+ Float standardDeviation{};
89+ SharedColor color{};
90+
91+ #ifdef RN_SERIALIZABLE_STATE
92+ folly::dynamic toDynamic () const {
93+ folly::dynamic result = folly::dynamic::object ();
94+ result[" offsetX" ] = offsetX;
95+ result[" offsetY" ] = offsetY;
96+ result[" standardDeviation" ] = standardDeviation;
97+ result[" color" ] = *color;
98+ return result;
99+ }
100+ #endif
101+ };
102+
103+ struct FilterFunction {
104+ bool operator ==(const FilterFunction& other) const = default ;
105+
106+ FilterType type{};
107+ std::variant<Float, DropShadowParams> parameters{};
108+
109+ #ifdef RN_SERIALIZABLE_STATE
110+ folly::dynamic toDynamic () const {
111+ folly::dynamic result = folly::dynamic::object ();
112+ std::string typeKey = toString (type);
113+ if (std::holds_alternative<Float>(parameters)) {
114+ result[typeKey] = std::get<Float>(parameters);
115+ } else if (std::holds_alternative<DropShadowParams>(parameters)) {
116+ const auto & dropShadowParams = std::get<DropShadowParams>(parameters);
117+ result[typeKey] = dropShadowParams.toDynamic ();
118+ }
119+ return result;
120+ }
121+ #endif
122+ };
123+
124+ #ifdef RN_SERIALIZABLE_STATE
125+ inline folly::dynamic toDynamic (const FilterFunction& filterFunction) {
126+ return filterFunction.toDynamic ();
127+ }
128+ #endif
129+
99130} // namespace facebook::react
0 commit comments