@shopify/react-native-skia 0.1.121 → 0.1.124
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 +3 -1
- package/android/cpp/jni/JniSkiaDrawView.cpp +14 -71
- package/android/cpp/jni/JniSkiaManager.cpp +1 -1
- package/android/cpp/jni/include/JniSkiaDrawView.h +18 -22
- package/android/cpp/jni/include/JniSkiaManager.h +4 -4
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +68 -0
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.h +48 -0
- package/android/cpp/{jni/include/JniPlatformContextWrapper.h → rnskia-android/RNSkPlatformContextImpl.h} +4 -4
- package/android/cpp/{jni → rnskia-android}/SkiaOpenGLRenderer.cpp +39 -54
- package/android/cpp/{jni/include → rnskia-android}/SkiaOpenGLRenderer.h +2 -31
- package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaViewManager.java +1 -1
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDrawView.java +21 -28
- package/cpp/api/JsiSkApi.h +2 -0
- package/cpp/api/JsiSkColor.h +49 -0
- package/cpp/api/JsiSkPath.h +31 -2
- package/cpp/api/JsiSkPathFactory.h +96 -1
- package/cpp/api/third_party/CSSColorParser.h +324 -0
- package/cpp/rnskia/RNSkAnimation.h +3 -8
- package/cpp/rnskia/RNSkDrawView.cpp +84 -126
- package/cpp/rnskia/RNSkDrawView.h +7 -37
- package/cpp/rnskia/RNSkJsiViewApi.h +8 -5
- package/cpp/rnskia/RNSkManager.cpp +2 -2
- package/cpp/rnskia/RNSkManager.h +2 -2
- package/cpp/rnskia/RNSkPlatformContext.h +1 -1
- package/cpp/rnskia/RNSkValueApi.h +6 -2
- package/cpp/rnskia/values/RNSkClockValue.h +21 -13
- package/cpp/rnskia/values/RNSkDerivedValue.h +13 -6
- package/cpp/rnskia/values/RNSkReadonlyValue.h +17 -16
- package/cpp/rnskia/values/RNSkValue.h +8 -3
- package/cpp/utils/RNSkTimingInfo.h +13 -1
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +8 -10
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +25 -10
- package/ios/RNSkia-iOS/SkiaDrawView.mm +21 -16
- package/lib/commonjs/renderer/Canvas.js +17 -8
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/components/Paint.js +1 -1
- package/lib/commonjs/renderer/components/Paint.js.map +1 -1
- package/lib/commonjs/renderer/components/colorFilters/Lerp.js +1 -1
- package/lib/commonjs/renderer/components/colorFilters/Lerp.js.map +1 -1
- package/lib/commonjs/renderer/components/shaders/Shader.js +2 -2
- package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/Path.js +10 -2
- package/lib/commonjs/renderer/components/shapes/Path.js.map +1 -1
- package/lib/commonjs/renderer/nodes/Node.js +3 -3
- package/lib/commonjs/renderer/nodes/Node.js.map +1 -1
- package/lib/commonjs/renderer/processors/Circles.js +3 -2
- package/lib/commonjs/renderer/processors/Circles.js.map +1 -1
- package/lib/commonjs/renderer/processors/Font.js +1 -1
- package/lib/commonjs/renderer/processors/Font.js.map +1 -1
- package/lib/commonjs/renderer/processors/Paint.js +6 -1
- package/lib/commonjs/renderer/processors/Paint.js.map +1 -1
- package/lib/commonjs/renderer/processors/Rects.js +6 -6
- package/lib/commonjs/renderer/processors/Rects.js.map +1 -1
- package/lib/commonjs/skia/Color.js +3 -25
- package/lib/commonjs/skia/Color.js.map +1 -1
- package/lib/commonjs/skia/Image/Image.js.map +1 -1
- package/lib/commonjs/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/Paint/Paint.js +13 -1
- package/lib/commonjs/skia/Paint/Paint.js.map +1 -1
- package/lib/commonjs/skia/Paint/usePaint.js +2 -4
- package/lib/commonjs/skia/Paint/usePaint.js.map +1 -1
- package/lib/commonjs/skia/Path/Path.js +13 -1
- package/lib/commonjs/skia/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/Shader/Shader.js.map +1 -1
- package/lib/commonjs/skia/Skia.js +43 -3
- package/lib/commonjs/skia/Skia.js.map +1 -1
- package/lib/commonjs/values/animation/timing/functions/getResolvedParams.js +3 -3
- package/lib/commonjs/values/animation/timing/functions/getResolvedParams.js.map +1 -1
- package/lib/module/renderer/Canvas.js +12 -6
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/components/Paint.js +2 -2
- package/lib/module/renderer/components/Paint.js.map +1 -1
- package/lib/module/renderer/components/colorFilters/Lerp.js +1 -1
- package/lib/module/renderer/components/colorFilters/Lerp.js.map +1 -1
- package/lib/module/renderer/components/shaders/Shader.js +3 -2
- package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/module/renderer/components/shapes/Path.js +10 -3
- package/lib/module/renderer/components/shapes/Path.js.map +1 -1
- package/lib/module/renderer/nodes/Node.js +3 -3
- package/lib/module/renderer/nodes/Node.js.map +1 -1
- package/lib/module/renderer/processors/Circles.js +3 -2
- package/lib/module/renderer/processors/Circles.js.map +1 -1
- package/lib/module/renderer/processors/Font.js +1 -1
- package/lib/module/renderer/processors/Font.js.map +1 -1
- package/lib/module/renderer/processors/Paint.js +6 -1
- package/lib/module/renderer/processors/Paint.js.map +1 -1
- package/lib/module/renderer/processors/Rects.js +5 -6
- package/lib/module/renderer/processors/Rects.js.map +1 -1
- package/lib/module/skia/Color.js +2 -21
- package/lib/module/skia/Color.js.map +1 -1
- package/lib/module/skia/Image/Image.js.map +1 -1
- package/lib/module/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/module/skia/Paint/Paint.js +6 -0
- package/lib/module/skia/Paint/Paint.js.map +1 -1
- package/lib/module/skia/Paint/usePaint.js +2 -3
- package/lib/module/skia/Paint/usePaint.js.map +1 -1
- package/lib/module/skia/Path/Path.js +11 -0
- package/lib/module/skia/Path/Path.js.map +1 -1
- package/lib/module/skia/Shader/Shader.js.map +1 -1
- package/lib/module/skia/Skia.js +45 -2
- package/lib/module/skia/Skia.js.map +1 -1
- package/lib/module/values/animation/timing/functions/getResolvedParams.js +3 -3
- package/lib/module/values/animation/timing/functions/getResolvedParams.js.map +1 -1
- package/lib/typescript/src/renderer/Canvas.d.ts +6 -0
- package/lib/typescript/src/renderer/components/shapes/Path.d.ts +3 -1
- package/lib/typescript/src/renderer/processors/Paint.d.ts +2 -1
- package/lib/typescript/src/skia/Color.d.ts +0 -1
- package/lib/typescript/src/skia/Image/Image.d.ts +3 -3
- package/lib/typescript/src/skia/ImageFilter/ImageFilterFactory.d.ts +2 -2
- package/lib/typescript/src/skia/Paint/Paint.d.ts +3 -2
- package/lib/typescript/src/skia/Path/Path.d.ts +13 -0
- package/lib/typescript/src/skia/Path/PathFactory.d.ts +7 -1
- package/lib/typescript/src/skia/Picture/Picture.d.ts +2 -2
- package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffect.d.ts +3 -3
- package/lib/typescript/src/skia/Shader/Shader.d.ts +2 -2
- package/lib/typescript/src/skia/Shader/ShaderFactory.d.ts +9 -9
- package/lib/typescript/src/skia/Skia.d.ts +5 -3
- package/lib/typescript/src/values/animation/types.d.ts +5 -5
- package/package.json +1 -1
- package/scripts/install-npm.js +1 -1
- package/src/renderer/Canvas.tsx +13 -6
- package/src/renderer/components/Paint.tsx +2 -2
- package/src/renderer/components/colorFilters/Lerp.tsx +1 -1
- package/src/renderer/components/shaders/Shader.tsx +1 -1
- package/src/renderer/components/shapes/Path.tsx +12 -4
- package/src/renderer/nodes/Node.ts +3 -3
- package/src/renderer/processors/Circles.ts +2 -1
- package/src/renderer/processors/Font.ts +1 -1
- package/src/renderer/processors/Paint.ts +5 -0
- package/src/renderer/processors/Rects.ts +3 -2
- package/src/skia/Color.ts +3 -20
- package/src/skia/Image/Image.ts +3 -3
- package/src/skia/ImageFilter/ImageFilterFactory.ts +2 -2
- package/src/skia/Paint/Paint.ts +9 -2
- package/src/skia/Paint/usePaint.ts +2 -4
- package/src/skia/Path/Path.ts +16 -0
- package/src/skia/Path/PathFactory.ts +8 -1
- package/src/skia/Picture/Picture.ts +2 -2
- package/src/skia/RuntimeEffect/RuntimeEffect.ts +4 -4
- package/src/skia/Shader/Shader.ts +2 -2
- package/src/skia/Shader/ShaderFactory.ts +9 -9
- package/src/skia/Skia.ts +47 -3
- package/src/values/animation/timing/functions/getResolvedParams.ts +2 -2
- package/src/values/animation/types.ts +5 -5
package/src/skia/Skia.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Platform, processColor } from "react-native";
|
|
2
|
+
|
|
1
3
|
/*global SkiaApi*/
|
|
2
4
|
import type { ImageFilterFactory } from "./ImageFilter";
|
|
3
5
|
import type { PathFactory } from "./Path";
|
|
@@ -11,8 +13,6 @@ import type { SkRect } from "./Rect";
|
|
|
11
13
|
import type { SkRRect } from "./RRect";
|
|
12
14
|
import type { RuntimeEffectFactory } from "./RuntimeEffect";
|
|
13
15
|
import type { ShaderFactory } from "./Shader";
|
|
14
|
-
import type { SkColor } from "./Color";
|
|
15
|
-
import { processColor } from "./Color";
|
|
16
16
|
import type { SkMatrix } from "./Matrix";
|
|
17
17
|
import type { PathEffectFactory } from "./PathEffect";
|
|
18
18
|
import type { SkPoint } from "./Point";
|
|
@@ -27,6 +27,45 @@ import type { SkRSXform } from "./RSXform";
|
|
|
27
27
|
import type { SkPath } from "./Path/Path";
|
|
28
28
|
import type { SkContourMeasureIter } from "./ContourMeasure";
|
|
29
29
|
import type { PictureFactory, SkPictureRecorder } from "./Picture";
|
|
30
|
+
import type { Color, SkColor } from "./Color";
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
* Parse CSS colors
|
|
34
|
+
*/
|
|
35
|
+
const SkiaColor = (cl: Color) => {
|
|
36
|
+
if (typeof cl === "number") {
|
|
37
|
+
return cl;
|
|
38
|
+
}
|
|
39
|
+
const color = Skia.parseColorString(cl);
|
|
40
|
+
if (color !== undefined) {
|
|
41
|
+
return color;
|
|
42
|
+
} else {
|
|
43
|
+
// If the color is not recognized, we fallback to React Native
|
|
44
|
+
let rnColor = processColor(cl);
|
|
45
|
+
// 1. Neither Skia or RN could parse the color
|
|
46
|
+
if (typeof rnColor !== "number") {
|
|
47
|
+
console.warn("Skia couldn't parse the following color " + cl);
|
|
48
|
+
return BLACK;
|
|
49
|
+
// 2. The color is recognized by RN but not by Skia
|
|
50
|
+
} else {
|
|
51
|
+
console.warn(
|
|
52
|
+
"Skia couldn't parse the following color " +
|
|
53
|
+
cl +
|
|
54
|
+
". The color parsing was delegated to React Native. Please file on issue with that color."
|
|
55
|
+
);
|
|
56
|
+
// On android we need to move the alpha byte to the start of the structure
|
|
57
|
+
if (Platform.OS === "android") {
|
|
58
|
+
rnColor = rnColor >>> 0;
|
|
59
|
+
const a = (rnColor >> 24) & 0xff;
|
|
60
|
+
const r = (rnColor >> 16) & 0xff;
|
|
61
|
+
const g = (rnColor >> 8) & 0xff;
|
|
62
|
+
const b = rnColor & 0xff;
|
|
63
|
+
rnColor = ((a << 24) | (r << 16) | (g << 8) | b) >>> 0;
|
|
64
|
+
}
|
|
65
|
+
return rnColor;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
30
69
|
|
|
31
70
|
/**
|
|
32
71
|
* Declares the interface for the native Skia API
|
|
@@ -36,6 +75,8 @@ export interface Skia {
|
|
|
36
75
|
XYWHRect: (x: number, y: number, width: number, height: number) => SkRect;
|
|
37
76
|
RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;
|
|
38
77
|
RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;
|
|
78
|
+
Color: (color: Color) => SkColor;
|
|
79
|
+
parseColorString: (color: string) => SkColor | undefined;
|
|
39
80
|
ContourMeasureIter: (
|
|
40
81
|
path: SkPath,
|
|
41
82
|
forceClosed: boolean,
|
|
@@ -115,7 +156,8 @@ export const Skia = {
|
|
|
115
156
|
ColorFilter: SkiaApi.ColorFilter,
|
|
116
157
|
ContourMeasureIter: SkiaApi.ContourMeasureIter,
|
|
117
158
|
// Here are constructors for data types which are represented as typed arrays in CanvasKit
|
|
118
|
-
Color:
|
|
159
|
+
Color: SkiaColor,
|
|
160
|
+
parseColorString: SkiaApi.parseColorString,
|
|
119
161
|
RSXform: SkiaApi.RSXform,
|
|
120
162
|
// For the following methods the factory symmetry is broken to be comptatible with CanvasKit
|
|
121
163
|
MakeSurface: SkiaApi.Surface.Make,
|
|
@@ -123,3 +165,5 @@ export const Skia = {
|
|
|
123
165
|
MakeImage: SkiaApi.Image.MakeImage,
|
|
124
166
|
MakeVertices: SkiaApi.MakeVertices,
|
|
125
167
|
};
|
|
168
|
+
|
|
169
|
+
const BLACK = Skia.parseColorString("black")!;
|
|
@@ -42,8 +42,8 @@ export const getResolvedParams = (
|
|
|
42
42
|
|
|
43
43
|
const resolvedConfig: Required<TimingConfig> = { ...DefaultTimingConfig };
|
|
44
44
|
if (config) {
|
|
45
|
-
resolvedConfig.duration = config.duration;
|
|
46
|
-
resolvedConfig.easing = config.easing ??
|
|
45
|
+
resolvedConfig.duration = config.duration ?? DefaultTimingConfig.duration;
|
|
46
|
+
resolvedConfig.easing = config.easing ?? DefaultTimingConfig.easing;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return { ...resolvedParameters, ...resolvedConfig };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export interface SpringConfig {
|
|
2
|
-
mass
|
|
3
|
-
stiffness
|
|
4
|
-
damping
|
|
5
|
-
velocity
|
|
2
|
+
mass?: number;
|
|
3
|
+
stiffness?: number;
|
|
4
|
+
damping?: number;
|
|
5
|
+
velocity?: number;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface TimingConfig {
|
|
9
|
-
duration
|
|
9
|
+
duration?: number;
|
|
10
10
|
easing?: (t: number) => number;
|
|
11
11
|
}
|
|
12
12
|
|