@shopify/react-native-skia 0.1.230 → 0.1.232
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 +1 -0
- package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.cpp +2 -2
- package/cpp/api/JsiSkAnimatedImage.h +1 -1
- package/cpp/api/JsiSkDataFactory.h +6 -6
- package/cpp/api/JsiSkImage.h +4 -4
- package/cpp/api/JsiSkPath.h +1 -1
- package/cpp/api/JsiSkRRect.h +30 -3
- package/cpp/api/third_party/base64.cpp +153 -0
- package/cpp/api/third_party/base64.h +50 -0
- package/cpp/jsi/JsiPromises.h +1 -1
- package/cpp/rnskia/dom/props/FontProp.h +2 -4
- package/cpp/rnskia/dom/props/RRectProp.h +50 -0
- package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.mm +1 -1
- package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +2 -1
- package/lib/commonjs/dom/nodes/datatypes/Rect.d.ts +1 -1
- package/lib/commonjs/dom/nodes/drawings/RRectNode.d.ts +3 -3
- package/lib/commonjs/dom/nodes/drawings/RRectNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/Text.js +1 -11
- package/lib/commonjs/dom/nodes/drawings/Text.js.map +1 -1
- package/lib/commonjs/dom/types/Common.d.ts +2 -2
- package/lib/commonjs/dom/types/Common.js.map +1 -1
- package/lib/commonjs/dom/types/Drawings.d.ts +1 -1
- package/lib/commonjs/dom/types/Drawings.js.map +1 -1
- package/lib/commonjs/headless/index.d.ts +3 -1
- package/lib/commonjs/headless/index.js +12 -6
- package/lib/commonjs/headless/index.js.map +1 -1
- package/lib/commonjs/skia/types/Canvas.d.ts +4 -4
- package/lib/commonjs/skia/types/Canvas.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix4.d.ts +5 -0
- package/lib/commonjs/skia/types/Matrix4.js +8 -3
- package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
- package/lib/commonjs/skia/types/Paragraph/Paragraph.d.ts +2 -2
- package/lib/commonjs/skia/types/Paragraph/Paragraph.js.map +1 -1
- package/lib/commonjs/skia/types/Paragraph/ParagraphStyle.d.ts +6 -6
- package/lib/commonjs/skia/types/Paragraph/ParagraphStyle.js +25 -25
- package/lib/commonjs/skia/types/Paragraph/ParagraphStyle.js.map +1 -1
- package/lib/commonjs/skia/types/Path/Path.d.ts +2 -2
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/types/RRect.d.ts +9 -0
- package/lib/commonjs/skia/types/RRect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +4 -4
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js +1 -1
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRRect.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkRRect.js +4 -0
- package/lib/commonjs/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/commonjs/web/LoadSkiaWeb.js +4 -1
- package/lib/commonjs/web/LoadSkiaWeb.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.d.ts +2 -1
- package/lib/module/dom/nodes/datatypes/Rect.d.ts +1 -1
- package/lib/module/dom/nodes/drawings/RRectNode.d.ts +3 -3
- package/lib/module/dom/nodes/drawings/RRectNode.js.map +1 -1
- package/lib/module/dom/nodes/drawings/Text.js +1 -11
- package/lib/module/dom/nodes/drawings/Text.js.map +1 -1
- package/lib/module/dom/types/Common.d.ts +2 -2
- package/lib/module/dom/types/Common.js.map +1 -1
- package/lib/module/dom/types/Drawings.d.ts +1 -1
- package/lib/module/dom/types/Drawings.js.map +1 -1
- package/lib/module/headless/index.d.ts +3 -1
- package/lib/module/headless/index.js +5 -3
- package/lib/module/headless/index.js.map +1 -1
- package/lib/module/skia/types/Canvas.d.ts +4 -4
- package/lib/module/skia/types/Canvas.js.map +1 -1
- package/lib/module/skia/types/Matrix4.d.ts +5 -0
- package/lib/module/skia/types/Matrix4.js +6 -4
- package/lib/module/skia/types/Matrix4.js.map +1 -1
- package/lib/module/skia/types/Paragraph/Paragraph.d.ts +2 -2
- package/lib/module/skia/types/Paragraph/Paragraph.js.map +1 -1
- package/lib/module/skia/types/Paragraph/ParagraphStyle.d.ts +6 -6
- package/lib/module/skia/types/Paragraph/ParagraphStyle.js +21 -21
- package/lib/module/skia/types/Paragraph/ParagraphStyle.js.map +1 -1
- package/lib/module/skia/types/Path/Path.d.ts +2 -2
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/types/RRect.d.ts +9 -0
- package/lib/module/skia/types/RRect.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.d.ts +4 -4
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraphStyle.js +2 -2
- package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.d.ts +2 -2
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkRRect.d.ts +2 -2
- package/lib/module/skia/web/JsiSkRRect.js +4 -0
- package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/module/web/LoadSkiaWeb.js +5 -1
- package/lib/module/web/LoadSkiaWeb.js.map +1 -1
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +2 -1
- package/lib/typescript/src/dom/nodes/datatypes/Rect.d.ts +1 -1
- package/lib/typescript/src/dom/nodes/drawings/RRectNode.d.ts +3 -3
- package/lib/typescript/src/dom/types/Common.d.ts +2 -2
- package/lib/typescript/src/dom/types/Drawings.d.ts +1 -1
- package/lib/typescript/src/headless/index.d.ts +3 -1
- package/lib/typescript/src/skia/types/Canvas.d.ts +4 -4
- package/lib/typescript/src/skia/types/Matrix4.d.ts +5 -0
- package/lib/typescript/src/skia/types/Paragraph/Paragraph.d.ts +2 -2
- package/lib/typescript/src/skia/types/Paragraph/ParagraphStyle.d.ts +6 -6
- package/lib/typescript/src/skia/types/Path/Path.d.ts +2 -2
- package/lib/typescript/src/skia/types/RRect.d.ts +9 -0
- package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +4 -4
- package/lib/typescript/src/skia/web/JsiSkPath.d.ts +2 -2
- package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +2 -2
- package/libs/android/arm64-v8a/libskia.a +0 -0
- package/libs/android/armeabi-v7a/libskia.a +0 -0
- package/libs/android/x86/libskia.a +0 -0
- package/libs/android/x86_64/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/ios/libskottie.xcframework/Info.plist +5 -5
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
- package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
- package/libs/ios/libsvg.xcframework/Info.plist +5 -5
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +1 -1
- package/src/dom/nodes/drawings/RRectNode.ts +2 -2
- package/src/dom/nodes/drawings/Text.ts +1 -14
- package/src/dom/types/Common.ts +2 -1
- package/src/dom/types/Drawings.ts +1 -1
- package/src/headless/index.ts +7 -3
- package/src/skia/types/Canvas.ts +4 -4
- package/src/skia/types/Matrix4.ts +8 -6
- package/src/skia/types/Paragraph/Paragraph.ts +2 -2
- package/src/skia/types/Paragraph/ParagraphStyle.ts +6 -6
- package/src/skia/types/Path/Path.ts +2 -2
- package/src/skia/types/RRect.ts +11 -0
- package/src/skia/web/JsiSkCanvas.ts +4 -4
- package/src/skia/web/JsiSkParagraphStyle.ts +2 -2
- package/src/skia/web/JsiSkPath.ts +2 -2
- package/src/skia/web/JsiSkRRect.ts +23 -2
- package/src/web/LoadSkiaWeb.tsx +4 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CanvasKit, Path } from "canvaskit-wasm";
|
|
2
|
-
import type { FillType, PathCommand, PathOp, SkMatrix, SkPath, SkPoint, SkRect,
|
|
2
|
+
import type { FillType, PathCommand, PathOp, SkMatrix, SkPath, SkPoint, SkRect, InputRRect, StrokeOpts } from "../types";
|
|
3
3
|
import { HostObject } from "./Host";
|
|
4
4
|
import { JsiSkPoint } from "./JsiSkPoint";
|
|
5
5
|
import { JsiSkRect } from "./JsiSkRect";
|
|
@@ -41,7 +41,7 @@ export declare class JsiSkPath extends HostObject<Path, "Path"> implements SkPat
|
|
|
41
41
|
getFillType(): number;
|
|
42
42
|
quadTo(x1: number, y1: number, x2: number, y2: number): this;
|
|
43
43
|
addRect(rect: SkRect, isCCW?: boolean): this;
|
|
44
|
-
addRRect(rrect:
|
|
44
|
+
addRRect(rrect: InputRRect, isCCW?: boolean): this;
|
|
45
45
|
getPoint(index: number): JsiSkPoint;
|
|
46
46
|
isEmpty(): boolean;
|
|
47
47
|
isVolatile(): boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { CanvasKit, RRect } from "canvaskit-wasm";
|
|
2
|
-
import type { SkRect, SkRRect } from "../types";
|
|
2
|
+
import type { InputRRect, SkRect, SkRRect } from "../types";
|
|
3
3
|
import { BaseHostObject } from "./Host";
|
|
4
4
|
import { JsiSkRect } from "./JsiSkRect";
|
|
5
5
|
export declare class JsiSkRRect extends BaseHostObject<RRect, "RRect"> implements SkRRect {
|
|
6
6
|
dispose: () => void;
|
|
7
|
-
static fromValue(CanvasKit: CanvasKit, rect:
|
|
7
|
+
static fromValue(CanvasKit: CanvasKit, rect: InputRRect): Float32Array;
|
|
8
8
|
constructor(CanvasKit: CanvasKit, rect: SkRect, rx: number, ry: number);
|
|
9
9
|
get rx(): number;
|
|
10
10
|
get ry(): number;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -6,32 +6,32 @@
|
|
|
6
6
|
<array>
|
|
7
7
|
<dict>
|
|
8
8
|
<key>LibraryIdentifier</key>
|
|
9
|
-
<string>ios-
|
|
9
|
+
<string>ios-arm64_arm64e</string>
|
|
10
10
|
<key>LibraryPath</key>
|
|
11
11
|
<string>libskottie.a</string>
|
|
12
12
|
<key>SupportedArchitectures</key>
|
|
13
13
|
<array>
|
|
14
14
|
<string>arm64</string>
|
|
15
15
|
<string>arm64e</string>
|
|
16
|
-
<string>x86_64</string>
|
|
17
16
|
</array>
|
|
18
17
|
<key>SupportedPlatform</key>
|
|
19
18
|
<string>ios</string>
|
|
20
|
-
<key>SupportedPlatformVariant</key>
|
|
21
|
-
<string>simulator</string>
|
|
22
19
|
</dict>
|
|
23
20
|
<dict>
|
|
24
21
|
<key>LibraryIdentifier</key>
|
|
25
|
-
<string>ios-
|
|
22
|
+
<string>ios-arm64_arm64e_x86_64-simulator</string>
|
|
26
23
|
<key>LibraryPath</key>
|
|
27
24
|
<string>libskottie.a</string>
|
|
28
25
|
<key>SupportedArchitectures</key>
|
|
29
26
|
<array>
|
|
30
27
|
<string>arm64</string>
|
|
31
28
|
<string>arm64e</string>
|
|
29
|
+
<string>x86_64</string>
|
|
32
30
|
</array>
|
|
33
31
|
<key>SupportedPlatform</key>
|
|
34
32
|
<string>ios</string>
|
|
33
|
+
<key>SupportedPlatformVariant</key>
|
|
34
|
+
<string>simulator</string>
|
|
35
35
|
</dict>
|
|
36
36
|
</array>
|
|
37
37
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -6,32 +6,32 @@
|
|
|
6
6
|
<array>
|
|
7
7
|
<dict>
|
|
8
8
|
<key>LibraryIdentifier</key>
|
|
9
|
-
<string>ios-
|
|
9
|
+
<string>ios-arm64_arm64e</string>
|
|
10
10
|
<key>LibraryPath</key>
|
|
11
11
|
<string>libskshaper.a</string>
|
|
12
12
|
<key>SupportedArchitectures</key>
|
|
13
13
|
<array>
|
|
14
14
|
<string>arm64</string>
|
|
15
15
|
<string>arm64e</string>
|
|
16
|
-
<string>x86_64</string>
|
|
17
16
|
</array>
|
|
18
17
|
<key>SupportedPlatform</key>
|
|
19
18
|
<string>ios</string>
|
|
20
|
-
<key>SupportedPlatformVariant</key>
|
|
21
|
-
<string>simulator</string>
|
|
22
19
|
</dict>
|
|
23
20
|
<dict>
|
|
24
21
|
<key>LibraryIdentifier</key>
|
|
25
|
-
<string>ios-
|
|
22
|
+
<string>ios-arm64_arm64e_x86_64-simulator</string>
|
|
26
23
|
<key>LibraryPath</key>
|
|
27
24
|
<string>libskshaper.a</string>
|
|
28
25
|
<key>SupportedArchitectures</key>
|
|
29
26
|
<array>
|
|
30
27
|
<string>arm64</string>
|
|
31
28
|
<string>arm64e</string>
|
|
29
|
+
<string>x86_64</string>
|
|
32
30
|
</array>
|
|
33
31
|
<key>SupportedPlatform</key>
|
|
34
32
|
<string>ios</string>
|
|
33
|
+
<key>SupportedPlatformVariant</key>
|
|
34
|
+
<string>simulator</string>
|
|
35
35
|
</dict>
|
|
36
36
|
</array>
|
|
37
37
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -6,32 +6,32 @@
|
|
|
6
6
|
<array>
|
|
7
7
|
<dict>
|
|
8
8
|
<key>LibraryIdentifier</key>
|
|
9
|
-
<string>ios-
|
|
9
|
+
<string>ios-arm64_arm64e</string>
|
|
10
10
|
<key>LibraryPath</key>
|
|
11
11
|
<string>libsvg.a</string>
|
|
12
12
|
<key>SupportedArchitectures</key>
|
|
13
13
|
<array>
|
|
14
14
|
<string>arm64</string>
|
|
15
15
|
<string>arm64e</string>
|
|
16
|
-
<string>x86_64</string>
|
|
17
16
|
</array>
|
|
18
17
|
<key>SupportedPlatform</key>
|
|
19
18
|
<string>ios</string>
|
|
20
|
-
<key>SupportedPlatformVariant</key>
|
|
21
|
-
<string>simulator</string>
|
|
22
19
|
</dict>
|
|
23
20
|
<dict>
|
|
24
21
|
<key>LibraryIdentifier</key>
|
|
25
|
-
<string>ios-
|
|
22
|
+
<string>ios-arm64_arm64e_x86_64-simulator</string>
|
|
26
23
|
<key>LibraryPath</key>
|
|
27
24
|
<string>libsvg.a</string>
|
|
28
25
|
<key>SupportedArchitectures</key>
|
|
29
26
|
<array>
|
|
30
27
|
<string>arm64</string>
|
|
31
28
|
<string>arm64e</string>
|
|
29
|
+
<string>x86_64</string>
|
|
32
30
|
</array>
|
|
33
31
|
<key>SupportedPlatform</key>
|
|
34
32
|
<string>ios</string>
|
|
33
|
+
<key>SupportedPlatformVariant</key>
|
|
34
|
+
<string>simulator</string>
|
|
35
35
|
</dict>
|
|
36
36
|
</array>
|
|
37
37
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { SkRRect } from "../../../skia/types";
|
|
1
|
+
import type { InputRRect, SkRRect } from "../../../skia/types";
|
|
2
2
|
import type { DrawingContext, RoundedRectProps } from "../../types";
|
|
3
3
|
import { NodeType } from "../../types";
|
|
4
4
|
import { processRRect } from "../datatypes";
|
|
5
5
|
import { JsiDrawingNode } from "../DrawingNode";
|
|
6
6
|
import type { NodeContext } from "../Node";
|
|
7
7
|
|
|
8
|
-
export class RRectNode extends JsiDrawingNode<RoundedRectProps,
|
|
8
|
+
export class RRectNode extends JsiDrawingNode<RoundedRectProps, InputRRect> {
|
|
9
9
|
rect?: SkRRect;
|
|
10
10
|
|
|
11
11
|
constructor(ctx: NodeContext, props: RoundedRectProps) {
|
|
@@ -23,21 +23,8 @@ export class TextNode extends JsiDrawingNode<TextProps, SkFont | null> {
|
|
|
23
23
|
|
|
24
24
|
protected deriveProps() {
|
|
25
25
|
const { font } = this.props;
|
|
26
|
-
if (font
|
|
27
|
-
return null;
|
|
28
|
-
} else if (font === undefined) {
|
|
29
|
-
console.warn(
|
|
30
|
-
"<Text />: the font property is mandatory on React Native Web"
|
|
31
|
-
);
|
|
26
|
+
if (!font) {
|
|
32
27
|
return null;
|
|
33
|
-
// return this.Skia.Font(
|
|
34
|
-
// this.Skia.FontMgr.System().matchFamilyStyle("System", {
|
|
35
|
-
// width: 5,
|
|
36
|
-
// weight: 400,
|
|
37
|
-
// slant: 0,
|
|
38
|
-
// }),
|
|
39
|
-
// 14
|
|
40
|
-
// );
|
|
41
28
|
}
|
|
42
29
|
return font;
|
|
43
30
|
}
|
package/src/dom/types/Common.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
BlendMode,
|
|
5
5
|
Color,
|
|
6
6
|
InputMatrix,
|
|
7
|
+
InputRRect,
|
|
7
8
|
PaintStyle,
|
|
8
9
|
SkPaint,
|
|
9
10
|
SkPath,
|
|
@@ -48,7 +49,7 @@ export interface RRectCtor extends RectCtor {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
export type RectDef = RectCtor | { rect: SkRect };
|
|
51
|
-
export type RRectDef = RRectCtor | { rect:
|
|
52
|
+
export type RRectDef = RRectCtor | { rect: InputRRect };
|
|
52
53
|
|
|
53
54
|
export interface PointCircleDef {
|
|
54
55
|
c?: Vector;
|
package/src/headless/index.ts
CHANGED
|
@@ -6,13 +6,14 @@ import type { ReactNode } from "react";
|
|
|
6
6
|
import { JsiSkApi } from "../skia/web";
|
|
7
7
|
import { SkiaRoot } from "../renderer/Reconciler";
|
|
8
8
|
import { JsiDrawingContext } from "../dom/types";
|
|
9
|
+
import type { SkSurface } from "../skia";
|
|
9
10
|
|
|
10
11
|
export * from "../renderer/components";
|
|
11
12
|
|
|
12
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
14
|
let Skia: any;
|
|
14
15
|
|
|
15
|
-
export const
|
|
16
|
+
export const makeOffscreenSurface = (width: number, height: number) => {
|
|
16
17
|
if (!Skia) {
|
|
17
18
|
Skia = JsiSkApi(CanvasKit);
|
|
18
19
|
}
|
|
@@ -20,12 +21,15 @@ export const draw = (element: ReactNode, width: number, height: number) => {
|
|
|
20
21
|
if (surface === null) {
|
|
21
22
|
throw new Error("Couldn't create surface!");
|
|
22
23
|
}
|
|
24
|
+
return surface;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const drawOffscreen = (surface: SkSurface, element: ReactNode) => {
|
|
23
28
|
const root = new SkiaRoot(Skia);
|
|
24
29
|
root.render(element);
|
|
25
30
|
const canvas = surface.getCanvas();
|
|
26
31
|
const ctx = new JsiDrawingContext(Skia, canvas);
|
|
27
32
|
root.dom.render(ctx);
|
|
28
33
|
surface.flush();
|
|
29
|
-
|
|
30
|
-
return image;
|
|
34
|
+
return surface.makeImageSnapshot();
|
|
31
35
|
};
|
package/src/skia/types/Canvas.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { SkPath } from "./Path";
|
|
|
5
5
|
import type { SkImage, MipmapMode, FilterMode, ImageInfo } from "./Image";
|
|
6
6
|
import type { SkSVG } from "./SVG";
|
|
7
7
|
import type { SkColor } from "./Color";
|
|
8
|
-
import type {
|
|
8
|
+
import type { InputRRect } from "./RRect";
|
|
9
9
|
import type { BlendMode } from "./Paint/BlendMode";
|
|
10
10
|
import type { SkPoint, PointMode } from "./Point";
|
|
11
11
|
import type { InputMatrix } from "./Matrix";
|
|
@@ -278,7 +278,7 @@ export interface SkCanvas {
|
|
|
278
278
|
* @param rrect
|
|
279
279
|
* @param paint
|
|
280
280
|
*/
|
|
281
|
-
drawRRect(rrect:
|
|
281
|
+
drawRRect(rrect: InputRRect, paint: SkPaint): void;
|
|
282
282
|
|
|
283
283
|
/**
|
|
284
284
|
* Draws RRect outer and inner using clip, Matrix, and Paint paint.
|
|
@@ -287,7 +287,7 @@ export interface SkCanvas {
|
|
|
287
287
|
* @param inner
|
|
288
288
|
* @param paint
|
|
289
289
|
*/
|
|
290
|
-
drawDRRect(outer:
|
|
290
|
+
drawDRRect(outer: InputRRect, inner: InputRRect, paint: SkPaint): void;
|
|
291
291
|
|
|
292
292
|
/**
|
|
293
293
|
* Draws an oval bounded by the given rectangle using the current clip, current matrix,
|
|
@@ -479,7 +479,7 @@ export interface SkCanvas {
|
|
|
479
479
|
* @param op
|
|
480
480
|
* @param doAntiAlias
|
|
481
481
|
*/
|
|
482
|
-
clipRRect(rrect:
|
|
482
|
+
clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean): void;
|
|
483
483
|
|
|
484
484
|
/**
|
|
485
485
|
* Replaces current matrix with m premultiplied with the existing matrix.
|
|
@@ -150,14 +150,16 @@ const rotatedUnitSinCos = (
|
|
|
150
150
|
];
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
/**
|
|
154
|
+
* @worklet
|
|
155
|
+
*/
|
|
156
|
+
export const matrixVecMul4 = (m: Matrix4, v: Vec4): Vec4 => {
|
|
154
157
|
"worklet";
|
|
155
|
-
const [vx, vy, vz, vw] = v;
|
|
156
158
|
return [
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3] * v[3],
|
|
160
|
+
m[4] * v[0] + m[5] * v[1] + m[6] * v[2] + m[7] * v[3],
|
|
161
|
+
m[8] * v[0] + m[9] * v[1] + m[10] * v[2] + m[11] * v[3],
|
|
162
|
+
m[12] * v[0] + m[13] * v[1] + m[14] * v[2] + m[15] * v[3],
|
|
161
163
|
];
|
|
162
164
|
};
|
|
163
165
|
|
|
@@ -2,11 +2,11 @@ import type { SkCanvas } from "../Canvas";
|
|
|
2
2
|
import type { SkJSIInstance } from "../JsiInstance";
|
|
3
3
|
import type { SkRect } from "../Rect";
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type { TextDirection } from "./ParagraphStyle";
|
|
6
6
|
|
|
7
7
|
export interface SkRectWithDirection {
|
|
8
8
|
rect: SkRect;
|
|
9
|
-
direction:
|
|
9
|
+
direction: TextDirection;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export interface SkParagraph extends SkJSIInstance<"Paragraph"> {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { SkTextFontStyle, SkTextStyle } from "./TextStyle";
|
|
2
2
|
|
|
3
|
-
export enum
|
|
3
|
+
export enum TextDirection {
|
|
4
4
|
RTL = 0,
|
|
5
5
|
LTR = 1,
|
|
6
6
|
}
|
|
7
|
-
export enum
|
|
7
|
+
export enum TextAlign {
|
|
8
8
|
Left = 0,
|
|
9
9
|
Right,
|
|
10
10
|
Center,
|
|
@@ -24,7 +24,7 @@ export interface SkStrutStyle {
|
|
|
24
24
|
forceStrutHeight?: boolean;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export enum
|
|
27
|
+
export enum TextHeightBehavior {
|
|
28
28
|
All = 0x0,
|
|
29
29
|
DisableFirstAscent = 0x1,
|
|
30
30
|
DisableLastDescent = 0x2,
|
|
@@ -38,8 +38,8 @@ export interface SkParagraphStyle {
|
|
|
38
38
|
maxLines?: number;
|
|
39
39
|
replaceTabCharacters?: boolean;
|
|
40
40
|
strutStyle?: SkStrutStyle;
|
|
41
|
-
textAlign?:
|
|
42
|
-
textDirection?:
|
|
43
|
-
textHeightBehavior?:
|
|
41
|
+
textAlign?: TextAlign;
|
|
42
|
+
textDirection?: TextDirection;
|
|
43
|
+
textHeightBehavior?: TextHeightBehavior;
|
|
44
44
|
textStyle?: SkTextStyle;
|
|
45
45
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SkRect } from "../Rect";
|
|
2
2
|
import type { SkPoint } from "../Point";
|
|
3
|
-
import type {
|
|
3
|
+
import type { InputRRect } from "../RRect";
|
|
4
4
|
import type { StrokeJoin, StrokeCap } from "../Paint";
|
|
5
5
|
import type { InputMatrix, SkMatrix } from "../Matrix";
|
|
6
6
|
import type { SkJSIInstance } from "../JsiInstance";
|
|
@@ -439,7 +439,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
|
|
|
439
439
|
* @param rrect
|
|
440
440
|
* @param isCCW
|
|
441
441
|
*/
|
|
442
|
-
addRRect(rrect:
|
|
442
|
+
addRRect(rrect: InputRRect, isCCW?: boolean): SkPath;
|
|
443
443
|
|
|
444
444
|
/** Appends src to SkPath, transformed by matrix. Transformed curves may have
|
|
445
445
|
different verbs, SkPoint, and conic weights.
|
package/src/skia/types/RRect.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SkPoint } from "./Point";
|
|
1
2
|
import type { SkRect } from "./Rect";
|
|
2
3
|
|
|
3
4
|
export interface SkRRect {
|
|
@@ -6,6 +7,16 @@ export interface SkRRect {
|
|
|
6
7
|
readonly ry: number;
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
export interface NonUniformRRect {
|
|
11
|
+
readonly rect: SkRect;
|
|
12
|
+
readonly topLeft: SkPoint;
|
|
13
|
+
readonly topRight: SkPoint;
|
|
14
|
+
readonly bottomRight: SkPoint;
|
|
15
|
+
readonly bottomLeft: SkPoint;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type InputRRect = SkRRect | NonUniformRRect;
|
|
19
|
+
|
|
9
20
|
// We have an issue to check property existence on JSI backed instances
|
|
10
21
|
export const isRRect = (def: SkRect | SkRRect): def is SkRRect =>
|
|
11
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -19,7 +19,7 @@ import type {
|
|
|
19
19
|
SkPicture,
|
|
20
20
|
SkPoint,
|
|
21
21
|
SkRect,
|
|
22
|
-
|
|
22
|
+
InputRRect,
|
|
23
23
|
SkSVG,
|
|
24
24
|
SkTextBlob,
|
|
25
25
|
SkVertices,
|
|
@@ -235,14 +235,14 @@ export class JsiSkCanvas
|
|
|
235
235
|
);
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
drawRRect(rrect:
|
|
238
|
+
drawRRect(rrect: InputRRect, paint: SkPaint) {
|
|
239
239
|
this.ref.drawRRect(
|
|
240
240
|
JsiSkRRect.fromValue(this.CanvasKit, rrect),
|
|
241
241
|
JsiSkPaint.fromValue(paint)
|
|
242
242
|
);
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
drawDRRect(outer:
|
|
245
|
+
drawDRRect(outer: InputRRect, inner: InputRRect, paint: SkPaint) {
|
|
246
246
|
this.ref.drawDRRect(
|
|
247
247
|
JsiSkRRect.fromValue(this.CanvasKit, outer),
|
|
248
248
|
JsiSkRRect.fromValue(this.CanvasKit, inner),
|
|
@@ -367,7 +367,7 @@ export class JsiSkCanvas
|
|
|
367
367
|
);
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
clipRRect(rrect:
|
|
370
|
+
clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean) {
|
|
371
371
|
this.ref.clipRRect(
|
|
372
372
|
JsiSkRRect.fromValue(this.CanvasKit, rrect),
|
|
373
373
|
getEnum(this.CanvasKit.PathOp, op),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CanvasKit, ParagraphStyle } from "canvaskit-wasm";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { TextDirection, type SkParagraphStyle } from "../types";
|
|
4
4
|
|
|
5
5
|
export class JsiSkParagraphStyle {
|
|
6
6
|
static toParagraphStyle(
|
|
@@ -23,7 +23,7 @@ export class JsiSkParagraphStyle {
|
|
|
23
23
|
: undefined ?? ps.textAlign;
|
|
24
24
|
ps.textDirection =
|
|
25
25
|
value.textDirection !== undefined
|
|
26
|
-
? { value: value.textDirection ===
|
|
26
|
+
? { value: value.textDirection === TextDirection.LTR ? 1 : 0 }
|
|
27
27
|
: ps.textDirection;
|
|
28
28
|
ps.textHeightBehavior =
|
|
29
29
|
value.textHeightBehavior !== undefined
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
SkPath,
|
|
10
10
|
SkPoint,
|
|
11
11
|
SkRect,
|
|
12
|
-
|
|
12
|
+
InputRRect,
|
|
13
13
|
StrokeOpts,
|
|
14
14
|
} from "../types";
|
|
15
15
|
|
|
@@ -285,7 +285,7 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
|
|
|
285
285
|
return this;
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
-
addRRect(rrect:
|
|
288
|
+
addRRect(rrect: InputRRect, isCCW?: boolean) {
|
|
289
289
|
this.ref.addRRect(JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);
|
|
290
290
|
return this;
|
|
291
291
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CanvasKit, RRect } from "canvaskit-wasm";
|
|
2
2
|
|
|
3
|
-
import type { SkRect, SkRRect } from "../types";
|
|
3
|
+
import type { InputRRect, SkRect, SkRRect } from "../types";
|
|
4
4
|
|
|
5
5
|
import { BaseHostObject } from "./Host";
|
|
6
6
|
import { JsiSkRect } from "./JsiSkRect";
|
|
@@ -13,10 +13,31 @@ export class JsiSkRRect
|
|
|
13
13
|
// Float32Array
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
static fromValue(CanvasKit: CanvasKit, rect:
|
|
16
|
+
static fromValue(CanvasKit: CanvasKit, rect: InputRRect) {
|
|
17
17
|
if (rect instanceof JsiSkRect) {
|
|
18
18
|
return rect.ref;
|
|
19
19
|
}
|
|
20
|
+
if (
|
|
21
|
+
"topLeft" in rect &&
|
|
22
|
+
"topRight" in rect &&
|
|
23
|
+
"bottomRight" in rect &&
|
|
24
|
+
"bottomLeft" in rect
|
|
25
|
+
) {
|
|
26
|
+
return Float32Array.of(
|
|
27
|
+
rect.rect.x,
|
|
28
|
+
rect.rect.y,
|
|
29
|
+
rect.rect.x + rect.rect.width,
|
|
30
|
+
rect.rect.y + rect.rect.height,
|
|
31
|
+
rect.topLeft.x,
|
|
32
|
+
rect.topLeft.y,
|
|
33
|
+
rect.topRight.x,
|
|
34
|
+
rect.topRight.y,
|
|
35
|
+
rect.bottomRight.x,
|
|
36
|
+
rect.bottomRight.y,
|
|
37
|
+
rect.bottomLeft.x,
|
|
38
|
+
rect.bottomLeft.y
|
|
39
|
+
);
|
|
40
|
+
}
|
|
20
41
|
return CanvasKit.RRectXY(
|
|
21
42
|
JsiSkRect.fromValue(CanvasKit, rect.rect),
|
|
22
43
|
rect.rx,
|
package/src/web/LoadSkiaWeb.tsx
CHANGED
|
@@ -10,11 +10,14 @@ declare global {
|
|
|
10
10
|
var CanvasKit: CanvasKitType;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
let ckSharedPromise: Promise<CanvasKitType>;
|
|
14
|
+
|
|
13
15
|
export const LoadSkiaWeb = async (opts?: CanvasKitInitOptions) => {
|
|
14
16
|
if (global.CanvasKit !== undefined) {
|
|
15
17
|
return;
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
ckSharedPromise = ckSharedPromise ?? CanvasKitInit(opts);
|
|
20
|
+
const CanvasKit = await ckSharedPromise;
|
|
18
21
|
// The CanvasKit API is stored on the global object and used
|
|
19
22
|
// to create the JsiSKApi in the Skia.web.ts file.
|
|
20
23
|
global.CanvasKit = CanvasKit;
|