@shopify/react-native-skia 0.1.172 → 0.1.173
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +1 -0
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +5 -0
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +106 -5
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +3 -1
- package/cpp/api/JsiSkSurface.h +7 -1
- package/cpp/api/JsiSkSurfaceFactory.h +15 -2
- package/cpp/rnskia/RNSkDomView.cpp +2 -4
- package/cpp/rnskia/RNSkJsView.cpp +3 -0
- package/cpp/rnskia/RNSkPictureView.h +3 -0
- package/cpp/rnskia/RNSkPlatformContext.h +9 -0
- package/cpp/rnskia/dom/JsiDomApi.h +1 -0
- package/cpp/rnskia/dom/base/ConcatablePaint.cpp +117 -0
- package/cpp/rnskia/dom/base/ConcatablePaint.h +49 -0
- package/cpp/rnskia/dom/base/Declaration.h +88 -0
- package/cpp/rnskia/dom/base/DeclarationContext.h +79 -0
- package/cpp/rnskia/dom/base/DerivedNodeProp.h +25 -9
- package/cpp/rnskia/dom/base/DrawingContext.cpp +32 -186
- package/cpp/rnskia/dom/base/DrawingContext.h +45 -64
- package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +35 -106
- package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +28 -9
- package/cpp/rnskia/dom/base/JsiDomNode.h +46 -17
- package/cpp/rnskia/dom/base/JsiDomRenderNode.h +81 -67
- package/cpp/rnskia/dom/base/NodeProp.h +12 -2
- package/cpp/rnskia/dom/base/NodePropsContainer.h +15 -16
- package/cpp/rnskia/dom/nodes/JsiBackdropFilterNode.h +22 -11
- package/cpp/rnskia/dom/nodes/JsiBlendNode.h +43 -59
- package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +16 -17
- package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +6 -5
- package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +45 -69
- package/cpp/rnskia/dom/nodes/JsiGroupNode.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +121 -161
- package/cpp/rnskia/dom/nodes/JsiImageNode.h +1 -0
- package/cpp/rnskia/dom/nodes/JsiLayerNode.h +28 -18
- package/cpp/rnskia/dom/nodes/JsiPaintNode.h +82 -45
- package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +68 -101
- package/cpp/rnskia/dom/nodes/JsiPathNode.h +3 -2
- package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +150 -207
- package/cpp/rnskia/dom/props/BezierProps.h +4 -2
- package/cpp/rnskia/dom/props/BlendModeProp.h +4 -2
- package/cpp/rnskia/dom/props/BoxShadowProps.h +8 -10
- package/cpp/rnskia/dom/props/CircleProp.h +6 -5
- package/cpp/rnskia/dom/props/ClipProp.h +6 -4
- package/cpp/rnskia/dom/props/ColorProp.h +8 -4
- package/cpp/rnskia/dom/props/DrawingProp.h +5 -3
- package/cpp/rnskia/dom/props/FontProp.h +4 -2
- package/cpp/rnskia/dom/props/GlyphsProp.h +4 -2
- package/cpp/rnskia/dom/props/ImageProps.h +9 -6
- package/cpp/rnskia/dom/props/LayerProp.h +6 -4
- package/cpp/rnskia/dom/props/MatrixProp.h +4 -2
- package/cpp/rnskia/dom/props/NumbersProp.h +8 -4
- package/cpp/rnskia/dom/props/PaintProps.h +55 -92
- package/cpp/rnskia/dom/props/PathProp.h +4 -2
- package/cpp/rnskia/dom/props/PictureProp.h +4 -2
- package/cpp/rnskia/dom/props/PointProp.h +4 -2
- package/cpp/rnskia/dom/props/PointsProp.h +8 -4
- package/cpp/rnskia/dom/props/RRectProp.h +23 -16
- package/cpp/rnskia/dom/props/RadiusProp.h +4 -2
- package/cpp/rnskia/dom/props/RectProp.h +18 -12
- package/cpp/rnskia/dom/props/StrokeProps.h +8 -4
- package/cpp/rnskia/dom/props/SvgProp.h +4 -2
- package/cpp/rnskia/dom/props/TextBlobProp.h +10 -8
- package/cpp/rnskia/dom/props/TileModeProp.h +4 -2
- package/cpp/rnskia/dom/props/TransformProp.h +4 -2
- package/cpp/rnskia/dom/props/TransformsProps.h +5 -7
- package/cpp/rnskia/dom/props/UniformsProp.h +4 -2
- package/cpp/rnskia/dom/props/VertexModeProp.h +4 -2
- package/cpp/rnskia/dom/props/VerticesProps.h +7 -11
- package/ios/RNSkia-iOS/DisplayLink.mm +22 -24
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +53 -50
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +2 -0
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +38 -25
- package/ios/RNSkia-iOS/SkiaDomViewManager.mm +17 -17
- package/ios/RNSkia-iOS/SkiaDrawViewManager.mm +17 -17
- package/ios/RNSkia-iOS/SkiaManager.mm +12 -10
- package/ios/RNSkia-iOS/SkiaMetalRenderer.h +5 -0
- package/ios/RNSkia-iOS/SkiaMetalRenderer.mm +53 -0
- package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +17 -17
- package/ios/RNSkia-iOS/SkiaUIView.mm +63 -53
- package/ios/RNSkiaModule.mm +5 -7
- package/lib/commonjs/dom/nodes/DrawingNode.js +5 -1
- package/lib/commonjs/dom/nodes/DrawingNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +33 -34
- package/lib/commonjs/dom/nodes/LayerNode.js +13 -6
- package/lib/commonjs/dom/nodes/LayerNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/Node.d.ts +6 -11
- package/lib/commonjs/dom/nodes/Node.js +8 -26
- package/lib/commonjs/dom/nodes/Node.js.map +1 -1
- package/lib/commonjs/dom/nodes/PaintContext.js.map +1 -1
- package/lib/commonjs/dom/nodes/PaintNode.d.ts +3 -3
- package/lib/commonjs/dom/nodes/PaintNode.js +32 -15
- package/lib/commonjs/dom/nodes/PaintNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/RenderNode.d.ts +2 -3
- package/lib/commonjs/dom/nodes/RenderNode.js +19 -187
- package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
- package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.js +25 -7
- package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/Box.d.ts +3 -1
- package/lib/commonjs/dom/nodes/drawings/Box.js +3 -0
- package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/BlendNode.d.ts +3 -7
- package/lib/commonjs/dom/nodes/paint/BlendNode.js +16 -47
- package/lib/commonjs/dom/nodes/paint/BlendNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/ColorFilters.d.ts +10 -11
- package/lib/commonjs/dom/nodes/paint/ColorFilters.js +29 -43
- package/lib/commonjs/dom/nodes/paint/ColorFilters.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/ImageFilters.d.ts +11 -11
- package/lib/commonjs/dom/nodes/paint/ImageFilters.js +45 -42
- package/lib/commonjs/dom/nodes/paint/ImageFilters.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/MaskFilters.d.ts +3 -3
- package/lib/commonjs/dom/nodes/paint/MaskFilters.js +3 -2
- package/lib/commonjs/dom/nodes/paint/MaskFilters.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/PathEffects.d.ts +15 -18
- package/lib/commonjs/dom/nodes/paint/PathEffects.js +30 -72
- package/lib/commonjs/dom/nodes/paint/PathEffects.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/Shaders.d.ts +11 -12
- package/lib/commonjs/dom/nodes/paint/Shaders.js +28 -18
- package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/commonjs/dom/types/DeclarationContext.d.ts +29 -0
- package/lib/commonjs/dom/types/DeclarationContext.js +118 -0
- package/lib/commonjs/dom/types/DeclarationContext.js.map +1 -0
- package/lib/commonjs/dom/types/DrawingContext.d.ts +18 -1
- package/lib/commonjs/dom/types/DrawingContext.js +330 -0
- package/lib/commonjs/dom/types/DrawingContext.js.map +1 -1
- package/lib/commonjs/dom/types/Node.d.ts +4 -10
- package/lib/commonjs/dom/types/Node.js.map +1 -1
- package/lib/commonjs/dom/types/SkDOM.d.ts +22 -23
- package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
- package/lib/commonjs/dom/types/index.d.ts +1 -0
- package/lib/commonjs/dom/types/index.js +13 -0
- package/lib/commonjs/dom/types/index.js.map +1 -1
- package/lib/commonjs/index.d.ts +1 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +3 -3
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/DrawingContext.d.ts +4 -3
- package/lib/commonjs/renderer/DrawingContext.js.map +1 -1
- package/lib/commonjs/renderer/HostComponents.d.ts +35 -35
- package/lib/commonjs/renderer/HostComponents.js.map +1 -1
- package/lib/commonjs/renderer/HostConfig.js +1 -0
- package/lib/commonjs/renderer/HostConfig.js.map +1 -1
- package/lib/commonjs/renderer/Offscreen.d.ts +2 -0
- package/lib/commonjs/renderer/Offscreen.js +31 -0
- package/lib/commonjs/renderer/Offscreen.js.map +1 -0
- package/lib/commonjs/renderer/Reconciler.js +0 -1
- package/lib/commonjs/renderer/Reconciler.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/Surface.d.ts +4 -0
- package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +6 -0
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkSurface.js +4 -0
- package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +21 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/commonjs/views/SkiaBaseWebView.js +6 -4
- package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
- package/lib/commonjs/views/SkiaDomView.web.js +3 -14
- package/lib/commonjs/views/SkiaDomView.web.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +0 -7
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/commonjs/views/SkiaView.web.js +0 -7
- package/lib/commonjs/views/SkiaView.web.js.map +1 -1
- package/lib/module/dom/nodes/DrawingNode.js +5 -1
- package/lib/module/dom/nodes/DrawingNode.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.d.ts +33 -34
- package/lib/module/dom/nodes/LayerNode.js +13 -7
- package/lib/module/dom/nodes/LayerNode.js.map +1 -1
- package/lib/module/dom/nodes/Node.d.ts +6 -11
- package/lib/module/dom/nodes/Node.js +8 -25
- package/lib/module/dom/nodes/Node.js.map +1 -1
- package/lib/module/dom/nodes/PaintContext.js.map +1 -1
- package/lib/module/dom/nodes/PaintNode.d.ts +3 -3
- package/lib/module/dom/nodes/PaintNode.js +32 -15
- package/lib/module/dom/nodes/PaintNode.js.map +1 -1
- package/lib/module/dom/nodes/RenderNode.d.ts +2 -3
- package/lib/module/dom/nodes/RenderNode.js +20 -187
- package/lib/module/dom/nodes/RenderNode.js.map +1 -1
- package/lib/module/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
- package/lib/module/dom/nodes/drawings/BackdropFilterNode.js +23 -4
- package/lib/module/dom/nodes/drawings/BackdropFilterNode.js.map +1 -1
- package/lib/module/dom/nodes/drawings/Box.d.ts +3 -1
- package/lib/module/dom/nodes/drawings/Box.js +3 -0
- package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
- package/lib/module/dom/nodes/paint/BlendNode.d.ts +3 -7
- package/lib/module/dom/nodes/paint/BlendNode.js +15 -46
- package/lib/module/dom/nodes/paint/BlendNode.js.map +1 -1
- package/lib/module/dom/nodes/paint/ColorFilters.d.ts +10 -11
- package/lib/module/dom/nodes/paint/ColorFilters.js +29 -43
- package/lib/module/dom/nodes/paint/ColorFilters.js.map +1 -1
- package/lib/module/dom/nodes/paint/ImageFilters.d.ts +11 -11
- package/lib/module/dom/nodes/paint/ImageFilters.js +48 -41
- package/lib/module/dom/nodes/paint/ImageFilters.js.map +1 -1
- package/lib/module/dom/nodes/paint/MaskFilters.d.ts +3 -3
- package/lib/module/dom/nodes/paint/MaskFilters.js +3 -2
- package/lib/module/dom/nodes/paint/MaskFilters.js.map +1 -1
- package/lib/module/dom/nodes/paint/PathEffects.d.ts +15 -18
- package/lib/module/dom/nodes/paint/PathEffects.js +29 -72
- package/lib/module/dom/nodes/paint/PathEffects.js.map +1 -1
- package/lib/module/dom/nodes/paint/Shaders.d.ts +11 -12
- package/lib/module/dom/nodes/paint/Shaders.js +28 -18
- package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/module/dom/types/DeclarationContext.d.ts +29 -0
- package/lib/module/dom/types/DeclarationContext.js +107 -0
- package/lib/module/dom/types/DeclarationContext.js.map +1 -0
- package/lib/module/dom/types/DrawingContext.d.ts +18 -1
- package/lib/module/dom/types/DrawingContext.js +322 -1
- package/lib/module/dom/types/DrawingContext.js.map +1 -1
- package/lib/module/dom/types/Node.d.ts +4 -10
- package/lib/module/dom/types/Node.js.map +1 -1
- package/lib/module/dom/types/SkDOM.d.ts +22 -23
- package/lib/module/dom/types/SkDOM.js.map +1 -1
- package/lib/module/dom/types/index.d.ts +1 -0
- package/lib/module/dom/types/index.js +1 -0
- package/lib/module/dom/types/index.js.map +1 -1
- package/lib/module/index.d.ts +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +3 -3
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/DrawingContext.d.ts +4 -3
- package/lib/module/renderer/DrawingContext.js.map +1 -1
- package/lib/module/renderer/HostComponents.d.ts +35 -35
- package/lib/module/renderer/HostComponents.js.map +1 -1
- package/lib/module/renderer/HostConfig.js +1 -0
- package/lib/module/renderer/HostConfig.js.map +1 -1
- package/lib/module/renderer/Offscreen.d.ts +2 -0
- package/lib/module/renderer/Offscreen.js +19 -0
- package/lib/module/renderer/Offscreen.js.map +1 -0
- package/lib/module/renderer/Reconciler.js +0 -1
- package/lib/module/renderer/Reconciler.js.map +1 -1
- package/lib/module/skia/types/Surface/Surface.d.ts +4 -0
- package/lib/module/skia/types/Surface/Surface.js.map +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +6 -0
- package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/module/skia/web/JsiSkSurface.js +4 -0
- package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js +21 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/module/views/SkiaBaseWebView.js +6 -4
- package/lib/module/views/SkiaBaseWebView.js.map +1 -1
- package/lib/module/views/SkiaDomView.web.js +2 -11
- package/lib/module/views/SkiaDomView.web.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +0 -5
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/views/SkiaView.web.js +0 -5
- package/lib/module/views/SkiaView.web.js.map +1 -1
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +33 -34
- package/lib/typescript/src/dom/nodes/Node.d.ts +6 -11
- package/lib/typescript/src/dom/nodes/PaintNode.d.ts +3 -3
- package/lib/typescript/src/dom/nodes/RenderNode.d.ts +2 -3
- package/lib/typescript/src/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
- package/lib/typescript/src/dom/nodes/drawings/Box.d.ts +3 -1
- package/lib/typescript/src/dom/nodes/paint/BlendNode.d.ts +3 -7
- package/lib/typescript/src/dom/nodes/paint/ColorFilters.d.ts +10 -11
- package/lib/typescript/src/dom/nodes/paint/ImageFilters.d.ts +11 -11
- package/lib/typescript/src/dom/nodes/paint/MaskFilters.d.ts +3 -3
- package/lib/typescript/src/dom/nodes/paint/PathEffects.d.ts +15 -18
- package/lib/typescript/src/dom/nodes/paint/Shaders.d.ts +11 -12
- package/lib/typescript/src/dom/types/DeclarationContext.d.ts +29 -0
- package/lib/typescript/src/dom/types/DrawingContext.d.ts +18 -1
- package/lib/typescript/src/dom/types/Node.d.ts +4 -10
- package/lib/typescript/src/dom/types/SkDOM.d.ts +22 -23
- package/lib/typescript/src/dom/types/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/renderer/DrawingContext.d.ts +4 -3
- package/lib/typescript/src/renderer/HostComponents.d.ts +35 -35
- package/lib/typescript/src/renderer/Offscreen.d.ts +2 -0
- package/lib/typescript/src/skia/types/Surface/Surface.d.ts +4 -0
- package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +6 -0
- package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/package.json +1 -1
- package/src/dom/nodes/DrawingNode.ts +5 -1
- package/src/dom/nodes/LayerNode.ts +13 -11
- package/src/dom/nodes/Node.ts +18 -41
- package/src/dom/nodes/PaintContext.ts +1 -0
- package/src/dom/nodes/PaintNode.ts +28 -18
- package/src/dom/nodes/RenderNode.ts +25 -183
- package/src/dom/nodes/drawings/BackdropFilterNode.ts +18 -11
- package/src/dom/nodes/drawings/Box.ts +6 -4
- package/src/dom/nodes/paint/BlendNode.ts +16 -63
- package/src/dom/nodes/paint/ColorFilters.ts +32 -55
- package/src/dom/nodes/paint/ImageFilters.ts +58 -53
- package/src/dom/nodes/paint/MaskFilters.ts +5 -7
- package/src/dom/nodes/paint/PathEffects.ts +37 -90
- package/src/dom/nodes/paint/Shaders.ts +31 -29
- package/src/dom/types/DeclarationContext.ts +105 -0
- package/src/dom/types/DrawingContext.ts +304 -1
- package/src/dom/types/Node.ts +4 -20
- package/src/dom/types/SkDOM.ts +22 -43
- package/src/dom/types/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/renderer/Canvas.tsx +3 -3
- package/src/renderer/DrawingContext.ts +4 -5
- package/src/renderer/HostComponents.ts +34 -53
- package/src/renderer/HostConfig.ts +1 -0
- package/src/renderer/Offscreen.tsx +24 -0
- package/src/renderer/Reconciler.tsx +0 -1
- package/src/skia/types/Surface/Surface.ts +5 -0
- package/src/skia/types/Surface/SurfaceFactory.ts +7 -0
- package/src/skia/web/JsiSkSurface.ts +4 -0
- package/src/skia/web/JsiSkSurfaceFactory.ts +21 -2
- package/src/views/SkiaBaseWebView.tsx +6 -2
- package/src/views/SkiaDomView.web.tsx +2 -13
- package/src/views/SkiaPictureView.web.tsx +0 -7
- package/src/views/SkiaView.web.tsx +0 -7
@@ -0,0 +1,105 @@
|
|
1
|
+
import type {
|
2
|
+
SkShader,
|
3
|
+
SkPaint,
|
4
|
+
SkImageFilter,
|
5
|
+
SkMaskFilter,
|
6
|
+
SkPathEffect,
|
7
|
+
Skia,
|
8
|
+
SkColorFilter,
|
9
|
+
} from "../../skia/types";
|
10
|
+
|
11
|
+
type Composer<T> = (outer: T, inner: T) => T;
|
12
|
+
|
13
|
+
export const composeDeclarations = <T>(filters: T[], composer: Composer<T>) => {
|
14
|
+
if (filters.length <= 1) {
|
15
|
+
return filters[0];
|
16
|
+
}
|
17
|
+
return filters.reverse().reduce((inner, outer) => {
|
18
|
+
if (!inner) {
|
19
|
+
return outer;
|
20
|
+
}
|
21
|
+
return composer(outer, inner);
|
22
|
+
});
|
23
|
+
};
|
24
|
+
|
25
|
+
class Declaration<T> {
|
26
|
+
private decls: T[] = [];
|
27
|
+
private indexes = [0];
|
28
|
+
|
29
|
+
constructor(private composer?: Composer<T>) {}
|
30
|
+
|
31
|
+
private get index() {
|
32
|
+
return this.indexes[this.indexes.length - 1];
|
33
|
+
}
|
34
|
+
|
35
|
+
save() {
|
36
|
+
this.indexes.push(this.decls.length);
|
37
|
+
}
|
38
|
+
|
39
|
+
restore() {
|
40
|
+
this.indexes.pop();
|
41
|
+
}
|
42
|
+
|
43
|
+
pop() {
|
44
|
+
return this.decls.pop();
|
45
|
+
}
|
46
|
+
|
47
|
+
push(decl: T) {
|
48
|
+
this.decls.push(decl);
|
49
|
+
}
|
50
|
+
|
51
|
+
popAll() {
|
52
|
+
return this.decls.splice(this.index, this.decls.length - this.index);
|
53
|
+
}
|
54
|
+
|
55
|
+
popAllAsOne() {
|
56
|
+
if (!this.composer) {
|
57
|
+
throw new Error("No composer for this type of declaration");
|
58
|
+
}
|
59
|
+
const decls = this.popAll();
|
60
|
+
return composeDeclarations(decls, this.composer!);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
export class DeclarationContext {
|
65
|
+
readonly paints: Declaration<SkPaint>;
|
66
|
+
readonly maskFilters: Declaration<SkMaskFilter>;
|
67
|
+
readonly shaders: Declaration<SkShader>;
|
68
|
+
readonly pathEffects: Declaration<SkPathEffect>;
|
69
|
+
readonly imageFilters: Declaration<SkImageFilter>;
|
70
|
+
readonly colorFilters: Declaration<SkColorFilter>;
|
71
|
+
|
72
|
+
constructor(private Skia: Skia) {
|
73
|
+
const peComp = this.Skia.PathEffect.MakeCompose.bind(this.Skia.PathEffect);
|
74
|
+
const ifComp = this.Skia.ImageFilter.MakeCompose.bind(
|
75
|
+
this.Skia.ImageFilter
|
76
|
+
);
|
77
|
+
const cfComp = this.Skia.ColorFilter.MakeCompose.bind(
|
78
|
+
this.Skia.ColorFilter
|
79
|
+
);
|
80
|
+
this.paints = new Declaration<SkPaint>();
|
81
|
+
this.maskFilters = new Declaration<SkMaskFilter>();
|
82
|
+
this.shaders = new Declaration<SkShader>();
|
83
|
+
this.pathEffects = new Declaration<SkPathEffect>(peComp);
|
84
|
+
this.imageFilters = new Declaration<SkImageFilter>(ifComp);
|
85
|
+
this.colorFilters = new Declaration<SkColorFilter>(cfComp);
|
86
|
+
}
|
87
|
+
|
88
|
+
save() {
|
89
|
+
this.paints.save();
|
90
|
+
this.maskFilters.save();
|
91
|
+
this.shaders.save();
|
92
|
+
this.pathEffects.save();
|
93
|
+
this.imageFilters.save();
|
94
|
+
this.colorFilters.save();
|
95
|
+
}
|
96
|
+
|
97
|
+
restore() {
|
98
|
+
this.paints.restore();
|
99
|
+
this.maskFilters.restore();
|
100
|
+
this.shaders.restore();
|
101
|
+
this.pathEffects.restore();
|
102
|
+
this.imageFilters.restore();
|
103
|
+
this.colorFilters.restore();
|
104
|
+
}
|
105
|
+
}
|
@@ -1,6 +1,309 @@
|
|
1
|
-
import type {
|
1
|
+
import type {
|
2
|
+
SkCanvas,
|
3
|
+
SkColor,
|
4
|
+
SkColorFilter,
|
5
|
+
SkImageFilter,
|
6
|
+
SkMaskFilter,
|
7
|
+
SkPaint,
|
8
|
+
SkPathEffect,
|
9
|
+
SkShader,
|
10
|
+
Skia,
|
11
|
+
} from "../../skia/types";
|
12
|
+
import { BlendMode, PaintStyle, StrokeCap, StrokeJoin } from "../../skia/types";
|
13
|
+
import { enumKey } from "../nodes/datatypes/Enum";
|
14
|
+
import { JsiDeclarationNode } from "../nodes/Node";
|
15
|
+
|
16
|
+
import type { PaintProps, SkEnum } from "./Common";
|
17
|
+
import { DeclarationContext } from "./DeclarationContext";
|
18
|
+
import type { Node } from "./Node";
|
2
19
|
|
3
20
|
export interface DrawingContext {
|
4
21
|
canvas: SkCanvas;
|
5
22
|
paint: SkPaint;
|
23
|
+
saveAndConcat(node: Node<PaintProps>, cache?: SkPaint): boolean;
|
24
|
+
restore(): void;
|
25
|
+
declarationCtx: DeclarationContext;
|
26
|
+
}
|
27
|
+
|
28
|
+
export class JsiDrawingContext implements DrawingContext {
|
29
|
+
paints: SkPaint[];
|
30
|
+
|
31
|
+
declarationCtx: DeclarationContext;
|
32
|
+
|
33
|
+
constructor(private readonly Skia: Skia, public readonly canvas: SkCanvas) {
|
34
|
+
const paint = this.Skia.Paint();
|
35
|
+
this.paints = [paint];
|
36
|
+
this.declarationCtx = new DeclarationContext(Skia);
|
37
|
+
}
|
38
|
+
|
39
|
+
get paint() {
|
40
|
+
return this.paints[this.paints.length - 1];
|
41
|
+
}
|
42
|
+
|
43
|
+
private save() {
|
44
|
+
const childPaint = this.paint.copy();
|
45
|
+
this.paints.push(childPaint);
|
46
|
+
}
|
47
|
+
|
48
|
+
restore(): void {
|
49
|
+
this.paints.pop();
|
50
|
+
}
|
51
|
+
|
52
|
+
saveAndConcat(node: Node<PaintProps>, cache?: SkPaint) {
|
53
|
+
if (cache) {
|
54
|
+
this.paints.push(cache);
|
55
|
+
return true;
|
56
|
+
}
|
57
|
+
const paint = new ConcatablePaint(this.Skia, this.declarationCtx, node);
|
58
|
+
if (!paint.isPristine()) {
|
59
|
+
this.save();
|
60
|
+
paint.concatTo(this.paint);
|
61
|
+
return true;
|
62
|
+
}
|
63
|
+
return false;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
class ConcatablePaint {
|
68
|
+
private pristine = true;
|
69
|
+
|
70
|
+
_color?: SkColor;
|
71
|
+
_strokeWidth?: number;
|
72
|
+
_blendMode?: BlendMode;
|
73
|
+
_style?: PaintStyle;
|
74
|
+
_strokeJoin?: StrokeJoin;
|
75
|
+
_strokeCap?: StrokeCap;
|
76
|
+
_strokeMiter?: number;
|
77
|
+
_opacity = 1;
|
78
|
+
_antiAlias?: boolean;
|
79
|
+
|
80
|
+
_imageFilter?: SkImageFilter;
|
81
|
+
_shader?: SkShader;
|
82
|
+
_pathEffect?: SkPathEffect;
|
83
|
+
_colorFilter?: SkColorFilter;
|
84
|
+
_maskFilter?: SkMaskFilter;
|
85
|
+
|
86
|
+
constructor(Skia: Skia, declCtx: DeclarationContext, node: Node<PaintProps>) {
|
87
|
+
const props = node.getProps();
|
88
|
+
const children = node.children();
|
89
|
+
this.setColor(
|
90
|
+
props.color !== undefined ? Skia.Color(props.color) : props.color
|
91
|
+
);
|
92
|
+
this.setStrokeWidth(props.strokeWidth);
|
93
|
+
this.setBlendMode(props.blendMode);
|
94
|
+
this.setStyle(props.style);
|
95
|
+
this.setStrokeJoin(props.strokeJoin);
|
96
|
+
this.setStrokeCap(props.strokeCap);
|
97
|
+
this.setStrokeMiter(props.strokeMiter);
|
98
|
+
this.setOpacity(props.opacity);
|
99
|
+
this.setAntiAlias(props.antiAlias);
|
100
|
+
declCtx.save();
|
101
|
+
children.forEach((child) => {
|
102
|
+
if (child instanceof JsiDeclarationNode) {
|
103
|
+
child.decorate(declCtx);
|
104
|
+
}
|
105
|
+
});
|
106
|
+
const colorFilter = declCtx.colorFilters.popAllAsOne();
|
107
|
+
const imageFilter = declCtx.imageFilters.popAllAsOne();
|
108
|
+
const shader = declCtx.shaders.pop();
|
109
|
+
const maskFilter = declCtx.maskFilters.pop();
|
110
|
+
const pathEffect = declCtx.pathEffects.popAllAsOne();
|
111
|
+
declCtx.restore();
|
112
|
+
if (imageFilter) {
|
113
|
+
this.setImageFilter(imageFilter);
|
114
|
+
}
|
115
|
+
if (shader) {
|
116
|
+
this.setShader(shader);
|
117
|
+
}
|
118
|
+
if (pathEffect) {
|
119
|
+
this.setPathEffect(pathEffect);
|
120
|
+
}
|
121
|
+
if (colorFilter) {
|
122
|
+
this.setColorFilter(colorFilter);
|
123
|
+
}
|
124
|
+
if (maskFilter) {
|
125
|
+
this.setMaskFilter(maskFilter);
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
private enum<T>(value: T, key?: Uncapitalize<string>) {
|
130
|
+
if (key !== undefined) {
|
131
|
+
return value[enumKey(key) as keyof T];
|
132
|
+
}
|
133
|
+
return undefined;
|
134
|
+
}
|
135
|
+
|
136
|
+
private setValue<T extends keyof typeof this>(
|
137
|
+
key: T,
|
138
|
+
value?: typeof this[T]
|
139
|
+
) {
|
140
|
+
if (value !== undefined) {
|
141
|
+
this[key] = value;
|
142
|
+
this.pristine = false;
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
146
|
+
setColor(color?: SkColor) {
|
147
|
+
this.setValue("_color", color);
|
148
|
+
}
|
149
|
+
|
150
|
+
getColor() {
|
151
|
+
return this._color;
|
152
|
+
}
|
153
|
+
|
154
|
+
setStrokeWidth(strokeWidth?: number) {
|
155
|
+
this.setValue("_strokeWidth", strokeWidth);
|
156
|
+
}
|
157
|
+
|
158
|
+
getStrokeWidth() {
|
159
|
+
return this._strokeWidth;
|
160
|
+
}
|
161
|
+
|
162
|
+
setBlendMode(blendMode?: SkEnum<typeof BlendMode>) {
|
163
|
+
this.setValue("_blendMode", this.enum(BlendMode, blendMode));
|
164
|
+
}
|
165
|
+
|
166
|
+
getBlendMode() {
|
167
|
+
return this._blendMode;
|
168
|
+
}
|
169
|
+
|
170
|
+
setStyle(style?: SkEnum<typeof PaintStyle>) {
|
171
|
+
this.setValue("_style", this.enum(PaintStyle, style));
|
172
|
+
}
|
173
|
+
|
174
|
+
getStyle() {
|
175
|
+
return this._style;
|
176
|
+
}
|
177
|
+
|
178
|
+
setStrokeJoin(strokeJoin?: SkEnum<typeof StrokeJoin>) {
|
179
|
+
this.setValue("_strokeJoin", this.enum(StrokeJoin, strokeJoin));
|
180
|
+
}
|
181
|
+
|
182
|
+
getStrokeJoin() {
|
183
|
+
return this._strokeJoin;
|
184
|
+
}
|
185
|
+
|
186
|
+
setStrokeCap(strokeCap?: SkEnum<typeof StrokeCap>) {
|
187
|
+
this.setValue("_strokeCap", this.enum(StrokeCap, strokeCap));
|
188
|
+
}
|
189
|
+
|
190
|
+
getStrokeCap() {
|
191
|
+
return this._strokeCap;
|
192
|
+
}
|
193
|
+
|
194
|
+
setStrokeMiter(strokeMiter?: number) {
|
195
|
+
this.setValue("_strokeMiter", strokeMiter);
|
196
|
+
}
|
197
|
+
|
198
|
+
getStrokeMiter() {
|
199
|
+
return this._strokeMiter;
|
200
|
+
}
|
201
|
+
|
202
|
+
setOpacity(opacity?: number) {
|
203
|
+
this.setValue("_opacity", opacity);
|
204
|
+
}
|
205
|
+
|
206
|
+
getOpacity() {
|
207
|
+
return this._opacity;
|
208
|
+
}
|
209
|
+
|
210
|
+
setAntiAlias(antiAlias?: boolean) {
|
211
|
+
this.setValue("_antiAlias", antiAlias);
|
212
|
+
}
|
213
|
+
|
214
|
+
getAntiAlias() {
|
215
|
+
return this._antiAlias;
|
216
|
+
}
|
217
|
+
|
218
|
+
setImageFilter(imageFilter?: SkImageFilter) {
|
219
|
+
this.setValue("_imageFilter", imageFilter);
|
220
|
+
}
|
221
|
+
|
222
|
+
getImageFilter() {
|
223
|
+
return this._imageFilter;
|
224
|
+
}
|
225
|
+
|
226
|
+
setShader(shader?: SkShader) {
|
227
|
+
this.setValue("_shader", shader);
|
228
|
+
}
|
229
|
+
|
230
|
+
getShader() {
|
231
|
+
return this._shader;
|
232
|
+
}
|
233
|
+
|
234
|
+
setPathEffect(pathEffect?: SkPathEffect) {
|
235
|
+
this.setValue("_pathEffect", pathEffect);
|
236
|
+
}
|
237
|
+
|
238
|
+
getPathEffect() {
|
239
|
+
return this._pathEffect;
|
240
|
+
}
|
241
|
+
|
242
|
+
setColorFilter(colorFilter?: SkColorFilter) {
|
243
|
+
this.setValue("_colorFilter", colorFilter);
|
244
|
+
}
|
245
|
+
|
246
|
+
getColorFilter() {
|
247
|
+
return this._colorFilter;
|
248
|
+
}
|
249
|
+
|
250
|
+
setMaskFilter(maskFilter?: SkMaskFilter) {
|
251
|
+
this.setValue("_maskFilter", maskFilter);
|
252
|
+
}
|
253
|
+
|
254
|
+
getMaskFilter() {
|
255
|
+
return this._maskFilter;
|
256
|
+
}
|
257
|
+
|
258
|
+
isPristine() {
|
259
|
+
return this.pristine;
|
260
|
+
}
|
261
|
+
|
262
|
+
concatTo(paint: SkPaint) {
|
263
|
+
if (this._opacity !== undefined) {
|
264
|
+
paint.setAlphaf(paint.getAlphaf() * this._opacity);
|
265
|
+
}
|
266
|
+
if (this._color !== undefined) {
|
267
|
+
const currentOpacity = paint.getAlphaf();
|
268
|
+
paint.setShader(null);
|
269
|
+
paint.setColor(this._color);
|
270
|
+
paint.setAlphaf(currentOpacity * paint.getAlphaf());
|
271
|
+
}
|
272
|
+
if (this._strokeWidth !== undefined) {
|
273
|
+
paint.setStrokeWidth(this._strokeWidth);
|
274
|
+
}
|
275
|
+
if (this._blendMode !== undefined) {
|
276
|
+
paint.setBlendMode(this._blendMode);
|
277
|
+
}
|
278
|
+
if (this._style !== undefined) {
|
279
|
+
paint.setStyle(this._style);
|
280
|
+
}
|
281
|
+
if (this._strokeJoin !== undefined) {
|
282
|
+
paint.setStrokeJoin(this._strokeJoin);
|
283
|
+
}
|
284
|
+
if (this._strokeCap !== undefined) {
|
285
|
+
paint.setStrokeCap(this._strokeCap);
|
286
|
+
}
|
287
|
+
if (this._strokeMiter !== undefined) {
|
288
|
+
paint.setStrokeMiter(this._strokeMiter);
|
289
|
+
}
|
290
|
+
if (this._antiAlias !== undefined) {
|
291
|
+
paint.setAntiAlias(this._antiAlias);
|
292
|
+
}
|
293
|
+
if (this._imageFilter !== undefined) {
|
294
|
+
paint.setImageFilter(this._imageFilter);
|
295
|
+
}
|
296
|
+
if (this._shader !== undefined) {
|
297
|
+
paint.setShader(this._shader);
|
298
|
+
}
|
299
|
+
if (this._pathEffect !== undefined) {
|
300
|
+
paint.setPathEffect(this._pathEffect);
|
301
|
+
}
|
302
|
+
if (this._colorFilter !== undefined) {
|
303
|
+
paint.setColorFilter(this._colorFilter);
|
304
|
+
}
|
305
|
+
if (this._maskFilter !== undefined) {
|
306
|
+
paint.setMaskFilter(this._maskFilter);
|
307
|
+
}
|
308
|
+
}
|
6
309
|
}
|
package/src/dom/types/Node.ts
CHANGED
@@ -1,15 +1,7 @@
|
|
1
|
-
import type {
|
2
|
-
SkColorFilter,
|
3
|
-
SkImageFilter,
|
4
|
-
SkMaskFilter,
|
5
|
-
SkPaint,
|
6
|
-
SkPathEffect,
|
7
|
-
SkShader,
|
8
|
-
} from "../../skia/types";
|
9
|
-
|
10
1
|
import type { GroupProps } from "./Common";
|
11
|
-
import type { DrawingContext } from "./DrawingContext";
|
12
2
|
import type { DeclarationType, NodeType } from "./NodeType";
|
3
|
+
import type { DeclarationContext } from "./DeclarationContext";
|
4
|
+
import type { DrawingContext } from "./DrawingContext";
|
13
5
|
|
14
6
|
export interface Node<P> {
|
15
7
|
type: NodeType;
|
@@ -26,19 +18,11 @@ export interface Node<P> {
|
|
26
18
|
|
27
19
|
export type Invalidate = () => void;
|
28
20
|
|
29
|
-
export interface DeclarationNode<P
|
30
|
-
extends Node<P> {
|
21
|
+
export interface DeclarationNode<P> extends Node<P> {
|
31
22
|
declarationType: DeclarationType;
|
32
|
-
|
23
|
+
decorate(ctx: DeclarationContext): void;
|
33
24
|
|
34
25
|
setInvalidate(invalidate: Invalidate): void;
|
35
|
-
|
36
|
-
isPaint(): this is DeclarationNode<unknown, SkPaint>;
|
37
|
-
isImageFilter(): this is DeclarationNode<unknown, SkImageFilter>;
|
38
|
-
isColorFilter(): this is DeclarationNode<unknown, SkColorFilter>;
|
39
|
-
isShader(): this is DeclarationNode<unknown, SkShader>;
|
40
|
-
isMaskFilter(): this is DeclarationNode<unknown, SkMaskFilter>;
|
41
|
-
isPathEffect(): this is DeclarationNode<unknown, SkPathEffect>;
|
42
26
|
}
|
43
27
|
|
44
28
|
export interface RenderNode<P extends GroupProps> extends Node<P> {
|
package/src/dom/types/SkDOM.ts
CHANGED
@@ -1,12 +1,3 @@
|
|
1
|
-
import type {
|
2
|
-
SkImageFilter,
|
3
|
-
SkMaskFilter,
|
4
|
-
SkShader,
|
5
|
-
SkColorFilter,
|
6
|
-
SkPathEffect,
|
7
|
-
SkPaint,
|
8
|
-
} from "../../skia/types";
|
9
|
-
|
10
1
|
import type { ChildrenProps, GroupProps, PaintProps } from "./Common";
|
11
2
|
import type {
|
12
3
|
BlendImageFilterProps,
|
@@ -68,17 +59,17 @@ import type {
|
|
68
59
|
Path2DPathEffectProps,
|
69
60
|
} from "./PathEffects";
|
70
61
|
|
71
|
-
type ImageFilterNode<P> = DeclarationNode<P
|
62
|
+
type ImageFilterNode<P> = DeclarationNode<P>;
|
72
63
|
|
73
|
-
type PathEffectNode<P> = DeclarationNode<P
|
74
|
-
type NullablePathEffectNode<P> = DeclarationNode<P
|
64
|
+
type PathEffectNode<P> = DeclarationNode<P>;
|
65
|
+
type NullablePathEffectNode<P> = DeclarationNode<P>;
|
75
66
|
|
76
67
|
type DrawingNode<P extends GroupProps> = RenderNode<P>;
|
77
68
|
|
78
69
|
export interface SkDOM {
|
79
70
|
Layer(props?: ChildrenProps): RenderNode<ChildrenProps>;
|
80
71
|
Group(props?: GroupProps): RenderNode<GroupProps>;
|
81
|
-
Paint(props: PaintProps): DeclarationNode<PaintProps
|
72
|
+
Paint(props: PaintProps): DeclarationNode<PaintProps>;
|
82
73
|
|
83
74
|
// Drawings
|
84
75
|
Fill(props?: DrawingNodeProps): DrawingNode<DrawingNodeProps>;
|
@@ -106,7 +97,7 @@ export interface SkDOM {
|
|
106
97
|
// BlurMaskFilters
|
107
98
|
BlurMaskFilter(
|
108
99
|
props: BlurMaskFilterProps
|
109
|
-
): DeclarationNode<BlurMaskFilterProps
|
100
|
+
): DeclarationNode<BlurMaskFilterProps>;
|
110
101
|
|
111
102
|
// ImageFilters
|
112
103
|
BlendImageFilter(
|
@@ -134,41 +125,33 @@ export interface SkDOM {
|
|
134
125
|
// ColorFilters
|
135
126
|
MatrixColorFilter(
|
136
127
|
props: MatrixColorFilterProps
|
137
|
-
): DeclarationNode<MatrixColorFilterProps
|
128
|
+
): DeclarationNode<MatrixColorFilterProps>;
|
138
129
|
BlendColorFilter(
|
139
130
|
props: BlendColorFilterProps
|
140
|
-
): DeclarationNode<BlendColorFilterProps
|
141
|
-
LumaColorFilter(): DeclarationNode<null
|
142
|
-
LinearToSRGBGammaColorFilter(): DeclarationNode<null
|
143
|
-
SRGBToLinearGammaColorFilter(): DeclarationNode<null
|
131
|
+
): DeclarationNode<BlendColorFilterProps>;
|
132
|
+
LumaColorFilter(): DeclarationNode<null>;
|
133
|
+
LinearToSRGBGammaColorFilter(): DeclarationNode<null>;
|
134
|
+
SRGBToLinearGammaColorFilter(): DeclarationNode<null>;
|
144
135
|
LerpColorFilter(
|
145
136
|
props: LerpColorFilterProps
|
146
|
-
): DeclarationNode<LerpColorFilterProps
|
137
|
+
): DeclarationNode<LerpColorFilterProps>;
|
147
138
|
|
148
139
|
// Shaders
|
149
|
-
Shader(props: ShaderProps): DeclarationNode<ShaderProps
|
150
|
-
ImageShader(
|
151
|
-
|
152
|
-
): DeclarationNode<
|
153
|
-
|
154
|
-
Turbulence(
|
155
|
-
props: TurbulenceProps
|
156
|
-
): DeclarationNode<TurbulenceProps, SkShader>;
|
157
|
-
FractalNoise(
|
158
|
-
props: FractalNoiseProps
|
159
|
-
): DeclarationNode<FractalNoiseProps, SkShader>;
|
140
|
+
Shader(props: ShaderProps): DeclarationNode<ShaderProps>;
|
141
|
+
ImageShader(props: ImageShaderProps): DeclarationNode<ImageShaderProps>;
|
142
|
+
ColorShader(props: ColorProps): DeclarationNode<ColorProps>;
|
143
|
+
Turbulence(props: TurbulenceProps): DeclarationNode<TurbulenceProps>;
|
144
|
+
FractalNoise(props: FractalNoiseProps): DeclarationNode<FractalNoiseProps>;
|
160
145
|
LinearGradient(
|
161
146
|
props: LinearGradientProps
|
162
|
-
): DeclarationNode<LinearGradientProps
|
147
|
+
): DeclarationNode<LinearGradientProps>;
|
163
148
|
RadialGradient(
|
164
149
|
props: RadialGradientProps
|
165
|
-
): DeclarationNode<RadialGradientProps
|
166
|
-
SweepGradient(
|
167
|
-
props: SweepGradientProps
|
168
|
-
): DeclarationNode<SweepGradientProps, SkShader>;
|
150
|
+
): DeclarationNode<RadialGradientProps>;
|
151
|
+
SweepGradient(props: SweepGradientProps): DeclarationNode<SweepGradientProps>;
|
169
152
|
TwoPointConicalGradient(
|
170
153
|
props: TwoPointConicalGradientProps
|
171
|
-
): DeclarationNode<TwoPointConicalGradientProps
|
154
|
+
): DeclarationNode<TwoPointConicalGradientProps>;
|
172
155
|
|
173
156
|
// Path Effects
|
174
157
|
CornerPathEffect(
|
@@ -192,12 +175,8 @@ export interface SkDOM {
|
|
192
175
|
): NullablePathEffectNode<Line2DPathEffectProps>;
|
193
176
|
|
194
177
|
// Mixed
|
195
|
-
Blend(
|
196
|
-
props: BlendProps
|
197
|
-
): DeclarationNode<BlendProps, SkShader | SkImageFilter>;
|
178
|
+
Blend(props: BlendProps): DeclarationNode<BlendProps>;
|
198
179
|
BackdropFilter(props: ChildrenProps): RenderNode<ChildrenProps>;
|
199
180
|
Box(props: BoxProps): RenderNode<BoxProps>;
|
200
|
-
BoxShadow(
|
201
|
-
props: BoxShadowProps
|
202
|
-
): DeclarationNode<BoxShadowProps, BoxShadowProps>;
|
181
|
+
BoxShadow(props: BoxShadowProps): DeclarationNode<BoxShadowProps>;
|
203
182
|
}
|
package/src/dom/types/index.ts
CHANGED
package/src/index.ts
CHANGED
package/src/renderer/Canvas.tsx
CHANGED
@@ -40,10 +40,10 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
|
|
40
40
|
|
41
41
|
const registerValues = useCallback(
|
42
42
|
(values: Array<SkiaValue<unknown>>) => {
|
43
|
-
if (ref.current
|
44
|
-
|
43
|
+
if (ref.current !== null) {
|
44
|
+
return ref.current.registerValues(values);
|
45
45
|
}
|
46
|
-
return
|
46
|
+
return () => {};
|
47
47
|
},
|
48
48
|
[ref]
|
49
49
|
);
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import type { DrawingInfo } from "../views";
|
2
|
-
import type { Skia } from "../skia/types";
|
3
|
-
import type { DrawingContext as DOMDrawingContext } from "../dom/types";
|
2
|
+
import type { Skia, SkCanvas, SkPaint } from "../skia/types";
|
4
3
|
|
5
|
-
export interface DrawingContext
|
6
|
-
extends Omit<DrawingInfo, "touches">,
|
7
|
-
DOMDrawingContext {
|
4
|
+
export interface DrawingContext extends Omit<DrawingInfo, "touches"> {
|
8
5
|
Skia: Skia;
|
6
|
+
canvas: SkCanvas;
|
7
|
+
paint: SkPaint;
|
9
8
|
}
|