@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
@@ -16,7 +16,7 @@ public:
|
|
16
16
|
protected:
|
17
17
|
void defineProperties(NodePropsContainer *container) override {
|
18
18
|
JsiDomRenderNode::defineProperties(container);
|
19
|
-
container->defineProperty<
|
19
|
+
_paintProp = container->defineProperty<PaintDrawingContextProp>();
|
20
20
|
}
|
21
21
|
|
22
22
|
/**
|
@@ -28,23 +28,42 @@ protected:
|
|
28
28
|
#if SKIA_DOM_DEBUG
|
29
29
|
printDebugInfo("Begin Draw", 1);
|
30
30
|
#endif
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
// Save paint if the paint property is set
|
32
|
+
if (_paintProp->isSet()) {
|
33
|
+
draw(_paintProp->getUnsafeDerivedValue().get());
|
34
|
+
} else {
|
35
|
+
// Call abstract draw method
|
36
|
+
draw(context);
|
37
|
+
}
|
36
38
|
|
37
39
|
// Draw once more for each child paint node
|
40
|
+
auto declarationCtx = context->getDeclarationContext();
|
38
41
|
for (auto &child : getChildren()) {
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
+
if (child->getNodeClass() == NodeClass::DeclarationNode &&
|
43
|
+
std::static_pointer_cast<JsiDomDeclarationNode>(child)
|
44
|
+
->getDeclarationType() == DeclarationType::Paint) {
|
45
|
+
auto paintNode = std::static_pointer_cast<JsiPaintNode>(child);
|
46
|
+
// Draw once again with the paint
|
47
|
+
declarationCtx->save();
|
48
|
+
paintNode->decorate(declarationCtx);
|
49
|
+
auto paint = declarationCtx->getPaints()->pop();
|
50
|
+
declarationCtx->restore();
|
51
|
+
|
52
|
+
// FIXME: Can we avoid creating a new drawing context here each time?
|
53
|
+
auto localContext =
|
54
|
+
std::make_shared<DrawingContext>(std::shared_ptr<SkPaint>(paint));
|
55
|
+
localContext->setCanvas(context->getCanvas());
|
56
|
+
draw(localContext.get());
|
42
57
|
}
|
43
58
|
}
|
59
|
+
|
44
60
|
#if SKIA_DOM_DEBUG
|
45
61
|
printDebugInfo("End Draw", 1);
|
46
62
|
#endif
|
47
63
|
}
|
64
|
+
|
65
|
+
private:
|
66
|
+
PaintDrawingContextProp *_paintProp;
|
48
67
|
};
|
49
68
|
|
50
69
|
} // namespace RNSkia
|
@@ -33,7 +33,7 @@ static std::atomic<size_t> NodeIdent = 1000;
|
|
33
33
|
typedef enum {
|
34
34
|
RenderNode = 1,
|
35
35
|
DeclarationNode = 2,
|
36
|
-
}
|
36
|
+
} NodeClass;
|
37
37
|
|
38
38
|
/**
|
39
39
|
Implements an abstract base class for nodes in the Skia Reconciler. This node
|
@@ -46,8 +46,10 @@ public:
|
|
46
46
|
Contructor. Takes as parameters the values comming from the JS world that
|
47
47
|
initialized the class.
|
48
48
|
*/
|
49
|
-
JsiDomNode(std::shared_ptr<RNSkPlatformContext> context, const char *type
|
50
|
-
|
49
|
+
JsiDomNode(std::shared_ptr<RNSkPlatformContext> context, const char *type,
|
50
|
+
NodeClass nodeClass)
|
51
|
+
: _type(type), _context(context), _nodeClass(nodeClass),
|
52
|
+
_nodeId(NodeIdent++), JsiHostObject() {}
|
51
53
|
|
52
54
|
/**
|
53
55
|
Called when creating the node, resolves properties from the node constructor.
|
@@ -183,7 +185,7 @@ public:
|
|
183
185
|
Returns the class of node so that we can do loops faster without
|
184
186
|
having to check using runtime type information
|
185
187
|
*/
|
186
|
-
|
188
|
+
NodeClass getNodeClass() { return _nodeClass; }
|
187
189
|
|
188
190
|
/**
|
189
191
|
Updates any pending property changes in all nodes and child nodes. This
|
@@ -205,11 +207,6 @@ public:
|
|
205
207
|
op();
|
206
208
|
}
|
207
209
|
|
208
|
-
// If there are any ops here we should invalidate the cached context
|
209
|
-
if (_queuedNodeOps.size() > 0) {
|
210
|
-
invalidateContext();
|
211
|
-
}
|
212
|
-
|
213
210
|
_queuedNodeOps.clear();
|
214
211
|
}
|
215
212
|
|
@@ -268,7 +265,21 @@ public:
|
|
268
265
|
}
|
269
266
|
}
|
270
267
|
|
268
|
+
/**
|
269
|
+
Empty implementation of the decorate context method
|
270
|
+
*/
|
271
|
+
virtual void decorateContext(DeclarationContext *context) {
|
272
|
+
// Empty implementation
|
273
|
+
}
|
274
|
+
|
271
275
|
protected:
|
276
|
+
/**
|
277
|
+
Adds an operation that will be executed when the render cycle is finished.
|
278
|
+
*/
|
279
|
+
void enqueAsynOperation(std::function<void()> &&fp) {
|
280
|
+
std::lock_guard<std::mutex> lock(_childrenLock);
|
281
|
+
_queuedNodeOps.push_back(std::move(fp));
|
282
|
+
}
|
272
283
|
/**
|
273
284
|
Override to define properties in node implementations
|
274
285
|
*/
|
@@ -298,7 +309,8 @@ protected:
|
|
298
309
|
if (_propsContainer == nullptr) {
|
299
310
|
|
300
311
|
// Initialize properties container
|
301
|
-
_propsContainer = std::make_shared<NodePropsContainer>(
|
312
|
+
_propsContainer = std::make_shared<NodePropsContainer>(
|
313
|
+
getType(), [=](BaseNodeProp *p) { onPropertyChanged(p); });
|
302
314
|
|
303
315
|
// Ask sub classes to define their properties
|
304
316
|
defineProperties(_propsContainer.get());
|
@@ -320,7 +332,8 @@ protected:
|
|
320
332
|
if (_propsContainer == nullptr) {
|
321
333
|
|
322
334
|
// Initialize properties container
|
323
|
-
_propsContainer = std::make_shared<NodePropsContainer>(
|
335
|
+
_propsContainer = std::make_shared<NodePropsContainer>(
|
336
|
+
getType(), [=](BaseNodeProp *p) { onPropertyChanged(p); });
|
324
337
|
|
325
338
|
// Ask sub classes to define their properties
|
326
339
|
defineProperties(_propsContainer.get());
|
@@ -335,6 +348,11 @@ protected:
|
|
335
348
|
return _children;
|
336
349
|
}
|
337
350
|
|
351
|
+
/**
|
352
|
+
Override to be notified when a node property has changed
|
353
|
+
*/
|
354
|
+
virtual void onPropertyChanged(BaseNodeProp *prop) {}
|
355
|
+
|
338
356
|
/**
|
339
357
|
Adds a child node to the array of children for this node
|
340
358
|
*/
|
@@ -343,8 +361,7 @@ protected:
|
|
343
361
|
printDebugInfo("JS:addChild(childId: " + std::to_string(child->_nodeId) +
|
344
362
|
")");
|
345
363
|
#endif
|
346
|
-
|
347
|
-
_queuedNodeOps.push_back([child, this]() {
|
364
|
+
enqueAsynOperation([child, this]() {
|
348
365
|
_children.push_back(child);
|
349
366
|
child->setParent(this);
|
350
367
|
});
|
@@ -361,8 +378,7 @@ protected:
|
|
361
378
|
"JS:insertChildBefore(childId: " + std::to_string(child->_nodeId) +
|
362
379
|
", beforeId: " + std::to_string(before->_nodeId) + ")");
|
363
380
|
#endif
|
364
|
-
|
365
|
-
_queuedNodeOps.push_back([child, before, this]() {
|
381
|
+
enqueAsynOperation([child, before, this]() {
|
366
382
|
auto position = std::find(_children.begin(), _children.end(), before);
|
367
383
|
_children.insert(position, child);
|
368
384
|
child->setParent(this);
|
@@ -378,8 +394,7 @@ protected:
|
|
378
394
|
printDebugInfo("JS:removeChild(childId: " + std::to_string(child->_nodeId) +
|
379
395
|
")");
|
380
396
|
#endif
|
381
|
-
|
382
|
-
_queuedNodeOps.push_back([child, this]() {
|
397
|
+
enqueAsynOperation([child, this]() {
|
383
398
|
// Delete child itself
|
384
399
|
_children.erase(
|
385
400
|
std::remove_if(_children.begin(), _children.end(),
|
@@ -429,6 +444,18 @@ protected:
|
|
429
444
|
*/
|
430
445
|
JsiDomNode *getParent() { return _parent; }
|
431
446
|
|
447
|
+
/**
|
448
|
+
Loops through all declaration nodes and gives each one of them the
|
449
|
+
opportunity to decorate the context.
|
450
|
+
*/
|
451
|
+
void decorateChildren(DeclarationContext *context) {
|
452
|
+
for (auto &child : getChildren()) {
|
453
|
+
// All JsiDomNodes has the decorateContext method - but only the
|
454
|
+
// JsiDomDeclarationNode is actually doing stuff inside this method.
|
455
|
+
child->decorateContext(context);
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
432
459
|
private:
|
433
460
|
const char *_type;
|
434
461
|
std::shared_ptr<RNSkPlatformContext> _context;
|
@@ -448,6 +475,8 @@ private:
|
|
448
475
|
std::vector<std::function<void()>> _queuedNodeOps;
|
449
476
|
|
450
477
|
JsiDomNode *_parent = nullptr;
|
478
|
+
|
479
|
+
NodeClass _nodeClass;
|
451
480
|
};
|
452
481
|
|
453
482
|
} // namespace RNSkia
|
@@ -15,6 +15,7 @@
|
|
15
15
|
|
16
16
|
#include <memory>
|
17
17
|
#include <string>
|
18
|
+
#include <vector>
|
18
19
|
|
19
20
|
namespace RNSkia {
|
20
21
|
|
@@ -22,17 +23,19 @@ class JsiDomRenderNode : public JsiDomNode {
|
|
22
23
|
public:
|
23
24
|
JsiDomRenderNode(std::shared_ptr<RNSkPlatformContext> context,
|
24
25
|
const char *type)
|
25
|
-
: JsiDomNode(context, type) {}
|
26
|
+
: JsiDomNode(context, type, NodeClass::RenderNode) {}
|
26
27
|
|
27
28
|
void render(DrawingContext *context) {
|
28
29
|
#if SKIA_DOM_DEBUG
|
29
30
|
printDebugInfo("Begin Render");
|
30
31
|
#endif
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
auto parentPaint = context->getPaint();
|
34
|
+
auto cache =
|
35
|
+
_paintCache.parent == parentPaint ? _paintCache.child : nullptr;
|
36
|
+
|
37
|
+
auto shouldRestore =
|
38
|
+
context->saveAndConcat(_paintProps, getChildren(), cache);
|
36
39
|
|
37
40
|
auto shouldTransform = _matrixProp->isSet() || _transformProp->isSet();
|
38
41
|
auto shouldSave =
|
@@ -43,37 +46,36 @@ public:
|
|
43
46
|
// Save canvas state
|
44
47
|
if (_layerProp->isSet()) {
|
45
48
|
if (_layerProp->isBool()) {
|
46
|
-
#if
|
49
|
+
#if SKIA_DOM_DEBUG_VERBOSE
|
47
50
|
printDebugInfo("canvas->saveLayer()");
|
48
51
|
#endif
|
49
|
-
|
52
|
+
context->getCanvas()->saveLayer(
|
50
53
|
SkCanvas::SaveLayerRec(nullptr, nullptr, nullptr, 0));
|
51
54
|
} else {
|
52
|
-
#if
|
55
|
+
#if SKIA_DOM_DEBUG_VERBOSE
|
53
56
|
printDebugInfo("canvas->saveLayer(paint)");
|
54
57
|
#endif
|
55
|
-
|
58
|
+
context->getCanvas()->saveLayer(SkCanvas::SaveLayerRec(
|
56
59
|
nullptr, _layerProp->getDerivedValue().get(), nullptr, 0));
|
57
60
|
}
|
58
61
|
} else {
|
59
|
-
#if
|
62
|
+
#if SKIA_DOM_DEBUG_VERBOSE
|
60
63
|
printDebugInfo("canvas->save()");
|
61
64
|
#endif
|
62
|
-
|
65
|
+
context->getCanvas()->save();
|
63
66
|
}
|
64
67
|
|
65
68
|
if (_originProp->isSet()) {
|
66
|
-
#if
|
69
|
+
#if SKIA_DOM_DEBUG_VERBOSE
|
67
70
|
printDebugInfo("canvas->translate(origin)");
|
68
71
|
#endif
|
69
72
|
// Handle origin
|
70
|
-
|
71
|
-
|
72
|
-
_originProp->getDerivedValue()->y());
|
73
|
+
context->getCanvas()->translate(_originProp->getDerivedValue()->x(),
|
74
|
+
_originProp->getDerivedValue()->y());
|
73
75
|
}
|
74
76
|
|
75
77
|
if (shouldTransform) {
|
76
|
-
#if
|
78
|
+
#if SKIA_DOM_DEBUG_VERBOSE
|
77
79
|
printDebugInfo(
|
78
80
|
"canvas->concat(" +
|
79
81
|
std::string(_matrixProp->isSet() ? "matrix" : "transform") +
|
@@ -83,43 +85,40 @@ public:
|
|
83
85
|
: _transformProp->getDerivedValue();
|
84
86
|
|
85
87
|
// Concat canvas' matrix with our matrix
|
86
|
-
|
88
|
+
context->getCanvas()->concat(*matrix);
|
87
89
|
}
|
88
90
|
|
89
91
|
// Clipping
|
90
92
|
if (_clipProp->isSet()) {
|
91
93
|
auto invert = _invertClip->isSet() && _invertClip->value().getAsBool();
|
92
|
-
clip(context,
|
94
|
+
clip(context, context->getCanvas(), invert);
|
93
95
|
}
|
94
96
|
|
95
97
|
if (_originProp->isSet()) {
|
96
|
-
#if
|
98
|
+
#if SKIA_DOM_DEBUG_VERBOSE
|
97
99
|
printDebugInfo("canvas->translate(-origin)");
|
98
100
|
#endif
|
99
101
|
// Handle origin
|
100
|
-
|
101
|
-
|
102
|
-
-_originProp->getDerivedValue()->y());
|
102
|
+
context->getCanvas()->translate(-_originProp->getDerivedValue()->x(),
|
103
|
+
-_originProp->getDerivedValue()->y());
|
103
104
|
}
|
104
105
|
}
|
105
106
|
|
106
|
-
// Let any local paint props decorate the context
|
107
|
-
_paintProps->decorate(_localContext.get());
|
108
|
-
|
109
|
-
// Now let's make sure the local context is resolved correctly - ie. that
|
110
|
-
// all children of type declaration (except paint) is given the opportunity
|
111
|
-
// to decorate the context.
|
112
|
-
materializeDeclarations();
|
113
|
-
|
114
107
|
// Render the node
|
115
|
-
renderNode(
|
108
|
+
renderNode(context);
|
116
109
|
|
117
110
|
// Restore if needed
|
118
111
|
if (shouldSave) {
|
119
|
-
#if
|
112
|
+
#if SKIA_DOM_DEBUG_VERBOSE
|
120
113
|
printDebugInfo("canvas->restore()");
|
121
114
|
#endif
|
122
|
-
|
115
|
+
context->getCanvas()->restore();
|
116
|
+
}
|
117
|
+
|
118
|
+
if (shouldRestore) {
|
119
|
+
_paintCache.parent = parentPaint;
|
120
|
+
_paintCache.child = context->getPaint();
|
121
|
+
context->restore();
|
123
122
|
}
|
124
123
|
|
125
124
|
#if SKIA_DOM_DEBUG
|
@@ -131,36 +130,22 @@ public:
|
|
131
130
|
Override reset (last thing that happens in the render cycle) to also reset
|
132
131
|
the changed flag on the local drawing context if necessary.
|
133
132
|
*/
|
134
|
-
void resetPendingChanges() override {
|
135
|
-
JsiDomNode::resetPendingChanges();
|
136
|
-
_localContext->resetChangedFlag();
|
137
|
-
}
|
133
|
+
void resetPendingChanges() override { JsiDomNode::resetPendingChanges(); }
|
138
134
|
|
139
135
|
/**
|
140
136
|
Signal from the JS side that the node is removed from the dom.
|
141
137
|
*/
|
142
|
-
void dispose() override {
|
143
|
-
JsiDomNode::dispose();
|
144
|
-
|
145
|
-
// Clear local drawing context
|
146
|
-
if (_localContext != nullptr) {
|
147
|
-
_localContext->dispose();
|
148
|
-
_localContext = nullptr;
|
149
|
-
}
|
150
|
-
}
|
151
|
-
|
152
|
-
JsiDomNodeClass getNodeClass() override {
|
153
|
-
return JsiDomNodeClass::RenderNode;
|
154
|
-
}
|
138
|
+
void dispose() override { JsiDomNode::dispose(); }
|
155
139
|
|
156
140
|
protected:
|
157
141
|
/**
|
158
142
|
Invalidates and marks then context as changed.
|
159
143
|
*/
|
160
144
|
void invalidateContext() override {
|
161
|
-
|
162
|
-
|
163
|
-
|
145
|
+
enqueAsynOperation([=]() {
|
146
|
+
_paintCache.parent = nullptr;
|
147
|
+
_paintCache.child = nullptr;
|
148
|
+
});
|
164
149
|
}
|
165
150
|
|
166
151
|
/**
|
@@ -185,6 +170,43 @@ protected:
|
|
185
170
|
_layerProp = container->defineProperty<LayerProp>("layer");
|
186
171
|
}
|
187
172
|
|
173
|
+
/**
|
174
|
+
Validates that only declaration nodes can be children
|
175
|
+
*/
|
176
|
+
void addChild(std::shared_ptr<JsiDomNode> child) override {
|
177
|
+
JsiDomNode::addChild(child);
|
178
|
+
_paintCache.parent = nullptr;
|
179
|
+
_paintCache.child = nullptr;
|
180
|
+
}
|
181
|
+
|
182
|
+
/**
|
183
|
+
Validates that only declaration nodes can be children
|
184
|
+
*/
|
185
|
+
void insertChildBefore(std::shared_ptr<JsiDomNode> child,
|
186
|
+
std::shared_ptr<JsiDomNode> before) override {
|
187
|
+
JsiDomNode::insertChildBefore(child, before);
|
188
|
+
_paintCache.parent = nullptr;
|
189
|
+
_paintCache.child = nullptr;
|
190
|
+
}
|
191
|
+
|
192
|
+
/**
|
193
|
+
A property changed
|
194
|
+
*/
|
195
|
+
void onPropertyChanged(BaseNodeProp *prop) override {
|
196
|
+
static std::vector<const char *> paintProps = {
|
197
|
+
JsiPropId::get("color"), JsiPropId::get("strokeWidth"),
|
198
|
+
JsiPropId::get("blendMode"), JsiPropId::get("strokeCap"),
|
199
|
+
JsiPropId::get("strokeJoin"), JsiPropId::get("strokeMiter"),
|
200
|
+
JsiPropId::get("style"), JsiPropId::get("antiAlias"),
|
201
|
+
JsiPropId::get("opacity")};
|
202
|
+
|
203
|
+
// We'll invalidate paint if a prop change happened in a paint property
|
204
|
+
if (std::find(paintProps.begin(), paintProps.end(), prop->getName()) !=
|
205
|
+
paintProps.end()) {
|
206
|
+
invalidateContext();
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
188
210
|
private:
|
189
211
|
/**
|
190
212
|
Clips the canvas depending on the clip property
|
@@ -209,18 +231,12 @@ private:
|
|
209
231
|
}
|
210
232
|
}
|
211
233
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
if (child->getNodeClass() == JsiDomNodeClass::DeclarationNode) {
|
219
|
-
std::static_pointer_cast<JsiBaseDomDeclarationNode>(child)
|
220
|
-
->decorateContext(_localContext.get());
|
221
|
-
}
|
222
|
-
}
|
223
|
-
}
|
234
|
+
struct PaintCache {
|
235
|
+
std::shared_ptr<SkPaint> parent;
|
236
|
+
std::shared_ptr<SkPaint> child;
|
237
|
+
};
|
238
|
+
|
239
|
+
PaintCache _paintCache;
|
224
240
|
|
225
241
|
PointProp *_originProp;
|
226
242
|
MatrixProp *_matrixProp;
|
@@ -229,8 +245,6 @@ private:
|
|
229
245
|
ClipProp *_clipProp;
|
230
246
|
LayerProp *_layerProp;
|
231
247
|
PaintProps *_paintProps;
|
232
|
-
|
233
|
-
std::shared_ptr<DrawingContext> _localContext;
|
234
248
|
};
|
235
249
|
|
236
250
|
} // namespace RNSkia
|
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
#include <chrono>
|
7
7
|
#include <memory>
|
8
|
+
#include <mutex>
|
8
9
|
#include <string>
|
9
10
|
|
10
11
|
namespace RNSkia {
|
@@ -19,8 +20,9 @@ public:
|
|
19
20
|
/**
|
20
21
|
Constructs a new optional dom node properrty
|
21
22
|
*/
|
22
|
-
explicit NodeProp(const std::string &name
|
23
|
-
|
23
|
+
explicit NodeProp(const std::string &name,
|
24
|
+
const std::function<void(BaseNodeProp *)> &onChange)
|
25
|
+
: _name(JsiPropId::get(name)), _onChange(onChange), BaseNodeProp() {}
|
24
26
|
|
25
27
|
/**
|
26
28
|
Reads JS value and swaps out with a new value
|
@@ -44,6 +46,9 @@ public:
|
|
44
46
|
_buffer->setCurrent(runtime, read(runtime, _name, this));
|
45
47
|
}
|
46
48
|
_hasNewValue = *_buffer.get() != *_value.get();
|
49
|
+
if (_hasNewValue && _onChange != nullptr) {
|
50
|
+
_onChange(this);
|
51
|
+
}
|
47
52
|
}
|
48
53
|
}
|
49
54
|
|
@@ -62,6 +67,9 @@ public:
|
|
62
67
|
// This is almost always a change - meaning a swap is
|
63
68
|
// cheaper than comparing for equality.
|
64
69
|
_hasNewValue = true;
|
70
|
+
if (_onChange != nullptr) {
|
71
|
+
_onChange(this);
|
72
|
+
}
|
65
73
|
}
|
66
74
|
|
67
75
|
/**
|
@@ -119,6 +127,8 @@ public:
|
|
119
127
|
private:
|
120
128
|
PropId _name;
|
121
129
|
|
130
|
+
std::function<void(BaseNodeProp *)> _onChange;
|
131
|
+
|
122
132
|
std::shared_ptr<JsiValue> _value;
|
123
133
|
std::shared_ptr<JsiValue> _buffer;
|
124
134
|
std::atomic<bool> _isChanged = {false};
|
@@ -20,11 +20,12 @@ namespace RNSkia {
|
|
20
20
|
class NodePropsContainer {
|
21
21
|
public:
|
22
22
|
/**
|
23
|
-
Constructor
|
24
|
-
and a function that will be called when any property was changed from within
|
25
|
-
this class as a result of a Skia value change.
|
23
|
+
Constructor for the node prop container
|
26
24
|
*/
|
27
|
-
explicit NodePropsContainer(
|
25
|
+
explicit NodePropsContainer(
|
26
|
+
PropId componentType,
|
27
|
+
const std::function<void(BaseNodeProp *)> &onPropChanged)
|
28
|
+
: _onPropChanged(onPropChanged), _type(componentType) {}
|
28
29
|
|
29
30
|
/**
|
30
31
|
Returns true if there are any changes in the props container in the current
|
@@ -102,25 +103,23 @@ public:
|
|
102
103
|
}
|
103
104
|
|
104
105
|
/**
|
105
|
-
Defines a property that will be
|
106
|
-
*/
|
107
|
-
template <typename T = BaseNodeProp>
|
108
|
-
T *defineProperty(std::shared_ptr<T> prop) {
|
109
|
-
_properties.push_back(prop);
|
110
|
-
return prop.get();
|
111
|
-
}
|
112
|
-
|
113
|
-
/**
|
114
|
-
Defines a property that will be updated with the container changes.
|
106
|
+
Defines a property that will be added to the container
|
115
107
|
*/
|
116
108
|
template <class _Tp, class... _Args,
|
117
109
|
class = std::_EnableIf<!std::is_array<_Tp>::value>>
|
118
110
|
_Tp *defineProperty(_Args &&...__args) {
|
119
|
-
|
120
|
-
|
111
|
+
// Create property and set onChange callback
|
112
|
+
auto prop =
|
113
|
+
std::make_shared<_Tp>(std::forward<_Args>(__args)..., _onPropChanged);
|
114
|
+
|
115
|
+
// Add to props list
|
116
|
+
_properties.push_back(prop);
|
117
|
+
|
118
|
+
return prop.get();
|
121
119
|
}
|
122
120
|
|
123
121
|
private:
|
122
|
+
std::function<void(BaseNodeProp *)> _onPropChanged;
|
124
123
|
std::vector<std::shared_ptr<BaseNodeProp>> _properties;
|
125
124
|
std::map<PropId, std::vector<NodeProp *>> _mappedProperties;
|
126
125
|
PropId _type;
|
@@ -15,22 +15,33 @@ public:
|
|
15
15
|
|
16
16
|
protected:
|
17
17
|
void draw(DrawingContext *context) override {
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
auto children = getChildren();
|
19
|
+
|
20
|
+
if (children.size() == 0) {
|
21
|
+
return;
|
21
22
|
}
|
22
|
-
auto child = getChildren()[0];
|
23
|
-
auto colorFilter = std::dynamic_pointer_cast<JsiBaseColorFilterNode>(child);
|
24
|
-
auto imageFilter = std::dynamic_pointer_cast<JsiBaseImageFilterNode>(child);
|
25
23
|
|
26
24
|
auto canvas = context->getCanvas();
|
27
|
-
auto
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
auto firstChild = children[0];
|
26
|
+
sk_sp<SkImageFilter> imageFilter;
|
27
|
+
|
28
|
+
if (firstChild->getNodeClass() == NodeClass::DeclarationNode) {
|
29
|
+
context->getDeclarationContext()->save();
|
30
|
+
firstChild->decorateContext(context->getDeclarationContext());
|
31
|
+
auto imgF = context->getDeclarationContext()->getImageFilters()->pop();
|
32
|
+
if (imgF) {
|
33
|
+
imageFilter = imgF;
|
34
|
+
} else {
|
35
|
+
auto cf = context->getDeclarationContext()->getColorFilters()->pop();
|
36
|
+
if (cf) {
|
37
|
+
imageFilter = SkImageFilters::ColorFilter(cf, nullptr);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
context->getDeclarationContext()->restore();
|
41
|
+
}
|
31
42
|
|
32
43
|
canvas->saveLayer(
|
33
|
-
SkCanvas::SaveLayerRec(nullptr, nullptr,
|
44
|
+
SkCanvas::SaveLayerRec(nullptr, nullptr, imageFilter.get(), 0));
|
34
45
|
canvas->restore();
|
35
46
|
}
|
36
47
|
};
|