@shopify/react-native-skia 1.8.0 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkPaint.h +8 -1
- package/lib/commonjs/dom/types/Common.d.ts +6 -4
- package/lib/commonjs/dom/types/Common.js.map +1 -1
- package/lib/commonjs/dom/types/ImageFilters.d.ts +1 -1
- package/lib/commonjs/dom/types/ImageFilters.js.map +1 -1
- package/lib/commonjs/dom/types/Node.d.ts +0 -2
- package/lib/commonjs/dom/types/Node.js.map +1 -1
- package/lib/commonjs/external/reanimated/index.d.ts +0 -1
- package/lib/commonjs/external/reanimated/index.js +0 -11
- package/lib/commonjs/external/reanimated/index.js.map +1 -1
- package/lib/commonjs/external/reanimated/renderHelpers.d.ts +0 -1
- package/lib/commonjs/external/reanimated/renderHelpers.js +5 -43
- package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +1 -8
- package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -1
- package/lib/commonjs/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/commonjs/skia/core/AnimatedImage.js +1 -1
- package/lib/commonjs/skia/core/AnimatedImage.js.map +1 -1
- package/lib/commonjs/skia/core/Data.d.ts +1 -1
- package/lib/commonjs/skia/core/Data.js +2 -8
- package/lib/commonjs/skia/core/Data.js.map +1 -1
- package/lib/commonjs/skia/types/Paint/Paint.d.ts +1 -0
- package/lib/commonjs/skia/types/Paint/Paint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkPaint.js +3 -0
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/sksg/Container.d.ts +3 -2
- package/lib/commonjs/sksg/Container.js +32 -26
- package/lib/commonjs/sksg/Container.js.map +1 -1
- package/lib/commonjs/sksg/HostConfig.d.ts +2 -2
- package/lib/commonjs/sksg/HostConfig.js +7 -25
- package/lib/commonjs/sksg/HostConfig.js.map +1 -1
- package/lib/commonjs/sksg/Node.d.ts +19 -0
- package/lib/commonjs/sksg/Node.js +78 -0
- package/lib/commonjs/sksg/Node.js.map +1 -0
- package/lib/commonjs/sksg/Reconciler.d.ts +1 -1
- package/lib/commonjs/sksg/Recorder/Core.d.ts +79 -0
- package/lib/commonjs/sksg/Recorder/Core.js +110 -0
- package/lib/commonjs/sksg/Recorder/Core.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +18 -0
- package/lib/commonjs/sksg/Recorder/DrawingContext.js +105 -0
- package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/Player.d.ts +3 -0
- package/lib/commonjs/sksg/Recorder/Player.js +127 -0
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/Recorder.d.ts +50 -0
- package/lib/commonjs/sksg/Recorder/Recorder.js +288 -0
- package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/Recording.d.ts +7 -0
- package/lib/commonjs/sksg/Recorder/Recording.js +12 -0
- package/lib/commonjs/sksg/Recorder/Recording.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/Visitor.d.ts +5 -0
- package/lib/commonjs/sksg/Recorder/Visitor.js +293 -0
- package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/Box.d.ts +13 -0
- package/lib/commonjs/sksg/Recorder/commands/Box.js +71 -0
- package/lib/commonjs/sksg/Recorder/commands/Box.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/CTM.d.ts +3 -0
- package/lib/commonjs/sksg/Recorder/commands/CTM.js +79 -0
- package/lib/commonjs/sksg/Recorder/commands/CTM.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/ColorFilters.d.ts +6 -0
- package/lib/commonjs/sksg/Recorder/commands/ColorFilters.js +76 -0
- package/lib/commonjs/sksg/Recorder/commands/ColorFilters.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +24 -0
- package/lib/commonjs/sksg/{nodes/drawings.js → Recorder/commands/Drawing.js} +5 -5
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.d.ts +12 -0
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +183 -0
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +4 -0
- package/lib/commonjs/sksg/Recorder/commands/Paint.js +70 -0
- package/lib/commonjs/sksg/Recorder/commands/Paint.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/PathEffects.d.ts +6 -0
- package/lib/commonjs/sksg/Recorder/commands/PathEffects.js +137 -0
- package/lib/commonjs/sksg/Recorder/commands/PathEffects.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/commands/Shaders.d.ts +5 -0
- package/lib/commonjs/sksg/{nodes/shaders.js → Recorder/commands/Shaders.js} +58 -15
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -0
- package/lib/commonjs/sksg/{nodes/utils.d.ts → utils.d.ts} +3 -0
- package/lib/commonjs/sksg/{nodes/utils.js → utils.js} +12 -2
- package/lib/commonjs/sksg/utils.js.map +1 -0
- package/lib/module/dom/types/Common.d.ts +6 -4
- package/lib/module/dom/types/Common.js.map +1 -1
- package/lib/module/dom/types/ImageFilters.d.ts +1 -1
- package/lib/module/dom/types/ImageFilters.js.map +1 -1
- package/lib/module/dom/types/Node.d.ts +0 -2
- package/lib/module/dom/types/Node.js.map +1 -1
- package/lib/module/external/reanimated/index.d.ts +0 -1
- package/lib/module/external/reanimated/index.js +0 -1
- package/lib/module/external/reanimated/index.js.map +1 -1
- package/lib/module/external/reanimated/renderHelpers.d.ts +0 -1
- package/lib/module/external/reanimated/renderHelpers.js +4 -42
- package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/module/external/reanimated/useAnimatedImageValue.js +1 -8
- package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -1
- package/lib/module/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/module/skia/core/AnimatedImage.js +1 -1
- package/lib/module/skia/core/AnimatedImage.js.map +1 -1
- package/lib/module/skia/core/Data.d.ts +1 -1
- package/lib/module/skia/core/Data.js +2 -8
- package/lib/module/skia/core/Data.js.map +1 -1
- package/lib/module/skia/types/Paint/Paint.d.ts +1 -0
- package/lib/module/skia/types/Paint/Paint.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/module/skia/web/JsiSkPaint.js +3 -0
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/sksg/Container.d.ts +3 -2
- package/lib/module/sksg/Container.js +30 -24
- package/lib/module/sksg/Container.js.map +1 -1
- package/lib/module/sksg/HostConfig.d.ts +2 -2
- package/lib/module/sksg/HostConfig.js +7 -25
- package/lib/module/sksg/HostConfig.js.map +1 -1
- package/lib/module/sksg/Node.d.ts +19 -0
- package/lib/module/sksg/Node.js +67 -0
- package/lib/module/sksg/Node.js.map +1 -0
- package/lib/module/sksg/Reconciler.d.ts +1 -1
- package/lib/module/sksg/Recorder/Core.d.ts +79 -0
- package/lib/module/sksg/Recorder/Core.js +101 -0
- package/lib/module/sksg/Recorder/Core.js.map +1 -0
- package/lib/module/sksg/Recorder/DrawingContext.d.ts +18 -0
- package/lib/module/sksg/Recorder/DrawingContext.js +98 -0
- package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -0
- package/lib/module/sksg/Recorder/Player.d.ts +3 -0
- package/lib/module/sksg/Recorder/Player.js +120 -0
- package/lib/module/sksg/Recorder/Player.js.map +1 -0
- package/lib/module/sksg/Recorder/Recorder.d.ts +50 -0
- package/lib/module/sksg/Recorder/Recorder.js +281 -0
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -0
- package/lib/module/sksg/Recorder/Recording.d.ts +7 -0
- package/lib/module/sksg/Recorder/Recording.js +5 -0
- package/lib/module/sksg/Recorder/Recording.js.map +1 -0
- package/lib/module/sksg/Recorder/Visitor.d.ts +5 -0
- package/lib/module/sksg/Recorder/Visitor.js +285 -0
- package/lib/module/sksg/Recorder/Visitor.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/Box.d.ts +13 -0
- package/lib/module/sksg/Recorder/commands/Box.js +63 -0
- package/lib/module/sksg/Recorder/commands/Box.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/CTM.d.ts +3 -0
- package/lib/module/sksg/Recorder/commands/CTM.js +72 -0
- package/lib/module/sksg/Recorder/commands/CTM.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/ColorFilters.d.ts +6 -0
- package/lib/module/sksg/Recorder/commands/ColorFilters.js +67 -0
- package/lib/module/sksg/Recorder/commands/ColorFilters.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/Drawing.d.ts +24 -0
- package/lib/module/sksg/{nodes/drawings.js → Recorder/commands/Drawing.js} +5 -5
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/ImageFilters.d.ts +12 -0
- package/lib/module/sksg/{nodes/imageFilters.js → Recorder/commands/ImageFilters.js} +87 -95
- package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/Paint.d.ts +4 -0
- package/lib/module/sksg/Recorder/commands/Paint.js +62 -0
- package/lib/module/sksg/Recorder/commands/Paint.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/PathEffects.d.ts +6 -0
- package/lib/module/sksg/Recorder/commands/PathEffects.js +128 -0
- package/lib/module/sksg/Recorder/commands/PathEffects.js.map +1 -0
- package/lib/module/sksg/Recorder/commands/Shaders.d.ts +5 -0
- package/lib/module/sksg/{nodes/shaders.js → Recorder/commands/Shaders.js} +63 -13
- package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -0
- package/lib/module/sksg/{nodes/utils.d.ts → utils.d.ts} +3 -0
- package/lib/module/sksg/{nodes/utils.js → utils.js} +10 -1
- package/lib/module/sksg/utils.js.map +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +0 -1
- package/lib/typescript/lib/commonjs/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/core/Data.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Container.d.ts +4 -0
- package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +1 -3
- package/lib/typescript/lib/commonjs/sksg/Node.d.ts +14 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Core.d.ts +5 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +17 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Player.d.ts +2 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +45 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recording.d.ts +5 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Visitor.d.ts +27 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Box.d.ts +3 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/CTM.d.ts +2 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/ColorFilters.d.ts +4 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/ImageFilters.d.ts +6 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +14 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/PathEffects.d.ts +4 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Shaders.d.ts +3 -0
- package/lib/typescript/lib/commonjs/sksg/{nodes/utils.d.ts → utils.d.ts} +1 -0
- package/lib/typescript/lib/module/external/reanimated/index.d.ts +0 -1
- package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +0 -1
- package/lib/typescript/lib/module/mock/index.d.ts +1 -1
- package/lib/typescript/lib/module/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/typescript/lib/module/skia/core/Data.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Container.d.ts +4 -0
- package/lib/typescript/lib/module/sksg/HostConfig.d.ts +1 -3
- package/lib/typescript/lib/module/sksg/Node.d.ts +13 -0
- package/lib/typescript/lib/module/sksg/Recorder/Core.d.ts +4 -0
- package/lib/typescript/lib/module/sksg/Recorder/DrawingContext.d.ts +16 -0
- package/lib/typescript/lib/module/sksg/Recorder/Player.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +44 -0
- package/lib/typescript/lib/module/sksg/Recorder/Recording.d.ts +4 -0
- package/lib/typescript/lib/module/sksg/Recorder/Visitor.d.ts +26 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/Box.d.ts +2 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/CTM.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/ColorFilters.d.ts +3 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/ImageFilters.d.ts +5 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/Paint.d.ts +13 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/PathEffects.d.ts +3 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/Shaders.d.ts +2 -0
- package/lib/typescript/lib/module/sksg/{nodes/utils.d.ts → utils.d.ts} +1 -0
- package/lib/typescript/src/dom/types/Common.d.ts +6 -4
- package/lib/typescript/src/dom/types/ImageFilters.d.ts +1 -1
- package/lib/typescript/src/dom/types/Node.d.ts +0 -2
- package/lib/typescript/src/external/reanimated/index.d.ts +0 -1
- package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +0 -1
- package/lib/typescript/src/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/typescript/src/skia/core/Data.d.ts +1 -1
- package/lib/typescript/src/skia/types/Paint/Paint.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/typescript/src/sksg/Container.d.ts +3 -2
- package/lib/typescript/src/sksg/HostConfig.d.ts +2 -2
- package/lib/typescript/src/sksg/Node.d.ts +19 -0
- package/lib/typescript/src/sksg/Reconciler.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/Core.d.ts +79 -0
- package/lib/typescript/src/sksg/Recorder/DrawingContext.d.ts +18 -0
- package/lib/typescript/src/sksg/Recorder/Player.d.ts +3 -0
- package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +50 -0
- package/lib/typescript/src/sksg/Recorder/Recording.d.ts +7 -0
- package/lib/typescript/src/sksg/Recorder/Visitor.d.ts +5 -0
- package/lib/typescript/src/sksg/Recorder/commands/Box.d.ts +13 -0
- package/lib/typescript/src/sksg/Recorder/commands/CTM.d.ts +3 -0
- package/lib/typescript/src/sksg/Recorder/commands/ColorFilters.d.ts +6 -0
- package/lib/typescript/src/sksg/Recorder/commands/Drawing.d.ts +24 -0
- package/lib/typescript/src/sksg/Recorder/commands/ImageFilters.d.ts +12 -0
- package/lib/typescript/src/sksg/Recorder/commands/Paint.d.ts +4 -0
- package/lib/typescript/src/sksg/Recorder/commands/PathEffects.d.ts +6 -0
- package/lib/typescript/src/sksg/Recorder/commands/Shaders.d.ts +5 -0
- package/lib/typescript/src/sksg/{nodes/utils.d.ts → utils.d.ts} +3 -0
- package/package.json +1 -1
- package/src/__tests__/snapshots/image-filter/test-shadow.png +0 -0
- package/src/dom/types/Common.ts +7 -5
- package/src/dom/types/ImageFilters.ts +2 -1
- package/src/dom/types/Node.ts +0 -4
- package/src/external/reanimated/index.ts +0 -1
- package/src/external/reanimated/renderHelpers.ts +4 -44
- package/src/external/reanimated/useAnimatedImageValue.ts +4 -15
- package/src/renderer/__tests__/e2e/ColorFilters.spec.tsx +15 -0
- package/src/renderer/__tests__/e2e/Composition/ColorFilterComposition.spec.tsx +23 -2
- package/src/renderer/__tests__/e2e/ImageFilters.spec.tsx +91 -2
- package/src/renderer/__tests__/setup.tsx +1 -1
- package/src/skia/core/AnimatedImage.ts +2 -3
- package/src/skia/core/Data.ts +3 -9
- package/src/skia/types/Paint/Paint.ts +2 -0
- package/src/skia/web/JsiSkPaint.ts +4 -0
- package/src/sksg/Container.ts +35 -29
- package/src/sksg/HostConfig.ts +5 -50
- package/src/sksg/Node.ts +105 -0
- package/src/sksg/Recorder/Core.ts +171 -0
- package/src/sksg/Recorder/DrawingContext.ts +130 -0
- package/src/sksg/Recorder/Player.ts +160 -0
- package/src/sksg/Recorder/Recorder.ts +259 -0
- package/src/sksg/Recorder/Recording.ts +13 -0
- package/src/sksg/Recorder/Visitor.ts +324 -0
- package/src/sksg/Recorder/commands/Box.ts +63 -0
- package/src/sksg/Recorder/commands/CTM.ts +72 -0
- package/src/sksg/Recorder/commands/ColorFilters.ts +87 -0
- package/src/sksg/{nodes/drawings.ts → Recorder/commands/Drawing.ts} +29 -65
- package/src/sksg/Recorder/commands/ImageFilters.ts +255 -0
- package/src/sksg/Recorder/commands/Paint.ts +77 -0
- package/src/sksg/Recorder/commands/PathEffects.ts +169 -0
- package/src/sksg/{nodes/shaders.ts → Recorder/commands/Shaders.ts} +100 -26
- package/src/sksg/{nodes/utils.ts → utils.ts} +14 -1
- package/lib/commonjs/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
- package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js +0 -24
- package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js.map +0 -1
- package/lib/commonjs/sksg/DeclarationContext.d.ts +0 -56
- package/lib/commonjs/sksg/DeclarationContext.js +0 -77
- package/lib/commonjs/sksg/DeclarationContext.js.map +0 -1
- package/lib/commonjs/sksg/DrawingContext.d.ts +0 -13
- package/lib/commonjs/sksg/DrawingContext.js +0 -172
- package/lib/commonjs/sksg/DrawingContext.js.map +0 -1
- package/lib/commonjs/sksg/__tests__/Declarations.spec.d.ts +0 -1
- package/lib/commonjs/sksg/__tests__/MockDeclaration.d.ts +0 -57
- package/lib/commonjs/sksg/nodes/Node.d.ts +0 -7
- package/lib/commonjs/sksg/nodes/Node.js +0 -6
- package/lib/commonjs/sksg/nodes/Node.js.map +0 -1
- package/lib/commonjs/sksg/nodes/colorFilters.d.ts +0 -10
- package/lib/commonjs/sksg/nodes/colorFilters.js +0 -79
- package/lib/commonjs/sksg/nodes/colorFilters.js.map +0 -1
- package/lib/commonjs/sksg/nodes/context.d.ts +0 -3
- package/lib/commonjs/sksg/nodes/context.js +0 -394
- package/lib/commonjs/sksg/nodes/context.js.map +0 -1
- package/lib/commonjs/sksg/nodes/drawings.d.ts +0 -30
- package/lib/commonjs/sksg/nodes/drawings.js.map +0 -1
- package/lib/commonjs/sksg/nodes/imageFilters.d.ts +0 -17
- package/lib/commonjs/sksg/nodes/imageFilters.js +0 -197
- package/lib/commonjs/sksg/nodes/imageFilters.js.map +0 -1
- package/lib/commonjs/sksg/nodes/index.d.ts +0 -3
- package/lib/commonjs/sksg/nodes/index.js +0 -39
- package/lib/commonjs/sksg/nodes/index.js.map +0 -1
- package/lib/commonjs/sksg/nodes/paint.d.ts +0 -3
- package/lib/commonjs/sksg/nodes/paint.js +0 -81
- package/lib/commonjs/sksg/nodes/paint.js.map +0 -1
- package/lib/commonjs/sksg/nodes/pathEffects.d.ts +0 -11
- package/lib/commonjs/sksg/nodes/pathEffects.js +0 -111
- package/lib/commonjs/sksg/nodes/pathEffects.js.map +0 -1
- package/lib/commonjs/sksg/nodes/shaders.d.ts +0 -11
- package/lib/commonjs/sksg/nodes/shaders.js.map +0 -1
- package/lib/commonjs/sksg/nodes/utils.js.map +0 -1
- package/lib/module/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
- package/lib/module/external/reanimated/useDerivedValueOnJS.js +0 -16
- package/lib/module/external/reanimated/useDerivedValueOnJS.js.map +0 -1
- package/lib/module/sksg/DeclarationContext.d.ts +0 -56
- package/lib/module/sksg/DeclarationContext.js +0 -69
- package/lib/module/sksg/DeclarationContext.js.map +0 -1
- package/lib/module/sksg/DrawingContext.d.ts +0 -13
- package/lib/module/sksg/DrawingContext.js +0 -165
- package/lib/module/sksg/DrawingContext.js.map +0 -1
- package/lib/module/sksg/__tests__/Declarations.spec.d.ts +0 -1
- package/lib/module/sksg/__tests__/MockDeclaration.d.ts +0 -57
- package/lib/module/sksg/nodes/Node.d.ts +0 -7
- package/lib/module/sksg/nodes/Node.js +0 -2
- package/lib/module/sksg/nodes/Node.js.map +0 -1
- package/lib/module/sksg/nodes/colorFilters.d.ts +0 -10
- package/lib/module/sksg/nodes/colorFilters.js +0 -66
- package/lib/module/sksg/nodes/colorFilters.js.map +0 -1
- package/lib/module/sksg/nodes/context.d.ts +0 -3
- package/lib/module/sksg/nodes/context.js +0 -387
- package/lib/module/sksg/nodes/context.js.map +0 -1
- package/lib/module/sksg/nodes/drawings.d.ts +0 -30
- package/lib/module/sksg/nodes/drawings.js.map +0 -1
- package/lib/module/sksg/nodes/imageFilters.d.ts +0 -17
- package/lib/module/sksg/nodes/imageFilters.js.map +0 -1
- package/lib/module/sksg/nodes/index.d.ts +0 -3
- package/lib/module/sksg/nodes/index.js +0 -4
- package/lib/module/sksg/nodes/index.js.map +0 -1
- package/lib/module/sksg/nodes/paint.d.ts +0 -3
- package/lib/module/sksg/nodes/paint.js +0 -74
- package/lib/module/sksg/nodes/paint.js.map +0 -1
- package/lib/module/sksg/nodes/pathEffects.d.ts +0 -11
- package/lib/module/sksg/nodes/pathEffects.js +0 -97
- package/lib/module/sksg/nodes/pathEffects.js.map +0 -1
- package/lib/module/sksg/nodes/shaders.d.ts +0 -11
- package/lib/module/sksg/nodes/shaders.js.map +0 -1
- package/lib/module/sksg/nodes/utils.js.map +0 -1
- package/lib/typescript/lib/commonjs/external/reanimated/useDerivedValueOnJS.d.ts +0 -2
- package/lib/typescript/lib/commonjs/sksg/DeclarationContext.d.ts +0 -53
- package/lib/typescript/lib/commonjs/sksg/DrawingContext.d.ts +0 -22
- package/lib/typescript/lib/commonjs/sksg/nodes/Node.d.ts +0 -1
- package/lib/typescript/lib/commonjs/sksg/nodes/colorFilters.d.ts +0 -8
- package/lib/typescript/lib/commonjs/sksg/nodes/context.d.ts +0 -2
- package/lib/typescript/lib/commonjs/sksg/nodes/imageFilters.d.ts +0 -12
- package/lib/typescript/lib/commonjs/sksg/nodes/index.d.ts +0 -1
- package/lib/typescript/lib/commonjs/sksg/nodes/paint.d.ts +0 -2
- package/lib/typescript/lib/commonjs/sksg/nodes/pathEffects.d.ts +0 -9
- package/lib/typescript/lib/commonjs/sksg/nodes/shaders.d.ts +0 -10
- package/lib/typescript/lib/module/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
- package/lib/typescript/lib/module/sksg/DeclarationContext.d.ts +0 -52
- package/lib/typescript/lib/module/sksg/DrawingContext.d.ts +0 -21
- package/lib/typescript/lib/module/sksg/nodes/Node.d.ts +0 -1
- package/lib/typescript/lib/module/sksg/nodes/colorFilters.d.ts +0 -7
- package/lib/typescript/lib/module/sksg/nodes/context.d.ts +0 -1
- package/lib/typescript/lib/module/sksg/nodes/imageFilters.d.ts +0 -11
- package/lib/typescript/lib/module/sksg/nodes/index.d.ts +0 -3
- package/lib/typescript/lib/module/sksg/nodes/paint.d.ts +0 -1
- package/lib/typescript/lib/module/sksg/nodes/pathEffects.d.ts +0 -8
- package/lib/typescript/lib/module/sksg/nodes/shaders.d.ts +0 -9
- package/lib/typescript/src/external/reanimated/useDerivedValueOnJS.d.ts +0 -1
- package/lib/typescript/src/sksg/DeclarationContext.d.ts +0 -56
- package/lib/typescript/src/sksg/DrawingContext.d.ts +0 -13
- package/lib/typescript/src/sksg/__tests__/Declarations.spec.d.ts +0 -1
- package/lib/typescript/src/sksg/__tests__/MockDeclaration.d.ts +0 -57
- package/lib/typescript/src/sksg/nodes/Node.d.ts +0 -7
- package/lib/typescript/src/sksg/nodes/colorFilters.d.ts +0 -10
- package/lib/typescript/src/sksg/nodes/context.d.ts +0 -3
- package/lib/typescript/src/sksg/nodes/drawings.d.ts +0 -30
- package/lib/typescript/src/sksg/nodes/imageFilters.d.ts +0 -17
- package/lib/typescript/src/sksg/nodes/index.d.ts +0 -3
- package/lib/typescript/src/sksg/nodes/paint.d.ts +0 -3
- package/lib/typescript/src/sksg/nodes/pathEffects.d.ts +0 -11
- package/lib/typescript/src/sksg/nodes/shaders.d.ts +0 -11
- package/src/external/reanimated/useDerivedValueOnJS.ts +0 -20
- package/src/sksg/DeclarationContext.ts +0 -85
- package/src/sksg/DrawingContext.ts +0 -226
- package/src/sksg/__tests__/Declarations.spec.tsx +0 -235
- package/src/sksg/__tests__/MockDeclaration.ts +0 -138
- package/src/sksg/nodes/Node.ts +0 -8
- package/src/sksg/nodes/colorFilters.ts +0 -79
- package/src/sksg/nodes/context.ts +0 -412
- package/src/sksg/nodes/imageFilters.ts +0 -235
- package/src/sksg/nodes/index.ts +0 -3
- package/src/sksg/nodes/paint.ts +0 -75
- package/src/sksg/nodes/pathEffects.ts +0 -118
- /package/lib/typescript/lib/commonjs/sksg/{nodes/drawings.d.ts → Recorder/commands/Drawing.d.ts} +0 -0
- /package/lib/typescript/lib/module/sksg/{nodes/drawings.d.ts → Recorder/commands/Drawing.d.ts} +0 -0
@@ -1,57 +0,0 @@
|
|
1
|
-
export declare enum DeclarationType {
|
2
|
-
ColorFilter = 0,
|
3
|
-
ImageFilter = 1,
|
4
|
-
Shader = 2,
|
5
|
-
MaskFilter = 3,
|
6
|
-
PathEffect = 4,
|
7
|
-
Paint = 5
|
8
|
-
}
|
9
|
-
interface Filter {
|
10
|
-
tag: string;
|
11
|
-
}
|
12
|
-
export interface SkColorFilter extends Filter {
|
13
|
-
type: DeclarationType.ColorFilter;
|
14
|
-
}
|
15
|
-
interface SkImageFilter extends Filter {
|
16
|
-
type: DeclarationType.ImageFilter;
|
17
|
-
}
|
18
|
-
interface SkShader extends Filter {
|
19
|
-
type: DeclarationType.Shader;
|
20
|
-
}
|
21
|
-
interface SkMaskFilter extends Filter {
|
22
|
-
type: DeclarationType.MaskFilter;
|
23
|
-
}
|
24
|
-
interface SkPathEffect extends Filter {
|
25
|
-
type: DeclarationType.PathEffect;
|
26
|
-
}
|
27
|
-
interface SkPaint extends Filter {
|
28
|
-
type: DeclarationType.Paint;
|
29
|
-
}
|
30
|
-
type Composer<T> = (outer: T, inner: T) => T;
|
31
|
-
export declare const compose: any;
|
32
|
-
export declare const composeDeclarations: <T>(filters: T[], composer: Composer<T>) => T;
|
33
|
-
declare class Declaration<T extends Filter> {
|
34
|
-
decls: T[];
|
35
|
-
indexes: number[];
|
36
|
-
composer?: Composer<T>;
|
37
|
-
constructor(composer?: Composer<T>);
|
38
|
-
private get index();
|
39
|
-
save(): void;
|
40
|
-
restore(): void;
|
41
|
-
pop(): T | undefined;
|
42
|
-
push(decl: T): void;
|
43
|
-
popAll(): T[];
|
44
|
-
popAllAsOne(): T | undefined;
|
45
|
-
}
|
46
|
-
export declare class DeclarationContext {
|
47
|
-
readonly paints: Declaration<SkPaint>;
|
48
|
-
readonly maskFilters: Declaration<SkMaskFilter>;
|
49
|
-
readonly shaders: Declaration<SkShader>;
|
50
|
-
readonly pathEffects: Declaration<SkPathEffect>;
|
51
|
-
readonly imageFilters: Declaration<SkImageFilter>;
|
52
|
-
readonly colorFilters: Declaration<SkColorFilter>;
|
53
|
-
constructor();
|
54
|
-
save(): void;
|
55
|
-
restore(): void;
|
56
|
-
}
|
57
|
-
export {};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { BlendColorFilterProps, LerpColorFilterProps, MatrixColorFilterProps } from "../../dom/types";
|
2
|
-
import type { SkColorFilter } from "../../skia/types";
|
3
|
-
import type { DeclarationContext } from "../DeclarationContext";
|
4
|
-
export declare const composeColorFilters: (ctx: DeclarationContext, cf: SkColorFilter, processChildren: () => void) => void;
|
5
|
-
export declare const makeBlendColorFilter: (ctx: DeclarationContext, props: BlendColorFilterProps) => SkColorFilter;
|
6
|
-
export declare const makeSRGBToLinearGammaColorFilter: (ctx: DeclarationContext) => SkColorFilter;
|
7
|
-
export declare const makeLinearToSRGBGammaColorFilter: (ctx: DeclarationContext) => SkColorFilter;
|
8
|
-
export declare const declareLerpColorFilter: (ctx: DeclarationContext, props: LerpColorFilterProps) => void;
|
9
|
-
export declare const makeMatrixColorFilter: (ctx: DeclarationContext, props: MatrixColorFilterProps) => SkColorFilter;
|
10
|
-
export declare const makeLumaColorFilter: (ctx: DeclarationContext) => SkColorFilter;
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import type { AtlasProps, BoxProps, CircleProps, DiffRectProps, DrawingNodeProps, GlyphsProps, ImageProps, ImageSVGProps, LineProps, OvalProps, ParagraphProps, PatchProps, PathProps, PictureProps, PointsProps, RectProps, RoundedRectProps, TextBlobProps, TextPathProps, TextProps, VerticesProps } from "../../dom/types";
|
2
|
-
import type { SkCanvas, SkPaint, Skia } from "../../skia/types";
|
3
|
-
import type { Node } from "./Node";
|
4
|
-
interface LocalDrawingContext {
|
5
|
-
Skia: Skia;
|
6
|
-
canvas: SkCanvas;
|
7
|
-
paint: SkPaint;
|
8
|
-
}
|
9
|
-
export declare const drawLine: (ctx: LocalDrawingContext, props: LineProps) => void;
|
10
|
-
export declare const drawOval: (ctx: LocalDrawingContext, props: OvalProps) => void;
|
11
|
-
export declare const drawBox: (ctx: LocalDrawingContext, props: BoxProps, children: Node<any>[]) => void;
|
12
|
-
export declare const drawImage: (ctx: LocalDrawingContext, props: ImageProps) => void;
|
13
|
-
export declare const drawPoints: (ctx: LocalDrawingContext, props: PointsProps) => void;
|
14
|
-
export declare const drawVertices: (ctx: LocalDrawingContext, props: VerticesProps) => void;
|
15
|
-
export declare const drawDiffRect: (ctx: LocalDrawingContext, props: DiffRectProps) => void;
|
16
|
-
export declare const drawTextPath: (ctx: LocalDrawingContext, props: TextPathProps) => void;
|
17
|
-
export declare const drawText: (ctx: LocalDrawingContext, props: TextProps) => void;
|
18
|
-
export declare const drawPatch: (ctx: LocalDrawingContext, props: PatchProps) => void;
|
19
|
-
export declare const drawPath: (ctx: LocalDrawingContext, props: PathProps) => void;
|
20
|
-
export declare const drawRect: (ctx: LocalDrawingContext, props: RectProps) => void;
|
21
|
-
export declare const drawRRect: (ctx: LocalDrawingContext, props: RoundedRectProps) => void;
|
22
|
-
export declare const drawTextBlob: (ctx: LocalDrawingContext, props: TextBlobProps) => void;
|
23
|
-
export declare const drawGlyphs: (ctx: LocalDrawingContext, props: GlyphsProps) => void;
|
24
|
-
export declare const drawImageSVG: (ctx: LocalDrawingContext, props: ImageSVGProps) => void;
|
25
|
-
export declare const drawParagraph: (ctx: LocalDrawingContext, props: ParagraphProps) => void;
|
26
|
-
export declare const drawPicture: (ctx: LocalDrawingContext, props: PictureProps) => void;
|
27
|
-
export declare const drawAtlas: (ctx: LocalDrawingContext, props: AtlasProps) => void;
|
28
|
-
export declare const drawCircle: (ctx: LocalDrawingContext, props: CircleProps) => void;
|
29
|
-
export declare const drawFill: (ctx: LocalDrawingContext, _props: DrawingNodeProps) => void;
|
30
|
-
export {};
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import type { BlendImageFilterProps, BlendProps, BlurImageFilterProps, BlurMaskFilterProps, DisplacementMapImageFilterProps, DropShadowImageFilterProps, MorphologyImageFilterProps, OffsetImageFilterProps, RuntimeShaderImageFilterProps } from "../../dom/types";
|
2
|
-
import type { SkImageFilter } from "../../skia/types";
|
3
|
-
import type { DeclarationContext } from "../DeclarationContext";
|
4
|
-
export declare enum MorphologyOperator {
|
5
|
-
Erode = 0,
|
6
|
-
Dilate = 1
|
7
|
-
}
|
8
|
-
export declare const declareBlend: (ctx: DeclarationContext, props: BlendProps) => void;
|
9
|
-
export declare const composeImageFilters: (ctx: DeclarationContext, imgf1: SkImageFilter, processChildren: () => void) => void;
|
10
|
-
export declare const makeOffsetImageFilter: (ctx: DeclarationContext, props: OffsetImageFilterProps) => SkImageFilter;
|
11
|
-
export declare const declareDisplacementMapImageFilter: (ctx: DeclarationContext, props: DisplacementMapImageFilterProps) => void;
|
12
|
-
export declare const makeBlurImageFilter: (ctx: DeclarationContext, props: BlurImageFilterProps) => SkImageFilter;
|
13
|
-
export declare const makeDropShadowImageFilter: (ctx: DeclarationContext, props: DropShadowImageFilterProps) => SkImageFilter;
|
14
|
-
export declare const makeMorphologyImageFilter: (ctx: DeclarationContext, props: MorphologyImageFilterProps) => SkImageFilter;
|
15
|
-
export declare const makeRuntimeShaderImageFilter: (ctx: DeclarationContext, props: RuntimeShaderImageFilterProps) => SkImageFilter;
|
16
|
-
export declare const declareBlendImageFilter: (ctx: DeclarationContext, props: BlendImageFilterProps) => void;
|
17
|
-
export declare const declareBlurMaskFilter: (ctx: DeclarationContext, props: BlurMaskFilterProps) => void;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import type { CornerPathEffectProps, DashPathEffectProps, DiscretePathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps } from "../../dom/types";
|
2
|
-
import type { SkPathEffect } from "../../skia/types";
|
3
|
-
import { type DeclarationContext } from "../DeclarationContext";
|
4
|
-
export declare const composePathEffects: (ctx: DeclarationContext, pe: SkPathEffect, processChildren: () => void) => void;
|
5
|
-
export declare const makeDiscretePathEffect: (ctx: DeclarationContext, props: DiscretePathEffectProps) => SkPathEffect;
|
6
|
-
export declare const makePath2DPathEffect: (ctx: DeclarationContext, props: Path2DPathEffectProps) => SkPathEffect;
|
7
|
-
export declare const makeDashPathEffect: (ctx: DeclarationContext, props: DashPathEffectProps) => SkPathEffect;
|
8
|
-
export declare const makeCornerPathEffect: (ctx: DeclarationContext, props: CornerPathEffectProps) => SkPathEffect;
|
9
|
-
export declare const declareSumPathEffect: (ctx: DeclarationContext) => void;
|
10
|
-
export declare const makeLine2DPathEffect: (ctx: DeclarationContext, props: Line2DPathEffectProps) => SkPathEffect;
|
11
|
-
export declare const makePath1DPathEffect: (ctx: DeclarationContext, props: Path1DPathEffectProps) => SkPathEffect;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import type { ColorProps, FractalNoiseProps, ImageShaderProps, LinearGradientProps, RadialGradientProps, ShaderProps, SweepGradientProps, TurbulenceProps, TwoPointConicalGradientProps } from "../../dom/types";
|
2
|
-
import type { DeclarationContext } from "../DeclarationContext";
|
3
|
-
export declare const declareShader: (ctx: DeclarationContext, props: ShaderProps) => void;
|
4
|
-
export declare const declareColorShader: (ctx: DeclarationContext, props: ColorProps) => void;
|
5
|
-
export declare const declareFractalNoiseShader: (ctx: DeclarationContext, props: FractalNoiseProps) => void;
|
6
|
-
export declare const declareTwoPointConicalGradientShader: (ctx: DeclarationContext, props: TwoPointConicalGradientProps) => void;
|
7
|
-
export declare const declareRadialGradientShader: (ctx: DeclarationContext, props: RadialGradientProps) => void;
|
8
|
-
export declare const declareSweepGradientShader: (ctx: DeclarationContext, props: SweepGradientProps) => void;
|
9
|
-
export declare const declareLinearGradientShader: (ctx: DeclarationContext, props: LinearGradientProps) => void;
|
10
|
-
export declare const declareTurbulenceShader: (ctx: DeclarationContext, props: TurbulenceProps) => void;
|
11
|
-
export declare const declareImageShader: (ctx: DeclarationContext, props: ImageShaderProps) => void;
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import { useEffect, useMemo } from "react";
|
2
|
-
|
3
|
-
import Rea from "./ReanimatedProxy";
|
4
|
-
|
5
|
-
export const useDerivedValueOnJS = (
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
7
|
-
fn: () => any,
|
8
|
-
deps: unknown[]
|
9
|
-
) => {
|
10
|
-
const init = useMemo(() => fn(), [fn]);
|
11
|
-
const value = Rea.useSharedValue(init);
|
12
|
-
useEffect(() => {
|
13
|
-
const mapperId = Rea.startMapper(() => {
|
14
|
-
"worklet";
|
15
|
-
Rea.runOnJS(fn)();
|
16
|
-
}, deps);
|
17
|
-
return () => Rea.stopMapper(mapperId);
|
18
|
-
}, [deps, fn]);
|
19
|
-
return value;
|
20
|
-
};
|
@@ -1,85 +0,0 @@
|
|
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
|
-
"worklet";
|
15
|
-
const len = filters.length;
|
16
|
-
if (len <= 1) {
|
17
|
-
return filters[0];
|
18
|
-
}
|
19
|
-
return filters.reduceRight((inner, outer) =>
|
20
|
-
inner ? composer(outer, inner) : outer
|
21
|
-
);
|
22
|
-
};
|
23
|
-
|
24
|
-
const createDeclaration = <T>(composer?: Composer<T>) => {
|
25
|
-
"worklet";
|
26
|
-
const state = {
|
27
|
-
decls: [] as T[],
|
28
|
-
indexes: [0],
|
29
|
-
};
|
30
|
-
|
31
|
-
return {
|
32
|
-
save: () => {
|
33
|
-
state.indexes.push(state.decls.length);
|
34
|
-
},
|
35
|
-
restore: () => {
|
36
|
-
state.indexes.pop();
|
37
|
-
},
|
38
|
-
pop: () => state.decls.pop(),
|
39
|
-
push: (decl: T) => {
|
40
|
-
state.decls.push(decl);
|
41
|
-
},
|
42
|
-
popAll: () => {
|
43
|
-
const idx = state.indexes[state.indexes.length - 1];
|
44
|
-
return state.decls.splice(idx, state.decls.length - idx);
|
45
|
-
},
|
46
|
-
popAllAsOne: () => {
|
47
|
-
if (state.decls.length === 0) {
|
48
|
-
return undefined;
|
49
|
-
}
|
50
|
-
if (!composer) {
|
51
|
-
throw new Error("No composer for this type of declaration");
|
52
|
-
}
|
53
|
-
if (!state.decls.length) {
|
54
|
-
return undefined;
|
55
|
-
}
|
56
|
-
if (!composer) {
|
57
|
-
throw new Error("No composer for this type of declaration");
|
58
|
-
}
|
59
|
-
|
60
|
-
const idx = state.indexes[state.indexes.length - 1];
|
61
|
-
const decls = state.decls.splice(idx, state.decls.length - idx);
|
62
|
-
return composeDeclarations(decls, composer);
|
63
|
-
},
|
64
|
-
};
|
65
|
-
};
|
66
|
-
|
67
|
-
export const createDeclarationContext = (Skia: Skia) => {
|
68
|
-
"worklet";
|
69
|
-
const composers = {
|
70
|
-
pathEffect: Skia.PathEffect.MakeCompose.bind(Skia.PathEffect),
|
71
|
-
imageFilter: Skia.ImageFilter.MakeCompose.bind(Skia.ImageFilter),
|
72
|
-
colorFilter: Skia.ColorFilter.MakeCompose.bind(Skia.ColorFilter),
|
73
|
-
};
|
74
|
-
return {
|
75
|
-
Skia,
|
76
|
-
paints: createDeclaration<SkPaint>(),
|
77
|
-
maskFilters: createDeclaration<SkMaskFilter>(),
|
78
|
-
shaders: createDeclaration<SkShader>(),
|
79
|
-
pathEffects: createDeclaration<SkPathEffect>(composers.pathEffect),
|
80
|
-
imageFilters: createDeclaration<SkImageFilter>(composers.imageFilter),
|
81
|
-
colorFilters: createDeclaration<SkColorFilter>(composers.colorFilter),
|
82
|
-
};
|
83
|
-
};
|
84
|
-
|
85
|
-
export type DeclarationContext = ReturnType<typeof createDeclarationContext>;
|
@@ -1,226 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
enumKey,
|
3
|
-
isPathDef,
|
4
|
-
processPath,
|
5
|
-
processTransformProps2,
|
6
|
-
} from "../dom/nodes";
|
7
|
-
import type { ClipDef, DrawingNodeProps, GroupProps } from "../dom/types";
|
8
|
-
import {
|
9
|
-
BlendMode,
|
10
|
-
ClipOp,
|
11
|
-
isRRect,
|
12
|
-
PaintStyle,
|
13
|
-
StrokeCap,
|
14
|
-
StrokeJoin,
|
15
|
-
} from "../skia/types";
|
16
|
-
import type {
|
17
|
-
SkPath,
|
18
|
-
SkRect,
|
19
|
-
SkRRect,
|
20
|
-
SkCanvas,
|
21
|
-
Skia,
|
22
|
-
SkPaint,
|
23
|
-
} from "../skia/types";
|
24
|
-
|
25
|
-
import type { DeclarationContext } from "./DeclarationContext";
|
26
|
-
|
27
|
-
const computeClip = (
|
28
|
-
Skia: Skia,
|
29
|
-
clip: ClipDef | undefined
|
30
|
-
):
|
31
|
-
| undefined
|
32
|
-
| { clipPath: SkPath }
|
33
|
-
| { clipRect: SkRect }
|
34
|
-
| { clipRRect: SkRRect } => {
|
35
|
-
"worklet";
|
36
|
-
if (clip) {
|
37
|
-
if (isPathDef(clip)) {
|
38
|
-
return { clipPath: processPath(Skia, clip) };
|
39
|
-
} else if (isRRect(clip)) {
|
40
|
-
return { clipRRect: clip };
|
41
|
-
} else {
|
42
|
-
return { clipRect: clip };
|
43
|
-
}
|
44
|
-
}
|
45
|
-
return undefined;
|
46
|
-
};
|
47
|
-
|
48
|
-
const processColor = (
|
49
|
-
Skia: Skia,
|
50
|
-
color: number | string | Float32Array | number[]
|
51
|
-
) => {
|
52
|
-
"worklet";
|
53
|
-
if (typeof color === "string" || typeof color === "number") {
|
54
|
-
return Skia.Color(color);
|
55
|
-
} else if (Array.isArray(color) || color instanceof Float32Array) {
|
56
|
-
return color instanceof Float32Array ? color : new Float32Array(color);
|
57
|
-
} else {
|
58
|
-
throw new Error(
|
59
|
-
`Invalid color type: ${typeof color}. Expected number, string, or array.`
|
60
|
-
);
|
61
|
-
}
|
62
|
-
};
|
63
|
-
|
64
|
-
export const createDrawingContext = (Skia: Skia, canvas: SkCanvas) => {
|
65
|
-
"worklet";
|
66
|
-
const state = {
|
67
|
-
paints: [Skia.Paint()],
|
68
|
-
};
|
69
|
-
|
70
|
-
const getPaint = () => {
|
71
|
-
return state.paints[state.paints.length - 1];
|
72
|
-
};
|
73
|
-
|
74
|
-
const processPaint = (
|
75
|
-
{
|
76
|
-
opacity,
|
77
|
-
color,
|
78
|
-
strokeWidth,
|
79
|
-
blendMode,
|
80
|
-
style,
|
81
|
-
strokeJoin,
|
82
|
-
strokeCap,
|
83
|
-
strokeMiter,
|
84
|
-
antiAlias,
|
85
|
-
dither,
|
86
|
-
paint: paintProp,
|
87
|
-
}: DrawingNodeProps,
|
88
|
-
declCtx: DeclarationContext
|
89
|
-
) => {
|
90
|
-
if (paintProp) {
|
91
|
-
declCtx.paints.push(paintProp);
|
92
|
-
return true;
|
93
|
-
}
|
94
|
-
let shouldRestore = false;
|
95
|
-
const colorFilter = declCtx.colorFilters.popAllAsOne();
|
96
|
-
const imageFilter = declCtx.imageFilters.popAllAsOne();
|
97
|
-
const shader = declCtx.shaders.pop();
|
98
|
-
const maskFilter = declCtx.maskFilters.pop();
|
99
|
-
const pathEffect = declCtx.pathEffects.popAllAsOne();
|
100
|
-
|
101
|
-
if (
|
102
|
-
opacity !== undefined ||
|
103
|
-
color !== undefined ||
|
104
|
-
strokeWidth !== undefined ||
|
105
|
-
blendMode !== undefined ||
|
106
|
-
style !== undefined ||
|
107
|
-
strokeJoin !== undefined ||
|
108
|
-
strokeCap !== undefined ||
|
109
|
-
strokeMiter !== undefined ||
|
110
|
-
antiAlias !== undefined ||
|
111
|
-
dither !== undefined ||
|
112
|
-
colorFilter !== undefined ||
|
113
|
-
imageFilter !== undefined ||
|
114
|
-
shader !== undefined ||
|
115
|
-
maskFilter !== undefined ||
|
116
|
-
pathEffect !== undefined
|
117
|
-
) {
|
118
|
-
if (!shouldRestore) {
|
119
|
-
state.paints.push(getPaint().copy());
|
120
|
-
shouldRestore = true;
|
121
|
-
}
|
122
|
-
}
|
123
|
-
|
124
|
-
const paint = getPaint();
|
125
|
-
if (opacity !== undefined) {
|
126
|
-
paint.setAlphaf(paint.getAlphaf() * opacity);
|
127
|
-
}
|
128
|
-
if (color !== undefined) {
|
129
|
-
const currentOpacity = paint.getAlphaf();
|
130
|
-
paint.setShader(null);
|
131
|
-
paint.setColor(processColor(Skia, color));
|
132
|
-
paint.setAlphaf(currentOpacity * paint.getAlphaf());
|
133
|
-
}
|
134
|
-
if (strokeWidth !== undefined) {
|
135
|
-
paint.setStrokeWidth(strokeWidth);
|
136
|
-
}
|
137
|
-
if (blendMode !== undefined) {
|
138
|
-
paint.setBlendMode(BlendMode[enumKey(blendMode)]);
|
139
|
-
}
|
140
|
-
if (style !== undefined) {
|
141
|
-
paint.setStyle(PaintStyle[enumKey(style)]);
|
142
|
-
}
|
143
|
-
if (strokeJoin !== undefined) {
|
144
|
-
paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);
|
145
|
-
}
|
146
|
-
if (strokeCap !== undefined) {
|
147
|
-
paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);
|
148
|
-
}
|
149
|
-
if (strokeMiter !== undefined) {
|
150
|
-
paint.setStrokeMiter(strokeMiter);
|
151
|
-
}
|
152
|
-
if (antiAlias !== undefined) {
|
153
|
-
paint.setAntiAlias(antiAlias);
|
154
|
-
}
|
155
|
-
if (dither !== undefined) {
|
156
|
-
paint.setDither(dither);
|
157
|
-
}
|
158
|
-
if (colorFilter) {
|
159
|
-
paint.setColorFilter(colorFilter);
|
160
|
-
}
|
161
|
-
if (imageFilter) {
|
162
|
-
paint.setImageFilter(imageFilter);
|
163
|
-
}
|
164
|
-
if (shader) {
|
165
|
-
paint.setShader(shader);
|
166
|
-
}
|
167
|
-
if (maskFilter) {
|
168
|
-
paint.setMaskFilter(maskFilter);
|
169
|
-
}
|
170
|
-
if (pathEffect) {
|
171
|
-
paint.setPathEffect(pathEffect);
|
172
|
-
}
|
173
|
-
return shouldRestore;
|
174
|
-
};
|
175
|
-
|
176
|
-
const processMatrixAndClipping = (
|
177
|
-
props: GroupProps,
|
178
|
-
layer?: boolean | SkPaint
|
179
|
-
) => {
|
180
|
-
const hasTransform =
|
181
|
-
props.matrix !== undefined || props.transform !== undefined;
|
182
|
-
const clip = computeClip(Skia, props.clip);
|
183
|
-
const hasClip = clip !== undefined;
|
184
|
-
const op = props.invertClip ? ClipOp.Difference : ClipOp.Intersect;
|
185
|
-
const m3 = processTransformProps2(Skia, props);
|
186
|
-
const shouldSave = hasTransform || hasClip || !!layer;
|
187
|
-
|
188
|
-
if (shouldSave) {
|
189
|
-
if (layer) {
|
190
|
-
if (typeof layer === "boolean") {
|
191
|
-
canvas.saveLayer();
|
192
|
-
} else {
|
193
|
-
canvas.saveLayer(layer);
|
194
|
-
}
|
195
|
-
} else {
|
196
|
-
canvas.save();
|
197
|
-
}
|
198
|
-
}
|
199
|
-
|
200
|
-
if (m3) {
|
201
|
-
canvas.concat(m3);
|
202
|
-
}
|
203
|
-
if (clip) {
|
204
|
-
if ("clipRect" in clip) {
|
205
|
-
canvas.clipRect(clip.clipRect, op, true);
|
206
|
-
} else if ("clipRRect" in clip) {
|
207
|
-
canvas.clipRRect(clip.clipRRect, op, true);
|
208
|
-
} else {
|
209
|
-
canvas.clipPath(clip.clipPath, op, true);
|
210
|
-
}
|
211
|
-
}
|
212
|
-
return shouldSave;
|
213
|
-
};
|
214
|
-
|
215
|
-
return {
|
216
|
-
Skia,
|
217
|
-
canvas,
|
218
|
-
save: () => state.paints.push(getPaint().copy()),
|
219
|
-
restore: () => state.paints.pop(),
|
220
|
-
getPaint,
|
221
|
-
processPaint,
|
222
|
-
processMatrixAndClipping,
|
223
|
-
};
|
224
|
-
};
|
225
|
-
|
226
|
-
export type DrawingContext = ReturnType<typeof createDrawingContext>;
|