@shopify/react-native-skia 0.1.172 → 0.1.173
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +1 -0
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +5 -0
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +106 -5
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +3 -1
- package/cpp/api/JsiSkSurface.h +7 -1
- package/cpp/api/JsiSkSurfaceFactory.h +15 -2
- package/cpp/rnskia/RNSkDomView.cpp +2 -4
- package/cpp/rnskia/RNSkJsView.cpp +3 -0
- package/cpp/rnskia/RNSkPictureView.h +3 -0
- package/cpp/rnskia/RNSkPlatformContext.h +9 -0
- package/cpp/rnskia/dom/JsiDomApi.h +1 -0
- package/cpp/rnskia/dom/base/ConcatablePaint.cpp +117 -0
- package/cpp/rnskia/dom/base/ConcatablePaint.h +49 -0
- package/cpp/rnskia/dom/base/Declaration.h +88 -0
- package/cpp/rnskia/dom/base/DeclarationContext.h +79 -0
- package/cpp/rnskia/dom/base/DerivedNodeProp.h +25 -9
- package/cpp/rnskia/dom/base/DrawingContext.cpp +32 -186
- package/cpp/rnskia/dom/base/DrawingContext.h +45 -64
- package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +35 -106
- package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +28 -9
- package/cpp/rnskia/dom/base/JsiDomNode.h +46 -17
- package/cpp/rnskia/dom/base/JsiDomRenderNode.h +81 -67
- package/cpp/rnskia/dom/base/NodeProp.h +12 -2
- package/cpp/rnskia/dom/base/NodePropsContainer.h +15 -16
- package/cpp/rnskia/dom/nodes/JsiBackdropFilterNode.h +22 -11
- package/cpp/rnskia/dom/nodes/JsiBlendNode.h +43 -59
- package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +16 -17
- package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +6 -5
- package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +45 -69
- package/cpp/rnskia/dom/nodes/JsiGroupNode.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +121 -161
- package/cpp/rnskia/dom/nodes/JsiImageNode.h +1 -0
- package/cpp/rnskia/dom/nodes/JsiLayerNode.h +28 -18
- package/cpp/rnskia/dom/nodes/JsiPaintNode.h +82 -45
- package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +68 -101
- package/cpp/rnskia/dom/nodes/JsiPathNode.h +3 -2
- package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +150 -207
- package/cpp/rnskia/dom/props/BezierProps.h +4 -2
- package/cpp/rnskia/dom/props/BlendModeProp.h +4 -2
- package/cpp/rnskia/dom/props/BoxShadowProps.h +8 -10
- package/cpp/rnskia/dom/props/CircleProp.h +6 -5
- package/cpp/rnskia/dom/props/ClipProp.h +6 -4
- package/cpp/rnskia/dom/props/ColorProp.h +8 -4
- package/cpp/rnskia/dom/props/DrawingProp.h +5 -3
- package/cpp/rnskia/dom/props/FontProp.h +4 -2
- package/cpp/rnskia/dom/props/GlyphsProp.h +4 -2
- package/cpp/rnskia/dom/props/ImageProps.h +9 -6
- package/cpp/rnskia/dom/props/LayerProp.h +6 -4
- package/cpp/rnskia/dom/props/MatrixProp.h +4 -2
- package/cpp/rnskia/dom/props/NumbersProp.h +8 -4
- package/cpp/rnskia/dom/props/PaintProps.h +55 -92
- package/cpp/rnskia/dom/props/PathProp.h +4 -2
- package/cpp/rnskia/dom/props/PictureProp.h +4 -2
- package/cpp/rnskia/dom/props/PointProp.h +4 -2
- package/cpp/rnskia/dom/props/PointsProp.h +8 -4
- package/cpp/rnskia/dom/props/RRectProp.h +23 -16
- package/cpp/rnskia/dom/props/RadiusProp.h +4 -2
- package/cpp/rnskia/dom/props/RectProp.h +18 -12
- package/cpp/rnskia/dom/props/StrokeProps.h +8 -4
- package/cpp/rnskia/dom/props/SvgProp.h +4 -2
- package/cpp/rnskia/dom/props/TextBlobProp.h +10 -8
- package/cpp/rnskia/dom/props/TileModeProp.h +4 -2
- package/cpp/rnskia/dom/props/TransformProp.h +4 -2
- package/cpp/rnskia/dom/props/TransformsProps.h +5 -7
- package/cpp/rnskia/dom/props/UniformsProp.h +4 -2
- package/cpp/rnskia/dom/props/VertexModeProp.h +4 -2
- package/cpp/rnskia/dom/props/VerticesProps.h +7 -11
- package/ios/RNSkia-iOS/DisplayLink.mm +22 -24
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +53 -50
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +2 -0
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +38 -25
- package/ios/RNSkia-iOS/SkiaDomViewManager.mm +17 -17
- package/ios/RNSkia-iOS/SkiaDrawViewManager.mm +17 -17
- package/ios/RNSkia-iOS/SkiaManager.mm +12 -10
- package/ios/RNSkia-iOS/SkiaMetalRenderer.h +5 -0
- package/ios/RNSkia-iOS/SkiaMetalRenderer.mm +53 -0
- package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +17 -17
- package/ios/RNSkia-iOS/SkiaUIView.mm +63 -53
- package/ios/RNSkiaModule.mm +5 -7
- package/lib/commonjs/dom/nodes/DrawingNode.js +5 -1
- package/lib/commonjs/dom/nodes/DrawingNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +33 -34
- package/lib/commonjs/dom/nodes/LayerNode.js +13 -6
- package/lib/commonjs/dom/nodes/LayerNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/Node.d.ts +6 -11
- package/lib/commonjs/dom/nodes/Node.js +8 -26
- package/lib/commonjs/dom/nodes/Node.js.map +1 -1
- package/lib/commonjs/dom/nodes/PaintContext.js.map +1 -1
- package/lib/commonjs/dom/nodes/PaintNode.d.ts +3 -3
- package/lib/commonjs/dom/nodes/PaintNode.js +32 -15
- package/lib/commonjs/dom/nodes/PaintNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/RenderNode.d.ts +2 -3
- package/lib/commonjs/dom/nodes/RenderNode.js +19 -187
- package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
- package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.js +25 -7
- package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/Box.d.ts +3 -1
- package/lib/commonjs/dom/nodes/drawings/Box.js +3 -0
- package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/BlendNode.d.ts +3 -7
- package/lib/commonjs/dom/nodes/paint/BlendNode.js +16 -47
- package/lib/commonjs/dom/nodes/paint/BlendNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/ColorFilters.d.ts +10 -11
- package/lib/commonjs/dom/nodes/paint/ColorFilters.js +29 -43
- package/lib/commonjs/dom/nodes/paint/ColorFilters.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/ImageFilters.d.ts +11 -11
- package/lib/commonjs/dom/nodes/paint/ImageFilters.js +45 -42
- package/lib/commonjs/dom/nodes/paint/ImageFilters.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/MaskFilters.d.ts +3 -3
- package/lib/commonjs/dom/nodes/paint/MaskFilters.js +3 -2
- package/lib/commonjs/dom/nodes/paint/MaskFilters.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/PathEffects.d.ts +15 -18
- package/lib/commonjs/dom/nodes/paint/PathEffects.js +30 -72
- package/lib/commonjs/dom/nodes/paint/PathEffects.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/Shaders.d.ts +11 -12
- package/lib/commonjs/dom/nodes/paint/Shaders.js +28 -18
- package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/commonjs/dom/types/DeclarationContext.d.ts +29 -0
- package/lib/commonjs/dom/types/DeclarationContext.js +118 -0
- package/lib/commonjs/dom/types/DeclarationContext.js.map +1 -0
- package/lib/commonjs/dom/types/DrawingContext.d.ts +18 -1
- package/lib/commonjs/dom/types/DrawingContext.js +330 -0
- package/lib/commonjs/dom/types/DrawingContext.js.map +1 -1
- package/lib/commonjs/dom/types/Node.d.ts +4 -10
- package/lib/commonjs/dom/types/Node.js.map +1 -1
- package/lib/commonjs/dom/types/SkDOM.d.ts +22 -23
- package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
- package/lib/commonjs/dom/types/index.d.ts +1 -0
- package/lib/commonjs/dom/types/index.js +13 -0
- package/lib/commonjs/dom/types/index.js.map +1 -1
- package/lib/commonjs/index.d.ts +1 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +3 -3
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/DrawingContext.d.ts +4 -3
- package/lib/commonjs/renderer/DrawingContext.js.map +1 -1
- package/lib/commonjs/renderer/HostComponents.d.ts +35 -35
- package/lib/commonjs/renderer/HostComponents.js.map +1 -1
- package/lib/commonjs/renderer/HostConfig.js +1 -0
- package/lib/commonjs/renderer/HostConfig.js.map +1 -1
- package/lib/commonjs/renderer/Offscreen.d.ts +2 -0
- package/lib/commonjs/renderer/Offscreen.js +31 -0
- package/lib/commonjs/renderer/Offscreen.js.map +1 -0
- package/lib/commonjs/renderer/Reconciler.js +0 -1
- package/lib/commonjs/renderer/Reconciler.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/Surface.d.ts +4 -0
- package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +6 -0
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkSurface.js +4 -0
- package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +21 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/commonjs/views/SkiaBaseWebView.js +6 -4
- package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
- package/lib/commonjs/views/SkiaDomView.web.js +3 -14
- package/lib/commonjs/views/SkiaDomView.web.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +0 -7
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/commonjs/views/SkiaView.web.js +0 -7
- package/lib/commonjs/views/SkiaView.web.js.map +1 -1
- package/lib/module/dom/nodes/DrawingNode.js +5 -1
- package/lib/module/dom/nodes/DrawingNode.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.d.ts +33 -34
- package/lib/module/dom/nodes/LayerNode.js +13 -7
- package/lib/module/dom/nodes/LayerNode.js.map +1 -1
- package/lib/module/dom/nodes/Node.d.ts +6 -11
- package/lib/module/dom/nodes/Node.js +8 -25
- package/lib/module/dom/nodes/Node.js.map +1 -1
- package/lib/module/dom/nodes/PaintContext.js.map +1 -1
- package/lib/module/dom/nodes/PaintNode.d.ts +3 -3
- package/lib/module/dom/nodes/PaintNode.js +32 -15
- package/lib/module/dom/nodes/PaintNode.js.map +1 -1
- package/lib/module/dom/nodes/RenderNode.d.ts +2 -3
- package/lib/module/dom/nodes/RenderNode.js +20 -187
- package/lib/module/dom/nodes/RenderNode.js.map +1 -1
- package/lib/module/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
- package/lib/module/dom/nodes/drawings/BackdropFilterNode.js +23 -4
- package/lib/module/dom/nodes/drawings/BackdropFilterNode.js.map +1 -1
- package/lib/module/dom/nodes/drawings/Box.d.ts +3 -1
- package/lib/module/dom/nodes/drawings/Box.js +3 -0
- package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
- package/lib/module/dom/nodes/paint/BlendNode.d.ts +3 -7
- package/lib/module/dom/nodes/paint/BlendNode.js +15 -46
- package/lib/module/dom/nodes/paint/BlendNode.js.map +1 -1
- package/lib/module/dom/nodes/paint/ColorFilters.d.ts +10 -11
- package/lib/module/dom/nodes/paint/ColorFilters.js +29 -43
- package/lib/module/dom/nodes/paint/ColorFilters.js.map +1 -1
- package/lib/module/dom/nodes/paint/ImageFilters.d.ts +11 -11
- package/lib/module/dom/nodes/paint/ImageFilters.js +48 -41
- package/lib/module/dom/nodes/paint/ImageFilters.js.map +1 -1
- package/lib/module/dom/nodes/paint/MaskFilters.d.ts +3 -3
- package/lib/module/dom/nodes/paint/MaskFilters.js +3 -2
- package/lib/module/dom/nodes/paint/MaskFilters.js.map +1 -1
- package/lib/module/dom/nodes/paint/PathEffects.d.ts +15 -18
- package/lib/module/dom/nodes/paint/PathEffects.js +29 -72
- package/lib/module/dom/nodes/paint/PathEffects.js.map +1 -1
- package/lib/module/dom/nodes/paint/Shaders.d.ts +11 -12
- package/lib/module/dom/nodes/paint/Shaders.js +28 -18
- package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/module/dom/types/DeclarationContext.d.ts +29 -0
- package/lib/module/dom/types/DeclarationContext.js +107 -0
- package/lib/module/dom/types/DeclarationContext.js.map +1 -0
- package/lib/module/dom/types/DrawingContext.d.ts +18 -1
- package/lib/module/dom/types/DrawingContext.js +322 -1
- package/lib/module/dom/types/DrawingContext.js.map +1 -1
- package/lib/module/dom/types/Node.d.ts +4 -10
- package/lib/module/dom/types/Node.js.map +1 -1
- package/lib/module/dom/types/SkDOM.d.ts +22 -23
- package/lib/module/dom/types/SkDOM.js.map +1 -1
- package/lib/module/dom/types/index.d.ts +1 -0
- package/lib/module/dom/types/index.js +1 -0
- package/lib/module/dom/types/index.js.map +1 -1
- package/lib/module/index.d.ts +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +3 -3
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/DrawingContext.d.ts +4 -3
- package/lib/module/renderer/DrawingContext.js.map +1 -1
- package/lib/module/renderer/HostComponents.d.ts +35 -35
- package/lib/module/renderer/HostComponents.js.map +1 -1
- package/lib/module/renderer/HostConfig.js +1 -0
- package/lib/module/renderer/HostConfig.js.map +1 -1
- package/lib/module/renderer/Offscreen.d.ts +2 -0
- package/lib/module/renderer/Offscreen.js +19 -0
- package/lib/module/renderer/Offscreen.js.map +1 -0
- package/lib/module/renderer/Reconciler.js +0 -1
- package/lib/module/renderer/Reconciler.js.map +1 -1
- package/lib/module/skia/types/Surface/Surface.d.ts +4 -0
- package/lib/module/skia/types/Surface/Surface.js.map +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +6 -0
- package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/module/skia/web/JsiSkSurface.js +4 -0
- package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js +21 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/module/views/SkiaBaseWebView.js +6 -4
- package/lib/module/views/SkiaBaseWebView.js.map +1 -1
- package/lib/module/views/SkiaDomView.web.js +2 -11
- package/lib/module/views/SkiaDomView.web.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +0 -5
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/views/SkiaView.web.js +0 -5
- package/lib/module/views/SkiaView.web.js.map +1 -1
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +33 -34
- package/lib/typescript/src/dom/nodes/Node.d.ts +6 -11
- package/lib/typescript/src/dom/nodes/PaintNode.d.ts +3 -3
- package/lib/typescript/src/dom/nodes/RenderNode.d.ts +2 -3
- package/lib/typescript/src/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
- package/lib/typescript/src/dom/nodes/drawings/Box.d.ts +3 -1
- package/lib/typescript/src/dom/nodes/paint/BlendNode.d.ts +3 -7
- package/lib/typescript/src/dom/nodes/paint/ColorFilters.d.ts +10 -11
- package/lib/typescript/src/dom/nodes/paint/ImageFilters.d.ts +11 -11
- package/lib/typescript/src/dom/nodes/paint/MaskFilters.d.ts +3 -3
- package/lib/typescript/src/dom/nodes/paint/PathEffects.d.ts +15 -18
- package/lib/typescript/src/dom/nodes/paint/Shaders.d.ts +11 -12
- package/lib/typescript/src/dom/types/DeclarationContext.d.ts +29 -0
- package/lib/typescript/src/dom/types/DrawingContext.d.ts +18 -1
- package/lib/typescript/src/dom/types/Node.d.ts +4 -10
- package/lib/typescript/src/dom/types/SkDOM.d.ts +22 -23
- package/lib/typescript/src/dom/types/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/renderer/DrawingContext.d.ts +4 -3
- package/lib/typescript/src/renderer/HostComponents.d.ts +35 -35
- package/lib/typescript/src/renderer/Offscreen.d.ts +2 -0
- package/lib/typescript/src/skia/types/Surface/Surface.d.ts +4 -0
- package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +6 -0
- package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/package.json +1 -1
- package/src/dom/nodes/DrawingNode.ts +5 -1
- package/src/dom/nodes/LayerNode.ts +13 -11
- package/src/dom/nodes/Node.ts +18 -41
- package/src/dom/nodes/PaintContext.ts +1 -0
- package/src/dom/nodes/PaintNode.ts +28 -18
- package/src/dom/nodes/RenderNode.ts +25 -183
- package/src/dom/nodes/drawings/BackdropFilterNode.ts +18 -11
- package/src/dom/nodes/drawings/Box.ts +6 -4
- package/src/dom/nodes/paint/BlendNode.ts +16 -63
- package/src/dom/nodes/paint/ColorFilters.ts +32 -55
- package/src/dom/nodes/paint/ImageFilters.ts +58 -53
- package/src/dom/nodes/paint/MaskFilters.ts +5 -7
- package/src/dom/nodes/paint/PathEffects.ts +37 -90
- package/src/dom/nodes/paint/Shaders.ts +31 -29
- package/src/dom/types/DeclarationContext.ts +105 -0
- package/src/dom/types/DrawingContext.ts +304 -1
- package/src/dom/types/Node.ts +4 -20
- package/src/dom/types/SkDOM.ts +22 -43
- package/src/dom/types/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/renderer/Canvas.tsx +3 -3
- package/src/renderer/DrawingContext.ts +4 -5
- package/src/renderer/HostComponents.ts +34 -53
- package/src/renderer/HostConfig.ts +1 -0
- package/src/renderer/Offscreen.tsx +24 -0
- package/src/renderer/Reconciler.tsx +0 -1
- package/src/skia/types/Surface/Surface.ts +5 -0
- package/src/skia/types/Surface/SurfaceFactory.ts +7 -0
- package/src/skia/web/JsiSkSurface.ts +4 -0
- package/src/skia/web/JsiSkSurfaceFactory.ts +21 -2
- package/src/views/SkiaBaseWebView.tsx +6 -2
- package/src/views/SkiaDomView.web.tsx +2 -13
- package/src/views/SkiaPictureView.web.tsx +0 -7
- package/src/views/SkiaView.web.tsx +0 -7
@@ -15,7 +15,8 @@ namespace RNSkia {
|
|
15
15
|
*/
|
16
16
|
class BaseDerivedProp : public BaseNodeProp {
|
17
17
|
public:
|
18
|
-
BaseDerivedProp(
|
18
|
+
explicit BaseDerivedProp(const std::function<void(BaseNodeProp *)> &onChange)
|
19
|
+
: _onChange(onChange), BaseNodeProp() {}
|
19
20
|
|
20
21
|
/**
|
21
22
|
Starts the process of updating and reading props
|
@@ -70,7 +71,11 @@ public:
|
|
70
71
|
/**
|
71
72
|
Adds a property to the derived property child props.
|
72
73
|
*/
|
73
|
-
template <
|
74
|
+
template <class _Tp, class... _Args,
|
75
|
+
class = std::_EnableIf<!std::is_array<_Tp>::value>>
|
76
|
+
_Tp *defineProperty(_Args &&...__args) {
|
77
|
+
auto prop =
|
78
|
+
std::make_shared<_Tp>(std::forward<_Args>(__args)..., _onChange);
|
74
79
|
_properties.push_back(prop);
|
75
80
|
return prop.get();
|
76
81
|
}
|
@@ -104,6 +109,7 @@ protected:
|
|
104
109
|
private:
|
105
110
|
std::vector<std::shared_ptr<BaseNodeProp>> _properties;
|
106
111
|
std::atomic<bool> _isChanged = {false};
|
112
|
+
std::function<void(BaseNodeProp *)> _onChange;
|
107
113
|
};
|
108
114
|
|
109
115
|
/**
|
@@ -111,12 +117,21 @@ private:
|
|
111
117
|
*/
|
112
118
|
template <typename T> class DerivedProp : public BaseDerivedProp {
|
113
119
|
public:
|
114
|
-
DerivedProp(
|
120
|
+
explicit DerivedProp(const std::function<void(BaseNodeProp *)> &onChange)
|
121
|
+
: BaseDerivedProp(onChange) {}
|
115
122
|
|
116
123
|
/**
|
117
124
|
Returns the derived value
|
118
125
|
*/
|
119
|
-
std::shared_ptr<const T> getDerivedValue() {
|
126
|
+
std::shared_ptr<const T> getDerivedValue() {
|
127
|
+
return std::const_pointer_cast<const T>(_derivedValue);
|
128
|
+
}
|
129
|
+
|
130
|
+
/**
|
131
|
+
Returns a mutable version of the derived value. Used by the paint props to
|
132
|
+
keep a drawing context
|
133
|
+
*/
|
134
|
+
std::shared_ptr<T> getUnsafeDerivedValue() { return _derivedValue; }
|
120
135
|
|
121
136
|
/**
|
122
137
|
Returns true if is optional and one of the child props has a value, or all
|
@@ -128,7 +143,7 @@ protected:
|
|
128
143
|
/**
|
129
144
|
Set derived value from sub classes
|
130
145
|
*/
|
131
|
-
void setDerivedValue(std::shared_ptr<
|
146
|
+
void setDerivedValue(std::shared_ptr<T> value) {
|
132
147
|
setIsChanged(_derivedValue != value);
|
133
148
|
_derivedValue = value;
|
134
149
|
}
|
@@ -136,13 +151,13 @@ protected:
|
|
136
151
|
/**
|
137
152
|
Set derived value from sub classes
|
138
153
|
*/
|
139
|
-
void setDerivedValue(
|
154
|
+
void setDerivedValue(T &&value) {
|
140
155
|
setIsChanged(true);
|
141
|
-
_derivedValue = std::make_shared<
|
156
|
+
_derivedValue = std::make_shared<T>(std::move(value));
|
142
157
|
}
|
143
158
|
|
144
159
|
private:
|
145
|
-
std::shared_ptr<
|
160
|
+
std::shared_ptr<T> _derivedValue;
|
146
161
|
};
|
147
162
|
|
148
163
|
/**
|
@@ -150,7 +165,8 @@ private:
|
|
150
165
|
*/
|
151
166
|
template <typename T> class DerivedSkProp : public BaseDerivedProp {
|
152
167
|
public:
|
153
|
-
DerivedSkProp(
|
168
|
+
explicit DerivedSkProp(const std::function<void(BaseNodeProp *)> &onChange)
|
169
|
+
: BaseDerivedProp(onChange) {}
|
154
170
|
|
155
171
|
/**
|
156
172
|
Returns the derived value
|
@@ -1,209 +1,55 @@
|
|
1
1
|
#include "DrawingContext.h"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
: DrawingContext("root") {
|
7
|
-
_paint = paint;
|
8
|
-
}
|
9
|
-
|
10
|
-
DrawingContext::DrawingContext(DrawingContext *parent, const char *source)
|
11
|
-
: DrawingContext(source) {
|
12
|
-
_parent = parent;
|
13
|
-
}
|
14
|
-
|
15
|
-
std::shared_ptr<DrawingContext>
|
16
|
-
DrawingContext::inheritContext(const char *source) {
|
17
|
-
auto result = std::make_shared<DrawingContext>(this, source);
|
18
|
-
_children.push_back(result);
|
19
|
-
return result;
|
20
|
-
}
|
21
|
-
|
22
|
-
std::string DrawingContext::getDebugDescription() {
|
23
|
-
std::string v = "ctx for " + std::string(_source) + ":";
|
24
|
-
|
25
|
-
if (_paint != nullptr) {
|
26
|
-
auto clr = _paint->getColor();
|
27
|
-
auto a = SkColorGetA(clr);
|
28
|
-
auto r = SkColorGetR(clr);
|
29
|
-
auto g = SkColorGetG(clr);
|
30
|
-
auto b = SkColorGetB(clr);
|
31
|
-
|
32
|
-
if (r > 0 || g > 0 || b > 0) {
|
33
|
-
v += " color:rgba(" + std::to_string(r) + ", " + std::to_string(g) +
|
34
|
-
", " + std::to_string(b) + ", " + std::to_string(a) + ")";
|
35
|
-
}
|
36
|
-
|
37
|
-
if (_paint->getMaskFilter() != nullptr) {
|
38
|
-
v += " maskFilter:set";
|
39
|
-
}
|
40
|
-
auto blendMode = _paint->getBlendMode_or(SkBlendMode::kSrc);
|
41
|
-
if (blendMode != SkBlendMode::kSrc) {
|
42
|
-
v += " blendMode:" + std::to_string(static_cast<size_t>(blendMode));
|
43
|
-
}
|
44
|
-
|
45
|
-
auto opacity = _paint->getAlphaf();
|
46
|
-
v += " opacity:" + std::to_string(opacity);
|
3
|
+
#include "ConcatablePaint.h"
|
4
|
+
#include "JsiDomNode.h"
|
5
|
+
#include "PaintProps.h"
|
47
6
|
|
48
|
-
|
49
|
-
v += " [PathEffect]";
|
50
|
-
}
|
51
|
-
|
52
|
-
if (_paint->getShader() != nullptr) {
|
53
|
-
v += " [Shader]";
|
54
|
-
}
|
55
|
-
|
56
|
-
if (_paint->getImageFilter() != nullptr) {
|
57
|
-
v += " [ImageFilter]";
|
58
|
-
}
|
59
|
-
|
60
|
-
if (_paint->getMaskFilter() != nullptr) {
|
61
|
-
v += " [MaskFilter]";
|
62
|
-
}
|
63
|
-
|
64
|
-
if (_paint->getColorFilter() != nullptr) {
|
65
|
-
v += " [ColorFilter]";
|
66
|
-
}
|
67
|
-
|
68
|
-
} else {
|
69
|
-
v = v + "[inherited] " +
|
70
|
-
(_parent != nullptr ? _parent->getDebugDescription() : "");
|
71
|
-
}
|
72
|
-
|
73
|
-
v = v + "\n";
|
74
|
-
|
75
|
-
return v;
|
76
|
-
}
|
77
|
-
|
78
|
-
/**
|
79
|
-
Invalidate cache
|
80
|
-
*/
|
81
|
-
void DrawingContext::markAsChanged() {
|
82
|
-
markChildrenAsChanged();
|
83
|
-
_paint = nullptr;
|
84
|
-
_isChanged = true;
|
85
|
-
}
|
7
|
+
#include <numeric>
|
86
8
|
|
87
|
-
|
88
|
-
Call to reset invalidate flag after render cycle
|
89
|
-
*/
|
90
|
-
void DrawingContext::resetChangedFlag() { _isChanged = false; }
|
91
|
-
|
92
|
-
/**
|
93
|
-
Dispose and remove the drawing context from its parent.
|
94
|
-
*/
|
95
|
-
void DrawingContext::dispose() {
|
96
|
-
if (_parent != nullptr) {
|
97
|
-
auto position = std::find(_parent->_children.begin(),
|
98
|
-
_parent->_children.end(), shared_from_this());
|
9
|
+
namespace RNSkia {
|
99
10
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
// rendering after setting this to null, and we also need to protect this
|
105
|
-
// section.
|
106
|
-
_parent = nullptr;
|
107
|
-
}
|
11
|
+
DrawingContext::DrawingContext(std::shared_ptr<SkPaint> paint) {
|
12
|
+
_declarationContext = std::make_unique<DeclarationContext>();
|
13
|
+
paint->setAntiAlias(true);
|
14
|
+
_paints.push_back(paint);
|
108
15
|
}
|
109
16
|
|
110
|
-
|
111
|
-
|
112
|
-
*/
|
113
|
-
bool DrawingContext::isChanged() { return _isChanged; }
|
17
|
+
DrawingContext::DrawingContext()
|
18
|
+
: DrawingContext(std::make_shared<SkPaint>()) {}
|
114
19
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
if (_parent != nullptr) {
|
120
|
-
return _parent->getCanvas();
|
121
|
-
}
|
122
|
-
|
123
|
-
return _canvas;
|
124
|
-
}
|
20
|
+
bool DrawingContext::saveAndConcat(
|
21
|
+
PaintProps *paintProps,
|
22
|
+
const std::vector<std::shared_ptr<JsiDomNode>> &children,
|
23
|
+
std::shared_ptr<SkPaint> paintCache) {
|
125
24
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
void DrawingContext::setCanvas(SkCanvas *canvas) { _canvas = canvas; }
|
130
|
-
|
131
|
-
/**
|
132
|
-
Gets the paint object
|
133
|
-
*/
|
134
|
-
std::shared_ptr<const SkPaint> DrawingContext::getPaint() {
|
135
|
-
if (_paint != nullptr) {
|
136
|
-
return _paint;
|
25
|
+
if (paintCache) {
|
26
|
+
_paints.push_back(paintCache);
|
27
|
+
return true;
|
137
28
|
}
|
138
|
-
return _parent->getPaint();
|
139
|
-
}
|
140
29
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
*/
|
147
|
-
std::shared_ptr<SkPaint> DrawingContext::getMutablePaint() {
|
148
|
-
if (_paint == nullptr) {
|
149
|
-
auto parentPaint = _parent->getPaint();
|
150
|
-
_paint = std::make_shared<SkPaint>(*parentPaint);
|
30
|
+
ConcatablePaint paint(_declarationContext.get(), paintProps, children);
|
31
|
+
if (!paint.isEmpty()) {
|
32
|
+
save();
|
33
|
+
paint.concatTo(getPaint());
|
34
|
+
return true;
|
151
35
|
}
|
152
|
-
// Calling the getMutablePaint accessor implies that the paint
|
153
|
-
// is about to be mutatet and will therefore invalidate
|
154
|
-
// any child contexts to pick up changes from this context as
|
155
|
-
// the parent context.
|
156
|
-
markChildrenAsChanged();
|
157
|
-
return _paint;
|
158
|
-
}
|
159
|
-
|
160
|
-
/**
|
161
|
-
Sets the paint in the current sub context
|
162
|
-
*/
|
163
|
-
void DrawingContext::setMutablePaint(std::shared_ptr<SkPaint> paint) {
|
164
|
-
_paint = paint;
|
165
|
-
}
|
166
36
|
|
167
|
-
|
168
|
-
if (_parent != nullptr) {
|
169
|
-
return _parent->getScaledWidth();
|
170
|
-
}
|
171
|
-
return _scaledWidth;
|
37
|
+
return false;
|
172
38
|
}
|
173
39
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
}
|
178
|
-
return _scaledHeight;
|
40
|
+
void DrawingContext::save() {
|
41
|
+
// Copy paint and push
|
42
|
+
_paints.push_back(std::make_shared<SkPaint>(*getPaint()));
|
179
43
|
}
|
180
44
|
|
181
|
-
|
45
|
+
void DrawingContext::restore() { _paints.pop_back(); }
|
182
46
|
|
183
|
-
|
184
|
-
void DrawingContext::setScaledHeight(float v) { _scaledHeight = v; }
|
185
|
-
|
186
|
-
void DrawingContext::setRequestRedraw(std::function<void()> &&requestRedraw) {
|
187
|
-
if (_parent != nullptr) {
|
188
|
-
_parent->setRequestRedraw(std::move(requestRedraw));
|
189
|
-
} else {
|
190
|
-
_requestRedraw = std::move(requestRedraw);
|
191
|
-
}
|
192
|
-
}
|
47
|
+
SkCanvas *DrawingContext::getCanvas() { return _canvas; }
|
193
48
|
|
194
|
-
|
195
|
-
if (_parent != nullptr) {
|
196
|
-
return _parent->getRequestRedraw();
|
197
|
-
}
|
198
|
-
return _requestRedraw;
|
199
|
-
}
|
200
|
-
|
201
|
-
DrawingContext::DrawingContext(const char *source) { _source = source; }
|
49
|
+
void DrawingContext::setCanvas(SkCanvas *canvas) { _canvas = canvas; }
|
202
50
|
|
203
|
-
|
204
|
-
|
205
|
-
child->markAsChanged();
|
206
|
-
}
|
51
|
+
std::shared_ptr<SkPaint> DrawingContext::getPaint() {
|
52
|
+
return _paints[_paints.size() - 1];
|
207
53
|
}
|
208
54
|
|
209
55
|
} // namespace RNSkia
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
#include "JsiHostObject.h"
|
4
4
|
|
5
|
+
#include "Declaration.h"
|
6
|
+
#include "DeclarationContext.h"
|
7
|
+
|
5
8
|
#include <memory>
|
6
9
|
#include <string>
|
7
10
|
#include <utility>
|
@@ -12,47 +15,55 @@
|
|
12
15
|
|
13
16
|
#include <SkCanvas.h>
|
14
17
|
#include <SkPaint.h>
|
18
|
+
#include <SkRefCnt.h>
|
15
19
|
|
16
20
|
#pragma clang diagnostic pop
|
17
21
|
|
18
22
|
namespace RNSkia {
|
19
23
|
|
20
|
-
class
|
24
|
+
class PaintProps;
|
25
|
+
class JsiDomNode;
|
26
|
+
|
27
|
+
class DomRenderContext {
|
21
28
|
public:
|
22
|
-
|
23
|
-
|
24
|
-
*/
|
25
|
-
explicit DrawingContext(std::shared_ptr<SkPaint> paint);
|
29
|
+
float getScaledWidth() { return _scaledWidth; }
|
30
|
+
float getScaledHeight() { return _scaledHeight; }
|
26
31
|
|
27
|
-
|
28
|
-
|
29
|
-
*/
|
30
|
-
DrawingContext(DrawingContext *parent, const char *source);
|
32
|
+
void setScaledWidth(float v) { _scaledWidth = v; }
|
33
|
+
void setScaledHeight(float v) { _scaledHeight = v; }
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
std::shared_ptr<DrawingContext> inheritContext(const char *source);
|
35
|
+
void setRequestRedraw(std::function<void()> &&requestRedraw) {
|
36
|
+
_requestRedraw = std::move(requestRedraw);
|
37
|
+
}
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
const std::function<void()> &getRequestRedraw() { return _requestRedraw; }
|
40
|
+
|
41
|
+
private:
|
42
|
+
float _scaledWidth = -1;
|
43
|
+
float _scaledHeight = -1;
|
44
|
+
std::function<void()> _requestRedraw;
|
45
|
+
};
|
41
46
|
|
47
|
+
class DrawingContext : public DomRenderContext,
|
48
|
+
public std::enable_shared_from_this<DrawingContext> {
|
49
|
+
public:
|
42
50
|
/**
|
43
|
-
|
51
|
+
Creates a root drawing context with paint and opacity
|
44
52
|
*/
|
45
|
-
|
53
|
+
DrawingContext();
|
46
54
|
|
47
55
|
/**
|
48
|
-
|
49
|
-
|
50
|
-
|
56
|
+
Creates a drawing context with the given paint as its starting paint object
|
57
|
+
*/
|
58
|
+
explicit DrawingContext(std::shared_ptr<SkPaint> paint);
|
51
59
|
|
52
60
|
/**
|
53
|
-
|
61
|
+
Factory for saving/restoring the context for a node
|
54
62
|
*/
|
55
|
-
|
63
|
+
bool saveAndConcat(PaintProps *paintProps,
|
64
|
+
const std::vector<std::shared_ptr<JsiDomNode>> &children,
|
65
|
+
std::shared_ptr<SkPaint> paintCache);
|
66
|
+
void restore();
|
56
67
|
|
57
68
|
/**
|
58
69
|
Returns true if the current cache is changed
|
@@ -72,52 +83,22 @@ public:
|
|
72
83
|
/**
|
73
84
|
Gets the paint object
|
74
85
|
*/
|
75
|
-
std::shared_ptr<
|
76
|
-
|
77
|
-
/**
|
78
|
-
To be able to mutate and change the paint in a context we need to mutate the
|
79
|
-
underlying paint object - otherwise we'll just use the parent paint object
|
80
|
-
(to avoid having to create multiple paint objects for nodes that does not
|
81
|
-
change the paint).
|
82
|
-
*/
|
83
|
-
std::shared_ptr<SkPaint> getMutablePaint();
|
86
|
+
std::shared_ptr<SkPaint> getPaint();
|
84
87
|
|
85
|
-
|
86
|
-
|
88
|
+
/*
|
89
|
+
Returns the root declaratiins object
|
87
90
|
*/
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
float getScaledHeight();
|
93
|
-
|
94
|
-
void setScaledWidth(float v);
|
95
|
-
void setScaledHeight(float v);
|
96
|
-
|
97
|
-
void setRequestRedraw(std::function<void()> &&requestRedraw);
|
98
|
-
const std::function<void()> &getRequestRedraw();
|
99
|
-
|
100
|
-
DrawingContext *getParent();
|
91
|
+
DeclarationContext *getDeclarationContext() {
|
92
|
+
return _declarationContext.get();
|
93
|
+
}
|
101
94
|
|
102
95
|
private:
|
103
|
-
|
104
|
-
|
105
|
-
void markChildrenAsChanged();
|
106
|
-
|
107
|
-
bool _isChanged = true;
|
108
|
-
|
109
|
-
std::shared_ptr<SkPaint> _paint;
|
96
|
+
void save();
|
110
97
|
|
98
|
+
explicit DrawingContext(const char *source);
|
111
99
|
SkCanvas *_canvas = nullptr;
|
112
|
-
|
113
|
-
|
114
|
-
DrawingContext *_parent = nullptr;
|
115
|
-
std::vector<std::shared_ptr<DrawingContext>> _children;
|
116
|
-
|
117
|
-
float _scaledWidth = -1;
|
118
|
-
float _scaledHeight = -1;
|
119
|
-
|
120
|
-
std::function<void()> _requestRedraw;
|
100
|
+
std::vector<std::shared_ptr<SkPaint>> _paints;
|
101
|
+
std::unique_ptr<DeclarationContext> _declarationContext;
|
121
102
|
};
|
122
103
|
|
123
104
|
} // namespace RNSkia
|
@@ -9,17 +9,29 @@
|
|
9
9
|
|
10
10
|
namespace RNSkia {
|
11
11
|
|
12
|
-
|
12
|
+
enum DeclarationType {
|
13
|
+
Unknown = 0,
|
14
|
+
Paint = 1,
|
15
|
+
Shader = 2,
|
16
|
+
ImageFilter = 3,
|
17
|
+
ColorFilter = 4,
|
18
|
+
PathEffect = 5,
|
19
|
+
MaskFilter = 6,
|
20
|
+
};
|
21
|
+
|
22
|
+
class JsiDomDeclarationNode : public JsiDomNode {
|
13
23
|
public:
|
14
|
-
|
15
|
-
|
16
|
-
: JsiDomNode(context, type)
|
24
|
+
JsiDomDeclarationNode(std::shared_ptr<RNSkPlatformContext> context,
|
25
|
+
const char *type, DeclarationType declarationType)
|
26
|
+
: JsiDomNode(context, type, NodeClass::DeclarationNode),
|
27
|
+
_declarationType(declarationType) {}
|
17
28
|
|
18
29
|
JSI_PROPERTY_GET(declarationType) {
|
30
|
+
// FIXME: Shouldn't this be the declaration type instead? It has been
|
19
31
|
return jsi::String::createFromUtf8(runtime, std::string(getType()));
|
20
32
|
}
|
21
33
|
|
22
|
-
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(
|
34
|
+
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiDomDeclarationNode,
|
23
35
|
declarationType),
|
24
36
|
JSI_EXPORT_PROP_GET(JsiDomNode, type))
|
25
37
|
|
@@ -34,30 +46,27 @@ public:
|
|
34
46
|
/**
|
35
47
|
Called when rendering the tree to create all derived values from all nodes.
|
36
48
|
*/
|
37
|
-
|
49
|
+
void decorateContext(DeclarationContext *context) override {
|
50
|
+
JsiDomNode::decorateContext(context);
|
51
|
+
|
38
52
|
#if SKIA_DOM_DEBUG
|
39
|
-
printDebugInfo("Begin
|
53
|
+
printDebugInfo("Begin decorate " + std::string(getType()));
|
40
54
|
#endif
|
41
|
-
// Materialize children first so that any inner nodes get the opportunity
|
42
|
-
// to calculate their state before this node continues.
|
43
|
-
for (auto &child : getChildren()) {
|
44
|
-
if (child->getNodeClass() == JsiDomNodeClass::DeclarationNode) {
|
45
|
-
std::static_pointer_cast<JsiBaseDomDeclarationNode>(child)
|
46
|
-
->decorateContext(context);
|
47
|
-
}
|
48
|
-
}
|
49
55
|
|
50
56
|
// decorate drawing context
|
51
57
|
decorate(context);
|
52
58
|
|
53
59
|
#if SKIA_DOM_DEBUG
|
54
|
-
printDebugInfo("End / Commit
|
60
|
+
printDebugInfo("End / Commit decorate " + std::string(getType()));
|
55
61
|
#endif
|
56
62
|
}
|
57
63
|
|
58
|
-
|
59
|
-
|
60
|
-
|
64
|
+
DeclarationType getDeclarationType() { return _declarationType; }
|
65
|
+
|
66
|
+
/**
|
67
|
+
Override to implement materialization
|
68
|
+
*/
|
69
|
+
virtual void decorate(DeclarationContext *context) = 0;
|
61
70
|
|
62
71
|
protected:
|
63
72
|
/**
|
@@ -71,16 +80,15 @@ protected:
|
|
71
80
|
}
|
72
81
|
|
73
82
|
/**
|
74
|
-
|
83
|
+
A property changed
|
75
84
|
*/
|
76
|
-
|
85
|
+
void onPropertyChanged(BaseNodeProp *prop) override { invalidateContext(); }
|
77
86
|
|
78
87
|
/**
|
79
88
|
Validates that only declaration nodes can be children
|
80
89
|
*/
|
81
90
|
void addChild(std::shared_ptr<JsiDomNode> child) override {
|
82
|
-
if (
|
83
|
-
nullptr) {
|
91
|
+
if (child->getNodeClass() != NodeClass::DeclarationNode) {
|
84
92
|
getContext()->raiseError(std::runtime_error(
|
85
93
|
"Cannot add a child of type \"" + std::string(child->getType()) +
|
86
94
|
"\" to a \"" + std::string(getType()) + "\"."));
|
@@ -93,98 +101,19 @@ protected:
|
|
93
101
|
*/
|
94
102
|
void insertChildBefore(std::shared_ptr<JsiDomNode> child,
|
95
103
|
std::shared_ptr<JsiDomNode> before) override {
|
96
|
-
if (
|
97
|
-
nullptr) {
|
104
|
+
if (child->getNodeClass() != NodeClass::DeclarationNode) {
|
98
105
|
getContext()->raiseError(std::runtime_error(
|
99
106
|
"Cannot add a child of type \"" + std::string(child->getType()) +
|
100
107
|
"\" to a \"" + std::string(getType()) + "\"."));
|
101
108
|
}
|
102
109
|
JsiDomNode::insertChildBefore(child, before);
|
103
110
|
}
|
104
|
-
};
|
105
|
-
|
106
|
-
template <typename T, typename ST>
|
107
|
-
class JsiDomDeclarationNode : public JsiBaseDomDeclarationNode {
|
108
|
-
public:
|
109
|
-
JsiDomDeclarationNode(std::shared_ptr<RNSkPlatformContext> context,
|
110
|
-
const char *type)
|
111
|
-
: JsiBaseDomDeclarationNode(context, type) {}
|
112
|
-
|
113
|
-
bool isChanged(DrawingContext *context) {
|
114
|
-
return getCurrent() == nullptr || context->isChanged() ||
|
115
|
-
getPropsContainer()->isChanged();
|
116
|
-
}
|
117
|
-
|
118
|
-
/**
|
119
|
-
Returns the inner element
|
120
|
-
*/
|
121
|
-
ST getCurrent() { return _current; }
|
122
|
-
|
123
|
-
/**
|
124
|
-
Clears the current
|
125
|
-
*/
|
126
|
-
void clearCurrent() { _current = nullptr; }
|
127
|
-
|
128
|
-
protected:
|
129
|
-
/**
|
130
|
-
Sets the current value
|
131
|
-
*/
|
132
|
-
void setCurrent(ST c) { _current = c; }
|
133
|
-
|
134
|
-
/**
|
135
|
-
Returns a required child image filter by index
|
136
|
-
*/
|
137
|
-
ST requireChild(size_t index) {
|
138
|
-
auto filter = optionalChild(index);
|
139
|
-
if (filter == nullptr) {
|
140
|
-
throw std::runtime_error("Expected child node at index " +
|
141
|
-
std::to_string(index) + " in node " + getType());
|
142
|
-
}
|
143
|
-
return filter;
|
144
|
-
}
|
145
|
-
|
146
|
-
/**
|
147
|
-
Returns an optional child image filter by index
|
148
|
-
*/
|
149
|
-
ST optionalChild(size_t index) {
|
150
|
-
if (index >= getChildren().size()) {
|
151
|
-
return nullptr;
|
152
|
-
}
|
153
|
-
|
154
|
-
auto child = getChildren()[index];
|
155
|
-
// Support all types here!! ImageFilters, ColorFilters
|
156
|
-
// package/src/dom/nodes/paint/ImageFilters.ts#80
|
157
|
-
return resolve(child);
|
158
|
-
}
|
159
|
-
|
160
|
-
/**
|
161
|
-
Returns child as inner type or nullptr
|
162
|
-
*/
|
163
|
-
virtual ST resolve(std::shared_ptr<JsiDomNode> child) = 0;
|
164
111
|
|
112
|
+
private:
|
165
113
|
/**
|
166
|
-
|
114
|
+
Type of declaration
|
167
115
|
*/
|
168
|
-
|
169
|
-
|
170
|
-
void removeChild(std::shared_ptr<JsiDomNode> child) override {
|
171
|
-
JsiBaseDomDeclarationNode::removeChild(child);
|
172
|
-
clearCurrent();
|
173
|
-
}
|
174
|
-
|
175
|
-
void addChild(std::shared_ptr<JsiDomNode> child) override {
|
176
|
-
JsiBaseDomDeclarationNode::addChild(child);
|
177
|
-
clearCurrent();
|
178
|
-
}
|
179
|
-
|
180
|
-
void insertChildBefore(std::shared_ptr<JsiDomNode> child,
|
181
|
-
std::shared_ptr<JsiDomNode> before) override {
|
182
|
-
JsiBaseDomDeclarationNode::insertChildBefore(child, before);
|
183
|
-
clearCurrent();
|
184
|
-
}
|
185
|
-
|
186
|
-
private:
|
187
|
-
ST _current;
|
116
|
+
DeclarationType _declarationType;
|
188
117
|
};
|
189
118
|
|
190
119
|
} // namespace RNSkia
|