@shopify/react-native-skia 2.13.0 → 2.14.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/android/CMakeLists.txt +2 -0
- package/android/cpp/jni/include/JniSkiaPictureView.h +16 -15
- package/android/cpp/rnskia-android/OpenGLContext.h +1 -1
- package/android/cpp/rnskia-android/gl/Surface.h +1 -1
- package/apple/RNSkApplePlatformContext.h +3 -4
- package/apple/RNSkiaModule.h +11 -3
- package/apple/RNSkiaModule.mm +46 -19
- package/apple/SkiaPictureView.mm +2 -2
- package/apple/SkiaUIView.h +0 -1
- package/apple/SkiaUIView.mm +1 -1
- package/apple/ViewScreenshotService.h +2 -2
- package/apple/ViewScreenshotService.mm +5 -4
- package/cpp/api/JsiSkImage.h +1 -1
- package/cpp/api/JsiSkImageFilter.h +3 -1
- package/cpp/api/JsiSkParagraph.h +2 -1
- package/cpp/api/JsiSkParagraphBuilder.h +1 -1
- package/cpp/api/JsiSkParagraphBuilderFactory.h +1 -1
- package/cpp/api/JsiSkPath.h +11 -435
- package/cpp/api/JsiSkPathBuilder.h +11 -4
- package/cpp/api/JsiSkPictureRecorder.h +2 -1
- package/cpp/api/JsiSkShader.h +3 -1
- package/cpp/api/JsiSkSkottie.h +29 -28
- package/cpp/api/JsiSkStrutStyle.h +1 -1
- package/cpp/api/JsiSkSurfaceFactory.h +41 -0
- package/cpp/api/recorder/Command.h +1 -1
- package/cpp/api/recorder/Convertor.h +153 -132
- package/cpp/api/recorder/DataTypes.h +12 -12
- package/cpp/api/recorder/DrawingCtx.h +1 -1
- package/cpp/api/recorder/ImageFit.h +8 -5
- package/cpp/api/recorder/JsiRecorder.h +14 -31
- package/cpp/api/recorder/Paint.h +3 -3
- package/cpp/api/recorder/RNRecorder.h +56 -0
- package/cpp/api/third_party/base64.cpp +1 -1
- package/cpp/jsi/JSICache.cpp +23 -0
- package/cpp/jsi/JSICache.h +28 -1
- package/cpp/jsi/NativeObject.h +36 -7
- package/cpp/jsi/ViewProperty.cpp +23 -0
- package/cpp/jsi/ViewProperty.h +31 -10
- package/cpp/rnskia/RNDawnContext.h +34 -1
- package/cpp/rnskia/RNSkJsiViewApi.h +69 -2
- package/cpp/rnskia/RNSkPictureView.cpp +58 -0
- package/cpp/rnskia/RNSkPictureView.h +110 -24
- package/lib/commonjs/Platform/IPlatform.js.map +1 -1
- package/lib/commonjs/animation/functions/interpolate.js.map +1 -1
- package/lib/commonjs/animation/functions/interpolatePaths.js +18 -0
- package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/commonjs/skia/core/Image.js.map +1 -1
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Path/Path.d.ts +2 -336
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/types/Recorder.d.ts +10 -0
- package/lib/commonjs/skia/types/Recorder.js.map +1 -1
- package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +16 -0
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.d.ts +4 -38
- package/lib/commonjs/skia/web/JsiSkPath.js +3 -275
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +3 -0
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/commonjs/sksg/Container.native.d.ts +15 -1
- package/lib/commonjs/sksg/Container.native.js +34 -33
- package/lib/commonjs/sksg/Container.native.js.map +1 -1
- package/lib/commonjs/specs/NativeSkiaModule.web.js +4 -0
- package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/commonjs/views/types.d.ts +9 -0
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/Platform/IPlatform.js.map +1 -1
- package/lib/module/animation/functions/interpolate.js.map +1 -1
- package/lib/module/animation/functions/interpolatePaths.js +18 -0
- package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/module/skia/core/Image.js.map +1 -1
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/module/skia/types/Path/Path.d.ts +2 -336
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/types/Recorder.d.ts +10 -0
- package/lib/module/skia/types/Recorder.js.map +1 -1
- package/lib/module/skia/types/Shader/Shader.js.map +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +16 -0
- package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.d.ts +4 -38
- package/lib/module/skia/web/JsiSkPath.js +4 -276
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js +4 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/module/sksg/Container.native.d.ts +15 -1
- package/lib/module/sksg/Container.native.js +34 -33
- package/lib/module/sksg/Container.native.js.map +1 -1
- package/lib/module/specs/NativeSkiaModule.web.js +4 -0
- package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/module/views/types.d.ts +9 -0
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +1 -35
- package/lib/typescript/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +15 -1
- package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +3 -37
- package/lib/typescript/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Container.native.d.ts +15 -1
- package/lib/typescript/src/skia/types/Path/Path.d.ts +2 -336
- package/lib/typescript/src/skia/types/Recorder.d.ts +10 -0
- package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +16 -0
- package/lib/typescript/src/skia/web/JsiSkPath.d.ts +4 -38
- package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/typescript/src/sksg/Container.native.d.ts +15 -1
- package/lib/typescript/src/views/types.d.ts +9 -0
- package/package.json +2 -2
- package/src/Platform/IPlatform.ts +1 -4
- package/src/animation/functions/interpolate.ts +1 -4
- package/src/animation/functions/interpolatePaths.ts +24 -0
- package/src/skia/core/Image.ts +1 -2
- package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +2 -5
- package/src/skia/types/Path/Path.ts +2 -420
- package/src/skia/types/Recorder.ts +10 -0
- package/src/skia/types/Shader/Shader.ts +1 -5
- package/src/skia/types/Surface/SurfaceFactory.ts +17 -0
- package/src/skia/web/JsiSkPath.ts +4 -495
- package/src/skia/web/JsiSkSurfaceFactory.ts +6 -2
- package/src/sksg/Container.native.ts +34 -37
- package/src/specs/NativeSkiaModule.web.ts +4 -0
- package/src/views/types.ts +13 -0
- package/apple/SkiaManager.h +0 -23
- package/apple/SkiaManager.mm +0 -63
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { PathVerb } from "../types";
|
|
2
|
-
import {
|
|
2
|
+
import { HostObject } from "./Host";
|
|
3
3
|
import { JsiSkPoint } from "./JsiSkPoint";
|
|
4
4
|
import { JsiSkRect } from "./JsiSkRect";
|
|
5
|
-
import { JsiSkRRect } from "./JsiSkRRect";
|
|
6
5
|
import { JsiSkMatrix } from "./JsiSkMatrix";
|
|
7
6
|
const CommandCount = {
|
|
8
7
|
[PathVerb.Move]: 3,
|
|
@@ -12,16 +11,6 @@ const CommandCount = {
|
|
|
12
11
|
[PathVerb.Cubic]: 7,
|
|
13
12
|
[PathVerb.Close]: 1
|
|
14
13
|
};
|
|
15
|
-
|
|
16
|
-
// Track which deprecation warnings have been shown to avoid spam
|
|
17
|
-
const shownDeprecationWarnings = new Set();
|
|
18
|
-
const warnDeprecatedPathMethod = (methodName, suggestion) => {
|
|
19
|
-
if (shownDeprecationWarnings.has(methodName)) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
shownDeprecationWarnings.add(methodName);
|
|
23
|
-
console.warn(`[react-native-skia] SkPath.${methodName}() is deprecated and will be removed in a future release. ${suggestion} See migration guide: https://shopify.github.io/react-native-skia/docs/shapes/path-migration`);
|
|
24
|
-
};
|
|
25
14
|
export const toMatrix3x3 = m => {
|
|
26
15
|
let matrix = m instanceof JsiSkMatrix ? Array.from(JsiSkMatrix.fromValue(m)) : m;
|
|
27
16
|
if (matrix.length === 16) {
|
|
@@ -33,8 +22,8 @@ export const toMatrix3x3 = m => {
|
|
|
33
22
|
};
|
|
34
23
|
|
|
35
24
|
/**
|
|
36
|
-
* SkPath wraps a CK PathBuilder internally, providing
|
|
37
|
-
* methods
|
|
25
|
+
* SkPath wraps a CK PathBuilder internally, providing immutable query
|
|
26
|
+
* methods. Use snapshot() internally to get
|
|
38
27
|
* an immutable CK Path for read-only operations.
|
|
39
28
|
*/
|
|
40
29
|
export class JsiSkPath extends HostObject {
|
|
@@ -52,259 +41,6 @@ export class JsiSkPath extends HostObject {
|
|
|
52
41
|
return JsiSkPath.fromValue(value).snapshot();
|
|
53
42
|
}
|
|
54
43
|
|
|
55
|
-
// ---- Mutable building methods (deprecated) ----
|
|
56
|
-
|
|
57
|
-
addPath(src, matrix, extend = false) {
|
|
58
|
-
warnDeprecatedPathMethod("addPath", "Use Skia.PathBuilder.Make().addPath() instead.");
|
|
59
|
-
const srcBuilder = JsiSkPath.fromValue(src);
|
|
60
|
-
const srcPath = srcBuilder.snapshot();
|
|
61
|
-
const args = [srcPath, ...(matrix ? JsiSkMatrix.fromValue(matrix) : []), extend];
|
|
62
|
-
this.ref.addPath(...args);
|
|
63
|
-
srcPath.delete();
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
addArc(oval, startAngleInDegrees, sweepAngleInDegrees) {
|
|
67
|
-
warnDeprecatedPathMethod("addArc", "Use Skia.PathBuilder.Make().addArc() instead.");
|
|
68
|
-
this.ref.addArc(JsiSkRect.fromValue(this.CanvasKit, oval), startAngleInDegrees, sweepAngleInDegrees);
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
addOval(oval, isCCW, startIndex) {
|
|
72
|
-
warnDeprecatedPathMethod("addOval", "Use Skia.Path.Oval() or Skia.PathBuilder.Make().addOval() instead.");
|
|
73
|
-
this.ref.addOval(JsiSkRect.fromValue(this.CanvasKit, oval), isCCW, startIndex);
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
addPoly(points, close) {
|
|
77
|
-
warnDeprecatedPathMethod("addPoly", "Use Skia.Path.Polygon() or Skia.PathBuilder.Make().addPoly() instead.");
|
|
78
|
-
this.ref.addPolygon(points.map(p => Array.from(JsiSkPoint.fromValue(p))).flat(), close);
|
|
79
|
-
return this;
|
|
80
|
-
}
|
|
81
|
-
addRect(rect, isCCW) {
|
|
82
|
-
warnDeprecatedPathMethod("addRect", "Use Skia.Path.Rect() or Skia.PathBuilder.Make().addRect() instead.");
|
|
83
|
-
this.ref.addRect(JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
|
-
addRRect(rrect, isCCW) {
|
|
87
|
-
warnDeprecatedPathMethod("addRRect", "Use Skia.Path.RRect() or Skia.PathBuilder.Make().addRRect() instead.");
|
|
88
|
-
this.ref.addRRect(JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);
|
|
89
|
-
return this;
|
|
90
|
-
}
|
|
91
|
-
addCircle(x, y, r) {
|
|
92
|
-
warnDeprecatedPathMethod("addCircle", "Use Skia.Path.Circle() or Skia.PathBuilder.Make().addCircle() instead.");
|
|
93
|
-
this.ref.addCircle(x, y, r);
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
96
|
-
moveTo(x, y) {
|
|
97
|
-
warnDeprecatedPathMethod("moveTo", "Use Skia.PathBuilder.Make().moveTo() instead.");
|
|
98
|
-
this.ref.moveTo(x, y);
|
|
99
|
-
return this;
|
|
100
|
-
}
|
|
101
|
-
rMoveTo(x, y) {
|
|
102
|
-
warnDeprecatedPathMethod("rMoveTo", "Use Skia.PathBuilder.Make().rMoveTo() instead.");
|
|
103
|
-
this.ref.rMoveTo(x, y);
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
lineTo(x, y) {
|
|
107
|
-
warnDeprecatedPathMethod("lineTo", "Use Skia.PathBuilder.Make().lineTo() instead.");
|
|
108
|
-
this.ref.lineTo(x, y);
|
|
109
|
-
return this;
|
|
110
|
-
}
|
|
111
|
-
rLineTo(x, y) {
|
|
112
|
-
warnDeprecatedPathMethod("rLineTo", "Use Skia.PathBuilder.Make().rLineTo() instead.");
|
|
113
|
-
this.ref.rLineTo(x, y);
|
|
114
|
-
return this;
|
|
115
|
-
}
|
|
116
|
-
quadTo(x1, y1, x2, y2) {
|
|
117
|
-
warnDeprecatedPathMethod("quadTo", "Use Skia.PathBuilder.Make().quadTo() instead.");
|
|
118
|
-
this.ref.quadTo(x1, y1, x2, y2);
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
rQuadTo(x1, y1, x2, y2) {
|
|
122
|
-
warnDeprecatedPathMethod("rQuadTo", "Use Skia.PathBuilder.Make().rQuadTo() instead.");
|
|
123
|
-
this.ref.rQuadTo(x1, y1, x2, y2);
|
|
124
|
-
return this;
|
|
125
|
-
}
|
|
126
|
-
conicTo(x1, y1, x2, y2, w) {
|
|
127
|
-
warnDeprecatedPathMethod("conicTo", "Use Skia.PathBuilder.Make().conicTo() instead.");
|
|
128
|
-
this.ref.conicTo(x1, y1, x2, y2, w);
|
|
129
|
-
return this;
|
|
130
|
-
}
|
|
131
|
-
rConicTo(x1, y1, x2, y2, w) {
|
|
132
|
-
warnDeprecatedPathMethod("rConicTo", "Use Skia.PathBuilder.Make().rConicTo() instead.");
|
|
133
|
-
this.ref.rConicTo(x1, y1, x2, y2, w);
|
|
134
|
-
return this;
|
|
135
|
-
}
|
|
136
|
-
cubicTo(cpx1, cpy1, cpx2, cpy2, x, y) {
|
|
137
|
-
warnDeprecatedPathMethod("cubicTo", "Use Skia.PathBuilder.Make().cubicTo() instead.");
|
|
138
|
-
this.ref.cubicTo(cpx1, cpy1, cpx2, cpy2, x, y);
|
|
139
|
-
return this;
|
|
140
|
-
}
|
|
141
|
-
rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y) {
|
|
142
|
-
warnDeprecatedPathMethod("rCubicTo", "Use Skia.PathBuilder.Make().rCubicTo() instead.");
|
|
143
|
-
this.ref.rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y);
|
|
144
|
-
return this;
|
|
145
|
-
}
|
|
146
|
-
close() {
|
|
147
|
-
warnDeprecatedPathMethod("close", "Use Skia.PathBuilder.Make().close() instead.");
|
|
148
|
-
this.ref.close();
|
|
149
|
-
return this;
|
|
150
|
-
}
|
|
151
|
-
reset() {
|
|
152
|
-
warnDeprecatedPathMethod("reset", "Use Skia.PathBuilder.Make().reset() instead.");
|
|
153
|
-
// CK PathBuilder has no reset — recreate
|
|
154
|
-
const newBuilder = new this.CanvasKit.PathBuilder();
|
|
155
|
-
if (this.ref !== null && typeof this.ref === "object" && "delete" in this.ref && typeof this.ref.delete === "function") {
|
|
156
|
-
this.ref.delete();
|
|
157
|
-
}
|
|
158
|
-
this.ref = newBuilder;
|
|
159
|
-
return this;
|
|
160
|
-
}
|
|
161
|
-
rewind() {
|
|
162
|
-
warnDeprecatedPathMethod("rewind", "Use Skia.PathBuilder.Make().reset() instead.");
|
|
163
|
-
return this.reset();
|
|
164
|
-
}
|
|
165
|
-
arcToOval(oval, startAngleInDegrees, sweepAngleInDegrees, forceMoveTo) {
|
|
166
|
-
warnDeprecatedPathMethod("arcToOval", "Use Skia.PathBuilder.Make().arcToOval() instead.");
|
|
167
|
-
this.ref.arcToOval(JsiSkRect.fromValue(this.CanvasKit, oval), startAngleInDegrees, sweepAngleInDegrees, forceMoveTo);
|
|
168
|
-
return this;
|
|
169
|
-
}
|
|
170
|
-
arcToRotated(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, x, y) {
|
|
171
|
-
warnDeprecatedPathMethod("arcToRotated", "Use Skia.PathBuilder.Make().arcToRotated() instead.");
|
|
172
|
-
this.ref.arcToRotated(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, x, y);
|
|
173
|
-
return this;
|
|
174
|
-
}
|
|
175
|
-
rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy) {
|
|
176
|
-
warnDeprecatedPathMethod("rArcTo", "Use Skia.PathBuilder.Make().rArcTo() instead.");
|
|
177
|
-
this.ref.rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy);
|
|
178
|
-
return this;
|
|
179
|
-
}
|
|
180
|
-
arcToTangent(x1, y1, x2, y2, radius) {
|
|
181
|
-
warnDeprecatedPathMethod("arcToTangent", "Use Skia.PathBuilder.Make().arcToTangent() instead.");
|
|
182
|
-
this.ref.arcToTangent(x1, y1, x2, y2, radius);
|
|
183
|
-
return this;
|
|
184
|
-
}
|
|
185
|
-
setFillType(fill) {
|
|
186
|
-
warnDeprecatedPathMethod("setFillType", "Use Skia.PathBuilder.Make().setFillType() instead.");
|
|
187
|
-
this.ref.setFillType(getEnum(this.CanvasKit, "FillType", fill));
|
|
188
|
-
return this;
|
|
189
|
-
}
|
|
190
|
-
setIsVolatile(_volatile) {
|
|
191
|
-
warnDeprecatedPathMethod("setIsVolatile", "Use Skia.PathBuilder.Make().setIsVolatile() instead.");
|
|
192
|
-
// Not supported in CK PathBuilder — no-op
|
|
193
|
-
return this;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// ---- Mutable path operations (deprecated) ----
|
|
197
|
-
|
|
198
|
-
offset(dx, dy) {
|
|
199
|
-
warnDeprecatedPathMethod("offset", "Use Skia.PathBuilder.Make().offset() instead.");
|
|
200
|
-
this.ref.offset(dx, dy);
|
|
201
|
-
return this;
|
|
202
|
-
}
|
|
203
|
-
transform(m) {
|
|
204
|
-
warnDeprecatedPathMethod("transform", "Use Skia.PathBuilder.Make().transform() instead.");
|
|
205
|
-
const matrix = toMatrix3x3(m);
|
|
206
|
-
this.ref.transform(matrix);
|
|
207
|
-
return this;
|
|
208
|
-
}
|
|
209
|
-
makeAsWinding() {
|
|
210
|
-
warnDeprecatedPathMethod("makeAsWinding", "Use Skia.Path.AsWinding(path) instead.");
|
|
211
|
-
const path = this.asPath();
|
|
212
|
-
const result = path.makeAsWinding();
|
|
213
|
-
path.delete();
|
|
214
|
-
if (result === null) {
|
|
215
|
-
return null;
|
|
216
|
-
}
|
|
217
|
-
const old = this.ref;
|
|
218
|
-
this.ref = new this.CanvasKit.PathBuilder(result);
|
|
219
|
-
result.delete();
|
|
220
|
-
old.delete();
|
|
221
|
-
return this;
|
|
222
|
-
}
|
|
223
|
-
simplify() {
|
|
224
|
-
warnDeprecatedPathMethod("simplify", "Use Skia.Path.Simplify(path) instead.");
|
|
225
|
-
const path = this.asPath();
|
|
226
|
-
const result = path.makeSimplified();
|
|
227
|
-
path.delete();
|
|
228
|
-
if (result === null) {
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
const old = this.ref;
|
|
232
|
-
this.ref = new this.CanvasKit.PathBuilder(result);
|
|
233
|
-
result.delete();
|
|
234
|
-
old.delete();
|
|
235
|
-
return true;
|
|
236
|
-
}
|
|
237
|
-
op(path, op) {
|
|
238
|
-
warnDeprecatedPathMethod("op", "Use Skia.Path.MakeFromOp() instead.");
|
|
239
|
-
const self = this.asPath();
|
|
240
|
-
const other = JsiSkPath.fromValue(path).snapshot();
|
|
241
|
-
const result = self.makeCombined(other, getEnum(this.CanvasKit, "PathOp", op));
|
|
242
|
-
self.delete();
|
|
243
|
-
other.delete();
|
|
244
|
-
if (result === null) {
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
const old = this.ref;
|
|
248
|
-
this.ref = new this.CanvasKit.PathBuilder(result);
|
|
249
|
-
result.delete();
|
|
250
|
-
old.delete();
|
|
251
|
-
return true;
|
|
252
|
-
}
|
|
253
|
-
dash(on, off, phase) {
|
|
254
|
-
warnDeprecatedPathMethod("dash", "Use Skia.Path.Dash(path, on, off, phase) instead.");
|
|
255
|
-
const path = this.asPath();
|
|
256
|
-
const result = path.makeDashed(on, off, phase);
|
|
257
|
-
path.delete();
|
|
258
|
-
if (result === null) {
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
const old = this.ref;
|
|
262
|
-
this.ref = new this.CanvasKit.PathBuilder(result);
|
|
263
|
-
result.delete();
|
|
264
|
-
old.delete();
|
|
265
|
-
return true;
|
|
266
|
-
}
|
|
267
|
-
stroke(opts) {
|
|
268
|
-
warnDeprecatedPathMethod("stroke", "Use Skia.Path.Stroke(path, opts) instead.");
|
|
269
|
-
const path = this.asPath();
|
|
270
|
-
const result = path.makeStroked(opts === undefined ? undefined : {
|
|
271
|
-
width: opts.width,
|
|
272
|
-
// eslint-disable-next-line camelcase
|
|
273
|
-
miter_limit: opts.miter_limit,
|
|
274
|
-
precision: opts.precision,
|
|
275
|
-
join: optEnum(this.CanvasKit, "StrokeJoin", opts.join),
|
|
276
|
-
cap: optEnum(this.CanvasKit, "StrokeCap", opts.cap)
|
|
277
|
-
});
|
|
278
|
-
path.delete();
|
|
279
|
-
if (result === null) {
|
|
280
|
-
return null;
|
|
281
|
-
}
|
|
282
|
-
const old = this.ref;
|
|
283
|
-
this.ref = new this.CanvasKit.PathBuilder(result);
|
|
284
|
-
result.delete();
|
|
285
|
-
old.delete();
|
|
286
|
-
return this;
|
|
287
|
-
}
|
|
288
|
-
trim(start, stop, isComplement) {
|
|
289
|
-
warnDeprecatedPathMethod("trim", "Use Skia.Path.Trim(path, start, end, isComplement) instead.");
|
|
290
|
-
const startT = Math.min(Math.max(start, 0), 1);
|
|
291
|
-
const stopT = Math.min(Math.max(stop, 0), 1);
|
|
292
|
-
if (startT === 0 && stopT === 1 && !isComplement) {
|
|
293
|
-
return this;
|
|
294
|
-
}
|
|
295
|
-
const path = this.asPath();
|
|
296
|
-
const result = path.makeTrimmed(startT, stopT, isComplement);
|
|
297
|
-
path.delete();
|
|
298
|
-
if (result === null) {
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
301
|
-
const old = this.ref;
|
|
302
|
-
this.ref = new this.CanvasKit.PathBuilder(result);
|
|
303
|
-
result.delete();
|
|
304
|
-
old.delete();
|
|
305
|
-
return this;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
44
|
// ---- Query methods (use snapshot for read-only) ----
|
|
309
45
|
|
|
310
46
|
countPoints() {
|
|
@@ -387,7 +123,7 @@ export class JsiSkPath extends HostObject {
|
|
|
387
123
|
p2.delete();
|
|
388
124
|
return result;
|
|
389
125
|
}
|
|
390
|
-
interpolate(end, weight
|
|
126
|
+
interpolate(end, weight) {
|
|
391
127
|
const p1 = this.asPath();
|
|
392
128
|
const p2 = JsiSkPath.fromValue(end).snapshot();
|
|
393
129
|
const path = this.CanvasKit.Path.MakeFromPathInterpolation(p1, p2, weight);
|
|
@@ -396,14 +132,6 @@ export class JsiSkPath extends HostObject {
|
|
|
396
132
|
if (path === null) {
|
|
397
133
|
return null;
|
|
398
134
|
}
|
|
399
|
-
if (output) {
|
|
400
|
-
const outRef = output;
|
|
401
|
-
const old = outRef.ref;
|
|
402
|
-
outRef.ref = new this.CanvasKit.PathBuilder(path);
|
|
403
|
-
path.delete();
|
|
404
|
-
old.delete();
|
|
405
|
-
return output;
|
|
406
|
-
}
|
|
407
135
|
const result = new JsiSkPath(this.CanvasKit, new this.CanvasKit.PathBuilder(path));
|
|
408
136
|
path.delete();
|
|
409
137
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PathVerb","getEnum","HostObject","optEnum","JsiSkPoint","JsiSkRect","JsiSkRRect","JsiSkMatrix","CommandCount","Move","Line","Quad","Conic","Cubic","Close","shownDeprecationWarnings","Set","warnDeprecatedPathMethod","methodName","suggestion","has","add","console","warn","toMatrix3x3","m","matrix","Array","from","fromValue","length","Error","JsiSkPath","constructor","CanvasKit","ref","asPath","snapshot","pathFromValue","value","addPath","src","extend","srcBuilder","srcPath","args","delete","addArc","oval","startAngleInDegrees","sweepAngleInDegrees","addOval","isCCW","startIndex","addPoly","points","close","addPolygon","map","p","flat","addRect","rect","addRRect","rrect","addCircle","x","y","r","moveTo","rMoveTo","lineTo","rLineTo","quadTo","x1","y1","x2","y2","rQuadTo","conicTo","w","rConicTo","cubicTo","cpx1","cpy1","cpx2","cpy2","rCubicTo","reset","newBuilder","PathBuilder","rewind","arcToOval","forceMoveTo","arcToRotated","rx","ry","xAxisRotateInDegrees","useSmallArc","rArcTo","dx","dy","arcToTangent","radius","setFillType","fill","setIsVolatile","_volatile","offset","transform","makeAsWinding","path","result","old","simplify","makeSimplified","op","self","other","makeCombined","dash","on","off","phase","makeDashed","stroke","opts","makeStroked","undefined","width","miter_limit","precision","join","cap","trim","start","stop","isComplement","startT","Math","min","max","stopT","makeTrimmed","countPoints","computeTightBounds","contains","copy","equals","p1","p2","getBounds","getFillType","getPoint","index","isEmpty","isVolatile","getLastPt","count","pt","toSVGString","isInterpolatable","path2","Path","CanInterpolate","interpolate","end","weight","output","MakeFromPathInterpolation","outRef","toCmds","cmds","reduce","acc","cmd","i","push","current"],"sources":["JsiSkPath.ts"],"sourcesContent":["import type { CanvasKit, PathBuilder as CKPathBuilder } from \"canvaskit-wasm\";\n\nimport { PathVerb } from \"../types\";\nimport type {\n FillType,\n PathCommand,\n PathOp,\n SkMatrix,\n SkPath,\n SkPoint,\n SkRect,\n InputRRect,\n StrokeOpts,\n InputMatrix,\n} from \"../types\";\n\nimport { getEnum, HostObject, optEnum } from \"./Host\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\n\nconst CommandCount = {\n [PathVerb.Move]: 3,\n [PathVerb.Line]: 3,\n [PathVerb.Quad]: 5,\n [PathVerb.Conic]: 6,\n [PathVerb.Cubic]: 7,\n [PathVerb.Close]: 1,\n};\n\n// Track which deprecation warnings have been shown to avoid spam\nconst shownDeprecationWarnings = new Set<string>();\n\nconst warnDeprecatedPathMethod = (\n methodName: string,\n suggestion: string\n): void => {\n if (shownDeprecationWarnings.has(methodName)) {\n return;\n }\n shownDeprecationWarnings.add(methodName);\n console.warn(\n `[react-native-skia] SkPath.${methodName}() is deprecated and will be removed in a future release. ${suggestion} See migration guide: https://shopify.github.io/react-native-skia/docs/shapes/path-migration`\n );\n};\n\nexport const toMatrix3x3 = (m: InputMatrix): number[] => {\n let matrix =\n m instanceof JsiSkMatrix\n ? Array.from(JsiSkMatrix.fromValue<Float32Array>(m))\n : (m as Exclude<InputMatrix, SkMatrix>);\n if (matrix.length === 16) {\n matrix = [\n matrix[0],\n matrix[1],\n matrix[3],\n matrix[4],\n matrix[5],\n matrix[7],\n matrix[12],\n matrix[13],\n matrix[15],\n ];\n } else if (matrix.length !== 9) {\n throw new Error(`Invalid matrix length: ${matrix.length}`);\n }\n return matrix as number[];\n};\n\n/**\n * SkPath wraps a CK PathBuilder internally, providing both mutable building\n * methods and immutable query methods. Use snapshot() internally to get\n * an immutable CK Path for read-only operations.\n */\nexport class JsiSkPath\n extends HostObject<CKPathBuilder, \"Path\">\n implements SkPath\n{\n constructor(CanvasKit: CanvasKit, ref: CKPathBuilder) {\n super(CanvasKit, ref, \"Path\");\n }\n\n /** Returns an immutable CK Path snapshot for read-only operations. */\n private asPath() {\n return this.ref.snapshot();\n }\n\n /** Extract an immutable CK Path from a JsiSkPath value (for CK interop). */\n static pathFromValue(value: SkPath) {\n return JsiSkPath.fromValue<CKPathBuilder>(value).snapshot();\n }\n\n // ---- Mutable building methods (deprecated) ----\n\n addPath(src: SkPath, matrix?: SkMatrix, extend = false) {\n warnDeprecatedPathMethod(\n \"addPath\",\n \"Use Skia.PathBuilder.Make().addPath() instead.\"\n );\n const srcBuilder = JsiSkPath.fromValue<CKPathBuilder>(src);\n const srcPath = srcBuilder.snapshot();\n const args = [\n srcPath,\n ...(matrix ? JsiSkMatrix.fromValue<Float32Array>(matrix) : []),\n extend,\n ];\n this.ref.addPath(...args);\n srcPath.delete();\n return this;\n }\n\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ) {\n warnDeprecatedPathMethod(\n \"addArc\",\n \"Use Skia.PathBuilder.Make().addArc() instead.\"\n );\n this.ref.addArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees\n );\n return this;\n }\n\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number) {\n warnDeprecatedPathMethod(\n \"addOval\",\n \"Use Skia.Path.Oval() or Skia.PathBuilder.Make().addOval() instead.\"\n );\n this.ref.addOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n isCCW,\n startIndex\n );\n return this;\n }\n\n addPoly(points: SkPoint[], close: boolean) {\n warnDeprecatedPathMethod(\n \"addPoly\",\n \"Use Skia.Path.Polygon() or Skia.PathBuilder.Make().addPoly() instead.\"\n );\n this.ref.addPolygon(\n points.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),\n close\n );\n return this;\n }\n\n addRect(rect: SkRect, isCCW?: boolean) {\n warnDeprecatedPathMethod(\n \"addRect\",\n \"Use Skia.Path.Rect() or Skia.PathBuilder.Make().addRect() instead.\"\n );\n this.ref.addRect(JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);\n return this;\n }\n\n addRRect(rrect: InputRRect, isCCW?: boolean) {\n warnDeprecatedPathMethod(\n \"addRRect\",\n \"Use Skia.Path.RRect() or Skia.PathBuilder.Make().addRRect() instead.\"\n );\n this.ref.addRRect(JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);\n return this;\n }\n\n addCircle(x: number, y: number, r: number) {\n warnDeprecatedPathMethod(\n \"addCircle\",\n \"Use Skia.Path.Circle() or Skia.PathBuilder.Make().addCircle() instead.\"\n );\n this.ref.addCircle(x, y, r);\n return this;\n }\n\n moveTo(x: number, y: number) {\n warnDeprecatedPathMethod(\n \"moveTo\",\n \"Use Skia.PathBuilder.Make().moveTo() instead.\"\n );\n this.ref.moveTo(x, y);\n return this;\n }\n\n rMoveTo(x: number, y: number) {\n warnDeprecatedPathMethod(\n \"rMoveTo\",\n \"Use Skia.PathBuilder.Make().rMoveTo() instead.\"\n );\n this.ref.rMoveTo(x, y);\n return this;\n }\n\n lineTo(x: number, y: number) {\n warnDeprecatedPathMethod(\n \"lineTo\",\n \"Use Skia.PathBuilder.Make().lineTo() instead.\"\n );\n this.ref.lineTo(x, y);\n return this;\n }\n\n rLineTo(x: number, y: number) {\n warnDeprecatedPathMethod(\n \"rLineTo\",\n \"Use Skia.PathBuilder.Make().rLineTo() instead.\"\n );\n this.ref.rLineTo(x, y);\n return this;\n }\n\n quadTo(x1: number, y1: number, x2: number, y2: number) {\n warnDeprecatedPathMethod(\n \"quadTo\",\n \"Use Skia.PathBuilder.Make().quadTo() instead.\"\n );\n this.ref.quadTo(x1, y1, x2, y2);\n return this;\n }\n\n rQuadTo(x1: number, y1: number, x2: number, y2: number) {\n warnDeprecatedPathMethod(\n \"rQuadTo\",\n \"Use Skia.PathBuilder.Make().rQuadTo() instead.\"\n );\n this.ref.rQuadTo(x1, y1, x2, y2);\n return this;\n }\n\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number) {\n warnDeprecatedPathMethod(\n \"conicTo\",\n \"Use Skia.PathBuilder.Make().conicTo() instead.\"\n );\n this.ref.conicTo(x1, y1, x2, y2, w);\n return this;\n }\n\n rConicTo(x1: number, y1: number, x2: number, y2: number, w: number) {\n warnDeprecatedPathMethod(\n \"rConicTo\",\n \"Use Skia.PathBuilder.Make().rConicTo() instead.\"\n );\n this.ref.rConicTo(x1, y1, x2, y2, w);\n return this;\n }\n\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n warnDeprecatedPathMethod(\n \"cubicTo\",\n \"Use Skia.PathBuilder.Make().cubicTo() instead.\"\n );\n this.ref.cubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n warnDeprecatedPathMethod(\n \"rCubicTo\",\n \"Use Skia.PathBuilder.Make().rCubicTo() instead.\"\n );\n this.ref.rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n close() {\n warnDeprecatedPathMethod(\n \"close\",\n \"Use Skia.PathBuilder.Make().close() instead.\"\n );\n this.ref.close();\n return this;\n }\n\n reset() {\n warnDeprecatedPathMethod(\n \"reset\",\n \"Use Skia.PathBuilder.Make().reset() instead.\"\n );\n // CK PathBuilder has no reset — recreate\n const newBuilder = new this.CanvasKit.PathBuilder();\n if (\n this.ref !== null &&\n typeof this.ref === \"object\" &&\n \"delete\" in this.ref &&\n typeof this.ref.delete === \"function\"\n ) {\n this.ref.delete();\n }\n this.ref = newBuilder;\n return this;\n }\n\n rewind() {\n warnDeprecatedPathMethod(\n \"rewind\",\n \"Use Skia.PathBuilder.Make().reset() instead.\"\n );\n return this.reset();\n }\n\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ) {\n warnDeprecatedPathMethod(\n \"arcToOval\",\n \"Use Skia.PathBuilder.Make().arcToOval() instead.\"\n );\n this.ref.arcToOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees,\n forceMoveTo\n );\n return this;\n }\n\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ) {\n warnDeprecatedPathMethod(\n \"arcToRotated\",\n \"Use Skia.PathBuilder.Make().arcToRotated() instead.\"\n );\n this.ref.arcToRotated(\n rx,\n ry,\n xAxisRotateInDegrees,\n useSmallArc,\n isCCW,\n x,\n y\n );\n return this;\n }\n\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ) {\n warnDeprecatedPathMethod(\n \"rArcTo\",\n \"Use Skia.PathBuilder.Make().rArcTo() instead.\"\n );\n this.ref.rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy);\n return this;\n }\n\n arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number) {\n warnDeprecatedPathMethod(\n \"arcToTangent\",\n \"Use Skia.PathBuilder.Make().arcToTangent() instead.\"\n );\n this.ref.arcToTangent(x1, y1, x2, y2, radius);\n return this;\n }\n\n setFillType(fill: FillType) {\n warnDeprecatedPathMethod(\n \"setFillType\",\n \"Use Skia.PathBuilder.Make().setFillType() instead.\"\n );\n this.ref.setFillType(getEnum(this.CanvasKit, \"FillType\", fill));\n return this;\n }\n\n setIsVolatile(_volatile: boolean) {\n warnDeprecatedPathMethod(\n \"setIsVolatile\",\n \"Use Skia.PathBuilder.Make().setIsVolatile() instead.\"\n );\n // Not supported in CK PathBuilder — no-op\n return this;\n }\n\n // ---- Mutable path operations (deprecated) ----\n\n offset(dx: number, dy: number) {\n warnDeprecatedPathMethod(\n \"offset\",\n \"Use Skia.PathBuilder.Make().offset() instead.\"\n );\n this.ref.offset(dx, dy);\n return this;\n }\n\n transform(m: InputMatrix) {\n warnDeprecatedPathMethod(\n \"transform\",\n \"Use Skia.PathBuilder.Make().transform() instead.\"\n );\n const matrix = toMatrix3x3(m);\n this.ref.transform(matrix);\n return this;\n }\n\n makeAsWinding() {\n warnDeprecatedPathMethod(\n \"makeAsWinding\",\n \"Use Skia.Path.AsWinding(path) instead.\"\n );\n const path = this.asPath();\n const result = path.makeAsWinding();\n path.delete();\n if (result === null) {\n return null;\n }\n const old = this.ref;\n this.ref = new this.CanvasKit.PathBuilder(result);\n result.delete();\n old.delete();\n return this;\n }\n\n simplify() {\n warnDeprecatedPathMethod(\n \"simplify\",\n \"Use Skia.Path.Simplify(path) instead.\"\n );\n const path = this.asPath();\n const result = path.makeSimplified();\n path.delete();\n if (result === null) {\n return false;\n }\n const old = this.ref;\n this.ref = new this.CanvasKit.PathBuilder(result);\n result.delete();\n old.delete();\n return true;\n }\n\n op(path: SkPath, op: PathOp) {\n warnDeprecatedPathMethod(\"op\", \"Use Skia.Path.MakeFromOp() instead.\");\n const self = this.asPath();\n const other = JsiSkPath.fromValue<CKPathBuilder>(path).snapshot();\n const result = self.makeCombined(\n other,\n getEnum(this.CanvasKit, \"PathOp\", op)\n );\n self.delete();\n other.delete();\n if (result === null) {\n return false;\n }\n const old = this.ref;\n this.ref = new this.CanvasKit.PathBuilder(result);\n result.delete();\n old.delete();\n return true;\n }\n\n dash(on: number, off: number, phase: number) {\n warnDeprecatedPathMethod(\n \"dash\",\n \"Use Skia.Path.Dash(path, on, off, phase) instead.\"\n );\n const path = this.asPath();\n const result = path.makeDashed(on, off, phase);\n path.delete();\n if (result === null) {\n return false;\n }\n const old = this.ref;\n this.ref = new this.CanvasKit.PathBuilder(result);\n result.delete();\n old.delete();\n return true;\n }\n\n stroke(opts?: StrokeOpts) {\n warnDeprecatedPathMethod(\n \"stroke\",\n \"Use Skia.Path.Stroke(path, opts) instead.\"\n );\n const path = this.asPath();\n const result = path.makeStroked(\n opts === undefined\n ? undefined\n : {\n width: opts.width,\n // eslint-disable-next-line camelcase\n miter_limit: opts.miter_limit,\n precision: opts.precision,\n join: optEnum(this.CanvasKit, \"StrokeJoin\", opts.join),\n cap: optEnum(this.CanvasKit, \"StrokeCap\", opts.cap),\n }\n );\n path.delete();\n if (result === null) {\n return null;\n }\n const old = this.ref;\n this.ref = new this.CanvasKit.PathBuilder(result);\n result.delete();\n old.delete();\n return this;\n }\n\n trim(start: number, stop: number, isComplement: boolean) {\n warnDeprecatedPathMethod(\n \"trim\",\n \"Use Skia.Path.Trim(path, start, end, isComplement) instead.\"\n );\n const startT = Math.min(Math.max(start, 0), 1);\n const stopT = Math.min(Math.max(stop, 0), 1);\n if (startT === 0 && stopT === 1 && !isComplement) {\n return this;\n }\n const path = this.asPath();\n const result = path.makeTrimmed(startT, stopT, isComplement);\n path.delete();\n if (result === null) {\n return null;\n }\n const old = this.ref;\n this.ref = new this.CanvasKit.PathBuilder(result);\n result.delete();\n old.delete();\n return this;\n }\n\n // ---- Query methods (use snapshot for read-only) ----\n\n countPoints() {\n return this.ref.countPoints();\n }\n\n computeTightBounds(): SkRect {\n const path = this.asPath();\n const result = new JsiSkRect(this.CanvasKit, path.computeTightBounds());\n path.delete();\n return result;\n }\n\n contains(x: number, y: number) {\n const path = this.asPath();\n const result = path.contains(x, y);\n path.delete();\n return result;\n }\n\n copy() {\n const path = this.asPath();\n const result = new JsiSkPath(\n this.CanvasKit,\n new this.CanvasKit.PathBuilder(path)\n );\n path.delete();\n return result;\n }\n\n equals(other: SkPath) {\n const p1 = this.asPath();\n const p2 = JsiSkPath.fromValue<CKPathBuilder>(other).snapshot();\n const result = p1.equals(p2);\n p1.delete();\n p2.delete();\n return result;\n }\n\n getBounds() {\n return new JsiSkRect(this.CanvasKit, this.ref.getBounds());\n }\n\n getFillType(): FillType {\n const path = this.asPath();\n const result = path.getFillType().value;\n path.delete();\n return result;\n }\n\n getPoint(index: number): SkPoint {\n const path = this.asPath();\n const result = new JsiSkPoint(this.CanvasKit, path.getPoint(index));\n path.delete();\n return result;\n }\n\n isEmpty() {\n return this.ref.isEmpty();\n }\n\n isVolatile() {\n return false;\n }\n\n getLastPt() {\n const count = this.ref.countPoints();\n if (count === 0) {\n return { x: 0, y: 0 };\n }\n const path = this.asPath();\n const pt = path.getPoint(count - 1);\n path.delete();\n return { x: pt[0], y: pt[1] };\n }\n\n toSVGString() {\n const path = this.asPath();\n const result = path.toSVGString();\n path.delete();\n return result;\n }\n\n isInterpolatable(path2: SkPath): boolean {\n const p1 = this.asPath();\n const p2 = JsiSkPath.fromValue<CKPathBuilder>(path2).snapshot();\n const result = this.CanvasKit.Path.CanInterpolate(p1, p2);\n p1.delete();\n p2.delete();\n return result;\n }\n\n interpolate(end: SkPath, weight: number, output?: SkPath): SkPath | null {\n const p1 = this.asPath();\n const p2 = JsiSkPath.fromValue<CKPathBuilder>(end).snapshot();\n const path = this.CanvasKit.Path.MakeFromPathInterpolation(p1, p2, weight);\n p1.delete();\n p2.delete();\n if (path === null) {\n return null;\n }\n if (output) {\n const outRef = output as JsiSkPath;\n const old = outRef.ref;\n outRef.ref = new this.CanvasKit.PathBuilder(path);\n path.delete();\n old.delete();\n return output;\n }\n const result = new JsiSkPath(\n this.CanvasKit,\n new this.CanvasKit.PathBuilder(path)\n );\n path.delete();\n return result;\n }\n\n toCmds() {\n const path = this.asPath();\n const cmds = path.toCmds();\n path.delete();\n const result = cmds.reduce<PathCommand[]>((acc, cmd, i) => {\n if (i === 0) {\n acc.push([]);\n }\n const current = acc[acc.length - 1];\n if (current.length === 0) {\n current.push(cmd);\n const length = CommandCount[current[0] as PathVerb];\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n } else {\n const length = CommandCount[current[0] as PathVerb];\n if (current.length < length) {\n current.push(cmd);\n }\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n }\n return acc;\n }, []);\n return result;\n }\n}\n"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,UAAU;AAcnC,SAASC,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AACrD,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,WAAW,QAAQ,eAAe;AAE3C,MAAMC,YAAY,GAAG;EACnB,CAACR,QAA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AMkE,MAAM,GAAG4D,IAAI,CAACC,MAAM,CAAgB,CAACC,GAAG,EAAEC,GAAG,EAAEC,CAAC,KAAK;MACzD,IAAIA,CAAC,KAAK,CAAC,EAAE;QACXF,GAAG,CAACG,IAAI,CAAC,EAAE,CAAC;MACd;MACA,MAAMC,OAAO,GAAGJ,GAAG,CAACA,GAAG,CAAChJ,MAAM,GAAG,CAAC,CAAC;MACnC,IAAIoJ,OAAO,CAACpJ,MAAM,KAAK,CAAC,EAAE;QACxBoJ,OAAO,CAACD,IAAI,CAACF,GAAG,CAAC;QACjB,MAAMjJ,MAAM,GAAGtB,YAAY,CAAC0K,OAAO,CAAC,CAAC,CAAC,CAAa;QACnD,IAAIA,OAAO,CAACpJ,MAAM,KAAKA,MAAM,IAAIkJ,CAAC,KAAKJ,IAAI,CAAC9I,MAAM,GAAG,CAAC,EAAE;UACtDgJ,GAAG,CAACG,IAAI,CAAC,EAAE,CAAC;QACd;MACF,CAAC,MAAM;QACL,MAAMnJ,MAAM,GAAGtB,YAAY,CAAC0K,OAAO,CAAC,CAAC,CAAC,CAAa;QACnD,IAAIA,OAAO,CAACpJ,MAAM,GAAGA,MAAM,EAAE;UAC3BoJ,OAAO,CAACD,IAAI,CAACF,GAAG,CAAC;QACnB;QACA,IAAIG,OAAO,CAACpJ,MAAM,KAAKA,MAAM,IAAIkJ,CAAC,KAAKJ,IAAI,CAAC9I,MAAM,GAAG,CAAC,EAAE;UACtDgJ,GAAG,CAACG,IAAI,CAAC,EAAE,CAAC;QACd;MACF;MACA,OAAOH,GAAG;IACZ,CAAC,EAAE,EAAE,CAAC;IACN,OAAO9D,MAAM;EACf;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["PathVerb","HostObject","JsiSkPoint","JsiSkRect","JsiSkMatrix","CommandCount","Move","Line","Quad","Conic","Cubic","Close","toMatrix3x3","m","matrix","Array","from","fromValue","length","Error","JsiSkPath","constructor","CanvasKit","ref","asPath","snapshot","pathFromValue","value","countPoints","computeTightBounds","path","result","delete","contains","x","y","copy","PathBuilder","equals","other","p1","p2","getBounds","getFillType","getPoint","index","isEmpty","isVolatile","getLastPt","count","pt","toSVGString","isInterpolatable","path2","Path","CanInterpolate","interpolate","end","weight","MakeFromPathInterpolation","toCmds","cmds","reduce","acc","cmd","i","push","current"],"sources":["JsiSkPath.ts"],"sourcesContent":["import type { CanvasKit, PathBuilder as CKPathBuilder } from \"canvaskit-wasm\";\n\nimport { PathVerb } from \"../types\";\nimport type {\n FillType,\n PathCommand,\n SkMatrix,\n SkPath,\n SkPoint,\n SkRect,\n InputMatrix,\n} from \"../types\";\n\nimport { HostObject } from \"./Host\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\n\nconst CommandCount = {\n [PathVerb.Move]: 3,\n [PathVerb.Line]: 3,\n [PathVerb.Quad]: 5,\n [PathVerb.Conic]: 6,\n [PathVerb.Cubic]: 7,\n [PathVerb.Close]: 1,\n};\n\nexport const toMatrix3x3 = (m: InputMatrix): number[] => {\n let matrix =\n m instanceof JsiSkMatrix\n ? Array.from(JsiSkMatrix.fromValue<Float32Array>(m))\n : (m as Exclude<InputMatrix, SkMatrix>);\n if (matrix.length === 16) {\n matrix = [\n matrix[0],\n matrix[1],\n matrix[3],\n matrix[4],\n matrix[5],\n matrix[7],\n matrix[12],\n matrix[13],\n matrix[15],\n ];\n } else if (matrix.length !== 9) {\n throw new Error(`Invalid matrix length: ${matrix.length}`);\n }\n return matrix as number[];\n};\n\n/**\n * SkPath wraps a CK PathBuilder internally, providing immutable query\n * methods. Use snapshot() internally to get\n * an immutable CK Path for read-only operations.\n */\nexport class JsiSkPath\n extends HostObject<CKPathBuilder, \"Path\">\n implements SkPath\n{\n constructor(CanvasKit: CanvasKit, ref: CKPathBuilder) {\n super(CanvasKit, ref, \"Path\");\n }\n\n /** Returns an immutable CK Path snapshot for read-only operations. */\n private asPath() {\n return this.ref.snapshot();\n }\n\n /** Extract an immutable CK Path from a JsiSkPath value (for CK interop). */\n static pathFromValue(value: SkPath) {\n return JsiSkPath.fromValue<CKPathBuilder>(value).snapshot();\n }\n\n // ---- Query methods (use snapshot for read-only) ----\n\n countPoints() {\n return this.ref.countPoints();\n }\n\n computeTightBounds(): SkRect {\n const path = this.asPath();\n const result = new JsiSkRect(this.CanvasKit, path.computeTightBounds());\n path.delete();\n return result;\n }\n\n contains(x: number, y: number) {\n const path = this.asPath();\n const result = path.contains(x, y);\n path.delete();\n return result;\n }\n\n copy() {\n const path = this.asPath();\n const result = new JsiSkPath(\n this.CanvasKit,\n new this.CanvasKit.PathBuilder(path)\n );\n path.delete();\n return result;\n }\n\n equals(other: SkPath) {\n const p1 = this.asPath();\n const p2 = JsiSkPath.fromValue<CKPathBuilder>(other).snapshot();\n const result = p1.equals(p2);\n p1.delete();\n p2.delete();\n return result;\n }\n\n getBounds() {\n return new JsiSkRect(this.CanvasKit, this.ref.getBounds());\n }\n\n getFillType(): FillType {\n const path = this.asPath();\n const result = path.getFillType().value;\n path.delete();\n return result;\n }\n\n getPoint(index: number): SkPoint {\n const path = this.asPath();\n const result = new JsiSkPoint(this.CanvasKit, path.getPoint(index));\n path.delete();\n return result;\n }\n\n isEmpty() {\n return this.ref.isEmpty();\n }\n\n isVolatile() {\n return false;\n }\n\n getLastPt() {\n const count = this.ref.countPoints();\n if (count === 0) {\n return { x: 0, y: 0 };\n }\n const path = this.asPath();\n const pt = path.getPoint(count - 1);\n path.delete();\n return { x: pt[0], y: pt[1] };\n }\n\n toSVGString() {\n const path = this.asPath();\n const result = path.toSVGString();\n path.delete();\n return result;\n }\n\n isInterpolatable(path2: SkPath): boolean {\n const p1 = this.asPath();\n const p2 = JsiSkPath.fromValue<CKPathBuilder>(path2).snapshot();\n const result = this.CanvasKit.Path.CanInterpolate(p1, p2);\n p1.delete();\n p2.delete();\n return result;\n }\n\n interpolate(end: SkPath, weight: number): SkPath | null {\n const p1 = this.asPath();\n const p2 = JsiSkPath.fromValue<CKPathBuilder>(end).snapshot();\n const path = this.CanvasKit.Path.MakeFromPathInterpolation(p1, p2, weight);\n p1.delete();\n p2.delete();\n if (path === null) {\n return null;\n }\n const result = new JsiSkPath(\n this.CanvasKit,\n new this.CanvasKit.PathBuilder(path)\n );\n path.delete();\n return result;\n }\n\n toCmds() {\n const path = this.asPath();\n const cmds = path.toCmds();\n path.delete();\n const result = cmds.reduce<PathCommand[]>((acc, cmd, i) => {\n if (i === 0) {\n acc.push([]);\n }\n const current = acc[acc.length - 1];\n if (current.length === 0) {\n current.push(cmd);\n const length = CommandCount[current[0] as PathVerb];\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n } else {\n const length = CommandCount[current[0] as PathVerb];\n if (current.length < length) {\n current.push(cmd);\n }\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n }\n return acc;\n }, []);\n return result;\n }\n}\n"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,UAAU;AAWnC,SAASC,UAAU,QAAQ,QAAQ;AACnC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,WAAW,QAAQ,eAAe;AAE3C,MAAMC,YAAY,GAAG;EACnB,CAACL,QAAQ,CAACM,IAAI,GAAG,CAAC;EAClB,CAACN,QAAQ,CAACO,IAAI,GAAG,CAAC;EAClB,CAACP,QAAQ,CAACQ,IAAI,GAAG,CAAC;EAClB,CAACR,QAAQ,CAACS,KAAK,GAAG,CAAC;EACnB,CAACT,QAAQ,CAACU,KAAK,GAAG,CAAC;EACnB,CAACV,QAAQ,CAACW,KAAK,GAAG;AACpB,CAAC;AAED,OAAO,MAAMC,WAAW,GAAIC,CAAc,IAAe;EACvD,IAAIC,MAAM,GACRD,CAAC,YAAYT,WAAW,GACpBW,KAAK,CAACC,IAAI,CAACZ,WAAW,CAACa,SAAS,CAAeJ,CAAC,CAAC,CAAC,GACjDA,CAAoC;EAC3C,IAAI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,IAAI,CAAC,EAAE,CAAC;MACd;MACA,MAAMC,OAAO,GAAGJ,GAAG,CAACA,GAAG,CAAC7C,MAAM,GAAG,CAAC,CAAC;MACnC,IAAIiD,OAAO,CAACjD,MAAM,KAAK,CAAC,EAAE;QACxBiD,OAAO,CAACD,IAAI,CAACF,GAAG,CAAC;QACjB,MAAM9C,MAAM,GAAGb,YAAY,CAAC8D,OAAO,CAAC,CAAC,CAAC,CAAa;QACnD,IAAIA,OAAO,CAACjD,MAAM,KAAKA,MAAM,IAAI+C,CAAC,KAAKJ,IAAI,CAAC3C,MAAM,GAAG,CAAC,EAAE;UACtD6C,GAAG,CAACG,IAAI,CAAC,EAAE,CAAC;QACd;MACF,CAAC,MAAM;QACL,MAAMhD,MAAM,GAAGb,YAAY,CAAC8D,OAAO,CAAC,CAAC,CAAC,CAAa;QACnD,IAAIA,OAAO,CAACjD,MAAM,GAAGA,MAAM,EAAE;UAC3BiD,OAAO,CAACD,IAAI,CAACF,GAAG,CAAC;QACnB;QACA,IAAIG,OAAO,CAACjD,MAAM,KAAKA,MAAM,IAAI+C,CAAC,KAAKJ,IAAI,CAAC3C,MAAM,GAAG,CAAC,EAAE;UACtD6C,GAAG,CAACG,IAAI,CAAC,EAAE,CAAC;QACd;MACF;MACA,OAAOH,GAAG;IACZ,CAAC,EAAE,EAAE,CAAC;IACN,OAAOhC,MAAM;EACf;AACF","ignoreList":[]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { CanvasKit } from "canvaskit-wasm";
|
|
2
|
-
import type { SurfaceFactory } from "../types";
|
|
2
|
+
import type { SkSurface, SurfaceFactory } from "../types";
|
|
3
3
|
import { Host } from "./Host";
|
|
4
4
|
import { JsiSkSurface } from "./JsiSkSurface";
|
|
5
5
|
export declare class JsiSkSurfaceFactory extends Host implements SurfaceFactory {
|
|
6
6
|
constructor(CanvasKit: CanvasKit);
|
|
7
7
|
Make(width: number, height: number): JsiSkSurface;
|
|
8
8
|
MakeOffscreen(width: number, height: number): JsiSkSurface | null;
|
|
9
|
+
MakeFromNativeTexture(_pointer: bigint): SkSurface;
|
|
9
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Host } from "./Host";
|
|
1
|
+
import { Host, throwNotImplementedOnRNWeb } from "./Host";
|
|
2
2
|
import { JsiSkSurface } from "./JsiSkSurface";
|
|
3
3
|
export class JsiSkSurfaceFactory extends Host {
|
|
4
4
|
constructor(CanvasKit) {
|
|
@@ -28,5 +28,8 @@ export class JsiSkSurfaceFactory extends Host {
|
|
|
28
28
|
}
|
|
29
29
|
return new JsiSkSurface(this.CanvasKit, surface);
|
|
30
30
|
}
|
|
31
|
+
MakeFromNativeTexture(_pointer) {
|
|
32
|
+
return throwNotImplementedOnRNWeb();
|
|
33
|
+
}
|
|
31
34
|
}
|
|
32
35
|
//# sourceMappingURL=JsiSkSurfaceFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Host","JsiSkSurface","JsiSkSurfaceFactory","constructor","CanvasKit","Make","width","height","MakeSurface","MakeOffscreen","OC","globalThis","OffscreenCanvas","surface","undefined","offscreen","webglContext","GetWebGLContext","grContext","MakeWebGLContext","Error","MakeRenderTarget"],"sources":["JsiSkSurfaceFactory.ts"],"sourcesContent":["import type { CanvasKit, Surface } from \"canvaskit-wasm\";\n\nimport type { SurfaceFactory } from \"../types\";\n\nimport { Host } from \"./Host\";\nimport { JsiSkSurface } from \"./JsiSkSurface\";\n\nexport class JsiSkSurfaceFactory extends Host implements SurfaceFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n Make(width: number, height: number) {\n return new JsiSkSurface(\n this.CanvasKit,\n this.CanvasKit.MakeSurface(width, height)!\n );\n }\n\n MakeOffscreen(width: number, height: number) {\n // OffscreenCanvas may be unvailable in some environments.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const OC = (globalThis as any).OffscreenCanvas;\n let surface: Surface | null;\n if (OC === undefined) {\n return this.Make(width, height);\n } else {\n const offscreen = new OC(width, height);\n const webglContext = this.CanvasKit.GetWebGLContext(offscreen);\n const grContext = this.CanvasKit.MakeWebGLContext(webglContext);\n if (!grContext) {\n throw new Error(\"Could not make a graphics context\");\n }\n surface = this.CanvasKit.MakeRenderTarget(grContext, width, height);\n }\n if (!surface) {\n return null;\n }\n return new JsiSkSurface(this.CanvasKit, surface);\n }\n}\n"],"mappings":"AAIA,SAASA,IAAI,QAAQ,QAAQ;
|
|
1
|
+
{"version":3,"names":["Host","throwNotImplementedOnRNWeb","JsiSkSurface","JsiSkSurfaceFactory","constructor","CanvasKit","Make","width","height","MakeSurface","MakeOffscreen","OC","globalThis","OffscreenCanvas","surface","undefined","offscreen","webglContext","GetWebGLContext","grContext","MakeWebGLContext","Error","MakeRenderTarget","MakeFromNativeTexture","_pointer"],"sources":["JsiSkSurfaceFactory.ts"],"sourcesContent":["import type { CanvasKit, Surface } from \"canvaskit-wasm\";\n\nimport type { SkSurface, SurfaceFactory } from \"../types\";\n\nimport { Host, throwNotImplementedOnRNWeb } from \"./Host\";\nimport { JsiSkSurface } from \"./JsiSkSurface\";\n\nexport class JsiSkSurfaceFactory extends Host implements SurfaceFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n Make(width: number, height: number) {\n return new JsiSkSurface(\n this.CanvasKit,\n this.CanvasKit.MakeSurface(width, height)!\n );\n }\n\n MakeOffscreen(width: number, height: number) {\n // OffscreenCanvas may be unvailable in some environments.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const OC = (globalThis as any).OffscreenCanvas;\n let surface: Surface | null;\n if (OC === undefined) {\n return this.Make(width, height);\n } else {\n const offscreen = new OC(width, height);\n const webglContext = this.CanvasKit.GetWebGLContext(offscreen);\n const grContext = this.CanvasKit.MakeWebGLContext(webglContext);\n if (!grContext) {\n throw new Error(\"Could not make a graphics context\");\n }\n surface = this.CanvasKit.MakeRenderTarget(grContext, width, height);\n }\n if (!surface) {\n return null;\n }\n return new JsiSkSurface(this.CanvasKit, surface);\n }\n\n MakeFromNativeTexture(_pointer: bigint): SkSurface {\n return throwNotImplementedOnRNWeb<SkSurface>();\n }\n}\n"],"mappings":"AAIA,SAASA,IAAI,EAAEC,0BAA0B,QAAQ,QAAQ;AACzD,SAASC,YAAY,QAAQ,gBAAgB;AAE7C,OAAO,MAAMC,mBAAmB,SAASH,IAAI,CAA2B;EACtEI,WAAWA,CAACC,SAAoB,EAAE;IAChC,KAAK,CAACA,SAAS,CAAC;EAClB;EAEAC,IAAIA,CAACC,KAAa,EAAEC,MAAc,EAAE;IAClC,OAAO,IAAIN,YAAY,CACrB,IAAI,CAACG,SAAS,EACd,IAAI,CAACA,SAAS,CAACI,WAAW,CAACF,KAAK,EAAEC,MAAM,CAC1C,CAAC;EACH;EAEAE,aAAaA,CAACH,KAAa,EAAEC,MAAc,EAAE;IAC3C;IACA;IACA,MAAMG,EAAE,GAAIC,UAAU,CAASC,eAAe;IAC9C,IAAIC,OAAuB;IAC3B,IAAIH,EAAE,KAAKI,SAAS,EAAE;MACpB,OAAO,IAAI,CAACT,IAAI,CAACC,KAAK,EAAEC,MAAM,CAAC;IACjC,CAAC,MAAM;MACL,MAAMQ,SAAS,GAAG,IAAIL,EAAE,CAACJ,KAAK,EAAEC,MAAM,CAAC;MACvC,MAAMS,YAAY,GAAG,IAAI,CAACZ,SAAS,CAACa,eAAe,CAACF,SAAS,CAAC;MAC9D,MAAMG,SAAS,GAAG,IAAI,CAACd,SAAS,CAACe,gBAAgB,CAACH,YAAY,CAAC;MAC/D,IAAI,CAACE,SAAS,EAAE;QACd,MAAM,IAAIE,KAAK,CAAC,mCAAmC,CAAC;MACtD;MACAP,OAAO,GAAG,IAAI,CAACT,SAAS,CAACiB,gBAAgB,CAACH,SAAS,EAAEZ,KAAK,EAAEC,MAAM,CAAC;IACrE;IACA,IAAI,CAACM,OAAO,EAAE;MACZ,OAAO,IAAI;IACb;IACA,OAAO,IAAIZ,YAAY,CAAC,IAAI,CAACG,SAAS,EAAES,OAAO,CAAC;EAClD;EAEAS,qBAAqBA,CAACC,QAAgB,EAAa;IACjD,OAAOvB,0BAA0B,CAAY,CAAC;EAChD;AACF","ignoreList":[]}
|
|
@@ -2,11 +2,25 @@ import type { Skia } from "../skia/types";
|
|
|
2
2
|
import { Container, StaticContainer } from "./StaticContainer";
|
|
3
3
|
import "../skia/NativeSetup";
|
|
4
4
|
import "../views/api";
|
|
5
|
+
/**
|
|
6
|
+
* Records the scene graph on the JS thread and hands the native recorder to
|
|
7
|
+
* the view, which owns it and replays it on every draw. The Reanimated mapper
|
|
8
|
+
* only pushes the shared values into that recorder through the view id: no
|
|
9
|
+
* Skia object is captured by a worklet, so nothing on the UI runtime holds
|
|
10
|
+
* native memory. The JS wrapper is disposed right after the handoff, so the
|
|
11
|
+
* view is the sole owner and the resources referenced by the recording
|
|
12
|
+
* (images, pictures) are released when the view replaces it or is torn down,
|
|
13
|
+
* not when a garbage collector gets around to a wrapper.
|
|
14
|
+
*
|
|
15
|
+
* Unmounting does not clear the view: the native view can outlive the React
|
|
16
|
+
* tree (exit animations, screen transitions) and keeps showing its last frame
|
|
17
|
+
* until it is torn down, which is when the recording is released.
|
|
18
|
+
*/
|
|
5
19
|
declare class NativeReanimatedContainer extends Container {
|
|
6
20
|
private nativeId;
|
|
7
21
|
private mapperId;
|
|
8
|
-
private picture;
|
|
9
22
|
constructor(Skia: Skia, nativeId: number);
|
|
23
|
+
private stopMapper;
|
|
10
24
|
unmount(): void;
|
|
11
25
|
redraw(): void;
|
|
12
26
|
}
|
|
@@ -13,62 +13,63 @@ import "../views/api";
|
|
|
13
13
|
const {
|
|
14
14
|
SkiaViewApi
|
|
15
15
|
} = globalThis;
|
|
16
|
-
const nativeDrawOnscreen = (nativeId, recorder, picture) => {
|
|
17
|
-
"worklet";
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Records the scene graph on the JS thread and hands the native recorder to
|
|
19
|
+
* the view, which owns it and replays it on every draw. The Reanimated mapper
|
|
20
|
+
* only pushes the shared values into that recorder through the view id: no
|
|
21
|
+
* Skia object is captured by a worklet, so nothing on the UI runtime holds
|
|
22
|
+
* native memory. The JS wrapper is disposed right after the handoff, so the
|
|
23
|
+
* view is the sole owner and the resources referenced by the recording
|
|
24
|
+
* (images, pictures) are released when the view replaces it or is torn down,
|
|
25
|
+
* not when a garbage collector gets around to a wrapper.
|
|
26
|
+
*
|
|
27
|
+
* Unmounting does not clear the view: the native view can outlive the React
|
|
28
|
+
* tree (exit animations, screen transitions) and keeps showing its last frame
|
|
29
|
+
* until it is torn down, which is when the recording is released.
|
|
30
|
+
*/
|
|
25
31
|
class NativeReanimatedContainer extends Container {
|
|
26
32
|
constructor(Skia, nativeId) {
|
|
27
33
|
super(Skia);
|
|
28
34
|
this.nativeId = nativeId;
|
|
29
35
|
_defineProperty(this, "mapperId", null);
|
|
30
|
-
_defineProperty(this, "picture", void 0);
|
|
31
|
-
this.picture = Skia.Picture.MakePicture(null);
|
|
32
36
|
}
|
|
33
|
-
|
|
34
|
-
super.unmount();
|
|
37
|
+
stopMapper() {
|
|
35
38
|
if (this.mapperId !== null) {
|
|
36
|
-
// The mapper closure retains the recorder and its resources (e.g.
|
|
37
|
-
// images) on the UI runtime and keeps updating the picture of an
|
|
38
|
-
// unmounted view — stop it or it leaks for the lifetime of the app.
|
|
39
39
|
Rea.stopMapper(this.mapperId);
|
|
40
40
|
this.mapperId = null;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
unmount() {
|
|
44
|
+
super.unmount();
|
|
45
|
+
this.stopMapper();
|
|
46
|
+
}
|
|
43
47
|
redraw() {
|
|
44
|
-
|
|
45
|
-
Rea.stopMapper(this.mapperId);
|
|
46
|
-
this.mapperId = null;
|
|
47
|
-
}
|
|
48
|
+
this.stopMapper();
|
|
48
49
|
if (this.unmounted) {
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
52
|
const recorder = new ReanimatedRecorder(this.Skia);
|
|
52
|
-
const {
|
|
53
|
-
nativeId,
|
|
54
|
-
picture
|
|
55
|
-
} = this;
|
|
56
53
|
visit(recorder, this.root);
|
|
57
54
|
const sharedValues = recorder.getSharedValues();
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
const {
|
|
56
|
+
nativeId
|
|
57
|
+
} = this;
|
|
58
|
+
const nativeRecorder = recorder.getRecorder();
|
|
59
|
+
// stopMapper() only takes effect on the UI thread later, so the previous
|
|
60
|
+
// mapper can still fire after the new recording is installed. Tagging the
|
|
61
|
+
// updates with the recording id lets the view ignore them.
|
|
62
|
+
const recorderId = nativeRecorder.getId();
|
|
63
|
+
// The view takes ownership of the recorder and draws the first frame. The
|
|
64
|
+
// wrapper is disposed right away: it would otherwise co-own the recording
|
|
65
|
+
// until the JS garbage collector finalizes it.
|
|
66
|
+
SkiaViewApi.setJsiProperty(nativeId, "recorder", nativeRecorder);
|
|
67
|
+
nativeRecorder.dispose();
|
|
66
68
|
if (sharedValues.length > 0) {
|
|
67
69
|
this.mapperId = Rea.startMapper(() => {
|
|
68
70
|
"worklet";
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
nativeDrawOnscreen(nativeId, sharedRecorder, picture);
|
|
72
|
+
SkiaViewApi.applyUpdates(nativeId, recorderId, sharedValues);
|
|
72
73
|
}, sharedValues);
|
|
73
74
|
}
|
|
74
75
|
}
|