@shopify/react-native-skia 0.1.207 → 0.1.209
Sign up to get free protection for your applications and to get access to all the features.
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +19 -12
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +1 -1
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomView.java +1 -1
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDrawView.java +1 -1
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaPictureView.java +1 -1
- package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +2 -0
- package/cpp/api/JsiSkColorFilter.h +1 -1
- package/cpp/api/JsiSkContourMeasure.h +1 -1
- package/cpp/api/JsiSkContourMeasureIter.h +1 -1
- package/cpp/api/JsiSkData.h +1 -1
- package/cpp/api/JsiSkFont.h +1 -1
- package/cpp/api/JsiSkFontMgr.h +2 -2
- package/cpp/api/JsiSkFontStyle.h +11 -5
- package/cpp/api/JsiSkImage.h +1 -1
- package/cpp/api/JsiSkImageFilter.h +1 -1
- package/cpp/api/JsiSkMaskFilter.h +1 -1
- package/cpp/api/JsiSkMatrix.h +1 -1
- package/cpp/api/JsiSkPaint.h +8 -1
- package/cpp/api/JsiSkPath.h +11 -8
- package/cpp/api/JsiSkPathEffect.h +1 -1
- package/cpp/api/JsiSkPicture.h +1 -1
- package/cpp/api/JsiSkPictureRecorder.h +1 -1
- package/cpp/api/JsiSkRuntimeEffect.h +1 -1
- package/cpp/api/JsiSkSVG.h +1 -1
- package/cpp/api/JsiSkShader.h +1 -1
- package/cpp/api/JsiSkSurface.h +1 -1
- package/cpp/api/JsiSkTextBlob.h +1 -1
- package/cpp/api/JsiSkTypeFaceFontProvider.h +4 -2
- package/cpp/api/JsiSkTypeface.h +24 -2
- package/cpp/api/JsiSkVertices.h +1 -1
- package/cpp/rnskia/dom/base/JsiDomRenderNode.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiPaintNode.h +4 -0
- package/cpp/rnskia/dom/props/FontProp.h +3 -1
- package/cpp/rnskia/dom/props/PaintProps.h +3 -0
- package/lib/commonjs/dom/nodes/PaintContext.d.ts +1 -0
- package/lib/commonjs/dom/nodes/PaintContext.js.map +1 -1
- package/lib/commonjs/dom/nodes/PaintNode.js +6 -1
- package/lib/commonjs/dom/nodes/PaintNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/RenderNode.js +1 -1
- package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/Text.d.ts +3 -3
- package/lib/commonjs/dom/nodes/drawings/Text.js +26 -4
- package/lib/commonjs/dom/nodes/drawings/Text.js.map +1 -1
- package/lib/commonjs/dom/types/Common.d.ts +1 -0
- package/lib/commonjs/dom/types/Common.js.map +1 -1
- package/lib/commonjs/dom/types/DrawingContext.js +15 -0
- package/lib/commonjs/dom/types/DrawingContext.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/external/reanimated/moduleWrapper.js +1 -1
- package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/commonjs/skia/types/Font/FontMgr.d.ts +1 -1
- package/lib/commonjs/skia/types/Font/FontMgr.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +12 -11
- package/lib/commonjs/skia/types/Image/ImageFactory.js +12 -11
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Paint/Paint.d.ts +5 -0
- package/lib/commonjs/skia/types/Paint/Paint.js.map +1 -1
- package/lib/commonjs/skia/types/Typeface/Typeface.d.ts +10 -1
- package/lib/commonjs/skia/types/Typeface/Typeface.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkPaint.js +4 -0
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js +10 -1
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTypeface.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkTypeface.js +4 -0
- package/lib/commonjs/skia/web/JsiSkTypeface.js.map +1 -1
- package/lib/module/dom/nodes/PaintContext.d.ts +1 -0
- package/lib/module/dom/nodes/PaintContext.js.map +1 -1
- package/lib/module/dom/nodes/PaintNode.js +6 -1
- package/lib/module/dom/nodes/PaintNode.js.map +1 -1
- package/lib/module/dom/nodes/RenderNode.js +1 -1
- package/lib/module/dom/nodes/RenderNode.js.map +1 -1
- package/lib/module/dom/nodes/drawings/Text.d.ts +3 -3
- package/lib/module/dom/nodes/drawings/Text.js +26 -4
- package/lib/module/dom/nodes/drawings/Text.js.map +1 -1
- package/lib/module/dom/types/Common.d.ts +1 -0
- package/lib/module/dom/types/Common.js.map +1 -1
- package/lib/module/dom/types/DrawingContext.js +15 -0
- package/lib/module/dom/types/DrawingContext.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/external/reanimated/moduleWrapper.js +1 -1
- package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/module/skia/types/Font/FontMgr.d.ts +1 -1
- package/lib/module/skia/types/Font/FontMgr.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +12 -11
- package/lib/module/skia/types/Image/ImageFactory.js +12 -11
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/Paint/Paint.d.ts +5 -0
- package/lib/module/skia/types/Paint/Paint.js.map +1 -1
- package/lib/module/skia/types/Typeface/Typeface.d.ts +10 -1
- package/lib/module/skia/types/Typeface/Typeface.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/module/skia/web/JsiSkPaint.js +4 -0
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.d.ts +1 -1
- package/lib/module/skia/web/JsiSkPath.js +11 -1
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkTypeface.d.ts +1 -0
- package/lib/module/skia/web/JsiSkTypeface.js +4 -0
- package/lib/module/skia/web/JsiSkTypeface.js.map +1 -1
- package/lib/typescript/src/dom/nodes/PaintContext.d.ts +1 -0
- package/lib/typescript/src/dom/nodes/drawings/Text.d.ts +3 -3
- package/lib/typescript/src/dom/types/Common.d.ts +1 -0
- package/lib/typescript/src/dom/types/Drawings.d.ts +1 -1
- package/lib/typescript/src/skia/types/Font/FontMgr.d.ts +1 -1
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +12 -11
- package/lib/typescript/src/skia/types/Paint/Paint.d.ts +5 -0
- package/lib/typescript/src/skia/types/Typeface/Typeface.d.ts +10 -1
- package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkPath.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkTypeface.d.ts +1 -0
- package/package.json +2 -2
- package/src/dom/nodes/PaintContext.ts +1 -0
- package/src/dom/nodes/PaintNode.ts +4 -0
- package/src/dom/nodes/RenderNode.ts +1 -0
- package/src/dom/nodes/drawings/Text.ts +31 -5
- package/src/dom/types/Common.ts +1 -0
- package/src/dom/types/DrawingContext.ts +13 -0
- package/src/dom/types/Drawings.ts +1 -1
- package/src/external/reanimated/moduleWrapper.ts +1 -1
- package/src/skia/types/Font/FontMgr.ts +1 -1
- package/src/skia/types/Image/ImageFactory.ts +1 -0
- package/src/skia/types/Paint/Paint.ts +6 -0
- package/src/skia/types/Typeface/Typeface.ts +10 -1
- package/src/skia/web/JsiSkPaint.ts +4 -0
- package/src/skia/web/JsiSkPath.ts +8 -1
- package/src/skia/web/JsiSkTypeface.ts +4 -0
@@ -1,4 +1,9 @@
|
|
1
|
-
import type {
|
1
|
+
import type {
|
2
|
+
SkRSXform,
|
3
|
+
SkTextBlob,
|
4
|
+
SkPoint,
|
5
|
+
SkFont,
|
6
|
+
} from "../../../skia/types";
|
2
7
|
import type {
|
3
8
|
DrawingContext,
|
4
9
|
TextBlobProps,
|
@@ -11,18 +16,39 @@ import type { GlyphsProps } from "../../types/Drawings";
|
|
11
16
|
import { JsiDrawingNode } from "../DrawingNode";
|
12
17
|
import type { NodeContext } from "../Node";
|
13
18
|
|
14
|
-
export class TextNode extends JsiDrawingNode<TextProps, null> {
|
19
|
+
export class TextNode extends JsiDrawingNode<TextProps, SkFont | null> {
|
15
20
|
constructor(ctx: NodeContext, props: TextProps) {
|
16
21
|
super(ctx, NodeType.Text, props);
|
17
22
|
}
|
18
23
|
|
19
24
|
protected deriveProps() {
|
20
|
-
|
25
|
+
const { font } = this.props;
|
26
|
+
if (font === null) {
|
27
|
+
return null;
|
28
|
+
} else if (font === undefined) {
|
29
|
+
console.warn(
|
30
|
+
"<Text />: the font property is mandatory on React Native Web"
|
31
|
+
);
|
32
|
+
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
|
+
}
|
42
|
+
return font;
|
21
43
|
}
|
22
44
|
|
23
45
|
draw({ canvas, paint }: DrawingContext) {
|
24
|
-
const { text, x, y
|
25
|
-
|
46
|
+
const { text, x, y } = this.props;
|
47
|
+
const font = this.derived;
|
48
|
+
if (font === undefined) {
|
49
|
+
throw new Error("TextNode: font hasn't been derived");
|
50
|
+
}
|
51
|
+
if (font != null) {
|
26
52
|
canvas.drawText(text, x, y, paint, font);
|
27
53
|
}
|
28
54
|
}
|
package/src/dom/types/Common.ts
CHANGED
@@ -76,6 +76,7 @@ class ConcatablePaint {
|
|
76
76
|
_strokeMiter?: number;
|
77
77
|
_opacity = 1;
|
78
78
|
_antiAlias?: boolean;
|
79
|
+
_dither?: boolean;
|
79
80
|
|
80
81
|
_imageFilter?: SkImageFilter;
|
81
82
|
_shader?: SkShader;
|
@@ -97,6 +98,7 @@ class ConcatablePaint {
|
|
97
98
|
this.setStrokeMiter(props.strokeMiter);
|
98
99
|
this.setOpacity(props.opacity);
|
99
100
|
this.setAntiAlias(props.antiAlias);
|
101
|
+
this.setDither(props.dither);
|
100
102
|
declCtx.save();
|
101
103
|
children.forEach((child) => {
|
102
104
|
if (child instanceof JsiDeclarationNode) {
|
@@ -215,6 +217,14 @@ class ConcatablePaint {
|
|
215
217
|
return this._antiAlias;
|
216
218
|
}
|
217
219
|
|
220
|
+
setDither(dither?: boolean) {
|
221
|
+
this.setValue("_dither", dither);
|
222
|
+
}
|
223
|
+
|
224
|
+
getDither() {
|
225
|
+
return this._dither;
|
226
|
+
}
|
227
|
+
|
218
228
|
setImageFilter(imageFilter?: SkImageFilter) {
|
219
229
|
this.setValue("_imageFilter", imageFilter);
|
220
230
|
}
|
@@ -290,6 +300,9 @@ class ConcatablePaint {
|
|
290
300
|
if (this._antiAlias !== undefined) {
|
291
301
|
paint.setAntiAlias(this._antiAlias);
|
292
302
|
}
|
303
|
+
if (this._dither !== undefined) {
|
304
|
+
paint.setDither(this._dither);
|
305
|
+
}
|
293
306
|
if (this._imageFilter !== undefined) {
|
294
307
|
paint.setImageFilter(this._imageFilter);
|
295
308
|
}
|
@@ -30,7 +30,7 @@ function throwOnMissingReanimated2() {
|
|
30
30
|
if (!HAS_REANIMATED2) {
|
31
31
|
throw new Error(
|
32
32
|
"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \
|
33
|
-
react-
|
33
|
+
react-native-skia's integration layer API."
|
34
34
|
);
|
35
35
|
}
|
36
36
|
}
|
@@ -6,5 +6,5 @@ import type { FontStyle } from "./Font";
|
|
6
6
|
export interface SkFontMgr extends SkJSIInstance<"FontMgr"> {
|
7
7
|
countFamilies(): number;
|
8
8
|
getFamilyName(index: number): string;
|
9
|
-
matchFamilyStyle(name
|
9
|
+
matchFamilyStyle(name?: string, style?: FontStyle): SkTypeface;
|
10
10
|
}
|
@@ -21,6 +21,7 @@ export enum ColorType {
|
|
21
21
|
BGRA_1010102, //!< 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
|
22
22
|
RGB_101010x, //!< pixel with 10 bits each for red, green, blue; in 32-bit word
|
23
23
|
BGR_101010x, //!< pixel with 10 bits each for blue, green, red; in 32-bit word
|
24
|
+
BGR_101010x_XR, //!< pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
|
24
25
|
Gray_8, //!< pixel with grayscale level in 8-bit byte
|
25
26
|
RGBA_F16Norm, //!< pixel with half floats in [0,1] for red, green, blue, alpha;
|
26
27
|
// in 64-bit word
|
@@ -84,6 +84,12 @@ export interface SkPaint extends SkJSIInstance<"Paint"> {
|
|
84
84
|
*/
|
85
85
|
setAntiAlias: (aa: boolean) => void;
|
86
86
|
|
87
|
+
/**
|
88
|
+
* Requests, but does not require, to distribute color error.
|
89
|
+
* @param dither
|
90
|
+
*/
|
91
|
+
setDither: (dither: boolean) => void;
|
92
|
+
|
87
93
|
/**
|
88
94
|
* Sets the blend mode that is, the mode used to combine source color
|
89
95
|
* with destination color.
|
@@ -1,3 +1,12 @@
|
|
1
1
|
import type { SkJSIInstance } from "../JsiInstance";
|
2
2
|
|
3
|
-
export
|
3
|
+
export interface SkTypeface extends SkJSIInstance<"Typeface"> {
|
4
|
+
/**
|
5
|
+
* Retrieves the glyph ids for each code point in the provided string. This call is passed to
|
6
|
+
* the typeface of this font. Note that glyph IDs are typeface-dependent; different faces
|
7
|
+
* may have different ids for the same code point.
|
8
|
+
* @param str
|
9
|
+
* @param numCodePoints - the number of code points in the string. Defaults to str.length.
|
10
|
+
*/
|
11
|
+
getGlyphIDs(str: string, numCodePoints?: number): number[];
|
12
|
+
}
|
@@ -70,6 +70,10 @@ export class JsiSkPaint extends HostObject<Paint, "Paint"> implements SkPaint {
|
|
70
70
|
this.ref.setAntiAlias(aa);
|
71
71
|
}
|
72
72
|
|
73
|
+
setDither(dither: boolean) {
|
74
|
+
this.ref.setDither(dither);
|
75
|
+
}
|
76
|
+
|
73
77
|
setBlendMode(blendMode: BlendMode) {
|
74
78
|
this.ref.setBlendMode(ckEnum(blendMode));
|
75
79
|
}
|
@@ -28,6 +28,8 @@ const CommandCount = {
|
|
28
28
|
[PathVerb.Close]: 1,
|
29
29
|
};
|
30
30
|
|
31
|
+
const pinT = (t: number) => Math.min(Math.max(t, 0), 1);
|
32
|
+
|
31
33
|
export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
|
32
34
|
constructor(CanvasKit: CanvasKit, ref: Path) {
|
33
35
|
super(CanvasKit, ref, "Path");
|
@@ -317,7 +319,12 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
|
|
317
319
|
return this.ref.toSVGString();
|
318
320
|
}
|
319
321
|
|
320
|
-
trim(
|
322
|
+
trim(start: number, stop: number, isComplement: boolean) {
|
323
|
+
const startT = pinT(start);
|
324
|
+
const stopT = pinT(stop);
|
325
|
+
if (startT === 0 && stopT === 1) {
|
326
|
+
return this;
|
327
|
+
}
|
321
328
|
const result = this.ref.trim(startT, stopT, isComplement);
|
322
329
|
return result === null ? result : this;
|
323
330
|
}
|