@shopify/react-native-skia 0.1.142 → 0.1.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cpp/api/JsiSkPathFactory.h +1 -1
- package/cpp/api/JsiSkPicture.h +7 -1
- package/cpp/rnskia/RNSkDrawView.cpp +4 -4
- package/cpp/rnskia/RNSkDrawView.h +1 -1
- package/lib/commonjs/renderer/components/Blend.js +20 -5
- package/lib/commonjs/renderer/components/Blend.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Morphology.js +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Morphology.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Shadow.js +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Shadow.js.map +1 -1
- package/lib/commonjs/skia/web/Host.js +12 -21
- package/lib/commonjs/skia/web/Host.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +46 -26
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +4 -4
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.js +7 -3
- package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.js +4 -2
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +4 -2
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +61 -19
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.js +1 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPaint.js +15 -6
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js +9 -55
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +7 -3
- 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 +5 -1
- package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPictureRecorder.js +3 -1
- package/lib/commonjs/skia/web/JsiSkPictureRecorder.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPoint.js +9 -1
- package/lib/commonjs/skia/web/JsiSkPoint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRRect.js +1 -1
- package/lib/commonjs/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRSXform.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRect.js +1 -1
- package/lib/commonjs/skia/web/JsiSkRect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js +4 -2
- package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js +10 -6
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurface.js +3 -1
- package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js +8 -4
- package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTypefaceFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkTypefaceFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +12 -6
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/renderer/components/Blend.js +21 -5
- package/lib/module/renderer/components/Blend.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/Morphology.js +1 -1
- package/lib/module/renderer/components/imageFilters/Morphology.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/Shadow.js +1 -1
- package/lib/module/renderer/components/imageFilters/Shadow.js.map +1 -1
- package/lib/module/skia/web/Host.js +9 -9
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +37 -27
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkColorFilterFactory.js +5 -5
- package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkFont.js +6 -4
- package/lib/module/skia/web/JsiSkFont.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.js +4 -3
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.js +4 -3
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFilterFactory.js +61 -20
- package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkMatrix.js +2 -2
- package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.js +11 -7
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.js +9 -57
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -4
- package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
- package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPicture.js +4 -2
- package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/module/skia/web/JsiSkPictureRecorder.js +3 -2
- package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
- package/lib/module/skia/web/JsiSkPoint.js +10 -2
- package/lib/module/skia/web/JsiSkPoint.js.map +1 -1
- package/lib/module/skia/web/JsiSkRRect.js +2 -2
- package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/module/skia/web/JsiSkRSXform.js.map +1 -1
- package/lib/module/skia/web/JsiSkRect.js +2 -2
- package/lib/module/skia/web/JsiSkRect.js.map +1 -1
- package/lib/module/skia/web/JsiSkRuntimeEffect.js +4 -3
- package/lib/module/skia/web/JsiSkRuntimeEffect.js.map +1 -1
- package/lib/module/skia/web/JsiSkShaderFactory.js +9 -7
- package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurface.js +3 -2
- package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/module/skia/web/JsiSkTextBlobFactory.js +7 -5
- package/lib/module/skia/web/JsiSkTextBlobFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkTypefaceFactory.js +2 -2
- package/lib/module/skia/web/JsiSkTypefaceFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +10 -5
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/typescript/src/skia/types/Picture/Picture.d.ts +2 -1
- package/lib/typescript/src/skia/web/Host.d.ts +5 -7
- package/lib/typescript/src/skia/web/JsiSkImageFilterFactory.d.ts +8 -8
- package/lib/typescript/src/skia/web/JsiSkPoint.d.ts +3 -2
- package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +2 -2
- package/lib/typescript/src/skia/web/JsiSkRSXform.d.ts +1 -2
- package/lib/typescript/src/skia/web/JsiSkRect.d.ts +2 -2
- package/lib/typescript/src/skia/web/JsiSkTextBlobFactory.d.ts +2 -1
- package/package.json +2 -2
- package/src/renderer/components/Blend.tsx +25 -5
- package/src/renderer/components/imageFilters/Morphology.tsx +2 -2
- package/src/renderer/components/imageFilters/Shadow.tsx +2 -2
- package/src/skia/types/Picture/Picture.ts +2 -1
- package/src/skia/web/Host.ts +11 -21
- package/src/skia/web/JsiSkCanvas.ts +78 -47
- package/src/skia/web/JsiSkColorFilterFactory.ts +15 -5
- package/src/skia/web/JsiSkFont.ts +11 -4
- package/src/skia/web/JsiSkImage.ts +4 -3
- package/src/skia/web/JsiSkImageFactory.ts +6 -3
- package/src/skia/web/JsiSkImageFilterFactory.ts +124 -52
- package/src/skia/web/JsiSkMatrix.ts +4 -2
- package/src/skia/web/JsiSkPaint.ts +11 -7
- package/src/skia/web/JsiSkPath.ts +16 -51
- package/src/skia/web/JsiSkPathEffectFactory.ts +10 -5
- package/src/skia/web/JsiSkPathFactory.ts +3 -3
- package/src/skia/web/JsiSkPicture.ts +5 -3
- package/src/skia/web/JsiSkPictureRecorder.ts +3 -2
- package/src/skia/web/JsiSkPoint.ts +12 -2
- package/src/skia/web/JsiSkRRect.ts +5 -2
- package/src/skia/web/JsiSkRSXform.ts +1 -1
- package/src/skia/web/JsiSkRect.ts +2 -2
- package/src/skia/web/JsiSkRuntimeEffect.ts +9 -4
- package/src/skia/web/JsiSkShaderFactory.ts +24 -15
- package/src/skia/web/JsiSkSurface.ts +7 -2
- package/src/skia/web/JsiSkTextBlobFactory.ts +14 -8
- package/src/skia/web/JsiSkTypefaceFactory.tsx +4 -2
- package/src/skia/web/JsiSkia.ts +17 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CanvasKit, RRect } from "canvaskit-wasm";
|
|
2
2
|
import type { SkRRect } from "../types";
|
|
3
|
-
import {
|
|
3
|
+
import { BaseHostObject } from "./Host";
|
|
4
4
|
import { JsiSkRect } from "./JsiSkRect";
|
|
5
|
-
export declare class JsiSkRRect extends
|
|
5
|
+
export declare class JsiSkRRect extends BaseHostObject<RRect, "RRect"> implements SkRRect {
|
|
6
6
|
static fromValue(CanvasKit: CanvasKit, rect: SkRRect): Float32Array;
|
|
7
7
|
constructor(CanvasKit: CanvasKit, ref: RRect);
|
|
8
8
|
get rx(): number;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { CanvasKit } from "canvaskit-wasm";
|
|
2
2
|
import type { SkRSXform } from "../types";
|
|
3
3
|
import { HostObject } from "./Host";
|
|
4
|
-
declare type RSXform = Float32Array;
|
|
4
|
+
export declare type RSXform = Float32Array;
|
|
5
5
|
export declare class JsiSkRSXform extends HostObject<RSXform, "RSXform"> implements SkRSXform {
|
|
6
6
|
constructor(CanvasKit: CanvasKit, ref: RSXform);
|
|
7
7
|
}
|
|
8
|
-
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CanvasKit, Rect } from "canvaskit-wasm";
|
|
2
2
|
import type { SkRect } from "../types";
|
|
3
|
-
import {
|
|
4
|
-
export declare class JsiSkRect extends
|
|
3
|
+
import { BaseHostObject } from "./Host";
|
|
4
|
+
export declare class JsiSkRect extends BaseHostObject<Rect, "Rect"> implements SkRect {
|
|
5
5
|
static fromValue(CanvasKit: CanvasKit, rect: SkRect): Float32Array;
|
|
6
6
|
constructor(CanvasKit: CanvasKit, ref: Rect);
|
|
7
7
|
get x(): number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CanvasKit } from "canvaskit-wasm";
|
|
2
|
-
import type { SkFont
|
|
2
|
+
import type { SkFont } from "../types";
|
|
3
3
|
import type { TextBlobFactory } from "../types/TextBlob";
|
|
4
|
+
import type { SkRSXform } from "../types/RSXform";
|
|
4
5
|
import { Host } from "./Host";
|
|
5
6
|
import { JsiSkTextBlob } from "./JsiSkTextBlob";
|
|
6
7
|
export declare class JsiSkTextBlobFactory extends Host implements TextBlobFactory {
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"setup-skia-web": "./scripts/setup-canvaskit.js"
|
|
8
8
|
},
|
|
9
9
|
"title": "React Native Skia",
|
|
10
|
-
"version": "0.1.
|
|
10
|
+
"version": "0.1.143",
|
|
11
11
|
"description": "High-performance React Native Graphics using Skia",
|
|
12
12
|
"main": "lib/module/index.js",
|
|
13
13
|
"files": [
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"typescript": "^4.6.4"
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"canvaskit-wasm": "^0.
|
|
92
|
+
"canvaskit-wasm": "^0.36.0",
|
|
93
93
|
"react-reconciler": "^0.26.2"
|
|
94
94
|
},
|
|
95
95
|
"eslintIgnore": [
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
|
|
4
|
+
import type { SkImageFilter, SkShader } from "../../skia/types";
|
|
4
5
|
import { isImageFilter, BlendMode, isShader } from "../../skia/types";
|
|
5
6
|
import { createDeclaration } from "../nodes";
|
|
6
7
|
import type { AnimatedProps, SkEnum } from "../processors";
|
|
7
8
|
import { enumKey } from "../processors/Paint";
|
|
9
|
+
import type { DeclarationResult } from "../nodes/Declaration";
|
|
10
|
+
|
|
11
|
+
const childrenAreImageFilters = (
|
|
12
|
+
children: DeclarationResult[]
|
|
13
|
+
): children is SkImageFilter[] =>
|
|
14
|
+
children.every((child) => isImageFilter(child));
|
|
15
|
+
|
|
16
|
+
const childrenAreShaders = (
|
|
17
|
+
children: DeclarationResult[]
|
|
18
|
+
): children is SkShader[] => children.every((child) => isShader(child));
|
|
8
19
|
|
|
9
20
|
interface BlendProps {
|
|
10
21
|
mode: SkEnum<typeof BlendMode>;
|
|
@@ -13,12 +24,21 @@ interface BlendProps {
|
|
|
13
24
|
|
|
14
25
|
const onDeclare = createDeclaration<BlendProps>(
|
|
15
26
|
({ mode }, children, { Skia }) => {
|
|
16
|
-
const [inner, outer] = children;
|
|
17
27
|
const blend = BlendMode[enumKey(mode)];
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
if (childrenAreImageFilters(children)) {
|
|
29
|
+
return children.reverse().reduce<SkImageFilter | null>((inner, outer) => {
|
|
30
|
+
if (inner === null) {
|
|
31
|
+
return outer;
|
|
32
|
+
}
|
|
33
|
+
return Skia.ImageFilter.MakeBlend(blend, outer, inner);
|
|
34
|
+
}, null);
|
|
35
|
+
} else if (childrenAreShaders(children)) {
|
|
36
|
+
return children.reverse().reduce<SkShader | null>((inner, outer) => {
|
|
37
|
+
if (inner === null) {
|
|
38
|
+
return outer;
|
|
39
|
+
}
|
|
40
|
+
return Skia.Shader.MakeBlend(blend, outer, inner);
|
|
41
|
+
}, null);
|
|
22
42
|
}
|
|
23
43
|
throw new Error("<Blend /> can only blend Shaders or ImageFilters");
|
|
24
44
|
}
|
|
@@ -18,8 +18,8 @@ const onDeclare = createDeclaration<MorphologyProps>(
|
|
|
18
18
|
const r = processRadius(Skia, radius);
|
|
19
19
|
const factory =
|
|
20
20
|
operator === "dilate"
|
|
21
|
-
? Skia.ImageFilter.MakeDilate
|
|
22
|
-
: Skia.ImageFilter.MakeErode;
|
|
21
|
+
? Skia.ImageFilter.MakeDilate.bind(Skia.ImageFilter)
|
|
22
|
+
: Skia.ImageFilter.MakeErode.bind(Skia.ImageFilter);
|
|
23
23
|
return factory(r.x, r.y, input);
|
|
24
24
|
}
|
|
25
25
|
);
|
|
@@ -30,8 +30,8 @@ const onDeclare = createDeclaration<ShadowProps>(
|
|
|
30
30
|
factory = MakeInnerShadow.bind(null, Skia, shadowOnly);
|
|
31
31
|
} else {
|
|
32
32
|
factory = shadowOnly
|
|
33
|
-
? Skia.ImageFilter.MakeDropShadowOnly
|
|
34
|
-
: Skia.ImageFilter.MakeDropShadow;
|
|
33
|
+
? Skia.ImageFilter.MakeDropShadowOnly.bind(Skia.ImageFilter)
|
|
34
|
+
: Skia.ImageFilter.MakeDropShadow.bind(Skia.ImageFilter);
|
|
35
35
|
}
|
|
36
36
|
return factory(dx, dy, blur, blur, color, input);
|
|
37
37
|
}
|
|
@@ -3,8 +3,9 @@ import type { TileMode } from "../ImageFilter";
|
|
|
3
3
|
import type { SkRect } from "../Rect";
|
|
4
4
|
import type { SkShader } from "../Shader";
|
|
5
5
|
import type { SkMatrix } from "../Matrix";
|
|
6
|
+
import type { SkJSIInstance } from "../JsiInstance";
|
|
6
7
|
|
|
7
|
-
export interface SkPicture {
|
|
8
|
+
export interface SkPicture extends SkJSIInstance<"Picture"> {
|
|
8
9
|
/**
|
|
9
10
|
* Returns a new shader that will draw with this picture.
|
|
10
11
|
*
|
package/src/skia/web/Host.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
/* eslint-disable no-nested-ternary */
|
|
2
1
|
import type { CanvasKit, EmbindEnumEntity } from "canvaskit-wasm";
|
|
3
2
|
|
|
4
3
|
import type { SkJSIInstance } from "../types";
|
|
5
4
|
|
|
6
5
|
export class NotImplementedOnRNWeb extends Error {
|
|
7
|
-
constructor() {
|
|
8
|
-
super("Not implemented on React Native Web");
|
|
6
|
+
constructor(msg?: string) {
|
|
7
|
+
super(msg ?? "Not implemented on React Native Web");
|
|
9
8
|
}
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -17,7 +16,7 @@ export abstract class Host {
|
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
export abstract class
|
|
19
|
+
export abstract class BaseHostObject<T, N extends string>
|
|
21
20
|
extends Host
|
|
22
21
|
implements SkJSIInstance<N>
|
|
23
22
|
{
|
|
@@ -31,23 +30,14 @@ export abstract class HostObject<T, N extends string>
|
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
value:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
export const toUndefinedableValue = <T>(
|
|
43
|
-
value: NonNullish | undefined
|
|
44
|
-
): T | undefined => (value === undefined ? undefined : toValue(value));
|
|
45
|
-
|
|
46
|
-
export const toNullableValue = <T>(value: NonNullish | null): T | null =>
|
|
47
|
-
value === null ? null : toValue(value);
|
|
48
|
-
|
|
49
|
-
export const toValue = <T>(value: NonNullish): T =>
|
|
50
|
-
(value as HostObject<T, string>).ref;
|
|
33
|
+
export abstract class HostObject<T, N extends string> extends BaseHostObject<
|
|
34
|
+
T,
|
|
35
|
+
N
|
|
36
|
+
> {
|
|
37
|
+
static fromValue<T>(value: SkJSIInstance<string>) {
|
|
38
|
+
return (value as HostObject<T, string>).ref;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
51
41
|
|
|
52
42
|
export const ckEnum = (value: number): EmbindEnumEntity => ({ value });
|
|
53
43
|
export const optEnum = (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Canvas,
|
|
1
|
+
import type { Canvas, CanvasKit } from "canvaskit-wasm";
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
4
|
BlendMode,
|
|
@@ -24,15 +24,19 @@ import type {
|
|
|
24
24
|
SkVertices,
|
|
25
25
|
} from "../types";
|
|
26
26
|
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
HostObject,
|
|
30
|
-
toValue,
|
|
31
|
-
toUndefinedableValue,
|
|
32
|
-
toOptionalValue,
|
|
33
|
-
} from "./Host";
|
|
27
|
+
import { ckEnum, HostObject } from "./Host";
|
|
28
|
+
import { JsiSkPaint } from "./JsiSkPaint";
|
|
34
29
|
import { JsiSkRect } from "./JsiSkRect";
|
|
35
30
|
import { JsiSkRRect } from "./JsiSkRRect";
|
|
31
|
+
import { JsiSkImage } from "./JsiSkImage";
|
|
32
|
+
import { JsiSkVertices } from "./JsiSkVertices";
|
|
33
|
+
import { JsiSkPath } from "./JsiSkPath";
|
|
34
|
+
import { JsiSkFont } from "./JsiSkFont";
|
|
35
|
+
import { JsiSkTextBlob } from "./JsiSkTextBlob";
|
|
36
|
+
import { JsiSkPicture } from "./JsiSkPicture";
|
|
37
|
+
import { JsiSkMatrix } from "./JsiSkMatrix";
|
|
38
|
+
import { JsiSkImageFilter } from "./JsiSkImageFilter";
|
|
39
|
+
import { JsiSkPoint } from "./JsiSkPoint";
|
|
36
40
|
|
|
37
41
|
export class JsiSkCanvas
|
|
38
42
|
extends HostObject<Canvas, "Canvas">
|
|
@@ -45,12 +49,17 @@ export class JsiSkCanvas
|
|
|
45
49
|
drawRect(rect: SkRect, paint: SkPaint) {
|
|
46
50
|
this.ref.drawRect(
|
|
47
51
|
JsiSkRect.fromValue(this.CanvasKit, rect),
|
|
48
|
-
|
|
52
|
+
JsiSkPaint.fromValue(paint)
|
|
49
53
|
);
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
drawImage(image: SkImage, x: number, y: number, paint?: SkPaint) {
|
|
53
|
-
this.ref.drawImage(
|
|
57
|
+
this.ref.drawImage(
|
|
58
|
+
JsiSkImage.fromValue(image),
|
|
59
|
+
x,
|
|
60
|
+
y,
|
|
61
|
+
paint ? JsiSkPaint.fromValue(paint) : paint
|
|
62
|
+
);
|
|
54
63
|
}
|
|
55
64
|
|
|
56
65
|
drawImageRect(
|
|
@@ -61,10 +70,10 @@ export class JsiSkCanvas
|
|
|
61
70
|
fastSample?: boolean
|
|
62
71
|
) {
|
|
63
72
|
this.ref.drawImageRect(
|
|
64
|
-
|
|
73
|
+
JsiSkImage.fromValue(img),
|
|
65
74
|
JsiSkRect.fromValue(this.CanvasKit, src),
|
|
66
75
|
JsiSkRect.fromValue(this.CanvasKit, dest),
|
|
67
|
-
|
|
76
|
+
JsiSkPaint.fromValue(paint),
|
|
68
77
|
fastSample
|
|
69
78
|
);
|
|
70
79
|
}
|
|
@@ -78,12 +87,12 @@ export class JsiSkCanvas
|
|
|
78
87
|
paint?: SkPaint | null
|
|
79
88
|
) {
|
|
80
89
|
this.ref.drawImageCubic(
|
|
81
|
-
|
|
90
|
+
JsiSkImage.fromValue(img),
|
|
82
91
|
left,
|
|
83
92
|
top,
|
|
84
93
|
B,
|
|
85
94
|
C,
|
|
86
|
-
|
|
95
|
+
paint ? JsiSkPaint.fromValue(paint) : paint
|
|
87
96
|
);
|
|
88
97
|
}
|
|
89
98
|
|
|
@@ -96,12 +105,12 @@ export class JsiSkCanvas
|
|
|
96
105
|
paint?: SkPaint | null
|
|
97
106
|
) {
|
|
98
107
|
this.ref.drawImageOptions(
|
|
99
|
-
|
|
108
|
+
JsiSkImage.fromValue(img),
|
|
100
109
|
left,
|
|
101
110
|
top,
|
|
102
111
|
ckEnum(fm),
|
|
103
112
|
ckEnum(mm),
|
|
104
|
-
|
|
113
|
+
paint ? JsiSkPaint.fromValue(paint) : paint
|
|
105
114
|
);
|
|
106
115
|
}
|
|
107
116
|
|
|
@@ -113,11 +122,11 @@ export class JsiSkCanvas
|
|
|
113
122
|
paint?: SkPaint | null
|
|
114
123
|
) {
|
|
115
124
|
this.ref.drawImageNine(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
125
|
+
JsiSkImage.fromValue(img),
|
|
126
|
+
Array.from(JsiSkRect.fromValue(this.CanvasKit, center)),
|
|
127
|
+
JsiSkRect.fromValue(this.CanvasKit, dest),
|
|
119
128
|
ckEnum(filter),
|
|
120
|
-
|
|
129
|
+
paint ? JsiSkPaint.fromValue(paint) : paint
|
|
121
130
|
);
|
|
122
131
|
}
|
|
123
132
|
|
|
@@ -130,12 +139,12 @@ export class JsiSkCanvas
|
|
|
130
139
|
paint?: SkPaint | null
|
|
131
140
|
) {
|
|
132
141
|
this.ref.drawImageRectCubic(
|
|
133
|
-
|
|
142
|
+
JsiSkImage.fromValue(img),
|
|
134
143
|
JsiSkRect.fromValue(this.CanvasKit, src),
|
|
135
144
|
JsiSkRect.fromValue(this.CanvasKit, dest),
|
|
136
145
|
B,
|
|
137
146
|
C,
|
|
138
|
-
|
|
147
|
+
paint ? JsiSkPaint.fromValue(paint) : paint
|
|
139
148
|
);
|
|
140
149
|
}
|
|
141
150
|
|
|
@@ -148,29 +157,33 @@ export class JsiSkCanvas
|
|
|
148
157
|
paint?: SkPaint | null
|
|
149
158
|
) {
|
|
150
159
|
this.ref.drawImageRectOptions(
|
|
151
|
-
|
|
160
|
+
JsiSkImage.fromValue(img),
|
|
152
161
|
JsiSkRect.fromValue(this.CanvasKit, src),
|
|
153
162
|
JsiSkRect.fromValue(this.CanvasKit, dest),
|
|
154
163
|
ckEnum(fm),
|
|
155
164
|
ckEnum(mm),
|
|
156
|
-
|
|
165
|
+
paint ? JsiSkPaint.fromValue(paint) : paint
|
|
157
166
|
);
|
|
158
167
|
}
|
|
159
168
|
|
|
160
169
|
drawPaint(paint: SkPaint) {
|
|
161
|
-
this.ref.drawPaint(
|
|
170
|
+
this.ref.drawPaint(JsiSkPaint.fromValue(paint));
|
|
162
171
|
}
|
|
163
172
|
|
|
164
173
|
drawLine(x0: number, y0: number, x1: number, y1: number, paint: SkPaint) {
|
|
165
|
-
this.ref.drawLine(x0, y0, x1, y1,
|
|
174
|
+
this.ref.drawLine(x0, y0, x1, y1, JsiSkPaint.fromValue(paint));
|
|
166
175
|
}
|
|
167
176
|
|
|
168
177
|
drawCircle(cx: number, cy: number, radius: number, paint: SkPaint) {
|
|
169
|
-
this.ref.drawCircle(cx, cy, radius,
|
|
178
|
+
this.ref.drawCircle(cx, cy, radius, JsiSkPaint.fromValue(paint));
|
|
170
179
|
}
|
|
171
180
|
|
|
172
181
|
drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {
|
|
173
|
-
this.ref.drawVertices(
|
|
182
|
+
this.ref.drawVertices(
|
|
183
|
+
JsiSkVertices.fromValue(verts),
|
|
184
|
+
ckEnum(mode),
|
|
185
|
+
JsiSkPaint.fromValue(paint)
|
|
186
|
+
);
|
|
174
187
|
}
|
|
175
188
|
|
|
176
189
|
drawPatch(
|
|
@@ -183,9 +196,9 @@ export class JsiSkCanvas
|
|
|
183
196
|
this.ref.drawPatch(
|
|
184
197
|
cubics.map(({ x, y }) => [x, y]).flat(),
|
|
185
198
|
colors,
|
|
186
|
-
|
|
199
|
+
texs ? texs.flatMap((p) => Array.from(JsiSkPoint.fromValue(p))) : texs,
|
|
187
200
|
mode ? ckEnum(mode) : null,
|
|
188
|
-
|
|
201
|
+
paint ? JsiSkPaint.fromValue(paint) : undefined
|
|
189
202
|
);
|
|
190
203
|
}
|
|
191
204
|
|
|
@@ -197,7 +210,7 @@ export class JsiSkCanvas
|
|
|
197
210
|
this.ref.drawPoints(
|
|
198
211
|
ckEnum(mode),
|
|
199
212
|
points.map(({ x, y }) => [x, y]).flat(),
|
|
200
|
-
|
|
213
|
+
JsiSkPaint.fromValue(paint)
|
|
201
214
|
);
|
|
202
215
|
}
|
|
203
216
|
|
|
@@ -209,39 +222,57 @@ export class JsiSkCanvas
|
|
|
209
222
|
paint: SkPaint
|
|
210
223
|
) {
|
|
211
224
|
this.ref.drawArc(
|
|
212
|
-
|
|
225
|
+
JsiSkRect.fromValue(this.CanvasKit, oval),
|
|
213
226
|
startAngle,
|
|
214
227
|
sweepAngle,
|
|
215
228
|
useCenter,
|
|
216
|
-
|
|
229
|
+
JsiSkPaint.fromValue(paint)
|
|
217
230
|
);
|
|
218
231
|
}
|
|
219
232
|
|
|
220
233
|
drawRRect(rrect: SkRRect, paint: SkPaint) {
|
|
221
234
|
this.ref.drawRRect(
|
|
222
235
|
JsiSkRRect.fromValue(this.CanvasKit, rrect),
|
|
223
|
-
|
|
236
|
+
JsiSkPaint.fromValue(paint)
|
|
224
237
|
);
|
|
225
238
|
}
|
|
226
239
|
|
|
227
240
|
drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint) {
|
|
228
|
-
this.ref.drawDRRect(
|
|
241
|
+
this.ref.drawDRRect(
|
|
242
|
+
JsiSkRRect.fromValue(this.CanvasKit, outer),
|
|
243
|
+
JsiSkRRect.fromValue(this.CanvasKit, inner),
|
|
244
|
+
JsiSkPaint.fromValue(paint)
|
|
245
|
+
);
|
|
229
246
|
}
|
|
230
247
|
|
|
231
248
|
drawOval(oval: SkRect, paint: SkPaint) {
|
|
232
|
-
this.ref.drawOval(
|
|
249
|
+
this.ref.drawOval(
|
|
250
|
+
JsiSkRect.fromValue(this.CanvasKit, oval),
|
|
251
|
+
JsiSkPaint.fromValue(paint)
|
|
252
|
+
);
|
|
233
253
|
}
|
|
234
254
|
|
|
235
255
|
drawPath(path: SkPath, paint: SkPaint) {
|
|
236
|
-
this.ref.drawPath(
|
|
256
|
+
this.ref.drawPath(JsiSkPath.fromValue(path), JsiSkPaint.fromValue(paint));
|
|
237
257
|
}
|
|
238
258
|
|
|
239
259
|
drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont) {
|
|
240
|
-
this.ref.drawText(
|
|
260
|
+
this.ref.drawText(
|
|
261
|
+
str,
|
|
262
|
+
x,
|
|
263
|
+
y,
|
|
264
|
+
JsiSkPaint.fromValue(paint),
|
|
265
|
+
JsiSkFont.fromValue(font)
|
|
266
|
+
);
|
|
241
267
|
}
|
|
242
268
|
|
|
243
269
|
drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint) {
|
|
244
|
-
this.ref.drawTextBlob(
|
|
270
|
+
this.ref.drawTextBlob(
|
|
271
|
+
JsiSkTextBlob.fromValue(blob),
|
|
272
|
+
x,
|
|
273
|
+
y,
|
|
274
|
+
JsiSkPaint.fromValue(paint)
|
|
275
|
+
);
|
|
245
276
|
}
|
|
246
277
|
|
|
247
278
|
drawGlyphs(
|
|
@@ -257,8 +288,8 @@ export class JsiSkCanvas
|
|
|
257
288
|
positions.map((p) => [p.x, p.y]).flat(),
|
|
258
289
|
x,
|
|
259
290
|
y,
|
|
260
|
-
|
|
261
|
-
|
|
291
|
+
JsiSkFont.fromValue(font),
|
|
292
|
+
JsiSkPaint.fromValue(paint)
|
|
262
293
|
);
|
|
263
294
|
}
|
|
264
295
|
|
|
@@ -277,9 +308,9 @@ export class JsiSkCanvas
|
|
|
277
308
|
flags?: SaveLayerFlag
|
|
278
309
|
) {
|
|
279
310
|
return this.ref.saveLayer(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
311
|
+
paint ? JsiSkPaint.fromValue(paint) : undefined,
|
|
312
|
+
bounds ? JsiSkRect.fromValue(this.CanvasKit, bounds) : bounds,
|
|
313
|
+
backdrop ? JsiSkImageFilter.fromValue(backdrop) : backdrop,
|
|
283
314
|
flags
|
|
284
315
|
);
|
|
285
316
|
}
|
|
@@ -313,7 +344,7 @@ export class JsiSkCanvas
|
|
|
313
344
|
}
|
|
314
345
|
|
|
315
346
|
clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {
|
|
316
|
-
this.ref.clipPath(
|
|
347
|
+
this.ref.clipPath(JsiSkPath.fromValue(path), ckEnum(op), doAntiAlias);
|
|
317
348
|
}
|
|
318
349
|
|
|
319
350
|
clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {
|
|
@@ -333,10 +364,10 @@ export class JsiSkCanvas
|
|
|
333
364
|
}
|
|
334
365
|
|
|
335
366
|
concat(m: SkMatrix) {
|
|
336
|
-
this.ref.concat(
|
|
367
|
+
this.ref.concat(JsiSkMatrix.fromValue(m));
|
|
337
368
|
}
|
|
338
369
|
|
|
339
370
|
drawPicture(skp: SkPicture) {
|
|
340
|
-
this.ref.drawPicture(
|
|
371
|
+
this.ref.drawPicture(JsiSkPicture.fromValue(skp));
|
|
341
372
|
}
|
|
342
373
|
}
|
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
BlendMode,
|
|
9
9
|
} from "../types";
|
|
10
10
|
|
|
11
|
-
import { ckEnum, Host
|
|
11
|
+
import { ckEnum, Host } from "./Host";
|
|
12
12
|
import { JsiSkColorFilter } from "./JsiSkColorFilter";
|
|
13
13
|
|
|
14
14
|
export class JsiSkColorFilterFactory
|
|
@@ -29,21 +29,28 @@ export class JsiSkColorFilterFactory
|
|
|
29
29
|
MakeBlend(color: SkColor, mode: BlendMode) {
|
|
30
30
|
return new JsiSkColorFilter(
|
|
31
31
|
this.CanvasKit,
|
|
32
|
-
this.CanvasKit.ColorFilter.MakeBlend(
|
|
32
|
+
this.CanvasKit.ColorFilter.MakeBlend(color, ckEnum(mode))
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
MakeCompose(outer: SkColorFilter, inner: SkColorFilter) {
|
|
37
37
|
return new JsiSkColorFilter(
|
|
38
38
|
this.CanvasKit,
|
|
39
|
-
this.CanvasKit.ColorFilter.MakeCompose(
|
|
39
|
+
this.CanvasKit.ColorFilter.MakeCompose(
|
|
40
|
+
JsiSkColorFilter.fromValue(outer),
|
|
41
|
+
JsiSkColorFilter.fromValue(inner)
|
|
42
|
+
)
|
|
40
43
|
);
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
MakeLerp(t: number, dst: SkColorFilter, src: SkColorFilter) {
|
|
44
47
|
return new JsiSkColorFilter(
|
|
45
48
|
this.CanvasKit,
|
|
46
|
-
this.CanvasKit.ColorFilter.MakeLerp(
|
|
49
|
+
this.CanvasKit.ColorFilter.MakeLerp(
|
|
50
|
+
t,
|
|
51
|
+
JsiSkColorFilter.fromValue(dst),
|
|
52
|
+
JsiSkColorFilter.fromValue(src)
|
|
53
|
+
)
|
|
47
54
|
);
|
|
48
55
|
}
|
|
49
56
|
|
|
@@ -62,6 +69,9 @@ export class JsiSkColorFilterFactory
|
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
MakeLumaColorFilter(): SkColorFilter {
|
|
65
|
-
|
|
72
|
+
return new JsiSkColorFilter(
|
|
73
|
+
this.CanvasKit,
|
|
74
|
+
this.CanvasKit.ColorFilter.MakeLuma()
|
|
75
|
+
);
|
|
66
76
|
}
|
|
67
77
|
}
|
|
@@ -9,7 +9,9 @@ import type {
|
|
|
9
9
|
SkTypeface,
|
|
10
10
|
} from "../types";
|
|
11
11
|
|
|
12
|
-
import { HostObject,
|
|
12
|
+
import { HostObject, ckEnum } from "./Host";
|
|
13
|
+
import { JsiSkPaint } from "./JsiSkPaint";
|
|
14
|
+
import { JsiSkPoint } from "./JsiSkPoint";
|
|
13
15
|
import { JsiSkRect } from "./JsiSkRect";
|
|
14
16
|
import { JsiSkTypeface } from "./JsiSkTypeface";
|
|
15
17
|
|
|
@@ -43,7 +45,12 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
|
|
|
43
45
|
|
|
44
46
|
// TODO: Fix return value in the C++ implementation, it return float32
|
|
45
47
|
getGlyphWidths(glyphs: number[], paint?: SkPaint | null) {
|
|
46
|
-
return [
|
|
48
|
+
return [
|
|
49
|
+
...this.ref.getGlyphWidths(
|
|
50
|
+
glyphs,
|
|
51
|
+
paint ? JsiSkPaint.fromValue(paint) : null
|
|
52
|
+
),
|
|
53
|
+
];
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
getGlyphIntercepts(
|
|
@@ -55,7 +62,7 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
|
|
|
55
62
|
return [
|
|
56
63
|
...this.ref.getGlyphIntercepts(
|
|
57
64
|
glyphs,
|
|
58
|
-
positions.map((p) =>
|
|
65
|
+
positions.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),
|
|
59
66
|
top,
|
|
60
67
|
bottom
|
|
61
68
|
),
|
|
@@ -120,6 +127,6 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
|
|
|
120
127
|
}
|
|
121
128
|
|
|
122
129
|
setTypeface(face: SkTypeface | null) {
|
|
123
|
-
this.ref.setTypeface(face ?
|
|
130
|
+
this.ref.setTypeface(face ? JsiSkTypeface.fromValue(face) : null);
|
|
124
131
|
}
|
|
125
132
|
}
|
|
@@ -11,7 +11,8 @@ import type {
|
|
|
11
11
|
TileMode,
|
|
12
12
|
} from "../types";
|
|
13
13
|
|
|
14
|
-
import { ckEnum, HostObject
|
|
14
|
+
import { ckEnum, HostObject } from "./Host";
|
|
15
|
+
import { JsiSkMatrix } from "./JsiSkMatrix";
|
|
15
16
|
import { JsiSkShader } from "./JsiSkShader";
|
|
16
17
|
|
|
17
18
|
export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
|
|
@@ -41,7 +42,7 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
|
|
|
41
42
|
ckEnum(ty),
|
|
42
43
|
ckEnum(fm),
|
|
43
44
|
ckEnum(mm),
|
|
44
|
-
localMatrix ?
|
|
45
|
+
localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined
|
|
45
46
|
)
|
|
46
47
|
);
|
|
47
48
|
}
|
|
@@ -60,7 +61,7 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
|
|
|
60
61
|
ckEnum(ty),
|
|
61
62
|
B,
|
|
62
63
|
C,
|
|
63
|
-
localMatrix ?
|
|
64
|
+
localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined
|
|
64
65
|
)
|
|
65
66
|
);
|
|
66
67
|
}
|
|
@@ -3,8 +3,9 @@ import type { CanvasKit } from "canvaskit-wasm";
|
|
|
3
3
|
import type { SkData, ImageInfo } from "../types";
|
|
4
4
|
import type { ImageFactory } from "../types/Image/ImageFactory";
|
|
5
5
|
|
|
6
|
-
import { Host,
|
|
6
|
+
import { Host, ckEnum } from "./Host";
|
|
7
7
|
import { JsiSkImage } from "./JsiSkImage";
|
|
8
|
+
import { JsiSkData } from "./JsiSkData";
|
|
8
9
|
|
|
9
10
|
export class JsiSkImageFactory extends Host implements ImageFactory {
|
|
10
11
|
constructor(CanvasKit: CanvasKit) {
|
|
@@ -12,7 +13,9 @@ export class JsiSkImageFactory extends Host implements ImageFactory {
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
MakeImageFromEncoded(encoded: SkData) {
|
|
15
|
-
const image = this.CanvasKit.MakeImageFromEncoded(
|
|
16
|
+
const image = this.CanvasKit.MakeImageFromEncoded(
|
|
17
|
+
JsiSkData.fromValue(encoded)
|
|
18
|
+
);
|
|
16
19
|
if (image === null) {
|
|
17
20
|
return null;
|
|
18
21
|
}
|
|
@@ -29,7 +32,7 @@ export class JsiSkImageFactory extends Host implements ImageFactory {
|
|
|
29
32
|
height: info.height,
|
|
30
33
|
width: info.width,
|
|
31
34
|
},
|
|
32
|
-
|
|
35
|
+
JsiSkData.fromValue(data),
|
|
33
36
|
bytesPerRow
|
|
34
37
|
);
|
|
35
38
|
if (image === null) {
|