@shopify/react-native-skia 0.1.172 → 0.1.174
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 +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,7 +8,7 @@ export class PaintNode extends JsiDeclarationNode {
|
|
8
8
|
super(ctx, DeclarationType.Paint, NodeType.Paint, props);
|
9
9
|
}
|
10
10
|
|
11
|
-
|
11
|
+
decorate(ctx) {
|
12
12
|
const {
|
13
13
|
color,
|
14
14
|
strokeWidth,
|
@@ -58,25 +58,42 @@ export class PaintNode extends JsiDeclarationNode {
|
|
58
58
|
paint.setAntiAlias(antiAlias);
|
59
59
|
}
|
60
60
|
|
61
|
+
ctx.save();
|
62
|
+
|
61
63
|
this._children.forEach(child => {
|
62
64
|
if (child instanceof JsiDeclarationNode) {
|
63
|
-
|
64
|
-
paint.setShader(child.materialize());
|
65
|
-
} else if (child.isColorFilter()) {
|
66
|
-
paint.setColorFilter(child.materialize());
|
67
|
-
} else if (child.isImageFilter()) {
|
68
|
-
paint.setImageFilter(child.materialize());
|
69
|
-
} else if (child.isMaskFilter()) {
|
70
|
-
paint.setMaskFilter(child.materialize());
|
71
|
-
} else if (child.isPathEffect()) {
|
72
|
-
paint.setPathEffect(child.materialize());
|
73
|
-
} else {
|
74
|
-
throw new Error(`Unknown paint child ${child.type}`);
|
75
|
-
}
|
65
|
+
child.decorate(ctx);
|
76
66
|
}
|
77
67
|
});
|
78
68
|
|
79
|
-
|
69
|
+
const colorFilter = ctx.colorFilters.popAllAsOne();
|
70
|
+
const imageFilter = ctx.imageFilters.popAllAsOne();
|
71
|
+
const shader = ctx.shaders.pop();
|
72
|
+
const maskFilter = ctx.maskFilters.pop();
|
73
|
+
const pathEffect = ctx.pathEffects.popAllAsOne();
|
74
|
+
ctx.restore();
|
75
|
+
|
76
|
+
if (imageFilter) {
|
77
|
+
paint.setImageFilter(imageFilter);
|
78
|
+
}
|
79
|
+
|
80
|
+
if (shader) {
|
81
|
+
paint.setShader(shader);
|
82
|
+
}
|
83
|
+
|
84
|
+
if (pathEffect) {
|
85
|
+
paint.setPathEffect(pathEffect);
|
86
|
+
}
|
87
|
+
|
88
|
+
if (colorFilter) {
|
89
|
+
paint.setColorFilter(colorFilter);
|
90
|
+
}
|
91
|
+
|
92
|
+
if (maskFilter) {
|
93
|
+
paint.setMaskFilter(maskFilter);
|
94
|
+
}
|
95
|
+
|
96
|
+
ctx.paints.push(paint);
|
80
97
|
}
|
81
98
|
|
82
99
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["StrokeCap","StrokeJoin","PaintStyle","BlendMode","DeclarationType","NodeType","enumKey","JsiDeclarationNode","PaintNode","constructor","ctx","props","Paint","
|
1
|
+
{"version":3,"names":["StrokeCap","StrokeJoin","PaintStyle","BlendMode","DeclarationType","NodeType","enumKey","JsiDeclarationNode","PaintNode","constructor","ctx","props","Paint","decorate","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","opacity","antiAlias","paint","Skia","undefined","setColor","Color","setStrokeWidth","setBlendMode","setStyle","setStrokeJoin","setStrokeCap","setStrokeMiter","setAlphaf","setAntiAlias","save","_children","forEach","child","colorFilter","colorFilters","popAllAsOne","imageFilter","imageFilters","shader","shaders","pop","maskFilter","maskFilters","pathEffect","pathEffects","restore","setImageFilter","setShader","setPathEffect","setColorFilter","setMaskFilter","paints","push"],"sources":["PaintNode.ts"],"sourcesContent":["import { StrokeCap, StrokeJoin, PaintStyle, BlendMode } from \"../../skia/types\";\nimport type { DeclarationNode, PaintProps } from \"../types\";\nimport { DeclarationType, NodeType } from \"../types\";\nimport type { DeclarationContext } from \"../types/DeclarationContext\";\n\nimport { enumKey } from \"./datatypes\";\nimport type { NodeContext } from \"./Node\";\nimport { JsiDeclarationNode } from \"./Node\";\n\nexport class PaintNode\n extends JsiDeclarationNode<PaintProps>\n implements DeclarationNode<PaintProps>\n{\n constructor(ctx: NodeContext, props: PaintProps = {}) {\n super(ctx, DeclarationType.Paint, NodeType.Paint, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const {\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n antiAlias,\n } = this.props;\n const paint = this.Skia.Paint();\n if (color !== undefined) {\n paint.setColor(this.Skia.Color(color));\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(BlendMode[enumKey(blendMode)]);\n }\n if (style !== undefined) {\n paint.setStyle(PaintStyle[enumKey(style)]);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (opacity !== undefined) {\n paint.setAlphaf(opacity);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n ctx.save();\n this._children.forEach((child) => {\n if (child instanceof JsiDeclarationNode) {\n child.decorate(ctx);\n }\n });\n const colorFilter = ctx.colorFilters.popAllAsOne();\n const imageFilter = ctx.imageFilters.popAllAsOne();\n const shader = ctx.shaders.pop();\n const maskFilter = ctx.maskFilters.pop();\n const pathEffect = ctx.pathEffects.popAllAsOne();\n ctx.restore();\n if (imageFilter) {\n paint.setImageFilter(imageFilter);\n }\n if (shader) {\n paint.setShader(shader);\n }\n if (pathEffect) {\n paint.setPathEffect(pathEffect);\n }\n if (colorFilter) {\n paint.setColorFilter(colorFilter);\n }\n if (maskFilter) {\n paint.setMaskFilter(maskFilter);\n }\n ctx.paints.push(paint);\n }\n}\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,UAApB,EAAgCC,UAAhC,EAA4CC,SAA5C,QAA6D,kBAA7D;AAEA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,UAA1C;AAGA,SAASC,OAAT,QAAwB,aAAxB;AAEA,SAASC,kBAAT,QAAmC,QAAnC;AAEA,OAAO,MAAMC,SAAN,SACGD,kBADH,CAGP;EACEE,WAAW,CAACC,GAAD,EAA2C;IAAA,IAAxBC,KAAwB,uEAAJ,EAAI;IACpD,MAAMD,GAAN,EAAWN,eAAe,CAACQ,KAA3B,EAAkCP,QAAQ,CAACO,KAA3C,EAAkDD,KAAlD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,IAAJ;;IACA,KAAKC,SAAL,CAAeC,OAAf,CAAwBC,KAAD,IAAW;MAChC,IAAIA,KAAK,YAAYhC,kBAArB,EAAyC;QACvCgC,KAAK,CAAC1B,QAAN,CAAeH,GAAf;MACD;IACF,CAJD;;IAKA,MAAM8B,WAAW,GAAG9B,GAAG,CAAC+B,YAAJ,CAAiBC,WAAjB,EAApB;IACA,MAAMC,WAAW,GAAGjC,GAAG,CAACkC,YAAJ,CAAiBF,WAAjB,EAApB;IACA,MAAMG,MAAM,GAAGnC,GAAG,CAACoC,OAAJ,CAAYC,GAAZ,EAAf;IACA,MAAMC,UAAU,GAAGtC,GAAG,CAACuC,WAAJ,CAAgBF,GAAhB,EAAnB;IACA,MAAMG,UAAU,GAAGxC,GAAG,CAACyC,WAAJ,CAAgBT,WAAhB,EAAnB;IACAhC,GAAG,CAAC0C,OAAJ;;IACA,IAAIT,WAAJ,EAAiB;MACfpB,KAAK,CAAC8B,cAAN,CAAqBV,WAArB;IACD;;IACD,IAAIE,MAAJ,EAAY;MACVtB,KAAK,CAAC+B,SAAN,CAAgBT,MAAhB;IACD;;IACD,IAAIK,UAAJ,EAAgB;MACd3B,KAAK,CAACgC,aAAN,CAAoBL,UAApB;IACD;;IACD,IAAIV,WAAJ,EAAiB;MACfjB,KAAK,CAACiC,cAAN,CAAqBhB,WAArB;IACD;;IACD,IAAIQ,UAAJ,EAAgB;MACdzB,KAAK,CAACkC,aAAN,CAAoBT,UAApB;IACD;;IACDtC,GAAG,CAACgD,MAAJ,CAAWC,IAAX,CAAgBpC,KAAhB;EACD;;AAzEH"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { SkMatrix, SkRect, SkRRect, SkPath, SkPaint } from "../../skia/types";
|
2
|
-
import type { RenderNode, GroupProps,
|
2
|
+
import type { RenderNode, GroupProps, NodeType, Node, DrawingContext } from "../types";
|
3
3
|
import type { NodeContext } from "./Node";
|
4
4
|
import { JsiNode } from "./Node";
|
5
5
|
interface PaintCache {
|
@@ -20,8 +20,7 @@ export declare abstract class JsiRenderNode<P extends GroupProps> extends JsiNod
|
|
20
20
|
insertChildBefore(child: Node<unknown>, before: Node<unknown>): void;
|
21
21
|
private computeClip;
|
22
22
|
private computeMatrix;
|
23
|
-
|
24
|
-
render(parentCtx: DrawingContext): void;
|
23
|
+
render(ctx: DrawingContext): void;
|
25
24
|
abstract renderNode(ctx: DrawingContext): void;
|
26
25
|
}
|
27
26
|
export {};
|
@@ -1,9 +1,8 @@
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
2
2
|
|
3
|
-
import {
|
3
|
+
import { ClipOp, isRRect } from "../../skia/types";
|
4
4
|
import { isPathDef, processPath, processTransformProps } from "./datatypes";
|
5
5
|
import { JsiNode, JsiDeclarationNode } from "./Node";
|
6
|
-
import { enumKey } from "./datatypes/Enum";
|
7
6
|
const paintProps = ["color", "strokeWidth", "blendMode", "strokeCap", "strokeJoin", "strokeMiter", "style", "antiAlias", "opacity"];
|
8
7
|
export class JsiRenderNode extends JsiNode {
|
9
8
|
constructor(ctx, type, props) {
|
@@ -26,7 +25,6 @@ export class JsiRenderNode extends JsiNode {
|
|
26
25
|
setProps(props) {
|
27
26
|
super.setProps(props);
|
28
27
|
this.onPropChange();
|
29
|
-
this.paintCache = null;
|
30
28
|
}
|
31
29
|
|
32
30
|
setProp(key, value) {
|
@@ -54,7 +52,9 @@ export class JsiRenderNode extends JsiNode {
|
|
54
52
|
|
55
53
|
addChild(child) {
|
56
54
|
if (child instanceof JsiDeclarationNode) {
|
57
|
-
child.setInvalidate(() =>
|
55
|
+
child.setInvalidate(() => {
|
56
|
+
this.paintCache = null;
|
57
|
+
});
|
58
58
|
}
|
59
59
|
|
60
60
|
super.addChild(child);
|
@@ -62,7 +62,9 @@ export class JsiRenderNode extends JsiNode {
|
|
62
62
|
|
63
63
|
insertChildBefore(child, before) {
|
64
64
|
if (child instanceof JsiDeclarationNode) {
|
65
|
-
child.setInvalidate(() =>
|
65
|
+
child.setInvalidate(() => {
|
66
|
+
this.paintCache = null;
|
67
|
+
});
|
66
68
|
}
|
67
69
|
|
68
70
|
super.insertChildBefore(child, before);
|
@@ -88,92 +90,7 @@ export class JsiRenderNode extends JsiNode {
|
|
88
90
|
processTransformProps(this.matrix, this.props);
|
89
91
|
}
|
90
92
|
|
91
|
-
|
92
|
-
let ctx;
|
93
|
-
const {
|
94
|
-
color,
|
95
|
-
strokeWidth,
|
96
|
-
blendMode,
|
97
|
-
style,
|
98
|
-
strokeJoin,
|
99
|
-
strokeCap,
|
100
|
-
strokeMiter,
|
101
|
-
opacity,
|
102
|
-
antiAlias
|
103
|
-
} = this.props;
|
104
|
-
|
105
|
-
if (color !== undefined || strokeWidth !== undefined || blendMode !== undefined || style !== undefined || strokeJoin !== undefined || strokeCap !== undefined || strokeMiter !== undefined || opacity !== undefined || antiAlias !== undefined) {
|
106
|
-
ctx = {
|
107
|
-
opacity: 1
|
108
|
-
};
|
109
|
-
|
110
|
-
if (color !== undefined) {
|
111
|
-
ctx.color = this.Skia.Color(color);
|
112
|
-
}
|
113
|
-
|
114
|
-
if (strokeWidth !== undefined) {
|
115
|
-
ctx.strokeWidth = strokeWidth;
|
116
|
-
}
|
117
|
-
|
118
|
-
if (blendMode !== undefined) {
|
119
|
-
ctx.blendMode = BlendMode[enumKey(blendMode)];
|
120
|
-
}
|
121
|
-
|
122
|
-
if (style !== undefined) {
|
123
|
-
ctx.style = PaintStyle[enumKey(style)];
|
124
|
-
}
|
125
|
-
|
126
|
-
if (strokeJoin !== undefined) {
|
127
|
-
ctx.strokeJoin = StrokeJoin[enumKey(strokeJoin)];
|
128
|
-
}
|
129
|
-
|
130
|
-
if (strokeCap !== undefined) {
|
131
|
-
ctx.strokeCap = StrokeCap[enumKey(strokeCap)];
|
132
|
-
}
|
133
|
-
|
134
|
-
if (strokeMiter !== undefined) {
|
135
|
-
ctx.strokeMiter = strokeMiter;
|
136
|
-
}
|
137
|
-
|
138
|
-
if (opacity !== undefined) {
|
139
|
-
ctx.opacity = opacity;
|
140
|
-
}
|
141
|
-
|
142
|
-
if (antiAlias !== undefined) {
|
143
|
-
ctx.antiAlias = antiAlias;
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
this._children.forEach(child => {
|
148
|
-
if (child instanceof JsiDeclarationNode) {
|
149
|
-
if (child.isColorFilter()) {
|
150
|
-
ctx = ctx || {};
|
151
|
-
const cf = child.materialize();
|
152
|
-
ctx.colorFilter = ctx.colorFilter ? this.Skia.ColorFilter.MakeCompose(cf, ctx.colorFilter) : cf;
|
153
|
-
} else if (child.isShader()) {
|
154
|
-
ctx = ctx || {};
|
155
|
-
const shader = child.materialize();
|
156
|
-
ctx.shader = shader;
|
157
|
-
} else if (child.isPathEffect()) {
|
158
|
-
ctx = ctx || {};
|
159
|
-
const pe = child.materialize();
|
160
|
-
ctx.pathEffect = ctx.pathEffect ? this.Skia.PathEffect.MakeCompose(pe, ctx.pathEffect) : pe;
|
161
|
-
} else if (child.isImageFilter()) {
|
162
|
-
ctx = ctx || {};
|
163
|
-
const filter = child.materialize();
|
164
|
-
ctx.imageFilter = ctx.imageFilter ? this.Skia.ImageFilter.MakeCompose(filter, ctx.imageFilter) : filter;
|
165
|
-
} else if (child.isMaskFilter()) {
|
166
|
-
ctx = ctx || {};
|
167
|
-
const filter = child.materialize();
|
168
|
-
ctx.maskFilter = filter;
|
169
|
-
}
|
170
|
-
}
|
171
|
-
});
|
172
|
-
|
173
|
-
return ctx;
|
174
|
-
}
|
175
|
-
|
176
|
-
render(parentCtx) {
|
93
|
+
render(ctx) {
|
177
94
|
const {
|
178
95
|
invertClip,
|
179
96
|
layer,
|
@@ -182,22 +99,10 @@ export class JsiRenderNode extends JsiNode {
|
|
182
99
|
} = this.props;
|
183
100
|
const {
|
184
101
|
canvas
|
185
|
-
} =
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
const child = paintCtx ? concatPaint(parentCtx.paint.copy(), paintCtx) : parentCtx.paint;
|
190
|
-
this.paintCache = {
|
191
|
-
parent: parentCtx.paint,
|
192
|
-
child
|
193
|
-
};
|
194
|
-
}
|
195
|
-
|
196
|
-
const paint = this.paintCache.child; // TODO: can we only recreate a new context here if needed?
|
197
|
-
|
198
|
-
const ctx = { ...parentCtx,
|
199
|
-
paint
|
200
|
-
};
|
102
|
+
} = ctx;
|
103
|
+
const parentPaint = ctx.paint;
|
104
|
+
const cache = this.paintCache !== null && this.paintCache.parent === ctx.paint ? this.paintCache.child : undefined;
|
105
|
+
const shouldRestore = ctx.saveAndConcat(this, cache);
|
201
106
|
const hasTransform = matrix !== undefined || transform !== undefined;
|
202
107
|
const hasClip = this.clipRect !== undefined || this.clipPath !== undefined || this.clipRRect !== undefined;
|
203
108
|
const shouldSave = hasTransform || hasClip || !!layer;
|
@@ -232,87 +137,15 @@ export class JsiRenderNode extends JsiNode {
|
|
232
137
|
if (shouldSave) {
|
233
138
|
canvas.restore();
|
234
139
|
}
|
235
|
-
}
|
236
|
-
|
237
|
-
}
|
238
|
-
|
239
|
-
const concatPaint = (paint, _ref) => {
|
240
|
-
let {
|
241
|
-
color,
|
242
|
-
strokeWidth,
|
243
|
-
shader,
|
244
|
-
antiAlias,
|
245
|
-
blendMode,
|
246
|
-
colorFilter,
|
247
|
-
imageFilter,
|
248
|
-
maskFilter,
|
249
|
-
pathEffect,
|
250
|
-
opacity,
|
251
|
-
strokeCap,
|
252
|
-
strokeJoin,
|
253
|
-
strokeMiter,
|
254
|
-
style
|
255
|
-
} = _ref;
|
256
|
-
|
257
|
-
if (opacity !== undefined) {
|
258
|
-
paint.setAlphaf(paint.getAlphaf() * opacity);
|
259
|
-
}
|
260
|
-
|
261
|
-
if (color !== undefined) {
|
262
|
-
const currentOpacity = paint.getAlphaf();
|
263
|
-
paint.setShader(null);
|
264
|
-
paint.setColor(color);
|
265
|
-
paint.setAlphaf(currentOpacity * paint.getAlphaf());
|
266
|
-
}
|
267
140
|
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
if (antiAlias !== undefined) {
|
277
|
-
paint.setAntiAlias(antiAlias);
|
278
|
-
}
|
279
|
-
|
280
|
-
if (blendMode !== undefined) {
|
281
|
-
paint.setBlendMode(blendMode);
|
282
|
-
}
|
283
|
-
|
284
|
-
if (colorFilter !== undefined) {
|
285
|
-
paint.setColorFilter(colorFilter);
|
286
|
-
}
|
287
|
-
|
288
|
-
if (imageFilter !== undefined) {
|
289
|
-
paint.setImageFilter(imageFilter);
|
290
|
-
}
|
291
|
-
|
292
|
-
if (maskFilter !== undefined) {
|
293
|
-
paint.setMaskFilter(maskFilter);
|
294
|
-
}
|
295
|
-
|
296
|
-
if (pathEffect !== undefined) {
|
297
|
-
paint.setPathEffect(pathEffect);
|
298
|
-
}
|
299
|
-
|
300
|
-
if (strokeCap !== undefined) {
|
301
|
-
paint.setStrokeCap(strokeCap);
|
302
|
-
}
|
303
|
-
|
304
|
-
if (strokeJoin !== undefined) {
|
305
|
-
paint.setStrokeJoin(strokeJoin);
|
306
|
-
}
|
307
|
-
|
308
|
-
if (strokeMiter !== undefined) {
|
309
|
-
paint.setStrokeMiter(strokeMiter);
|
310
|
-
}
|
311
|
-
|
312
|
-
if (style !== undefined) {
|
313
|
-
paint.setStyle(style);
|
141
|
+
if (shouldRestore) {
|
142
|
+
this.paintCache = {
|
143
|
+
parent: parentPaint,
|
144
|
+
child: ctx.paint
|
145
|
+
};
|
146
|
+
ctx.restore();
|
147
|
+
}
|
314
148
|
}
|
315
149
|
|
316
|
-
|
317
|
-
};
|
150
|
+
}
|
318
151
|
//# sourceMappingURL=RenderNode.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["StrokeCap","StrokeJoin","PaintStyle","BlendMode","ClipOp","isRRect","isPathDef","processPath","processTransformProps","JsiNode","JsiDeclarationNode","enumKey","paintProps","JsiRenderNode","constructor","ctx","type","props","matrix","Skia","Matrix","onPropChange","setProps","paintCache","setProp","key","value","hasChanged","includes","identity","clipPath","undefined","clipRect","clipRRect","computeMatrix","computeClip","addChild","child","setInvalidate","insertChildBefore","before","clip","getPaintCtx","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","opacity","antiAlias","Color","_children","forEach","isColorFilter","cf","materialize","colorFilter","ColorFilter","MakeCompose","isShader","shader","isPathEffect","pe","pathEffect","PathEffect","isImageFilter","filter","imageFilter","ImageFilter","isMaskFilter","maskFilter","render","parentCtx","invertClip","layer","transform","canvas","parent","paint","paintCtx","concatPaint","copy","hasTransform","hasClip","shouldSave","op","Difference","Intersect","saveLayer","save","concat","renderNode","restore","setAlphaf","getAlphaf","currentOpacity","setShader","setColor","setStrokeWidth","setAntiAlias","setBlendMode","setColorFilter","setImageFilter","setMaskFilter","setPathEffect","setStrokeCap","setStrokeJoin","setStrokeMiter","setStyle"],"sources":["RenderNode.ts"],"sourcesContent":["import type {\n SkMatrix,\n SkRect,\n SkRRect,\n SkPath,\n SkPaint,\n} from \"../../skia/types\";\nimport {\n StrokeCap,\n StrokeJoin,\n PaintStyle,\n BlendMode,\n ClipOp,\n isRRect,\n} from \"../../skia/types\";\nimport type {\n RenderNode,\n GroupProps,\n DrawingContext,\n NodeType,\n Node,\n} from \"../types\";\n\nimport { isPathDef, processPath, processTransformProps } from \"./datatypes\";\nimport type { NodeContext } from \"./Node\";\nimport { JsiNode, JsiDeclarationNode } from \"./Node\";\nimport type { PaintContext } from \"./PaintContext\";\nimport { enumKey } from \"./datatypes/Enum\";\n\nconst paintProps = [\n \"color\",\n \"strokeWidth\",\n \"blendMode\",\n \"strokeCap\",\n \"strokeJoin\",\n \"strokeMiter\",\n \"style\",\n \"antiAlias\",\n \"opacity\",\n];\n\ninterface PaintCache {\n parent: SkPaint;\n child: SkPaint;\n}\n\nexport abstract class JsiRenderNode<P extends GroupProps>\n extends JsiNode<P>\n implements RenderNode<P>\n{\n paintCache: PaintCache | null = null;\n matrix: SkMatrix;\n clipRect?: SkRect;\n clipRRect?: SkRRect;\n clipPath?: SkPath;\n\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, type, props);\n this.matrix = this.Skia.Matrix();\n this.onPropChange();\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.onPropChange();\n this.paintCache = null;\n }\n\n setProp<K extends keyof P>(key: K, value: P[K]) {\n const hasChanged = super.setProp(key, value);\n if (hasChanged) {\n this.onPropChange();\n if (paintProps.includes(key as string)) {\n this.paintCache = null;\n }\n }\n return hasChanged;\n }\n\n protected onPropChange() {\n this.matrix.identity();\n this.clipPath = undefined;\n this.clipRect = undefined;\n this.clipRRect = undefined;\n this.computeMatrix();\n this.computeClip();\n }\n\n addChild(child: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.addChild(child);\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.insertChildBefore(child, before);\n }\n\n private computeClip() {\n const { clip } = this.props;\n if (clip) {\n if (isPathDef(clip)) {\n this.clipPath = processPath(this.Skia, clip);\n } else if (isRRect(clip)) {\n this.clipRRect = clip;\n } else {\n this.clipRect = clip;\n }\n }\n }\n\n private computeMatrix() {\n processTransformProps(this.matrix, this.props);\n }\n\n private getPaintCtx() {\n let ctx: PaintContext | undefined;\n const {\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n antiAlias,\n } = this.props;\n if (\n color !== undefined ||\n strokeWidth !== undefined ||\n blendMode !== undefined ||\n style !== undefined ||\n strokeJoin !== undefined ||\n strokeCap !== undefined ||\n strokeMiter !== undefined ||\n opacity !== undefined ||\n antiAlias !== undefined\n ) {\n ctx = { opacity: 1 };\n if (color !== undefined) {\n ctx.color = this.Skia.Color(color);\n }\n if (strokeWidth !== undefined) {\n ctx.strokeWidth = strokeWidth;\n }\n if (blendMode !== undefined) {\n ctx.blendMode = BlendMode[enumKey(blendMode)];\n }\n if (style !== undefined) {\n ctx.style = PaintStyle[enumKey(style)];\n }\n if (strokeJoin !== undefined) {\n ctx.strokeJoin = StrokeJoin[enumKey(strokeJoin)];\n }\n if (strokeCap !== undefined) {\n ctx.strokeCap = StrokeCap[enumKey(strokeCap)];\n }\n if (strokeMiter !== undefined) {\n ctx.strokeMiter = strokeMiter;\n }\n if (opacity !== undefined) {\n ctx.opacity = opacity;\n }\n if (antiAlias !== undefined) {\n ctx.antiAlias = antiAlias;\n }\n }\n this._children.forEach((child) => {\n if (child instanceof JsiDeclarationNode) {\n if (child.isColorFilter()) {\n ctx = ctx || {};\n const cf = child.materialize();\n ctx.colorFilter = ctx.colorFilter\n ? this.Skia.ColorFilter.MakeCompose(cf, ctx.colorFilter)\n : cf;\n } else if (child.isShader()) {\n ctx = ctx || {};\n const shader = child.materialize();\n ctx.shader = shader;\n } else if (child.isPathEffect()) {\n ctx = ctx || {};\n const pe = child.materialize();\n ctx.pathEffect = ctx.pathEffect\n ? this.Skia.PathEffect.MakeCompose(pe, ctx.pathEffect)\n : pe;\n } else if (child.isImageFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.imageFilter = ctx.imageFilter\n ? this.Skia.ImageFilter.MakeCompose(filter, ctx.imageFilter)\n : filter;\n } else if (child.isMaskFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.maskFilter = filter;\n }\n }\n });\n return ctx;\n }\n\n render(parentCtx: DrawingContext) {\n const { invertClip, layer, matrix, transform } = this.props;\n const { canvas } = parentCtx;\n\n if (\n this.paintCache === null ||\n this.paintCache.parent !== parentCtx.paint\n ) {\n const paintCtx = this.getPaintCtx();\n const child = paintCtx\n ? concatPaint(parentCtx.paint.copy(), paintCtx)\n : parentCtx.paint;\n this.paintCache = { parent: parentCtx.paint, child };\n }\n const paint = this.paintCache.child;\n // TODO: can we only recreate a new context here if needed?\n const ctx = { ...parentCtx, paint };\n const hasTransform = matrix !== undefined || transform !== undefined;\n const hasClip =\n this.clipRect !== undefined ||\n this.clipPath !== undefined ||\n this.clipRRect !== undefined;\n const shouldSave = hasTransform || hasClip || !!layer;\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n if (shouldSave) {\n if (layer) {\n if (typeof layer === \"boolean\") {\n canvas.saveLayer();\n } else {\n canvas.saveLayer(layer);\n }\n } else {\n canvas.save();\n }\n }\n\n if (this.matrix) {\n canvas.concat(this.matrix);\n }\n if (this.clipRect) {\n canvas.clipRect(this.clipRect, op, true);\n } else if (this.clipRRect) {\n canvas.clipRRect(this.clipRRect, op, true);\n } else if (this.clipPath) {\n canvas.clipPath(this.clipPath, op, true);\n }\n\n this.renderNode(ctx);\n\n if (shouldSave) {\n canvas.restore();\n }\n }\n\n abstract renderNode(ctx: DrawingContext): void;\n}\n\nconst concatPaint = (\n paint: SkPaint,\n {\n color,\n strokeWidth,\n shader,\n antiAlias,\n blendMode,\n colorFilter,\n imageFilter,\n maskFilter,\n pathEffect,\n opacity,\n strokeCap,\n strokeJoin,\n strokeMiter,\n style,\n }: PaintContext\n) => {\n if (opacity !== undefined) {\n paint.setAlphaf(paint.getAlphaf() * opacity);\n }\n if (color !== undefined) {\n const currentOpacity = paint.getAlphaf();\n paint.setShader(null);\n paint.setColor(color);\n paint.setAlphaf(currentOpacity * paint.getAlphaf());\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (shader !== undefined) {\n paint.setShader(shader);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(blendMode);\n }\n if (colorFilter !== undefined) {\n paint.setColorFilter(colorFilter);\n }\n if (imageFilter !== undefined) {\n paint.setImageFilter(imageFilter);\n }\n if (maskFilter !== undefined) {\n paint.setMaskFilter(maskFilter);\n }\n if (pathEffect !== undefined) {\n paint.setPathEffect(pathEffect);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(strokeCap);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(strokeJoin);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (style !== undefined) {\n paint.setStyle(style);\n }\n return paint;\n};\n"],"mappings":";;AAOA,SACEA,SADF,EAEEC,UAFF,EAGEC,UAHF,EAIEC,SAJF,EAKEC,MALF,EAMEC,OANF,QAOO,kBAPP;AAgBA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,qBAAjC,QAA8D,aAA9D;AAEA,SAASC,OAAT,EAAkBC,kBAAlB,QAA4C,QAA5C;AAEA,SAASC,OAAT,QAAwB,kBAAxB;AAEA,MAAMC,UAAU,GAAG,CACjB,OADiB,EAEjB,aAFiB,EAGjB,WAHiB,EAIjB,WAJiB,EAKjB,YALiB,EAMjB,aANiB,EAOjB,OAPiB,EAQjB,WARiB,EASjB,SATiB,CAAnB;AAiBA,OAAO,MAAeC,aAAf,SACGJ,OADH,CAGP;EAOEK,WAAW,CAACC,GAAD,EAAmBC,IAAnB,EAAmCC,KAAnC,EAA6C;IACtD,MAAMF,GAAN,EAAWC,IAAX,EAAiBC,KAAjB;;IADsD,oCANxB,IAMwB;;IAAA;;IAAA;;IAAA;;IAAA;;IAEtD,KAAKC,MAAL,GAAc,KAAKC,IAAL,CAAUC,MAAV,EAAd;IACA,KAAKC,YAAL;EACD;;EAEDC,QAAQ,CAACL,KAAD,EAAW;IACjB,MAAMK,QAAN,CAAeL,KAAf;IACA,KAAKI,YAAL;IACA,KAAKE,UAAL,GAAkB,IAAlB;EACD;;EAEDC,OAAO,CAAoBC,GAApB,EAA4BC,KAA5B,EAAyC;IAC9C,MAAMC,UAAU,GAAG,MAAMH,OAAN,CAAcC,GAAd,EAAmBC,KAAnB,CAAnB;;IACA,IAAIC,UAAJ,EAAgB;MACd,KAAKN,YAAL;;MACA,IAAIT,UAAU,CAACgB,QAAX,CAAoB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ApB;EACD;;EACD,IAAIjB,SAAS,KAAKjB,SAAlB,EAA6B;IAC3BiD,KAAK,CAAC2B,YAAN,CAAmB3D,SAAnB;EACD;;EACD,IAAID,UAAU,KAAKhB,SAAnB,EAA8B;IAC5BiD,KAAK,CAAC4B,aAAN,CAAoB7D,UAApB;EACD;;EACD,IAAIE,WAAW,KAAKlB,SAApB,EAA+B;IAC7BiD,KAAK,CAAC6B,cAAN,CAAqB5D,WAArB;EACD;;EACD,IAAIH,KAAK,KAAKf,SAAd,EAAyB;IACvBiD,KAAK,CAAC8B,QAAN,CAAehE,KAAf;EACD;;EACD,OAAOkC,KAAP;AACD,CAjED"}
|
1
|
+
{"version":3,"names":["ClipOp","isRRect","isPathDef","processPath","processTransformProps","JsiNode","JsiDeclarationNode","paintProps","JsiRenderNode","constructor","ctx","type","props","matrix","Skia","Matrix","onPropChange","setProps","setProp","key","value","hasChanged","includes","paintCache","identity","clipPath","undefined","clipRect","clipRRect","computeMatrix","computeClip","addChild","child","setInvalidate","insertChildBefore","before","clip","render","invertClip","layer","transform","canvas","parentPaint","paint","cache","parent","shouldRestore","saveAndConcat","hasTransform","hasClip","shouldSave","op","Difference","Intersect","saveLayer","save","concat","renderNode","restore"],"sources":["RenderNode.ts"],"sourcesContent":["import type {\n SkMatrix,\n SkRect,\n SkRRect,\n SkPath,\n SkPaint,\n} from \"../../skia/types\";\nimport { ClipOp, isRRect } from \"../../skia/types\";\nimport type {\n RenderNode,\n GroupProps,\n NodeType,\n Node,\n DrawingContext,\n} from \"../types\";\n\nimport { isPathDef, processPath, processTransformProps } from \"./datatypes\";\nimport type { NodeContext } from \"./Node\";\nimport { JsiNode, JsiDeclarationNode } from \"./Node\";\n\nconst paintProps = [\n \"color\",\n \"strokeWidth\",\n \"blendMode\",\n \"strokeCap\",\n \"strokeJoin\",\n \"strokeMiter\",\n \"style\",\n \"antiAlias\",\n \"opacity\",\n];\n\ninterface PaintCache {\n parent: SkPaint;\n child: SkPaint;\n}\n\nexport abstract class JsiRenderNode<P extends GroupProps>\n extends JsiNode<P>\n implements RenderNode<P>\n{\n paintCache: PaintCache | null = null;\n\n matrix: SkMatrix;\n clipRect?: SkRect;\n clipRRect?: SkRRect;\n clipPath?: SkPath;\n\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, type, props);\n this.matrix = this.Skia.Matrix();\n this.onPropChange();\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.onPropChange();\n }\n\n setProp<K extends keyof P>(key: K, value: P[K]) {\n const hasChanged = super.setProp(key, value);\n if (hasChanged) {\n this.onPropChange();\n if (paintProps.includes(key as string)) {\n this.paintCache = null;\n }\n }\n return hasChanged;\n }\n\n protected onPropChange() {\n this.matrix.identity();\n this.clipPath = undefined;\n this.clipRect = undefined;\n this.clipRRect = undefined;\n this.computeMatrix();\n this.computeClip();\n }\n\n addChild(child: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => {\n this.paintCache = null;\n });\n }\n super.addChild(child);\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => {\n this.paintCache = null;\n });\n }\n super.insertChildBefore(child, before);\n }\n\n private computeClip() {\n const { clip } = this.props;\n if (clip) {\n if (isPathDef(clip)) {\n this.clipPath = processPath(this.Skia, clip);\n } else if (isRRect(clip)) {\n this.clipRRect = clip;\n } else {\n this.clipRect = clip;\n }\n }\n }\n\n private computeMatrix() {\n processTransformProps(this.matrix, this.props);\n }\n\n render(ctx: DrawingContext) {\n const { invertClip, layer, matrix, transform } = this.props;\n const { canvas } = ctx;\n const parentPaint = ctx.paint;\n\n const cache =\n this.paintCache !== null && this.paintCache.parent === ctx.paint\n ? this.paintCache.child\n : undefined;\n const shouldRestore = ctx.saveAndConcat(this, cache);\n\n const hasTransform = matrix !== undefined || transform !== undefined;\n const hasClip =\n this.clipRect !== undefined ||\n this.clipPath !== undefined ||\n this.clipRRect !== undefined;\n const shouldSave = hasTransform || hasClip || !!layer;\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n if (shouldSave) {\n if (layer) {\n if (typeof layer === \"boolean\") {\n canvas.saveLayer();\n } else {\n canvas.saveLayer(layer);\n }\n } else {\n canvas.save();\n }\n }\n\n if (this.matrix) {\n canvas.concat(this.matrix);\n }\n if (this.clipRect) {\n canvas.clipRect(this.clipRect, op, true);\n } else if (this.clipRRect) {\n canvas.clipRRect(this.clipRRect, op, true);\n } else if (this.clipPath) {\n canvas.clipPath(this.clipPath, op, true);\n }\n\n this.renderNode(ctx);\n\n if (shouldSave) {\n canvas.restore();\n }\n if (shouldRestore) {\n this.paintCache = {\n parent: parentPaint,\n child: ctx.paint,\n };\n ctx.restore();\n }\n }\n\n abstract renderNode(ctx: DrawingContext): void;\n}\n"],"mappings":";;AAOA,SAASA,MAAT,EAAiBC,OAAjB,QAAgC,kBAAhC;AASA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,qBAAjC,QAA8D,aAA9D;AAEA,SAASC,OAAT,EAAkBC,kBAAlB,QAA4C,QAA5C;AAEA,MAAMC,UAAU,GAAG,CACjB,OADiB,EAEjB,aAFiB,EAGjB,WAHiB,EAIjB,WAJiB,EAKjB,YALiB,EAMjB,aANiB,EAOjB,OAPiB,EAQjB,WARiB,EASjB,SATiB,CAAnB;AAiBA,OAAO,MAAeC,aAAf,SACGH,OADH,CAGP;EAQEI,WAAW,CAACC,GAAD,EAAmBC,IAAnB,EAAmCC,KAAnC,EAA6C;IACtD,MAAMF,GAAN,EAAWC,IAAX,EAAiBC,KAAjB;;IADsD,oCAPxB,IAOwB;;IAAA;;IAAA;;IAAA;;IAAA;;IAEtD,KAAKC,MAAL,GAAc,KAAKC,IAAL,CAAUC,MAAV,EAAd;IACA,KAAKC,YAAL;EACD;;EAEDC,QAAQ,CAACL,KAAD,EAAW;IACjB,MAAMK,QAAN,CAAeL,KAAf;IACA,KAAKI,YAAL;EACD;;EAEDE,OAAO,CAAoBC,GAApB,EAA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C,MAAT,EAAiB;MACf4B,MAAM,CAACe,MAAP,CAAc,KAAK3C,MAAnB;IACD;;IACD,IAAI,KAAKc,QAAT,EAAmB;MACjBc,MAAM,CAACd,QAAP,CAAgB,KAAKA,QAArB,EAA+BwB,EAA/B,EAAmC,IAAnC;IACD,CAFD,MAEO,IAAI,KAAKvB,SAAT,EAAoB;MACzBa,MAAM,CAACb,SAAP,CAAiB,KAAKA,SAAtB,EAAiCuB,EAAjC,EAAqC,IAArC;IACD,CAFM,MAEA,IAAI,KAAK1B,QAAT,EAAmB;MACxBgB,MAAM,CAAChB,QAAP,CAAgB,KAAKA,QAArB,EAA+B0B,EAA/B,EAAmC,IAAnC;IACD;;IAED,KAAKM,UAAL,CAAgB/C,GAAhB;;IAEA,IAAIwC,UAAJ,EAAgB;MACdT,MAAM,CAACiB,OAAP;IACD;;IACD,IAAIZ,aAAJ,EAAmB;MACjB,KAAKvB,UAAL,GAAkB;QAChBsB,MAAM,EAAEH,WADQ;QAEhBV,KAAK,EAAEtB,GAAG,CAACiC;MAFK,CAAlB;MAIAjC,GAAG,CAACgD,OAAJ;IACD;EACF;;AA/HH"}
|
@@ -4,5 +4,5 @@ import type { NodeContext } from "../Node";
|
|
4
4
|
export declare class BackdropFilterNode extends JsiDrawingNode<ChildrenProps, null> {
|
5
5
|
constructor(ctx: NodeContext, props: ChildrenProps);
|
6
6
|
protected deriveProps(): null;
|
7
|
-
draw({ canvas }: DrawingContext): void;
|
7
|
+
draw({ canvas, declarationCtx }: DrawingContext): void;
|
8
8
|
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { isColorFilter } from "../../../skia/types";
|
2
1
|
import { NodeType } from "../../types";
|
3
2
|
import { JsiDrawingNode } from "../DrawingNode";
|
4
3
|
import { JsiDeclarationNode } from "../Node";
|
@@ -13,11 +12,31 @@ export class BackdropFilterNode extends JsiDrawingNode {
|
|
13
12
|
|
14
13
|
draw(_ref) {
|
15
14
|
let {
|
16
|
-
canvas
|
15
|
+
canvas,
|
16
|
+
declarationCtx
|
17
17
|
} = _ref;
|
18
18
|
const child = this._children[0];
|
19
|
-
|
20
|
-
|
19
|
+
let imageFilter = null;
|
20
|
+
|
21
|
+
if (child instanceof JsiDeclarationNode) {
|
22
|
+
declarationCtx.save();
|
23
|
+
child.decorate(declarationCtx);
|
24
|
+
const imgf = declarationCtx.imageFilters.pop();
|
25
|
+
|
26
|
+
if (imgf) {
|
27
|
+
imageFilter = imgf;
|
28
|
+
} else {
|
29
|
+
const cf = declarationCtx.colorFilters.pop();
|
30
|
+
|
31
|
+
if (cf) {
|
32
|
+
imageFilter = this.Skia.ImageFilter.MakeColorFilter(cf, null);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
declarationCtx.restore();
|
37
|
+
}
|
38
|
+
|
39
|
+
canvas.saveLayer(undefined, null, imageFilter);
|
21
40
|
canvas.restore();
|
22
41
|
}
|
23
42
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["NodeType","JsiDrawingNode","JsiDeclarationNode","BackdropFilterNode","constructor","ctx","props","BackdropFilter","deriveProps","draw","canvas","declarationCtx","child","_children","imageFilter","save","decorate","imgf","imageFilters","pop","cf","colorFilters","Skia","ImageFilter","MakeColorFilter","restore","saveLayer","undefined"],"sources":["BackdropFilterNode.ts"],"sourcesContent":["import type { ChildrenProps, DrawingContext } from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type { SkImageFilter } from \"../../../skia/types/ImageFilter/ImageFilter\";\n\nexport class BackdropFilterNode extends JsiDrawingNode<ChildrenProps, null> {\n constructor(ctx: NodeContext, props: ChildrenProps) {\n super(ctx, NodeType.BackdropFilter, props);\n }\n\n protected deriveProps() {\n return null;\n }\n\n draw({ canvas, declarationCtx }: DrawingContext) {\n const child = this._children[0];\n let imageFilter: SkImageFilter | null = null;\n if (child instanceof JsiDeclarationNode) {\n declarationCtx.save();\n child.decorate(declarationCtx);\n const imgf = declarationCtx.imageFilters.pop();\n if (imgf) {\n imageFilter = imgf;\n } else {\n const cf = declarationCtx.colorFilters.pop();\n if (cf) {\n imageFilter = this.Skia.ImageFilter.MakeColorFilter(cf, null);\n }\n }\n declarationCtx.restore();\n }\n canvas.saveLayer(undefined, null, imageFilter);\n canvas.restore();\n }\n}\n"],"mappings":"AACA,SAASA,QAAT,QAAyB,aAAzB;AACA,SAASC,cAAT,QAA+B,gBAA/B;AAEA,SAASC,kBAAT,QAAmC,SAAnC;AAGA,OAAO,MAAMC,kBAAN,SAAiCF,cAAjC,CAAqE;EAC1EG,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAyC;IAClD,MAAMD,GAAN,EAAWL,QAAQ,CAACO,cAApB,EAAoCD,KAApC;EACD;;EAESE,WAAW,GAAG;IACtB,OAAO,IAAP;EACD;;EAEDC,IAAI,OAA6C;IAAA,IAA5C;MAAEC,MAAF;MAAUC;IAAV,CAA4C;IAC/C,MAAMC,KAAK,GAAG,KAAKC,SAAL,CAAe,CAAf,CAAd;IACA,IAAIC,WAAiC,GAAG,IAAxC;;IACA,IAAIF,KAAK,YAAYV,kBAArB,EAAyC;MACvCS,cAAc,CAACI,IAAf;MACAH,KAAK,CAACI,QAAN,CAAeL,cAAf;MACA,MAAMM,IAAI,GAAGN,cAAc,CAACO,YAAf,CAA4BC,GAA5B,EAAb;;MACA,IAAIF,IAAJ,EAAU;QACRH,WAAW,GAAGG,IAAd;MACD,CAFD,MAEO;QACL,MAAMG,EAAE,GAAGT,cAAc,CAACU,YAAf,CAA4BF,GAA5B,EAAX;;QACA,IAAIC,EAAJ,EAAQ;UACNN,WAAW,GAAG,KAAKQ,IAAL,CAAUC,WAAV,CAAsBC,eAAtB,CAAsCJ,EAAtC,EAA0C,IAA1C,CAAd;QACD;MACF;;MACDT,cAAc,CAACc,OAAf;IACD;;IACDf,MAAM,CAACgB,SAAP,CAAiBC,SAAjB,EAA4B,IAA5B,EAAkCb,WAAlC;IACAJ,MAAM,CAACe,OAAP;EACD;;AA5ByE"}
|
@@ -3,8 +3,10 @@ import type { BoxShadowProps, BoxProps } from "../../types/Drawings";
|
|
3
3
|
import type { NodeContext } from "../Node";
|
4
4
|
import { JsiDeclarationNode } from "../Node";
|
5
5
|
import { JsiRenderNode } from "../RenderNode";
|
6
|
-
|
6
|
+
import type { DeclarationContext } from "../../types/DeclarationContext";
|
7
|
+
export declare class BoxShadowNode extends JsiDeclarationNode<BoxShadowProps> {
|
7
8
|
constructor(ctx: NodeContext, props: BoxShadowProps);
|
9
|
+
decorate(_ctx: DeclarationContext): void;
|
8
10
|
materialize(): BoxShadowProps;
|
9
11
|
}
|
10
12
|
export declare class BoxNode extends JsiRenderNode<BoxProps> {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["BlurStyle","ClipOp","isRRect","DeclarationType","NodeType","JsiDeclarationNode","JsiRenderNode","inflate","Skia","box","dx","dy","tx","ty","RRectXY","XYWHRect","rect","x","y","width","height","rx","ry","deflate","BoxShadowNode","constructor","ctx","props","Unknown","BoxShadow","materialize","BoxNode","Box","renderNode","canvas","paint","defaultBox","opacity","getAlphaf","shadows","_children","map","node","filter","n","shadow","inner","color","blur","spread","lPaint","Paint","setColor","Color","setAlphaf","setMaskFilter","MaskFilter","MakeBlur","Normal","drawRRect","delta","Point","Math","abs","save","clipRRect","Intersect","outer","drawDRRect","restore"],"sources":["Box.ts"],"sourcesContent":["import type { SkRRect, Skia } from \"../../../skia/types\";\nimport { BlurStyle, ClipOp, isRRect } from \"../../../skia/types\";\nimport type { DrawingContext } from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport type { BoxShadowProps, BoxProps } from \"../../types/Drawings\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport { JsiRenderNode } from \"../RenderNode\";\n\nconst inflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) =>\n Skia.RRectXY(\n Skia.XYWHRect(\n box.rect.x - dx + tx,\n box.rect.y - dy + ty,\n box.rect.width + 2 * dx,\n box.rect.height + 2 * dy\n ),\n box.rx + dx,\n box.ry + dy\n );\n\nconst deflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) => inflate(Skia, box, -dx, -dy, tx, ty);\n\nexport class BoxShadowNode extends JsiDeclarationNode
|
1
|
+
{"version":3,"names":["BlurStyle","ClipOp","isRRect","DeclarationType","NodeType","JsiDeclarationNode","JsiRenderNode","inflate","Skia","box","dx","dy","tx","ty","RRectXY","XYWHRect","rect","x","y","width","height","rx","ry","deflate","BoxShadowNode","constructor","ctx","props","Unknown","BoxShadow","decorate","_ctx","materialize","BoxNode","Box","renderNode","canvas","paint","defaultBox","opacity","getAlphaf","shadows","_children","map","node","filter","n","shadow","inner","color","blur","spread","lPaint","Paint","setColor","Color","setAlphaf","setMaskFilter","MaskFilter","MakeBlur","Normal","drawRRect","delta","Point","Math","abs","save","clipRRect","Intersect","outer","drawDRRect","restore"],"sources":["Box.ts"],"sourcesContent":["import type { SkRRect, Skia } from \"../../../skia/types\";\nimport { BlurStyle, ClipOp, isRRect } from \"../../../skia/types\";\nimport type { DrawingContext } from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport type { BoxShadowProps, BoxProps } from \"../../types/Drawings\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport { JsiRenderNode } from \"../RenderNode\";\nimport type { DeclarationContext } from \"../../types/DeclarationContext\";\n\nconst inflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) =>\n Skia.RRectXY(\n Skia.XYWHRect(\n box.rect.x - dx + tx,\n box.rect.y - dy + ty,\n box.rect.width + 2 * dx,\n box.rect.height + 2 * dy\n ),\n box.rx + dx,\n box.ry + dy\n );\n\nconst deflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) => inflate(Skia, box, -dx, -dy, tx, ty);\n\nexport class BoxShadowNode extends JsiDeclarationNode<BoxShadowProps> {\n constructor(ctx: NodeContext, props: BoxShadowProps) {\n super(ctx, DeclarationType.Unknown, NodeType.BoxShadow, props);\n }\n\n decorate(_ctx: DeclarationContext) {\n // do nothing\n }\n\n materialize() {\n return this.props;\n }\n}\n\nexport class BoxNode extends JsiRenderNode<BoxProps> {\n constructor(ctx: NodeContext, props: BoxProps) {\n super(ctx, NodeType.Box, props);\n }\n\n renderNode({ canvas, paint }: DrawingContext) {\n const { box: defaultBox } = this.props;\n const opacity = paint.getAlphaf();\n const box = isRRect(defaultBox)\n ? defaultBox\n : this.Skia.RRectXY(defaultBox, 0, 0);\n const shadows = this._children\n .map((node) => {\n if (node instanceof BoxShadowNode) {\n return node.materialize();\n }\n return null;\n })\n .filter((n): n is BoxShadowProps => n !== null);\n shadows\n .filter((shadow) => !shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const lPaint = this.Skia.Paint();\n lPaint.setColor(this.Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n lPaint.setMaskFilter(\n this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n canvas.drawRRect(\n inflate(this.Skia, box, spread, spread, dx, dy),\n lPaint\n );\n });\n\n canvas.drawRRect(box, paint);\n\n shadows\n .filter((shadow) => shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const delta = this.Skia.Point(10 + Math.abs(dx), 10 + Math.abs(dy));\n canvas.save();\n canvas.clipRRect(box, ClipOp.Intersect, false);\n const lPaint = this.Skia.Paint();\n lPaint.setColor(this.Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n\n lPaint.setMaskFilter(\n this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n const inner = deflate(this.Skia, box, spread, spread, dx, dy);\n const outer = inflate(this.Skia, box, delta.x, delta.y);\n canvas.drawDRRect(outer, inner, lPaint);\n canvas.restore();\n });\n }\n}\n"],"mappings":"AACA,SAASA,SAAT,EAAoBC,MAApB,EAA4BC,OAA5B,QAA2C,qBAA3C;AAEA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,aAA1C;AAGA,SAASC,kBAAT,QAAmC,SAAnC;AACA,SAASC,aAAT,QAA8B,eAA9B;;AAGA,MAAMC,OAAO,GAAG,UACdC,IADc,EAEdC,GAFc,EAGdC,EAHc,EAIdC,EAJc;EAAA,IAKdC,EALc,uEAKT,CALS;EAAA,IAMdC,EANc,uEAMT,CANS;EAAA,OAQdL,IAAI,CAACM,OAAL,CACEN,IAAI,CAACO,QAAL,CACEN,GAAG,CAACO,IAAJ,CAASC,CAAT,GAAaP,EAAb,GAAkBE,EADpB,EAEEH,GAAG,CAACO,IAAJ,CAASE,CAAT,GAAaP,EAAb,GAAkBE,EAFpB,EAGEJ,GAAG,CAACO,IAAJ,CAASG,KAAT,GAAiB,IAAIT,EAHvB,EAIED,GAAG,CAACO,IAAJ,CAASI,MAAT,GAAkB,IAAIT,EAJxB,CADF,EAOEF,GAAG,CAACY,EAAJ,GAASX,EAPX,EAQED,GAAG,CAACa,EAAJ,GAASX,EARX,CARc;AAAA,CAAhB;;AAmBA,MAAMY,OAAO,GAAG,UACdf,IADc,EAEdC,GAFc,EAGdC,EAHc,EAIdC,EAJc;EAAA,IAKdC,EALc,uEAKT,CALS;EAAA,IAMdC,EANc,uEAMT,CANS;EAAA,OAOXN,OAAO,CAACC,IAAD,EAAOC,GAAP,EAAY,CAACC,EAAb,EAAiB,CAACC,EAAlB,EAAsBC,EAAtB,EAA0BC,EAA1B,CAPI;AAAA,CAAhB;;AASA,OAAO,MAAMW,aAAN,SAA4BnB,kBAA5B,CAA+D;EACpEoB,WAA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CAAgBN,KAAhB,CAAhB;MACAG,MAAM,CAACI,SAAP,CAAiBnB,KAAK,CAACG,SAAN,KAAoBD,OAArC;MAEAa,MAAM,CAACK,aAAP,CACE,KAAKjD,IAAL,CAAUkD,UAAV,CAAqBC,QAArB,CAA8B3D,SAAS,CAAC4D,MAAxC,EAAgDV,IAAhD,EAAsD,IAAtD,CADF;MAGA,MAAMF,KAAK,GAAGzB,OAAO,CAAC,KAAKf,IAAN,EAAYC,GAAZ,EAAiB0C,MAAjB,EAAyBA,MAAzB,EAAiCzC,EAAjC,EAAqCC,EAArC,CAArB;MACA,MAAM0D,KAAK,GAAG9D,OAAO,CAAC,KAAKC,IAAN,EAAYC,GAAZ,EAAiBqD,KAAK,CAAC7C,CAAvB,EAA0B6C,KAAK,CAAC5C,CAAhC,CAArB;MACAkB,MAAM,CAACkC,UAAP,CAAkBD,KAAlB,EAAyBrB,KAAzB,EAAgCI,MAAhC;MACAhB,MAAM,CAACmC,OAAP;IACD,CAlBH;EAmBD;;AAxDkD"}
|
@@ -1,12 +1,8 @@
|
|
1
1
|
import type { BlendProps } from "../../types/ImageFilters";
|
2
|
-
import type { SkShader, SkImageFilter } from "../../../skia/types";
|
3
2
|
import type { NodeContext } from "../Node";
|
4
3
|
import { JsiDeclarationNode } from "../Node";
|
5
|
-
import type {
|
6
|
-
export declare class BlendNode extends JsiDeclarationNode<BlendProps
|
4
|
+
import type { DeclarationContext } from "../../types/DeclarationContext";
|
5
|
+
export declare class BlendNode extends JsiDeclarationNode<BlendProps> {
|
7
6
|
constructor(ctx: NodeContext, props: BlendProps);
|
8
|
-
|
9
|
-
addChild(child: Node<unknown>): void;
|
10
|
-
insertChildBefore(child: Node<unknown>, before: Node<unknown>): void;
|
11
|
-
materialize(): SkImageFilter | SkShader;
|
7
|
+
decorate(ctx: DeclarationContext): void;
|
12
8
|
}
|