@shopify/react-native-skia 0.1.172 → 0.1.174
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 +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 +56 -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/JsiSkDataFactory.js +0 -1
- package/lib/commonjs/skia/web/JsiSkDataFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkImage.js +34 -3
- package/lib/commonjs/skia/web/JsiSkImage.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 +14 -8
- 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/JsiSkDataFactory.js +0 -1
- package/lib/module/skia/web/JsiSkDataFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/module/skia/web/JsiSkImage.js +31 -3
- package/lib/module/skia/web/JsiSkImage.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 +14 -8
- 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/JsiSkImage.d.ts +1 -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/JsiSkDataFactory.ts +0 -1
- package/src/skia/web/JsiSkImage.ts +26 -2
- package/src/skia/web/JsiSkSurface.ts +4 -0
- package/src/skia/web/JsiSkSurfaceFactory.ts +21 -2
- package/src/views/SkiaBaseWebView.tsx +9 -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
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import type {
|
|
9
9
|
BlendImageFilterProps,
|
|
10
10
|
BlurImageFilterProps,
|
|
11
|
+
DeclarationContext,
|
|
11
12
|
DisplacementMapImageFilterProps,
|
|
12
13
|
DropShadowImageFilterProps,
|
|
13
14
|
MorphologyImageFilterProps,
|
|
@@ -55,37 +56,31 @@ const MakeInnerShadow = (
|
|
|
55
56
|
);
|
|
56
57
|
};
|
|
57
58
|
|
|
58
|
-
export abstract class ImageFilterDeclaration<
|
|
59
|
-
P,
|
|
60
|
-
Nullable extends null | never = never
|
|
61
|
-
> extends JsiDeclarationNode<P, SkImageFilter, Nullable> {
|
|
59
|
+
export abstract class ImageFilterDeclaration<P> extends JsiDeclarationNode<P> {
|
|
62
60
|
constructor(ctx: NodeContext, type: NodeType, props: P) {
|
|
63
61
|
super(ctx, DeclarationType.ImageFilter, type, props);
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} else if (child.declarationType === DeclarationType.ColorFilter) {
|
|
82
|
-
return this.Skia.ImageFilter.MakeColorFilter(child.materialize(), null);
|
|
83
|
-
} else {
|
|
84
|
-
throw new Error(`Found invalid child ${child.type} in ${this.type}`);
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
throw new Error(`Found invalid child ${child.type} in ${this.type}`);
|
|
64
|
+
protected input(ctx: DeclarationContext) {
|
|
65
|
+
return ctx.imageFilters.pop() ?? null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
protected composeAndPush(ctx: DeclarationContext, imgf1: SkImageFilter) {
|
|
69
|
+
ctx.save();
|
|
70
|
+
this.decorateChildren(ctx);
|
|
71
|
+
let imgf2 = ctx.imageFilters.popAllAsOne();
|
|
72
|
+
const cf = ctx.colorFilters.popAllAsOne();
|
|
73
|
+
ctx.restore();
|
|
74
|
+
if (cf) {
|
|
75
|
+
imgf2 = this.Skia.ImageFilter.MakeCompose(
|
|
76
|
+
imgf2 ?? null,
|
|
77
|
+
this.Skia.ImageFilter.MakeColorFilter(cf, null)
|
|
78
|
+
);
|
|
88
79
|
}
|
|
80
|
+
const imgf = imgf2
|
|
81
|
+
? this.Skia.ImageFilter.MakeCompose(imgf1, imgf2)
|
|
82
|
+
: imgf1;
|
|
83
|
+
ctx.imageFilters.push(imgf);
|
|
89
84
|
}
|
|
90
85
|
}
|
|
91
86
|
|
|
@@ -94,13 +89,11 @@ export class OffsetImageFilterNode extends ImageFilterDeclaration<OffsetImageFil
|
|
|
94
89
|
super(ctx, NodeType.OffsetImageFilter, props);
|
|
95
90
|
}
|
|
96
91
|
|
|
97
|
-
|
|
92
|
+
decorate(ctx: DeclarationContext) {
|
|
93
|
+
this.decorateChildren(ctx);
|
|
98
94
|
const { x, y } = this.props;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
y,
|
|
102
|
-
this.getOptionalChildInstance(0)
|
|
103
|
-
);
|
|
95
|
+
const imgf = this.Skia.ImageFilter.MakeOffset(x, y, null);
|
|
96
|
+
this.composeAndPush(ctx, imgf);
|
|
104
97
|
}
|
|
105
98
|
}
|
|
106
99
|
|
|
@@ -109,15 +102,16 @@ export class DisplacementMapImageFilterNode extends ImageFilterDeclaration<Displ
|
|
|
109
102
|
super(ctx, NodeType.DisplacementMapImageFilter, props);
|
|
110
103
|
}
|
|
111
104
|
|
|
112
|
-
|
|
105
|
+
decorate(ctx: DeclarationContext) {
|
|
113
106
|
const { channelX, channelY, scale } = this.props;
|
|
114
|
-
|
|
107
|
+
const imgf = this.Skia.ImageFilter.MakeDisplacementMap(
|
|
115
108
|
ColorChannel[enumKey(channelX)],
|
|
116
109
|
ColorChannel[enumKey(channelY)],
|
|
117
110
|
scale,
|
|
118
|
-
|
|
119
|
-
this.
|
|
111
|
+
ctx.imageFilters.pop()!,
|
|
112
|
+
this.input(ctx)
|
|
120
113
|
);
|
|
114
|
+
this.composeAndPush(ctx, imgf);
|
|
121
115
|
}
|
|
122
116
|
}
|
|
123
117
|
|
|
@@ -126,15 +120,16 @@ export class BlurImageFilterNode extends ImageFilterDeclaration<BlurImageFilterP
|
|
|
126
120
|
super(ctx, NodeType.BlurImageFilter, props);
|
|
127
121
|
}
|
|
128
122
|
|
|
129
|
-
|
|
123
|
+
decorate(ctx: DeclarationContext) {
|
|
130
124
|
const { mode, blur } = this.props;
|
|
131
125
|
const sigma = processRadius(this.Skia, blur);
|
|
132
|
-
|
|
126
|
+
const imgf = this.Skia.ImageFilter.MakeBlur(
|
|
133
127
|
sigma.x,
|
|
134
128
|
sigma.y,
|
|
135
129
|
TileMode[enumKey(mode)],
|
|
136
|
-
this.
|
|
130
|
+
this.input(ctx)
|
|
137
131
|
);
|
|
132
|
+
this.composeAndPush(ctx, imgf);
|
|
138
133
|
}
|
|
139
134
|
}
|
|
140
135
|
|
|
@@ -143,10 +138,9 @@ export class DropShadowImageFilterNode extends ImageFilterDeclaration<DropShadow
|
|
|
143
138
|
super(ctx, NodeType.DropShadowImageFilter, props);
|
|
144
139
|
}
|
|
145
140
|
|
|
146
|
-
|
|
141
|
+
decorate(ctx: DeclarationContext) {
|
|
147
142
|
const { dx, dy, blur, shadowOnly, color: cl, inner } = this.props;
|
|
148
143
|
const color = this.Skia.Color(cl);
|
|
149
|
-
const input = this.getOptionalChildInstance(0);
|
|
150
144
|
let factory;
|
|
151
145
|
if (inner) {
|
|
152
146
|
factory = MakeInnerShadow.bind(null, this.Skia, shadowOnly);
|
|
@@ -155,7 +149,8 @@ export class DropShadowImageFilterNode extends ImageFilterDeclaration<DropShadow
|
|
|
155
149
|
? this.Skia.ImageFilter.MakeDropShadowOnly.bind(this.Skia.ImageFilter)
|
|
156
150
|
: this.Skia.ImageFilter.MakeDropShadow.bind(this.Skia.ImageFilter);
|
|
157
151
|
}
|
|
158
|
-
|
|
152
|
+
const imgf = factory(dx, dy, blur, blur, color, this.input(ctx));
|
|
153
|
+
this.composeAndPush(ctx, imgf);
|
|
159
154
|
}
|
|
160
155
|
}
|
|
161
156
|
|
|
@@ -169,14 +164,16 @@ export class MorphologyImageFilterNode extends ImageFilterDeclaration<Morphology
|
|
|
169
164
|
super(ctx, NodeType.MorphologyImageFilter, props);
|
|
170
165
|
}
|
|
171
166
|
|
|
172
|
-
|
|
167
|
+
decorate(ctx: DeclarationContext) {
|
|
173
168
|
const { operator } = this.props;
|
|
174
169
|
const r = processRadius(this.Skia, this.props.radius);
|
|
175
|
-
|
|
170
|
+
let imgf;
|
|
176
171
|
if (MorphologyOperator[enumKey(operator)] === MorphologyOperator.Erode) {
|
|
177
|
-
|
|
172
|
+
imgf = this.Skia.ImageFilter.MakeErode(r.x, r.y, this.input(ctx));
|
|
173
|
+
} else {
|
|
174
|
+
imgf = this.Skia.ImageFilter.MakeDilate(r.x, r.y, this.input(ctx));
|
|
178
175
|
}
|
|
179
|
-
|
|
176
|
+
this.composeAndPush(ctx, imgf);
|
|
180
177
|
}
|
|
181
178
|
}
|
|
182
179
|
|
|
@@ -185,11 +182,15 @@ export class BlendImageFilterNode extends ImageFilterDeclaration<BlendImageFilte
|
|
|
185
182
|
super(ctx, NodeType.BlendImageFilter, props);
|
|
186
183
|
}
|
|
187
184
|
|
|
188
|
-
|
|
185
|
+
decorate(ctx: DeclarationContext) {
|
|
189
186
|
const { mode } = this.props;
|
|
190
|
-
const a =
|
|
191
|
-
const b =
|
|
192
|
-
|
|
187
|
+
const a = ctx.imageFilters.pop();
|
|
188
|
+
const b = ctx.imageFilters.pop();
|
|
189
|
+
if (!a || !b) {
|
|
190
|
+
throw new Error("BlendImageFilter requires two image filters");
|
|
191
|
+
}
|
|
192
|
+
const imgf = this.Skia.ImageFilter.MakeBlend(mode, a, b);
|
|
193
|
+
this.composeAndPush(ctx, imgf);
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
196
|
|
|
@@ -198,13 +199,17 @@ export class RuntimeShaderImageFilterNode extends ImageFilterDeclaration<Runtime
|
|
|
198
199
|
super(ctx, NodeType.RuntimeShaderImageFilter, props);
|
|
199
200
|
}
|
|
200
201
|
|
|
201
|
-
|
|
202
|
+
decorate(ctx: DeclarationContext) {
|
|
202
203
|
const { source, uniforms } = this.props;
|
|
203
204
|
const rtb = this.Skia.RuntimeShaderBuilder(source);
|
|
204
205
|
if (uniforms) {
|
|
205
206
|
processUniforms(source, uniforms, rtb);
|
|
206
207
|
}
|
|
207
|
-
const
|
|
208
|
-
|
|
208
|
+
const imgf = this.Skia.ImageFilter.MakeRuntimeShader(
|
|
209
|
+
rtb,
|
|
210
|
+
null,
|
|
211
|
+
this.input(ctx)
|
|
212
|
+
);
|
|
213
|
+
this.composeAndPush(ctx, imgf);
|
|
209
214
|
}
|
|
210
215
|
}
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import type { SkMaskFilter } from "../../../skia/types";
|
|
2
1
|
import { BlurStyle } from "../../../skia/types";
|
|
3
2
|
import type { NodeContext } from "../Node";
|
|
4
3
|
import { JsiDeclarationNode } from "../Node";
|
|
5
4
|
import type { BlurMaskFilterProps } from "../../types";
|
|
6
5
|
import { DeclarationType, NodeType } from "../../types";
|
|
7
6
|
import { enumKey } from "../datatypes";
|
|
7
|
+
import type { DeclarationContext } from "../../types/DeclarationContext";
|
|
8
8
|
|
|
9
|
-
export class BlurMaskFilterNode extends JsiDeclarationNode<
|
|
10
|
-
BlurMaskFilterProps,
|
|
11
|
-
SkMaskFilter
|
|
12
|
-
> {
|
|
9
|
+
export class BlurMaskFilterNode extends JsiDeclarationNode<BlurMaskFilterProps> {
|
|
13
10
|
constructor(ctx: NodeContext, props: BlurMaskFilterProps) {
|
|
14
11
|
super(ctx, DeclarationType.MaskFilter, NodeType.BlurMaskFilter, props);
|
|
15
12
|
}
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
decorate(ctx: DeclarationContext) {
|
|
18
15
|
const { style, blur, respectCTM } = this.props;
|
|
19
|
-
|
|
16
|
+
const mf = this.Skia.MaskFilter.MakeBlur(
|
|
20
17
|
BlurStyle[enumKey(style)],
|
|
21
18
|
blur,
|
|
22
19
|
respectCTM
|
|
23
20
|
);
|
|
21
|
+
ctx.maskFilters.push(mf);
|
|
24
22
|
}
|
|
25
23
|
}
|
|
@@ -7,71 +7,27 @@ import type {
|
|
|
7
7
|
DashPathEffectProps,
|
|
8
8
|
DiscretePathEffectProps,
|
|
9
9
|
Line2DPathEffectProps,
|
|
10
|
-
Node,
|
|
11
10
|
Path1DPathEffectProps,
|
|
12
11
|
Path2DPathEffectProps,
|
|
13
12
|
} from "../../types";
|
|
14
13
|
import { DeclarationType, NodeType } from "../../types";
|
|
15
14
|
import { enumKey } from "../datatypes/Enum";
|
|
16
15
|
import { processPath } from "../datatypes";
|
|
16
|
+
import type { DeclarationContext } from "../../types/DeclarationContext";
|
|
17
|
+
import { composeDeclarations } from "../../types/DeclarationContext";
|
|
17
18
|
|
|
18
|
-
abstract class PathEffectDeclaration<
|
|
19
|
-
P,
|
|
20
|
-
Nullable extends null | never = never
|
|
21
|
-
> extends JsiDeclarationNode<P, SkPathEffect, Nullable> {
|
|
19
|
+
abstract class PathEffectDeclaration<P> extends JsiDeclarationNode<P> {
|
|
22
20
|
constructor(ctx: NodeContext, type: NodeType, props: P) {
|
|
23
21
|
super(ctx, DeclarationType.PathEffect, type, props);
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
insertChildBefore(child: Node<unknown>, before: Node<unknown>): void {
|
|
34
|
-
if (!(child instanceof PathEffectDeclaration)) {
|
|
35
|
-
throw new Error(`Cannot add child of type ${child.type} to ${this.type}`);
|
|
36
|
-
}
|
|
37
|
-
super.insertChildBefore(child, before);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
compose(pe: SkPathEffect) {
|
|
41
|
-
const children = this._children as PathEffectDeclaration<unknown>[];
|
|
42
|
-
if (this._children.length === 0) {
|
|
43
|
-
return pe;
|
|
44
|
-
} else {
|
|
45
|
-
return this.Skia.PathEffect.MakeCompose(
|
|
46
|
-
pe,
|
|
47
|
-
children.reduce<SkPathEffect | null>((acc, child) => {
|
|
48
|
-
if (acc === null) {
|
|
49
|
-
return child.materialize();
|
|
50
|
-
}
|
|
51
|
-
return this.Skia.PathEffect.MakeCompose(acc, child.materialize());
|
|
52
|
-
}, null) as SkPathEffect
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
getOptionalChildInstance(index: number) {
|
|
57
|
-
const child = this._children[index];
|
|
58
|
-
if (!child) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
return this.getMandatoryChildInstance(index);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
getMandatoryChildInstance(index: number) {
|
|
65
|
-
const child = this._children[index];
|
|
66
|
-
if (child instanceof JsiDeclarationNode) {
|
|
67
|
-
if (child.isPathEffect()) {
|
|
68
|
-
return child.materialize();
|
|
69
|
-
} else {
|
|
70
|
-
throw new Error(`Found invalid child ${child.type} in ${this.type}`);
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
throw new Error(`Found invalid child ${child.type} in ${this.type}`);
|
|
74
|
-
}
|
|
24
|
+
protected composeAndPush(ctx: DeclarationContext, pe1: SkPathEffect) {
|
|
25
|
+
ctx.save();
|
|
26
|
+
this.decorateChildren(ctx);
|
|
27
|
+
const pe2 = ctx.pathEffects.popAllAsOne();
|
|
28
|
+
ctx.restore();
|
|
29
|
+
const pe = pe2 ? this.Skia.PathEffect.MakeCompose(pe1, pe2) : pe1;
|
|
30
|
+
ctx.pathEffects.push(pe);
|
|
75
31
|
}
|
|
76
32
|
}
|
|
77
33
|
|
|
@@ -80,29 +36,26 @@ export class DiscretePathEffectNode extends PathEffectDeclaration<DiscretePathEf
|
|
|
80
36
|
super(ctx, NodeType.DiscretePathEffect, props);
|
|
81
37
|
}
|
|
82
38
|
|
|
83
|
-
|
|
39
|
+
decorate(ctx: DeclarationContext) {
|
|
84
40
|
const { length, deviation, seed } = this.props;
|
|
85
41
|
const pe = this.Skia.PathEffect.MakeDiscrete(length, deviation, seed);
|
|
86
|
-
|
|
42
|
+
this.composeAndPush(ctx, pe);
|
|
87
43
|
}
|
|
88
44
|
}
|
|
89
45
|
|
|
90
|
-
export class Path2DPathEffectNode extends PathEffectDeclaration<
|
|
91
|
-
Path2DPathEffectProps,
|
|
92
|
-
null
|
|
93
|
-
> {
|
|
46
|
+
export class Path2DPathEffectNode extends PathEffectDeclaration<Path2DPathEffectProps> {
|
|
94
47
|
constructor(ctx: NodeContext, props: Path2DPathEffectProps) {
|
|
95
48
|
super(ctx, NodeType.Path2DPathEffect, props);
|
|
96
49
|
}
|
|
97
50
|
|
|
98
|
-
|
|
51
|
+
decorate(ctx: DeclarationContext) {
|
|
99
52
|
const { matrix } = this.props;
|
|
100
53
|
const path = processPath(this.Skia, this.props.path);
|
|
101
54
|
const pe = this.Skia.PathEffect.MakePath2D(matrix, path);
|
|
102
55
|
if (pe === null) {
|
|
103
|
-
|
|
56
|
+
throw new Error("Path2DPathEffectNode: invalid path");
|
|
104
57
|
}
|
|
105
|
-
|
|
58
|
+
this.composeAndPush(ctx, pe);
|
|
106
59
|
}
|
|
107
60
|
}
|
|
108
61
|
|
|
@@ -111,28 +64,25 @@ export class DashPathEffectNode extends PathEffectDeclaration<DashPathEffectProp
|
|
|
111
64
|
super(ctx, NodeType.DashPathEffect, props);
|
|
112
65
|
}
|
|
113
66
|
|
|
114
|
-
|
|
67
|
+
decorate(ctx: DeclarationContext) {
|
|
115
68
|
const { intervals, phase } = this.props;
|
|
116
69
|
const pe = this.Skia.PathEffect.MakeDash(intervals, phase);
|
|
117
|
-
|
|
70
|
+
this.composeAndPush(ctx, pe);
|
|
118
71
|
}
|
|
119
72
|
}
|
|
120
73
|
|
|
121
|
-
export class CornerPathEffectNode extends PathEffectDeclaration<
|
|
122
|
-
CornerPathEffectProps,
|
|
123
|
-
null
|
|
124
|
-
> {
|
|
74
|
+
export class CornerPathEffectNode extends PathEffectDeclaration<CornerPathEffectProps> {
|
|
125
75
|
constructor(ctx: NodeContext, props: CornerPathEffectProps) {
|
|
126
76
|
super(ctx, NodeType.CornerPathEffect, props);
|
|
127
77
|
}
|
|
128
78
|
|
|
129
|
-
|
|
79
|
+
decorate(ctx: DeclarationContext) {
|
|
130
80
|
const { r } = this.props;
|
|
131
81
|
const pe = this.Skia.PathEffect.MakeCorner(r);
|
|
132
82
|
if (pe === null) {
|
|
133
|
-
|
|
83
|
+
throw new Error("CornerPathEffectNode: couldn't create path effect");
|
|
134
84
|
}
|
|
135
|
-
|
|
85
|
+
this.composeAndPush(ctx, pe);
|
|
136
86
|
}
|
|
137
87
|
}
|
|
138
88
|
|
|
@@ -141,41 +91,38 @@ export class SumPathEffectNode extends PathEffectDeclaration<null> {
|
|
|
141
91
|
super(ctx, NodeType.SumPathEffect, null);
|
|
142
92
|
}
|
|
143
93
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
94
|
+
decorate(ctx: DeclarationContext) {
|
|
95
|
+
this.decorateChildren(ctx);
|
|
96
|
+
const pes = ctx.pathEffects.popAll();
|
|
97
|
+
const pe = composeDeclarations(
|
|
98
|
+
pes,
|
|
99
|
+
this.Skia.PathEffect.MakeSum.bind(this.Skia.PathEffect)
|
|
148
100
|
);
|
|
101
|
+
ctx.pathEffects.push(pe);
|
|
149
102
|
}
|
|
150
103
|
}
|
|
151
104
|
|
|
152
|
-
export class Line2DPathEffectNode extends PathEffectDeclaration<
|
|
153
|
-
Line2DPathEffectProps,
|
|
154
|
-
null
|
|
155
|
-
> {
|
|
105
|
+
export class Line2DPathEffectNode extends PathEffectDeclaration<Line2DPathEffectProps> {
|
|
156
106
|
constructor(ctx: NodeContext, props: Line2DPathEffectProps) {
|
|
157
107
|
super(ctx, NodeType.Line2DPathEffect, props);
|
|
158
108
|
}
|
|
159
109
|
|
|
160
|
-
|
|
110
|
+
decorate(ctx: DeclarationContext) {
|
|
161
111
|
const { width, matrix } = this.props;
|
|
162
112
|
const pe = this.Skia.PathEffect.MakeLine2D(width, matrix);
|
|
163
113
|
if (pe === null) {
|
|
164
|
-
|
|
114
|
+
throw new Error("Line2DPathEffectNode: could not create path effect");
|
|
165
115
|
}
|
|
166
|
-
|
|
116
|
+
this.composeAndPush(ctx, pe);
|
|
167
117
|
}
|
|
168
118
|
}
|
|
169
119
|
|
|
170
|
-
export class Path1DPathEffectNode extends PathEffectDeclaration<
|
|
171
|
-
Path1DPathEffectProps,
|
|
172
|
-
null
|
|
173
|
-
> {
|
|
120
|
+
export class Path1DPathEffectNode extends PathEffectDeclaration<Path1DPathEffectProps> {
|
|
174
121
|
constructor(ctx: NodeContext, props: Path1DPathEffectProps) {
|
|
175
122
|
super(ctx, NodeType.Path1DPathEffect, props);
|
|
176
123
|
}
|
|
177
124
|
|
|
178
|
-
|
|
125
|
+
decorate(ctx: DeclarationContext) {
|
|
179
126
|
const { advance, phase, style } = this.props;
|
|
180
127
|
const path = processPath(this.Skia, this.props.path);
|
|
181
128
|
const pe = this.Skia.PathEffect.MakePath1D(
|
|
@@ -185,8 +132,8 @@ export class Path1DPathEffectNode extends PathEffectDeclaration<
|
|
|
185
132
|
Path1DEffectStyle[enumKey(style)]
|
|
186
133
|
);
|
|
187
134
|
if (pe === null) {
|
|
188
|
-
|
|
135
|
+
throw new Error("Path1DPathEffectNode: could not create path effect");
|
|
189
136
|
}
|
|
190
|
-
|
|
137
|
+
this.composeAndPush(ctx, pe);
|
|
191
138
|
}
|
|
192
139
|
}
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
MipmapMode,
|
|
5
5
|
TileMode,
|
|
6
6
|
} from "../../../skia/types";
|
|
7
|
-
import type { SkShader } from "../../../skia/types";
|
|
8
7
|
import type { NodeContext } from "../Node";
|
|
9
8
|
import { JsiDeclarationNode } from "../Node";
|
|
10
9
|
import type {
|
|
11
10
|
ColorProps,
|
|
11
|
+
DeclarationContext,
|
|
12
12
|
FractalNoiseProps,
|
|
13
13
|
ImageShaderProps,
|
|
14
14
|
LinearGradientProps,
|
|
@@ -28,10 +28,7 @@ import {
|
|
|
28
28
|
rect2rect,
|
|
29
29
|
} from "../datatypes";
|
|
30
30
|
|
|
31
|
-
export abstract class ShaderDeclaration<P> extends JsiDeclarationNode<
|
|
32
|
-
P,
|
|
33
|
-
SkShader
|
|
34
|
-
> {
|
|
31
|
+
export abstract class ShaderDeclaration<P> extends JsiDeclarationNode<P> {
|
|
35
32
|
constructor(ctx: NodeContext, type: NodeType, props: P) {
|
|
36
33
|
super(ctx, DeclarationType.Shader, type, props);
|
|
37
34
|
}
|
|
@@ -42,20 +39,17 @@ export class ShaderNode extends ShaderDeclaration<ShaderProps> {
|
|
|
42
39
|
super(ctx, NodeType.Shader, props);
|
|
43
40
|
}
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
decorate(ctx: DeclarationContext) {
|
|
43
|
+
this.decorateChildren(ctx);
|
|
46
44
|
const { source, uniforms, ...transform } = this.props;
|
|
47
45
|
const m3 = this.Skia.Matrix();
|
|
48
46
|
processTransformProps(m3, transform);
|
|
49
|
-
|
|
47
|
+
const shader = source.makeShaderWithChildren(
|
|
50
48
|
processUniforms(source, uniforms),
|
|
51
|
-
|
|
52
|
-
.filter(
|
|
53
|
-
(child): child is JsiDeclarationNode<unknown, SkShader> =>
|
|
54
|
-
child instanceof JsiDeclarationNode && child.isShader()
|
|
55
|
-
)
|
|
56
|
-
.map((child) => child.materialize()),
|
|
49
|
+
ctx.shaders.popAll(),
|
|
57
50
|
m3
|
|
58
51
|
);
|
|
52
|
+
ctx.shaders.push(shader);
|
|
59
53
|
}
|
|
60
54
|
}
|
|
61
55
|
|
|
@@ -64,7 +58,7 @@ export class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {
|
|
|
64
58
|
super(ctx, NodeType.ImageShader, props);
|
|
65
59
|
}
|
|
66
60
|
|
|
67
|
-
|
|
61
|
+
decorate(ctx: DeclarationContext) {
|
|
68
62
|
const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = this.props;
|
|
69
63
|
const rct = getRect(this.Skia, imageShaderProps);
|
|
70
64
|
const m3 = this.Skia.Matrix();
|
|
@@ -81,13 +75,14 @@ export class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {
|
|
|
81
75
|
const lm = this.Skia.Matrix();
|
|
82
76
|
lm.concat(m3);
|
|
83
77
|
processTransformProps(lm, imageShaderProps);
|
|
84
|
-
|
|
78
|
+
const shader = image.makeShaderOptions(
|
|
85
79
|
TileMode[enumKey(tx)],
|
|
86
80
|
TileMode[enumKey(ty)],
|
|
87
81
|
FilterMode[enumKey(fm)],
|
|
88
82
|
MipmapMode[enumKey(mm)],
|
|
89
83
|
lm
|
|
90
84
|
);
|
|
85
|
+
ctx.shaders.push(shader);
|
|
91
86
|
}
|
|
92
87
|
}
|
|
93
88
|
|
|
@@ -96,9 +91,10 @@ export class ColorNode extends ShaderDeclaration<ColorProps> {
|
|
|
96
91
|
super(ctx, NodeType.ColorShader, props);
|
|
97
92
|
}
|
|
98
93
|
|
|
99
|
-
|
|
94
|
+
decorate(ctx: DeclarationContext) {
|
|
100
95
|
const { color } = this.props;
|
|
101
|
-
|
|
96
|
+
const shader = this.Skia.Shader.MakeColor(this.Skia.Color(color));
|
|
97
|
+
ctx.shaders.push(shader);
|
|
102
98
|
}
|
|
103
99
|
}
|
|
104
100
|
|
|
@@ -107,9 +103,9 @@ export class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {
|
|
|
107
103
|
super(ctx, NodeType.Turbulence, props);
|
|
108
104
|
}
|
|
109
105
|
|
|
110
|
-
|
|
106
|
+
decorate(ctx: DeclarationContext) {
|
|
111
107
|
const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;
|
|
112
|
-
|
|
108
|
+
const shader = this.Skia.Shader.MakeTurbulence(
|
|
113
109
|
freqX,
|
|
114
110
|
freqY,
|
|
115
111
|
octaves,
|
|
@@ -117,6 +113,7 @@ export class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {
|
|
|
117
113
|
tileWidth,
|
|
118
114
|
tileHeight
|
|
119
115
|
);
|
|
116
|
+
ctx.shaders.push(shader);
|
|
120
117
|
}
|
|
121
118
|
}
|
|
122
119
|
|
|
@@ -125,9 +122,9 @@ export class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {
|
|
|
125
122
|
super(ctx, NodeType.FractalNoise, props);
|
|
126
123
|
}
|
|
127
124
|
|
|
128
|
-
|
|
125
|
+
decorate(ctx: DeclarationContext) {
|
|
129
126
|
const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;
|
|
130
|
-
|
|
127
|
+
const shader = this.Skia.Shader.MakeFractalNoise(
|
|
131
128
|
freqX,
|
|
132
129
|
freqY,
|
|
133
130
|
octaves,
|
|
@@ -135,6 +132,7 @@ export class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {
|
|
|
135
132
|
tileWidth,
|
|
136
133
|
tileHeight
|
|
137
134
|
);
|
|
135
|
+
ctx.shaders.push(shader);
|
|
138
136
|
}
|
|
139
137
|
}
|
|
140
138
|
|
|
@@ -143,11 +141,11 @@ export class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {
|
|
|
143
141
|
super(ctx, NodeType.LinearGradient, props);
|
|
144
142
|
}
|
|
145
143
|
|
|
146
|
-
|
|
144
|
+
decorate(ctx: DeclarationContext) {
|
|
147
145
|
const { start, end } = this.props;
|
|
148
146
|
const { colors, positions, mode, localMatrix, flags } =
|
|
149
147
|
processGradientProps(this.Skia, this.props);
|
|
150
|
-
|
|
148
|
+
const shader = this.Skia.Shader.MakeLinearGradient(
|
|
151
149
|
start,
|
|
152
150
|
end,
|
|
153
151
|
colors,
|
|
@@ -156,6 +154,7 @@ export class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {
|
|
|
156
154
|
localMatrix,
|
|
157
155
|
flags
|
|
158
156
|
);
|
|
157
|
+
ctx.shaders.push(shader);
|
|
159
158
|
}
|
|
160
159
|
}
|
|
161
160
|
|
|
@@ -164,11 +163,11 @@ export class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {
|
|
|
164
163
|
super(ctx, NodeType.RadialGradient, props);
|
|
165
164
|
}
|
|
166
165
|
|
|
167
|
-
|
|
166
|
+
decorate(ctx: DeclarationContext) {
|
|
168
167
|
const { c, r } = this.props;
|
|
169
168
|
const { colors, positions, mode, localMatrix, flags } =
|
|
170
169
|
processGradientProps(this.Skia, this.props);
|
|
171
|
-
|
|
170
|
+
const shader = this.Skia.Shader.MakeRadialGradient(
|
|
172
171
|
c,
|
|
173
172
|
r,
|
|
174
173
|
colors,
|
|
@@ -177,6 +176,7 @@ export class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {
|
|
|
177
176
|
localMatrix,
|
|
178
177
|
flags
|
|
179
178
|
);
|
|
179
|
+
ctx.shaders.push(shader);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
|
|
@@ -185,11 +185,11 @@ export class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {
|
|
|
185
185
|
super(ctx, NodeType.SweepGradient, props);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
decorate(ctx: DeclarationContext) {
|
|
189
189
|
const { c, start, end } = this.props;
|
|
190
190
|
const { colors, positions, mode, localMatrix, flags } =
|
|
191
191
|
processGradientProps(this.Skia, this.props);
|
|
192
|
-
|
|
192
|
+
const shader = this.Skia.Shader.MakeSweepGradient(
|
|
193
193
|
c.x,
|
|
194
194
|
c.y,
|
|
195
195
|
colors,
|
|
@@ -200,6 +200,7 @@ export class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {
|
|
|
200
200
|
start,
|
|
201
201
|
end
|
|
202
202
|
);
|
|
203
|
+
ctx.shaders.push(shader);
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
206
|
|
|
@@ -208,11 +209,11 @@ export class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConic
|
|
|
208
209
|
super(ctx, NodeType.TwoPointConicalGradient, props);
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
|
|
212
|
+
decorate(ctx: DeclarationContext) {
|
|
212
213
|
const { startR, endR, start, end } = this.props;
|
|
213
214
|
const { colors, positions, mode, localMatrix, flags } =
|
|
214
215
|
processGradientProps(this.Skia, this.props);
|
|
215
|
-
|
|
216
|
+
const shader = this.Skia.Shader.MakeTwoPointConicalGradient(
|
|
216
217
|
start,
|
|
217
218
|
startR,
|
|
218
219
|
end,
|
|
@@ -223,5 +224,6 @@ export class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConic
|
|
|
223
224
|
localMatrix,
|
|
224
225
|
flags
|
|
225
226
|
);
|
|
227
|
+
ctx.shaders.push(shader);
|
|
226
228
|
}
|
|
227
229
|
}
|