@shopify/react-native-skia 1.12.1 → 1.12.2
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/apple/MetalContext.h +129 -0
- package/apple/MetalContext.mm +34 -0
- package/apple/MetalWindowContext.h +39 -0
- package/apple/MetalWindowContext.mm +64 -0
- package/apple/RNSkApplePlatformContext.h +79 -0
- package/apple/RNSkApplePlatformContext.mm +303 -0
- package/apple/RNSkAppleVideo.h +51 -0
- package/apple/RNSkAppleVideo.mm +137 -0
- package/apple/RNSkAppleView.h +37 -0
- package/apple/RNSkAppleView.mm +35 -0
- package/apple/RNSkMetalCanvasProvider.h +38 -0
- package/apple/RNSkMetalCanvasProvider.mm +108 -0
- package/apple/RNSkiaModule.h +20 -0
- package/apple/RNSkiaModule.mm +55 -0
- package/apple/SkiaCVPixelBufferUtils.h +119 -0
- package/apple/SkiaCVPixelBufferUtils.mm +344 -0
- package/apple/SkiaManager.h +25 -0
- package/apple/SkiaManager.mm +62 -0
- package/apple/SkiaPictureView.h +7 -0
- package/apple/SkiaPictureView.mm +66 -0
- package/apple/SkiaPictureViewManager.h +8 -0
- package/apple/SkiaPictureViewManager.mm +55 -0
- package/apple/SkiaUIView.h +45 -0
- package/apple/SkiaUIView.mm +172 -0
- package/apple/ViewScreenshotService.h +25 -0
- package/apple/ViewScreenshotService.mm +89 -0
- package/lib/commonjs/skia/web/Host.d.ts +3 -3
- package/lib/commonjs/skia/web/Host.js +16 -4
- package/lib/commonjs/skia/web/Host.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +15 -15
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.js +2 -2
- package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.js +6 -6
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +3 -3
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPaint.js +3 -3
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js +4 -4
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPicture.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js +5 -5
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
- package/lib/module/skia/web/Host.d.ts +3 -3
- package/lib/module/skia/web/Host.js +16 -4
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +15 -15
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkColorFilterFactory.js +1 -1
- package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkFont.js +2 -2
- package/lib/module/skia/web/JsiSkFont.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.js +6 -6
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.js +2 -2
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFilterFactory.js +3 -3
- package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkMaskFilterFactory.js +1 -1
- package/lib/module/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.js +3 -3
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.js +4 -4
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathEffectFactory.js +1 -1
- package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathFactory.js +1 -1
- package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPicture.js +1 -1
- package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/module/skia/web/JsiSkShaderFactory.js +5 -5
- package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkVerticesFactory.js +1 -1
- package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/Host.d.ts +2 -2
- package/lib/typescript/lib/module/skia/web/Host.d.ts +2 -2
- package/lib/typescript/src/skia/web/Host.d.ts +3 -3
- package/package.json +2 -2
- package/src/skia/__tests__/Enums.spec.ts +34 -0
- package/src/skia/web/Host.ts +24 -7
- package/src/skia/web/JsiSkCanvas.ts +17 -17
- package/src/skia/web/JsiSkColorFilterFactory.ts +1 -1
- package/src/skia/web/JsiSkFont.ts +2 -2
- package/src/skia/web/JsiSkImage.ts +14 -10
- package/src/skia/web/JsiSkImageFactory.ts +2 -2
- package/src/skia/web/JsiSkImageFilterFactory.ts +4 -4
- package/src/skia/web/JsiSkMaskFilterFactory.ts +1 -1
- package/src/skia/web/JsiSkPaint.ts +3 -3
- package/src/skia/web/JsiSkPath.ts +4 -4
- package/src/skia/web/JsiSkPathEffectFactory.ts +1 -1
- package/src/skia/web/JsiSkPathFactory.ts +1 -1
- package/src/skia/web/JsiSkPicture.ts +3 -3
- package/src/skia/web/JsiSkShaderFactory.ts +5 -5
- package/src/skia/web/JsiSkVerticesFactory.ts +1 -1
@@ -13,7 +13,7 @@ const concat = (...arrays) => {
|
|
13
13
|
}
|
14
14
|
return result;
|
15
15
|
};
|
16
|
-
export const MakeVertices = (CanvasKit, mode, positions, textureCoordinates, colors, indices, isVolatile) => new JsiSkVertices(CanvasKit, CanvasKit.MakeVertices(getEnum(CanvasKit
|
16
|
+
export const MakeVertices = (CanvasKit, mode, positions, textureCoordinates, colors, indices, isVolatile) => new JsiSkVertices(CanvasKit, CanvasKit.MakeVertices(getEnum(CanvasKit, "VertexMode", mode), positions.map(({
|
17
17
|
x,
|
18
18
|
y
|
19
19
|
}) => [x, y]).flat(), (textureCoordinates || []).map(({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["JsiSkVertices","getEnum","concat","arrays","totalLength","arr","length","result","Float32Array","offset","set","MakeVertices","CanvasKit","mode","positions","textureCoordinates","colors","indices","isVolatile","
|
1
|
+
{"version":3,"names":["JsiSkVertices","getEnum","concat","arrays","totalLength","arr","length","result","Float32Array","offset","set","MakeVertices","CanvasKit","mode","positions","textureCoordinates","colors","indices","isVolatile","map","x","y","flat","reduce","a","c"],"sources":["JsiSkVerticesFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkColor, SkPoint, VertexMode } from \"../types\";\n\nimport { JsiSkVertices } from \"./JsiSkVertices\";\nimport { getEnum } from \"./Host\";\n\nconst concat = (...arrays: Float32Array[]) => {\n let totalLength = 0;\n for (const arr of arrays) {\n totalLength += arr.length;\n }\n const result = new Float32Array(totalLength);\n let offset = 0;\n for (const arr of arrays) {\n result.set(arr, offset);\n offset += arr.length;\n }\n return result;\n};\n\nexport const MakeVertices = (\n CanvasKit: CanvasKit,\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n) =>\n new JsiSkVertices(\n CanvasKit,\n CanvasKit.MakeVertices(\n getEnum(CanvasKit, \"VertexMode\", mode),\n positions.map(({ x, y }) => [x, y]).flat(),\n (textureCoordinates || []).map(({ x, y }) => [x, y]).flat(),\n !colors ? null : colors.reduce((a, c) => concat(a, c)),\n indices,\n isVolatile\n )\n );\n"],"mappings":"AAIA,SAASA,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,OAAO,QAAQ,QAAQ;AAEhC,MAAMC,MAAM,GAAGA,CAAC,GAAGC,MAAsB,KAAK;EAC5C,IAAIC,WAAW,GAAG,CAAC;EACnB,KAAK,MAAMC,GAAG,IAAIF,MAAM,EAAE;IACxBC,WAAW,IAAIC,GAAG,CAACC,MAAM;EAC3B;EACA,MAAMC,MAAM,GAAG,IAAIC,YAAY,CAACJ,WAAW,CAAC;EAC5C,IAAIK,MAAM,GAAG,CAAC;EACd,KAAK,MAAMJ,GAAG,IAAIF,MAAM,EAAE;IACxBI,MAAM,CAACG,GAAG,CAACL,GAAG,EAAEI,MAAM,CAAC;IACvBA,MAAM,IAAIJ,GAAG,CAACC,MAAM;EACtB;EACA,OAAOC,MAAM;AACf,CAAC;AAED,OAAO,MAAMI,YAAY,GAAGA,CAC1BC,SAAoB,EACpBC,IAAgB,EAChBC,SAAoB,EACpBC,kBAAqC,EACrCC,MAAkB,EAClBC,OAAyB,EACzBC,UAAoB,KAEpB,IAAIlB,aAAa,CACfY,SAAS,EACTA,SAAS,CAACD,YAAY,CACpBV,OAAO,CAACW,SAAS,EAAE,YAAY,EAAEC,IAAI,CAAC,EACtCC,SAAS,CAACK,GAAG,CAAC,CAAC;EAAEC,CAAC;EAAEC;AAAE,CAAC,KAAK,CAACD,CAAC,EAAEC,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,EAC1C,CAACP,kBAAkB,IAAI,EAAE,EAAEI,GAAG,CAAC,CAAC;EAAEC,CAAC;EAAEC;AAAE,CAAC,KAAK,CAACD,CAAC,EAAEC,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,EAC3D,CAACN,MAAM,GAAG,IAAI,GAAGA,MAAM,CAACO,MAAM,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKvB,MAAM,CAACsB,CAAC,EAAEC,CAAC,CAAC,CAAC,EACtDR,OAAO,EACPC,UACF,CACF,CAAC","ignoreList":[]}
|
@@ -12,5 +12,5 @@ export class BaseHostObject extends Host {
|
|
12
12
|
export class HostObject extends BaseHostObject {
|
13
13
|
static fromValue(value: any): any;
|
14
14
|
}
|
15
|
-
export function getEnum(
|
16
|
-
export function optEnum(
|
15
|
+
export function getEnum(CanvasKit: any, name: any, v: any): any;
|
16
|
+
export function optEnum(CanvasKit: any, name: any, v: any): any;
|
@@ -11,5 +11,5 @@ export class BaseHostObject extends Host {
|
|
11
11
|
export class HostObject extends BaseHostObject {
|
12
12
|
static fromValue(value: any): any;
|
13
13
|
}
|
14
|
-
export function getEnum(
|
15
|
-
export function optEnum(
|
14
|
+
export function getEnum(CanvasKit: any, name: any, v: any): any;
|
15
|
+
export function optEnum(CanvasKit: any, name: any, v: any): any;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { CanvasKit, EmbindEnumEntity
|
1
|
+
import type { CanvasKit, EmbindEnumEntity } from "canvaskit-wasm";
|
2
2
|
import type { SkJSIInstance } from "../types";
|
3
3
|
export declare const throwNotImplementedOnRNWeb: <T>() => T;
|
4
4
|
export declare abstract class Host {
|
@@ -14,5 +14,5 @@ export declare abstract class BaseHostObject<T, N extends string> extends Host i
|
|
14
14
|
export declare abstract class HostObject<T, N extends string> extends BaseHostObject<T, N> {
|
15
15
|
static fromValue<T>(value: SkJSIInstance<string>): T;
|
16
16
|
}
|
17
|
-
export declare const getEnum: (
|
18
|
-
export declare const optEnum: (
|
17
|
+
export declare const getEnum: (CanvasKit: CanvasKit, name: keyof CanvasKit, v: number) => EmbindEnumEntity;
|
18
|
+
export declare const optEnum: (CanvasKit: CanvasKit, name: keyof CanvasKit, v: number | undefined) => EmbindEnumEntity | undefined;
|
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": "1.12.
|
11
|
+
"version": "1.12.2",
|
12
12
|
"description": "High-performance React Native Graphics using Skia",
|
13
13
|
"main": "lib/module/index.js",
|
14
14
|
"react-native": "src/index.ts",
|
@@ -29,7 +29,7 @@
|
|
29
29
|
"jestSetup.mjs",
|
30
30
|
"jestEnv.mjs",
|
31
31
|
"cpp/**/*.{h,cpp}",
|
32
|
-
"
|
32
|
+
"apple/**",
|
33
33
|
"libs/apple/*.xcframework/**",
|
34
34
|
"react-native-skia.podspec",
|
35
35
|
"scripts/setup-canvaskit.js",
|
@@ -111,4 +111,38 @@ describe("Enums", () => {
|
|
111
111
|
);
|
112
112
|
checkEnum(ClipOp, CanvasKit.ClipOp);
|
113
113
|
});
|
114
|
+
it("Should match color types with CanvasKit", () => {
|
115
|
+
const { CanvasKit } = setupSkia();
|
116
|
+
//expect(CanvasKit.ColorType.Unknown.value).toBe(ColorType.Unknown);
|
117
|
+
expect(CanvasKit.ColorType.Alpha_8.value).toBe(ColorTypeCanvasKit.Alpha_8);
|
118
|
+
expect(CanvasKit.ColorType.RGB_565.value).toBe(ColorTypeCanvasKit.RGB_565);
|
119
|
+
//expect(CanvasKit.ColorType.ARGB_4444.value).toBe(ColorType.ARGB_4444);
|
120
|
+
expect(CanvasKit.ColorType.RGBA_8888.value).toBe(
|
121
|
+
ColorTypeCanvasKit.RGBA_8888
|
122
|
+
);
|
123
|
+
//expect(CanvasKit.ColorType.RGB_888x.value).toBe(ColorType.RGB_888x);
|
124
|
+
expect(CanvasKit.ColorType.BGRA_8888.value).toBe(
|
125
|
+
ColorTypeCanvasKit.BGRA_8888
|
126
|
+
);
|
127
|
+
expect(CanvasKit.ColorType.RGBA_1010102.value).toBe(
|
128
|
+
ColorTypeCanvasKit.RGBA_1010102
|
129
|
+
);
|
130
|
+
//expect(CanvasKit.ColorType.BGRA_1010102.value).toBe(ColorType.BGRA_1010102);
|
131
|
+
expect(CanvasKit.ColorType.RGB_101010x.value).toBe(
|
132
|
+
ColorTypeCanvasKit.RGB_101010x
|
133
|
+
);
|
134
|
+
//expect(CanvasKit.ColorType.BGR_101010x.value).toBe(ColorType.BGR_101010x);
|
135
|
+
//expect(CanvasKit.ColorType.BGR_101010x_XR.value).toBe(ColorType.BGR_101010x_XR);
|
136
|
+
//expect(CanvasKit.ColorType.BGRA_10101010_XR.value).toBe(ColorType.BGRA_10101010_XR);
|
137
|
+
//expect(CanvasKit.ColorType.RGBA_10x6.value).toBe(ColorType.RGBA_10x6);
|
138
|
+
expect(CanvasKit.ColorType.Gray_8.value).toBe(ColorTypeCanvasKit.Gray_8);
|
139
|
+
//expect(CanvasKit.ColorType.RGBA_F16Norm.value).toBe(ColorType.RGBA_F16Norm);
|
140
|
+
expect(CanvasKit.ColorType.RGBA_F16.value).toBe(
|
141
|
+
ColorTypeCanvasKit.RGBA_F16
|
142
|
+
);
|
143
|
+
//expect(CanvasKit.ColorType.RGB_F16F16F16x.value).toBe(ColorType.RGB_F16F16F16x);
|
144
|
+
expect(CanvasKit.ColorType.RGBA_F32.value).toBe(
|
145
|
+
ColorTypeCanvasKit.RGBA_F32
|
146
|
+
);
|
147
|
+
});
|
114
148
|
});
|
package/src/skia/web/Host.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { CanvasKit, EmbindEnumEntity
|
1
|
+
import type { CanvasKit, EmbindEnumEntity } from "canvaskit-wasm";
|
2
2
|
|
3
3
|
import type { SkJSIInstance } from "../types";
|
4
4
|
|
@@ -42,11 +42,28 @@ export abstract class HostObject<T, N extends string> extends BaseHostObject<
|
|
42
42
|
}
|
43
43
|
}
|
44
44
|
|
45
|
-
export const getEnum = (
|
46
|
-
|
45
|
+
export const getEnum = (
|
46
|
+
CanvasKit: CanvasKit,
|
47
|
+
name: keyof CanvasKit,
|
48
|
+
v: number
|
49
|
+
): EmbindEnumEntity => {
|
50
|
+
const e = CanvasKit[name];
|
51
|
+
if (typeof e !== "function") {
|
52
|
+
throw new Error(`${name} is not an number`);
|
53
|
+
}
|
54
|
+
const result = Object.values(e).find(({ value }) => value === v);
|
55
|
+
if (!result) {
|
56
|
+
throw new Error(
|
57
|
+
`Enum ${name} does not have value ${v} on React Native Web`
|
58
|
+
);
|
59
|
+
}
|
60
|
+
return result;
|
61
|
+
};
|
47
62
|
|
48
63
|
export const optEnum = (
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
64
|
+
CanvasKit: CanvasKit,
|
65
|
+
name: keyof CanvasKit,
|
66
|
+
v: number | undefined
|
67
|
+
): EmbindEnumEntity | undefined => {
|
68
|
+
return v === undefined ? undefined : getEnum(CanvasKit, name, v);
|
69
|
+
};
|
@@ -124,8 +124,8 @@ export class JsiSkCanvas
|
|
124
124
|
JsiSkImage.fromValue(img),
|
125
125
|
left,
|
126
126
|
top,
|
127
|
-
getEnum(this.CanvasKit
|
128
|
-
getEnum(this.CanvasKit
|
127
|
+
getEnum(this.CanvasKit, "FilterMode", fm),
|
128
|
+
getEnum(this.CanvasKit, "MipmapMode", mm),
|
129
129
|
paint ? JsiSkPaint.fromValue(paint) : paint
|
130
130
|
);
|
131
131
|
}
|
@@ -141,7 +141,7 @@ export class JsiSkCanvas
|
|
141
141
|
JsiSkImage.fromValue(img),
|
142
142
|
Array.from(JsiSkRect.fromValue(this.CanvasKit, center)),
|
143
143
|
JsiSkRect.fromValue(this.CanvasKit, dest),
|
144
|
-
getEnum(this.CanvasKit
|
144
|
+
getEnum(this.CanvasKit, "FilterMode", filter),
|
145
145
|
paint ? JsiSkPaint.fromValue(paint) : paint
|
146
146
|
);
|
147
147
|
}
|
@@ -176,8 +176,8 @@ export class JsiSkCanvas
|
|
176
176
|
JsiSkImage.fromValue(img),
|
177
177
|
JsiSkRect.fromValue(this.CanvasKit, src),
|
178
178
|
JsiSkRect.fromValue(this.CanvasKit, dest),
|
179
|
-
getEnum(this.CanvasKit
|
180
|
-
getEnum(this.CanvasKit
|
179
|
+
getEnum(this.CanvasKit, "FilterMode", fm),
|
180
|
+
getEnum(this.CanvasKit, "MipmapMode", mm),
|
181
181
|
paint ? JsiSkPaint.fromValue(paint) : paint
|
182
182
|
);
|
183
183
|
}
|
@@ -197,7 +197,7 @@ export class JsiSkCanvas
|
|
197
197
|
drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {
|
198
198
|
this.ref.drawVertices(
|
199
199
|
JsiSkVertices.fromValue(verts),
|
200
|
-
getEnum(this.CanvasKit
|
200
|
+
getEnum(this.CanvasKit, "BlendMode", mode),
|
201
201
|
JsiSkPaint.fromValue(paint)
|
202
202
|
);
|
203
203
|
}
|
@@ -213,7 +213,7 @@ export class JsiSkCanvas
|
|
213
213
|
cubics.map(({ x, y }) => [x, y]).flat(),
|
214
214
|
colors,
|
215
215
|
texs ? texs.flatMap((p) => Array.from(JsiSkPoint.fromValue(p))) : texs,
|
216
|
-
mode ? getEnum(this.CanvasKit
|
216
|
+
mode ? getEnum(this.CanvasKit, "BlendMode", mode) : null,
|
217
217
|
paint ? JsiSkPaint.fromValue(paint) : undefined
|
218
218
|
);
|
219
219
|
}
|
@@ -224,7 +224,7 @@ export class JsiSkCanvas
|
|
224
224
|
|
225
225
|
drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint) {
|
226
226
|
this.ref.drawPoints(
|
227
|
-
getEnum(this.CanvasKit
|
227
|
+
getEnum(this.CanvasKit, "PointMode", mode),
|
228
228
|
points.map(({ x, y }) => [x, y]).flat(),
|
229
229
|
JsiSkPaint.fromValue(paint)
|
230
230
|
);
|
@@ -357,7 +357,7 @@ export class JsiSkCanvas
|
|
357
357
|
drawColor(color: SkColor, blendMode?: BlendMode) {
|
358
358
|
this.ref.drawColor(
|
359
359
|
color,
|
360
|
-
blendMode ? getEnum(this.CanvasKit
|
360
|
+
blendMode ? getEnum(this.CanvasKit, "BlendMode", blendMode) : undefined
|
361
361
|
);
|
362
362
|
}
|
363
363
|
|
@@ -368,7 +368,7 @@ export class JsiSkCanvas
|
|
368
368
|
clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {
|
369
369
|
this.ref.clipPath(
|
370
370
|
JsiSkPath.fromValue(path),
|
371
|
-
getEnum(this.CanvasKit
|
371
|
+
getEnum(this.CanvasKit, "PathOp", op),
|
372
372
|
doAntiAlias
|
373
373
|
);
|
374
374
|
}
|
@@ -376,7 +376,7 @@ export class JsiSkCanvas
|
|
376
376
|
clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {
|
377
377
|
this.ref.clipRect(
|
378
378
|
JsiSkRect.fromValue(this.CanvasKit, rect),
|
379
|
-
getEnum(this.CanvasKit
|
379
|
+
getEnum(this.CanvasKit, "PathOp", op),
|
380
380
|
doAntiAlias
|
381
381
|
);
|
382
382
|
}
|
@@ -384,7 +384,7 @@ export class JsiSkCanvas
|
|
384
384
|
clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean) {
|
385
385
|
this.ref.clipRRect(
|
386
386
|
JsiSkRRect.fromValue(this.CanvasKit, rrect),
|
387
|
-
getEnum(this.CanvasKit
|
387
|
+
getEnum(this.CanvasKit, "PathOp", op),
|
388
388
|
doAntiAlias
|
389
389
|
);
|
390
390
|
}
|
@@ -426,9 +426,9 @@ export class JsiSkCanvas
|
|
426
426
|
ckSampling = sampling;
|
427
427
|
} else if (sampling) {
|
428
428
|
ckSampling = {
|
429
|
-
filter: getEnum(this.CanvasKit
|
429
|
+
filter: getEnum(this.CanvasKit, "FilterMode", sampling.filter),
|
430
430
|
mipmap: sampling.mipmap
|
431
|
-
? getEnum(this.CanvasKit
|
431
|
+
? getEnum(this.CanvasKit, "MipmapMode", sampling.mipmap)
|
432
432
|
: this.CanvasKit.MipmapMode.None,
|
433
433
|
};
|
434
434
|
}
|
@@ -438,7 +438,7 @@ export class JsiSkCanvas
|
|
438
438
|
dst,
|
439
439
|
JsiSkPaint.fromValue(paint),
|
440
440
|
blendMode
|
441
|
-
? getEnum(this.CanvasKit
|
441
|
+
? getEnum(this.CanvasKit, "BlendMode", blendMode)
|
442
442
|
: this.CanvasKit.BlendMode.DstOver,
|
443
443
|
cls,
|
444
444
|
ckSampling
|
@@ -450,8 +450,8 @@ export class JsiSkCanvas
|
|
450
450
|
width: imageInfo.width,
|
451
451
|
height: imageInfo.height,
|
452
452
|
colorSpace: this.CanvasKit.ColorSpace.SRGB,
|
453
|
-
alphaType: getEnum(this.CanvasKit
|
454
|
-
colorType: getEnum(this.CanvasKit
|
453
|
+
alphaType: getEnum(this.CanvasKit, "AlphaType", imageInfo.alphaType),
|
454
|
+
colorType: getEnum(this.CanvasKit, "ColorType", imageInfo.colorType),
|
455
455
|
};
|
456
456
|
return this.ref.readPixels(srcX, srcY, pxInfo);
|
457
457
|
}
|
@@ -100,7 +100,7 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
|
|
100
100
|
}
|
101
101
|
|
102
102
|
setEdging(edging: FontEdging) {
|
103
|
-
this.ref.setEdging(getEnum(this.CanvasKit
|
103
|
+
this.ref.setEdging(getEnum(this.CanvasKit, "FontEdging", edging));
|
104
104
|
}
|
105
105
|
|
106
106
|
setEmbeddedBitmaps(embeddedBitmaps: boolean) {
|
@@ -108,7 +108,7 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
|
|
108
108
|
}
|
109
109
|
|
110
110
|
setHinting(hinting: FontHinting) {
|
111
|
-
this.ref.setHinting(getEnum(this.CanvasKit
|
111
|
+
this.ref.setHinting(getEnum(this.CanvasKit, "FontHinting", hinting));
|
112
112
|
}
|
113
113
|
|
114
114
|
setLinearMetrics(linearMetrics: boolean) {
|
@@ -77,10 +77,10 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
|
|
77
77
|
return new JsiSkShader(
|
78
78
|
this.CanvasKit,
|
79
79
|
this.ref.makeShaderOptions(
|
80
|
-
getEnum(this.CanvasKit
|
81
|
-
getEnum(this.CanvasKit
|
82
|
-
getEnum(this.CanvasKit
|
83
|
-
getEnum(this.CanvasKit
|
80
|
+
getEnum(this.CanvasKit, "TileMode", tx),
|
81
|
+
getEnum(this.CanvasKit, "TileMode", ty),
|
82
|
+
getEnum(this.CanvasKit, "FilterMode", fm),
|
83
|
+
getEnum(this.CanvasKit, "MipmapMode", mm),
|
84
84
|
localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined
|
85
85
|
)
|
86
86
|
);
|
@@ -96,8 +96,8 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
|
|
96
96
|
return new JsiSkShader(
|
97
97
|
this.CanvasKit,
|
98
98
|
this.ref.makeShaderCubic(
|
99
|
-
getEnum(this.CanvasKit
|
100
|
-
getEnum(this.CanvasKit
|
99
|
+
getEnum(this.CanvasKit, "TileMode", tx),
|
100
|
+
getEnum(this.CanvasKit, "TileMode", ty),
|
101
101
|
B,
|
102
102
|
C,
|
103
103
|
localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined
|
@@ -109,11 +109,13 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
|
|
109
109
|
let result: Uint8Array | null;
|
110
110
|
if (fmt && quality) {
|
111
111
|
result = this.ref.encodeToBytes(
|
112
|
-
getEnum(this.CanvasKit
|
112
|
+
getEnum(this.CanvasKit, "ImageFormat", fmt),
|
113
113
|
quality
|
114
114
|
);
|
115
115
|
} else if (fmt) {
|
116
|
-
result = this.ref.encodeToBytes(
|
116
|
+
result = this.ref.encodeToBytes(
|
117
|
+
getEnum(this.CanvasKit, "ImageFormat", fmt)
|
118
|
+
);
|
117
119
|
} else {
|
118
120
|
result = this.ref.encodeToBytes();
|
119
121
|
}
|
@@ -137,11 +139,13 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
|
|
137
139
|
width: imageInfo?.width ?? info.width,
|
138
140
|
height: imageInfo?.height ?? info.height,
|
139
141
|
alphaType: getEnum(
|
140
|
-
this.CanvasKit
|
142
|
+
this.CanvasKit,
|
143
|
+
"AlphaType",
|
141
144
|
(imageInfo ?? info).alphaType
|
142
145
|
),
|
143
146
|
colorType: getEnum(
|
144
|
-
this.CanvasKit
|
147
|
+
this.CanvasKit,
|
148
|
+
"ColorType",
|
145
149
|
(imageInfo ?? info).colorType
|
146
150
|
),
|
147
151
|
};
|
@@ -83,9 +83,9 @@ export class JsiSkImageFactory extends Host implements ImageFactory {
|
|
83
83
|
// see toSkImageInfo() from canvaskit
|
84
84
|
const image = this.CanvasKit.MakeImage(
|
85
85
|
{
|
86
|
-
alphaType: getEnum(this.CanvasKit
|
86
|
+
alphaType: getEnum(this.CanvasKit, "AlphaType", info.alphaType),
|
87
87
|
colorSpace: this.CanvasKit.ColorSpace.SRGB,
|
88
|
-
colorType: getEnum(this.CanvasKit
|
88
|
+
colorType: getEnum(this.CanvasKit, "ColorType", info.colorType),
|
89
89
|
height: info.height,
|
90
90
|
width: info.width,
|
91
91
|
},
|
@@ -42,8 +42,8 @@ export class JsiSkImageFilterFactory
|
|
42
42
|
const inputFilter =
|
43
43
|
input === null ? null : JsiSkImageFilter.fromValue<ImageFilter>(input);
|
44
44
|
const filter = this.CanvasKit.ImageFilter.MakeDisplacementMap(
|
45
|
-
getEnum(this.CanvasKit
|
46
|
-
getEnum(this.CanvasKit
|
45
|
+
getEnum(this.CanvasKit, "ColorChannel", channelX),
|
46
|
+
getEnum(this.CanvasKit, "ColorChannel", channelY),
|
47
47
|
scale,
|
48
48
|
JsiSkImageFilter.fromValue(in1),
|
49
49
|
inputFilter
|
@@ -69,7 +69,7 @@ export class JsiSkImageFilterFactory
|
|
69
69
|
this.CanvasKit.ImageFilter.MakeBlur(
|
70
70
|
sigmaX,
|
71
71
|
sigmaY,
|
72
|
-
getEnum(this.CanvasKit
|
72
|
+
getEnum(this.CanvasKit, "TileMode", mode),
|
73
73
|
input === null ? null : JsiSkImageFilter.fromValue(input)
|
74
74
|
)
|
75
75
|
);
|
@@ -189,7 +189,7 @@ export class JsiSkImageFilterFactory
|
|
189
189
|
throwNotImplementedOnRNWeb<SkImageFilter>();
|
190
190
|
}
|
191
191
|
const filter = this.CanvasKit.ImageFilter.MakeBlend(
|
192
|
-
getEnum(this.CanvasKit
|
192
|
+
getEnum(this.CanvasKit, "BlendMode", mode),
|
193
193
|
JsiSkImageFilter.fromValue(background),
|
194
194
|
inputFilter
|
195
195
|
);
|
@@ -15,7 +15,7 @@ export class JsiSkMaskFilterFactory extends Host implements MaskFilterFactory {
|
|
15
15
|
return new JsiSkMaskFilter(
|
16
16
|
this.CanvasKit,
|
17
17
|
this.CanvasKit.MaskFilter.MakeBlur(
|
18
|
-
getEnum(this.CanvasKit
|
18
|
+
getEnum(this.CanvasKit, "BlurStyle", style),
|
19
19
|
sigma,
|
20
20
|
respectCTM
|
21
21
|
)
|
@@ -79,7 +79,7 @@ export class JsiSkPaint extends HostObject<Paint, "Paint"> implements SkPaint {
|
|
79
79
|
}
|
80
80
|
|
81
81
|
setBlendMode(blendMode: BlendMode) {
|
82
|
-
this.ref.setBlendMode(getEnum(this.CanvasKit
|
82
|
+
this.ref.setBlendMode(getEnum(this.CanvasKit, "BlendMode", blendMode));
|
83
83
|
}
|
84
84
|
|
85
85
|
setColor(color: SkColor) {
|
@@ -107,11 +107,11 @@ export class JsiSkPaint extends HostObject<Paint, "Paint"> implements SkPaint {
|
|
107
107
|
}
|
108
108
|
|
109
109
|
setStrokeCap(cap: StrokeCap) {
|
110
|
-
this.ref.setStrokeCap(getEnum(this.CanvasKit
|
110
|
+
this.ref.setStrokeCap(getEnum(this.CanvasKit, "StrokeCap", cap));
|
111
111
|
}
|
112
112
|
|
113
113
|
setStrokeJoin(join: StrokeJoin) {
|
114
|
-
this.ref.setStrokeJoin(getEnum(this.CanvasKit
|
114
|
+
this.ref.setStrokeJoin(getEnum(this.CanvasKit, "StrokeJoin", join));
|
115
115
|
}
|
116
116
|
|
117
117
|
setStrokeMiter(limit: number) {
|
@@ -150,7 +150,7 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
|
|
150
150
|
}
|
151
151
|
|
152
152
|
setFillType(fill: FillType) {
|
153
|
-
this.ref.setFillType(getEnum(this.CanvasKit
|
153
|
+
this.ref.setFillType(getEnum(this.CanvasKit, "FillType", fill));
|
154
154
|
return this;
|
155
155
|
}
|
156
156
|
|
@@ -168,8 +168,8 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
|
|
168
168
|
// eslint-disable-next-line camelcase
|
169
169
|
miter_limit: opts.width,
|
170
170
|
precision: opts.width,
|
171
|
-
join: optEnum(this.CanvasKit
|
172
|
-
cap: optEnum(this.CanvasKit
|
171
|
+
join: optEnum(this.CanvasKit, "StrokeJoin", opts.join),
|
172
|
+
cap: optEnum(this.CanvasKit, "StrokeCap", opts.cap),
|
173
173
|
}
|
174
174
|
);
|
175
175
|
return result === null ? result : this;
|
@@ -318,7 +318,7 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
|
|
318
318
|
op(path: SkPath, op: PathOp) {
|
319
319
|
return this.ref.op(
|
320
320
|
JsiSkPath.fromValue(path),
|
321
|
-
getEnum(this.CanvasKit
|
321
|
+
getEnum(this.CanvasKit, "PathOp", op)
|
322
322
|
);
|
323
323
|
}
|
324
324
|
|
@@ -69,7 +69,7 @@ export class JsiSkPathEffectFactory extends Host implements PathEffectFactory {
|
|
69
69
|
JsiSkPath.fromValue(path),
|
70
70
|
advance,
|
71
71
|
phase,
|
72
|
-
getEnum(this.CanvasKit
|
72
|
+
getEnum(this.CanvasKit, "Path1DEffect", style)
|
73
73
|
);
|
74
74
|
if (pe === null) {
|
75
75
|
return null;
|
@@ -27,7 +27,7 @@ export class JsiSkPathFactory extends Host implements PathFactory {
|
|
27
27
|
const path = this.CanvasKit.Path.MakeFromOp(
|
28
28
|
JsiSkPath.fromValue(one),
|
29
29
|
JsiSkPath.fromValue(two),
|
30
|
-
getEnum(this.CanvasKit
|
30
|
+
getEnum(this.CanvasKit, "PathOp", op)
|
31
31
|
);
|
32
32
|
if (path === null) {
|
33
33
|
return null;
|
@@ -36,9 +36,9 @@ export class JsiSkPicture
|
|
36
36
|
return new JsiSkShader(
|
37
37
|
this.CanvasKit,
|
38
38
|
this.ref.makeShader(
|
39
|
-
getEnum(this.CanvasKit
|
40
|
-
getEnum(this.CanvasKit
|
41
|
-
getEnum(this.CanvasKit
|
39
|
+
getEnum(this.CanvasKit, "TileMode", tmx),
|
40
|
+
getEnum(this.CanvasKit, "TileMode", tmy),
|
41
|
+
getEnum(this.CanvasKit, "FilterMode", mode),
|
42
42
|
localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined,
|
43
43
|
tileRect ? JsiSkRect.fromValue(this.CanvasKit, tileRect) : undefined
|
44
44
|
)
|
@@ -36,7 +36,7 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
|
|
36
36
|
JsiSkPoint.fromValue(end),
|
37
37
|
colors,
|
38
38
|
pos,
|
39
|
-
getEnum(this.CanvasKit
|
39
|
+
getEnum(this.CanvasKit, "TileMode", mode),
|
40
40
|
localMatrix === undefined
|
41
41
|
? undefined
|
42
42
|
: JsiSkMatrix.fromValue(localMatrix),
|
@@ -61,7 +61,7 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
|
|
61
61
|
radius,
|
62
62
|
colors,
|
63
63
|
pos,
|
64
|
-
getEnum(this.CanvasKit
|
64
|
+
getEnum(this.CanvasKit, "TileMode", mode),
|
65
65
|
localMatrix === undefined
|
66
66
|
? undefined
|
67
67
|
: JsiSkMatrix.fromValue(localMatrix),
|
@@ -90,7 +90,7 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
|
|
90
90
|
endRadius,
|
91
91
|
colors,
|
92
92
|
pos,
|
93
|
-
getEnum(this.CanvasKit
|
93
|
+
getEnum(this.CanvasKit, "TileMode", mode),
|
94
94
|
localMatrix === undefined
|
95
95
|
? undefined
|
96
96
|
: JsiSkMatrix.fromValue(localMatrix),
|
@@ -117,7 +117,7 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
|
|
117
117
|
cy,
|
118
118
|
colors,
|
119
119
|
pos,
|
120
|
-
getEnum(this.CanvasKit
|
120
|
+
getEnum(this.CanvasKit, "TileMode", mode),
|
121
121
|
localMatrix === undefined || localMatrix === null
|
122
122
|
? undefined
|
123
123
|
: JsiSkMatrix.fromValue(localMatrix),
|
@@ -174,7 +174,7 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
|
|
174
174
|
return new JsiSkShader(
|
175
175
|
this.CanvasKit,
|
176
176
|
this.CanvasKit.Shader.MakeBlend(
|
177
|
-
getEnum(this.CanvasKit
|
177
|
+
getEnum(this.CanvasKit, "BlendMode", mode),
|
178
178
|
JsiSkShader.fromValue(one),
|
179
179
|
JsiSkShader.fromValue(two)
|
180
180
|
)
|
@@ -31,7 +31,7 @@ export const MakeVertices = (
|
|
31
31
|
new JsiSkVertices(
|
32
32
|
CanvasKit,
|
33
33
|
CanvasKit.MakeVertices(
|
34
|
-
getEnum(CanvasKit
|
34
|
+
getEnum(CanvasKit, "VertexMode", mode),
|
35
35
|
positions.map(({ x, y }) => [x, y]).flat(),
|
36
36
|
(textureCoordinates || []).map(({ x, y }) => [x, y]).flat(),
|
37
37
|
!colors ? null : colors.reduce((a, c) => concat(a, c)),
|