@shopify/react-native-skia 0.1.141 → 0.1.145
Sign up to get free protection for your applications and to get access to all the features.
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +2 -2
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.h +1 -1
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +15 -16
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +2 -2
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDrawView.java +69 -27
- package/cpp/api/JsiSkPaint.h +6 -0
- package/cpp/api/JsiSkPathFactory.h +1 -1
- package/cpp/api/JsiSkPicture.h +7 -1
- package/cpp/rnskia/RNSkDrawView.cpp +66 -66
- package/cpp/rnskia/RNSkDrawView.h +22 -6
- package/cpp/rnskia/RNSkJsiViewApi.h +2 -2
- package/cpp/rnskia/values/RNSkComputedValue.h +10 -7
- package/cpp/rnskia/values/RNSkReadonlyValue.h +21 -2
- package/cpp/rnskia/values/RNSkValue.h +1 -0
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +1 -1
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +2 -2
- package/ios/RNSkia-iOS/SkiaDrawView.mm +4 -0
- package/lib/commonjs/mock/index.js +3 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +17 -7
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/DependencyManager.js +144 -36
- package/lib/commonjs/renderer/DependencyManager.js.map +1 -1
- package/lib/commonjs/renderer/HostConfig.js +1 -1
- package/lib/commonjs/renderer/HostConfig.js.map +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/backdrop/BackdropFilter.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/renderer/nodes/Declaration.js +2 -3
- package/lib/commonjs/renderer/nodes/Declaration.js.map +1 -1
- package/lib/commonjs/renderer/nodes/Drawing.js +3 -7
- package/lib/commonjs/renderer/nodes/Drawing.js.map +1 -1
- package/lib/commonjs/renderer/nodes/Node.js +9 -7
- package/lib/commonjs/renderer/nodes/Node.js.map +1 -1
- package/lib/commonjs/renderer/processors/Animations/Animations.js +14 -20
- package/lib/commonjs/renderer/processors/Animations/Animations.js.map +1 -1
- package/lib/commonjs/skia/core/Data.js +10 -22
- package/lib/commonjs/skia/core/Data.js.map +1 -1
- package/lib/commonjs/skia/core/Font.js +2 -3
- package/lib/commonjs/skia/core/Font.js.map +1 -1
- package/lib/commonjs/skia/core/Image.js.map +1 -1
- package/lib/commonjs/skia/core/SVG.js.map +1 -1
- package/lib/commonjs/skia/core/Typeface.js.map +1 -1
- package/lib/commonjs/skia/types/Data/Data.js +5 -0
- package/lib/commonjs/skia/types/Data/Data.js.map +1 -1
- package/lib/commonjs/skia/types/Paint/Paint.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 +50 -28
- 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 +19 -6
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js +16 -60
- 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 +9 -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 +3 -3
- 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/commonjs/values/hooks/useComputedValue.js +6 -2
- package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
- package/lib/commonjs/values/index.js +13 -0
- package/lib/commonjs/values/index.js.map +1 -1
- package/lib/commonjs/values/selector.js +24 -0
- package/lib/commonjs/values/selector.js.map +1 -0
- package/lib/commonjs/values/web/RNSkComputedValue.js +8 -0
- package/lib/commonjs/values/web/RNSkComputedValue.js.map +1 -1
- package/lib/commonjs/values/web/RNSkReadonlyValue.js +4 -0
- package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -1
- package/lib/module/mock/index.js +2 -1
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +17 -6
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/DependencyManager.js +141 -34
- package/lib/module/renderer/DependencyManager.js.map +1 -1
- package/lib/module/renderer/HostConfig.js +1 -1
- package/lib/module/renderer/HostConfig.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/backdrop/BackdropFilter.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/renderer/nodes/Declaration.js +3 -4
- package/lib/module/renderer/nodes/Declaration.js.map +1 -1
- package/lib/module/renderer/nodes/Drawing.js +3 -6
- package/lib/module/renderer/nodes/Drawing.js.map +1 -1
- package/lib/module/renderer/nodes/Node.js +9 -7
- package/lib/module/renderer/nodes/Node.js.map +1 -1
- package/lib/module/renderer/processors/Animations/Animations.js +9 -15
- package/lib/module/renderer/processors/Animations/Animations.js.map +1 -1
- package/lib/module/skia/core/Data.js +10 -20
- package/lib/module/skia/core/Data.js.map +1 -1
- package/lib/module/skia/core/Font.js +2 -3
- package/lib/module/skia/core/Font.js.map +1 -1
- package/lib/module/skia/core/Image.js.map +1 -1
- package/lib/module/skia/core/SVG.js.map +1 -1
- package/lib/module/skia/core/Typeface.js.map +1 -1
- package/lib/module/skia/types/Data/Data.js +1 -1
- package/lib/module/skia/types/Data/Data.js.map +1 -1
- package/lib/module/skia/types/Paint/Paint.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 +40 -29
- 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 +15 -7
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.js +15 -62
- 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 +10 -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 +4 -4
- 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/module/values/hooks/useComputedValue.js +7 -3
- package/lib/module/values/hooks/useComputedValue.js.map +1 -1
- package/lib/module/values/index.js +1 -0
- package/lib/module/values/index.js.map +1 -1
- package/lib/module/values/selector.js +15 -0
- package/lib/module/values/selector.js.map +1 -0
- package/lib/module/values/web/RNSkComputedValue.js +8 -0
- package/lib/module/values/web/RNSkComputedValue.js.map +1 -1
- package/lib/module/values/web/RNSkReadonlyValue.js +4 -0
- package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -1
- package/lib/typescript/src/renderer/Canvas.d.ts +1 -1
- package/lib/typescript/src/renderer/DependencyManager.d.ts +40 -14
- package/lib/typescript/src/renderer/nodes/Declaration.d.ts +2 -2
- package/lib/typescript/src/renderer/nodes/Drawing.d.ts +2 -2
- package/lib/typescript/src/renderer/nodes/Node.d.ts +3 -2
- package/lib/typescript/src/renderer/processors/Animations/Animations.d.ts +7 -3
- package/lib/typescript/src/skia/core/Data.d.ts +3 -5
- package/lib/typescript/src/skia/core/Font.d.ts +2 -2
- package/lib/typescript/src/skia/core/Image.d.ts +2 -2
- package/lib/typescript/src/skia/core/SVG.d.ts +2 -2
- package/lib/typescript/src/skia/core/Typeface.d.ts +2 -2
- package/lib/typescript/src/skia/types/Data/Data.d.ts +10 -3
- package/lib/typescript/src/skia/types/Paint/Paint.d.ts +5 -0
- package/lib/typescript/src/skia/types/Picture/Picture.d.ts +2 -1
- package/lib/typescript/src/skia/web/Host.d.ts +6 -8
- package/lib/typescript/src/skia/web/JsiSkImageFilterFactory.d.ts +8 -8
- package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkPoint.d.ts +3 -2
- package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +3 -2
- package/lib/typescript/src/skia/web/JsiSkRSXform.d.ts +1 -2
- package/lib/typescript/src/skia/web/JsiSkRect.d.ts +3 -3
- package/lib/typescript/src/skia/web/JsiSkTextBlobFactory.d.ts +2 -1
- package/lib/typescript/src/values/index.d.ts +1 -0
- package/lib/typescript/src/values/selector.d.ts +14 -0
- package/lib/typescript/src/values/types.d.ts +4 -0
- package/lib/typescript/src/values/web/RNSkComputedValue.d.ts +1 -0
- package/lib/typescript/src/values/web/RNSkReadonlyValue.d.ts +1 -0
- package/libs/ios/libskia.xcframework/Info.plist +5 -5
- 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/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/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 +3 -3
- package/src/mock/index.ts +2 -1
- package/src/renderer/Canvas.tsx +19 -7
- package/src/renderer/DependencyManager.tsx +171 -37
- package/src/renderer/HostConfig.ts +1 -1
- package/src/renderer/components/Blend.tsx +25 -5
- package/src/renderer/components/backdrop/BackdropFilter.tsx +1 -1
- package/src/renderer/components/imageFilters/Morphology.tsx +2 -2
- package/src/renderer/components/imageFilters/Shadow.tsx +2 -2
- package/src/renderer/nodes/Declaration.tsx +6 -8
- package/src/renderer/nodes/Drawing.tsx +5 -7
- package/src/renderer/nodes/Node.ts +11 -9
- package/src/renderer/processors/Animations/Animations.ts +23 -14
- package/src/skia/core/Data.ts +20 -51
- package/src/skia/core/Font.ts +4 -5
- package/src/skia/core/Image.ts +2 -2
- package/src/skia/core/SVG.ts +2 -2
- package/src/skia/core/Typeface.ts +2 -2
- package/src/skia/types/Data/Data.ts +11 -1
- package/src/skia/types/Paint/Paint.ts +6 -0
- package/src/skia/types/Picture/Picture.ts +2 -1
- package/src/skia/web/Host.ts +12 -22
- package/src/skia/web/JsiSkCanvas.ts +99 -56
- 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 +15 -7
- package/src/skia/web/JsiSkPath.ts +30 -56
- 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 +16 -2
- package/src/skia/web/JsiSkRSXform.ts +1 -1
- package/src/skia/web/JsiSkRect.ts +4 -7
- 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
- package/src/values/hooks/useComputedValue.ts +6 -3
- package/src/values/index.ts +1 -0
- package/src/values/selector.ts +24 -0
- package/src/values/types.ts +4 -0
- package/src/values/web/RNSkComputedValue.ts +6 -0
- package/src/values/web/RNSkReadonlyValue.ts +4 -0
@@ -1,21 +1,47 @@
|
|
1
|
-
import type { RefObject } from "react";
|
2
|
-
import type { SkiaView } from "../views";
|
3
1
|
import type { SkiaValue } from "../values";
|
4
2
|
import type { Node } from "./nodes";
|
3
|
+
import type { AnimatedProps } from "./processors";
|
5
4
|
declare type Unsubscribe = () => void;
|
6
|
-
declare type
|
7
|
-
|
5
|
+
declare type Mutator = (value: unknown) => void;
|
6
|
+
declare type SubscriptionState = {
|
7
|
+
nodes: Map<Node, Mutator[]>;
|
8
|
+
unsubscribe: null | Unsubscribe;
|
8
9
|
};
|
9
10
|
export declare class DependencyManager {
|
10
|
-
|
11
|
-
subscriptions: Map<
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
registerValues: (values: Array<SkiaValue<unknown>>) => () => void;
|
12
|
+
subscriptions: Map<SkiaValue<unknown>, SubscriptionState>;
|
13
|
+
unregisterDependantValues: null | Unsubscribe;
|
14
|
+
constructor(registerValues: (values: Array<SkiaValue<unknown>>) => () => void);
|
15
|
+
/**
|
16
|
+
* Call to unsubscribe all value listeners from the given node based
|
17
|
+
* on the current list of subscriptions for the node. This function
|
18
|
+
* is typically called when the node is unmounted or when one or more
|
19
|
+
* properties have changed.
|
20
|
+
* @param node Node to unsubscribe value listeners from
|
21
|
+
*/
|
22
|
+
unsubscribeNode(node: Node): void;
|
23
|
+
/**
|
24
|
+
* Adds listeners to the provided values so that the node is notified
|
25
|
+
* when a value changes. This is done in an optimized way so that this
|
26
|
+
* class only needs to listen to the value once and then forwards the
|
27
|
+
* change to the node and its listener. This method is typically called
|
28
|
+
* when the node is mounted and when one or more props on the node changes.
|
29
|
+
* @param node Node to subscribe to value changes for
|
30
|
+
* @param props Node's properties
|
31
|
+
* @param onResolveProp Callback when a property value changes
|
32
|
+
*/
|
33
|
+
subscribeNode<P extends Record<string, unknown>>(node: Node, props: AnimatedProps<P>): void;
|
34
|
+
/**
|
35
|
+
* Called when the hosting container is mounted or updated. This ensures that we have
|
36
|
+
* a ref to the underlying SkiaView so that we can registers redraw listeners
|
37
|
+
* on values used in the current View automatically.
|
38
|
+
*/
|
39
|
+
update(): void;
|
40
|
+
/**
|
41
|
+
* Called when the hosting container is unmounted or recreated. This ensures that we remove
|
42
|
+
* all subscriptions to Skia values so that we don't have any listeners left after
|
43
|
+
* the component is removed.
|
44
|
+
*/
|
45
|
+
remove(): void;
|
20
46
|
}
|
21
47
|
export {};
|
@@ -8,7 +8,7 @@ export declare type DeclarationResult = SkJSIInstance<string> | null;
|
|
8
8
|
declare type DeclarationCallback<T> = (props: T, children: DeclarationResult[], ctx: DrawingContext) => DeclarationResult;
|
9
9
|
export declare const createDeclaration: <T>(cb: DeclarationCallback<T>) => DeclarationCallback<T>;
|
10
10
|
export declare const useDeclaration: <P>(cb: DeclarationCallback<P>, deps?: DependencyList | undefined) => DeclarationCallback<P>;
|
11
|
-
export declare const isDeclarationNode: (node: Node) => node is DeclarationNode<
|
11
|
+
export declare const isDeclarationNode: <P>(node: Node) => node is DeclarationNode<P>;
|
12
12
|
export interface DeclarationProps<P> {
|
13
13
|
onDeclare: DeclarationCallback<P>;
|
14
14
|
}
|
@@ -16,7 +16,7 @@ export declare class DeclarationNode<P> extends Node<P> {
|
|
16
16
|
private onDeclare;
|
17
17
|
constructor(depMgr: DependencyManager, onDeclare: DeclarationCallback<P>, props: AnimatedProps<P>);
|
18
18
|
set props(props: AnimatedProps<P>);
|
19
|
-
get props():
|
19
|
+
get props(): P;
|
20
20
|
draw(ctx: DrawingContext): DeclarationResult;
|
21
21
|
}
|
22
22
|
export {};
|
@@ -7,8 +7,8 @@ declare type DrawingCallback<P> = (ctx: DrawingContext, props: P, node: Node<P>)
|
|
7
7
|
declare type OnDrawCallback<P> = (ctx: DrawingContext, props: P, node: Node<P>) => void;
|
8
8
|
export declare const createDrawing: <P>(cb: OnDrawCallback<P>) => DrawingCallback<P>;
|
9
9
|
export declare const useDrawing: <P>(cb: OnDrawCallback<P>, deps?: DependencyList | undefined) => OnDrawCallback<P>;
|
10
|
-
export declare type DrawingProps<
|
11
|
-
onDraw: DrawingCallback<
|
10
|
+
export declare type DrawingProps<P> = {
|
11
|
+
onDraw: DrawingCallback<P>;
|
12
12
|
skipProcessing?: boolean;
|
13
13
|
children?: ReactNode | ReactNode[];
|
14
14
|
};
|
@@ -9,15 +9,16 @@ export declare enum NodeType {
|
|
9
9
|
declare type DeclarationResult = SkJSIInstance<string> | null;
|
10
10
|
export declare abstract class Node<P = unknown> {
|
11
11
|
readonly children: Node[];
|
12
|
-
|
12
|
+
resolvedProps: P;
|
13
13
|
memoizable: boolean;
|
14
14
|
memoized: DeclarationResult | null;
|
15
15
|
parent?: Node;
|
16
16
|
depMgr: DependencyManager;
|
17
17
|
constructor(depMgr: DependencyManager, props: AnimatedProps<P>);
|
18
18
|
abstract draw(ctx: DrawingContext): void | DeclarationResult;
|
19
|
+
updatePropSubscriptions(props: AnimatedProps<P>): void;
|
19
20
|
set props(props: AnimatedProps<P>);
|
20
|
-
get props():
|
21
|
+
get props(): P;
|
21
22
|
visit(ctx: DrawingContext, children?: Node[]): SkJSIInstance<string>[];
|
22
23
|
}
|
23
24
|
export {};
|
@@ -1,7 +1,11 @@
|
|
1
|
-
import type { SkiaValue } from "../../../values";
|
1
|
+
import type { SkiaSelector, SkiaValue } from "../../../values";
|
2
2
|
export declare const isValue: (value: unknown) => value is SkiaValue<unknown>;
|
3
|
+
export declare const isSelector: <T, R>(value: unknown) => value is {
|
4
|
+
selector: (v: T) => R;
|
5
|
+
value: SkiaValue<T>;
|
6
|
+
};
|
3
7
|
export declare const isAnimated: <T>(props: AnimatedProps<T>) => boolean;
|
4
|
-
export declare
|
8
|
+
export declare type AnimatedProp<T, P = any> = T | SkiaValue<T> | SkiaSelector<T, P>;
|
5
9
|
export declare type AnimatedProps<T> = {
|
6
|
-
[K in keyof T]:
|
10
|
+
[K in keyof T]: AnimatedProp<T[K]>;
|
7
11
|
};
|
@@ -1,5 +1,3 @@
|
|
1
|
-
import type {
|
2
|
-
|
3
|
-
export declare const
|
4
|
-
export declare const useRawData: <T>(source: DataSource | null | undefined, factory: (data: SkData) => T, onError?: ((err: Error) => void) | undefined, deps?: DependencyList | undefined) => T | null;
|
5
|
-
export declare const useData: (source: DataSource | null | undefined, onError?: ((err: Error) => void) | undefined, deps?: DependencyList | undefined) => SkData | null;
|
1
|
+
import type { SkData, DataSourceParam } from "../types";
|
2
|
+
export declare const useRawData: <T>(source: DataSourceParam, factory: (data: SkData) => T, onError?: ((err: Error) => void) | undefined) => T | null;
|
3
|
+
export declare const useData: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => SkData | null;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type {
|
1
|
+
import type { DataSourceParam } from "../types";
|
2
2
|
/**
|
3
3
|
* Returns a Skia Font object
|
4
4
|
* */
|
5
|
-
export declare const useFont: (font:
|
5
|
+
export declare const useFont: (font: DataSourceParam, size?: number | undefined, onError?: ((err: Error) => void) | undefined) => import("../types").SkFont | null;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type {
|
1
|
+
import type { DataSourceParam } from "../types";
|
2
2
|
/**
|
3
3
|
* Returns a Skia Image object
|
4
4
|
* */
|
5
|
-
export declare const useImage: (source:
|
5
|
+
export declare const useImage: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkImage | null;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import type {
|
2
|
-
export declare const useSVG: (source:
|
1
|
+
import type { DataSourceParam } from "../types";
|
2
|
+
export declare const useSVG: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkSVG | null;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type {
|
1
|
+
import type { DataSourceParam } from "../types";
|
2
2
|
/**
|
3
3
|
* Returns a Skia Typeface object
|
4
4
|
* */
|
5
|
-
export declare const useTypeface: (source:
|
5
|
+
export declare const useTypeface: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkTypeface | null;
|
@@ -1,5 +1,12 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
/// <reference types="react-native" />
|
3
1
|
import type { SkJSIInstance } from "../JsiInstance";
|
4
2
|
export declare type SkData = SkJSIInstance<"Data">;
|
5
|
-
|
3
|
+
declare type RNModule = number;
|
4
|
+
declare type ESModule = {
|
5
|
+
__esModule: true;
|
6
|
+
default: string;
|
7
|
+
};
|
8
|
+
export declare type DataModule = RNModule | ESModule;
|
9
|
+
export declare type DataSource = DataModule | string | Uint8Array;
|
10
|
+
export declare type DataSourceParam = DataSource | null | undefined;
|
11
|
+
export declare const isRNModule: (mod: DataModule) => mod is number;
|
12
|
+
export {};
|
@@ -26,6 +26,11 @@ export interface SkPaint extends SkJSIInstance<"Paint"> {
|
|
26
26
|
* Returns a copy of this paint.
|
27
27
|
*/
|
28
28
|
copy(): SkPaint;
|
29
|
+
/**
|
30
|
+
* Sets all SkPaint contents to their initial values. This is equivalent to replacing
|
31
|
+
SkPaint with the result of SkPaint().
|
32
|
+
*/
|
33
|
+
reset(): void;
|
29
34
|
/**
|
30
35
|
* Retrieves the alpha and RGB unpremultiplied. RGB are extended sRGB values
|
31
36
|
* (sRGB gamut, and encoded with the sRGB transfer function).
|
@@ -3,7 +3,8 @@ 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
|
-
|
6
|
+
import type { SkJSIInstance } from "../JsiInstance";
|
7
|
+
export interface SkPicture extends SkJSIInstance<"Picture"> {
|
7
8
|
/**
|
8
9
|
* Returns a new shader that will draw with this picture.
|
9
10
|
*
|
@@ -1,21 +1,19 @@
|
|
1
1
|
import type { CanvasKit, EmbindEnumEntity } from "canvaskit-wasm";
|
2
2
|
import type { SkJSIInstance } from "../types";
|
3
3
|
export declare class NotImplementedOnRNWeb extends Error {
|
4
|
-
constructor();
|
4
|
+
constructor(msg?: string);
|
5
5
|
}
|
6
6
|
export declare abstract class Host {
|
7
7
|
readonly CanvasKit: CanvasKit;
|
8
8
|
constructor(CanvasKit: CanvasKit);
|
9
9
|
}
|
10
|
-
export declare abstract class
|
10
|
+
export declare abstract class BaseHostObject<T, N extends string> extends Host implements SkJSIInstance<N> {
|
11
11
|
readonly __typename__: N;
|
12
|
-
|
12
|
+
ref: T;
|
13
13
|
constructor(CanvasKit: CanvasKit, ref: T, typename: N);
|
14
14
|
}
|
15
|
-
export declare
|
16
|
-
|
17
|
-
|
18
|
-
export declare const toNullableValue: <T>(value: NonNullish | null) => T | null;
|
19
|
-
export declare const toValue: <T>(value: NonNullish) => T;
|
15
|
+
export declare abstract class HostObject<T, N extends string> extends BaseHostObject<T, N> {
|
16
|
+
static fromValue<T>(value: SkJSIInstance<string>): T;
|
17
|
+
}
|
20
18
|
export declare const ckEnum: (value: number) => EmbindEnumEntity;
|
21
19
|
export declare const optEnum: (value: number | undefined) => EmbindEnumEntity | undefined;
|
@@ -4,16 +4,16 @@ import { Host } from "./Host";
|
|
4
4
|
import { JsiSkImageFilter } from "./JsiSkImageFilter";
|
5
5
|
export declare class JsiSkImageFilterFactory extends Host implements ImageFilterFactory {
|
6
6
|
constructor(CanvasKit: CanvasKit);
|
7
|
-
MakeOffset(
|
8
|
-
MakeDisplacementMap(
|
9
|
-
MakeShader(
|
7
|
+
MakeOffset(dx: number, dy: number, input: SkImageFilter | null): JsiSkImageFilter;
|
8
|
+
MakeDisplacementMap(channelX: ColorChannel, channelY: ColorChannel, scale: number, in1: SkImageFilter, input: SkImageFilter | null): SkImageFilter;
|
9
|
+
MakeShader(shader: SkShader, _input: SkImageFilter | null): SkImageFilter;
|
10
10
|
MakeBlur(sigmaX: number, sigmaY: number, mode: TileMode, input: SkImageFilter | null): JsiSkImageFilter;
|
11
11
|
MakeColorFilter(cf: SkColorFilter, input: SkImageFilter | null): JsiSkImageFilter;
|
12
12
|
MakeCompose(outer: SkImageFilter | null, inner: SkImageFilter | null): JsiSkImageFilter;
|
13
|
-
MakeDropShadow(
|
14
|
-
MakeDropShadowOnly(
|
15
|
-
MakeErode(
|
16
|
-
MakeDilate(
|
17
|
-
MakeBlend(
|
13
|
+
MakeDropShadow(dx: number, dy: number, sigmaX: number, sigmaY: number, color: SkColor, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
|
14
|
+
MakeDropShadowOnly(dx: number, dy: number, sigmaX: number, sigmaY: number, color: SkColor, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
|
15
|
+
MakeErode(rx: number, ry: number, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
|
16
|
+
MakeDilate(rx: number, ry: number, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
|
17
|
+
MakeBlend(mode: BlendMode, background: SkImageFilter, foreground: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
|
18
18
|
MakeRuntimeShader(_builder: SkRuntimeShaderBuilder, _childShaderName: string | null, _input: SkImageFilter | null): SkImageFilter;
|
19
19
|
}
|
@@ -4,6 +4,7 @@ import { HostObject } from "./Host";
|
|
4
4
|
export declare class JsiSkPaint extends HostObject<Paint, "Paint"> implements SkPaint {
|
5
5
|
constructor(CanvasKit: CanvasKit, ref: Paint);
|
6
6
|
copy(): JsiSkPaint;
|
7
|
+
reset(): void;
|
7
8
|
getColor(): Float32Array;
|
8
9
|
getStrokeCap(): number;
|
9
10
|
getStrokeJoin(): number;
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import type { CanvasKit, Point } from "canvaskit-wasm";
|
2
2
|
import type { SkPoint } from "../types";
|
3
|
-
import {
|
4
|
-
export declare class JsiSkPoint extends
|
3
|
+
import { BaseHostObject } from "./Host";
|
4
|
+
export declare class JsiSkPoint extends BaseHostObject<Point, "Point"> implements SkPoint {
|
5
|
+
static fromValue(point: SkPoint): Float32Array;
|
5
6
|
constructor(CanvasKit: CanvasKit, ref: Point);
|
6
7
|
get x(): number;
|
7
8
|
get y(): number;
|
@@ -1,8 +1,9 @@
|
|
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
|
+
static fromValue(CanvasKit: CanvasKit, rect: SkRRect): Float32Array;
|
6
7
|
constructor(CanvasKit: CanvasKit, ref: RRect);
|
7
8
|
get rx(): number;
|
8
9
|
get ry(): 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,8 +1,8 @@
|
|
1
1
|
import type { CanvasKit, Rect } from "canvaskit-wasm";
|
2
2
|
import type { SkRect } from "../types";
|
3
|
-
import {
|
4
|
-
export declare class JsiSkRect extends
|
5
|
-
static fromValue(CanvasKit: CanvasKit, rect: SkRect):
|
3
|
+
import { BaseHostObject } from "./Host";
|
4
|
+
export declare class JsiSkRect extends BaseHostObject<Rect, "Rect"> implements SkRect {
|
5
|
+
static fromValue(CanvasKit: CanvasKit, rect: SkRect): Float32Array;
|
6
6
|
constructor(CanvasKit: CanvasKit, ref: Rect);
|
7
7
|
get x(): number;
|
8
8
|
get y(): 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 {
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { SkiaValue } from "./types";
|
2
|
+
export declare type SkiaSelector<TReturn, TInput = unknown> = {
|
3
|
+
value: SkiaValue<TInput>;
|
4
|
+
selector: (v: TInput) => TReturn;
|
5
|
+
};
|
6
|
+
/**
|
7
|
+
* Wraps a Skia Value with a selector function. The selector function can access the
|
8
|
+
* inner values of the Skia Value so that we can dynamically ready array values and
|
9
|
+
* object values when doing animations in Skia.
|
10
|
+
* @param value Dependant value
|
11
|
+
* @param selector Selector function to calculate new value from the Skia Value's value
|
12
|
+
* @returns A descriptor that will be used by the reconciler to calculate the value
|
13
|
+
*/
|
14
|
+
export declare const Selector: <TInput, TReturn>(value: SkiaValue<TInput>, selector: (v: TInput) => TReturn) => SkiaSelector<TReturn, TInput>;
|
@@ -8,6 +8,10 @@ export interface SkiaValue<T = number> {
|
|
8
8
|
* Returns unsubscribe method.
|
9
9
|
*/
|
10
10
|
addListener: (cb: (value: T) => void) => () => void;
|
11
|
+
/**
|
12
|
+
* Invalidates the value. Has different meaning depending on the type of the value.
|
13
|
+
*/
|
14
|
+
__invalidate: () => void;
|
11
15
|
/**
|
12
16
|
* Field to make typechecking easier
|
13
17
|
*/
|
@@ -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>libskia.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>libskia.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
|
Binary file
|
Binary file
|
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.145",
|
11
11
|
"description": "High-performance React Native Graphics using Skia",
|
12
12
|
"main": "lib/module/index.js",
|
13
13
|
"files": [
|
@@ -37,7 +37,7 @@
|
|
37
37
|
],
|
38
38
|
"scripts": {
|
39
39
|
"tsc": "tsc --noEmit",
|
40
|
-
"lint": "eslint . --ext .ts,.tsx --max-warnings 0",
|
40
|
+
"lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache",
|
41
41
|
"test": "jest",
|
42
42
|
"postinstall": "node scripts/install-npm.js",
|
43
43
|
"build": "bob build"
|
@@ -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": [
|
package/src/mock/index.ts
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
import type { Color, Skia as SkiaApi, SkRect, Vector } from "../skia/types";
|
4
4
|
import * as Values from "../values/web";
|
5
5
|
import * as ValuesHooks from "../values/hooks";
|
6
|
+
import { Selector } from "../values/selector";
|
6
7
|
import * as BaseSkia from "../skia/types";
|
7
8
|
import type * as SkiaExports from "../skia";
|
8
9
|
import type * as ExternalExports from "../external";
|
@@ -46,7 +47,6 @@ export const Mock: typeof SkiaExports &
|
|
46
47
|
Skia,
|
47
48
|
...BaseSkia,
|
48
49
|
// 2. Hooks
|
49
|
-
useDataCollection: Noop,
|
50
50
|
useRawData: Noop,
|
51
51
|
useData: Noop,
|
52
52
|
useFont: Noop,
|
@@ -87,6 +87,7 @@ export const Mock: typeof SkiaExports &
|
|
87
87
|
// ValueExports
|
88
88
|
...Values,
|
89
89
|
...ValuesHooks,
|
90
|
+
Selector,
|
90
91
|
// Animations
|
91
92
|
...timingFunctions,
|
92
93
|
...springFunctions,
|
package/src/renderer/Canvas.tsx
CHANGED
@@ -20,6 +20,7 @@ import { SkiaView, useDrawCallback } from "../views";
|
|
20
20
|
import type { TouchHandler } from "../views";
|
21
21
|
import { useValue } from "../values/hooks/useValue";
|
22
22
|
import { Skia } from "../skia/Skia";
|
23
|
+
import type { SkiaValue } from "../values";
|
23
24
|
|
24
25
|
import { debug as hostDebug, skHostConfig } from "./HostConfig";
|
25
26
|
// import { debugTree } from "./nodes";
|
@@ -38,8 +39,7 @@ skiaReconciler.injectIntoDevTools({
|
|
38
39
|
const render = (element: ReactNode, root: OpaqueRoot, container: Container) => {
|
39
40
|
skiaReconciler.updateContainer(element, root, null, () => {
|
40
41
|
hostDebug("updateContainer");
|
41
|
-
|
42
|
-
container.depMgr.subscribe();
|
42
|
+
container.depMgr.update();
|
43
43
|
});
|
44
44
|
};
|
45
45
|
|
@@ -60,9 +60,19 @@ export const Canvas = forwardRef<SkiaView, CanvasProps>(
|
|
60
60
|
const [tick, setTick] = useState(0);
|
61
61
|
const redraw = useCallback(() => setTick((t) => t + 1), []);
|
62
62
|
|
63
|
+
const registerValues = useCallback(
|
64
|
+
(values: Array<SkiaValue<unknown>>) => {
|
65
|
+
if (ref.current === null) {
|
66
|
+
throw new Error("Canvas ref is not set");
|
67
|
+
}
|
68
|
+
return ref.current.registerValues(values);
|
69
|
+
},
|
70
|
+
[ref]
|
71
|
+
);
|
72
|
+
|
63
73
|
const container = useMemo(
|
64
|
-
() => new Container(new DependencyManager(
|
65
|
-
[redraw,
|
74
|
+
() => new Container(new DependencyManager(registerValues), redraw),
|
75
|
+
[redraw, registerValues]
|
66
76
|
);
|
67
77
|
|
68
78
|
const root = useMemo(
|
@@ -78,6 +88,8 @@ export const Canvas = forwardRef<SkiaView, CanvasProps>(
|
|
78
88
|
);
|
79
89
|
}, [children, root, redraw, container, canvasCtx]);
|
80
90
|
|
91
|
+
const paint = useMemo(() => Skia.Paint(), []);
|
92
|
+
|
81
93
|
// Draw callback
|
82
94
|
const onDraw = useDrawCallback(
|
83
95
|
(canvas, info) => {
|
@@ -92,7 +104,7 @@ export const Canvas = forwardRef<SkiaView, CanvasProps>(
|
|
92
104
|
) {
|
93
105
|
canvasCtx.size.current = { width, height };
|
94
106
|
}
|
95
|
-
|
107
|
+
paint.reset();
|
96
108
|
const ctx = {
|
97
109
|
width,
|
98
110
|
height,
|
@@ -101,7 +113,7 @@ export const Canvas = forwardRef<SkiaView, CanvasProps>(
|
|
101
113
|
paint,
|
102
114
|
opacity: 1,
|
103
115
|
ref,
|
104
|
-
center:
|
116
|
+
center: { x: width / 2, y: height / 2 },
|
105
117
|
Skia,
|
106
118
|
};
|
107
119
|
container.draw(ctx);
|
@@ -112,7 +124,7 @@ export const Canvas = forwardRef<SkiaView, CanvasProps>(
|
|
112
124
|
useEffect(() => {
|
113
125
|
return () => {
|
114
126
|
skiaReconciler.updateContainer(null, root, null, () => {
|
115
|
-
container.depMgr.
|
127
|
+
container.depMgr.remove();
|
116
128
|
});
|
117
129
|
};
|
118
130
|
}, [container, root]);
|