@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
|
@@ -4,9 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createDrawingContext = void 0;
|
|
7
|
+
var _FrameScope = require("./FrameScope");
|
|
7
8
|
const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
8
9
|
"worklet";
|
|
9
10
|
|
|
11
|
+
// Everything the renderer creates through frameSkia is frame-scoped and
|
|
12
|
+
// deleted by dispose() once the frame has been recorded. The paint pool is
|
|
13
|
+
// recording-scoped and deliberately allocated with the raw Skia instance.
|
|
14
|
+
const {
|
|
15
|
+
Skia: frameSkia,
|
|
16
|
+
track,
|
|
17
|
+
dispose
|
|
18
|
+
} = (0, _FrameScope.createFrameScope)(Skia);
|
|
19
|
+
|
|
10
20
|
// State (formerly class fields)
|
|
11
21
|
const paints = [];
|
|
12
22
|
const colorFilters = [];
|
|
@@ -18,7 +28,11 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
18
28
|
let nextPaintIndex = 1;
|
|
19
29
|
|
|
20
30
|
// Initialize first paint and opacity
|
|
21
|
-
paintPool
|
|
31
|
+
if (paintPool.length === 0) {
|
|
32
|
+
paintPool.push(Skia.Paint());
|
|
33
|
+
} else {
|
|
34
|
+
paintPool[0].reset();
|
|
35
|
+
}
|
|
22
36
|
paints.push(paintPool[0]);
|
|
23
37
|
opacities.push(1);
|
|
24
38
|
|
|
@@ -48,7 +62,7 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
48
62
|
} else {
|
|
49
63
|
const cf = colorFilters.pop();
|
|
50
64
|
if (cf) {
|
|
51
|
-
imageFilter =
|
|
65
|
+
imageFilter = frameSkia.ImageFilter.MakeColorFilter(cf, null);
|
|
52
66
|
}
|
|
53
67
|
}
|
|
54
68
|
canvas.saveLayer(undefined, null, imageFilter);
|
|
@@ -66,7 +80,7 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
66
80
|
const materializePaint = () => {
|
|
67
81
|
// Color Filters
|
|
68
82
|
if (colorFilters.length > 0) {
|
|
69
|
-
getCurrentPaint().setColorFilter(colorFilters.reduceRight((inner, outer) => inner ?
|
|
83
|
+
getCurrentPaint().setColorFilter(colorFilters.reduceRight((inner, outer) => inner ? frameSkia.ColorFilter.MakeCompose(outer, inner) : outer));
|
|
70
84
|
}
|
|
71
85
|
// Shaders
|
|
72
86
|
if (shaders.length > 0) {
|
|
@@ -74,12 +88,12 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
74
88
|
}
|
|
75
89
|
// Image Filters
|
|
76
90
|
if (imageFilters.length > 0) {
|
|
77
|
-
getCurrentPaint().setImageFilter(imageFilters.reduceRight((inner, outer) => inner ?
|
|
91
|
+
getCurrentPaint().setImageFilter(imageFilters.reduceRight((inner, outer) => inner ? frameSkia.ImageFilter.MakeCompose(outer, inner) : outer));
|
|
78
92
|
}
|
|
79
93
|
|
|
80
94
|
// Path Effects
|
|
81
95
|
if (pathEffects.length > 0) {
|
|
82
|
-
getCurrentPaint().setPathEffect(pathEffects.reduceRight((inner, outer) => inner ?
|
|
96
|
+
getCurrentPaint().setPathEffect(pathEffects.reduceRight((inner, outer) => inner ? frameSkia.PathEffect.MakeCompose(outer, inner) : outer));
|
|
83
97
|
}
|
|
84
98
|
|
|
85
99
|
// Clear arrays
|
|
@@ -92,8 +106,10 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
92
106
|
// Return an object containing the Skia reference, the canvas, and the methods
|
|
93
107
|
return {
|
|
94
108
|
// Public fields
|
|
95
|
-
Skia,
|
|
109
|
+
Skia: frameSkia,
|
|
96
110
|
canvas,
|
|
111
|
+
track,
|
|
112
|
+
dispose,
|
|
97
113
|
paints,
|
|
98
114
|
colorFilters,
|
|
99
115
|
shaders,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createDrawingContext","Skia","paintPool","canvas","paints","colorFilters","shaders","imageFilters","pathEffects","paintDeclarations","opacities","nextPaintIndex","
|
|
1
|
+
{"version":3,"names":["_FrameScope","require","createDrawingContext","Skia","paintPool","canvas","frameSkia","track","dispose","createFrameScope","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","exports"],"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,IAAAA,WAAA,GAAAC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ACAkB,SAAS;IACTU,kBAAkB;IAClB,IAAIsB,KAAKA,CAAA,EAAG;MACV,OAAO5C,MAAM,CAACA,MAAM,CAACQ,MAAM,GAAG,CAAC,CAAC;IAClC,CAAC;IAAE;IACHwB,YAAY;IACZC,gBAAgB;IAChBjB,UAAU;IACVC;EACF,CAAC;AACH,CAAC;AAAC4B,OAAA,CAAArD,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
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,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createFrameScope = void 0;
|
|
7
|
+
const isDisposable = value => {
|
|
8
|
+
"worklet";
|
|
9
|
+
|
|
10
|
+
return value !== null && typeof value === "object" && typeof value.dispose === "function";
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Wraps a Skia instance so that every object created through its factories is
|
|
14
|
+
* collected and deleted when the scope is disposed. The renderer only keeps
|
|
15
|
+
* the objects it creates alive for the duration of a frame: once the frame
|
|
16
|
+
* has been recorded they can be deleted. This is required on Web where
|
|
17
|
+
* CanvasKit objects live in WASM memory that the JS garbage collector does
|
|
18
|
+
* not perceive, so it (almost) never reclaims them on its own.
|
|
19
|
+
*
|
|
20
|
+
* Objects passed in via props are user-owned: they are not created through
|
|
21
|
+
* this facade and are therefore never tracked nor disposed.
|
|
22
|
+
*/
|
|
23
|
+
const createFrameScope = Skia => {
|
|
24
|
+
"worklet";
|
|
25
|
+
|
|
26
|
+
const disposables = [];
|
|
27
|
+
const track = value => {
|
|
28
|
+
if (isDisposable(value)) {
|
|
29
|
+
disposables.push(value);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
};
|
|
33
|
+
const wrap = obj => {
|
|
34
|
+
const cache = new Map();
|
|
35
|
+
return new Proxy(obj, {
|
|
36
|
+
get(target, prop) {
|
|
37
|
+
if (cache.has(prop)) {
|
|
38
|
+
return cache.get(prop);
|
|
39
|
+
}
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
const value = target[prop];
|
|
42
|
+
let wrapped = value;
|
|
43
|
+
if (typeof value === "function") {
|
|
44
|
+
wrapped = (...args) => track(value.apply(target, args));
|
|
45
|
+
} else if (value !== null && typeof value === "object") {
|
|
46
|
+
wrapped = wrap(value);
|
|
47
|
+
}
|
|
48
|
+
cache.set(prop, wrapped);
|
|
49
|
+
return wrapped;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const dispose = () => {
|
|
54
|
+
for (let i = 0; i < disposables.length; i++) {
|
|
55
|
+
disposables[i].dispose();
|
|
56
|
+
}
|
|
57
|
+
disposables.length = 0;
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
Skia: wrap(Skia),
|
|
61
|
+
track,
|
|
62
|
+
dispose
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
exports.createFrameScope = createFrameScope;
|
|
66
|
+
//# 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","exports"],"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,MAAM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AAC,CAAC;EACJ,CAAC;EACD,MAAMf,OAAO,GAAGA,CAAA,KAAM;IACpB,KAAK,IAAImB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGhB,WAAW,CAACiB,MAAM,EAAED,CAAC,EAAE,EAAE;MAC3ChB,WAAW,CAACgB,CAAC,CAAC,CAACnB,OAAO,CAAC,CAAC;IAC1B;IACAG,WAAW,CAACiB,MAAM,GAAG,CAAC;EACxB,CAAC;EACD,OAAO;IAAElB,IAAI,EAAEI,IAAI,CAACJ,IAAI,CAAC;IAAEE,KAAK;IAAEJ;EAAQ,CAAC;AAC7C,CAAC;AAACqB,OAAA,CAAApB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Skia } from "../../skia/types";
|
|
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,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createFrameScope = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* No-op on native. The JSI wrappers report the size of the native objects
|
|
9
|
+
* they hold to the garbage collector (setExternalMemoryPressure), so the GC
|
|
10
|
+
* is aware of the real cost of the objects the renderer creates and reclaims
|
|
11
|
+
* them on its own. The tracking scope is only needed on Web, where CanvasKit
|
|
12
|
+
* objects live in WASM memory the GC cannot see (see FrameScope.ts).
|
|
13
|
+
*/
|
|
14
|
+
const createFrameScope = Skia => {
|
|
15
|
+
"worklet";
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
Skia,
|
|
19
|
+
track: value => value,
|
|
20
|
+
dispose: () => {
|
|
21
|
+
// nothing to dispose: no objects are tracked on native
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.createFrameScope = createFrameScope;
|
|
26
|
+
//# sourceMappingURL=FrameScope.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFrameScope","Skia","track","value","dispose","exports"],"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;AACO,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;AAACC,OAAA,CAAAL,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -116,9 +116,8 @@ const play = (ctx, _command) => {
|
|
|
116
116
|
} else if ((0, _Core.isCommand)(command, _Core.CommandType.RestoreCTM)) {
|
|
117
117
|
ctx.canvas.restore();
|
|
118
118
|
} else {
|
|
119
|
-
// TODO: is a copy needed here?
|
|
120
119
|
// apply opacity to the current paint.
|
|
121
|
-
const paint = ctx.paint.copy();
|
|
120
|
+
const paint = ctx.track(ctx.paint.copy());
|
|
122
121
|
paint.setAlphaf(paint.getAlphaf() * ctx.getOpacity());
|
|
123
122
|
const paints = [paint, ...ctx.paintDeclarations];
|
|
124
123
|
ctx.paintDeclarations = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Drawing","require","_Box","_ColorFilters","_CTM","_ImageFilters","_Paint","_PathEffects","_Shaders","_Core","getZIndex","command","_materialized$props","materialized","materializeCommand","zIndex","props","Number","isNaN","flushPendingGroups","ctx","pendingGroups","playFn","length","sort","a","b","order","forEach","playGroup","group","pending","children","child","isGroup","push","play","_command","isCommand","CommandType","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","isDrawCommand","SavePaint","paints","standalone","savePaint","freshPaint","Skia","Paint","assign","setPaintProperties","RestorePaint","restorePaint","ComposeColorFilter","composeColorFilters","RestorePaintDeclaration","Error","MaterializePaint","isPushColorFilter","pushColorFilter","isPushShader","pushShader","isPushImageFilter","pushImageFilter","isPushPathEffect","pushPathEffect","ComposePathEffect","composePathEffects","ComposeImageFilter","composeImageFilters","PushBlurMaskFilter","setBlurMaskFilter","SaveCTM","saveCTM","RestoreCTM","restore","copy","setAlphaf","getAlphaf","getOpacity","p","isBoxCommand","drawBox","DrawPaint","drawPaint","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","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,IAAAA,QAAA,GAAAC,OAAA;AAsBA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAKA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAMA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAKA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AAgBA,MAAMS,SAAS,GAAIC,OAAqB,IAAK;EAC3C,SAAS;;EAAC,IAAAC,mBAAA;EACV,MAAMC,YAAY,GAAG,IAAAC,wBAAkB,EAACH,OAAO,CAAC;EAChD,MAAM;IAAEI;EAAO,CAAC,IAAAH,mBAAA,GAAIC,YAAY,CAACG,KAAK,cAAAJ,mBAAA,cAAAA,mBAAA,GAAI,CAAC,CAAsB;EACjE,IAAI,OAAOG,MAAM,KAAK,QAAQ,IAAIE,MAAM,CAACC,KAAK,CAACH,MAAM,CAAC,EAAE;IACtD,OAAO,CAAC;EACV;EACA,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,EAAET,OAAO,CAAC;EACpB,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_Drawing","require","_Box","_ColorFilters","_CTM","_ImageFilters","_Paint","_PathEffects","_Shaders","_Core","getZIndex","command","_materialized$props","materialized","materializeCommand","zIndex","props","Number","isNaN","flushPendingGroups","ctx","pendingGroups","playFn","length","sort","a","b","order","forEach","playGroup","group","pending","children","child","isGroup","push","play","_command","isCommand","CommandType","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","isDrawCommand","SavePaint","paints","standalone","savePaint","freshPaint","Skia","Paint","assign","setPaintProperties","RestorePaint","restorePaint","ComposeColorFilter","composeColorFilters","RestorePaintDeclaration","Error","MaterializePaint","isPushColorFilter","pushColorFilter","isPushShader","pushShader","isPushImageFilter","pushImageFilter","isPushPathEffect","pushPathEffect","ComposePathEffect","composePathEffects","ComposeImageFilter","composeImageFilters","PushBlurMaskFilter","setBlurMaskFilter","SaveCTM","saveCTM","RestoreCTM","restore","track","copy","setAlphaf","getAlphaf","getOpacity","p","isBoxCommand","drawBox","DrawPaint","drawPaint","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","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,IAAAA,QAAA,GAAAC,OAAA;AAsBA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAKA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAMA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAKA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AAgBA,MAAMS,SAAS,GAAIC,OAAqB,IAAK;EAC3C,SAAS;;EAAC,IAAAC,mBAAA;EACV,MAAMC,YAAY,GAAG,IAAAC,wBAAkB,EAACH,OAAO,CAAC;EAChD,MAAM;IAAEI;EAAO,CAAC,IAAAH,mBAAA,GAAIC,YAAY,CAACG,KAAK,cAAAJ,mBAAA,cAAAA,mBAAA,GAAI,CAAC,CAAsB;EACjE,IAAI,OAAOG,MAAM,KAAK,QAAQ,IAAIE,MAAM,CAACC,KAAK,CAACH,MAAM,CAAC,EAAE;IACtD,OAAO,CAAC;EACV;EACA,OAAOA,MAAM;AACf,CAAC;AAED,MAAMI,kBAAkB,GAAGA,CACzBC,GAAmB,EACnBC,aAA6B,EAC7BC,MAAmD,KAChD;EACH,SAAS;;EACT,IAAID,aAAa,CAACE,MAAM,KAAK,CAAC,EAAE;IAC9B;EACF;EACAF,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AE4B,iBAAW,CAACqF,WAAW,CAAC,EAAE;QAC1D,IAAAC,oBAAW,EAACzG,GAAG,EAAET,OAAO,CAACK,KAAK,CAAC;MACjC,CAAC,MAAM,IAAI,IAAAiC,mBAAa,EAACtC,OAAO,EAAE4B,iBAAW,CAACuF,YAAY,CAAC,EAAE;QAC3D,IAAAC,qBAAY,EAAC3G,GAAG,EAAET,OAAO,CAACK,KAAK,CAAC;MAClC,CAAC,MAAM,IAAI,IAAAiC,mBAAa,EAACtC,OAAO,EAAE4B,iBAAW,CAACyF,aAAa,CAAC,EAAE;QAC5D,IAAAC,sBAAa,EAAC7G,GAAG,EAAET,OAAO,CAACK,KAAK,CAAC;MACnC,CAAC,MAAM,IAAI,IAAAiC,mBAAa,EAACtC,OAAO,EAAE4B,iBAAW,CAAC2F,SAAS,CAAC,EAAE;QACxD,IAAAC,kBAAS,EAAC/G,GAAG,EAAET,OAAO,CAACK,KAAK,CAAC;MAC/B,CAAC,MAAM,IAAI,IAAAiC,mBAAa,EAACtC,OAAO,EAAE4B,iBAAW,CAAC6F,WAAW,CAAC,EAAE;QAC1D,IAAAC,oBAAW,EAACjH,GAAG,EAAET,OAAO,CAACK,KAAK,CAAC;MACjC,CAAC,MAAM;QACLsH,OAAO,CAACC,IAAI,CAAC,oBAAoB5H,OAAO,CAAC6H,IAAI,EAAE,CAAC;MAClD;MACApH,GAAG,CAAC+B,MAAM,CAACL,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC;EACJ;AACF,CAAC;AACM,SAAS2F,MAAMA,CAACrH,GAAmB,EAAEsH,QAAmB,EAAE;EAC/D,SAAS;;EACT;EACAA,QAAQ,CAAC9G,OAAO,CAAEjB,OAAO,IAAK;IAC5ByB,IAAI,CAAChB,GAAG,EAAET,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
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.Recorder = void 0;
|
|
6
|
+
exports.disposeRecording = exports.Recorder = void 0;
|
|
7
7
|
var _types = require("../../dom/types");
|
|
8
8
|
var _utils = require("../utils");
|
|
9
9
|
var _Node = require("../Node");
|
|
@@ -11,6 +11,17 @@ var _Core = require("./Core");
|
|
|
11
11
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
12
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
13
13
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
const disposeRecording = recording => {
|
|
15
|
+
"worklet";
|
|
16
|
+
|
|
17
|
+
recording.paintPool.forEach(paint => paint.dispose());
|
|
18
|
+
recording.paintPool.length = 0;
|
|
19
|
+
if (recording.lastPicture) {
|
|
20
|
+
recording.lastPicture.dispose();
|
|
21
|
+
recording.lastPicture = null;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.disposeRecording = disposeRecording;
|
|
14
25
|
class Recorder {
|
|
15
26
|
constructor() {
|
|
16
27
|
_defineProperty(this, "commands", []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_types","require","_utils","_Node","_Core","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","Recorder","constructor","Set","cursors","push","commands","getRecording","paintPool","animationValues","processProps","props","animatedProps","hasAnimatedProps","key","prop","isSharedValue","add","undefined","command","length","saveGroup","children","group","type","CommandType","Group","restoreGroup","pop","savePaint","standalone","SavePaint","restorePaint","RestorePaint","restorePaintDeclaration","RestorePaintDeclaration","materializePaint","MaterializePaint","pushPathEffect","pathEffectType","isPathEffect","Error","PushPathEffect","pushImageFilter","imageFilterType","isImageFilter","PushImageFilter","pushColorFilter","colorFilterType","isColorFilter","PushColorFilter","pushShader","shaderType","isShader","NodeType","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","exports"],"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,IAAAA,MAAA,GAAAC,OAAA;AA8BA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAGA,IAAAG,KAAA,GAAAH,OAAA;AAAqC,SAAAI,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,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AAG,CAAC;MAAEO,IAAI,EAAEC,iBAAW,CAACmF,YAAY;MAAEjG;IAAM,CAAC,CAAC;EACrD;EAEAkG,UAAUA,CAAClG,KAAiC,EAAE;IAC5C,IAAI,CAACM,GAAG,CAAC;MAAEO,IAAI,EAAEC,iBAAW,CAACqF,UAAU;MAAEnG;IAAM,CAAC,CAAC;EACnD;EAEAoG,WAAWA,CAACpG,KAAkC,EAAE;IAC9C,IAAI,CAACM,GAAG,CAAC;MAAEO,IAAI,EAAEC,iBAAW,CAACuF,WAAW;MAAErG;IAAM,CAAC,CAAC;EACpD;EAEAsG,YAAYA,CAACtG,KAAmC,EAAE;IAChD,IAAI,CAACM,GAAG,CAAC;MAAEO,IAAI,EAAEC,iBAAW,CAACyF,YAAY;MAAEvG;IAAM,CAAC,CAAC;EACrD;EAEAwG,aAAaA,CAACxG,KAAoC,EAAE;IAClD,IAAI,CAACM,GAAG,CAAC;MAAEO,IAAI,EAAEC,iBAAW,CAAC2F,aAAa;MAAEzG;IAAM,CAAC,CAAC;EACtD;EAEA0G,SAASA,CAAC1G,KAAgC,EAAE;IAC1C,IAAI,CAACM,GAAG,CAAC;MAAEO,IAAI,EAAEC,iBAAW,CAAC6F,SAAS;MAAE3G;IAAM,CAAC,CAAC;EAClD;EAEA4G,WAAWA,CAAC5G,KAAkC,EAAE;IAC9C,IAAI,CAACM,GAAG,CAAC;MAAEO,IAAI,EAAEC,iBAAW,CAAC+F,WAAW;MAAE7G;IAAM,CAAC,CAAC;EACpD;AACF;AAAC8G,OAAA,CAAAxH,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_types","require","_utils","_Node","_Core","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","disposeRecording","recording","paintPool","forEach","paint","dispose","length","lastPicture","exports","Recorder","constructor","Set","cursors","push","commands","getRecording","animationValues","processProps","props","animatedProps","hasAnimatedProps","key","prop","isSharedValue","add","undefined","command","saveGroup","children","group","type","CommandType","Group","restoreGroup","pop","savePaint","standalone","SavePaint","restorePaint","RestorePaint","restorePaintDeclaration","RestorePaintDeclaration","materializePaint","MaterializePaint","pushPathEffect","pathEffectType","isPathEffect","Error","PushPathEffect","pushImageFilter","imageFilterType","isImageFilter","PushImageFilter","pushColorFilter","colorFilterType","isColorFilter","PushColorFilter","pushShader","shaderType","isShader","NodeType","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,IAAAA,MAAA,GAAAC,OAAA;AA8BA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAGA,IAAAG,KAAA,GAAAH,OAAA;AAAqC,SAAAI,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GAAAE,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAb,CAAA,QAAAU,CAAA,G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D,IAAI,CAACM,GAAG,CAAC;MAAEM,IAAI,EAAEC,iBAAW,CAACkF,YAAY;MAAE/F;IAAM,CAAC,CAAC;EACrD;EAEAgG,UAAUA,CAAChG,KAAiC,EAAE;IAC5C,IAAI,CAACM,GAAG,CAAC;MAAEM,IAAI,EAAEC,iBAAW,CAACoF,UAAU;MAAEjG;IAAM,CAAC,CAAC;EACnD;EAEAkG,WAAWA,CAAClG,KAAkC,EAAE;IAC9C,IAAI,CAACM,GAAG,CAAC;MAAEM,IAAI,EAAEC,iBAAW,CAACsF,WAAW;MAAEnG;IAAM,CAAC,CAAC;EACpD;EAEAoG,YAAYA,CAACpG,KAAmC,EAAE;IAChD,IAAI,CAACM,GAAG,CAAC;MAAEM,IAAI,EAAEC,iBAAW,CAACwF,YAAY;MAAErG;IAAM,CAAC,CAAC;EACrD;EAEAsG,aAAaA,CAACtG,KAAoC,EAAE;IAClD,IAAI,CAACM,GAAG,CAAC;MAAEM,IAAI,EAAEC,iBAAW,CAAC0F,aAAa;MAAEvG;IAAM,CAAC,CAAC;EACtD;EAEAwG,SAASA,CAACxG,KAAgC,EAAE;IAC1C,IAAI,CAACM,GAAG,CAAC;MAAEM,IAAI,EAAEC,iBAAW,CAAC4F,SAAS;MAAEzG;IAAM,CAAC,CAAC;EAClD;EAEA0G,WAAWA,CAAC1G,KAAkC,EAAE;IAC9C,IAAI,CAACM,GAAG,CAAC;MAAEM,IAAI,EAAEC,iBAAW,CAAC8F,WAAW;MAAE3G;IAAM,CAAC,CAAC;EACpD;AACF;AAACV,OAAA,CAAAC,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -106,14 +106,14 @@ const drawTextPath = (ctx, props) => {
|
|
|
106
106
|
const widths = font.getGlyphWidths(ids);
|
|
107
107
|
const rsx = [];
|
|
108
108
|
const meas = ctx.Skia.ContourMeasureIter(path, false, 1);
|
|
109
|
-
let cont = meas.next();
|
|
109
|
+
let cont = ctx.track(meas.next());
|
|
110
110
|
let dist = initialOffset;
|
|
111
111
|
for (let i = 0; i < text.length && cont; i++) {
|
|
112
112
|
const width = widths[i];
|
|
113
113
|
dist += width / 2;
|
|
114
114
|
if (dist > cont.length()) {
|
|
115
115
|
// jump to next contour
|
|
116
|
-
cont = meas.next();
|
|
116
|
+
cont = ctx.track(meas.next());
|
|
117
117
|
if (!cont) {
|
|
118
118
|
// We have come to the end of the path - terminate the string
|
|
119
119
|
// right here.
|
|
@@ -192,7 +192,7 @@ const drawPath = (ctx, props) => {
|
|
|
192
192
|
if (hasFillType) {
|
|
193
193
|
const builder = ctx.Skia.PathBuilder.MakeFromPath(path);
|
|
194
194
|
builder.setFillType(_types.FillType[(0, _nodes.enumKey)(fillType)]);
|
|
195
|
-
path = builder.build();
|
|
195
|
+
path = ctx.track(builder.build());
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
// Apply stroke using static Path.Stroke
|