@shopify/react-native-skia 0.1.165 → 0.1.166
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 +16 -5
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +34 -0
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomViewManager.java +2 -47
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDrawViewManager.java +2 -44
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaPictureViewManager.java +2 -47
- package/cpp/rnskia/dom/base/DerivedNodeProp.h +4 -4
- package/cpp/rnskia/dom/nodes/JsiBoxNode.h +4 -4
- package/cpp/rnskia/dom/nodes/JsiPathNode.h +12 -5
- package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +17 -7
- package/cpp/rnskia/dom/props/ClipProp.h +6 -6
- package/cpp/rnskia/dom/props/ImageProps.h +3 -1
- package/cpp/rnskia/dom/props/PaintProps.h +0 -16
- package/cpp/rnskia/dom/props/VerticesProps.h +2 -2
- package/lib/commonjs/dom/nodes/drawings/Box.js +1 -1
- package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/ImageFilters.js +1 -1
- package/lib/commonjs/dom/nodes/paint/ImageFilters.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/Shaders.js +5 -2
- package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/commonjs/skia/types/Shader/Shader.js +26 -27
- package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
- package/lib/module/dom/nodes/drawings/Box.js +1 -1
- package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
- package/lib/module/dom/nodes/paint/ImageFilters.js +1 -1
- package/lib/module/dom/nodes/paint/ImageFilters.js.map +1 -1
- package/lib/module/dom/nodes/paint/Shaders.js +5 -4
- package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/module/skia/types/Shader/Shader.js +26 -27
- package/lib/module/skia/types/Shader/Shader.js.map +1 -1
- package/lib/typescript/src/skia/types/Shader/Shader.d.ts +1 -2
- package/package.json +1 -1
- package/src/dom/nodes/drawings/Box.ts +1 -1
- package/src/dom/nodes/paint/ImageFilters.ts +1 -1
- package/src/dom/nodes/paint/Shaders.ts +5 -5
- package/src/skia/types/Shader/Shader.ts +30 -38
@@ -7,9 +7,7 @@ export const isShader = (obj: SkJSIInstance<string> | null): obj is SkShader =>
|
|
7
7
|
|
8
8
|
export type SkShader = SkJSIInstance<"Shader">;
|
9
9
|
|
10
|
-
export type
|
11
|
-
|
12
|
-
export type Uniform = UniformValue | readonly UniformValue[] | Float32Array;
|
10
|
+
export type Uniform = number | Vector | Float32Array | Uniform[];
|
13
11
|
|
14
12
|
export interface Uniforms {
|
15
13
|
[name: string]: Uniform;
|
@@ -20,11 +18,16 @@ const isVector = (obj: unknown): obj is Vector =>
|
|
20
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
21
19
|
(obj as any).x !== undefined && (obj as any).y !== undefined;
|
22
20
|
|
23
|
-
const processValue = (
|
24
|
-
if (
|
25
|
-
|
21
|
+
const processValue = (values: number[], value: Uniform) => {
|
22
|
+
if (typeof value === "number") {
|
23
|
+
values.push(value);
|
24
|
+
} else if (Array.isArray(value)) {
|
25
|
+
value.forEach((v) => processValue(values, v));
|
26
|
+
} else if (isVector(value)) {
|
27
|
+
values.push(value.x, value.y);
|
28
|
+
} else if (value instanceof Float32Array) {
|
29
|
+
values.push(...value);
|
26
30
|
}
|
27
|
-
return value;
|
28
31
|
};
|
29
32
|
|
30
33
|
export const processUniforms = (
|
@@ -32,36 +35,25 @@ export const processUniforms = (
|
|
32
35
|
uniforms: Uniforms,
|
33
36
|
builder?: SkRuntimeShaderBuilder
|
34
37
|
) => {
|
35
|
-
const
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
.fill(0)
|
55
|
-
.map((_, i) => source.getUniformName(i));
|
56
|
-
const unusedUniform = names
|
57
|
-
.map((name) => {
|
58
|
-
if (usedUniforms.indexOf(name) === -1) {
|
59
|
-
return name;
|
60
|
-
}
|
61
|
-
return null;
|
62
|
-
})
|
63
|
-
.filter((n) => n !== null);
|
64
|
-
console.warn("Unused uniforms were provided: " + unusedUniform.join(", "));
|
38
|
+
const result: number[] = [];
|
39
|
+
const uniformsCount = source.getUniformCount();
|
40
|
+
for (let i = 0; i < uniformsCount; i++) {
|
41
|
+
const name = source.getUniformName(i);
|
42
|
+
const value = uniforms[name];
|
43
|
+
if (!value === undefined) {
|
44
|
+
throw new Error(
|
45
|
+
// eslint-disable-next-line max-len
|
46
|
+
`The runtime effect has the uniform value "${name}" declared, but it is missing from the uniforms property of the Runtime effect.`
|
47
|
+
);
|
48
|
+
}
|
49
|
+
if (builder === undefined) {
|
50
|
+
processValue(result, value);
|
51
|
+
} else {
|
52
|
+
const uniformValue: number[] = [];
|
53
|
+
processValue(uniformValue, value);
|
54
|
+
builder.setUniform(name, uniformValue);
|
55
|
+
result.push(...uniformValue);
|
56
|
+
}
|
65
57
|
}
|
66
|
-
return
|
58
|
+
return result;
|
67
59
|
};
|