@shopify/react-native-skia 2.2.19 → 2.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/CMakeLists.txt +2 -0
- package/apple/SkiaCVPixelBufferUtils.mm +8 -4
- package/cpp/api/JsiSkCanvas.h +22 -0
- package/cpp/api/JsiSkDispatcher.cpp +9 -0
- package/cpp/api/JsiSkDispatcher.h +149 -0
- package/cpp/api/JsiSkImage.h +27 -9
- package/cpp/api/JsiSkPicture.h +22 -1
- package/cpp/api/JsiSkSurface.h +15 -10
- package/cpp/api/recorder/Drawings.h +43 -9
- package/cpp/api/recorder/JsiRecorder.h +3 -1
- package/cpp/api/recorder/RNRecorder.h +10 -4
- package/lib/commonjs/external/reanimated/textures.js +31 -28
- package/lib/commonjs/external/reanimated/textures.js.map +1 -1
- package/lib/commonjs/renderer/Offscreen.js +1 -7
- package/lib/commonjs/renderer/Offscreen.js.map +1 -1
- package/lib/commonjs/skia/core/SVG.web.d.ts +2 -2
- package/lib/commonjs/skia/core/SVG.web.js +23 -7
- package/lib/commonjs/skia/core/SVG.web.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +7 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +4 -0
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +4 -0
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/module/external/reanimated/textures.js +33 -30
- package/lib/module/external/reanimated/textures.js.map +1 -1
- package/lib/module/renderer/Offscreen.js +1 -8
- package/lib/module/renderer/Offscreen.js.map +1 -1
- package/lib/module/skia/core/SVG.web.d.ts +2 -2
- package/lib/module/skia/core/SVG.web.js +23 -7
- package/lib/module/skia/core/SVG.web.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +7 -1
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +4 -0
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js +5 -0
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/core/SVG.web.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +4 -0
- package/lib/typescript/lib/module/skia/core/SVG.web.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +4 -0
- package/lib/typescript/src/skia/core/SVG.web.d.ts +2 -2
- package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +4 -0
- package/package.json +6 -1
- package/src/external/reanimated/textures.tsx +36 -27
- package/src/renderer/Offscreen.tsx +1 -7
- package/src/skia/core/SVG.web.ts +35 -21
- package/src/skia/web/JsiSkCanvas.ts +3 -1
- package/src/sksg/Recorder/ReanimatedRecorder.ts +4 -0
- package/cpp/api/JsiSkThreadSafeDeletion.h +0 -105
@@ -1,8 +1,6 @@
|
|
1
1
|
import { Skia } from "../skia";
|
2
2
|
import { Platform } from "../Platform";
|
3
3
|
import { SkiaSGRoot } from "../sksg/Reconciler";
|
4
|
-
|
5
|
-
// We call it main thread because on web main is JS thread
|
6
4
|
export const isOnMainThread = () => {
|
7
5
|
"worklet";
|
8
6
|
|
@@ -29,11 +27,6 @@ export const drawAsImageFromPicture = (picture, size) => {
|
|
29
27
|
canvas.drawPicture(picture);
|
30
28
|
surface.flush();
|
31
29
|
const image = surface.makeImageSnapshot();
|
32
|
-
|
33
|
-
if (!isOnMainThread() || Platform.OS === "web") {
|
34
|
-
return image.makeNonTextureImage();
|
35
|
-
} else {
|
36
|
-
return image;
|
37
|
-
}
|
30
|
+
return image.makeNonTextureImage();
|
38
31
|
};
|
39
32
|
//# sourceMappingURL=Offscreen.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Skia","Platform","SkiaSGRoot","isOnMainThread","_WORKLET","OS","drawAsPicture","element","bounds","recorder","PictureRecorder","canvas","beginRecording","root","render","drawOnCanvas","picture","finishRecordingAsPicture","unmount","drawAsImage","size","drawAsImageFromPicture","surface","Surface","MakeOffscreen","width","height","getCanvas","drawPicture","flush","image","makeImageSnapshot","makeNonTextureImage"],"sources":["Offscreen.tsx"],"sourcesContent":["import type { ReactElement } from \"react\";\n\nimport type { SkPicture, SkRect, SkSize } from \"../skia/types\";\nimport { Skia } from \"../skia\";\nimport { Platform } from \"../Platform\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\n\
|
1
|
+
{"version":3,"names":["Skia","Platform","SkiaSGRoot","isOnMainThread","_WORKLET","OS","drawAsPicture","element","bounds","recorder","PictureRecorder","canvas","beginRecording","root","render","drawOnCanvas","picture","finishRecordingAsPicture","unmount","drawAsImage","size","drawAsImageFromPicture","surface","Surface","MakeOffscreen","width","height","getCanvas","drawPicture","flush","image","makeImageSnapshot","makeNonTextureImage"],"sources":["Offscreen.tsx"],"sourcesContent":["import type { ReactElement } from \"react\";\n\nimport type { SkPicture, SkRect, SkSize } from \"../skia/types\";\nimport { Skia } from \"../skia\";\nimport { Platform } from \"../Platform\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\n\nexport const isOnMainThread = () => {\n \"worklet\";\n return (\n (typeof _WORKLET !== \"undefined\" && _WORKLET === true) ||\n Platform.OS === \"web\"\n );\n};\n\nexport const drawAsPicture = async (element: ReactElement, bounds?: SkRect) => {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(bounds);\n const root = new SkiaSGRoot(Skia);\n await root.render(element);\n root.drawOnCanvas(canvas);\n const picture = recorder.finishRecordingAsPicture();\n root.unmount();\n return picture;\n};\n\nexport const drawAsImage = async (element: ReactElement, size: SkSize) => {\n return drawAsImageFromPicture(await drawAsPicture(element), size);\n};\n\nexport const drawAsImageFromPicture = (picture: SkPicture, size: SkSize) => {\n \"worklet\";\n const surface = Skia.Surface.MakeOffscreen(size.width, size.height)!;\n const canvas = surface.getCanvas();\n canvas.drawPicture(picture);\n surface.flush();\n const image = surface.makeImageSnapshot();\n return image.makeNonTextureImage();\n};\n"],"mappings":"AAGA,SAASA,IAAI,QAAQ,SAAS;AAC9B,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,UAAU,QAAQ,oBAAoB;AAE/C,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAClC,SAAS;;EACT,OACG,OAAOC,QAAQ,KAAK,WAAW,IAAIA,QAAQ,KAAK,IAAI,IACrDH,QAAQ,CAACI,EAAE,KAAK,KAAK;AAEzB,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG,MAAAA,CAAOC,OAAqB,EAAEC,MAAe,KAAK;EAC7E,MAAMC,QAAQ,GAAGT,IAAI,CAACU,eAAe,CAAC,CAAC;EACvC,MAAMC,MAAM,GAAGF,QAAQ,CAACG,cAAc,CAACJ,MAAM,CAAC;EAC9C,MAAMK,IAAI,GAAG,IAAIX,UAAU,CAACF,IAAI,CAAC;EACjC,MAAMa,IAAI,CAACC,MAAM,CAACP,OAAO,CAAC;EAC1BM,IAAI,CAACE,YAAY,CAACJ,MAAM,CAAC;EACzB,MAAMK,OAAO,GAAGP,QAAQ,CAACQ,wBAAwB,CAAC,CAAC;EACnDJ,IAAI,CAACK,OAAO,CAAC,CAAC;EACd,OAAOF,OAAO;AAChB,CAAC;AAED,OAAO,MAAMG,WAAW,GAAG,MAAAA,CAAOZ,OAAqB,EAAEa,IAAY,KAAK;EACxE,OAAOC,sBAAsB,CAAC,MAAMf,aAAa,CAACC,OAAO,CAAC,EAAEa,IAAI,CAAC;AACnE,CAAC;AAED,OAAO,MAAMC,sBAAsB,GAAGA,CAACL,OAAkB,EAAEI,IAAY,KAAK;EAC1E,SAAS;;EACT,MAAME,OAAO,GAAGtB,IAAI,CAACuB,OAAO,CAACC,aAAa,CAACJ,IAAI,CAACK,KAAK,EAAEL,IAAI,CAACM,MAAM,CAAE;EACpE,MAAMf,MAAM,GAAGW,OAAO,CAACK,SAAS,CAAC,CAAC;EAClChB,MAAM,CAACiB,WAAW,CAACZ,OAAO,CAAC;EAC3BM,OAAO,CAACO,KAAK,CAAC,CAAC;EACf,MAAMC,KAAK,GAAGR,OAAO,CAACS,iBAAiB,CAAC,CAAC;EACzC,OAAOD,KAAK,CAACE,mBAAmB,CAAC,CAAC;AACpC,CAAC","ignoreList":[]}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import type { DataSourceParam } from "../types";
|
2
|
-
export declare const useSVG: (source: DataSourceParam, onError?: (err: Error) => void) =>
|
1
|
+
import type { DataSourceParam, SkSVG } from "../types";
|
2
|
+
export declare const useSVG: (source: DataSourceParam, onError?: (err: Error) => void) => SkSVG | null;
|
@@ -1,15 +1,31 @@
|
|
1
|
+
import { useEffect, useState } from "react";
|
1
2
|
import { Skia } from "../Skia";
|
2
3
|
export const useSVG = (source, onError) => {
|
4
|
+
const [svg, setSVG] = useState(null);
|
3
5
|
if (source === null || source === undefined) {
|
4
6
|
throw new Error(`Invalid svg data source. Got: ${source}`);
|
5
7
|
}
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
useEffect(() => {
|
9
|
+
(async () => {
|
10
|
+
let src;
|
11
|
+
if (typeof source === "string") {
|
12
|
+
src = source;
|
13
|
+
} else if (typeof source === "object" && "default" in source && typeof source.default === "string") {
|
14
|
+
src = source.default;
|
15
|
+
} else if (typeof source === "object" && "uri" in source) {
|
16
|
+
src = source.uri;
|
17
|
+
} else {
|
18
|
+
throw new Error(`Invalid svg data source. Make sure that the source resolves to a string. Got: ${JSON.stringify(source, null, 2)}`);
|
19
|
+
}
|
20
|
+
const result = await fetch(src);
|
21
|
+
const svgStr = await result.text();
|
22
|
+
const newSvg = Skia.SVG.MakeFromString(svgStr);
|
23
|
+
setSVG(newSvg);
|
24
|
+
if (newSvg === null && onError !== undefined) {
|
25
|
+
onError(new Error("Failed to create SVG from source."));
|
26
|
+
}
|
27
|
+
})();
|
28
|
+
}, [onError, source]);
|
13
29
|
return svg;
|
14
30
|
};
|
15
31
|
//# sourceMappingURL=SVG.web.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Skia","useSVG","source","onError","undefined","Error","
|
1
|
+
{"version":3,"names":["useEffect","useState","Skia","useSVG","source","onError","svg","setSVG","undefined","Error","src","default","uri","JSON","stringify","result","fetch","svgStr","text","newSvg","SVG","MakeFromString"],"sources":["SVG.web.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport type { DataSourceParam, SkSVG } from \"../types\";\n\nexport const useSVG = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => {\n const [svg, setSVG] = useState<SkSVG | null>(null);\n if (source === null || source === undefined) {\n throw new Error(`Invalid svg data source. Got: ${source}`);\n }\n useEffect(() => {\n (async () => {\n let src: string;\n if (typeof source === \"string\") {\n src = source;\n } else if (\n typeof source === \"object\" &&\n \"default\" in source &&\n typeof source.default === \"string\"\n ) {\n src = source.default;\n } else if (typeof source === \"object\" && \"uri\" in source) {\n src = source.uri;\n } else {\n throw new Error(\n `Invalid svg data source. Make sure that the source resolves to a string. Got: ${JSON.stringify(\n source,\n null,\n 2\n )}`\n );\n }\n const result = await fetch(src);\n const svgStr = await result.text();\n const newSvg = Skia.SVG.MakeFromString(svgStr);\n setSVG(newSvg);\n if (newSvg === null && onError !== undefined) {\n onError(new Error(\"Failed to create SVG from source.\"));\n }\n })();\n }, [onError, source]);\n return svg;\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QA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,CAAC,EAAE,CAAC;EACN,CAAC,EAAE,CAACJ,OAAO,EAAED,MAAM,CAAC,CAAC;EACrB,OAAOE,GAAG;AACZ,CAAC","ignoreList":[]}
|
@@ -26,7 +26,7 @@ export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements
|
|
26
26
|
drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont): void;
|
27
27
|
drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint): void;
|
28
28
|
drawGlyphs(glyphs: number[], positions: SkPoint[], x: number, y: number, font: SkFont, paint: SkPaint): void;
|
29
|
-
drawSvg(svg: SkSVG,
|
29
|
+
drawSvg(svg: SkSVG, width?: number, height?: number): void;
|
30
30
|
save(): number;
|
31
31
|
saveLayer(paint?: SkPaint, bounds?: SkRect | null, backdrop?: SkImageFilter | null, flags?: SaveLayerFlag): number;
|
32
32
|
restore(): void;
|
@@ -92,7 +92,13 @@ export class JsiSkCanvas extends HostObject {
|
|
92
92
|
drawGlyphs(glyphs, positions, x, y, font, paint) {
|
93
93
|
this.ref.drawGlyphs(glyphs, positions.map(p => [p.x, p.y]).flat(), x, y, JsiSkFont.fromValue(font), JsiSkPaint.fromValue(paint));
|
94
94
|
}
|
95
|
-
drawSvg(svg,
|
95
|
+
drawSvg(svg, width, height) {
|
96
|
+
const ctm = this.ref.getLocalToDevice();
|
97
|
+
console.log({
|
98
|
+
ctm,
|
99
|
+
width,
|
100
|
+
height
|
101
|
+
});
|
96
102
|
const image = this.CanvasKit.MakeImageFromCanvasImageSource(svg.ref);
|
97
103
|
this.ref.drawImage(image, 0, 0);
|
98
104
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isCubicSampling","getEnum","HostObject","JsiSkPaint","JsiSkRect","JsiSkRRect","JsiSkImage","JsiSkVertices","JsiSkPath","JsiSkFont","JsiSkTextBlob","JsiSkPicture","JsiSkMatrix","JsiSkImageFilter","JsiSkPoint","JsiSkRSXform","JsiSkCanvas","constructor","CanvasKit","ref","drawRect","rect","paint","fromValue","drawImage","image","x","y","drawImageRect","img","src","dest","fastSample","drawImageCubic","left","top","B","C","drawImageOptions","fm","mm","drawImageNine","center","filter","Array","from","drawImageRectCubic","drawImageRectOptions","drawPaint","drawLine","x0","y0","x1","y1","drawCircle","cx","cy","radius","drawVertices","verts","mode","drawPatch","cubics","colors","texs","map","flat","flatMap","p","undefined","restoreToCount","saveCount","drawPoints","points","drawArc","oval","startAngle","sweepAngle","useCenter","drawRRect","rrect","drawDRRect","outer","inner","drawOval","drawPath","path","drawText","str","font","drawTextBlob","blob","drawGlyphs","glyphs","positions","drawSvg","svg","_width","_height","MakeImageFromCanvasImageSource","save","saveLayer","bounds","backdrop","flags","restore","rotate","rotationInDegrees","rx","ry","scale","sx","sy","skew","translate","dx","dy","drawColor","color","blendMode","clear","clipPath","op","doAntiAlias","clipRect","clipRRect","concat","m","isArray","drawPicture","skp","drawAtlas","atlas","srcs","dsts","sampling","s","dst","cls","Uint32Array","length","i","r","g","b","a","ColorAsInt","ckSampling","FilterMode","Linear","mipmap","MipmapMode","None","BlendMode","DstOver","readPixels","srcX","srcY","imageInfo","pxInfo","width","height","colorSpace","ColorSpace","SRGB","alphaType","colorType"],"sources":["JsiSkCanvas.ts"],"sourcesContent":["import type {\n Canvas,\n CanvasKit,\n CubicResampler as CKCubicResampler,\n FilterOptions as CKFilterOptions,\n} from \"canvaskit-wasm\";\n\nimport {\n type BlendMode,\n type ClipOp,\n type FilterMode,\n type MipmapMode,\n type PointMode,\n type SaveLayerFlag,\n type ImageInfo,\n type SkCanvas,\n type SkColor,\n type SkFont,\n type SkImage,\n type SkImageFilter,\n type SkMatrix,\n type SkPaint,\n type SkPath,\n type SkPicture,\n type SkPoint,\n type SkRect,\n type InputRRect,\n type SkSVG,\n type SkTextBlob,\n type SkVertices,\n type SkRSXform,\n type CubicResampler,\n type FilterOptions,\n isCubicSampling,\n} from \"../types\";\n\nimport { getEnum, HostObject } from \"./Host\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkVertices } from \"./JsiSkVertices\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { JsiSkTextBlob } from \"./JsiSkTextBlob\";\nimport { JsiSkPicture } from \"./JsiSkPicture\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkImageFilter } from \"./JsiSkImageFilter\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport type { JsiSkSVG } from \"./JsiSkSVG\";\n\nexport class JsiSkCanvas\n extends HostObject<Canvas, \"Canvas\">\n implements SkCanvas\n{\n constructor(CanvasKit: CanvasKit, ref: Canvas) {\n super(CanvasKit, ref, \"Canvas\");\n }\n\n drawRect(rect: SkRect, paint: SkPaint) {\n this.ref.drawRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawImage(image: SkImage, x: number, y: number, paint?: SkPaint) {\n this.ref.drawImage(\n JsiSkImage.fromValue(image),\n x,\n y,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ) {\n this.ref.drawImageRect(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n JsiSkPaint.fromValue(paint),\n fastSample\n );\n }\n\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageCubic(\n JsiSkImage.fromValue(img),\n left,\n top,\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageOptions(\n JsiSkImage.fromValue(img),\n left,\n top,\n getEnum(this.CanvasKit, \"FilterMode\", fm),\n getEnum(this.CanvasKit, \"MipmapMode\", mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageNine(\n JsiSkImage.fromValue(img),\n Array.from(JsiSkRect.fromValue(this.CanvasKit, center)),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n getEnum(this.CanvasKit, \"FilterMode\", filter),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectCubic(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectOptions(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n getEnum(this.CanvasKit, \"FilterMode\", fm),\n getEnum(this.CanvasKit, \"MipmapMode\", mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawPaint(paint: SkPaint) {\n this.ref.drawPaint(JsiSkPaint.fromValue(paint));\n }\n\n drawLine(x0: number, y0: number, x1: number, y1: number, paint: SkPaint) {\n this.ref.drawLine(x0, y0, x1, y1, JsiSkPaint.fromValue(paint));\n }\n\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint) {\n this.ref.drawCircle(cx, cy, radius, JsiSkPaint.fromValue(paint));\n }\n\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {\n this.ref.drawVertices(\n JsiSkVertices.fromValue(verts),\n getEnum(this.CanvasKit, \"BlendMode\", mode),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPatch(\n cubics: SkPoint[],\n colors?: SkColor[] | null,\n texs?: SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ) {\n this.ref.drawPatch(\n cubics.map(({ x, y }) => [x, y]).flat(),\n colors,\n texs ? texs.flatMap((p) => Array.from(JsiSkPoint.fromValue(p))) : texs,\n mode ? getEnum(this.CanvasKit, \"BlendMode\", mode) : null,\n paint ? JsiSkPaint.fromValue(paint) : undefined\n );\n }\n\n restoreToCount(saveCount: number) {\n this.ref.restoreToCount(saveCount);\n }\n\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint) {\n this.ref.drawPoints(\n getEnum(this.CanvasKit, \"PointMode\", mode),\n points.map(({ x, y }) => [x, y]).flat(),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawArc(\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) {\n this.ref.drawArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngle,\n sweepAngle,\n useCenter,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawRRect(rrect: InputRRect, paint: SkPaint) {\n this.ref.drawRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawDRRect(outer: InputRRect, inner: InputRRect, paint: SkPaint) {\n this.ref.drawDRRect(\n JsiSkRRect.fromValue(this.CanvasKit, outer),\n JsiSkRRect.fromValue(this.CanvasKit, inner),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawOval(oval: SkRect, paint: SkPaint) {\n this.ref.drawOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPath(path: SkPath, paint: SkPaint) {\n this.ref.drawPath(JsiSkPath.fromValue(path), JsiSkPaint.fromValue(paint));\n }\n\n drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont) {\n this.ref.drawText(\n str,\n x,\n y,\n JsiSkPaint.fromValue(paint),\n JsiSkFont.fromValue(font)\n );\n }\n\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint) {\n this.ref.drawTextBlob(\n JsiSkTextBlob.fromValue(blob),\n x,\n y,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ) {\n this.ref.drawGlyphs(\n glyphs,\n positions.map((p) => [p.x, p.y]).flat(),\n x,\n y,\n JsiSkFont.fromValue(font),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawSvg(svg: SkSVG, _width?: number, _height?: number) {\n const image = this.CanvasKit.MakeImageFromCanvasImageSource(\n (svg as JsiSkSVG).ref\n );\n this.ref.drawImage(image, 0, 0);\n }\n\n save() {\n return this.ref.save();\n }\n\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ) {\n return this.ref.saveLayer(\n paint ? JsiSkPaint.fromValue(paint) : undefined,\n bounds ? JsiSkRect.fromValue(this.CanvasKit, bounds) : bounds,\n backdrop ? JsiSkImageFilter.fromValue(backdrop) : backdrop,\n flags\n );\n }\n\n restore() {\n this.ref.restore();\n }\n\n rotate(rotationInDegrees: number, rx: number, ry: number) {\n this.ref.rotate(rotationInDegrees, rx, ry);\n }\n\n scale(sx: number, sy: number) {\n this.ref.scale(sx, sy);\n }\n\n skew(sx: number, sy: number) {\n this.ref.skew(sx, sy);\n }\n\n translate(dx: number, dy: number) {\n this.ref.translate(dx, dy);\n }\n\n drawColor(color: SkColor, blendMode?: BlendMode) {\n this.ref.drawColor(\n color,\n blendMode ? getEnum(this.CanvasKit, \"BlendMode\", blendMode) : undefined\n );\n }\n\n clear(color: SkColor) {\n this.ref.clear(color);\n }\n\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipPath(\n JsiSkPath.fromValue(path),\n getEnum(this.CanvasKit, \"PathOp\", op),\n doAntiAlias\n );\n }\n\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n getEnum(this.CanvasKit, \"PathOp\", op),\n doAntiAlias\n );\n }\n\n clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n getEnum(this.CanvasKit, \"PathOp\", op),\n doAntiAlias\n );\n }\n\n concat(m: SkMatrix | number[]) {\n this.ref.concat(Array.isArray(m) ? m : JsiSkMatrix.fromValue(m));\n }\n\n drawPicture(skp: SkPicture) {\n this.ref.drawPicture(JsiSkPicture.fromValue(skp));\n }\n\n drawAtlas(\n atlas: SkImage,\n srcs: SkRect[],\n dsts: SkRSXform[],\n paint: SkPaint,\n blendMode?: BlendMode,\n colors?: SkColor[],\n sampling?: CubicResampler | FilterOptions\n ) {\n const src = srcs.flatMap((s) =>\n Array.from(JsiSkRect.fromValue(this.CanvasKit, s))\n );\n const dst = dsts.flatMap((s) => Array.from(JsiSkRSXform.fromValue(s)));\n let cls: Uint32Array | undefined;\n if (colors) {\n cls = new Uint32Array(colors.length);\n for (let i = 0; i < colors.length; i++) {\n const [r, g, b, a] = colors[i];\n cls[i] = this.CanvasKit.ColorAsInt(r * 255, g * 255, b * 255, a * 255);\n }\n }\n let ckSampling: CKCubicResampler | CKFilterOptions = {\n filter: this.CanvasKit.FilterMode.Linear,\n mipmap: this.CanvasKit.MipmapMode.None,\n };\n if (sampling && isCubicSampling(sampling)) {\n ckSampling = sampling;\n } else if (sampling) {\n ckSampling = {\n filter: getEnum(this.CanvasKit, \"FilterMode\", sampling.filter),\n mipmap: sampling.mipmap\n ? getEnum(this.CanvasKit, \"MipmapMode\", sampling.mipmap)\n : this.CanvasKit.MipmapMode.None,\n };\n }\n this.ref.drawAtlas(\n JsiSkImage.fromValue(atlas),\n src,\n dst,\n JsiSkPaint.fromValue(paint),\n blendMode\n ? getEnum(this.CanvasKit, \"BlendMode\", blendMode)\n : this.CanvasKit.BlendMode.DstOver,\n cls,\n ckSampling\n );\n }\n\n readPixels(srcX: number, srcY: number, imageInfo: ImageInfo) {\n const pxInfo = {\n width: imageInfo.width,\n height: imageInfo.height,\n colorSpace: this.CanvasKit.ColorSpace.SRGB,\n alphaType: getEnum(this.CanvasKit, \"AlphaType\", imageInfo.alphaType),\n colorType: getEnum(this.CanvasKit, \"ColorType\", imageInfo.colorType),\n };\n return this.ref.readPixels(srcX, srcY, pxInfo);\n }\n}\n"],"mappings":"AAOA,SA0BEA,eAAe,QACV,UAAU;AAEjB,SAASC,OAAO,EAAEC,UAAU,QAAQ,QAAQ;AAC5C,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,YAAY,QAAQ,gBAAgB;AAG7C,OAAO,MAAMC,WAAW,SACdd,UAAU,CAEpB;EACEe,WAAWA,CAACC,SAAoB,EAAEC,GAAW,EAAE;IAC7C,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,QAAQ,CA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AAM,CAAC;EAChD;AACF","ignoreList":[]}
|
1
|
+
{"version":3,"names":["isCubicSampling","getEnum","HostObject","JsiSkPaint","JsiSkRect","JsiSkRRect","JsiSkImage","JsiSkVertices","JsiSkPath","JsiSkFont","JsiSkTextBlob","JsiSkPicture","JsiSkMatrix","JsiSkImageFilter","JsiSkPoint","JsiSkRSXform","JsiSkCanvas","constructor","CanvasKit","ref","drawRect","rect","paint","fromValue","drawImage","image","x","y","drawImageRect","img","src","dest","fastSample","drawImageCubic","left","top","B","C","drawImageOptions","fm","mm","drawImageNine","center","filter","Array","from","drawImageRectCubic","drawImageRectOptions","drawPaint","drawLine","x0","y0","x1","y1","drawCircle","cx","cy","radius","drawVertices","verts","mode","drawPatch","cubics","colors","texs","map","flat","flatMap","p","undefined","restoreToCount","saveCount","drawPoints","points","drawArc","oval","startAngle","sweepAngle","useCenter","drawRRect","rrect","drawDRRect","outer","inner","drawOval","drawPath","path","drawText","str","font","drawTextBlob","blob","drawGlyphs","glyphs","positions","drawSvg","svg","width","height","ctm","getLocalToDevice","console","log","MakeImageFromCanvasImageSource","save","saveLayer","bounds","backdrop","flags","restore","rotate","rotationInDegrees","rx","ry","scale","sx","sy","skew","translate","dx","dy","drawColor","color","blendMode","clear","clipPath","op","doAntiAlias","clipRect","clipRRect","concat","m","isArray","drawPicture","skp","drawAtlas","atlas","srcs","dsts","sampling","s","dst","cls","Uint32Array","length","i","r","g","b","a","ColorAsInt","ckSampling","FilterMode","Linear","mipmap","MipmapMode","None","BlendMode","DstOver","readPixels","srcX","srcY","imageInfo","pxInfo","colorSpace","ColorSpace","SRGB","alphaType","colorType"],"sources":["JsiSkCanvas.ts"],"sourcesContent":["import type {\n Canvas,\n CanvasKit,\n CubicResampler as CKCubicResampler,\n FilterOptions as CKFilterOptions,\n} from \"canvaskit-wasm\";\n\nimport {\n type BlendMode,\n type ClipOp,\n type FilterMode,\n type MipmapMode,\n type PointMode,\n type SaveLayerFlag,\n type ImageInfo,\n type SkCanvas,\n type SkColor,\n type SkFont,\n type SkImage,\n type SkImageFilter,\n type SkMatrix,\n type SkPaint,\n type SkPath,\n type SkPicture,\n type SkPoint,\n type SkRect,\n type InputRRect,\n type SkSVG,\n type SkTextBlob,\n type SkVertices,\n type SkRSXform,\n type CubicResampler,\n type FilterOptions,\n isCubicSampling,\n} from \"../types\";\n\nimport { getEnum, HostObject } from \"./Host\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkVertices } from \"./JsiSkVertices\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { JsiSkTextBlob } from \"./JsiSkTextBlob\";\nimport { JsiSkPicture } from \"./JsiSkPicture\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkImageFilter } from \"./JsiSkImageFilter\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport type { JsiSkSVG } from \"./JsiSkSVG\";\n\nexport class JsiSkCanvas\n extends HostObject<Canvas, \"Canvas\">\n implements SkCanvas\n{\n constructor(CanvasKit: CanvasKit, ref: Canvas) {\n super(CanvasKit, ref, \"Canvas\");\n }\n\n drawRect(rect: SkRect, paint: SkPaint) {\n this.ref.drawRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawImage(image: SkImage, x: number, y: number, paint?: SkPaint) {\n this.ref.drawImage(\n JsiSkImage.fromValue(image),\n x,\n y,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ) {\n this.ref.drawImageRect(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n JsiSkPaint.fromValue(paint),\n fastSample\n );\n }\n\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageCubic(\n JsiSkImage.fromValue(img),\n left,\n top,\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageOptions(\n JsiSkImage.fromValue(img),\n left,\n top,\n getEnum(this.CanvasKit, \"FilterMode\", fm),\n getEnum(this.CanvasKit, \"MipmapMode\", mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageNine(\n JsiSkImage.fromValue(img),\n Array.from(JsiSkRect.fromValue(this.CanvasKit, center)),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n getEnum(this.CanvasKit, \"FilterMode\", filter),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectCubic(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectOptions(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n getEnum(this.CanvasKit, \"FilterMode\", fm),\n getEnum(this.CanvasKit, \"MipmapMode\", mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawPaint(paint: SkPaint) {\n this.ref.drawPaint(JsiSkPaint.fromValue(paint));\n }\n\n drawLine(x0: number, y0: number, x1: number, y1: number, paint: SkPaint) {\n this.ref.drawLine(x0, y0, x1, y1, JsiSkPaint.fromValue(paint));\n }\n\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint) {\n this.ref.drawCircle(cx, cy, radius, JsiSkPaint.fromValue(paint));\n }\n\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {\n this.ref.drawVertices(\n JsiSkVertices.fromValue(verts),\n getEnum(this.CanvasKit, \"BlendMode\", mode),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPatch(\n cubics: SkPoint[],\n colors?: SkColor[] | null,\n texs?: SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ) {\n this.ref.drawPatch(\n cubics.map(({ x, y }) => [x, y]).flat(),\n colors,\n texs ? texs.flatMap((p) => Array.from(JsiSkPoint.fromValue(p))) : texs,\n mode ? getEnum(this.CanvasKit, \"BlendMode\", mode) : null,\n paint ? JsiSkPaint.fromValue(paint) : undefined\n );\n }\n\n restoreToCount(saveCount: number) {\n this.ref.restoreToCount(saveCount);\n }\n\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint) {\n this.ref.drawPoints(\n getEnum(this.CanvasKit, \"PointMode\", mode),\n points.map(({ x, y }) => [x, y]).flat(),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawArc(\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) {\n this.ref.drawArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngle,\n sweepAngle,\n useCenter,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawRRect(rrect: InputRRect, paint: SkPaint) {\n this.ref.drawRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawDRRect(outer: InputRRect, inner: InputRRect, paint: SkPaint) {\n this.ref.drawDRRect(\n JsiSkRRect.fromValue(this.CanvasKit, outer),\n JsiSkRRect.fromValue(this.CanvasKit, inner),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawOval(oval: SkRect, paint: SkPaint) {\n this.ref.drawOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPath(path: SkPath, paint: SkPaint) {\n this.ref.drawPath(JsiSkPath.fromValue(path), JsiSkPaint.fromValue(paint));\n }\n\n drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont) {\n this.ref.drawText(\n str,\n x,\n y,\n JsiSkPaint.fromValue(paint),\n JsiSkFont.fromValue(font)\n );\n }\n\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint) {\n this.ref.drawTextBlob(\n JsiSkTextBlob.fromValue(blob),\n x,\n y,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ) {\n this.ref.drawGlyphs(\n glyphs,\n positions.map((p) => [p.x, p.y]).flat(),\n x,\n y,\n JsiSkFont.fromValue(font),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawSvg(svg: SkSVG, width?: number, height?: number) {\n const ctm = this.ref.getLocalToDevice();\n console.log({ ctm, width, height });\n const image = this.CanvasKit.MakeImageFromCanvasImageSource(\n (svg as JsiSkSVG).ref\n );\n this.ref.drawImage(image, 0, 0);\n }\n\n save() {\n return this.ref.save();\n }\n\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ) {\n return this.ref.saveLayer(\n paint ? JsiSkPaint.fromValue(paint) : undefined,\n bounds ? JsiSkRect.fromValue(this.CanvasKit, bounds) : bounds,\n backdrop ? JsiSkImageFilter.fromValue(backdrop) : backdrop,\n flags\n );\n }\n\n restore() {\n this.ref.restore();\n }\n\n rotate(rotationInDegrees: number, rx: number, ry: number) {\n this.ref.rotate(rotationInDegrees, rx, ry);\n }\n\n scale(sx: number, sy: number) {\n this.ref.scale(sx, sy);\n }\n\n skew(sx: number, sy: number) {\n this.ref.skew(sx, sy);\n }\n\n translate(dx: number, dy: number) {\n this.ref.translate(dx, dy);\n }\n\n drawColor(color: SkColor, blendMode?: BlendMode) {\n this.ref.drawColor(\n color,\n blendMode ? getEnum(this.CanvasKit, \"BlendMode\", blendMode) : undefined\n );\n }\n\n clear(color: SkColor) {\n this.ref.clear(color);\n }\n\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipPath(\n JsiSkPath.fromValue(path),\n getEnum(this.CanvasKit, \"PathOp\", op),\n doAntiAlias\n );\n }\n\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n getEnum(this.CanvasKit, \"PathOp\", op),\n doAntiAlias\n );\n }\n\n clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n getEnum(this.CanvasKit, \"PathOp\", op),\n doAntiAlias\n );\n }\n\n concat(m: SkMatrix | number[]) {\n this.ref.concat(Array.isArray(m) ? m : JsiSkMatrix.fromValue(m));\n }\n\n drawPicture(skp: SkPicture) {\n this.ref.drawPicture(JsiSkPicture.fromValue(skp));\n }\n\n drawAtlas(\n atlas: SkImage,\n srcs: SkRect[],\n dsts: SkRSXform[],\n paint: SkPaint,\n blendMode?: BlendMode,\n colors?: SkColor[],\n sampling?: CubicResampler | FilterOptions\n ) {\n const src = srcs.flatMap((s) =>\n Array.from(JsiSkRect.fromValue(this.CanvasKit, s))\n );\n const dst = dsts.flatMap((s) => Array.from(JsiSkRSXform.fromValue(s)));\n let cls: Uint32Array | undefined;\n if (colors) {\n cls = new Uint32Array(colors.length);\n for (let i = 0; i < colors.length; i++) {\n const [r, g, b, a] = colors[i];\n cls[i] = this.CanvasKit.ColorAsInt(r * 255, g * 255, b * 255, a * 255);\n }\n }\n let ckSampling: CKCubicResampler | CKFilterOptions = {\n filter: this.CanvasKit.FilterMode.Linear,\n mipmap: this.CanvasKit.MipmapMode.None,\n };\n if (sampling && isCubicSampling(sampling)) {\n ckSampling = sampling;\n } else if (sampling) {\n ckSampling = {\n filter: getEnum(this.CanvasKit, \"FilterMode\", sampling.filter),\n mipmap: sampling.mipmap\n ? getEnum(this.CanvasKit, \"MipmapMode\", sampling.mipmap)\n : this.CanvasKit.MipmapMode.None,\n };\n }\n this.ref.drawAtlas(\n JsiSkImage.fromValue(atlas),\n src,\n dst,\n JsiSkPaint.fromValue(paint),\n blendMode\n ? getEnum(this.CanvasKit, \"BlendMode\", blendMode)\n : this.CanvasKit.BlendMode.DstOver,\n cls,\n ckSampling\n );\n }\n\n readPixels(srcX: number, srcY: number, imageInfo: ImageInfo) {\n const pxInfo = {\n width: imageInfo.width,\n height: imageInfo.height,\n colorSpace: this.CanvasKit.ColorSpace.SRGB,\n alphaType: getEnum(this.CanvasKit, \"AlphaType\", imageInfo.alphaType),\n colorType: getEnum(this.CanvasKit, \"ColorType\", imageInfo.colorType),\n };\n return this.ref.readPixels(srcX, srcY, pxInfo);\n }\n}\n"],"mappings":"AAOA,SA0BEA,eAAe,QACV,UAAU;AAEjB,SAASC,OAAO,EAAEC,UAAU,QAAQ,QAAQ;AAC5C,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,YAAY,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IAC3D,MAAMC,MAAM,GAAG;MACblE,KAAK,EAAEiE,SAAS,CAACjE,KAAK;MACtBC,MAAM,EAAEgE,SAAS,CAAChE,MAAM;MACxBkE,UAAU,EAAE,IAAI,CAAClJ,SAAS,CAACmJ,UAAU,CAACC,IAAI;MAC1CC,SAAS,EAAEtK,OAAO,CAAC,IAAI,CAACiB,SAAS,EAAE,WAAW,EAAEgJ,SAAS,CAACK,SAAS,CAAC;MACpEC,SAAS,EAAEvK,OAAO,CAAC,IAAI,CAACiB,SAAS,EAAE,WAAW,EAAEgJ,SAAS,CAACM,SAAS;IACrE,CAAC;IACD,OAAO,IAAI,CAACrJ,GAAG,CAAC4I,UAAU,CAACC,IAAI,EAAEC,IAAI,EAAEE,MAAM,CAAC;EAChD;AACF","ignoreList":[]}
|
@@ -2,6 +2,10 @@ import type { SharedValue } from "react-native-reanimated";
|
|
2
2
|
import type { BaseRecorder, JsiRecorder, Skia } from "../../skia/types";
|
3
3
|
import type { PaintProps, NodeType, BlurMaskFilterProps, CTMProps, BoxProps, BoxShadowProps, ImageProps, CircleProps, PointsProps, PathProps, RectProps, RoundedRectProps, OvalProps, LineProps, PatchProps, VerticesProps, DiffRectProps, TextProps, TextPathProps, TextBlobProps, GlyphsProps, PictureProps, ImageSVGProps, ParagraphProps, AtlasProps, SkottieProps } from "../../dom/types";
|
4
4
|
import type { AnimatedProps } from "../../renderer";
|
5
|
+
/**
|
6
|
+
* Currently the recorder only work if the GPU resources (e.g Images) are owned by the main thread.
|
7
|
+
* It will crash otherwise on Ganesh (iOS/Android).
|
8
|
+
*/
|
5
9
|
export declare class ReanimatedRecorder implements BaseRecorder {
|
6
10
|
private values;
|
7
11
|
private recorder;
|
@@ -2,6 +2,11 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
2
2
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
3
3
|
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); }
|
4
4
|
import { isSharedValue } from "../utils";
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Currently the recorder only work if the GPU resources (e.g Images) are owned by the main thread.
|
8
|
+
* It will crash otherwise on Ganesh (iOS/Android).
|
9
|
+
*/
|
5
10
|
export class ReanimatedRecorder {
|
6
11
|
constructor(Skia) {
|
7
12
|
_defineProperty(this, "values", new Set());
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isSharedValue","ReanimatedRecorder","constructor","Skia","_defineProperty","Set","recorder","Recorder","processAnimationValues","props","Object","values","forEach","value","has","name","size","add","getRecorder","getSharedValues","Array","from","saveGroup","restoreGroup","savePaint","standalone","restorePaint","restorePaintDeclaration","materializePaint","pushPathEffect","pathEffectType","pushImageFilter","imageFilterType","pushColorFilter","colorFilterType","pushShader","shaderType","children","pushBlurMaskFilter","composePathEffect","composeColorFilter","composeImageFilter","saveCTM","restoreCTM","drawPaint","saveLayer","saveBackdropFilter","drawBox","boxProps","shadows","shadow","map","s","drawImage","drawCircle","drawPoints","drawPath","drawRect","drawRRect","drawOval","drawLine","drawPatch","drawVertices","drawDiffRect","drawText","drawTextPath","drawTextBlob","drawGlyphs","drawPicture","drawImageSVG","drawParagraph","drawAtlas","drawSkottie"],"sources":["ReanimatedRecorder.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type { BaseRecorder, JsiRecorder, Skia } from \"../../skia/types\";\nimport type {\n PaintProps,\n NodeType,\n BlurMaskFilterProps,\n CTMProps,\n BoxProps,\n BoxShadowProps,\n ImageProps,\n CircleProps,\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 SkottieProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer\";\nimport { isSharedValue } from \"../utils\";\n\nexport class ReanimatedRecorder implements BaseRecorder {\n private values = new Set<SharedValue<unknown>>();\n private recorder: JsiRecorder;\n\n constructor(Skia: Skia) {\n this.recorder = Skia.Recorder();\n }\n\n private processAnimationValues(props?: Record<string, unknown>) {\n if (!props) {\n return;\n }\n Object.values(props).forEach((value) => {\n if (isSharedValue(value) && !this.values.has(value)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n value.name = `variable${this.values.size}`;\n this.values.add(value as SharedValue<unknown>);\n }\n });\n }\n\n getRecorder() {\n return this.recorder;\n }\n\n getSharedValues() {\n return Array.from(this.values);\n }\n\n saveGroup(): void {\n this.recorder.saveGroup();\n }\n\n restoreGroup(): void {\n this.recorder.restoreGroup();\n }\n\n savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void {\n this.processAnimationValues(props);\n this.recorder.savePaint(props, standalone);\n }\n\n restorePaint(): void {\n this.recorder.restorePaint();\n }\n\n restorePaintDeclaration(): void {\n this.recorder.restorePaintDeclaration();\n }\n\n materializePaint(): void {\n this.recorder.materializePaint();\n }\n\n pushPathEffect(\n pathEffectType: NodeType,\n props: AnimatedProps<unknown>\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushPathEffect(pathEffectType, props);\n }\n\n pushImageFilter(\n imageFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushImageFilter(imageFilterType, props);\n }\n\n pushColorFilter(\n colorFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushColorFilter(colorFilterType, props);\n }\n\n pushShader(\n shaderType: NodeType,\n props: AnimatedProps<unknown>,\n children: number\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushShader(shaderType, props, children);\n }\n\n pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void {\n this.processAnimationValues(props);\n this.recorder.pushBlurMaskFilter(props);\n }\n\n composePathEffect(): void {\n this.recorder.composePathEffect();\n }\n\n composeColorFilter(): void {\n this.recorder.composeColorFilter();\n }\n\n composeImageFilter(): void {\n this.recorder.composeImageFilter();\n }\n\n saveCTM(props: AnimatedProps<CTMProps>): void {\n this.processAnimationValues(props);\n this.recorder.saveCTM(props);\n }\n\n restoreCTM(): void {\n this.recorder.restoreCTM();\n }\n\n drawPaint(): void {\n this.recorder.drawPaint();\n }\n\n saveLayer(): void {\n this.recorder.saveLayer();\n }\n\n saveBackdropFilter(): void {\n this.recorder.saveBackdropFilter();\n }\n\n drawBox(\n boxProps: AnimatedProps<BoxProps>,\n shadows: {\n props: BoxShadowProps;\n }[]\n ): void {\n this.processAnimationValues(boxProps);\n shadows.forEach((shadow) => {\n this.processAnimationValues(\n shadow.props as AnimatedProps<BoxShadowProps>\n );\n });\n this.recorder.drawBox(\n boxProps,\n // TODO: Fix this type BaseRecorder.drawBox()\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n shadows.map((s) => s.props)\n );\n }\n\n drawImage(props: AnimatedProps<ImageProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawImage(props);\n }\n\n drawCircle(props: AnimatedProps<CircleProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawCircle(props);\n }\n\n drawPoints(props: AnimatedProps<PointsProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPoints(props);\n }\n\n drawPath(props: AnimatedProps<PathProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPath(props);\n }\n\n drawRect(props: AnimatedProps<RectProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawRect(props);\n }\n\n drawRRect(props: AnimatedProps<RoundedRectProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawRRect(props);\n }\n\n drawOval(props: AnimatedProps<OvalProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawOval(props);\n }\n\n drawLine(props: AnimatedProps<LineProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawLine(props);\n }\n\n drawPatch(props: AnimatedProps<PatchProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPatch(props);\n }\n\n drawVertices(props: AnimatedProps<VerticesProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawVertices(props);\n }\n\n drawDiffRect(props: AnimatedProps<DiffRectProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawDiffRect(props);\n }\n\n drawText(props: AnimatedProps<TextProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawText(props);\n }\n\n drawTextPath(props: AnimatedProps<TextPathProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawTextPath(props);\n }\n\n drawTextBlob(props: AnimatedProps<TextBlobProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawTextBlob(props);\n }\n\n drawGlyphs(props: AnimatedProps<GlyphsProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawGlyphs(props);\n }\n\n drawPicture(props: AnimatedProps<PictureProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPicture(props);\n }\n\n drawImageSVG(props: AnimatedProps<ImageSVGProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawImageSVG(props);\n }\n\n drawParagraph(props: AnimatedProps<ParagraphProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawParagraph(props);\n }\n\n drawAtlas(props: AnimatedProps<AtlasProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawAtlas(props);\n }\n\n drawSkottie(props: AnimatedProps<SkottieProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawSkottie(props);\n }\n}\n"],"mappings":";;;AAgCA,SAASA,aAAa,QAAQ,UAAU;AAExC,OAAO,MAAMC,kBAAkB,CAAyB;EAItDC,WAAWA,CAACC,IAAU,EAAE;IAAAC,eAAA,iBAHP,IAAIC,GAAG,CAAuB,CAAC;IAAAD,eAAA;IAI9C,IAAI,CAACE,QAAQ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AAW,CAAC/D,KAAK,CAAC;EAClC;AACF","ignoreList":[]}
|
1
|
+
{"version":3,"names":["isSharedValue","ReanimatedRecorder","constructor","Skia","_defineProperty","Set","recorder","Recorder","processAnimationValues","props","Object","values","forEach","value","has","name","size","add","getRecorder","getSharedValues","Array","from","saveGroup","restoreGroup","savePaint","standalone","restorePaint","restorePaintDeclaration","materializePaint","pushPathEffect","pathEffectType","pushImageFilter","imageFilterType","pushColorFilter","colorFilterType","pushShader","shaderType","children","pushBlurMaskFilter","composePathEffect","composeColorFilter","composeImageFilter","saveCTM","restoreCTM","drawPaint","saveLayer","saveBackdropFilter","drawBox","boxProps","shadows","shadow","map","s","drawImage","drawCircle","drawPoints","drawPath","drawRect","drawRRect","drawOval","drawLine","drawPatch","drawVertices","drawDiffRect","drawText","drawTextPath","drawTextBlob","drawGlyphs","drawPicture","drawImageSVG","drawParagraph","drawAtlas","drawSkottie"],"sources":["ReanimatedRecorder.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type { BaseRecorder, JsiRecorder, Skia } from \"../../skia/types\";\nimport type {\n PaintProps,\n NodeType,\n BlurMaskFilterProps,\n CTMProps,\n BoxProps,\n BoxShadowProps,\n ImageProps,\n CircleProps,\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 SkottieProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer\";\nimport { isSharedValue } from \"../utils\";\n\n/**\n * Currently the recorder only work if the GPU resources (e.g Images) are owned by the main thread.\n * It will crash otherwise on Ganesh (iOS/Android).\n */\nexport class ReanimatedRecorder implements BaseRecorder {\n private values = new Set<SharedValue<unknown>>();\n private recorder: JsiRecorder;\n\n constructor(Skia: Skia) {\n this.recorder = Skia.Recorder();\n }\n\n private processAnimationValues(props?: Record<string, unknown>) {\n if (!props) {\n return;\n }\n Object.values(props).forEach((value) => {\n if (isSharedValue(value) && !this.values.has(value)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n value.name = `variable${this.values.size}`;\n this.values.add(value as SharedValue<unknown>);\n }\n });\n }\n\n getRecorder() {\n return this.recorder;\n }\n\n getSharedValues() {\n return Array.from(this.values);\n }\n\n saveGroup(): void {\n this.recorder.saveGroup();\n }\n\n restoreGroup(): void {\n this.recorder.restoreGroup();\n }\n\n savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void {\n this.processAnimationValues(props);\n this.recorder.savePaint(props, standalone);\n }\n\n restorePaint(): void {\n this.recorder.restorePaint();\n }\n\n restorePaintDeclaration(): void {\n this.recorder.restorePaintDeclaration();\n }\n\n materializePaint(): void {\n this.recorder.materializePaint();\n }\n\n pushPathEffect(\n pathEffectType: NodeType,\n props: AnimatedProps<unknown>\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushPathEffect(pathEffectType, props);\n }\n\n pushImageFilter(\n imageFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushImageFilter(imageFilterType, props);\n }\n\n pushColorFilter(\n colorFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushColorFilter(colorFilterType, props);\n }\n\n pushShader(\n shaderType: NodeType,\n props: AnimatedProps<unknown>,\n children: number\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushShader(shaderType, props, children);\n }\n\n pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void {\n this.processAnimationValues(props);\n this.recorder.pushBlurMaskFilter(props);\n }\n\n composePathEffect(): void {\n this.recorder.composePathEffect();\n }\n\n composeColorFilter(): void {\n this.recorder.composeColorFilter();\n }\n\n composeImageFilter(): void {\n this.recorder.composeImageFilter();\n }\n\n saveCTM(props: AnimatedProps<CTMProps>): void {\n this.processAnimationValues(props);\n this.recorder.saveCTM(props);\n }\n\n restoreCTM(): void {\n this.recorder.restoreCTM();\n }\n\n drawPaint(): void {\n this.recorder.drawPaint();\n }\n\n saveLayer(): void {\n this.recorder.saveLayer();\n }\n\n saveBackdropFilter(): void {\n this.recorder.saveBackdropFilter();\n }\n\n drawBox(\n boxProps: AnimatedProps<BoxProps>,\n shadows: {\n props: BoxShadowProps;\n }[]\n ): void {\n this.processAnimationValues(boxProps);\n shadows.forEach((shadow) => {\n this.processAnimationValues(\n shadow.props as AnimatedProps<BoxShadowProps>\n );\n });\n this.recorder.drawBox(\n boxProps,\n // TODO: Fix this type BaseRecorder.drawBox()\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n shadows.map((s) => s.props)\n );\n }\n\n drawImage(props: AnimatedProps<ImageProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawImage(props);\n }\n\n drawCircle(props: AnimatedProps<CircleProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawCircle(props);\n }\n\n drawPoints(props: AnimatedProps<PointsProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPoints(props);\n }\n\n drawPath(props: AnimatedProps<PathProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPath(props);\n }\n\n drawRect(props: AnimatedProps<RectProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawRect(props);\n }\n\n drawRRect(props: AnimatedProps<RoundedRectProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawRRect(props);\n }\n\n drawOval(props: AnimatedProps<OvalProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawOval(props);\n }\n\n drawLine(props: AnimatedProps<LineProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawLine(props);\n }\n\n drawPatch(props: AnimatedProps<PatchProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPatch(props);\n }\n\n drawVertices(props: AnimatedProps<VerticesProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawVertices(props);\n }\n\n drawDiffRect(props: AnimatedProps<DiffRectProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawDiffRect(props);\n }\n\n drawText(props: AnimatedProps<TextProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawText(props);\n }\n\n drawTextPath(props: AnimatedProps<TextPathProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawTextPath(props);\n }\n\n drawTextBlob(props: AnimatedProps<TextBlobProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawTextBlob(props);\n }\n\n drawGlyphs(props: AnimatedProps<GlyphsProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawGlyphs(props);\n }\n\n drawPicture(props: AnimatedProps<PictureProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPicture(props);\n }\n\n drawImageSVG(props: AnimatedProps<ImageSVGProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawImageSVG(props);\n }\n\n drawParagraph(props: AnimatedProps<ParagraphProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawParagraph(props);\n }\n\n drawAtlas(props: AnimatedProps<AtlasProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawAtlas(props);\n }\n\n drawSkottie(props: AnimatedProps<SkottieProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawSkottie(props);\n }\n}\n"],"mappings":";;;AAgCA,SAASA,aAAa,QAAQ,UAAU;;AAExC;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,CAAyB;EAItDC,WAAWA,CAACC,IAAU,EAAE;IAAAC,eAAA,iBAHP,IAAIC,GAAG,CAAuB,CAAC;IAAAD,eAAA;IAI9C,IAAI,CAACE,QAAQ,GAAGH,IAAI,CAACI,QAAQ,CAAC,CAAC;EACjC;EAEQC,sBAAsBA,CAACC,KAA+B,EAAE;IAC9D,IAAI,CAACA,KAAK,EAAE;MACV;IACF;IACAC,MAAM,CAACC,MAAM,CAACF,KAAK,CAAC,CAACG,OAAO,CAAEC,KAAK,IAAK;MACtC,IAAIb,aAAa,CAACa,KAAK,CAAC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,YAAYA,CAACzD,KAAmC,EAAQ;IACtD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACH,QAAQ,CAAC4D,YAAY,CAACzD,KAAK,CAAC;EACnC;EAEA0D,UAAUA,CAAC1D,KAAiC,EAAQ;IAClD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACH,QAAQ,CAAC6D,UAAU,CAAC1D,KAAK,CAAC;EACjC;EAEA2D,WAAWA,CAAC3D,KAAkC,EAAQ;IACpD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACH,QAAQ,CAAC8D,WAAW,CAAC3D,KAAK,CAAC;EAClC;EAEA4D,YAAYA,CAAC5D,KAAmC,EAAQ;IACtD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACH,QAAQ,CAAC+D,YAAY,CAAC5D,KAAK,CAAC;EACnC;EAEA6D,aAAaA,CAAC7D,KAAoC,EAAQ;IACxD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACH,QAAQ,CAACgE,aAAa,CAAC7D,KAAK,CAAC;EACpC;EAEA8D,SAASA,CAAC9D,KAAgC,EAAQ;IAChD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACH,QAAQ,CAACiE,SAAS,CAAC9D,KAAK,CAAC;EAChC;EAEA+D,WAAWA,CAAC/D,KAAkC,EAAQ;IACpD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACH,QAAQ,CAACkE,WAAW,CAAC/D,KAAK,CAAC;EAClC;AACF","ignoreList":[]}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export const __esModule: boolean;
|
2
|
-
export function useSVG(source: any, onError: any):
|
2
|
+
export function useSVG(source: any, onError: any): null;
|
@@ -24,7 +24,7 @@ export class JsiSkCanvas extends _Host.HostObject {
|
|
24
24
|
drawText(str: any, x: any, y: any, paint: any, font: any): void;
|
25
25
|
drawTextBlob(blob: any, x: any, y: any, paint: any): void;
|
26
26
|
drawGlyphs(glyphs: any, positions: any, x: any, y: any, font: any, paint: any): void;
|
27
|
-
drawSvg(svg: any,
|
27
|
+
drawSvg(svg: any, width: any, height: any): void;
|
28
28
|
save(): any;
|
29
29
|
saveLayer(paint: any, bounds: any, backdrop: any, flags: any): any;
|
30
30
|
restore(): void;
|
@@ -1,4 +1,8 @@
|
|
1
1
|
export const __esModule: boolean;
|
2
|
+
/**
|
3
|
+
* Currently the recorder only work if the GPU resources (e.g Images) are owned by the main thread.
|
4
|
+
* It will crash otherwise on Ganesh (iOS/Android).
|
5
|
+
*/
|
2
6
|
export class ReanimatedRecorder {
|
3
7
|
constructor(Skia: any);
|
4
8
|
recorder: any;
|
@@ -1 +1 @@
|
|
1
|
-
export function useSVG(source: any, onError: any):
|
1
|
+
export function useSVG(source: any, onError: any): null;
|
@@ -23,7 +23,7 @@ export class JsiSkCanvas extends HostObject {
|
|
23
23
|
drawText(str: any, x: any, y: any, paint: any, font: any): void;
|
24
24
|
drawTextBlob(blob: any, x: any, y: any, paint: any): void;
|
25
25
|
drawGlyphs(glyphs: any, positions: any, x: any, y: any, font: any, paint: any): void;
|
26
|
-
drawSvg(svg: any,
|
26
|
+
drawSvg(svg: any, width: any, height: any): void;
|
27
27
|
save(): any;
|
28
28
|
saveLayer(paint: any, bounds: any, backdrop: any, flags: any): any;
|
29
29
|
restore(): void;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import type { DataSourceParam } from "../types";
|
2
|
-
export declare const useSVG: (source: DataSourceParam, onError?: (err: Error) => void) =>
|
1
|
+
import type { DataSourceParam, SkSVG } from "../types";
|
2
|
+
export declare const useSVG: (source: DataSourceParam, onError?: (err: Error) => void) => SkSVG | null;
|
@@ -26,7 +26,7 @@ export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements
|
|
26
26
|
drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont): void;
|
27
27
|
drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint): void;
|
28
28
|
drawGlyphs(glyphs: number[], positions: SkPoint[], x: number, y: number, font: SkFont, paint: SkPaint): void;
|
29
|
-
drawSvg(svg: SkSVG,
|
29
|
+
drawSvg(svg: SkSVG, width?: number, height?: number): void;
|
30
30
|
save(): number;
|
31
31
|
saveLayer(paint?: SkPaint, bounds?: SkRect | null, backdrop?: SkImageFilter | null, flags?: SaveLayerFlag): number;
|
32
32
|
restore(): void;
|
@@ -2,6 +2,10 @@ import type { SharedValue } from "react-native-reanimated";
|
|
2
2
|
import type { BaseRecorder, JsiRecorder, Skia } from "../../skia/types";
|
3
3
|
import type { PaintProps, NodeType, BlurMaskFilterProps, CTMProps, BoxProps, BoxShadowProps, ImageProps, CircleProps, PointsProps, PathProps, RectProps, RoundedRectProps, OvalProps, LineProps, PatchProps, VerticesProps, DiffRectProps, TextProps, TextPathProps, TextBlobProps, GlyphsProps, PictureProps, ImageSVGProps, ParagraphProps, AtlasProps, SkottieProps } from "../../dom/types";
|
4
4
|
import type { AnimatedProps } from "../../renderer";
|
5
|
+
/**
|
6
|
+
* Currently the recorder only work if the GPU resources (e.g Images) are owned by the main thread.
|
7
|
+
* It will crash otherwise on Ganesh (iOS/Android).
|
8
|
+
*/
|
5
9
|
export declare class ReanimatedRecorder implements BaseRecorder {
|
6
10
|
private values;
|
7
11
|
private recorder;
|
package/package.json
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
"setup-skia-web": "scripts/setup-canvaskit.js"
|
9
9
|
},
|
10
10
|
"title": "React Native Skia",
|
11
|
-
"version": "2.2.
|
11
|
+
"version": "2.2.21",
|
12
12
|
"description": "High-performance React Native Graphics using Skia",
|
13
13
|
"main": "lib/module/index.js",
|
14
14
|
"react-native": "src/index.ts",
|
@@ -137,6 +137,11 @@
|
|
137
137
|
"jsSrcsDir": "src/specs",
|
138
138
|
"android": {
|
139
139
|
"javaPackageName": "com.shopify.reactnative.skia"
|
140
|
+
},
|
141
|
+
"ios": {
|
142
|
+
"componentProviders": [
|
143
|
+
"SkiaPictureViewNativeComponent"
|
144
|
+
]
|
140
145
|
}
|
141
146
|
},
|
142
147
|
"react-native-builder-bob": {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useEffect,
|
1
|
+
import { useEffect, useState } from "react";
|
2
2
|
import type { DependencyList, ReactElement } from "react";
|
3
3
|
import type { SharedValue } from "react-native-reanimated";
|
4
4
|
|
@@ -8,21 +8,45 @@ import type {
|
|
8
8
|
SkPicture,
|
9
9
|
SkSize,
|
10
10
|
} from "../../skia/types";
|
11
|
-
import {
|
12
|
-
drawAsImageFromPicture,
|
13
|
-
drawAsPicture,
|
14
|
-
} from "../../renderer/Offscreen";
|
11
|
+
import { drawAsPicture } from "../../renderer/Offscreen";
|
15
12
|
import { Skia, useImage } from "../../skia";
|
13
|
+
import { Platform } from "../../Platform";
|
16
14
|
|
17
15
|
import Rea from "./ReanimatedProxy";
|
18
16
|
|
17
|
+
const createTextureFromImage = (
|
18
|
+
texture: SharedValue<SkImage | null>,
|
19
|
+
image: SkImage
|
20
|
+
) => {
|
21
|
+
"worklet";
|
22
|
+
const surface = Skia.Surface.MakeOffscreen(image.width(), image.height());
|
23
|
+
if (!surface) {
|
24
|
+
texture.value = null;
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
const canvas = surface.getCanvas();
|
28
|
+
canvas.drawImage(image, 0, 0);
|
29
|
+
surface.flush();
|
30
|
+
texture.value = surface.makeImageSnapshot();
|
31
|
+
if (Platform.OS === "web") {
|
32
|
+
texture.value = texture.value.makeNonTextureImage();
|
33
|
+
}
|
34
|
+
};
|
35
|
+
|
19
36
|
const createTexture = (
|
20
37
|
texture: SharedValue<SkImage | null>,
|
21
38
|
picture: SkPicture,
|
22
39
|
size: SkSize
|
23
40
|
) => {
|
24
41
|
"worklet";
|
25
|
-
|
42
|
+
const surface = Skia.Surface.MakeOffscreen(size.width, size.height)!;
|
43
|
+
const canvas = surface.getCanvas();
|
44
|
+
canvas.drawPicture(picture);
|
45
|
+
surface.flush();
|
46
|
+
texture.value = surface.makeImageSnapshot();
|
47
|
+
if (Platform.OS === "web") {
|
48
|
+
texture.value = texture.value.makeNonTextureImage();
|
49
|
+
}
|
26
50
|
};
|
27
51
|
|
28
52
|
export const useTexture = (
|
@@ -61,26 +85,11 @@ export const usePictureAsTexture = (
|
|
61
85
|
|
62
86
|
export const useImageAsTexture = (source: DataSourceParam) => {
|
63
87
|
const image = useImage(source);
|
64
|
-
const
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
return { width: 0, height: 0 };
|
69
|
-
}, [image]);
|
70
|
-
const picture = useMemo(() => {
|
71
|
-
if (image) {
|
72
|
-
const recorder = Skia.PictureRecorder();
|
73
|
-
const canvas = recorder.beginRecording({
|
74
|
-
x: 0,
|
75
|
-
y: 0,
|
76
|
-
width: size.width,
|
77
|
-
height: size.height,
|
78
|
-
});
|
79
|
-
canvas.drawImage(image, 0, 0);
|
80
|
-
return recorder.finishRecordingAsPicture();
|
81
|
-
} else {
|
82
|
-
return null;
|
88
|
+
const texture = Rea.useSharedValue<SkImage | null>(null);
|
89
|
+
useEffect(() => {
|
90
|
+
if (image !== null) {
|
91
|
+
Rea.runOnUI(createTextureFromImage)(texture, image);
|
83
92
|
}
|
84
|
-
}, [
|
85
|
-
return
|
93
|
+
}, [image, texture]);
|
94
|
+
return texture;
|
86
95
|
};
|
@@ -5,7 +5,6 @@ import { Skia } from "../skia";
|
|
5
5
|
import { Platform } from "../Platform";
|
6
6
|
import { SkiaSGRoot } from "../sksg/Reconciler";
|
7
7
|
|
8
|
-
// We call it main thread because on web main is JS thread
|
9
8
|
export const isOnMainThread = () => {
|
10
9
|
"worklet";
|
11
10
|
return (
|
@@ -36,10 +35,5 @@ export const drawAsImageFromPicture = (picture: SkPicture, size: SkSize) => {
|
|
36
35
|
canvas.drawPicture(picture);
|
37
36
|
surface.flush();
|
38
37
|
const image = surface.makeImageSnapshot();
|
39
|
-
|
40
|
-
if (!isOnMainThread() || Platform.OS === "web") {
|
41
|
-
return image.makeNonTextureImage();
|
42
|
-
} else {
|
43
|
-
return image;
|
44
|
-
}
|
38
|
+
return image.makeNonTextureImage();
|
45
39
|
};
|