@shopify/react-native-skia 2.7.0 → 2.9.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/build.gradle +10 -4
- package/android/cpp/rnskia-android/OpenGLContext.h +29 -3
- package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +9 -2
- package/android/cpp/rnskia-android/gl/Context.h +3 -0
- package/android/cpp/rnskia-android/gl/Surface.h +1 -1
- package/cpp/api/JsiSkParagraph.h +114 -0
- package/cpp/api/JsiSkiaContext.h +4 -0
- package/cpp/rnskia/RNSkView.h +6 -0
- package/lib/commonjs/Platform/Platform.js +5 -2
- package/lib/commonjs/Platform/Platform.js.map +1 -1
- package/lib/commonjs/Platform/Platform.web.js +8 -7
- package/lib/commonjs/Platform/Platform.web.js.map +1 -1
- package/lib/commonjs/external/reanimated/useVideoLoading.js +11 -2
- package/lib/commonjs/external/reanimated/useVideoLoading.js.map +1 -1
- package/lib/commonjs/skia/core/Font.d.ts +21 -6
- package/lib/commonjs/skia/core/Font.js +24 -4
- package/lib/commonjs/skia/core/Font.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/Data/Data.d.ts +5 -4
- package/lib/commonjs/skia/types/Data/Data.js +7 -1
- package/lib/commonjs/skia/types/Data/Data.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/JsiSkFont.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.js +43 -2
- package/lib/commonjs/skia/web/JsiSkFont.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/Platform/Platform.js +6 -3
- package/lib/module/Platform/Platform.js.map +1 -1
- package/lib/module/Platform/Platform.web.js +9 -8
- package/lib/module/Platform/Platform.web.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/Font.d.ts +21 -6
- package/lib/module/skia/core/Font.js +26 -5
- package/lib/module/skia/core/Font.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/Data/Data.d.ts +5 -4
- package/lib/module/skia/types/Data/Data.js +5 -0
- package/lib/module/skia/types/Data/Data.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/JsiSkFont.d.ts +1 -1
- package/lib/module/skia/web/JsiSkFont.js +44 -3
- package/lib/module/skia/web/JsiSkFont.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/types/Data/Data.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkFont.d.ts +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/mock/index.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Data/Data.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkFont.d.ts +1 -1
- 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/core/Font.d.ts +21 -6
- package/lib/typescript/src/skia/types/Data/Data.d.ts +5 -4
- package/lib/typescript/src/skia/types/Paragraph/Paragraph.d.ts +62 -0
- package/lib/typescript/src/skia/web/JsiSkFont.d.ts +1 -1
- 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 +8 -2
- package/react-native-skia.podspec +18 -10
- package/src/Platform/Platform.ts +6 -7
- package/src/Platform/Platform.web.tsx +9 -8
- package/src/external/reanimated/useVideoLoading.ts +12 -2
- package/src/skia/core/Font.ts +34 -13
- package/src/skia/core/SVG.web.ts +5 -14
- package/src/skia/types/Data/Data.ts +14 -4
- package/src/skia/types/Paragraph/Paragraph.ts +67 -0
- package/src/skia/web/Host.ts +7 -0
- package/src/skia/web/JsiSkFont.ts +48 -4
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","Container","StaticContainer","SkiaViewApi","globalThis","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","
|
|
1
|
+
{"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","disposeRecording","visit","replay","createDrawingContext","Container","StaticContainer","SkiaViewApi","globalThis","drawOnscreen","Skia","nativeId","recording","_recording$lastPictur","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","picture","commands","finishRecordingAsPicture","dispose","setJsiProperty","lastPicture","ReanimatedContainer","constructor","_defineProperty","unmount","mapperId","stopMapper","runOnUI","redraw","unmounted","previousRecording","recorder","root","record","getRecording","animationValues","size","startMapper","Array","from","createContainer"],"sources":["Container.web.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\n\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder, disposeRecording } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\n// create local reference for `strictGlobal` option in Worklets\nconst { SkiaViewApi } = globalThis;\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n const ctx = createDrawingContext(Skia, recording.paintPool, canvas);\n let picture;\n try {\n replay(ctx, recording.commands);\n picture = rec.finishRecordingAsPicture();\n } finally {\n // Frame-scoped objects (shaders, filters, paint copies, ...) are\n // referenced by the picture once it is finished — delete the JS handles,\n // otherwise they leak on Web where the GC cannot see WASM memory.\n ctx.dispose();\n rec.dispose();\n }\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n // The view now references the new picture; the previous one is ours to\n // delete.\n recording.lastPicture?.dispose();\n recording.lastPicture = picture;\n};\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(\n Skia: Skia,\n private nativeId: number\n ) {\n super(Skia);\n }\n\n unmount() {\n super.unmount();\n if (this.mapperId !== null) {\n // The mapper closure retains the recording and keeps updating the\n // picture of an unmounted view — stop it or it leaks for the\n // lifetime of the app.\n Rea.stopMapper(this.mapperId);\n this.mapperId = null;\n }\n const { recording } = this;\n if (recording) {\n this.recording = null;\n // Deferred through the same channel as the draw calls so it runs after\n // any of them that are still queued.\n Rea.runOnUI(() => {\n \"worklet\";\n disposeRecording(recording);\n })();\n }\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n this.mapperId = null;\n }\n if (this.unmounted) {\n return;\n }\n const previousRecording = this.recording;\n const recorder = new Recorder();\n visit(recorder, this.root);\n const record = recorder.getRecording();\n const { animationValues } = record;\n this.recording = {\n commands: record.commands,\n paintPool: record.paintPool,\n };\n const { nativeId, Skia, recording } = this;\n if (animationValues.size > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n }, Array.from(animationValues));\n }\n Rea.runOnUI(() => {\n \"worklet\";\n if (previousRecording) {\n // Runs after any still-queued draw of the previous recording.\n disposeRecording(previousRecording);\n }\n drawOnscreen(Skia, nativeId, recording!);\n })();\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new ReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAAA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAGvE,SAASC,QAAQ,EAAEC,gBAAgB,QAAQ,qBAAqB;AAChE,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,oBAAoB,QAAQ,2B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AAQ,EAAEC,SAAU,CAAC;MAC1C,CAAC,EAAE+B,KAAK,CAACC,IAAI,CAACJ,eAAe,CAAC,CAAC;IACjC;IACA1C,GAAG,CAACkC,OAAO,CAAC,MAAM;MAChB,SAAS;;MACT,IAAIG,iBAAiB,EAAE;QACrB;QACAlC,gBAAgB,CAACkC,iBAAiB,CAAC;MACrC;MACA1B,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAU,CAAC;IAC1C,CAAC,CAAC,CAAC,CAAC;EACN;AACF;AAEA,OAAO,MAAMiC,eAAe,GAAGA,CAACnC,IAAU,EAAEC,QAAgB,KAAK;EAC/D,IAAIZ,gBAAgB,IAAIY,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,OAAO,IAAIe,mBAAmB,CAAChB,IAAI,EAAEC,QAAQ,CAAC;EAChD,CAAC,MAAM;IACL,OAAO,IAAIL,eAAe,CAACI,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
|
|
@@ -2,6 +2,8 @@ import type { Skia, SkCanvas, SkColorFilter, SkPaint, SkShader, SkImageFilter, S
|
|
|
2
2
|
export declare const createDrawingContext: (Skia: Skia, paintPool: SkPaint[], canvas: SkCanvas) => {
|
|
3
3
|
Skia: Skia;
|
|
4
4
|
canvas: SkCanvas;
|
|
5
|
+
track: <T>(value: T) => T;
|
|
6
|
+
dispose: () => void;
|
|
5
7
|
paints: SkPaint[];
|
|
6
8
|
colorFilters: SkColorFilter[];
|
|
7
9
|
shaders: SkShader[];
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
import { createFrameScope } from "./FrameScope";
|
|
1
2
|
export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
2
3
|
"worklet";
|
|
3
4
|
|
|
5
|
+
// Everything the renderer creates through frameSkia is frame-scoped and
|
|
6
|
+
// deleted by dispose() once the frame has been recorded. The paint pool is
|
|
7
|
+
// recording-scoped and deliberately allocated with the raw Skia instance.
|
|
8
|
+
const {
|
|
9
|
+
Skia: frameSkia,
|
|
10
|
+
track,
|
|
11
|
+
dispose
|
|
12
|
+
} = createFrameScope(Skia);
|
|
13
|
+
|
|
4
14
|
// State (formerly class fields)
|
|
5
15
|
const paints = [];
|
|
6
16
|
const colorFilters = [];
|
|
@@ -12,7 +22,11 @@ export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
12
22
|
let nextPaintIndex = 1;
|
|
13
23
|
|
|
14
24
|
// Initialize first paint and opacity
|
|
15
|
-
paintPool
|
|
25
|
+
if (paintPool.length === 0) {
|
|
26
|
+
paintPool.push(Skia.Paint());
|
|
27
|
+
} else {
|
|
28
|
+
paintPool[0].reset();
|
|
29
|
+
}
|
|
16
30
|
paints.push(paintPool[0]);
|
|
17
31
|
opacities.push(1);
|
|
18
32
|
|
|
@@ -42,7 +56,7 @@ export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
42
56
|
} else {
|
|
43
57
|
const cf = colorFilters.pop();
|
|
44
58
|
if (cf) {
|
|
45
|
-
imageFilter =
|
|
59
|
+
imageFilter = frameSkia.ImageFilter.MakeColorFilter(cf, null);
|
|
46
60
|
}
|
|
47
61
|
}
|
|
48
62
|
canvas.saveLayer(undefined, null, imageFilter);
|
|
@@ -60,7 +74,7 @@ export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
60
74
|
const materializePaint = () => {
|
|
61
75
|
// Color Filters
|
|
62
76
|
if (colorFilters.length > 0) {
|
|
63
|
-
getCurrentPaint().setColorFilter(colorFilters.reduceRight((inner, outer) => inner ?
|
|
77
|
+
getCurrentPaint().setColorFilter(colorFilters.reduceRight((inner, outer) => inner ? frameSkia.ColorFilter.MakeCompose(outer, inner) : outer));
|
|
64
78
|
}
|
|
65
79
|
// Shaders
|
|
66
80
|
if (shaders.length > 0) {
|
|
@@ -68,12 +82,12 @@ export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
68
82
|
}
|
|
69
83
|
// Image Filters
|
|
70
84
|
if (imageFilters.length > 0) {
|
|
71
|
-
getCurrentPaint().setImageFilter(imageFilters.reduceRight((inner, outer) => inner ?
|
|
85
|
+
getCurrentPaint().setImageFilter(imageFilters.reduceRight((inner, outer) => inner ? frameSkia.ImageFilter.MakeCompose(outer, inner) : outer));
|
|
72
86
|
}
|
|
73
87
|
|
|
74
88
|
// Path Effects
|
|
75
89
|
if (pathEffects.length > 0) {
|
|
76
|
-
getCurrentPaint().setPathEffect(pathEffects.reduceRight((inner, outer) => inner ?
|
|
90
|
+
getCurrentPaint().setPathEffect(pathEffects.reduceRight((inner, outer) => inner ? frameSkia.PathEffect.MakeCompose(outer, inner) : outer));
|
|
77
91
|
}
|
|
78
92
|
|
|
79
93
|
// Clear arrays
|
|
@@ -86,8 +100,10 @@ export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
86
100
|
// Return an object containing the Skia reference, the canvas, and the methods
|
|
87
101
|
return {
|
|
88
102
|
// Public fields
|
|
89
|
-
Skia,
|
|
103
|
+
Skia: frameSkia,
|
|
90
104
|
canvas,
|
|
105
|
+
track,
|
|
106
|
+
dispose,
|
|
91
107
|
paints,
|
|
92
108
|
colorFilters,
|
|
93
109
|
shaders,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createDrawingContext","Skia","paintPool","canvas","paints","colorFilters","shaders","imageFilters","pathEffects","paintDeclarations","opacities","nextPaintIndex","
|
|
1
|
+
{"version":3,"names":["createFrameScope","createDrawingContext","Skia","paintPool","canvas","frameSkia","track","dispose","paints","colorFilters","shaders","imageFilters","pathEffects","paintDeclarations","opacities","nextPaintIndex","length","push","Paint","reset","savePaint","nextPaint","assign","getCurrentPaint","getOpacity","setOpacity","newOpacity","Math","max","min","saveBackdropFilter","imageFilter","imgf","pop","cf","ImageFilter","MakeColorFilter","saveLayer","undefined","restore","restorePaint","materializePaint","setColorFilter","reduceRight","inner","outer","ColorFilter","MakeCompose","setShader","setImageFilter","setPathEffect","PathEffect","paint"],"sources":["DrawingContext.ts"],"sourcesContent":["import type {\n Skia,\n SkCanvas,\n SkColorFilter,\n SkPaint,\n SkShader,\n SkImageFilter,\n SkPathEffect,\n} from \"../../skia/types\";\n\nimport { createFrameScope } from \"./FrameScope\";\n\nexport const createDrawingContext = (\n Skia: Skia,\n paintPool: SkPaint[],\n canvas: SkCanvas\n) => {\n \"worklet\";\n\n // Everything the renderer creates through frameSkia is frame-scoped and\n // deleted by dispose() once the frame has been recorded. The paint pool is\n // recording-scoped and deliberately allocated with the raw Skia instance.\n const { Skia: frameSkia, track, dispose } = createFrameScope(Skia);\n\n // State (formerly class fields)\n const paints: SkPaint[] = [];\n const colorFilters: SkColorFilter[] = [];\n const shaders: SkShader[] = [];\n const imageFilters: SkImageFilter[] = [];\n const pathEffects: SkPathEffect[] = [];\n const paintDeclarations: SkPaint[] = [];\n const opacities: number[] = [];\n\n let nextPaintIndex = 1;\n\n // Initialize first paint and opacity\n if (paintPool.length === 0) {\n paintPool.push(Skia.Paint());\n } else {\n paintPool[0].reset();\n }\n paints.push(paintPool[0]);\n opacities.push(1);\n\n // Methods (formerly class methods)\n const savePaint = () => {\n // Get next available paint from pool or create new one if needed\n if (nextPaintIndex >= paintPool.length) {\n paintPool.push(Skia.Paint());\n }\n\n const nextPaint = paintPool[nextPaintIndex];\n nextPaint.assign(getCurrentPaint()); // Reuse allocation by copying properties\n paints.push(nextPaint);\n opacities.push(opacities[opacities.length - 1]);\n nextPaintIndex++;\n };\n\n const getOpacity = () => {\n return opacities[opacities.length - 1];\n };\n\n const setOpacity = (newOpacity: number) => {\n opacities[opacities.length - 1] = Math.max(0, Math.min(1, newOpacity));\n };\n\n const saveBackdropFilter = () => {\n let imageFilter: SkImageFilter | null = null;\n const imgf = imageFilters.pop();\n if (imgf) {\n imageFilter = imgf;\n } else {\n const cf = colorFilters.pop();\n if (cf) {\n imageFilter = frameSkia.ImageFilter.MakeColorFilter(cf, null);\n }\n }\n canvas.saveLayer(undefined, null, imageFilter);\n canvas.restore();\n };\n\n // Equivalent to the `get paint()` getter in the original class\n const getCurrentPaint = () => {\n return paints[paints.length - 1];\n };\n\n const restorePaint = () => {\n opacities.pop();\n return paints.pop();\n };\n\n const materializePaint = () => {\n // Color Filters\n if (colorFilters.length > 0) {\n getCurrentPaint().setColorFilter(\n colorFilters.reduceRight((inner, outer) =>\n inner ? frameSkia.ColorFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n // Shaders\n if (shaders.length > 0) {\n getCurrentPaint().setShader(shaders[shaders.length - 1]);\n }\n // Image Filters\n if (imageFilters.length > 0) {\n getCurrentPaint().setImageFilter(\n imageFilters.reduceRight((inner, outer) =>\n inner ? frameSkia.ImageFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Path Effects\n if (pathEffects.length > 0) {\n getCurrentPaint().setPathEffect(\n pathEffects.reduceRight((inner, outer) =>\n inner ? frameSkia.PathEffect.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Clear arrays\n colorFilters.length = 0;\n shaders.length = 0;\n imageFilters.length = 0;\n pathEffects.length = 0;\n };\n\n // Return an object containing the Skia reference, the canvas, and the methods\n return {\n // Public fields\n Skia: frameSkia,\n canvas,\n track,\n dispose,\n paints,\n colorFilters,\n shaders,\n imageFilters,\n pathEffects,\n paintDeclarations,\n paintPool,\n\n // Public methods\n savePaint,\n saveBackdropFilter,\n get paint() {\n return paints[paints.length - 1];\n }, // the \"getter\" for the current paint\n restorePaint,\n materializePaint,\n getOpacity,\n setOpacity,\n };\n};\n\nexport type DrawingContext = ReturnType<typeof createDrawingContext>;\n"],"mappings":"AAUA,SAASA,gBAAgB,QAAQ,cAAc;AAE/C,OAAO,MAAMC,oBAAoB,GAAGA,CAClCC,IAAU,EACVC,SAAoB,EACpBC,MAAgB,KACb;EACH,SAAS;;EAET;EACA;EACA;EACA,MAAM;IAAEF,IAAI,EAAEG,SAAS;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGP,gBAAgB,CAACE,IAAI,CAAC;;EAElE;EACA,MAAMM,MAAiB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|
|
|
1
|
+
import type { Skia } from "../../skia/types";
|
|
2
|
+
export interface FrameScope {
|
|
3
|
+
Skia: Skia;
|
|
4
|
+
track: <T>(value: T) => T;
|
|
5
|
+
dispose: () => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a Skia instance so that every object created through its factories is
|
|
9
|
+
* collected and deleted when the scope is disposed. The renderer only keeps
|
|
10
|
+
* the objects it creates alive for the duration of a frame: once the frame
|
|
11
|
+
* has been recorded they can be deleted. This is required on Web where
|
|
12
|
+
* CanvasKit objects live in WASM memory that the JS garbage collector does
|
|
13
|
+
* not perceive, so it (almost) never reclaims them on its own.
|
|
14
|
+
*
|
|
15
|
+
* Objects passed in via props are user-owned: they are not created through
|
|
16
|
+
* this facade and are therefore never tracked nor disposed.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createFrameScope: (Skia: Skia) => FrameScope;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const isDisposable = value => {
|
|
2
|
+
"worklet";
|
|
3
|
+
|
|
4
|
+
return value !== null && typeof value === "object" && typeof value.dispose === "function";
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Wraps a Skia instance so that every object created through its factories is
|
|
8
|
+
* collected and deleted when the scope is disposed. The renderer only keeps
|
|
9
|
+
* the objects it creates alive for the duration of a frame: once the frame
|
|
10
|
+
* has been recorded they can be deleted. This is required on Web where
|
|
11
|
+
* CanvasKit objects live in WASM memory that the JS garbage collector does
|
|
12
|
+
* not perceive, so it (almost) never reclaims them on its own.
|
|
13
|
+
*
|
|
14
|
+
* Objects passed in via props are user-owned: they are not created through
|
|
15
|
+
* this facade and are therefore never tracked nor disposed.
|
|
16
|
+
*/
|
|
17
|
+
export const createFrameScope = Skia => {
|
|
18
|
+
"worklet";
|
|
19
|
+
|
|
20
|
+
const disposables = [];
|
|
21
|
+
const track = value => {
|
|
22
|
+
if (isDisposable(value)) {
|
|
23
|
+
disposables.push(value);
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
};
|
|
27
|
+
const wrap = obj => {
|
|
28
|
+
const cache = new Map();
|
|
29
|
+
return new Proxy(obj, {
|
|
30
|
+
get(target, prop) {
|
|
31
|
+
if (cache.has(prop)) {
|
|
32
|
+
return cache.get(prop);
|
|
33
|
+
}
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
+
const value = target[prop];
|
|
36
|
+
let wrapped = value;
|
|
37
|
+
if (typeof value === "function") {
|
|
38
|
+
wrapped = (...args) => track(value.apply(target, args));
|
|
39
|
+
} else if (value !== null && typeof value === "object") {
|
|
40
|
+
wrapped = wrap(value);
|
|
41
|
+
}
|
|
42
|
+
cache.set(prop, wrapped);
|
|
43
|
+
return wrapped;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const dispose = () => {
|
|
48
|
+
for (let i = 0; i < disposables.length; i++) {
|
|
49
|
+
disposables[i].dispose();
|
|
50
|
+
}
|
|
51
|
+
disposables.length = 0;
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
Skia: wrap(Skia),
|
|
55
|
+
track,
|
|
56
|
+
dispose
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=FrameScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isDisposable","value","dispose","createFrameScope","Skia","disposables","track","push","wrap","obj","cache","Map","Proxy","get","target","prop","has","wrapped","args","apply","set","i","length"],"sources":["FrameScope.ts"],"sourcesContent":["import type { Skia } from \"../../skia/types\";\n\ninterface Disposable {\n dispose: () => void;\n}\n\nconst isDisposable = (value: unknown): value is Disposable => {\n \"worklet\";\n return (\n value !== null &&\n typeof value === \"object\" &&\n typeof (value as Disposable).dispose === \"function\"\n );\n};\n\nexport interface FrameScope {\n Skia: Skia;\n track: <T>(value: T) => T;\n dispose: () => void;\n}\n\n/**\n * Wraps a Skia instance so that every object created through its factories is\n * collected and deleted when the scope is disposed. The renderer only keeps\n * the objects it creates alive for the duration of a frame: once the frame\n * has been recorded they can be deleted. This is required on Web where\n * CanvasKit objects live in WASM memory that the JS garbage collector does\n * not perceive, so it (almost) never reclaims them on its own.\n *\n * Objects passed in via props are user-owned: they are not created through\n * this facade and are therefore never tracked nor disposed.\n */\nexport const createFrameScope = (Skia: Skia): FrameScope => {\n \"worklet\";\n const disposables: Disposable[] = [];\n const track = <T>(value: T): T => {\n if (isDisposable(value)) {\n disposables.push(value);\n }\n return value;\n };\n const wrap = <T extends object>(obj: T): T => {\n const cache = new Map<PropertyKey, unknown>();\n return new Proxy(obj, {\n get(target, prop) {\n if (cache.has(prop)) {\n return cache.get(prop);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const value = (target as any)[prop];\n let wrapped: unknown = value;\n if (typeof value === \"function\") {\n wrapped = (...args: unknown[]) => track(value.apply(target, args));\n } else if (value !== null && typeof value === \"object\") {\n wrapped = wrap(value);\n }\n cache.set(prop, wrapped);\n return wrapped;\n },\n }) as T;\n };\n const dispose = () => {\n for (let i = 0; i < disposables.length; i++) {\n disposables[i].dispose();\n }\n disposables.length = 0;\n };\n return { Skia: wrap(Skia), track, dispose };\n};\n"],"mappings":"AAMA,MAAMA,YAAY,GAAIC,KAAc,IAA0B;EAC5D,SAAS;;EACT,OACEA,KAAK,KAAK,IAAI,IACd,OAAOA,KAAK,KAAK,QAAQ,IACzB,OAAQA,KAAK,CAAgBC,OAAO,KAAK,UAAU;AAEvD,CAAC;AAQD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAIC,IAAU,IAAiB;EAC1D,SAAS;;EACT,MAAMC,WAAyB,GAAG,EAAE;EACpC,MAAMC,KAAK,GAAOL,KAAQ,IAAQ;IAChC,IAAID,YAAY,CAACC,KAAK,CAAC,EAAE;MACvBI,WAAW,CAACE,IAAI,CAACN,KAAK,CAAC;IACzB;IACA,OAAOA,KAAK;E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|
|
2
|
+
import type { FrameScope } from "./FrameScope";
|
|
3
|
+
/**
|
|
4
|
+
* No-op on native. The JSI wrappers report the size of the native objects
|
|
5
|
+
* they hold to the garbage collector (setExternalMemoryPressure), so the GC
|
|
6
|
+
* is aware of the real cost of the objects the renderer creates and reclaims
|
|
7
|
+
* them on its own. The tracking scope is only needed on Web, where CanvasKit
|
|
8
|
+
* objects live in WASM memory the GC cannot see (see FrameScope.ts).
|
|
9
|
+
*/
|
|
10
|
+
export declare const createFrameScope: (Skia: Skia) => FrameScope;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* No-op on native. The JSI wrappers report the size of the native objects
|
|
3
|
+
* they hold to the garbage collector (setExternalMemoryPressure), so the GC
|
|
4
|
+
* is aware of the real cost of the objects the renderer creates and reclaims
|
|
5
|
+
* them on its own. The tracking scope is only needed on Web, where CanvasKit
|
|
6
|
+
* objects live in WASM memory the GC cannot see (see FrameScope.ts).
|
|
7
|
+
*/
|
|
8
|
+
export const createFrameScope = Skia => {
|
|
9
|
+
"worklet";
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
Skia,
|
|
13
|
+
track: value => value,
|
|
14
|
+
dispose: () => {
|
|
15
|
+
// nothing to dispose: no objects are tracked on native
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=FrameScope.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFrameScope","Skia","track","value","dispose"],"sources":["FrameScope.native.ts"],"sourcesContent":["import type { Skia } from \"../../skia/types\";\n\nimport type { FrameScope } from \"./FrameScope\";\n\n/**\n * No-op on native. The JSI wrappers report the size of the native objects\n * they hold to the garbage collector (setExternalMemoryPressure), so the GC\n * is aware of the real cost of the objects the renderer creates and reclaims\n * them on its own. The tracking scope is only needed on Web, where CanvasKit\n * objects live in WASM memory the GC cannot see (see FrameScope.ts).\n */\nexport const createFrameScope = (Skia: Skia): FrameScope => {\n \"worklet\";\n return {\n Skia,\n track: <T>(value: T): T => value,\n dispose: () => {\n // nothing to dispose: no objects are tracked on native\n },\n };\n};\n"],"mappings":"AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,GAAIC,IAAU,IAAiB;EAC1D,SAAS;;EACT,OAAO;IACLA,IAAI;IACJC,KAAK,EAAMC,KAAQ,IAAQA,KAAK;IAChCC,OAAO,EAAEA,CAAA,KAAM;MACb;IAAA;EAEJ,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -110,9 +110,8 @@ const play = (ctx, _command) => {
|
|
|
110
110
|
} else if (isCommand(command, CommandType.RestoreCTM)) {
|
|
111
111
|
ctx.canvas.restore();
|
|
112
112
|
} else {
|
|
113
|
-
// TODO: is a copy needed here?
|
|
114
113
|
// apply opacity to the current paint.
|
|
115
|
-
const paint = ctx.paint.copy();
|
|
114
|
+
const paint = ctx.track(ctx.paint.copy());
|
|
116
115
|
paint.setAlphaf(paint.getAlphaf() * ctx.getOpacity());
|
|
117
116
|
const paints = [paint, ...ctx.paintDeclarations];
|
|
118
117
|
ctx.paintDeclarations = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["drawCircle","drawImage","drawOval","drawPath","drawPoints","drawRect","drawRRect","drawLine","drawAtlas","drawParagraph","drawImageSVG","drawPicture","drawGlyphs","drawTextBlob","drawTextPath","drawText","drawDiffRect","drawVertices","drawPatch","drawSkottie","drawBox","isBoxCommand","composeColorFilters","isPushColorFilter","pushColorFilter","saveCTM","setBlurMaskFilter","isPushImageFilter","pushImageFilter","composeImageFilters","setPaintProperties","composePathEffects","isPushPathEffect","pushPathEffect","isPushShader","pushShader","CommandType","isCommand","isDrawCommand","isGroup","materializeCommand","getZIndex","command","_materialized$props","materialized","zIndex","props","Number","isNaN","flushPendingGroups","ctx","pendingGroups","playFn","length","sort","a","b","order","forEach","playGroup","group","pending","children","child","push","play","_command","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","SavePaint","paints","standalone","savePaint","freshPaint","Skia","Paint","assign","RestorePaint","restorePaint","ComposeColorFilter","RestorePaintDeclaration","Error","MaterializePaint","ComposePathEffect","ComposeImageFilter","PushBlurMaskFilter","SaveCTM","RestoreCTM","restore","copy","setAlphaf","getAlphaf","getOpacity","p","DrawPaint","drawPaint","DrawImage","DrawCircle","DrawPoints","DrawPath","DrawRect","DrawRRect","DrawOval","DrawLine","DrawPatch","DrawVertices","DrawDiffRect","DrawText","DrawTextPath","DrawTextBlob","DrawGlyphs","DrawPicture","DrawImageSVG","DrawParagraph","DrawAtlas","DrawSkottie","console","warn","type","replay","commands"],"sources":["Player.ts"],"sourcesContent":["import type { DrawingNodeProps } from \"../../dom/types\";\n\nimport {\n drawCircle,\n drawImage,\n drawOval,\n drawPath,\n drawPoints,\n drawRect,\n drawRRect,\n drawLine,\n drawAtlas,\n drawParagraph,\n drawImageSVG,\n drawPicture,\n drawGlyphs,\n drawTextBlob,\n drawTextPath,\n drawText,\n drawDiffRect,\n drawVertices,\n drawPatch,\n drawSkottie,\n} from \"./commands/Drawing\";\nimport { drawBox, isBoxCommand } from \"./commands/Box\";\nimport {\n composeColorFilters,\n isPushColorFilter,\n pushColorFilter,\n} from \"./commands/ColorFilters\";\nimport { saveCTM } from \"./commands/CTM\";\nimport {\n setBlurMaskFilter,\n isPushImageFilter,\n pushImageFilter,\n composeImageFilters,\n} from \"./commands/ImageFilters\";\nimport { setPaintProperties } from \"./commands/Paint\";\nimport {\n composePathEffects,\n isPushPathEffect,\n pushPathEffect,\n} from \"./commands/PathEffects\";\nimport { isPushShader, pushShader } from \"./commands/Shaders\";\nimport {\n CommandType,\n isCommand,\n isDrawCommand,\n isGroup,\n materializeCommand,\n} from \"./Core\";\nimport type { Command, GroupCommand } from \"./Core\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\ntype PendingGroup = {\n command: GroupCommand;\n zIndex: number;\n order: number;\n};\n\nconst getZIndex = (command: GroupCommand) => {\n \"worklet\";\n const materialized = materializeCommand(command);\n const { zIndex } = (materialized.props ?? {}) as DrawingNodeProps;\n if (typeof zIndex !== \"number\" || Number.isNaN(zIndex)) {\n return 0;\n }\n return zIndex;\n};\n\nconst flushPendingGroups = (\n ctx: DrawingContext,\n pendingGroups: PendingGroup[],\n playFn: (ctx: DrawingContext, cmd: Command) => void\n) => {\n \"worklet\";\n if (pendingGroups.length === 0) {\n return;\n }\n pendingGroups\n .sort((a, b) =>\n a.zIndex === b.zIndex ? a.order - b.order : a.zIndex - b.zIndex\n )\n .forEach(({ command }) => {\n playFn(ctx, command);\n });\n pendingGroups.length = 0;\n};\n\nconst playGroup = (\n ctx: DrawingContext,\n group: GroupCommand,\n playFn: (ctx: DrawingContext, cmd: Command) => void\n) => {\n \"worklet\";\n const pending: PendingGroup[] = [];\n group.children.forEach((child) => {\n if (isGroup(child)) {\n pending.push({\n command: child,\n zIndex: getZIndex(child),\n order: pending.length,\n });\n return;\n }\n flushPendingGroups(ctx, pending, playFn);\n playFn(ctx, child);\n });\n flushPendingGroups(ctx, pending, playFn);\n};\n\nconst play = (ctx: DrawingContext, _command: Command) => {\n if (isGroup(_command)) {\n playGroup(ctx, _command, play);\n return;\n }\n const command = materializeCommand(_command);\n if (isCommand(command, CommandType.SaveBackdropFilter)) {\n ctx.saveBackdropFilter();\n } else if (isCommand(command, CommandType.SaveLayer)) {\n ctx.materializePaint();\n const paint = ctx.paintDeclarations.pop();\n ctx.canvas.saveLayer(paint);\n } else if (isDrawCommand(command, CommandType.SavePaint)) {\n if (command.props.paint) {\n ctx.paints.push(command.props.paint);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { standalone } = command as any;\n ctx.savePaint();\n if (standalone) {\n const freshPaint = ctx.Skia.Paint();\n ctx.paint.assign(freshPaint);\n }\n setPaintProperties(ctx.Skia, ctx, command.props, standalone);\n }\n } else if (isCommand(command, CommandType.RestorePaint)) {\n ctx.restorePaint();\n } else if (isCommand(command, CommandType.ComposeColorFilter)) {\n composeColorFilters(ctx);\n } else if (isCommand(command, CommandType.RestorePaintDeclaration)) {\n ctx.materializePaint();\n const paint = ctx.restorePaint();\n if (!paint) {\n throw new Error(\"No paint declaration to push\");\n }\n ctx.paintDeclarations.push(paint);\n } else if (isCommand(command, CommandType.MaterializePaint)) {\n ctx.materializePaint();\n } else if (isPushColorFilter(command)) {\n pushColorFilter(ctx, command);\n } else if (isPushShader(command)) {\n pushShader(ctx, command);\n } else if (isPushImageFilter(command)) {\n pushImageFilter(ctx, command);\n } else if (isPushPathEffect(command)) {\n pushPathEffect(ctx, command);\n } else if (isCommand(command, CommandType.ComposePathEffect)) {\n composePathEffects(ctx);\n } else if (isCommand(command, CommandType.ComposeImageFilter)) {\n composeImageFilters(ctx);\n } else if (isDrawCommand(command, CommandType.PushBlurMaskFilter)) {\n setBlurMaskFilter(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.SaveCTM)) {\n saveCTM(ctx, command.props);\n } else if (isCommand(command, CommandType.RestoreCTM)) {\n ctx.canvas.restore();\n } else {\n // TODO: is a copy needed here?\n // apply opacity to the current paint.\n const paint = ctx.paint.copy();\n paint.setAlphaf(paint.getAlphaf() * ctx.getOpacity());\n const paints = [paint, ...ctx.paintDeclarations];\n ctx.paintDeclarations = [];\n paints.forEach((p) => {\n ctx.paints.push(p);\n if (isBoxCommand(command)) {\n drawBox(ctx, command);\n } else if (isCommand(command, CommandType.DrawPaint)) {\n ctx.canvas.drawPaint(ctx.paint);\n } else if (isDrawCommand(command, CommandType.DrawImage)) {\n drawImage(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawCircle)) {\n drawCircle(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPoints)) {\n drawPoints(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPath)) {\n drawPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRect)) {\n drawRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRRect)) {\n drawRRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawOval)) {\n drawOval(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawLine)) {\n drawLine(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPatch)) {\n drawPatch(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawVertices)) {\n drawVertices(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawDiffRect)) {\n drawDiffRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawText)) {\n drawText(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextPath)) {\n drawTextPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextBlob)) {\n drawTextBlob(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawGlyphs)) {\n drawGlyphs(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPicture)) {\n drawPicture(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawImageSVG)) {\n drawImageSVG(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawParagraph)) {\n drawParagraph(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawAtlas)) {\n drawAtlas(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawSkottie)) {\n drawSkottie(ctx, command.props);\n } else {\n console.warn(`Unknown command: ${command.type}`);\n }\n ctx.paints.pop();\n });\n }\n};\nexport function replay(ctx: DrawingContext, commands: Command[]) {\n \"worklet\";\n //console.log(debugTree(commands));\n commands.forEach((command) => {\n play(ctx, command);\n });\n}\n"],"mappings":"AAEA,SACEA,UAAU,EACVC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,aAAa,EACbC,YAAY,EACZC,WAAW,EACXC,UAAU,EACVC,YAAY,EACZC,YAAY,EACZC,QAAQ,EACRC,YAAY,E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G,CAAC2B,MAAM,CAACJ,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC;EACJ;AACF,CAAC;AACD,OAAO,SAASqD,MAAMA,CAAC5E,GAAmB,EAAE6E,QAAmB,EAAE;EAC/D,SAAS;;EACT;EACAA,QAAQ,CAACrE,OAAO,CAAEhB,OAAO,IAAK;IAC5BuB,IAAI,CAACf,GAAG,EAAER,OAAO,CAAC;EACpB,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["drawCircle","drawImage","drawOval","drawPath","drawPoints","drawRect","drawRRect","drawLine","drawAtlas","drawParagraph","drawImageSVG","drawPicture","drawGlyphs","drawTextBlob","drawTextPath","drawText","drawDiffRect","drawVertices","drawPatch","drawSkottie","drawBox","isBoxCommand","composeColorFilters","isPushColorFilter","pushColorFilter","saveCTM","setBlurMaskFilter","isPushImageFilter","pushImageFilter","composeImageFilters","setPaintProperties","composePathEffects","isPushPathEffect","pushPathEffect","isPushShader","pushShader","CommandType","isCommand","isDrawCommand","isGroup","materializeCommand","getZIndex","command","_materialized$props","materialized","zIndex","props","Number","isNaN","flushPendingGroups","ctx","pendingGroups","playFn","length","sort","a","b","order","forEach","playGroup","group","pending","children","child","push","play","_command","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","SavePaint","paints","standalone","savePaint","freshPaint","Skia","Paint","assign","RestorePaint","restorePaint","ComposeColorFilter","RestorePaintDeclaration","Error","MaterializePaint","ComposePathEffect","ComposeImageFilter","PushBlurMaskFilter","SaveCTM","RestoreCTM","restore","track","copy","setAlphaf","getAlphaf","getOpacity","p","DrawPaint","drawPaint","DrawImage","DrawCircle","DrawPoints","DrawPath","DrawRect","DrawRRect","DrawOval","DrawLine","DrawPatch","DrawVertices","DrawDiffRect","DrawText","DrawTextPath","DrawTextBlob","DrawGlyphs","DrawPicture","DrawImageSVG","DrawParagraph","DrawAtlas","DrawSkottie","console","warn","type","replay","commands"],"sources":["Player.ts"],"sourcesContent":["import type { DrawingNodeProps } from \"../../dom/types\";\n\nimport {\n drawCircle,\n drawImage,\n drawOval,\n drawPath,\n drawPoints,\n drawRect,\n drawRRect,\n drawLine,\n drawAtlas,\n drawParagraph,\n drawImageSVG,\n drawPicture,\n drawGlyphs,\n drawTextBlob,\n drawTextPath,\n drawText,\n drawDiffRect,\n drawVertices,\n drawPatch,\n drawSkottie,\n} from \"./commands/Drawing\";\nimport { drawBox, isBoxCommand } from \"./commands/Box\";\nimport {\n composeColorFilters,\n isPushColorFilter,\n pushColorFilter,\n} from \"./commands/ColorFilters\";\nimport { saveCTM } from \"./commands/CTM\";\nimport {\n setBlurMaskFilter,\n isPushImageFilter,\n pushImageFilter,\n composeImageFilters,\n} from \"./commands/ImageFilters\";\nimport { setPaintProperties } from \"./commands/Paint\";\nimport {\n composePathEffects,\n isPushPathEffect,\n pushPathEffect,\n} from \"./commands/PathEffects\";\nimport { isPushShader, pushShader } from \"./commands/Shaders\";\nimport {\n CommandType,\n isCommand,\n isDrawCommand,\n isGroup,\n materializeCommand,\n} from \"./Core\";\nimport type { Command, GroupCommand } from \"./Core\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\ntype PendingGroup = {\n command: GroupCommand;\n zIndex: number;\n order: number;\n};\n\nconst getZIndex = (command: GroupCommand) => {\n \"worklet\";\n const materialized = materializeCommand(command);\n const { zIndex } = (materialized.props ?? {}) as DrawingNodeProps;\n if (typeof zIndex !== \"number\" || Number.isNaN(zIndex)) {\n return 0;\n }\n return zIndex;\n};\n\nconst flushPendingGroups = (\n ctx: DrawingContext,\n pendingGroups: PendingGroup[],\n playFn: (ctx: DrawingContext, cmd: Command) => void\n) => {\n \"worklet\";\n if (pendingGroups.length === 0) {\n return;\n }\n pendingGroups\n .sort((a, b) =>\n a.zIndex === b.zIndex ? a.order - b.order : a.zIndex - b.zIndex\n )\n .forEach(({ command }) => {\n playFn(ctx, command);\n });\n pendingGroups.length = 0;\n};\n\nconst playGroup = (\n ctx: DrawingContext,\n group: GroupCommand,\n playFn: (ctx: DrawingContext, cmd: Command) => void\n) => {\n \"worklet\";\n const pending: PendingGroup[] = [];\n group.children.forEach((child) => {\n if (isGroup(child)) {\n pending.push({\n command: child,\n zIndex: getZIndex(child),\n order: pending.length,\n });\n return;\n }\n flushPendingGroups(ctx, pending, playFn);\n playFn(ctx, child);\n });\n flushPendingGroups(ctx, pending, playFn);\n};\n\nconst play = (ctx: DrawingContext, _command: Command) => {\n if (isGroup(_command)) {\n playGroup(ctx, _command, play);\n return;\n }\n const command = materializeCommand(_command);\n if (isCommand(command, CommandType.SaveBackdropFilter)) {\n ctx.saveBackdropFilter();\n } else if (isCommand(command, CommandType.SaveLayer)) {\n ctx.materializePaint();\n const paint = ctx.paintDeclarations.pop();\n ctx.canvas.saveLayer(paint);\n } else if (isDrawCommand(command, CommandType.SavePaint)) {\n if (command.props.paint) {\n ctx.paints.push(command.props.paint);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { standalone } = command as any;\n ctx.savePaint();\n if (standalone) {\n const freshPaint = ctx.Skia.Paint();\n ctx.paint.assign(freshPaint);\n }\n setPaintProperties(ctx.Skia, ctx, command.props, standalone);\n }\n } else if (isCommand(command, CommandType.RestorePaint)) {\n ctx.restorePaint();\n } else if (isCommand(command, CommandType.ComposeColorFilter)) {\n composeColorFilters(ctx);\n } else if (isCommand(command, CommandType.RestorePaintDeclaration)) {\n ctx.materializePaint();\n const paint = ctx.restorePaint();\n if (!paint) {\n throw new Error(\"No paint declaration to push\");\n }\n ctx.paintDeclarations.push(paint);\n } else if (isCommand(command, CommandType.MaterializePaint)) {\n ctx.materializePaint();\n } else if (isPushColorFilter(command)) {\n pushColorFilter(ctx, command);\n } else if (isPushShader(command)) {\n pushShader(ctx, command);\n } else if (isPushImageFilter(command)) {\n pushImageFilter(ctx, command);\n } else if (isPushPathEffect(command)) {\n pushPathEffect(ctx, command);\n } else if (isCommand(command, CommandType.ComposePathEffect)) {\n composePathEffects(ctx);\n } else if (isCommand(command, CommandType.ComposeImageFilter)) {\n composeImageFilters(ctx);\n } else if (isDrawCommand(command, CommandType.PushBlurMaskFilter)) {\n setBlurMaskFilter(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.SaveCTM)) {\n saveCTM(ctx, command.props);\n } else if (isCommand(command, CommandType.RestoreCTM)) {\n ctx.canvas.restore();\n } else {\n // apply opacity to the current paint.\n const paint = ctx.track(ctx.paint.copy());\n paint.setAlphaf(paint.getAlphaf() * ctx.getOpacity());\n const paints = [paint, ...ctx.paintDeclarations];\n ctx.paintDeclarations = [];\n paints.forEach((p) => {\n ctx.paints.push(p);\n if (isBoxCommand(command)) {\n drawBox(ctx, command);\n } else if (isCommand(command, CommandType.DrawPaint)) {\n ctx.canvas.drawPaint(ctx.paint);\n } else if (isDrawCommand(command, CommandType.DrawImage)) {\n drawImage(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawCircle)) {\n drawCircle(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPoints)) {\n drawPoints(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPath)) {\n drawPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRect)) {\n drawRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRRect)) {\n drawRRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawOval)) {\n drawOval(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawLine)) {\n drawLine(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPatch)) {\n drawPatch(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawVertices)) {\n drawVertices(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawDiffRect)) {\n drawDiffRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawText)) {\n drawText(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextPath)) {\n drawTextPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextBlob)) {\n drawTextBlob(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawGlyphs)) {\n drawGlyphs(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPicture)) {\n drawPicture(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawImageSVG)) {\n drawImageSVG(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawParagraph)) {\n drawParagraph(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawAtlas)) {\n drawAtlas(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawSkottie)) {\n drawSkottie(ctx, command.props);\n } else {\n console.warn(`Unknown command: ${command.type}`);\n }\n ctx.paints.pop();\n });\n }\n};\nexport function replay(ctx: DrawingContext, commands: Command[]) {\n \"worklet\";\n //console.log(debugTree(commands));\n commands.forEach((command) => {\n play(ctx, command);\n });\n}\n"],"mappings":"AAEA,SACEA,UAAU,EACVC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,aAAa,EACbC,YAAY,EACZC,WAAW,EACXC,UAAU,EACVC,YAAY,EACZC,YAAY,EACZC,QAAQ,EACRC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,WAAW,QACN,oBAAoB;AAC3B,SAASC,OAAO,EAAEC,YAAY,QAAQ,gBAAgB;AACtD,SACEC,mBAAmB,EACnBC,iBAAiB,EACjBC,eAAe,QACV,yBAAyB;AAChC,SAASC,OAAO,QAAQ,gBAAgB;AACxC,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,eAAe,EACfC,mBAAmB,QACd,yBAAyB;AAChC,SAASC,kBAAkB,QAAQ,kBAAkB;AACrD,SACEC,kBAAkB,EAClBC,gBAAgB,EAChBC,cAAc,QACT,wBAAwB;AAC/B,SAASC,YAAY,EAAEC,UAAU,QAAQ,oBAAoB;AAC7D,SACEC,WAAW,EACXC,SAAS,EACTC,aAAa,EAC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AM,IAAIR,aAAa,CAACI,OAAO,EAAEN,WAAW,CAACmF,WAAW,CAAC,EAAE;QAC1D5G,WAAW,CAACuC,GAAG,EAAER,OAAO,CAACI,KAAK,CAAC;MACjC,CAAC,MAAM,IAAIR,aAAa,CAACI,OAAO,EAAEN,WAAW,CAACoF,YAAY,CAAC,EAAE;QAC3D9G,YAAY,CAACwC,GAAG,EAAER,OAAO,CAACI,KAAK,CAAC;MAClC,CAAC,MAAM,IAAIR,aAAa,CAACI,OAAO,EAAEN,WAAW,CAACqF,aAAa,CAAC,EAAE;QAC5DhH,aAAa,CAACyC,GAAG,EAAER,OAAO,CAACI,KAAK,CAAC;MACnC,CAAC,MAAM,IAAIR,aAAa,CAACI,OAAO,EAAEN,WAAW,CAACsF,SAAS,CAAC,EAAE;QACxDlH,SAAS,CAAC0C,GAAG,EAAER,OAAO,CAACI,KAAK,CAAC;MAC/B,CAAC,MAAM,IAAIR,aAAa,CAACI,OAAO,EAAEN,WAAW,CAACuF,WAAW,CAAC,EAAE;QAC1DxG,WAAW,CAAC+B,GAAG,EAAER,OAAO,CAACI,KAAK,CAAC;MACjC,CAAC,MAAM;QACL8E,OAAO,CAACC,IAAI,CAAC,oBAAoBnF,OAAO,CAACoF,IAAI,EAAE,CAAC;MAClD;MACA5E,GAAG,CAAC2B,MAAM,CAACJ,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC;EACJ;AACF,CAAC;AACD,OAAO,SAASsD,MAAMA,CAAC7E,GAAmB,EAAE8E,QAAmB,EAAE;EAC/D,SAAS;;EACT;EACAA,QAAQ,CAACtE,OAAO,CAAEhB,OAAO,IAAK;IAC5BuB,IAAI,CAACf,GAAG,EAAER,OAAO,CAAC;EACpB,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -2,12 +2,14 @@ import type { SharedValue } from "react-native-reanimated";
|
|
|
2
2
|
import { NodeType } from "../../dom/types";
|
|
3
3
|
import type { BlurMaskFilterProps, CircleProps, CTMProps, ImageProps, PaintProps, PointsProps, PathProps, RectProps, RoundedRectProps, OvalProps, LineProps, PatchProps, VerticesProps, DiffRectProps, TextProps, TextPathProps, TextBlobProps, GlyphsProps, PictureProps, ImageSVGProps, ParagraphProps, AtlasProps, BoxProps, BoxShadowProps, SkottieProps, DrawingNodeProps } from "../../dom/types";
|
|
4
4
|
import type { AnimatedProps } from "../../renderer";
|
|
5
|
-
import type { SkPaint, BaseRecorder } from "../../skia/types";
|
|
5
|
+
import type { SkPaint, SkPicture, BaseRecorder } from "../../skia/types";
|
|
6
6
|
import type { Command } from "./Core";
|
|
7
7
|
export interface Recording {
|
|
8
8
|
commands: Command[];
|
|
9
9
|
paintPool: SkPaint[];
|
|
10
|
+
lastPicture?: SkPicture | null;
|
|
10
11
|
}
|
|
12
|
+
export declare const disposeRecording: (recording: Recording) => void;
|
|
11
13
|
interface AnimationValues {
|
|
12
14
|
animationValues: Set<SharedValue<unknown>>;
|
|
13
15
|
}
|
|
@@ -5,6 +5,16 @@ import { NodeType } from "../../dom/types";
|
|
|
5
5
|
import { isSharedValue } from "../utils";
|
|
6
6
|
import { isColorFilter, isImageFilter, isPathEffect, isShader } from "../Node";
|
|
7
7
|
import { CommandType } from "./Core";
|
|
8
|
+
export const disposeRecording = recording => {
|
|
9
|
+
"worklet";
|
|
10
|
+
|
|
11
|
+
recording.paintPool.forEach(paint => paint.dispose());
|
|
12
|
+
recording.paintPool.length = 0;
|
|
13
|
+
if (recording.lastPicture) {
|
|
14
|
+
recording.lastPicture.dispose();
|
|
15
|
+
recording.lastPicture = null;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
8
18
|
export class Recorder {
|
|
9
19
|
constructor() {
|
|
10
20
|
_defineProperty(this, "commands", []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NodeType","isSharedValue","isColorFilter","isImageFilter","isPathEffect","isShader","CommandType","Recorder","constructor","_defineProperty","Set","cursors","push","commands","getRecording","paintPool","animationValues","processProps","props","animatedProps","hasAnimatedProps","key","prop","add","undefined","command","length","saveGroup","children","group","type","Group","restoreGroup","pop","savePaint","standalone","SavePaint","restorePaint","RestorePaint","restorePaintDeclaration","RestorePaintDeclaration","materializePaint","MaterializePaint","pushPathEffect","pathEffectType","Error","PushPathEffect","pushImageFilter","imageFilterType","PushImageFilter","pushColorFilter","colorFilterType","PushColorFilter","pushShader","shaderType","Blend","PushShader","pushBlurMaskFilter","PushBlurMaskFilter","composePathEffect","ComposePathEffect","composeColorFilter","ComposeColorFilter","composeImageFilter","ComposeImageFilter","saveCTM","SaveCTM","restoreCTM","RestoreCTM","drawPaint","DrawPaint","saveLayer","SaveLayer","saveBackdropFilter","SaveBackdropFilter","drawBox","boxProps","shadows","forEach","shadow","DrawBox","drawImage","DrawImage","drawCircle","DrawCircle","drawPoints","DrawPoints","drawPath","DrawPath","drawRect","DrawRect","drawRRect","DrawRRect","drawOval","DrawOval","drawLine","DrawLine","drawPatch","DrawPatch","drawVertices","DrawVertices","drawDiffRect","DrawDiffRect","drawText","DrawText","drawTextPath","DrawTextPath","drawTextBlob","DrawTextBlob","drawGlyphs","DrawGlyphs","drawPicture","DrawPicture","drawImageSVG","DrawImageSVG","drawParagraph","DrawParagraph","drawAtlas","DrawAtlas","drawSkottie","DrawSkottie"],"sources":["Recorder.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport { NodeType } from \"../../dom/types\";\nimport type {\n BlurMaskFilterProps,\n CircleProps,\n CTMProps,\n ImageProps,\n PaintProps,\n PointsProps,\n PathProps,\n RectProps,\n RoundedRectProps,\n OvalProps,\n LineProps,\n PatchProps,\n VerticesProps,\n DiffRectProps,\n TextProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n PictureProps,\n ImageSVGProps,\n ParagraphProps,\n AtlasProps,\n BoxProps,\n BoxShadowProps,\n SkottieProps,\n DrawingNodeProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer\";\nimport { isSharedValue } from \"../utils\";\nimport { isColorFilter, isImageFilter, isPathEffect, isShader } from \"../Node\";\nimport type { SkPaint, BaseRecorder } from \"../../skia/types\";\n\nimport { CommandType } from \"./Core\";\nimport type { Command } from \"./Core\";\n\nexport interface Recording {\n commands: Command[];\n paintPool: SkPaint[];\n}\n\ninterface AnimationValues {\n animationValues: Set<SharedValue<unknown>>;\n}\n\nexport class Recorder implements BaseRecorder {\n commands: Command[] = [];\n cursors: Command[][] = [];\n animationValues: Set<SharedValue<unknown>> = new Set();\n\n constructor() {\n this.cursors.push(this.commands);\n }\n\n getRecording(): Recording & AnimationValues {\n return {\n commands: this.commands,\n paintPool: [],\n animationValues: this.animationValues,\n };\n }\n\n private processProps(props: Record<string, unknown>) {\n const animatedProps: Record<string, SharedValue<unknown>> = {};\n let hasAnimatedProps = false;\n\n for (const key in props) {\n const prop = props[key];\n if (isSharedValue(prop)) {\n this.animationValues.add(prop);\n animatedProps[key] = prop;\n hasAnimatedProps = true;\n }\n }\n\n return {\n props,\n animatedProps: hasAnimatedProps ? animatedProps : undefined,\n };\n }\n\n private add(command: Command) {\n if (command.props) {\n const { animatedProps } = this.processProps(\n command.props as Record<string, unknown>\n );\n if (animatedProps) {\n command.animatedProps = animatedProps;\n }\n }\n this.cursors[this.cursors.length - 1].push(command);\n }\n\n saveGroup(props?: AnimatedProps<Pick<DrawingNodeProps, \"zIndex\">>) {\n const children: Command[] = [];\n const group: Command = { type: CommandType.Group, children };\n if (props) {\n group.props = props;\n }\n this.add(group);\n this.cursors.push(children);\n }\n\n restoreGroup() {\n this.cursors.pop();\n }\n\n savePaint(props: AnimatedProps<PaintProps>, standalone: boolean) {\n this.add({ type: CommandType.SavePaint, props, standalone });\n }\n\n restorePaint() {\n this.add({ type: CommandType.RestorePaint });\n }\n\n restorePaintDeclaration() {\n this.add({ type: CommandType.RestorePaintDeclaration });\n }\n\n materializePaint() {\n this.add({ type: CommandType.MaterializePaint });\n }\n\n pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>) {\n if (!isPathEffect(pathEffectType)) {\n throw new Error(\"Invalid color filter type: \" + pathEffectType);\n }\n this.add({\n type: CommandType.PushPathEffect,\n pathEffectType,\n props,\n });\n }\n\n pushImageFilter(imageFilterType: NodeType, props: AnimatedProps<unknown>) {\n if (!isImageFilter(imageFilterType)) {\n throw new Error(\"Invalid color filter type: \" + imageFilterType);\n }\n this.add({\n type: CommandType.PushImageFilter,\n imageFilterType,\n props,\n });\n }\n\n pushColorFilter(colorFilterType: NodeType, props: AnimatedProps<unknown>) {\n if (!isColorFilter(colorFilterType)) {\n throw new Error(\"Invalid color filter type: \" + colorFilterType);\n }\n this.add({\n type: CommandType.PushColorFilter,\n colorFilterType,\n props,\n });\n }\n\n pushShader(\n shaderType: NodeType,\n props: AnimatedProps<unknown>,\n children: number\n ) {\n if (!isShader(shaderType) && !(shaderType === NodeType.Blend)) {\n throw new Error(\"Invalid color filter type: \" + shaderType);\n }\n this.add({ type: CommandType.PushShader, shaderType, props, children });\n }\n\n pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>) {\n this.add({ type: CommandType.PushBlurMaskFilter, props });\n }\n\n composePathEffect() {\n this.add({ type: CommandType.ComposePathEffect });\n }\n\n composeColorFilter() {\n this.add({ type: CommandType.ComposeColorFilter });\n }\n\n composeImageFilter() {\n this.add({ type: CommandType.ComposeImageFilter });\n }\n\n saveCTM(props: AnimatedProps<CTMProps>) {\n this.add({ type: CommandType.SaveCTM, props });\n }\n\n restoreCTM() {\n this.add({ type: CommandType.RestoreCTM });\n }\n\n drawPaint() {\n this.add({ type: CommandType.DrawPaint });\n }\n\n saveLayer() {\n this.add({ type: CommandType.SaveLayer });\n }\n\n saveBackdropFilter() {\n this.add({ type: CommandType.SaveBackdropFilter });\n }\n\n drawBox(\n boxProps: AnimatedProps<BoxProps>,\n shadows: {\n props: BoxShadowProps;\n animatedProps?: Record<string, SharedValue<unknown>>;\n }[]\n ) {\n shadows.forEach((shadow) => {\n if (shadow.props) {\n if (shadow.props) {\n const { animatedProps } = this.processProps(\n shadow.props as unknown as Record<string, unknown>\n );\n if (animatedProps) {\n shadow.animatedProps = animatedProps;\n }\n }\n }\n });\n this.add({ type: CommandType.DrawBox, props: boxProps, shadows });\n }\n\n drawImage(props: AnimatedProps<ImageProps>) {\n this.add({ type: CommandType.DrawImage, props });\n }\n\n drawCircle(props: AnimatedProps<CircleProps>) {\n this.add({ type: CommandType.DrawCircle, props });\n }\n drawPoints(props: AnimatedProps<PointsProps>) {\n this.add({ type: CommandType.DrawPoints, props });\n }\n\n drawPath(props: AnimatedProps<PathProps>) {\n this.add({ type: CommandType.DrawPath, props });\n }\n\n drawRect(props: AnimatedProps<RectProps>) {\n this.add({ type: CommandType.DrawRect, props });\n }\n\n drawRRect(props: AnimatedProps<RoundedRectProps>) {\n this.add({ type: CommandType.DrawRRect, props });\n }\n\n drawOval(props: AnimatedProps<OvalProps>) {\n this.add({ type: CommandType.DrawOval, props });\n }\n\n drawLine(props: AnimatedProps<LineProps>) {\n this.add({ type: CommandType.DrawLine, props });\n }\n\n drawPatch(props: AnimatedProps<PatchProps>) {\n this.add({ type: CommandType.DrawPatch, props });\n }\n\n drawVertices(props: AnimatedProps<VerticesProps>) {\n this.add({ type: CommandType.DrawVertices, props });\n }\n\n drawDiffRect(props: AnimatedProps<DiffRectProps>) {\n this.add({ type: CommandType.DrawDiffRect, props });\n }\n\n drawText(props: AnimatedProps<TextProps>) {\n this.add({ type: CommandType.DrawText, props });\n }\n\n drawTextPath(props: AnimatedProps<TextPathProps>) {\n this.add({ type: CommandType.DrawTextPath, props });\n }\n\n drawTextBlob(props: AnimatedProps<TextBlobProps>) {\n this.add({ type: CommandType.DrawTextBlob, props });\n }\n\n drawGlyphs(props: AnimatedProps<GlyphsProps>) {\n this.add({ type: CommandType.DrawGlyphs, props });\n }\n\n drawPicture(props: AnimatedProps<PictureProps>) {\n this.add({ type: CommandType.DrawPicture, props });\n }\n\n drawImageSVG(props: AnimatedProps<ImageSVGProps>) {\n this.add({ type: CommandType.DrawImageSVG, props });\n }\n\n drawParagraph(props: AnimatedProps<ParagraphProps>) {\n this.add({ type: CommandType.DrawParagraph, props });\n }\n\n drawAtlas(props: AnimatedProps<AtlasProps>) {\n this.add({ type: CommandType.DrawAtlas, props });\n }\n\n drawSkottie(props: AnimatedProps<SkottieProps>) {\n this.add({ type: CommandType.DrawSkottie, props });\n }\n}\n"],"mappings":";;;AAEA,SAASA,QAAQ,QAAQ,iBAAiB;AA8B1C,SAASC,aAAa,QAAQ,UAAU;AACxC,SAASC,aAAa,EAAEC,aAAa,EAAEC,YAAY,EAAEC,QAAQ,QAAQ,SAAS;AAG9E,SAASC,WAAW,QAAQ,QAAQ;AAYpC,OAAO,MAAMC,QAAQ,CAAyB;EAK5CC,WAAWA,CAAA,EAAG;IAAAC,eAAA,mBAJQ,EAAE;IAAAA,eAAA,kBACD,EAAE;IAAAA,eAAA,0BACoB,IAAIC,GAAG,CAAC,CAAC;IAGpD,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,IAAI,CAACC,QAAQ,CAAC;EAClC;EAEAC,YAAYA,CAAA,EAAgC;IAC1C,OAAO;MACLD,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBE,SAAS,EAAE,EAAE;MACbC,eAAe,EAAE,IAAI,CAACA;IACxB,CAAC;EACH;EAEQC,YAAYA,CAACC,KAA8B,EAAE;IACnD,MAAMC,aAAmD,GAAG,CAAC,CAAC;IAC9D,IAAIC,gBAAgB,GAAG,KAAK;IAE5B,KAAK,MAAMC,GAAG,IAAIH,KAAK,EAAE;MACvB,MAAMI,IAAI,GAAGJ,KAAK,CAACG,GAAG,CAAC;MACvB,IAAIpB,aAAa,CAACqB,IAAI,CAAC,EAAE;QACvB,IAAI,CAACN,eAAe,CAACO,GAAG,CAACD,IAAI,CAAC;QAC9BH,aAAa,CAACE,GAAG,CAAC,GAAGC,IAAI;QACzBF,gBAAgB,GAAG,IAAI;MACzB;IACF;IAEA,OAAO;MACLF,KAAK;MACLC,aAAa,EAAEC,gB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WAAW,CAACwG,UAAU;MAAE5F;IAAM,CAAC,CAAC;EACnD;EAEA6F,WAAWA,CAAC7F,KAAkC,EAAE;IAC9C,IAAI,CAACK,GAAG,CAAC;MAAEO,IAAI,EAAExB,WAAW,CAAC0G,WAAW;MAAE9F;IAAM,CAAC,CAAC;EACpD;EAEA+F,YAAYA,CAAC/F,KAAmC,EAAE;IAChD,IAAI,CAACK,GAAG,CAAC;MAAEO,IAAI,EAAExB,WAAW,CAAC4G,YAAY;MAAEhG;IAAM,CAAC,CAAC;EACrD;EAEAiG,aAAaA,CAACjG,KAAoC,EAAE;IAClD,IAAI,CAACK,GAAG,CAAC;MAAEO,IAAI,EAAExB,WAAW,CAAC8G,aAAa;MAAElG;IAAM,CAAC,CAAC;EACtD;EAEAmG,SAASA,CAACnG,KAAgC,EAAE;IAC1C,IAAI,CAACK,GAAG,CAAC;MAAEO,IAAI,EAAExB,WAAW,CAACgH,SAAS;MAAEpG;IAAM,CAAC,CAAC;EAClD;EAEAqG,WAAWA,CAACrG,KAAkC,EAAE;IAC9C,IAAI,CAACK,GAAG,CAAC;MAAEO,IAAI,EAAExB,WAAW,CAACkH,WAAW;MAAEtG;IAAM,CAAC,CAAC;EACpD;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["NodeType","isSharedValue","isColorFilter","isImageFilter","isPathEffect","isShader","CommandType","disposeRecording","recording","paintPool","forEach","paint","dispose","length","lastPicture","Recorder","constructor","_defineProperty","Set","cursors","push","commands","getRecording","animationValues","processProps","props","animatedProps","hasAnimatedProps","key","prop","add","undefined","command","saveGroup","children","group","type","Group","restoreGroup","pop","savePaint","standalone","SavePaint","restorePaint","RestorePaint","restorePaintDeclaration","RestorePaintDeclaration","materializePaint","MaterializePaint","pushPathEffect","pathEffectType","Error","PushPathEffect","pushImageFilter","imageFilterType","PushImageFilter","pushColorFilter","colorFilterType","PushColorFilter","pushShader","shaderType","Blend","PushShader","pushBlurMaskFilter","PushBlurMaskFilter","composePathEffect","ComposePathEffect","composeColorFilter","ComposeColorFilter","composeImageFilter","ComposeImageFilter","saveCTM","SaveCTM","restoreCTM","RestoreCTM","drawPaint","DrawPaint","saveLayer","SaveLayer","saveBackdropFilter","SaveBackdropFilter","drawBox","boxProps","shadows","shadow","DrawBox","drawImage","DrawImage","drawCircle","DrawCircle","drawPoints","DrawPoints","drawPath","DrawPath","drawRect","DrawRect","drawRRect","DrawRRect","drawOval","DrawOval","drawLine","DrawLine","drawPatch","DrawPatch","drawVertices","DrawVertices","drawDiffRect","DrawDiffRect","drawText","DrawText","drawTextPath","DrawTextPath","drawTextBlob","DrawTextBlob","drawGlyphs","DrawGlyphs","drawPicture","DrawPicture","drawImageSVG","DrawImageSVG","drawParagraph","DrawParagraph","drawAtlas","DrawAtlas","drawSkottie","DrawSkottie"],"sources":["Recorder.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport { NodeType } from \"../../dom/types\";\nimport type {\n BlurMaskFilterProps,\n CircleProps,\n CTMProps,\n ImageProps,\n PaintProps,\n PointsProps,\n PathProps,\n RectProps,\n RoundedRectProps,\n OvalProps,\n LineProps,\n PatchProps,\n VerticesProps,\n DiffRectProps,\n TextProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n PictureProps,\n ImageSVGProps,\n ParagraphProps,\n AtlasProps,\n BoxProps,\n BoxShadowProps,\n SkottieProps,\n DrawingNodeProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer\";\nimport { isSharedValue } from \"../utils\";\nimport { isColorFilter, isImageFilter, isPathEffect, isShader } from \"../Node\";\nimport type { SkPaint, SkPicture, BaseRecorder } from \"../../skia/types\";\n\nimport { CommandType } from \"./Core\";\nimport type { Command } from \"./Core\";\n\nexport interface Recording {\n commands: Command[];\n paintPool: SkPaint[];\n // Last picture produced from this recording. The view keeps its own\n // reference to the picture it displays, so the renderer owns this one and\n // disposes it when the next frame replaces it or the recording is disposed.\n lastPicture?: SkPicture | null;\n}\n\nexport const disposeRecording = (recording: Recording) => {\n \"worklet\";\n recording.paintPool.forEach((paint) => paint.dispose());\n recording.paintPool.length = 0;\n if (recording.lastPicture) {\n recording.lastPicture.dispose();\n recording.lastPicture = null;\n }\n};\n\ninterface AnimationValues {\n animationValues: Set<SharedValue<unknown>>;\n}\n\nexport class Recorder implements BaseRecorder {\n commands: Command[] = [];\n cursors: Command[][] = [];\n animationValues: Set<SharedValue<unknown>> = new Set();\n\n constructor() {\n this.cursors.push(this.commands);\n }\n\n getRecording(): Recording & AnimationValues {\n return {\n commands: this.commands,\n paintPool: [],\n animationValues: this.animationValues,\n };\n }\n\n private processProps(props: Record<string, unknown>) {\n const animatedProps: Record<string, SharedValue<unknown>> = {};\n let hasAnimatedProps = false;\n\n for (const key in props) {\n const prop = props[key];\n if (isSharedValue(prop)) {\n this.animationValues.add(prop);\n animatedProps[key] = prop;\n hasAnimatedProps = true;\n }\n }\n\n return {\n props,\n animatedProps: hasAnimatedProps ? animatedProps : undefined,\n };\n }\n\n private add(command: Command) {\n if (command.props) {\n const { animatedProps } = this.processProps(\n command.props as Record<string, unknown>\n );\n if (animatedProps) {\n command.animatedProps = animatedProps;\n }\n }\n this.cursors[this.cursors.length - 1].push(command);\n }\n\n saveGroup(props?: AnimatedProps<Pick<DrawingNodeProps, \"zIndex\">>) {\n const children: Command[] = [];\n const group: Command = { type: CommandType.Group, children };\n if (props) {\n group.props = props;\n }\n this.add(group);\n this.cursors.push(children);\n }\n\n restoreGroup() {\n this.cursors.pop();\n }\n\n savePaint(props: AnimatedProps<PaintProps>, standalone: boolean) {\n this.add({ type: CommandType.SavePaint, props, standalone });\n }\n\n restorePaint() {\n this.add({ type: CommandType.RestorePaint });\n }\n\n restorePaintDeclaration() {\n this.add({ type: CommandType.RestorePaintDeclaration });\n }\n\n materializePaint() {\n this.add({ type: CommandType.MaterializePaint });\n }\n\n pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>) {\n if (!isPathEffect(pathEffectType)) {\n throw new Error(\"Invalid color filter type: \" + pathEffectType);\n }\n this.add({\n type: CommandType.PushPathEffect,\n pathEffectType,\n props,\n });\n }\n\n pushImageFilter(imageFilterType: NodeType, props: AnimatedProps<unknown>) {\n if (!isImageFilter(imageFilterType)) {\n throw new Error(\"Invalid color filter type: \" + imageFilterType);\n }\n this.add({\n type: CommandType.PushImageFilter,\n imageFilterType,\n props,\n });\n }\n\n pushColorFilter(colorFilterType: NodeType, props: AnimatedProps<unknown>) {\n if (!isColorFilter(colorFilterType)) {\n throw new Error(\"Invalid color filter type: \" + colorFilterType);\n }\n this.add({\n type: CommandType.PushColorFilter,\n colorFilterType,\n props,\n });\n }\n\n pushShader(\n shaderType: NodeType,\n props: AnimatedProps<unknown>,\n children: number\n ) {\n if (!isShader(shaderType) && !(shaderType === NodeType.Blend)) {\n throw new Error(\"Invalid color filter type: \" + shaderType);\n }\n this.add({ type: CommandType.PushShader, shaderType, props, children });\n }\n\n pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>) {\n this.add({ type: CommandType.PushBlurMaskFilter, props });\n }\n\n composePathEffect() {\n this.add({ type: CommandType.ComposePathEffect });\n }\n\n composeColorFilter() {\n this.add({ type: CommandType.ComposeColorFilter });\n }\n\n composeImageFilter() {\n this.add({ type: CommandType.ComposeImageFilter });\n }\n\n saveCTM(props: AnimatedProps<CTMProps>) {\n this.add({ type: CommandType.SaveCTM, props });\n }\n\n restoreCTM() {\n this.add({ type: CommandType.RestoreCTM });\n }\n\n drawPaint() {\n this.add({ type: CommandType.DrawPaint });\n }\n\n saveLayer() {\n this.add({ type: CommandType.SaveLayer });\n }\n\n saveBackdropFilter() {\n this.add({ type: CommandType.SaveBackdropFilter });\n }\n\n drawBox(\n boxProps: AnimatedProps<BoxProps>,\n shadows: {\n props: BoxShadowProps;\n animatedProps?: Record<string, SharedValue<unknown>>;\n }[]\n ) {\n shadows.forEach((shadow) => {\n if (shadow.props) {\n if (shadow.props) {\n const { animatedProps } = this.processProps(\n shadow.props as unknown as Record<string, unknown>\n );\n if (animatedProps) {\n shadow.animatedProps = animatedProps;\n }\n }\n }\n });\n this.add({ type: CommandType.DrawBox, props: boxProps, shadows });\n }\n\n drawImage(props: AnimatedProps<ImageProps>) {\n this.add({ type: CommandType.DrawImage, props });\n }\n\n drawCircle(props: AnimatedProps<CircleProps>) {\n this.add({ type: CommandType.DrawCircle, props });\n }\n drawPoints(props: AnimatedProps<PointsProps>) {\n this.add({ type: CommandType.DrawPoints, props });\n }\n\n drawPath(props: AnimatedProps<PathProps>) {\n this.add({ type: CommandType.DrawPath, props });\n }\n\n drawRect(props: AnimatedProps<RectProps>) {\n this.add({ type: CommandType.DrawRect, props });\n }\n\n drawRRect(props: AnimatedProps<RoundedRectProps>) {\n this.add({ type: CommandType.DrawRRect, props });\n }\n\n drawOval(props: AnimatedProps<OvalProps>) {\n this.add({ type: CommandType.DrawOval, props });\n }\n\n drawLine(props: AnimatedProps<LineProps>) {\n this.add({ type: CommandType.DrawLine, props });\n }\n\n drawPatch(props: AnimatedProps<PatchProps>) {\n this.add({ type: CommandType.DrawPatch, props });\n }\n\n drawVertices(props: AnimatedProps<VerticesProps>) {\n this.add({ type: CommandType.DrawVertices, props });\n }\n\n drawDiffRect(props: AnimatedProps<DiffRectProps>) {\n this.add({ type: CommandType.DrawDiffRect, props });\n }\n\n drawText(props: AnimatedProps<TextProps>) {\n this.add({ type: CommandType.DrawText, props });\n }\n\n drawTextPath(props: AnimatedProps<TextPathProps>) {\n this.add({ type: CommandType.DrawTextPath, props });\n }\n\n drawTextBlob(props: AnimatedProps<TextBlobProps>) {\n this.add({ type: CommandType.DrawTextBlob, props });\n }\n\n drawGlyphs(props: AnimatedProps<GlyphsProps>) {\n this.add({ type: CommandType.DrawGlyphs, props });\n }\n\n drawPicture(props: AnimatedProps<PictureProps>) {\n this.add({ type: CommandType.DrawPicture, props });\n }\n\n drawImageSVG(props: AnimatedProps<ImageSVGProps>) {\n this.add({ type: CommandType.DrawImageSVG, props });\n }\n\n drawParagraph(props: AnimatedProps<ParagraphProps>) {\n this.add({ type: CommandType.DrawParagraph, props });\n }\n\n drawAtlas(props: AnimatedProps<AtlasProps>) {\n this.add({ type: CommandType.DrawAtlas, props });\n }\n\n drawSkottie(props: AnimatedProps<SkottieProps>) {\n this.add({ type: CommandType.DrawSkottie, props });\n }\n}\n"],"mappings":";;;AAEA,SAASA,QAAQ,QAAQ,iBAAiB;AA8B1C,SAASC,aAAa,QAAQ,UAAU;AACxC,SAASC,aAAa,EAAEC,aAAa,EAAEC,YAAY,EAAEC,QAAQ,QAAQ,SAAS;AAG9E,SAASC,WAAW,QAAQ,QAAQ;AAYpC,OAAO,MAAMC,gBAAgB,GAAIC,SAAoB,IAAK;EACxD,SAAS;;EACTA,SAAS,CAACC,SAAS,CAACC,OAAO,CAAEC,KAAK,IAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;EACvDJ,SAAS,CAACC,SAAS,CAACI,MAAM,GAAG,CAAC;EAC9B,IAAIL,SAAS,CAACM,WAAW,EAAE;IACzBN,SAAS,CAACM,WAAW,CAACF,OAAO,CAAC,CAAC;IAC/BJ,SAAS,CAACM,WAAW,GAAG,IAAI;EAC9B;AACF,CAAC;AAMD,OAAO,MAAMC,QAAQ,CAAyB;EAK5CC,WAAWA,CAAA,EAAG;IAAAC,eAAA,mBAJQ,EAAE;IAAAA,eAAA,kBACD,EAAE;IAAAA,eAAA,0BACoB,IAAIC,GAAG,CAAC,CAAC;IAGpD,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,IAAI,CAACC,QAAQ,CAAC;EAClC;EAEAC,YAAYA,CAAA,EAAgC;IAC1C,OAAO;MACLD,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBZ,SAAS,EAAE,EAAE;MACbc,eAAe,EAAE,IAAI,CAACA;IACxB,CAAC;EACH;EAEQC,YAAYA,CAACC,KAA8B,EAAE;IACnD,MAAMC,aAAmD,GAAG,CAAC,CAAC;IAC9D,IAAIC,gBAAgB,GAAG,KAAK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
|
|
95
95
|
const rsx = [];
|
|
96
96
|
const meas = ctx.Skia.ContourMeasureIter(path, false, 1);
|
|
97
|
-
let cont = meas.next();
|
|
97
|
+
let cont = ctx.track(meas.next());
|
|
98
98
|
let dist = initialOffset;
|
|
99
99
|
for (let i = 0; i < text.length && cont; i++) {
|
|
100
100
|
const width = widths[i];
|
|
101
101
|
dist += width / 2;
|
|
102
102
|
if (dist > cont.length()) {
|
|
103
103
|
// jump to next contour
|
|
104
|
-
cont = meas.next();
|
|
104
|
+
cont = ctx.track(meas.next());
|
|
105
105
|
if (!cont) {
|
|
106
106
|
// We have come to the end of the path - terminate the string
|
|
107
107
|
// right here.
|
|
@@ -177,7 +177,7 @@ export const drawPath = (ctx, props) => {
|
|
|
177
177
|
if (hasFillType) {
|
|
178
178
|
const builder = ctx.Skia.PathBuilder.MakeFromPath(path);
|
|
179
179
|
builder.setFillType(FillType[enumKey(fillType)]);
|
|
180
|
-
path = builder.build();
|
|
180
|
+
path = ctx.track(builder.build());
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
// Apply stroke using static Path.Stroke
|