|
1 | 1 | #pragma once |
2 | 2 |
|
3 | 3 | #include <reanimated/CSS/common/filters/FilterOp.h> |
4 | | -#include <reanimated/CSS/common/values/CSSAngle.h> |
5 | | -#include <reanimated/CSS/common/values/CSSNumber.h> |
6 | | -#include <reanimated/CSS/common/values/complex/CSSDropShadow.h> |
7 | 4 | #include <reanimated/CSS/interpolation/configs.h> |
8 | 5 | #include <reanimated/CSS/interpolation/filters/FilterOperation.h> |
9 | | -#include <reanimated/CSS/interpolation/filters/operations/blur.h> |
10 | | -#include <reanimated/CSS/interpolation/filters/operations/brightness.h> |
11 | | -#include <reanimated/CSS/interpolation/filters/operations/contrast.h> |
12 | | -#include <reanimated/CSS/interpolation/filters/operations/dropShadow.h> |
13 | | -#include <reanimated/CSS/interpolation/filters/operations/grayscale.h> |
14 | | -#include <reanimated/CSS/interpolation/filters/operations/hueRotate.h> |
15 | | -#include <reanimated/CSS/interpolation/filters/operations/invert.h> |
16 | | -#include <reanimated/CSS/interpolation/filters/operations/opacity.h> |
17 | | -#include <reanimated/CSS/interpolation/filters/operations/saturate.h> |
18 | | -#include <reanimated/CSS/interpolation/filters/operations/sepia.h> |
19 | 6 |
|
20 | 7 | #include <memory> |
21 | 8 | #include <unordered_map> |
@@ -60,7 +47,7 @@ template <typename TOperation> |
60 | 47 | class FilterOperationInterpolatorBase : public FilterInterpolator { |
61 | 48 | public: |
62 | 49 | explicit FilterOperationInterpolatorBase(std::shared_ptr<TOperation> defaultOperation) |
63 | | - : defaultOperation_(std::move(defaultOperation)) {} |
| 50 | + : defaultOperation_(defaultOperation) {} |
64 | 51 |
|
65 | 52 | std::shared_ptr<FilterOperation> getDefaultOperation() const override { |
66 | 53 | return defaultOperation_; |
@@ -107,78 +94,4 @@ class FilterOperationInterpolator<TOperation> : public FilterOperationInterpolat |
107 | 94 | ResolvableValueInterpolationContext getResolvableValueContext(const FilterInterpolationContext &context) const; |
108 | 95 | }; |
109 | 96 |
|
110 | | -// Template implementations |
111 | | -template <typename TOperation> |
112 | | -FilterOperationInterpolator<TOperation>::FilterOperationInterpolator( |
113 | | - const std::shared_ptr<TOperation> &defaultOperation) |
114 | | - : FilterOperationInterpolatorBase<TOperation>(defaultOperation) {} |
115 | | - |
116 | | -template <typename TOperation> |
117 | | -std::unique_ptr<FilterOperation> FilterOperationInterpolator<TOperation>::interpolate( |
118 | | - double progress, |
119 | | - const std::shared_ptr<FilterOperation> &from, |
120 | | - const std::shared_ptr<FilterOperation> &to, |
121 | | - const FilterInterpolationContext &context) const { |
122 | | - const auto &fromOp = *std::static_pointer_cast<TOperation>(from); |
123 | | - const auto &toOp = *std::static_pointer_cast<TOperation>(to); |
124 | | - |
125 | | - return std::make_unique<TOperation>(fromOp.value.interpolate(progress, toOp.value)); |
126 | | -} |
127 | | - |
128 | | -template <ResolvableFilterOp TOperation> |
129 | | -FilterOperationInterpolator<TOperation>::FilterOperationInterpolator( |
130 | | - const std::shared_ptr<TOperation> &defaultOperation, |
131 | | - ResolvableValueInterpolatorConfig config) |
132 | | - : FilterOperationInterpolatorBase<TOperation>(defaultOperation), config_(std::move(config)) {} |
133 | | - |
134 | | -template <ResolvableFilterOp TOperation> |
135 | | -std::unique_ptr<FilterOperation> FilterOperationInterpolator<TOperation>::interpolate( |
136 | | - double progress, |
137 | | - const std::shared_ptr<FilterOperation> &from, |
138 | | - const std::shared_ptr<FilterOperation> &to, |
139 | | - const FilterInterpolationContext &context) const { |
140 | | - const auto &fromOp = *std::static_pointer_cast<TOperation>(from); |
141 | | - const auto &toOp = *std::static_pointer_cast<TOperation>(to); |
142 | | - |
143 | | - return std::make_unique<TOperation>( |
144 | | - fromOp.value.interpolate(progress, toOp.value, getResolvableValueContext(context))); |
145 | | -} |
146 | | - |
147 | | -template <ResolvableFilterOp TOperation> |
148 | | -std::shared_ptr<FilterOperation> FilterOperationInterpolator<TOperation>::resolveOperation( |
149 | | - const std::shared_ptr<FilterOperation> &operation, |
150 | | - const FilterInterpolationContext &context) const { |
151 | | - const auto &resolvableOp = std::static_pointer_cast<TOperation>(operation); |
152 | | - const auto &resolved = resolvableOp->value.resolve(getResolvableValueContext(context)); |
153 | | - |
154 | | - if (!resolved.has_value()) { |
155 | | - throw std::invalid_argument( |
156 | | - "[Reanimated] Cannot resolve resolvable operation: " + operation->getOperationName() + |
157 | | - " for node with tag: " + std::to_string(context.node->getTag())); |
158 | | - } |
159 | | - |
160 | | - return std::make_shared<TOperation>(resolved.value()); |
161 | | -} |
162 | | - |
163 | | -template <ResolvableFilterOp TOperation> |
164 | | -ResolvableValueInterpolationContext FilterOperationInterpolator<TOperation>::getResolvableValueContext( |
165 | | - const FilterInterpolationContext &context) const { |
166 | | - return ResolvableValueInterpolationContext{ |
167 | | - .node = context.node, |
168 | | - .viewStylesRepository = context.viewStylesRepository, |
169 | | - .relativeProperty = config_.relativeProperty, |
170 | | - .relativeTo = config_.relativeTo}; |
171 | | -} |
172 | | - |
173 | | -template class FilterOperationInterpolator<BlurOperation>; |
174 | | -template class FilterOperationInterpolator<BrightnessOperation>; |
175 | | -template class FilterOperationInterpolator<ContrastOperation>; |
176 | | -template class FilterOperationInterpolator<DropShadowOperation>; |
177 | | -template class FilterOperationInterpolator<GrayscaleOperation>; |
178 | | -template class FilterOperationInterpolator<HueRotateOperation>; |
179 | | -template class FilterOperationInterpolator<InvertOperation>; |
180 | | -template class FilterOperationInterpolator<OpacityOperation>; |
181 | | -template class FilterOperationInterpolator<SaturateOperation>; |
182 | | -template class FilterOperationInterpolator<SepiaOperation>; |
183 | | - |
184 | 97 | } // namespace reanimated::css |
0 commit comments