@shopify/react-native-skia 2.7.0 → 2.8.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/cpp/api/JsiSkParagraph.h +114 -0
- package/lib/commonjs/external/reanimated/useVideoLoading.js +11 -2
- package/lib/commonjs/external/reanimated/useVideoLoading.js.map +1 -1
- package/lib/commonjs/skia/core/SVG.web.js +4 -5
- package/lib/commonjs/skia/core/SVG.web.js.map +1 -1
- package/lib/commonjs/skia/types/Paragraph/Paragraph.d.ts +62 -0
- package/lib/commonjs/skia/types/Paragraph/Paragraph.js.map +1 -1
- package/lib/commonjs/skia/web/Host.js +7 -0
- package/lib/commonjs/skia/web/Host.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPaint.js +5 -0
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkParagraph.d.ts +3 -1
- package/lib/commonjs/skia/web/JsiSkParagraph.js +6 -0
- package/lib/commonjs/skia/web/JsiSkParagraph.js.map +1 -1
- package/lib/commonjs/sksg/Container.web.js +34 -3
- package/lib/commonjs/sksg/Container.web.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/commonjs/sksg/Recorder/DrawingContext.js +22 -6
- package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/FrameScope.d.ts +18 -0
- package/lib/commonjs/sksg/Recorder/FrameScope.js +66 -0
- package/lib/commonjs/sksg/Recorder/FrameScope.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/FrameScope.native.d.ts +10 -0
- package/lib/commonjs/sksg/Recorder/FrameScope.native.js +26 -0
- package/lib/commonjs/sksg/Recorder/FrameScope.native.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/Player.js +1 -2
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.d.ts +3 -1
- package/lib/commonjs/sksg/Recorder/Recorder.js +12 -1
- package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js +3 -3
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js +3 -3
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/commonjs/sksg/StaticContainer.d.ts +1 -0
- package/lib/commonjs/sksg/StaticContainer.js +27 -1
- package/lib/commonjs/sksg/StaticContainer.js.map +1 -1
- package/lib/module/external/reanimated/useVideoLoading.js +12 -2
- package/lib/module/external/reanimated/useVideoLoading.js.map +1 -1
- package/lib/module/skia/core/SVG.web.js +4 -5
- package/lib/module/skia/core/SVG.web.js.map +1 -1
- package/lib/module/skia/types/Paragraph/Paragraph.d.ts +62 -0
- package/lib/module/skia/types/Paragraph/Paragraph.js.map +1 -1
- package/lib/module/skia/web/Host.js +7 -0
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.js +5 -0
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraph.d.ts +3 -1
- package/lib/module/skia/web/JsiSkParagraph.js +7 -1
- package/lib/module/skia/web/JsiSkParagraph.js.map +1 -1
- package/lib/module/sksg/Container.web.js +35 -4
- package/lib/module/sksg/Container.web.js.map +1 -1
- package/lib/module/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/module/sksg/Recorder/DrawingContext.js +22 -6
- package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -1
- package/lib/module/sksg/Recorder/FrameScope.d.ts +18 -0
- package/lib/module/sksg/Recorder/FrameScope.js +59 -0
- package/lib/module/sksg/Recorder/FrameScope.js.map +1 -0
- package/lib/module/sksg/Recorder/FrameScope.native.d.ts +10 -0
- package/lib/module/sksg/Recorder/FrameScope.native.js +19 -0
- package/lib/module/sksg/Recorder/FrameScope.native.js.map +1 -0
- package/lib/module/sksg/Recorder/Player.js +1 -2
- package/lib/module/sksg/Recorder/Player.js.map +1 -1
- package/lib/module/sksg/Recorder/Recorder.d.ts +3 -1
- package/lib/module/sksg/Recorder/Recorder.js +10 -0
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js +3 -3
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Shaders.js +3 -3
- package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/module/sksg/StaticContainer.d.ts +1 -0
- package/lib/module/sksg/StaticContainer.js +28 -2
- package/lib/module/sksg/StaticContainer.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkParagraph.d.ts +2 -0
- package/lib/typescript/lib/commonjs/sksg/Container.web.d.ts +2 -2
- package/lib/typescript/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/FrameScope.d.ts +17 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/FrameScope.native.d.ts +13 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/StaticContainer.d.ts +2 -2
- package/lib/typescript/lib/module/skia/web/JsiSkParagraph.d.ts +2 -0
- package/lib/typescript/lib/module/sksg/Container.web.d.ts +2 -2
- package/lib/typescript/lib/module/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/typescript/lib/module/sksg/Recorder/FrameScope.d.ts +5 -0
- package/lib/typescript/lib/module/sksg/Recorder/FrameScope.native.d.ts +5 -0
- package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/StaticContainer.d.ts +2 -2
- package/lib/typescript/src/skia/types/Paragraph/Paragraph.d.ts +62 -0
- package/lib/typescript/src/skia/web/JsiSkParagraph.d.ts +3 -1
- package/lib/typescript/src/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/typescript/src/sksg/Recorder/FrameScope.d.ts +18 -0
- package/lib/typescript/src/sksg/Recorder/FrameScope.native.d.ts +10 -0
- package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +3 -1
- package/lib/typescript/src/sksg/StaticContainer.d.ts +1 -0
- package/package.json +1 -1
- package/src/external/reanimated/useVideoLoading.ts +12 -2
- package/src/skia/core/SVG.web.ts +5 -14
- package/src/skia/types/Paragraph/Paragraph.ts +67 -0
- package/src/skia/web/Host.ts +7 -0
- package/src/skia/web/JsiSkPaint.ts +5 -0
- package/src/skia/web/JsiSkParagraph.ts +9 -1
- package/src/sksg/Container.web.ts +31 -4
- package/src/sksg/Recorder/DrawingContext.ts +19 -6
- package/src/sksg/Recorder/FrameScope.native.ts +21 -0
- package/src/sksg/Recorder/FrameScope.ts +69 -0
- package/src/sksg/Recorder/Player.ts +1 -2
- package/src/sksg/Recorder/Recorder.ts +15 -1
- package/src/sksg/Recorder/commands/Drawing.ts +3 -3
- package/src/sksg/Recorder/commands/Shaders.ts +22 -16
- package/src/sksg/StaticContainer.ts +29 -2
|
@@ -131,14 +131,14 @@ export const drawTextPath = (ctx: DrawingContext, props: TextPathProps) => {
|
|
|
131
131
|
const widths = font.getGlyphWidths(ids);
|
|
132
132
|
const rsx: SkRSXform[] = [];
|
|
133
133
|
const meas = ctx.Skia.ContourMeasureIter(path, false, 1);
|
|
134
|
-
let cont = meas.next();
|
|
134
|
+
let cont = ctx.track(meas.next());
|
|
135
135
|
let dist = initialOffset;
|
|
136
136
|
for (let i = 0; i < text.length && cont; i++) {
|
|
137
137
|
const width = widths[i];
|
|
138
138
|
dist += width / 2;
|
|
139
139
|
if (dist > cont.length()) {
|
|
140
140
|
// jump to next contour
|
|
141
|
-
cont = meas.next();
|
|
141
|
+
cont = ctx.track(meas.next());
|
|
142
142
|
if (!cont) {
|
|
143
143
|
// We have come to the end of the path - terminate the string
|
|
144
144
|
// right here.
|
|
@@ -221,7 +221,7 @@ export const drawPath = (ctx: DrawingContext, props: PathProps) => {
|
|
|
221
221
|
if (hasFillType) {
|
|
222
222
|
const builder = ctx.Skia.PathBuilder.MakeFromPath(path);
|
|
223
223
|
builder.setFillType(FillType[enumKey(fillType)]);
|
|
224
|
-
path = builder.build();
|
|
224
|
+
path = ctx.track(builder.build());
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
// Apply stroke using static Path.Stroke
|
|
@@ -43,10 +43,12 @@ const declareShader = (
|
|
|
43
43
|
const { source, uniforms, ...transform } = props;
|
|
44
44
|
const m3 = ctx.Skia.Matrix();
|
|
45
45
|
processTransformProps(m3, transform);
|
|
46
|
-
const shader =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
const shader = ctx.track(
|
|
47
|
+
source.makeShaderWithChildren(
|
|
48
|
+
processUniforms(source, uniforms),
|
|
49
|
+
ctx.shaders.splice(0, children),
|
|
50
|
+
m3
|
|
51
|
+
)
|
|
50
52
|
);
|
|
51
53
|
ctx.shaders.push(shader);
|
|
52
54
|
};
|
|
@@ -208,20 +210,24 @@ const declareImageShader = (ctx: DrawingContext, props: ImageShaderProps) => {
|
|
|
208
210
|
processTransformProps(lm, imageShaderProps);
|
|
209
211
|
let shader: SkShader;
|
|
210
212
|
if (sampling && isCubicSampling(sampling)) {
|
|
211
|
-
shader =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
shader = ctx.track(
|
|
214
|
+
image.makeShaderCubic(
|
|
215
|
+
TileMode[enumKey(tx)],
|
|
216
|
+
TileMode[enumKey(ty)],
|
|
217
|
+
sampling.B,
|
|
218
|
+
sampling.C,
|
|
219
|
+
lm
|
|
220
|
+
)
|
|
217
221
|
);
|
|
218
222
|
} else {
|
|
219
|
-
shader =
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
shader = ctx.track(
|
|
224
|
+
image.makeShaderCubic(
|
|
225
|
+
TileMode[enumKey(tx)],
|
|
226
|
+
TileMode[enumKey(ty)],
|
|
227
|
+
sampling?.filter ?? FilterMode.Linear,
|
|
228
|
+
sampling?.mipmap ?? MipmapMode.None,
|
|
229
|
+
lm
|
|
230
|
+
)
|
|
225
231
|
);
|
|
226
232
|
}
|
|
227
233
|
ctx.shaders.push(shader);
|
|
@@ -2,7 +2,7 @@ import type { Skia, SkCanvas } from "../skia/types";
|
|
|
2
2
|
|
|
3
3
|
import type { Node } from "./Node";
|
|
4
4
|
import type { Recording } from "./Recorder/Recorder";
|
|
5
|
-
import { Recorder } from "./Recorder/Recorder";
|
|
5
|
+
import { Recorder, disposeRecording } from "./Recorder/Recorder";
|
|
6
6
|
import { visit } from "./Recorder/Visitor";
|
|
7
7
|
import { replay } from "./Recorder/Player";
|
|
8
8
|
import { createDrawingContext } from "./Recorder/DrawingContext";
|
|
@@ -41,7 +41,14 @@ export abstract class Container {
|
|
|
41
41
|
this.recording.paintPool,
|
|
42
42
|
canvas
|
|
43
43
|
);
|
|
44
|
-
|
|
44
|
+
try {
|
|
45
|
+
replay(ctx, this.recording.commands);
|
|
46
|
+
} finally {
|
|
47
|
+
// Frame-scoped objects created during the replay are no longer needed
|
|
48
|
+
// once drawn — delete them, otherwise they leak on Web where the GC
|
|
49
|
+
// cannot see WASM memory.
|
|
50
|
+
ctx.dispose();
|
|
51
|
+
}
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
abstract redraw(): void;
|
|
@@ -55,7 +62,24 @@ export class StaticContainer extends Container {
|
|
|
55
62
|
super(Skia);
|
|
56
63
|
}
|
|
57
64
|
|
|
65
|
+
unmount() {
|
|
66
|
+
super.unmount();
|
|
67
|
+
if (this.recording) {
|
|
68
|
+
disposeRecording(this.recording);
|
|
69
|
+
this.recording = null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
58
73
|
redraw() {
|
|
74
|
+
if (this.unmounted) {
|
|
75
|
+
// The unmount commit triggers a last redraw — recording it would
|
|
76
|
+
// resurrect a recording for a container that has just disposed it.
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (this.recording) {
|
|
80
|
+
disposeRecording(this.recording);
|
|
81
|
+
this.recording = null;
|
|
82
|
+
}
|
|
59
83
|
const recorder = new Recorder();
|
|
60
84
|
visit(recorder, this.root);
|
|
61
85
|
this.recording = recorder.getRecording();
|
|
@@ -67,6 +91,9 @@ export class StaticContainer extends Container {
|
|
|
67
91
|
const picture = rec.finishRecordingAsPicture();
|
|
68
92
|
rec.dispose();
|
|
69
93
|
SkiaViewApi.setJsiProperty(this.nativeId, "picture", picture);
|
|
94
|
+
// The view keeps its own reference to the picture it displays; this
|
|
95
|
+
// one is renderer-owned and disposed with the recording.
|
|
96
|
+
this.recording.lastPicture = picture;
|
|
70
97
|
}
|
|
71
98
|
}
|
|
72
99
|
}
|