react-native-smooth-clip-view 0.3.0 → 0.4.1
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 +135 -386
- package/android/build.gradle +4 -7
- package/android/proguard-rules.pro +2 -2
- package/android/src/main/cpp/SmoothClipAndroid.h +9 -12
- package/android/src/main/cpp/SmoothClipBindings.cpp +300 -704
- package/android/src/main/cpp/SmoothClipRegistry.cpp +348 -594
- package/android/src/main/java/com/smoothclipview/ClipGeometryNormalizer.kt +36 -227
- package/android/src/main/java/com/smoothclipview/SmoothClipBindings.kt +16 -19
- package/android/src/main/java/com/smoothclipview/SmoothClipModule.kt +36 -294
- package/android/src/main/java/com/smoothclipview/SmoothClipView.kt +369 -486
- package/android/src/main/java/com/smoothclipview/SmoothClipViewManager.kt +75 -77
- package/cpp/SmoothClipAnimationCurve.h +237 -346
- package/cpp/SmoothClipRegistry.h +24 -52
- package/cpp/SmoothClipSharedGeometry.h +64 -94
- package/cpp/SmoothClipVelocityTracker.h +5 -5
- package/ios/SmoothClipGeometry.h +23 -34
- package/ios/SmoothClipRegistry.mm +206 -711
- package/ios/SmoothClipTurboModule.cpp +217 -715
- package/ios/SmoothClipTurboModule.h +54 -297
- package/ios/SmoothClipView.mm +599 -505
- package/ios/SmoothClipViewRegistry.h +2 -7
- package/lib/module/NativeSmoothClipModule.js.map +1 -1
- package/lib/module/SmoothClipView.ios.js +84 -17
- package/lib/module/SmoothClipView.ios.js.map +1 -1
- package/lib/module/SmoothClipView.js +1 -1
- package/lib/module/SmoothClipView.js.map +1 -1
- package/lib/module/SmoothClipViewNativeComponent.ts +20 -26
- package/lib/module/capabilities.native.js +1 -19
- package/lib/module/capabilities.native.js.map +1 -1
- package/lib/module/capabilityTypes.js +0 -9
- package/lib/module/capabilityTypes.js.map +1 -1
- package/lib/module/controllerInternals.js +28 -0
- package/lib/module/controllerInternals.js.map +1 -0
- package/lib/module/controllerLifecycle.js +9 -0
- package/lib/module/controllerLifecycle.js.map +1 -0
- package/lib/module/controllerTypes.js +4 -0
- package/lib/module/controllerTypes.js.map +1 -0
- package/lib/module/controllers.android.js +4 -0
- package/lib/module/controllers.android.js.map +1 -0
- package/lib/module/controllers.ios.js +4 -0
- package/lib/module/controllers.ios.js.map +1 -0
- package/lib/module/controllers.js +4 -0
- package/lib/module/controllers.js.map +1 -0
- package/lib/module/controllers.native.js +89 -0
- package/lib/module/controllers.native.js.map +1 -0
- package/lib/module/geometry.js +71 -51
- package/lib/module/geometry.js.map +1 -1
- package/lib/module/groupTypes.js +4 -0
- package/lib/module/{groupDriverTypes.js.map → groupTypes.js.map} +1 -1
- package/lib/module/groups.android.js +4 -0
- package/lib/module/groups.android.js.map +1 -0
- package/lib/module/groups.ios.js +4 -0
- package/lib/module/groups.ios.js.map +1 -0
- package/lib/module/groups.js +4 -0
- package/lib/module/groups.js.map +1 -0
- package/lib/module/groups.native.js +399 -0
- package/lib/module/groups.native.js.map +1 -0
- package/lib/module/ids.js +8 -0
- package/lib/module/ids.js.map +1 -0
- package/lib/module/index.js +3 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeCompletion.js +37 -16
- package/lib/module/nativeCompletion.js.map +1 -1
- package/lib/module/presentationCodec.js +81 -0
- package/lib/module/presentationCodec.js.map +1 -0
- package/lib/typescript/src/NativeSmoothClipModule.d.ts +14 -23
- package/lib/typescript/src/NativeSmoothClipModule.d.ts.map +1 -1
- package/lib/typescript/src/SmoothClipView.d.ts +1 -1
- package/lib/typescript/src/SmoothClipView.d.ts.map +1 -1
- package/lib/typescript/src/SmoothClipView.ios.d.ts +18 -14
- package/lib/typescript/src/SmoothClipView.ios.d.ts.map +1 -1
- package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts +10 -5
- package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/capabilities.native.d.ts +1 -1
- package/lib/typescript/src/capabilities.native.d.ts.map +1 -1
- package/lib/typescript/src/capabilityTypes.d.ts +0 -6
- package/lib/typescript/src/capabilityTypes.d.ts.map +1 -1
- package/lib/typescript/src/controllerInternals.d.ts +14 -0
- package/lib/typescript/src/controllerInternals.d.ts.map +1 -0
- package/lib/typescript/src/controllerLifecycle.d.ts +3 -0
- package/lib/typescript/src/controllerLifecycle.d.ts.map +1 -0
- package/lib/typescript/src/controllerTypes.d.ts +62 -0
- package/lib/typescript/src/controllerTypes.d.ts.map +1 -0
- package/lib/typescript/src/controllers.android.d.ts +2 -0
- package/lib/typescript/src/controllers.android.d.ts.map +1 -0
- package/lib/typescript/src/controllers.d.ts +2 -0
- package/lib/typescript/src/controllers.d.ts.map +1 -0
- package/lib/typescript/src/controllers.ios.d.ts +2 -0
- package/lib/typescript/src/controllers.ios.d.ts.map +1 -0
- package/lib/typescript/src/controllers.native.d.ts +3 -0
- package/lib/typescript/src/controllers.native.d.ts.map +1 -0
- package/lib/typescript/src/geometry.d.ts +22 -12
- package/lib/typescript/src/geometry.d.ts.map +1 -1
- package/lib/typescript/src/groupTypes.d.ts +31 -0
- package/lib/typescript/src/groupTypes.d.ts.map +1 -0
- package/lib/typescript/src/groups.android.d.ts +2 -0
- package/lib/typescript/src/groups.android.d.ts.map +1 -0
- package/lib/typescript/src/groups.d.ts +2 -0
- package/lib/typescript/src/groups.d.ts.map +1 -0
- package/lib/typescript/src/groups.ios.d.ts +2 -0
- package/lib/typescript/src/groups.ios.d.ts.map +1 -0
- package/lib/typescript/src/groups.native.d.ts +3 -0
- package/lib/typescript/src/groups.native.d.ts.map +1 -0
- package/lib/typescript/src/ids.d.ts +2 -0
- package/lib/typescript/src/ids.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -6
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/nativeCompletion.d.ts +16 -6
- package/lib/typescript/src/nativeCompletion.d.ts.map +1 -1
- package/lib/typescript/src/presentationCodec.d.ts +10 -0
- package/lib/typescript/src/presentationCodec.d.ts.map +1 -0
- package/package.json +8 -3
- package/src/NativeSmoothClipModule.ts +41 -292
- package/src/SmoothClipView.ios.tsx +130 -23
- package/src/SmoothClipView.tsx +5 -1
- package/src/SmoothClipViewNativeComponent.ts +20 -26
- package/src/capabilities.native.ts +2 -52
- package/src/capabilityTypes.ts +0 -14
- package/src/controllerInternals.ts +52 -0
- package/src/controllerLifecycle.ts +6 -0
- package/src/controllerTypes.ts +87 -0
- package/src/controllers.android.ts +1 -0
- package/src/controllers.ios.ts +1 -0
- package/src/controllers.native.ts +104 -0
- package/src/controllers.ts +1 -0
- package/src/geometry.ts +118 -74
- package/src/groupTypes.ts +53 -0
- package/src/groups.android.ts +1 -0
- package/src/groups.ios.ts +1 -0
- package/src/groups.native.ts +604 -0
- package/src/groups.ts +1 -0
- package/src/ids.ts +6 -0
- package/src/index.ts +20 -28
- package/src/nativeCompletion.ts +67 -32
- package/src/presentationCodec.ts +134 -0
- package/lib/module/driverState.js +0 -82
- package/lib/module/driverState.js.map +0 -1
- package/lib/module/driverTypes.js +0 -4
- package/lib/module/driverTypes.js.map +0 -1
- package/lib/module/drivers.android.js +0 -6
- package/lib/module/drivers.android.js.map +0 -1
- package/lib/module/drivers.ios.js +0 -6
- package/lib/module/drivers.ios.js.map +0 -1
- package/lib/module/drivers.js +0 -4
- package/lib/module/drivers.js.map +0 -1
- package/lib/module/drivers.native.js +0 -756
- package/lib/module/drivers.native.js.map +0 -1
- package/lib/module/groupDriverTypes.js +0 -4
- package/lib/module/groupDrivers.android.js +0 -4
- package/lib/module/groupDrivers.android.js.map +0 -1
- package/lib/module/groupDrivers.ios.js +0 -4
- package/lib/module/groupDrivers.ios.js.map +0 -1
- package/lib/module/groupDrivers.js +0 -4
- package/lib/module/groupDrivers.js.map +0 -1
- package/lib/module/groupDrivers.native.js +0 -799
- package/lib/module/groupDrivers.native.js.map +0 -1
- package/lib/module/presentationProtocol.js +0 -15
- package/lib/module/presentationProtocol.js.map +0 -1
- package/lib/module/reactRequests.js +0 -56
- package/lib/module/reactRequests.js.map +0 -1
- package/lib/typescript/src/driverState.d.ts +0 -26
- package/lib/typescript/src/driverState.d.ts.map +0 -1
- package/lib/typescript/src/driverTypes.d.ts +0 -121
- package/lib/typescript/src/driverTypes.d.ts.map +0 -1
- package/lib/typescript/src/drivers.android.d.ts +0 -3
- package/lib/typescript/src/drivers.android.d.ts.map +0 -1
- package/lib/typescript/src/drivers.d.ts +0 -3
- package/lib/typescript/src/drivers.d.ts.map +0 -1
- package/lib/typescript/src/drivers.ios.d.ts +0 -3
- package/lib/typescript/src/drivers.ios.d.ts.map +0 -1
- package/lib/typescript/src/drivers.native.d.ts +0 -5
- package/lib/typescript/src/drivers.native.d.ts.map +0 -1
- package/lib/typescript/src/groupDriverTypes.d.ts +0 -66
- package/lib/typescript/src/groupDriverTypes.d.ts.map +0 -1
- package/lib/typescript/src/groupDrivers.android.d.ts +0 -2
- package/lib/typescript/src/groupDrivers.android.d.ts.map +0 -1
- package/lib/typescript/src/groupDrivers.d.ts +0 -2
- package/lib/typescript/src/groupDrivers.d.ts.map +0 -1
- package/lib/typescript/src/groupDrivers.ios.d.ts +0 -2
- package/lib/typescript/src/groupDrivers.ios.d.ts.map +0 -1
- package/lib/typescript/src/groupDrivers.native.d.ts +0 -4
- package/lib/typescript/src/groupDrivers.native.d.ts.map +0 -1
- package/lib/typescript/src/presentationProtocol.d.ts +0 -4
- package/lib/typescript/src/presentationProtocol.d.ts.map +0 -1
- package/lib/typescript/src/reactRequests.d.ts +0 -9
- package/lib/typescript/src/reactRequests.d.ts.map +0 -1
- package/src/driverState.ts +0 -118
- package/src/driverTypes.ts +0 -171
- package/src/drivers.android.ts +0 -8
- package/src/drivers.ios.ts +0 -8
- package/src/drivers.native.ts +0 -1599
- package/src/drivers.ts +0 -6
- package/src/groupDriverTypes.ts +0 -117
- package/src/groupDrivers.android.ts +0 -1
- package/src/groupDrivers.ios.ts +0 -1
- package/src/groupDrivers.native.ts +0 -1189
- package/src/groupDrivers.ts +0 -1
- package/src/presentationProtocol.ts +0 -28
- package/src/reactRequests.ts +0 -76
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
namespace facebook::react {
|
|
11
11
|
namespace {
|
|
12
12
|
|
|
13
|
+
constexpr size_t kPresentationStride = 21;
|
|
14
|
+
constexpr size_t kSnapshotStride = kPresentationStride + 1;
|
|
15
|
+
constexpr size_t kMotionEntryStride = kPresentationStride * 2 + 2;
|
|
16
|
+
|
|
13
17
|
constexpr double kMaxSafeJavaScriptInteger = 9007199254740991.0;
|
|
14
18
|
|
|
15
19
|
bool validDriverId(double value) {
|
|
@@ -23,24 +27,11 @@ bool finiteGeometry(const smoothclip::Geometry &geometry) {
|
|
|
23
27
|
std::isfinite(geometry.radius);
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
bool finitePresentation(const smoothclip::Presentation &presentation) {
|
|
27
|
-
return finiteGeometry(presentation.clip) &&
|
|
28
|
-
std::isfinite(presentation.contentTranslateX) &&
|
|
29
|
-
std::isfinite(presentation.contentTranslateY);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
30
|
bool validCurveCode(int32_t curveCode) {
|
|
33
31
|
return curveCode == static_cast<int32_t>(smoothclip::ClipCurve::Circular) ||
|
|
34
32
|
curveCode == static_cast<int32_t>(smoothclip::ClipCurve::Continuous);
|
|
35
33
|
}
|
|
36
34
|
|
|
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
35
|
bool numberAt(
|
|
45
36
|
jsi::Runtime &runtime,
|
|
46
37
|
const jsi::Array &array,
|
|
@@ -53,7 +44,7 @@ bool numberAt(
|
|
|
53
44
|
return std::isfinite(result);
|
|
54
45
|
}
|
|
55
46
|
|
|
56
|
-
smoothclip::Presentation
|
|
47
|
+
smoothclip::Presentation makePresentation(
|
|
57
48
|
double x,
|
|
58
49
|
double y,
|
|
59
50
|
double width,
|
|
@@ -65,7 +56,16 @@ smoothclip::Presentation presentationV2(
|
|
|
65
56
|
int32_t curveCode,
|
|
66
57
|
double contentTranslateX,
|
|
67
58
|
double contentTranslateY,
|
|
68
|
-
double contentScale
|
|
59
|
+
double contentScale,
|
|
60
|
+
bool shadowEnabled = false,
|
|
61
|
+
double shadowRed = 0,
|
|
62
|
+
double shadowGreen = 0,
|
|
63
|
+
double shadowBlue = 0,
|
|
64
|
+
double shadowAlpha = 1,
|
|
65
|
+
double shadowOffsetX = 0,
|
|
66
|
+
double shadowOffsetY = 0,
|
|
67
|
+
double shadowBlurRadius = 0,
|
|
68
|
+
double shadowSpreadDistance = 0) {
|
|
69
69
|
const bool uniform = topLeftRadius == topRightRadius &&
|
|
70
70
|
topLeftRadius == bottomRightRadius &&
|
|
71
71
|
topLeftRadius == bottomLeftRadius;
|
|
@@ -76,10 +76,16 @@ smoothclip::Presentation presentationV2(
|
|
|
76
76
|
geometry.bottomRightRadius = bottomRightRadius;
|
|
77
77
|
geometry.bottomLeftRadius = bottomLeftRadius;
|
|
78
78
|
geometry.curve = static_cast<smoothclip::ClipCurve>(curveCode);
|
|
79
|
-
return {
|
|
79
|
+
return {
|
|
80
|
+
geometry,
|
|
81
|
+
contentTranslateX,
|
|
82
|
+
contentTranslateY,
|
|
83
|
+
contentScale,
|
|
84
|
+
{shadowEnabled, shadowRed, shadowGreen, shadowBlue, shadowAlpha,
|
|
85
|
+
shadowOffsetX, shadowOffsetY, shadowBlurRadius, shadowSpreadDistance}};
|
|
80
86
|
}
|
|
81
87
|
|
|
82
|
-
bool
|
|
88
|
+
bool finitePresentation(const smoothclip::Presentation &presentation) {
|
|
83
89
|
const smoothclip::Geometry &geometry = presentation.clip;
|
|
84
90
|
return finiteGeometry(geometry) &&
|
|
85
91
|
std::isfinite(geometry.topLeftRadius) &&
|
|
@@ -90,23 +96,37 @@ bool finitePresentationV2(const smoothclip::Presentation &presentation) {
|
|
|
90
96
|
std::isfinite(presentation.contentTranslateX) &&
|
|
91
97
|
std::isfinite(presentation.contentTranslateY) &&
|
|
92
98
|
std::isfinite(presentation.contentScale) &&
|
|
93
|
-
presentation.contentScale > 0
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
presentation.contentScale > 0 &&
|
|
100
|
+
std::isfinite(presentation.shadow.red) &&
|
|
101
|
+
std::isfinite(presentation.shadow.green) &&
|
|
102
|
+
std::isfinite(presentation.shadow.blue) &&
|
|
103
|
+
std::isfinite(presentation.shadow.alpha) &&
|
|
104
|
+
std::isfinite(presentation.shadow.offsetX) &&
|
|
105
|
+
std::isfinite(presentation.shadow.offsetY) &&
|
|
106
|
+
std::isfinite(presentation.shadow.blurRadius) &&
|
|
107
|
+
std::isfinite(presentation.shadow.spreadDistance) &&
|
|
108
|
+
presentation.shadow.red >= 0 && presentation.shadow.red <= 1 &&
|
|
109
|
+
presentation.shadow.green >= 0 && presentation.shadow.green <= 1 &&
|
|
110
|
+
presentation.shadow.blue >= 0 && presentation.shadow.blue <= 1 &&
|
|
111
|
+
presentation.shadow.alpha >= 0 && presentation.shadow.alpha <= 1 &&
|
|
112
|
+
presentation.shadow.blurRadius >= 0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
bool presentationAt(
|
|
97
116
|
jsi::Runtime &runtime,
|
|
98
117
|
const jsi::Array &array,
|
|
99
118
|
size_t offset,
|
|
100
119
|
smoothclip::Presentation &result) {
|
|
101
|
-
double values[
|
|
102
|
-
for (size_t index = 0; index <
|
|
120
|
+
double values[kPresentationStride];
|
|
121
|
+
for (size_t index = 0; index < kPresentationStride; index += 1) {
|
|
103
122
|
if (!numberAt(runtime, array, offset + index, values[index])) {
|
|
104
123
|
return false;
|
|
105
124
|
}
|
|
106
125
|
}
|
|
107
126
|
const int32_t curveCode = static_cast<int32_t>(values[8]);
|
|
108
|
-
if (values[8] != curveCode || !validCurveCode(curveCode)
|
|
109
|
-
|
|
127
|
+
if (values[8] != curveCode || !validCurveCode(curveCode) ||
|
|
128
|
+
(values[12] != 0 && values[12] != 1)) return false;
|
|
129
|
+
result = makePresentation(
|
|
110
130
|
values[0],
|
|
111
131
|
values[1],
|
|
112
132
|
values[2],
|
|
@@ -118,11 +138,14 @@ bool presentationV2At(
|
|
|
118
138
|
curveCode,
|
|
119
139
|
values[9],
|
|
120
140
|
values[10],
|
|
121
|
-
values[11]
|
|
122
|
-
|
|
141
|
+
values[11],
|
|
142
|
+
values[12] == 1,
|
|
143
|
+
values[13], values[14], values[15], values[16],
|
|
144
|
+
values[17], values[18], values[19], values[20]);
|
|
145
|
+
return finitePresentation(result);
|
|
123
146
|
}
|
|
124
147
|
|
|
125
|
-
void
|
|
148
|
+
void writePresentation(
|
|
126
149
|
jsi::Runtime &runtime,
|
|
127
150
|
jsi::Array &result,
|
|
128
151
|
size_t offset,
|
|
@@ -149,22 +172,64 @@ void writePresentationV2(
|
|
|
149
172
|
result.setValueAtIndex(runtime, offset + 9, presentation.contentTranslateX);
|
|
150
173
|
result.setValueAtIndex(runtime, offset + 10, presentation.contentTranslateY);
|
|
151
174
|
result.setValueAtIndex(runtime, offset + 11, presentation.contentScale);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
175
|
+
result.setValueAtIndex(runtime, offset + 12, presentation.shadow.enabled ? 1.0 : 0.0);
|
|
176
|
+
result.setValueAtIndex(runtime, offset + 13, presentation.shadow.red);
|
|
177
|
+
result.setValueAtIndex(runtime, offset + 14, presentation.shadow.green);
|
|
178
|
+
result.setValueAtIndex(runtime, offset + 15, presentation.shadow.blue);
|
|
179
|
+
result.setValueAtIndex(runtime, offset + 16, presentation.shadow.alpha);
|
|
180
|
+
result.setValueAtIndex(runtime, offset + 17, presentation.shadow.offsetX);
|
|
181
|
+
result.setValueAtIndex(runtime, offset + 18, presentation.shadow.offsetY);
|
|
182
|
+
result.setValueAtIndex(runtime, offset + 19, presentation.shadow.blurRadius);
|
|
183
|
+
result.setValueAtIndex(runtime, offset + 20, presentation.shadow.spreadDistance);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
jsi::Array snapshotArray(
|
|
155
187
|
jsi::Runtime &runtime,
|
|
156
188
|
const std::vector<smoothclip::DriverSnapshot> &snapshots) {
|
|
157
|
-
jsi::Array result(runtime, snapshots.size() *
|
|
189
|
+
jsi::Array result(runtime, snapshots.size() * kSnapshotStride);
|
|
158
190
|
for (size_t index = 0; index < snapshots.size(); index += 1) {
|
|
159
|
-
const size_t offset = index *
|
|
191
|
+
const size_t offset = index * kSnapshotStride;
|
|
160
192
|
result.setValueAtIndex(
|
|
161
193
|
runtime, offset, snapshots[index].ready ? 1.0 : 0.0);
|
|
162
|
-
|
|
194
|
+
writePresentation(
|
|
163
195
|
runtime, result, offset + 1, snapshots[index].presentation);
|
|
164
196
|
}
|
|
165
197
|
return result;
|
|
166
198
|
}
|
|
167
199
|
|
|
200
|
+
std::vector<double> snapshotValues(
|
|
201
|
+
const std::vector<smoothclip::DriverSnapshot> &snapshots) {
|
|
202
|
+
std::vector<double> result;
|
|
203
|
+
result.reserve(snapshots.size() * kSnapshotStride);
|
|
204
|
+
for (const smoothclip::DriverSnapshot &snapshot : snapshots) {
|
|
205
|
+
const smoothclip::Presentation &presentation = snapshot.presentation;
|
|
206
|
+
result.push_back(snapshot.ready ? 1.0 : 0.0);
|
|
207
|
+
result.push_back(presentation.clip.x);
|
|
208
|
+
result.push_back(presentation.clip.y);
|
|
209
|
+
result.push_back(presentation.clip.width);
|
|
210
|
+
result.push_back(presentation.clip.height);
|
|
211
|
+
result.push_back(presentation.clip.topLeftRadius);
|
|
212
|
+
result.push_back(presentation.clip.topRightRadius);
|
|
213
|
+
result.push_back(presentation.clip.bottomRightRadius);
|
|
214
|
+
result.push_back(presentation.clip.bottomLeftRadius);
|
|
215
|
+
result.push_back(
|
|
216
|
+
presentation.clip.curve == smoothclip::ClipCurve::Continuous ? 1.0 : 0.0);
|
|
217
|
+
result.push_back(presentation.contentTranslateX);
|
|
218
|
+
result.push_back(presentation.contentTranslateY);
|
|
219
|
+
result.push_back(presentation.contentScale);
|
|
220
|
+
result.push_back(presentation.shadow.enabled ? 1.0 : 0.0);
|
|
221
|
+
result.push_back(presentation.shadow.red);
|
|
222
|
+
result.push_back(presentation.shadow.green);
|
|
223
|
+
result.push_back(presentation.shadow.blue);
|
|
224
|
+
result.push_back(presentation.shadow.alpha);
|
|
225
|
+
result.push_back(presentation.shadow.offsetX);
|
|
226
|
+
result.push_back(presentation.shadow.offsetY);
|
|
227
|
+
result.push_back(presentation.shadow.blurRadius);
|
|
228
|
+
result.push_back(presentation.shadow.spreadDistance);
|
|
229
|
+
}
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
232
|
+
|
|
168
233
|
bool driverIdsAt(
|
|
169
234
|
jsi::Runtime &runtime,
|
|
170
235
|
const jsi::Array &array,
|
|
@@ -186,7 +251,7 @@ bool fixedGroupEntriesAt(
|
|
|
186
251
|
jsi::Runtime &runtime,
|
|
187
252
|
const jsi::Array &array,
|
|
188
253
|
std::vector<smoothclip::GroupMotionEntry> &result) {
|
|
189
|
-
constexpr size_t stride =
|
|
254
|
+
constexpr size_t stride = kMotionEntryStride;
|
|
190
255
|
const size_t count = array.size(runtime);
|
|
191
256
|
if (count == 0 || count % stride != 0) return false;
|
|
192
257
|
result.clear();
|
|
@@ -200,8 +265,9 @@ bool fixedGroupEntriesAt(
|
|
|
200
265
|
!validDriverId(rawDriverId) ||
|
|
201
266
|
!numberAt(runtime, array, offset + 1, rawHasFrom) ||
|
|
202
267
|
(rawHasFrom != 0 && rawHasFrom != 1) ||
|
|
203
|
-
!
|
|
204
|
-
!
|
|
268
|
+
!presentationAt(runtime, array, offset + 2, from) ||
|
|
269
|
+
!presentationAt(
|
|
270
|
+
runtime, array, offset + 2 + kPresentationStride, target)) {
|
|
205
271
|
return false;
|
|
206
272
|
}
|
|
207
273
|
result.push_back({
|
|
@@ -209,102 +275,20 @@ bool fixedGroupEntriesAt(
|
|
|
209
275
|
rawHasFrom == 1,
|
|
210
276
|
from,
|
|
211
277
|
target,
|
|
212
|
-
{},
|
|
213
278
|
});
|
|
214
279
|
}
|
|
215
280
|
return true;
|
|
216
281
|
}
|
|
217
282
|
|
|
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
|
-
|
|
278
283
|
jsi::Array presentationArray(
|
|
279
284
|
jsi::Runtime &runtime,
|
|
280
285
|
smoothclip::Presentation presentation,
|
|
281
286
|
bool includeHandled = false,
|
|
282
287
|
bool handled = true) {
|
|
283
288
|
const size_t offset = includeHandled ? 1 : 0;
|
|
284
|
-
jsi::Array result(runtime, offset +
|
|
285
|
-
// JS checks `values[0] !== 1`, so the handled flag must be a number: a jsi
|
|
286
|
-
// bool would make every comparison fail and leave the driver stuck in
|
|
287
|
-
// native ownership after cancelAnimation.
|
|
288
|
-
if (includeHandled) result.setValueAtIndex(runtime, 0, handled ? 1.0 : 0.0);
|
|
289
|
-
result.setValueAtIndex(runtime, offset, presentation.clip.x);
|
|
290
|
-
result.setValueAtIndex(runtime, offset + 1, presentation.clip.y);
|
|
291
|
-
result.setValueAtIndex(runtime, offset + 2, presentation.clip.width);
|
|
292
|
-
result.setValueAtIndex(runtime, offset + 3, presentation.clip.height);
|
|
293
|
-
result.setValueAtIndex(runtime, offset + 4, presentation.clip.radius);
|
|
294
|
-
result.setValueAtIndex(runtime, offset + 5, presentation.contentTranslateX);
|
|
295
|
-
result.setValueAtIndex(runtime, offset + 6, presentation.contentTranslateY);
|
|
296
|
-
return result;
|
|
297
|
-
}
|
|
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);
|
|
289
|
+
jsi::Array result(runtime, offset + kPresentationStride);
|
|
306
290
|
if (includeHandled) result.setValueAtIndex(runtime, 0, handled ? 1.0 : 0.0);
|
|
307
|
-
|
|
291
|
+
writePresentation(runtime, result, offset, presentation);
|
|
308
292
|
return result;
|
|
309
293
|
}
|
|
310
294
|
|
|
@@ -315,28 +299,29 @@ SmoothClipTurboModule::SmoothClipTurboModule(
|
|
|
315
299
|
: NativeSmoothClipModuleCxxSpec(std::move(jsInvoker)) {
|
|
316
300
|
smoothclip::setCompletionCallback(
|
|
317
301
|
this,
|
|
318
|
-
[this](
|
|
302
|
+
[this](
|
|
303
|
+
uint64_t driverId,
|
|
304
|
+
int32_t animationId,
|
|
305
|
+
int32_t completionTag,
|
|
306
|
+
bool finished) {
|
|
319
307
|
emitOnClipAnimationComplete(SmoothClipAnimationCompletion{
|
|
320
|
-
static_cast<double>(driverId), animationId, finished});
|
|
308
|
+
static_cast<double>(driverId), animationId, completionTag, finished});
|
|
321
309
|
});
|
|
322
310
|
smoothclip::setGroupCompletionCallback(
|
|
323
311
|
this,
|
|
324
312
|
[this](
|
|
325
313
|
uint64_t controllerId,
|
|
326
314
|
int32_t groupId,
|
|
315
|
+
int32_t completionTag,
|
|
327
316
|
bool finished,
|
|
328
|
-
std::vector<
|
|
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
|
-
}
|
|
317
|
+
std::vector<smoothclip::DriverSnapshot> snapshots) {
|
|
334
318
|
emitOnClipGroupAnimationComplete(
|
|
335
319
|
SmoothClipGroupAnimationCompletion{
|
|
336
320
|
static_cast<double>(controllerId),
|
|
337
321
|
groupId,
|
|
322
|
+
completionTag,
|
|
338
323
|
finished,
|
|
339
|
-
|
|
324
|
+
snapshotValues(snapshots),
|
|
340
325
|
});
|
|
341
326
|
});
|
|
342
327
|
}
|
|
@@ -346,40 +331,36 @@ SmoothClipTurboModule::~SmoothClipTurboModule() {
|
|
|
346
331
|
smoothclip::clearGroupCompletionCallback(this);
|
|
347
332
|
}
|
|
348
333
|
|
|
349
|
-
int32_t SmoothClipTurboModule::getPresentationProtocolVersion(jsi::Runtime &) {
|
|
350
|
-
return 2;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
334
|
bool SmoothClipTurboModule::supportsAutonomousComplexPathAnimation(
|
|
354
335
|
jsi::Runtime &) {
|
|
355
336
|
return false;
|
|
356
337
|
}
|
|
357
338
|
|
|
358
|
-
jsi::Array SmoothClipTurboModule::
|
|
339
|
+
jsi::Array SmoothClipTurboModule::beginGroupInteraction(
|
|
359
340
|
jsi::Runtime &runtime,
|
|
360
341
|
jsi::Array driverIds) {
|
|
361
342
|
std::vector<uint64_t> parsed;
|
|
362
343
|
if (!driverIdsAt(runtime, driverIds, parsed)) {
|
|
363
344
|
return jsi::Array(runtime, 0);
|
|
364
345
|
}
|
|
365
|
-
return
|
|
346
|
+
return snapshotArray(
|
|
366
347
|
runtime, smoothclip::beginGroupInteraction(parsed));
|
|
367
348
|
}
|
|
368
349
|
|
|
369
|
-
jsi::Array SmoothClipTurboModule::
|
|
350
|
+
jsi::Array SmoothClipTurboModule::snapshotGroup(
|
|
370
351
|
jsi::Runtime &runtime,
|
|
371
352
|
jsi::Array driverIds) {
|
|
372
353
|
std::vector<uint64_t> parsed;
|
|
373
354
|
if (!driverIdsAt(runtime, driverIds, parsed)) {
|
|
374
355
|
return jsi::Array(runtime, 0);
|
|
375
356
|
}
|
|
376
|
-
return
|
|
357
|
+
return snapshotArray(runtime, smoothclip::snapshotGroup(parsed));
|
|
377
358
|
}
|
|
378
359
|
|
|
379
|
-
bool SmoothClipTurboModule::
|
|
360
|
+
bool SmoothClipTurboModule::setClipPresentationBatch(
|
|
380
361
|
jsi::Runtime &runtime,
|
|
381
362
|
jsi::Array entries) {
|
|
382
|
-
constexpr size_t stride =
|
|
363
|
+
constexpr size_t stride = kSnapshotStride;
|
|
383
364
|
const size_t count = entries.size(runtime);
|
|
384
365
|
if (count % stride != 0) return false;
|
|
385
366
|
std::vector<smoothclip::BatchEntry> parsed;
|
|
@@ -389,7 +370,7 @@ bool SmoothClipTurboModule::setClipPresentationBatchV2(
|
|
|
389
370
|
smoothclip::Presentation presentation;
|
|
390
371
|
if (!numberAt(runtime, entries, offset, driverId) ||
|
|
391
372
|
!validDriverId(driverId) ||
|
|
392
|
-
!
|
|
373
|
+
!presentationAt(runtime, entries, offset + 1, presentation)) {
|
|
393
374
|
return false;
|
|
394
375
|
}
|
|
395
376
|
parsed.push_back(
|
|
@@ -398,7 +379,7 @@ bool SmoothClipTurboModule::setClipPresentationBatchV2(
|
|
|
398
379
|
return smoothclip::setPresentationBatch(parsed);
|
|
399
380
|
}
|
|
400
381
|
|
|
401
|
-
int32_t SmoothClipTurboModule::
|
|
382
|
+
int32_t SmoothClipTurboModule::animateTimingGroup(
|
|
402
383
|
jsi::Runtime &runtime,
|
|
403
384
|
double controllerId,
|
|
404
385
|
jsi::Array entries,
|
|
@@ -408,14 +389,15 @@ int32_t SmoothClipTurboModule::animateTimingGroupV2(
|
|
|
408
389
|
double controlPoint2X,
|
|
409
390
|
double controlPoint2Y,
|
|
410
391
|
int32_t reduceMotion,
|
|
411
|
-
int32_t
|
|
392
|
+
int32_t completionTag,
|
|
393
|
+
double startTimestamp) {
|
|
394
|
+
(void)startTimestamp;
|
|
412
395
|
std::vector<smoothclip::GroupMotionEntry> parsed;
|
|
413
396
|
if (!validDriverId(controllerId) ||
|
|
414
397
|
!fixedGroupEntriesAt(runtime, entries, parsed) ||
|
|
415
398
|
!std::isfinite(durationMs) || !std::isfinite(controlPoint1X) ||
|
|
416
399
|
!std::isfinite(controlPoint1Y) || !std::isfinite(controlPoint2X) ||
|
|
417
|
-
!std::isfinite(controlPoint2Y)
|
|
418
|
-
!validSuspensionPolicy(suspensionPolicy)) {
|
|
400
|
+
!std::isfinite(controlPoint2Y)) {
|
|
419
401
|
return 0;
|
|
420
402
|
}
|
|
421
403
|
return smoothclip::animateTimingGroup(
|
|
@@ -427,27 +409,29 @@ int32_t SmoothClipTurboModule::animateTimingGroupV2(
|
|
|
427
409
|
controlPoint2X,
|
|
428
410
|
controlPoint2Y,
|
|
429
411
|
reduceMotion},
|
|
430
|
-
|
|
412
|
+
completionTag);
|
|
431
413
|
}
|
|
432
414
|
|
|
433
|
-
int32_t SmoothClipTurboModule::
|
|
415
|
+
int32_t SmoothClipTurboModule::animateSpringGroup(
|
|
434
416
|
jsi::Runtime &runtime,
|
|
435
417
|
double controllerId,
|
|
436
418
|
jsi::Array entries,
|
|
437
419
|
double mass,
|
|
438
420
|
double stiffness,
|
|
439
421
|
double damping,
|
|
440
|
-
double
|
|
441
|
-
|
|
422
|
+
double velocity,
|
|
423
|
+
double energyThreshold,
|
|
442
424
|
int32_t reduceMotion,
|
|
443
|
-
int32_t
|
|
425
|
+
int32_t completionTag,
|
|
426
|
+
double startTimestamp) {
|
|
427
|
+
(void)startTimestamp;
|
|
444
428
|
std::vector<smoothclip::GroupMotionEntry> parsed;
|
|
445
429
|
if (!validDriverId(controllerId) ||
|
|
446
430
|
!fixedGroupEntriesAt(runtime, entries, parsed) ||
|
|
447
431
|
!std::isfinite(mass) || !std::isfinite(stiffness) ||
|
|
448
|
-
!std::isfinite(damping) || !std::isfinite(
|
|
449
|
-
mass <= 0 || stiffness <= 0 ||
|
|
450
|
-
|
|
432
|
+
!std::isfinite(damping) || !std::isfinite(velocity) ||
|
|
433
|
+
!std::isfinite(energyThreshold) || mass <= 0 || stiffness <= 0 ||
|
|
434
|
+
damping < 0 || energyThreshold <= 0) {
|
|
451
435
|
return 0;
|
|
452
436
|
}
|
|
453
437
|
return smoothclip::animateSpringGroup(
|
|
@@ -456,35 +440,14 @@ int32_t SmoothClipTurboModule::animateSpringGroupV2(
|
|
|
456
440
|
{mass,
|
|
457
441
|
stiffness,
|
|
458
442
|
damping,
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
reduceMotion
|
|
462
|
-
|
|
443
|
+
velocity,
|
|
444
|
+
false,
|
|
445
|
+
reduceMotion,
|
|
446
|
+
energyThreshold},
|
|
447
|
+
completionTag);
|
|
463
448
|
}
|
|
464
449
|
|
|
465
|
-
|
|
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(
|
|
450
|
+
jsi::Array SmoothClipTurboModule::cancelAnimationGroup(
|
|
488
451
|
jsi::Runtime &runtime,
|
|
489
452
|
int32_t groupId,
|
|
490
453
|
int32_t behavior) {
|
|
@@ -495,14 +458,30 @@ jsi::Array SmoothClipTurboModule::cancelAnimationGroupV2(
|
|
|
495
458
|
smoothclip::GroupCancelBehavior::Finish))) {
|
|
496
459
|
return jsi::Array(runtime, 0);
|
|
497
460
|
}
|
|
498
|
-
return
|
|
461
|
+
return snapshotArray(
|
|
499
462
|
runtime,
|
|
500
463
|
smoothclip::cancelAnimationGroup(
|
|
501
464
|
groupId,
|
|
502
465
|
static_cast<smoothclip::GroupCancelBehavior>(behavior)));
|
|
503
466
|
}
|
|
504
467
|
|
|
505
|
-
void SmoothClipTurboModule::
|
|
468
|
+
void SmoothClipTurboModule::setClipPresentation(
|
|
469
|
+
jsi::Runtime &runtime,
|
|
470
|
+
double driverId,
|
|
471
|
+
jsi::Array values,
|
|
472
|
+
bool takeOwnership,
|
|
473
|
+
bool overridePendingAnimation) {
|
|
474
|
+
smoothclip::Presentation presentation{};
|
|
475
|
+
if (values.size(runtime) == kPresentationStride &&
|
|
476
|
+
validDriverId(driverId) &&
|
|
477
|
+
presentationAt(runtime, values, 0, presentation)) {
|
|
478
|
+
smoothclip::setPresentation(
|
|
479
|
+
static_cast<uint64_t>(driverId), presentation, takeOwnership,
|
|
480
|
+
overridePendingAnimation);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
void SmoothClipTurboModule::setClipFrameScalars(
|
|
506
485
|
jsi::Runtime &,
|
|
507
486
|
double driverId,
|
|
508
487
|
double x,
|
|
@@ -517,289 +496,112 @@ void SmoothClipTurboModule::setClipPresentationV2(
|
|
|
517
496
|
double contentTranslateX,
|
|
518
497
|
double contentTranslateY,
|
|
519
498
|
double contentScale,
|
|
520
|
-
bool
|
|
521
|
-
|
|
522
|
-
|
|
499
|
+
bool shadowEnabled,
|
|
500
|
+
double shadowRed,
|
|
501
|
+
double shadowGreen,
|
|
502
|
+
double shadowBlue,
|
|
503
|
+
double shadowAlpha,
|
|
504
|
+
double shadowOffsetX,
|
|
505
|
+
double shadowOffsetY,
|
|
506
|
+
double shadowBlurRadius,
|
|
507
|
+
double shadowSpreadDistance) {
|
|
508
|
+
const smoothclip::Presentation presentation = makePresentation(
|
|
523
509
|
x, y, width, height, topLeftRadius, topRightRadius,
|
|
524
510
|
bottomRightRadius, bottomLeftRadius, curveCode,
|
|
525
|
-
contentTranslateX, contentTranslateY, contentScale
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
511
|
+
contentTranslateX, contentTranslateY, contentScale,
|
|
512
|
+
shadowEnabled, shadowRed, shadowGreen, shadowBlue, shadowAlpha,
|
|
513
|
+
shadowOffsetX, shadowOffsetY, shadowBlurRadius, shadowSpreadDistance);
|
|
514
|
+
if (!validDriverId(driverId) || !finitePresentation(presentation)) return;
|
|
515
|
+
smoothclip::setPresentation(
|
|
516
|
+
static_cast<uint64_t>(driverId), presentation, true, false, true);
|
|
531
517
|
}
|
|
532
518
|
|
|
533
|
-
jsi::Array SmoothClipTurboModule::
|
|
519
|
+
jsi::Array SmoothClipTurboModule::beginInteraction(
|
|
534
520
|
jsi::Runtime &runtime,
|
|
535
521
|
double driverId) {
|
|
536
522
|
if (!validDriverId(driverId)) {
|
|
537
|
-
return
|
|
538
|
-
runtime,
|
|
523
|
+
return presentationArray(
|
|
524
|
+
runtime, makePresentation(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1));
|
|
539
525
|
}
|
|
540
|
-
return
|
|
526
|
+
return presentationArray(
|
|
541
527
|
runtime,
|
|
542
528
|
smoothclip::beginInteraction(static_cast<uint64_t>(driverId)));
|
|
543
529
|
}
|
|
544
530
|
|
|
545
|
-
jsi::Array SmoothClipTurboModule::
|
|
531
|
+
jsi::Array SmoothClipTurboModule::snapshotCurrent(
|
|
546
532
|
jsi::Runtime &runtime,
|
|
547
533
|
double driverId) {
|
|
548
534
|
if (!validDriverId(driverId)) {
|
|
549
|
-
return
|
|
550
|
-
runtime,
|
|
535
|
+
return presentationArray(
|
|
536
|
+
runtime, makePresentation(NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN,
|
|
551
537
|
0, NAN, NAN, NAN));
|
|
552
538
|
}
|
|
553
|
-
return presentationArrayV2(
|
|
554
|
-
runtime,
|
|
555
|
-
smoothclip::snapshotCurrent(static_cast<uint64_t>(driverId)));
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
void SmoothClipTurboModule::setClipPresentation(
|
|
559
|
-
jsi::Runtime &,
|
|
560
|
-
double driverId,
|
|
561
|
-
double x,
|
|
562
|
-
double y,
|
|
563
|
-
double width,
|
|
564
|
-
double height,
|
|
565
|
-
double radius,
|
|
566
|
-
double contentTranslateX,
|
|
567
|
-
double contentTranslateY,
|
|
568
|
-
bool takeOwnership,
|
|
569
|
-
bool overridePendingAnimation) {
|
|
570
|
-
const smoothclip::Presentation presentation{
|
|
571
|
-
{x, y, width, height, radius}, contentTranslateX, contentTranslateY};
|
|
572
|
-
if (validDriverId(driverId) && finitePresentation(presentation)) {
|
|
573
|
-
smoothclip::setPresentation(
|
|
574
|
-
static_cast<uint64_t>(driverId), presentation, takeOwnership,
|
|
575
|
-
overridePendingAnimation);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
jsi::Array SmoothClipTurboModule::beginInteraction(
|
|
580
|
-
jsi::Runtime &runtime,
|
|
581
|
-
double driverId) {
|
|
582
|
-
if (!validDriverId(driverId)) {
|
|
583
|
-
return presentationArray(runtime, {{0, 0, 0, 0, 0}, 0, 0});
|
|
584
|
-
}
|
|
585
539
|
return presentationArray(
|
|
586
540
|
runtime,
|
|
587
|
-
smoothclip::
|
|
541
|
+
smoothclip::snapshotCurrent(static_cast<uint64_t>(driverId)));
|
|
588
542
|
}
|
|
589
543
|
|
|
590
544
|
int32_t SmoothClipTurboModule::animateTiming(
|
|
591
|
-
jsi::Runtime
|
|
592
|
-
double driverId,
|
|
593
|
-
bool hasInteractiveStart,
|
|
594
|
-
double startX,
|
|
595
|
-
double startY,
|
|
596
|
-
double startWidth,
|
|
597
|
-
double startHeight,
|
|
598
|
-
double startRadius,
|
|
599
|
-
double startContentTranslateX,
|
|
600
|
-
double startContentTranslateY,
|
|
601
|
-
double x,
|
|
602
|
-
double y,
|
|
603
|
-
double width,
|
|
604
|
-
double height,
|
|
605
|
-
double radius,
|
|
606
|
-
double contentTranslateX,
|
|
607
|
-
double contentTranslateY,
|
|
608
|
-
double durationMs,
|
|
609
|
-
double controlPoint1X,
|
|
610
|
-
double controlPoint1Y,
|
|
611
|
-
double controlPoint2X,
|
|
612
|
-
double controlPoint2Y,
|
|
613
|
-
int32_t reduceMotion) {
|
|
614
|
-
const smoothclip::Presentation startPresentation{
|
|
615
|
-
{startX, startY, startWidth, startHeight, startRadius},
|
|
616
|
-
startContentTranslateX,
|
|
617
|
-
startContentTranslateY};
|
|
618
|
-
const smoothclip::Presentation presentation{
|
|
619
|
-
{x, y, width, height, radius}, contentTranslateX, contentTranslateY};
|
|
620
|
-
const smoothclip::TimingAnimation animation{
|
|
621
|
-
durationMs,
|
|
622
|
-
controlPoint1X,
|
|
623
|
-
controlPoint1Y,
|
|
624
|
-
controlPoint2X,
|
|
625
|
-
controlPoint2Y,
|
|
626
|
-
reduceMotion};
|
|
627
|
-
if (!validDriverId(driverId) ||
|
|
628
|
-
!finitePresentation(startPresentation) ||
|
|
629
|
-
!finitePresentation(presentation) ||
|
|
630
|
-
!std::isfinite(durationMs) || !std::isfinite(controlPoint1X) ||
|
|
631
|
-
!std::isfinite(controlPoint1Y) || !std::isfinite(controlPoint2X) ||
|
|
632
|
-
!std::isfinite(controlPoint2Y)) return 0;
|
|
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 &,
|
|
545
|
+
jsi::Runtime &runtime,
|
|
644
546
|
double driverId,
|
|
645
|
-
|
|
646
|
-
|
|
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,
|
|
547
|
+
jsi::Array start,
|
|
548
|
+
jsi::Array target,
|
|
670
549
|
double durationMs,
|
|
671
550
|
double controlPoint1X,
|
|
672
551
|
double controlPoint1Y,
|
|
673
552
|
double controlPoint2X,
|
|
674
553
|
double controlPoint2Y,
|
|
675
|
-
int32_t reduceMotion
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
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);
|
|
554
|
+
int32_t reduceMotion,
|
|
555
|
+
int32_t completionTag) {
|
|
556
|
+
const bool hasInteractiveStart = start.size(runtime) != 0;
|
|
557
|
+
smoothclip::Presentation startPresentation{};
|
|
558
|
+
smoothclip::Presentation presentation{};
|
|
685
559
|
const smoothclip::TimingAnimation animation{
|
|
686
560
|
durationMs, controlPoint1X, controlPoint1Y,
|
|
687
561
|
controlPoint2X, controlPoint2Y, reduceMotion};
|
|
688
562
|
if (!validDriverId(driverId) ||
|
|
689
|
-
|
|
690
|
-
|
|
563
|
+
(hasInteractiveStart &&
|
|
564
|
+
(start.size(runtime) != kPresentationStride ||
|
|
565
|
+
!presentationAt(runtime, start, 0, startPresentation))) ||
|
|
566
|
+
target.size(runtime) != kPresentationStride ||
|
|
567
|
+
!presentationAt(runtime, target, 0, presentation) ||
|
|
691
568
|
!std::isfinite(durationMs) || !std::isfinite(controlPoint1X) ||
|
|
692
569
|
!std::isfinite(controlPoint1Y) || !std::isfinite(controlPoint2X) ||
|
|
693
570
|
!std::isfinite(controlPoint2Y)) {
|
|
694
571
|
return 0;
|
|
695
572
|
}
|
|
696
573
|
return smoothclip::animateTiming(
|
|
697
|
-
static_cast<uint64_t>(driverId),
|
|
698
|
-
{hasInteractiveStart, startPresentation},
|
|
699
|
-
presentation,
|
|
700
|
-
animation);
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
int32_t SmoothClipTurboModule::animateSpring(
|
|
704
|
-
jsi::Runtime &,
|
|
705
|
-
double driverId,
|
|
706
|
-
bool hasInteractiveStart,
|
|
707
|
-
double startX,
|
|
708
|
-
double startY,
|
|
709
|
-
double startWidth,
|
|
710
|
-
double startHeight,
|
|
711
|
-
double startRadius,
|
|
712
|
-
double startContentTranslateX,
|
|
713
|
-
double startContentTranslateY,
|
|
714
|
-
double x,
|
|
715
|
-
double y,
|
|
716
|
-
double width,
|
|
717
|
-
double height,
|
|
718
|
-
double radius,
|
|
719
|
-
double contentTranslateX,
|
|
720
|
-
double contentTranslateY,
|
|
721
|
-
double mass,
|
|
722
|
-
double stiffness,
|
|
723
|
-
double damping,
|
|
724
|
-
double initialVelocity,
|
|
725
|
-
bool inheritVelocity,
|
|
726
|
-
int32_t reduceMotion) {
|
|
727
|
-
const smoothclip::Presentation startPresentation{
|
|
728
|
-
{startX, startY, startWidth, startHeight, startRadius},
|
|
729
|
-
startContentTranslateX,
|
|
730
|
-
startContentTranslateY};
|
|
731
|
-
const smoothclip::Presentation presentation{
|
|
732
|
-
{x, y, width, height, radius}, contentTranslateX, contentTranslateY};
|
|
733
|
-
const smoothclip::SpringAnimation animation{
|
|
734
|
-
mass,
|
|
735
|
-
stiffness,
|
|
736
|
-
damping,
|
|
737
|
-
initialVelocity,
|
|
738
|
-
inheritVelocity,
|
|
739
|
-
reduceMotion};
|
|
740
|
-
if (!validDriverId(driverId) ||
|
|
741
|
-
!finitePresentation(startPresentation) ||
|
|
742
|
-
!finitePresentation(presentation) ||
|
|
743
|
-
!std::isfinite(mass) || !std::isfinite(stiffness) ||
|
|
744
|
-
!std::isfinite(damping) || !std::isfinite(initialVelocity)) return 0;
|
|
745
|
-
|
|
746
|
-
return smoothclip::animateSpring(
|
|
747
574
|
static_cast<uint64_t>(driverId),
|
|
748
575
|
{hasInteractiveStart, startPresentation},
|
|
749
576
|
presentation,
|
|
750
577
|
animation,
|
|
751
|
-
|
|
578
|
+
completionTag);
|
|
752
579
|
}
|
|
753
580
|
|
|
754
|
-
int32_t SmoothClipTurboModule::
|
|
755
|
-
jsi::Runtime
|
|
581
|
+
int32_t SmoothClipTurboModule::animateSpring(
|
|
582
|
+
jsi::Runtime &runtime,
|
|
756
583
|
double driverId,
|
|
757
|
-
|
|
758
|
-
|
|
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,
|
|
584
|
+
jsi::Array start,
|
|
585
|
+
jsi::Array target,
|
|
782
586
|
double mass,
|
|
783
587
|
double stiffness,
|
|
784
588
|
double damping,
|
|
785
589
|
double initialVelocity,
|
|
786
590
|
bool inheritVelocity,
|
|
787
|
-
int32_t reduceMotion
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
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);
|
|
591
|
+
int32_t reduceMotion,
|
|
592
|
+
int32_t completionTag) {
|
|
593
|
+
const bool hasInteractiveStart = start.size(runtime) != 0;
|
|
594
|
+
smoothclip::Presentation startPresentation{};
|
|
595
|
+
smoothclip::Presentation presentation{};
|
|
797
596
|
const smoothclip::SpringAnimation animation{
|
|
798
597
|
mass, stiffness, damping, initialVelocity,
|
|
799
598
|
inheritVelocity, reduceMotion};
|
|
800
599
|
if (!validDriverId(driverId) ||
|
|
801
|
-
|
|
802
|
-
|
|
600
|
+
(hasInteractiveStart &&
|
|
601
|
+
(start.size(runtime) != kPresentationStride ||
|
|
602
|
+
!presentationAt(runtime, start, 0, startPresentation))) ||
|
|
603
|
+
target.size(runtime) != kPresentationStride ||
|
|
604
|
+
!presentationAt(runtime, target, 0, presentation) ||
|
|
803
605
|
!std::isfinite(mass) || !std::isfinite(stiffness) ||
|
|
804
606
|
!std::isfinite(damping) || !std::isfinite(initialVelocity) ||
|
|
805
607
|
mass <= 0 || stiffness <= 0 || damping < 0) {
|
|
@@ -809,293 +611,8 @@ int32_t SmoothClipTurboModule::animateSpringV2(
|
|
|
809
611
|
static_cast<uint64_t>(driverId),
|
|
810
612
|
{hasInteractiveStart, startPresentation},
|
|
811
613
|
presentation,
|
|
812
|
-
animation
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
int32_t SmoothClipTurboModule::animateKeyframes(
|
|
816
|
-
jsi::Runtime &runtime,
|
|
817
|
-
double driverId,
|
|
818
|
-
bool hasInteractiveStart,
|
|
819
|
-
double startX,
|
|
820
|
-
double startY,
|
|
821
|
-
double startWidth,
|
|
822
|
-
double startHeight,
|
|
823
|
-
double startRadius,
|
|
824
|
-
double startContentTranslateX,
|
|
825
|
-
double startContentTranslateY,
|
|
826
|
-
double x,
|
|
827
|
-
double y,
|
|
828
|
-
double width,
|
|
829
|
-
double height,
|
|
830
|
-
double radius,
|
|
831
|
-
double contentTranslateX,
|
|
832
|
-
double contentTranslateY,
|
|
833
|
-
double durationMs,
|
|
834
|
-
jsi::Array frames,
|
|
835
|
-
int32_t reduceMotion) {
|
|
836
|
-
const smoothclip::Presentation startPresentation{
|
|
837
|
-
{startX, startY, startWidth, startHeight, startRadius},
|
|
838
|
-
startContentTranslateX,
|
|
839
|
-
startContentTranslateY};
|
|
840
|
-
const smoothclip::Presentation presentation{
|
|
841
|
-
{x, y, width, height, radius}, contentTranslateX, contentTranslateY};
|
|
842
|
-
if (!validDriverId(driverId) ||
|
|
843
|
-
!finitePresentation(startPresentation) ||
|
|
844
|
-
!finitePresentation(presentation) || !std::isfinite(durationMs) ||
|
|
845
|
-
frames.size(runtime) < 16 || frames.size(runtime) % 8 != 0) {
|
|
846
|
-
return 0;
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
std::vector<smoothclip::Keyframe> keyframes;
|
|
850
|
-
keyframes.reserve(frames.size(runtime) / 8);
|
|
851
|
-
double previousOffset = -1;
|
|
852
|
-
for (size_t index = 0; index < frames.size(runtime); index += 8) {
|
|
853
|
-
const double offset = frames.getValueAtIndex(runtime, index).asNumber();
|
|
854
|
-
smoothclip::Presentation frame{
|
|
855
|
-
{frames.getValueAtIndex(runtime, index + 1).asNumber(),
|
|
856
|
-
frames.getValueAtIndex(runtime, index + 2).asNumber(),
|
|
857
|
-
frames.getValueAtIndex(runtime, index + 3).asNumber(),
|
|
858
|
-
frames.getValueAtIndex(runtime, index + 4).asNumber(),
|
|
859
|
-
frames.getValueAtIndex(runtime, index + 5).asNumber()},
|
|
860
|
-
frames.getValueAtIndex(runtime, index + 6).asNumber(),
|
|
861
|
-
frames.getValueAtIndex(runtime, index + 7).asNumber()};
|
|
862
|
-
if (!std::isfinite(offset) || offset < 0 || offset > 1 ||
|
|
863
|
-
offset <= previousOffset || !finitePresentation(frame)) return 0;
|
|
864
|
-
previousOffset = offset;
|
|
865
|
-
keyframes.push_back({offset, frame});
|
|
866
|
-
}
|
|
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;
|
|
958
|
-
return smoothclip::animateKeyframes(
|
|
959
|
-
static_cast<uint64_t>(driverId),
|
|
960
|
-
{hasInteractiveStart, startPresentation},
|
|
961
|
-
presentation,
|
|
962
|
-
durationMs,
|
|
963
|
-
std::move(keyframes),
|
|
964
|
-
reduceMotion);
|
|
965
|
-
}
|
|
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);
|
|
614
|
+
animation,
|
|
615
|
+
completionTag);
|
|
1099
616
|
}
|
|
1100
617
|
|
|
1101
618
|
int32_t SmoothClipTurboModule::rejectAnimation(
|
|
@@ -1112,29 +629,14 @@ jsi::Array SmoothClipTurboModule::cancelAnimation(
|
|
|
1112
629
|
int32_t behavior) {
|
|
1113
630
|
if (!validDriverId(driverId)) {
|
|
1114
631
|
return presentationArray(
|
|
1115
|
-
runtime, {{0, 0, 0, 0, 0}, 0, 0}, true, false);
|
|
1116
|
-
}
|
|
1117
|
-
const smoothclip::CancelResult result = smoothclip::cancelAnimation(
|
|
1118
|
-
static_cast<uint64_t>(driverId), animationId, behavior == 1);
|
|
1119
|
-
return presentationArray(
|
|
1120
|
-
runtime, result.presentation, true, result.handled);
|
|
1121
|
-
}
|
|
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
632
|
runtime,
|
|
1131
|
-
|
|
633
|
+
makePresentation(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
|
|
1132
634
|
true,
|
|
1133
635
|
false);
|
|
1134
636
|
}
|
|
1135
637
|
const smoothclip::CancelResult result = smoothclip::cancelAnimation(
|
|
1136
638
|
static_cast<uint64_t>(driverId), animationId, behavior == 1);
|
|
1137
|
-
return
|
|
639
|
+
return presentationArray(
|
|
1138
640
|
runtime, result.presentation, true, result.handled);
|
|
1139
641
|
}
|
|
1140
642
|
|