react-native-smooth-clip-view 0.2.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -21
- package/android/CMakeLists.txt +7 -0
- package/android/build.gradle +14 -2
- package/android/proguard-rules.pro +3 -3
- package/android/src/main/cpp/SmoothClipAndroid.h +10 -0
- package/android/src/main/cpp/SmoothClipBindings.cpp +896 -6
- package/android/src/main/cpp/SmoothClipRegistry.cpp +1067 -46
- package/android/src/main/cpp/SmoothClipTrace.h +25 -0
- package/android/src/main/java/com/smoothclipview/ClipGeometryNormalizer.kt +265 -0
- package/android/src/main/java/com/smoothclipview/SmoothClipBindings.kt +21 -0
- package/android/src/main/java/com/smoothclipview/SmoothClipModule.kt +283 -0
- package/android/src/main/java/com/smoothclipview/SmoothClipView.kt +385 -24
- package/android/src/main/java/com/smoothclipview/SmoothClipViewManager.kt +138 -24
- package/cpp/SmoothClipAnimationCurve.h +151 -122
- package/cpp/SmoothClipRegistry.h +102 -4
- package/cpp/SmoothClipSharedGeometry.h +146 -7
- package/cpp/SmoothClipVelocityTracker.h +13 -9
- package/ios/SmoothClipGeometry.h +184 -6
- package/ios/SmoothClipRegistry.mm +1033 -25
- package/ios/SmoothClipRegistrySnapshot.h +13 -0
- package/ios/SmoothClipTurboModule.cpp +857 -2
- package/ios/SmoothClipTurboModule.h +310 -0
- package/ios/SmoothClipView.mm +714 -183
- package/ios/SmoothClipViewRegistry.h +1 -0
- package/ios/reactnativesmoothclipview.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/reactnativesmoothclipview.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/lib/module/NativeSmoothClipModule.js.map +1 -1
- package/lib/module/SmoothClipView.ios.js +22 -6
- package/lib/module/SmoothClipView.ios.js.map +1 -1
- package/lib/module/SmoothClipView.js +1 -46
- package/lib/module/SmoothClipView.js.map +1 -1
- package/lib/module/SmoothClipViewNativeComponent.ts +27 -1
- package/lib/module/capabilities.js +4 -0
- package/lib/module/capabilities.js.map +1 -0
- package/lib/module/capabilities.native.js +36 -0
- package/lib/module/capabilities.native.js.map +1 -0
- package/lib/module/capabilityTypes.js +11 -0
- package/lib/module/capabilityTypes.js.map +1 -0
- package/lib/module/driverState.js +0 -28
- package/lib/module/driverState.js.map +1 -1
- package/lib/module/drivers.js +1 -281
- package/lib/module/drivers.js.map +1 -1
- package/lib/module/drivers.native.js +340 -75
- package/lib/module/drivers.native.js.map +1 -1
- package/lib/module/geometry.js +147 -17
- package/lib/module/geometry.js.map +1 -1
- package/lib/module/groupDriverTypes.js +4 -0
- package/lib/module/groupDriverTypes.js.map +1 -0
- package/lib/module/groupDrivers.android.js +4 -0
- package/lib/module/groupDrivers.android.js.map +1 -0
- package/lib/module/groupDrivers.ios.js +4 -0
- package/lib/module/groupDrivers.ios.js.map +1 -0
- package/lib/module/groupDrivers.js +4 -0
- package/lib/module/groupDrivers.js.map +1 -0
- package/lib/module/groupDrivers.native.js +799 -0
- package/lib/module/groupDrivers.native.js.map +1 -0
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/presentationProtocol.js +15 -0
- package/lib/module/presentationProtocol.js.map +1 -0
- package/lib/typescript/src/NativeSmoothClipModule.d.ts +25 -0
- package/lib/typescript/src/NativeSmoothClipModule.d.ts.map +1 -1
- package/lib/typescript/src/SmoothClipView.d.ts +2 -10
- package/lib/typescript/src/SmoothClipView.d.ts.map +1 -1
- package/lib/typescript/src/SmoothClipView.ios.d.ts +133 -2
- package/lib/typescript/src/SmoothClipView.ios.d.ts.map +1 -1
- package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts +8 -0
- package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/capabilities.d.ts +3 -0
- package/lib/typescript/src/capabilities.d.ts.map +1 -0
- package/lib/typescript/src/capabilities.native.d.ts +3 -0
- package/lib/typescript/src/capabilities.native.d.ts.map +1 -0
- package/lib/typescript/src/capabilityTypes.d.ts +10 -0
- package/lib/typescript/src/capabilityTypes.d.ts.map +1 -0
- package/lib/typescript/src/driverState.d.ts +1 -6
- package/lib/typescript/src/driverState.d.ts.map +1 -1
- package/lib/typescript/src/driverTypes.d.ts +39 -11
- package/lib/typescript/src/driverTypes.d.ts.map +1 -1
- package/lib/typescript/src/drivers.d.ts +2 -4
- package/lib/typescript/src/drivers.d.ts.map +1 -1
- package/lib/typescript/src/drivers.native.d.ts.map +1 -1
- package/lib/typescript/src/geometry.d.ts +36 -2
- package/lib/typescript/src/geometry.d.ts.map +1 -1
- package/lib/typescript/src/groupDriverTypes.d.ts +66 -0
- package/lib/typescript/src/groupDriverTypes.d.ts.map +1 -0
- package/lib/typescript/src/groupDrivers.android.d.ts +2 -0
- package/lib/typescript/src/groupDrivers.android.d.ts.map +1 -0
- package/lib/typescript/src/groupDrivers.d.ts +2 -0
- package/lib/typescript/src/groupDrivers.d.ts.map +1 -0
- package/lib/typescript/src/groupDrivers.ios.d.ts +2 -0
- package/lib/typescript/src/groupDrivers.ios.d.ts.map +1 -0
- package/lib/typescript/src/groupDrivers.native.d.ts +4 -0
- package/lib/typescript/src/groupDrivers.native.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/presentationProtocol.d.ts +4 -0
- package/lib/typescript/src/presentationProtocol.d.ts.map +1 -0
- package/package.json +10 -11
- package/src/NativeSmoothClipModule.ts +275 -0
- package/src/SmoothClipView.ios.tsx +30 -11
- package/src/SmoothClipView.tsx +2 -76
- package/src/SmoothClipViewNativeComponent.ts +27 -1
- package/src/capabilities.native.ts +69 -0
- package/src/capabilities.ts +2 -0
- package/src/capabilityTypes.ts +17 -0
- package/src/driverState.ts +1 -41
- package/src/driverTypes.ts +56 -11
- package/src/drivers.native.ts +921 -151
- package/src/drivers.ts +2 -423
- package/src/geometry.ts +231 -27
- package/src/groupDriverTypes.ts +117 -0
- package/src/groupDrivers.android.ts +1 -0
- package/src/groupDrivers.ios.ts +1 -0
- package/src/groupDrivers.native.ts +1189 -0
- package/src/groupDrivers.ts +1 -0
- package/src/index.ts +30 -2
- package/src/presentationProtocol.ts +28 -0
- package/lib/module/SmoothClipView.web.js +0 -54
- package/lib/module/SmoothClipView.web.js.map +0 -1
- package/lib/module/index.web.js +0 -8
- package/lib/module/index.web.js.map +0 -1
- package/lib/module/webClipPath.js +0 -25
- package/lib/module/webClipPath.js.map +0 -1
- package/lib/typescript/src/SmoothClipView.web.d.ts +0 -10
- package/lib/typescript/src/SmoothClipView.web.d.ts.map +0 -1
- package/lib/typescript/src/index.web.d.ts +0 -9
- package/lib/typescript/src/index.web.d.ts.map +0 -1
- package/lib/typescript/src/webClipPath.d.ts +0 -7
- package/lib/typescript/src/webClipPath.d.ts.map +0 -1
- package/src/SmoothClipView.web.tsx +0 -66
- package/src/index.web.ts +0 -23
- package/src/webClipPath.ts +0 -30
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#include "SmoothClipTurboModule.h"
|
|
2
2
|
|
|
3
|
+
#include "SmoothClipAnimationCurve.h"
|
|
3
4
|
#include "SmoothClipRegistry.h"
|
|
5
|
+
#include "SmoothClipRegistrySnapshot.h"
|
|
4
6
|
|
|
5
7
|
#include <cmath>
|
|
6
8
|
#include <utility>
|
|
@@ -27,6 +29,252 @@ bool finitePresentation(const smoothclip::Presentation &presentation) {
|
|
|
27
29
|
std::isfinite(presentation.contentTranslateY);
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
bool validCurveCode(int32_t curveCode) {
|
|
33
|
+
return curveCode == static_cast<int32_t>(smoothclip::ClipCurve::Circular) ||
|
|
34
|
+
curveCode == static_cast<int32_t>(smoothclip::ClipCurve::Continuous);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
bool validSuspensionPolicy(int32_t value) {
|
|
38
|
+
return value == static_cast<int32_t>(
|
|
39
|
+
smoothclip::GroupSuspensionPolicy::Pause) ||
|
|
40
|
+
value == static_cast<int32_t>(
|
|
41
|
+
smoothclip::GroupSuspensionPolicy::Finish);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
bool numberAt(
|
|
45
|
+
jsi::Runtime &runtime,
|
|
46
|
+
const jsi::Array &array,
|
|
47
|
+
size_t index,
|
|
48
|
+
double &result) {
|
|
49
|
+
if (index >= array.size(runtime)) return false;
|
|
50
|
+
const jsi::Value value = array.getValueAtIndex(runtime, index);
|
|
51
|
+
if (!value.isNumber()) return false;
|
|
52
|
+
result = value.asNumber();
|
|
53
|
+
return std::isfinite(result);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
smoothclip::Presentation presentationV2(
|
|
57
|
+
double x,
|
|
58
|
+
double y,
|
|
59
|
+
double width,
|
|
60
|
+
double height,
|
|
61
|
+
double topLeftRadius,
|
|
62
|
+
double topRightRadius,
|
|
63
|
+
double bottomRightRadius,
|
|
64
|
+
double bottomLeftRadius,
|
|
65
|
+
int32_t curveCode,
|
|
66
|
+
double contentTranslateX,
|
|
67
|
+
double contentTranslateY,
|
|
68
|
+
double contentScale) {
|
|
69
|
+
const bool uniform = topLeftRadius == topRightRadius &&
|
|
70
|
+
topLeftRadius == bottomRightRadius &&
|
|
71
|
+
topLeftRadius == bottomLeftRadius;
|
|
72
|
+
smoothclip::Geometry geometry{
|
|
73
|
+
x, y, width, height, uniform ? topLeftRadius : 0};
|
|
74
|
+
geometry.topLeftRadius = topLeftRadius;
|
|
75
|
+
geometry.topRightRadius = topRightRadius;
|
|
76
|
+
geometry.bottomRightRadius = bottomRightRadius;
|
|
77
|
+
geometry.bottomLeftRadius = bottomLeftRadius;
|
|
78
|
+
geometry.curve = static_cast<smoothclip::ClipCurve>(curveCode);
|
|
79
|
+
return {geometry, contentTranslateX, contentTranslateY, contentScale};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
bool finitePresentationV2(const smoothclip::Presentation &presentation) {
|
|
83
|
+
const smoothclip::Geometry &geometry = presentation.clip;
|
|
84
|
+
return finiteGeometry(geometry) &&
|
|
85
|
+
std::isfinite(geometry.topLeftRadius) &&
|
|
86
|
+
std::isfinite(geometry.topRightRadius) &&
|
|
87
|
+
std::isfinite(geometry.bottomRightRadius) &&
|
|
88
|
+
std::isfinite(geometry.bottomLeftRadius) &&
|
|
89
|
+
validCurveCode(static_cast<int32_t>(geometry.curve)) &&
|
|
90
|
+
std::isfinite(presentation.contentTranslateX) &&
|
|
91
|
+
std::isfinite(presentation.contentTranslateY) &&
|
|
92
|
+
std::isfinite(presentation.contentScale) &&
|
|
93
|
+
presentation.contentScale > 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
bool presentationV2At(
|
|
97
|
+
jsi::Runtime &runtime,
|
|
98
|
+
const jsi::Array &array,
|
|
99
|
+
size_t offset,
|
|
100
|
+
smoothclip::Presentation &result) {
|
|
101
|
+
double values[12];
|
|
102
|
+
for (size_t index = 0; index < 12; index += 1) {
|
|
103
|
+
if (!numberAt(runtime, array, offset + index, values[index])) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const int32_t curveCode = static_cast<int32_t>(values[8]);
|
|
108
|
+
if (values[8] != curveCode || !validCurveCode(curveCode)) return false;
|
|
109
|
+
result = presentationV2(
|
|
110
|
+
values[0],
|
|
111
|
+
values[1],
|
|
112
|
+
values[2],
|
|
113
|
+
values[3],
|
|
114
|
+
values[4],
|
|
115
|
+
values[5],
|
|
116
|
+
values[6],
|
|
117
|
+
values[7],
|
|
118
|
+
curveCode,
|
|
119
|
+
values[9],
|
|
120
|
+
values[10],
|
|
121
|
+
values[11]);
|
|
122
|
+
return finitePresentationV2(result);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
void writePresentationV2(
|
|
126
|
+
jsi::Runtime &runtime,
|
|
127
|
+
jsi::Array &result,
|
|
128
|
+
size_t offset,
|
|
129
|
+
const smoothclip::Presentation &presentation) {
|
|
130
|
+
const smoothclip::Geometry &clip = presentation.clip;
|
|
131
|
+
result.setValueAtIndex(runtime, offset, clip.x);
|
|
132
|
+
result.setValueAtIndex(runtime, offset + 1, clip.y);
|
|
133
|
+
result.setValueAtIndex(runtime, offset + 2, clip.width);
|
|
134
|
+
result.setValueAtIndex(runtime, offset + 3, clip.height);
|
|
135
|
+
result.setValueAtIndex(
|
|
136
|
+
runtime, offset + 4,
|
|
137
|
+
smoothclip::resolvedRadius(clip.topLeftRadius, clip.radius));
|
|
138
|
+
result.setValueAtIndex(
|
|
139
|
+
runtime, offset + 5,
|
|
140
|
+
smoothclip::resolvedRadius(clip.topRightRadius, clip.radius));
|
|
141
|
+
result.setValueAtIndex(
|
|
142
|
+
runtime, offset + 6,
|
|
143
|
+
smoothclip::resolvedRadius(clip.bottomRightRadius, clip.radius));
|
|
144
|
+
result.setValueAtIndex(
|
|
145
|
+
runtime, offset + 7,
|
|
146
|
+
smoothclip::resolvedRadius(clip.bottomLeftRadius, clip.radius));
|
|
147
|
+
result.setValueAtIndex(
|
|
148
|
+
runtime, offset + 8, static_cast<int32_t>(clip.curve));
|
|
149
|
+
result.setValueAtIndex(runtime, offset + 9, presentation.contentTranslateX);
|
|
150
|
+
result.setValueAtIndex(runtime, offset + 10, presentation.contentTranslateY);
|
|
151
|
+
result.setValueAtIndex(runtime, offset + 11, presentation.contentScale);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
jsi::Array snapshotArrayV2(
|
|
155
|
+
jsi::Runtime &runtime,
|
|
156
|
+
const std::vector<smoothclip::DriverSnapshot> &snapshots) {
|
|
157
|
+
jsi::Array result(runtime, snapshots.size() * 13);
|
|
158
|
+
for (size_t index = 0; index < snapshots.size(); index += 1) {
|
|
159
|
+
const size_t offset = index * 13;
|
|
160
|
+
result.setValueAtIndex(
|
|
161
|
+
runtime, offset, snapshots[index].ready ? 1.0 : 0.0);
|
|
162
|
+
writePresentationV2(
|
|
163
|
+
runtime, result, offset + 1, snapshots[index].presentation);
|
|
164
|
+
}
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
bool driverIdsAt(
|
|
169
|
+
jsi::Runtime &runtime,
|
|
170
|
+
const jsi::Array &array,
|
|
171
|
+
std::vector<uint64_t> &result) {
|
|
172
|
+
result.clear();
|
|
173
|
+
result.reserve(array.size(runtime));
|
|
174
|
+
for (size_t index = 0; index < array.size(runtime); index += 1) {
|
|
175
|
+
double driverId = 0;
|
|
176
|
+
if (!numberAt(runtime, array, index, driverId) ||
|
|
177
|
+
!validDriverId(driverId)) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
result.push_back(static_cast<uint64_t>(driverId));
|
|
181
|
+
}
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
bool fixedGroupEntriesAt(
|
|
186
|
+
jsi::Runtime &runtime,
|
|
187
|
+
const jsi::Array &array,
|
|
188
|
+
std::vector<smoothclip::GroupMotionEntry> &result) {
|
|
189
|
+
constexpr size_t stride = 26;
|
|
190
|
+
const size_t count = array.size(runtime);
|
|
191
|
+
if (count == 0 || count % stride != 0) return false;
|
|
192
|
+
result.clear();
|
|
193
|
+
result.reserve(count / stride);
|
|
194
|
+
for (size_t offset = 0; offset < count; offset += stride) {
|
|
195
|
+
double rawDriverId = 0;
|
|
196
|
+
double rawHasFrom = 0;
|
|
197
|
+
smoothclip::Presentation from;
|
|
198
|
+
smoothclip::Presentation target;
|
|
199
|
+
if (!numberAt(runtime, array, offset, rawDriverId) ||
|
|
200
|
+
!validDriverId(rawDriverId) ||
|
|
201
|
+
!numberAt(runtime, array, offset + 1, rawHasFrom) ||
|
|
202
|
+
(rawHasFrom != 0 && rawHasFrom != 1) ||
|
|
203
|
+
!presentationV2At(runtime, array, offset + 2, from) ||
|
|
204
|
+
!presentationV2At(runtime, array, offset + 14, target)) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
result.push_back({
|
|
208
|
+
static_cast<uint64_t>(rawDriverId),
|
|
209
|
+
rawHasFrom == 1,
|
|
210
|
+
from,
|
|
211
|
+
target,
|
|
212
|
+
{},
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
bool keyframeGroupEntriesAt(
|
|
219
|
+
jsi::Runtime &runtime,
|
|
220
|
+
const jsi::Array &array,
|
|
221
|
+
std::vector<smoothclip::GroupMotionEntry> &result) {
|
|
222
|
+
const size_t count = array.size(runtime);
|
|
223
|
+
if (count == 0) return false;
|
|
224
|
+
result.clear();
|
|
225
|
+
size_t cursor = 0;
|
|
226
|
+
while (cursor < count) {
|
|
227
|
+
constexpr size_t prefix = 27;
|
|
228
|
+
if (count - cursor < prefix) return false;
|
|
229
|
+
double rawDriverId = 0;
|
|
230
|
+
double rawHasFrom = 0;
|
|
231
|
+
double rawFrameCount = 0;
|
|
232
|
+
smoothclip::Presentation from;
|
|
233
|
+
smoothclip::Presentation target;
|
|
234
|
+
if (!numberAt(runtime, array, cursor, rawDriverId) ||
|
|
235
|
+
!validDriverId(rawDriverId) ||
|
|
236
|
+
!numberAt(runtime, array, cursor + 1, rawHasFrom) ||
|
|
237
|
+
(rawHasFrom != 0 && rawHasFrom != 1) ||
|
|
238
|
+
!presentationV2At(runtime, array, cursor + 2, from) ||
|
|
239
|
+
!presentationV2At(runtime, array, cursor + 14, target) ||
|
|
240
|
+
!numberAt(runtime, array, cursor + 26, rawFrameCount) ||
|
|
241
|
+
rawFrameCount < 2 || std::floor(rawFrameCount) != rawFrameCount) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
const size_t frameCount = static_cast<size_t>(rawFrameCount);
|
|
245
|
+
if (frameCount > (count - cursor - prefix) / 13) return false;
|
|
246
|
+
std::vector<smoothclip::Keyframe> keyframes;
|
|
247
|
+
keyframes.reserve(frameCount);
|
|
248
|
+
double previousOffset = -1;
|
|
249
|
+
const size_t framesOffset = cursor + prefix;
|
|
250
|
+
for (size_t frameIndex = 0; frameIndex < frameCount; frameIndex += 1) {
|
|
251
|
+
const size_t frameOffset = framesOffset + frameIndex * 13;
|
|
252
|
+
double offset = 0;
|
|
253
|
+
smoothclip::Presentation presentation;
|
|
254
|
+
if (!numberAt(runtime, array, frameOffset, offset) || offset < 0 ||
|
|
255
|
+
offset > 1 || offset <= previousOffset ||
|
|
256
|
+
!presentationV2At(
|
|
257
|
+
runtime, array, frameOffset + 1, presentation)) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
previousOffset = offset;
|
|
261
|
+
keyframes.push_back({offset, presentation});
|
|
262
|
+
}
|
|
263
|
+
if (keyframes.front().offset != 0 || keyframes.back().offset != 1) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
result.push_back({
|
|
267
|
+
static_cast<uint64_t>(rawDriverId),
|
|
268
|
+
rawHasFrom == 1,
|
|
269
|
+
from,
|
|
270
|
+
target,
|
|
271
|
+
std::move(keyframes),
|
|
272
|
+
});
|
|
273
|
+
cursor = framesOffset + frameCount * 13;
|
|
274
|
+
}
|
|
275
|
+
return !result.empty();
|
|
276
|
+
}
|
|
277
|
+
|
|
30
278
|
jsi::Array presentationArray(
|
|
31
279
|
jsi::Runtime &runtime,
|
|
32
280
|
smoothclip::Presentation presentation,
|
|
@@ -48,6 +296,18 @@ jsi::Array presentationArray(
|
|
|
48
296
|
return result;
|
|
49
297
|
}
|
|
50
298
|
|
|
299
|
+
jsi::Array presentationArrayV2(
|
|
300
|
+
jsi::Runtime &runtime,
|
|
301
|
+
smoothclip::Presentation presentation,
|
|
302
|
+
bool includeHandled = false,
|
|
303
|
+
bool handled = true) {
|
|
304
|
+
const size_t offset = includeHandled ? 1 : 0;
|
|
305
|
+
jsi::Array result(runtime, offset + 12);
|
|
306
|
+
if (includeHandled) result.setValueAtIndex(runtime, 0, handled ? 1.0 : 0.0);
|
|
307
|
+
writePresentationV2(runtime, result, offset, presentation);
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
310
|
+
|
|
51
311
|
} // namespace
|
|
52
312
|
|
|
53
313
|
SmoothClipTurboModule::SmoothClipTurboModule(
|
|
@@ -59,10 +319,240 @@ SmoothClipTurboModule::SmoothClipTurboModule(
|
|
|
59
319
|
emitOnClipAnimationComplete(SmoothClipAnimationCompletion{
|
|
60
320
|
static_cast<double>(driverId), animationId, finished});
|
|
61
321
|
});
|
|
322
|
+
smoothclip::setGroupCompletionCallback(
|
|
323
|
+
this,
|
|
324
|
+
[this](
|
|
325
|
+
uint64_t controllerId,
|
|
326
|
+
int32_t groupId,
|
|
327
|
+
bool finished,
|
|
328
|
+
std::vector<uint64_t> driverIds) {
|
|
329
|
+
std::vector<double> jsDriverIds;
|
|
330
|
+
jsDriverIds.reserve(driverIds.size());
|
|
331
|
+
for (const uint64_t driverId : driverIds) {
|
|
332
|
+
jsDriverIds.push_back(static_cast<double>(driverId));
|
|
333
|
+
}
|
|
334
|
+
emitOnClipGroupAnimationComplete(
|
|
335
|
+
SmoothClipGroupAnimationCompletion{
|
|
336
|
+
static_cast<double>(controllerId),
|
|
337
|
+
groupId,
|
|
338
|
+
finished,
|
|
339
|
+
std::move(jsDriverIds),
|
|
340
|
+
});
|
|
341
|
+
});
|
|
62
342
|
}
|
|
63
343
|
|
|
64
344
|
SmoothClipTurboModule::~SmoothClipTurboModule() {
|
|
65
345
|
smoothclip::clearCompletionCallback(this);
|
|
346
|
+
smoothclip::clearGroupCompletionCallback(this);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
int32_t SmoothClipTurboModule::getPresentationProtocolVersion(jsi::Runtime &) {
|
|
350
|
+
return 2;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
bool SmoothClipTurboModule::supportsAutonomousComplexPathAnimation(
|
|
354
|
+
jsi::Runtime &) {
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
jsi::Array SmoothClipTurboModule::beginGroupInteractionV2(
|
|
359
|
+
jsi::Runtime &runtime,
|
|
360
|
+
jsi::Array driverIds) {
|
|
361
|
+
std::vector<uint64_t> parsed;
|
|
362
|
+
if (!driverIdsAt(runtime, driverIds, parsed)) {
|
|
363
|
+
return jsi::Array(runtime, 0);
|
|
364
|
+
}
|
|
365
|
+
return snapshotArrayV2(
|
|
366
|
+
runtime, smoothclip::beginGroupInteraction(parsed));
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
jsi::Array SmoothClipTurboModule::snapshotGroupV2(
|
|
370
|
+
jsi::Runtime &runtime,
|
|
371
|
+
jsi::Array driverIds) {
|
|
372
|
+
std::vector<uint64_t> parsed;
|
|
373
|
+
if (!driverIdsAt(runtime, driverIds, parsed)) {
|
|
374
|
+
return jsi::Array(runtime, 0);
|
|
375
|
+
}
|
|
376
|
+
return snapshotArrayV2(runtime, smoothclip::snapshotGroup(parsed));
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
bool SmoothClipTurboModule::setClipPresentationBatchV2(
|
|
380
|
+
jsi::Runtime &runtime,
|
|
381
|
+
jsi::Array entries) {
|
|
382
|
+
constexpr size_t stride = 13;
|
|
383
|
+
const size_t count = entries.size(runtime);
|
|
384
|
+
if (count % stride != 0) return false;
|
|
385
|
+
std::vector<smoothclip::BatchEntry> parsed;
|
|
386
|
+
parsed.reserve(count / stride);
|
|
387
|
+
for (size_t offset = 0; offset < count; offset += stride) {
|
|
388
|
+
double driverId = 0;
|
|
389
|
+
smoothclip::Presentation presentation;
|
|
390
|
+
if (!numberAt(runtime, entries, offset, driverId) ||
|
|
391
|
+
!validDriverId(driverId) ||
|
|
392
|
+
!presentationV2At(runtime, entries, offset + 1, presentation)) {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
parsed.push_back(
|
|
396
|
+
{static_cast<uint64_t>(driverId), presentation});
|
|
397
|
+
}
|
|
398
|
+
return smoothclip::setPresentationBatch(parsed);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
int32_t SmoothClipTurboModule::animateTimingGroupV2(
|
|
402
|
+
jsi::Runtime &runtime,
|
|
403
|
+
double controllerId,
|
|
404
|
+
jsi::Array entries,
|
|
405
|
+
double durationMs,
|
|
406
|
+
double controlPoint1X,
|
|
407
|
+
double controlPoint1Y,
|
|
408
|
+
double controlPoint2X,
|
|
409
|
+
double controlPoint2Y,
|
|
410
|
+
int32_t reduceMotion,
|
|
411
|
+
int32_t suspensionPolicy) {
|
|
412
|
+
std::vector<smoothclip::GroupMotionEntry> parsed;
|
|
413
|
+
if (!validDriverId(controllerId) ||
|
|
414
|
+
!fixedGroupEntriesAt(runtime, entries, parsed) ||
|
|
415
|
+
!std::isfinite(durationMs) || !std::isfinite(controlPoint1X) ||
|
|
416
|
+
!std::isfinite(controlPoint1Y) || !std::isfinite(controlPoint2X) ||
|
|
417
|
+
!std::isfinite(controlPoint2Y) ||
|
|
418
|
+
!validSuspensionPolicy(suspensionPolicy)) {
|
|
419
|
+
return 0;
|
|
420
|
+
}
|
|
421
|
+
return smoothclip::animateTimingGroup(
|
|
422
|
+
static_cast<uint64_t>(controllerId),
|
|
423
|
+
std::move(parsed),
|
|
424
|
+
{durationMs,
|
|
425
|
+
controlPoint1X,
|
|
426
|
+
controlPoint1Y,
|
|
427
|
+
controlPoint2X,
|
|
428
|
+
controlPoint2Y,
|
|
429
|
+
reduceMotion},
|
|
430
|
+
static_cast<smoothclip::GroupSuspensionPolicy>(suspensionPolicy));
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
int32_t SmoothClipTurboModule::animateSpringGroupV2(
|
|
434
|
+
jsi::Runtime &runtime,
|
|
435
|
+
double controllerId,
|
|
436
|
+
jsi::Array entries,
|
|
437
|
+
double mass,
|
|
438
|
+
double stiffness,
|
|
439
|
+
double damping,
|
|
440
|
+
double initialVelocity,
|
|
441
|
+
bool inheritVelocity,
|
|
442
|
+
int32_t reduceMotion,
|
|
443
|
+
int32_t suspensionPolicy) {
|
|
444
|
+
std::vector<smoothclip::GroupMotionEntry> parsed;
|
|
445
|
+
if (!validDriverId(controllerId) ||
|
|
446
|
+
!fixedGroupEntriesAt(runtime, entries, parsed) ||
|
|
447
|
+
!std::isfinite(mass) || !std::isfinite(stiffness) ||
|
|
448
|
+
!std::isfinite(damping) || !std::isfinite(initialVelocity) ||
|
|
449
|
+
mass <= 0 || stiffness <= 0 || damping < 0 ||
|
|
450
|
+
!validSuspensionPolicy(suspensionPolicy)) {
|
|
451
|
+
return 0;
|
|
452
|
+
}
|
|
453
|
+
return smoothclip::animateSpringGroup(
|
|
454
|
+
static_cast<uint64_t>(controllerId),
|
|
455
|
+
std::move(parsed),
|
|
456
|
+
{mass,
|
|
457
|
+
stiffness,
|
|
458
|
+
damping,
|
|
459
|
+
initialVelocity,
|
|
460
|
+
inheritVelocity,
|
|
461
|
+
reduceMotion},
|
|
462
|
+
static_cast<smoothclip::GroupSuspensionPolicy>(suspensionPolicy));
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
int32_t SmoothClipTurboModule::animateKeyframesGroupV2(
|
|
466
|
+
jsi::Runtime &runtime,
|
|
467
|
+
double controllerId,
|
|
468
|
+
jsi::Array entries,
|
|
469
|
+
double durationMs,
|
|
470
|
+
int32_t reduceMotion,
|
|
471
|
+
int32_t suspensionPolicy) {
|
|
472
|
+
std::vector<smoothclip::GroupMotionEntry> parsed;
|
|
473
|
+
if (!validDriverId(controllerId) ||
|
|
474
|
+
!keyframeGroupEntriesAt(runtime, entries, parsed) ||
|
|
475
|
+
!std::isfinite(durationMs) ||
|
|
476
|
+
!validSuspensionPolicy(suspensionPolicy)) {
|
|
477
|
+
return 0;
|
|
478
|
+
}
|
|
479
|
+
return smoothclip::animateKeyframesGroup(
|
|
480
|
+
static_cast<uint64_t>(controllerId),
|
|
481
|
+
std::move(parsed),
|
|
482
|
+
durationMs,
|
|
483
|
+
reduceMotion,
|
|
484
|
+
static_cast<smoothclip::GroupSuspensionPolicy>(suspensionPolicy));
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
jsi::Array SmoothClipTurboModule::cancelAnimationGroupV2(
|
|
488
|
+
jsi::Runtime &runtime,
|
|
489
|
+
int32_t groupId,
|
|
490
|
+
int32_t behavior) {
|
|
491
|
+
if (groupId <= 0 ||
|
|
492
|
+
(behavior != static_cast<int32_t>(
|
|
493
|
+
smoothclip::GroupCancelBehavior::Freeze) &&
|
|
494
|
+
behavior != static_cast<int32_t>(
|
|
495
|
+
smoothclip::GroupCancelBehavior::Finish))) {
|
|
496
|
+
return jsi::Array(runtime, 0);
|
|
497
|
+
}
|
|
498
|
+
return snapshotArrayV2(
|
|
499
|
+
runtime,
|
|
500
|
+
smoothclip::cancelAnimationGroup(
|
|
501
|
+
groupId,
|
|
502
|
+
static_cast<smoothclip::GroupCancelBehavior>(behavior)));
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
void SmoothClipTurboModule::setClipPresentationV2(
|
|
506
|
+
jsi::Runtime &,
|
|
507
|
+
double driverId,
|
|
508
|
+
double x,
|
|
509
|
+
double y,
|
|
510
|
+
double width,
|
|
511
|
+
double height,
|
|
512
|
+
double topLeftRadius,
|
|
513
|
+
double topRightRadius,
|
|
514
|
+
double bottomRightRadius,
|
|
515
|
+
double bottomLeftRadius,
|
|
516
|
+
int32_t curveCode,
|
|
517
|
+
double contentTranslateX,
|
|
518
|
+
double contentTranslateY,
|
|
519
|
+
double contentScale,
|
|
520
|
+
bool takeOwnership,
|
|
521
|
+
bool overridePendingAnimation) {
|
|
522
|
+
const smoothclip::Presentation presentation = presentationV2(
|
|
523
|
+
x, y, width, height, topLeftRadius, topRightRadius,
|
|
524
|
+
bottomRightRadius, bottomLeftRadius, curveCode,
|
|
525
|
+
contentTranslateX, contentTranslateY, contentScale);
|
|
526
|
+
if (validDriverId(driverId) && finitePresentationV2(presentation)) {
|
|
527
|
+
smoothclip::setPresentation(
|
|
528
|
+
static_cast<uint64_t>(driverId), presentation, takeOwnership,
|
|
529
|
+
overridePendingAnimation);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
jsi::Array SmoothClipTurboModule::beginInteractionV2(
|
|
534
|
+
jsi::Runtime &runtime,
|
|
535
|
+
double driverId) {
|
|
536
|
+
if (!validDriverId(driverId)) {
|
|
537
|
+
return presentationArrayV2(
|
|
538
|
+
runtime, presentationV2(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1));
|
|
539
|
+
}
|
|
540
|
+
return presentationArrayV2(
|
|
541
|
+
runtime,
|
|
542
|
+
smoothclip::beginInteraction(static_cast<uint64_t>(driverId)));
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
jsi::Array SmoothClipTurboModule::snapshotCurrentV2(
|
|
546
|
+
jsi::Runtime &runtime,
|
|
547
|
+
double driverId) {
|
|
548
|
+
if (!validDriverId(driverId)) {
|
|
549
|
+
return presentationArrayV2(
|
|
550
|
+
runtime, presentationV2(NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN,
|
|
551
|
+
0, NAN, NAN, NAN));
|
|
552
|
+
}
|
|
553
|
+
return presentationArrayV2(
|
|
554
|
+
runtime,
|
|
555
|
+
smoothclip::snapshotCurrent(static_cast<uint64_t>(driverId)));
|
|
66
556
|
}
|
|
67
557
|
|
|
68
558
|
void SmoothClipTurboModule::setClipPresentation(
|
|
@@ -141,6 +631,68 @@ int32_t SmoothClipTurboModule::animateTiming(
|
|
|
141
631
|
!std::isfinite(controlPoint1Y) || !std::isfinite(controlPoint2X) ||
|
|
142
632
|
!std::isfinite(controlPoint2Y)) return 0;
|
|
143
633
|
|
|
634
|
+
return smoothclip::animateTiming(
|
|
635
|
+
static_cast<uint64_t>(driverId),
|
|
636
|
+
{hasInteractiveStart, startPresentation},
|
|
637
|
+
presentation,
|
|
638
|
+
animation,
|
|
639
|
+
smoothclip::AnimationValidationMode::LegacyV1);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
int32_t SmoothClipTurboModule::animateTimingV2(
|
|
643
|
+
jsi::Runtime &,
|
|
644
|
+
double driverId,
|
|
645
|
+
bool hasInteractiveStart,
|
|
646
|
+
double startX,
|
|
647
|
+
double startY,
|
|
648
|
+
double startWidth,
|
|
649
|
+
double startHeight,
|
|
650
|
+
double startTopLeftRadius,
|
|
651
|
+
double startTopRightRadius,
|
|
652
|
+
double startBottomRightRadius,
|
|
653
|
+
double startBottomLeftRadius,
|
|
654
|
+
int32_t startCurveCode,
|
|
655
|
+
double startContentTranslateX,
|
|
656
|
+
double startContentTranslateY,
|
|
657
|
+
double startContentScale,
|
|
658
|
+
double x,
|
|
659
|
+
double y,
|
|
660
|
+
double width,
|
|
661
|
+
double height,
|
|
662
|
+
double topLeftRadius,
|
|
663
|
+
double topRightRadius,
|
|
664
|
+
double bottomRightRadius,
|
|
665
|
+
double bottomLeftRadius,
|
|
666
|
+
int32_t curveCode,
|
|
667
|
+
double contentTranslateX,
|
|
668
|
+
double contentTranslateY,
|
|
669
|
+
double contentScale,
|
|
670
|
+
double durationMs,
|
|
671
|
+
double controlPoint1X,
|
|
672
|
+
double controlPoint1Y,
|
|
673
|
+
double controlPoint2X,
|
|
674
|
+
double controlPoint2Y,
|
|
675
|
+
int32_t reduceMotion) {
|
|
676
|
+
const smoothclip::Presentation startPresentation = presentationV2(
|
|
677
|
+
startX, startY, startWidth, startHeight,
|
|
678
|
+
startTopLeftRadius, startTopRightRadius,
|
|
679
|
+
startBottomRightRadius, startBottomLeftRadius, startCurveCode,
|
|
680
|
+
startContentTranslateX, startContentTranslateY, startContentScale);
|
|
681
|
+
const smoothclip::Presentation presentation = presentationV2(
|
|
682
|
+
x, y, width, height, topLeftRadius, topRightRadius,
|
|
683
|
+
bottomRightRadius, bottomLeftRadius, curveCode,
|
|
684
|
+
contentTranslateX, contentTranslateY, contentScale);
|
|
685
|
+
const smoothclip::TimingAnimation animation{
|
|
686
|
+
durationMs, controlPoint1X, controlPoint1Y,
|
|
687
|
+
controlPoint2X, controlPoint2Y, reduceMotion};
|
|
688
|
+
if (!validDriverId(driverId) ||
|
|
689
|
+
!finitePresentationV2(startPresentation) ||
|
|
690
|
+
!finitePresentationV2(presentation) ||
|
|
691
|
+
!std::isfinite(durationMs) || !std::isfinite(controlPoint1X) ||
|
|
692
|
+
!std::isfinite(controlPoint1Y) || !std::isfinite(controlPoint2X) ||
|
|
693
|
+
!std::isfinite(controlPoint2Y)) {
|
|
694
|
+
return 0;
|
|
695
|
+
}
|
|
144
696
|
return smoothclip::animateTiming(
|
|
145
697
|
static_cast<uint64_t>(driverId),
|
|
146
698
|
{hasInteractiveStart, startPresentation},
|
|
@@ -189,9 +741,70 @@ int32_t SmoothClipTurboModule::animateSpring(
|
|
|
189
741
|
!finitePresentation(startPresentation) ||
|
|
190
742
|
!finitePresentation(presentation) ||
|
|
191
743
|
!std::isfinite(mass) || !std::isfinite(stiffness) ||
|
|
192
|
-
!std::isfinite(damping) || !std::isfinite(initialVelocity)
|
|
193
|
-
mass <= 0 || stiffness <= 0 || damping < 0) return 0;
|
|
744
|
+
!std::isfinite(damping) || !std::isfinite(initialVelocity)) return 0;
|
|
194
745
|
|
|
746
|
+
return smoothclip::animateSpring(
|
|
747
|
+
static_cast<uint64_t>(driverId),
|
|
748
|
+
{hasInteractiveStart, startPresentation},
|
|
749
|
+
presentation,
|
|
750
|
+
animation,
|
|
751
|
+
smoothclip::AnimationValidationMode::LegacyV1);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
int32_t SmoothClipTurboModule::animateSpringV2(
|
|
755
|
+
jsi::Runtime &,
|
|
756
|
+
double driverId,
|
|
757
|
+
bool hasInteractiveStart,
|
|
758
|
+
double startX,
|
|
759
|
+
double startY,
|
|
760
|
+
double startWidth,
|
|
761
|
+
double startHeight,
|
|
762
|
+
double startTopLeftRadius,
|
|
763
|
+
double startTopRightRadius,
|
|
764
|
+
double startBottomRightRadius,
|
|
765
|
+
double startBottomLeftRadius,
|
|
766
|
+
int32_t startCurveCode,
|
|
767
|
+
double startContentTranslateX,
|
|
768
|
+
double startContentTranslateY,
|
|
769
|
+
double startContentScale,
|
|
770
|
+
double x,
|
|
771
|
+
double y,
|
|
772
|
+
double width,
|
|
773
|
+
double height,
|
|
774
|
+
double topLeftRadius,
|
|
775
|
+
double topRightRadius,
|
|
776
|
+
double bottomRightRadius,
|
|
777
|
+
double bottomLeftRadius,
|
|
778
|
+
int32_t curveCode,
|
|
779
|
+
double contentTranslateX,
|
|
780
|
+
double contentTranslateY,
|
|
781
|
+
double contentScale,
|
|
782
|
+
double mass,
|
|
783
|
+
double stiffness,
|
|
784
|
+
double damping,
|
|
785
|
+
double initialVelocity,
|
|
786
|
+
bool inheritVelocity,
|
|
787
|
+
int32_t reduceMotion) {
|
|
788
|
+
const smoothclip::Presentation startPresentation = presentationV2(
|
|
789
|
+
startX, startY, startWidth, startHeight,
|
|
790
|
+
startTopLeftRadius, startTopRightRadius,
|
|
791
|
+
startBottomRightRadius, startBottomLeftRadius, startCurveCode,
|
|
792
|
+
startContentTranslateX, startContentTranslateY, startContentScale);
|
|
793
|
+
const smoothclip::Presentation presentation = presentationV2(
|
|
794
|
+
x, y, width, height, topLeftRadius, topRightRadius,
|
|
795
|
+
bottomRightRadius, bottomLeftRadius, curveCode,
|
|
796
|
+
contentTranslateX, contentTranslateY, contentScale);
|
|
797
|
+
const smoothclip::SpringAnimation animation{
|
|
798
|
+
mass, stiffness, damping, initialVelocity,
|
|
799
|
+
inheritVelocity, reduceMotion};
|
|
800
|
+
if (!validDriverId(driverId) ||
|
|
801
|
+
!finitePresentationV2(startPresentation) ||
|
|
802
|
+
!finitePresentationV2(presentation) ||
|
|
803
|
+
!std::isfinite(mass) || !std::isfinite(stiffness) ||
|
|
804
|
+
!std::isfinite(damping) || !std::isfinite(initialVelocity) ||
|
|
805
|
+
mass <= 0 || stiffness <= 0 || damping < 0) {
|
|
806
|
+
return 0;
|
|
807
|
+
}
|
|
195
808
|
return smoothclip::animateSpring(
|
|
196
809
|
static_cast<uint64_t>(driverId),
|
|
197
810
|
{hasInteractiveStart, startPresentation},
|
|
@@ -252,6 +865,96 @@ int32_t SmoothClipTurboModule::animateKeyframes(
|
|
|
252
865
|
keyframes.push_back({offset, frame});
|
|
253
866
|
}
|
|
254
867
|
if (keyframes.front().offset != 0 || keyframes.back().offset != 1) return 0;
|
|
868
|
+
return smoothclip::animateKeyframes(
|
|
869
|
+
static_cast<uint64_t>(driverId),
|
|
870
|
+
{hasInteractiveStart, startPresentation},
|
|
871
|
+
presentation,
|
|
872
|
+
durationMs,
|
|
873
|
+
std::move(keyframes),
|
|
874
|
+
reduceMotion,
|
|
875
|
+
smoothclip::AnimationValidationMode::LegacyV1);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
int32_t SmoothClipTurboModule::animateKeyframesV2(
|
|
879
|
+
jsi::Runtime &runtime,
|
|
880
|
+
double driverId,
|
|
881
|
+
bool hasInteractiveStart,
|
|
882
|
+
double startX,
|
|
883
|
+
double startY,
|
|
884
|
+
double startWidth,
|
|
885
|
+
double startHeight,
|
|
886
|
+
double startTopLeftRadius,
|
|
887
|
+
double startTopRightRadius,
|
|
888
|
+
double startBottomRightRadius,
|
|
889
|
+
double startBottomLeftRadius,
|
|
890
|
+
int32_t startCurveCode,
|
|
891
|
+
double startContentTranslateX,
|
|
892
|
+
double startContentTranslateY,
|
|
893
|
+
double startContentScale,
|
|
894
|
+
double x,
|
|
895
|
+
double y,
|
|
896
|
+
double width,
|
|
897
|
+
double height,
|
|
898
|
+
double topLeftRadius,
|
|
899
|
+
double topRightRadius,
|
|
900
|
+
double bottomRightRadius,
|
|
901
|
+
double bottomLeftRadius,
|
|
902
|
+
int32_t curveCode,
|
|
903
|
+
double contentTranslateX,
|
|
904
|
+
double contentTranslateY,
|
|
905
|
+
double contentScale,
|
|
906
|
+
double durationMs,
|
|
907
|
+
jsi::Array frames,
|
|
908
|
+
int32_t reduceMotion) {
|
|
909
|
+
const smoothclip::Presentation startPresentation = presentationV2(
|
|
910
|
+
startX, startY, startWidth, startHeight,
|
|
911
|
+
startTopLeftRadius, startTopRightRadius,
|
|
912
|
+
startBottomRightRadius, startBottomLeftRadius, startCurveCode,
|
|
913
|
+
startContentTranslateX, startContentTranslateY, startContentScale);
|
|
914
|
+
const smoothclip::Presentation presentation = presentationV2(
|
|
915
|
+
x, y, width, height, topLeftRadius, topRightRadius,
|
|
916
|
+
bottomRightRadius, bottomLeftRadius, curveCode,
|
|
917
|
+
contentTranslateX, contentTranslateY, contentScale);
|
|
918
|
+
const size_t frameValueCount = frames.size(runtime);
|
|
919
|
+
if (!validDriverId(driverId) ||
|
|
920
|
+
!finitePresentationV2(startPresentation) ||
|
|
921
|
+
!finitePresentationV2(presentation) || !std::isfinite(durationMs) ||
|
|
922
|
+
frameValueCount < 26 || frameValueCount % 13 != 0) {
|
|
923
|
+
return 0;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
std::vector<smoothclip::Keyframe> keyframes;
|
|
927
|
+
keyframes.reserve(frameValueCount / 13);
|
|
928
|
+
double previousOffset = -1;
|
|
929
|
+
for (size_t index = 0; index < frameValueCount; index += 13) {
|
|
930
|
+
const double offset = frames.getValueAtIndex(runtime, index).asNumber();
|
|
931
|
+
const double rawFrameCurveCode =
|
|
932
|
+
frames.getValueAtIndex(runtime, index + 9).asNumber();
|
|
933
|
+
const int32_t frameCurveCode =
|
|
934
|
+
static_cast<int32_t>(rawFrameCurveCode);
|
|
935
|
+
const smoothclip::Presentation frame = presentationV2(
|
|
936
|
+
frames.getValueAtIndex(runtime, index + 1).asNumber(),
|
|
937
|
+
frames.getValueAtIndex(runtime, index + 2).asNumber(),
|
|
938
|
+
frames.getValueAtIndex(runtime, index + 3).asNumber(),
|
|
939
|
+
frames.getValueAtIndex(runtime, index + 4).asNumber(),
|
|
940
|
+
frames.getValueAtIndex(runtime, index + 5).asNumber(),
|
|
941
|
+
frames.getValueAtIndex(runtime, index + 6).asNumber(),
|
|
942
|
+
frames.getValueAtIndex(runtime, index + 7).asNumber(),
|
|
943
|
+
frames.getValueAtIndex(runtime, index + 8).asNumber(),
|
|
944
|
+
frameCurveCode,
|
|
945
|
+
frames.getValueAtIndex(runtime, index + 10).asNumber(),
|
|
946
|
+
frames.getValueAtIndex(runtime, index + 11).asNumber(),
|
|
947
|
+
frames.getValueAtIndex(runtime, index + 12).asNumber());
|
|
948
|
+
if (!std::isfinite(rawFrameCurveCode) ||
|
|
949
|
+
rawFrameCurveCode != frameCurveCode ||
|
|
950
|
+
!std::isfinite(offset) || offset < 0 || offset > 1 ||
|
|
951
|
+
offset <= previousOffset || !finitePresentationV2(frame)) {
|
|
952
|
+
return 0;
|
|
953
|
+
}
|
|
954
|
+
previousOffset = offset;
|
|
955
|
+
keyframes.push_back({offset, frame});
|
|
956
|
+
}
|
|
957
|
+
if (keyframes.front().offset != 0 || keyframes.back().offset != 1) return 0;
|
|
255
958
|
return smoothclip::animateKeyframes(
|
|
256
959
|
static_cast<uint64_t>(driverId),
|
|
257
960
|
{hasInteractiveStart, startPresentation},
|
|
@@ -261,6 +964,140 @@ int32_t SmoothClipTurboModule::animateKeyframes(
|
|
|
261
964
|
reduceMotion);
|
|
262
965
|
}
|
|
263
966
|
|
|
967
|
+
int32_t SmoothClipTurboModule::animateTimingFromV2(
|
|
968
|
+
jsi::Runtime &runtime,
|
|
969
|
+
double driverId,
|
|
970
|
+
double startX,
|
|
971
|
+
double startY,
|
|
972
|
+
double startWidth,
|
|
973
|
+
double startHeight,
|
|
974
|
+
double startTopLeftRadius,
|
|
975
|
+
double startTopRightRadius,
|
|
976
|
+
double startBottomRightRadius,
|
|
977
|
+
double startBottomLeftRadius,
|
|
978
|
+
int32_t startCurveCode,
|
|
979
|
+
double startContentTranslateX,
|
|
980
|
+
double startContentTranslateY,
|
|
981
|
+
double startContentScale,
|
|
982
|
+
double x,
|
|
983
|
+
double y,
|
|
984
|
+
double width,
|
|
985
|
+
double height,
|
|
986
|
+
double topLeftRadius,
|
|
987
|
+
double topRightRadius,
|
|
988
|
+
double bottomRightRadius,
|
|
989
|
+
double bottomLeftRadius,
|
|
990
|
+
int32_t curveCode,
|
|
991
|
+
double contentTranslateX,
|
|
992
|
+
double contentTranslateY,
|
|
993
|
+
double contentScale,
|
|
994
|
+
double durationMs,
|
|
995
|
+
double controlPoint1X,
|
|
996
|
+
double controlPoint1Y,
|
|
997
|
+
double controlPoint2X,
|
|
998
|
+
double controlPoint2Y,
|
|
999
|
+
int32_t reduceMotion) {
|
|
1000
|
+
return animateTimingV2(
|
|
1001
|
+
runtime, driverId, true,
|
|
1002
|
+
startX, startY, startWidth, startHeight,
|
|
1003
|
+
startTopLeftRadius, startTopRightRadius,
|
|
1004
|
+
startBottomRightRadius, startBottomLeftRadius, startCurveCode,
|
|
1005
|
+
startContentTranslateX, startContentTranslateY, startContentScale,
|
|
1006
|
+
x, y, width, height,
|
|
1007
|
+
topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius,
|
|
1008
|
+
curveCode, contentTranslateX, contentTranslateY, contentScale,
|
|
1009
|
+
durationMs, controlPoint1X, controlPoint1Y,
|
|
1010
|
+
controlPoint2X, controlPoint2Y, reduceMotion);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
int32_t SmoothClipTurboModule::animateSpringFromV2(
|
|
1014
|
+
jsi::Runtime &runtime,
|
|
1015
|
+
double driverId,
|
|
1016
|
+
double startX,
|
|
1017
|
+
double startY,
|
|
1018
|
+
double startWidth,
|
|
1019
|
+
double startHeight,
|
|
1020
|
+
double startTopLeftRadius,
|
|
1021
|
+
double startTopRightRadius,
|
|
1022
|
+
double startBottomRightRadius,
|
|
1023
|
+
double startBottomLeftRadius,
|
|
1024
|
+
int32_t startCurveCode,
|
|
1025
|
+
double startContentTranslateX,
|
|
1026
|
+
double startContentTranslateY,
|
|
1027
|
+
double startContentScale,
|
|
1028
|
+
double x,
|
|
1029
|
+
double y,
|
|
1030
|
+
double width,
|
|
1031
|
+
double height,
|
|
1032
|
+
double topLeftRadius,
|
|
1033
|
+
double topRightRadius,
|
|
1034
|
+
double bottomRightRadius,
|
|
1035
|
+
double bottomLeftRadius,
|
|
1036
|
+
int32_t curveCode,
|
|
1037
|
+
double contentTranslateX,
|
|
1038
|
+
double contentTranslateY,
|
|
1039
|
+
double contentScale,
|
|
1040
|
+
double mass,
|
|
1041
|
+
double stiffness,
|
|
1042
|
+
double damping,
|
|
1043
|
+
double initialVelocity,
|
|
1044
|
+
bool inheritVelocity,
|
|
1045
|
+
int32_t reduceMotion) {
|
|
1046
|
+
return animateSpringV2(
|
|
1047
|
+
runtime, driverId, true,
|
|
1048
|
+
startX, startY, startWidth, startHeight,
|
|
1049
|
+
startTopLeftRadius, startTopRightRadius,
|
|
1050
|
+
startBottomRightRadius, startBottomLeftRadius, startCurveCode,
|
|
1051
|
+
startContentTranslateX, startContentTranslateY, startContentScale,
|
|
1052
|
+
x, y, width, height,
|
|
1053
|
+
topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius,
|
|
1054
|
+
curveCode, contentTranslateX, contentTranslateY, contentScale,
|
|
1055
|
+
mass, stiffness, damping, initialVelocity, inheritVelocity,
|
|
1056
|
+
reduceMotion);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
int32_t SmoothClipTurboModule::animateKeyframesFromV2(
|
|
1060
|
+
jsi::Runtime &runtime,
|
|
1061
|
+
double driverId,
|
|
1062
|
+
double startX,
|
|
1063
|
+
double startY,
|
|
1064
|
+
double startWidth,
|
|
1065
|
+
double startHeight,
|
|
1066
|
+
double startTopLeftRadius,
|
|
1067
|
+
double startTopRightRadius,
|
|
1068
|
+
double startBottomRightRadius,
|
|
1069
|
+
double startBottomLeftRadius,
|
|
1070
|
+
int32_t startCurveCode,
|
|
1071
|
+
double startContentTranslateX,
|
|
1072
|
+
double startContentTranslateY,
|
|
1073
|
+
double startContentScale,
|
|
1074
|
+
double x,
|
|
1075
|
+
double y,
|
|
1076
|
+
double width,
|
|
1077
|
+
double height,
|
|
1078
|
+
double topLeftRadius,
|
|
1079
|
+
double topRightRadius,
|
|
1080
|
+
double bottomRightRadius,
|
|
1081
|
+
double bottomLeftRadius,
|
|
1082
|
+
int32_t curveCode,
|
|
1083
|
+
double contentTranslateX,
|
|
1084
|
+
double contentTranslateY,
|
|
1085
|
+
double contentScale,
|
|
1086
|
+
double durationMs,
|
|
1087
|
+
jsi::Array frames,
|
|
1088
|
+
int32_t reduceMotion) {
|
|
1089
|
+
return animateKeyframesV2(
|
|
1090
|
+
runtime, driverId, true,
|
|
1091
|
+
startX, startY, startWidth, startHeight,
|
|
1092
|
+
startTopLeftRadius, startTopRightRadius,
|
|
1093
|
+
startBottomRightRadius, startBottomLeftRadius, startCurveCode,
|
|
1094
|
+
startContentTranslateX, startContentTranslateY, startContentScale,
|
|
1095
|
+
x, y, width, height,
|
|
1096
|
+
topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius,
|
|
1097
|
+
curveCode, contentTranslateX, contentTranslateY, contentScale,
|
|
1098
|
+
durationMs, std::move(frames), reduceMotion);
|
|
1099
|
+
}
|
|
1100
|
+
|
|
264
1101
|
int32_t SmoothClipTurboModule::rejectAnimation(
|
|
265
1102
|
jsi::Runtime &,
|
|
266
1103
|
double driverId) {
|
|
@@ -283,6 +1120,24 @@ jsi::Array SmoothClipTurboModule::cancelAnimation(
|
|
|
283
1120
|
runtime, result.presentation, true, result.handled);
|
|
284
1121
|
}
|
|
285
1122
|
|
|
1123
|
+
jsi::Array SmoothClipTurboModule::cancelAnimationV2(
|
|
1124
|
+
jsi::Runtime &runtime,
|
|
1125
|
+
double driverId,
|
|
1126
|
+
int32_t animationId,
|
|
1127
|
+
int32_t behavior) {
|
|
1128
|
+
if (!validDriverId(driverId)) {
|
|
1129
|
+
return presentationArrayV2(
|
|
1130
|
+
runtime,
|
|
1131
|
+
presentationV2(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
|
|
1132
|
+
true,
|
|
1133
|
+
false);
|
|
1134
|
+
}
|
|
1135
|
+
const smoothclip::CancelResult result = smoothclip::cancelAnimation(
|
|
1136
|
+
static_cast<uint64_t>(driverId), animationId, behavior == 1);
|
|
1137
|
+
return presentationArrayV2(
|
|
1138
|
+
runtime, result.presentation, true, result.handled);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
286
1141
|
void SmoothClipTurboModule::destroyDriver(jsi::Runtime &, double driverId) {
|
|
287
1142
|
if (validDriverId(driverId)) {
|
|
288
1143
|
smoothclip::destroyDriver(static_cast<uint64_t>(driverId));
|