@shopify/react-native-skia 1.11.1 → 1.11.3
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +0 -8
- package/android/cpp/jni/JniLoad.cpp +0 -2
- package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +1 -1
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaPictureViewManagerDelegate.java +4 -2
- package/cpp/jsi/ViewProperty.h +5 -16
- package/cpp/rnskia/RNSkManager.cpp +1 -7
- package/lib/commonjs/dom/nodes/index.d.ts +0 -1
- package/lib/commonjs/dom/nodes/index.js +0 -11
- package/lib/commonjs/dom/nodes/index.js.map +1 -1
- package/lib/commonjs/external/reanimated/renderHelpers.d.ts +0 -6
- package/lib/commonjs/external/reanimated/renderHelpers.js +0 -73
- package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/commonjs/index.d.ts +0 -1
- package/lib/commonjs/index.js +0 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.d.ts +10 -1
- package/lib/commonjs/renderer/Canvas.js +3 -1
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/sksg/Container.d.ts +2 -0
- package/lib/commonjs/sksg/Container.js +10 -0
- package/lib/commonjs/sksg/Container.js.map +1 -1
- package/lib/commonjs/sksg/Elements.d.ts +65 -0
- package/lib/commonjs/sksg/Elements.js +6 -0
- package/lib/commonjs/sksg/Elements.js.map +1 -0
- package/lib/commonjs/sksg/Reconciler.d.ts +1 -0
- package/lib/commonjs/sksg/Reconciler.js +2 -0
- package/lib/commonjs/sksg/Reconciler.js.map +1 -1
- package/lib/commonjs/views/index.d.ts +0 -1
- package/lib/commonjs/views/index.js +0 -11
- package/lib/commonjs/views/index.js.map +1 -1
- package/lib/module/dom/nodes/index.d.ts +0 -1
- package/lib/module/dom/nodes/index.js +0 -1
- package/lib/module/dom/nodes/index.js.map +1 -1
- package/lib/module/external/reanimated/renderHelpers.d.ts +0 -6
- package/lib/module/external/reanimated/renderHelpers.js +0 -68
- package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/module/index.d.ts +0 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +10 -1
- package/lib/module/renderer/Canvas.js +1 -0
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/sksg/Container.d.ts +2 -0
- package/lib/module/sksg/Container.js +10 -0
- package/lib/module/sksg/Container.js.map +1 -1
- package/lib/module/sksg/Elements.d.ts +65 -0
- package/lib/module/sksg/Elements.js +2 -0
- package/lib/module/sksg/Elements.js.map +1 -0
- package/lib/module/sksg/Reconciler.d.ts +1 -0
- package/lib/module/sksg/Reconciler.js +2 -0
- package/lib/module/sksg/Reconciler.js.map +1 -1
- package/lib/module/views/index.d.ts +0 -1
- package/lib/module/views/index.js +0 -1
- package/lib/module/views/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +0 -3
- package/lib/typescript/lib/commonjs/renderer/Canvas.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Container.d.ts +2 -0
- package/lib/typescript/lib/commonjs/sksg/Elements.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +6 -0
- package/lib/typescript/lib/module/dom/nodes/index.d.ts +0 -1
- package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +0 -3
- package/lib/typescript/lib/module/index.d.ts +0 -1
- package/lib/typescript/lib/module/mock/index.d.ts +0 -1
- package/lib/typescript/lib/module/renderer/Canvas.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Container.d.ts +2 -0
- package/lib/typescript/lib/module/sksg/Elements.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Reconciler.d.ts +6 -0
- package/lib/typescript/lib/module/views/index.d.ts +0 -1
- package/lib/typescript/src/dom/nodes/index.d.ts +0 -1
- package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +0 -6
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/renderer/Canvas.d.ts +10 -1
- package/lib/typescript/src/sksg/Container.d.ts +2 -0
- package/lib/typescript/src/sksg/Elements.d.ts +65 -0
- package/lib/typescript/src/sksg/Reconciler.d.ts +1 -0
- package/lib/typescript/src/views/index.d.ts +0 -1
- package/package.json +1 -1
- package/react-native-skia.podspec +1 -1
- package/src/dom/nodes/index.ts +0 -1
- package/src/external/reanimated/renderHelpers.ts +1 -78
- package/src/index.ts +0 -1
- package/src/renderer/Canvas.tsx +11 -1
- package/src/sksg/Container.ts +11 -0
- package/src/sksg/Elements.tsx +136 -0
- package/src/sksg/Reconciler.ts +2 -0
- package/src/views/index.ts +0 -1
- package/android/cpp/jni/include/JniSkiaDomView.h +0 -82
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomView.java +0 -41
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomViewManager.java +0 -32
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerDelegate.java +0 -34
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerInterface.java +0 -18
- package/cpp/rnskia/RNSkDomView.cpp +0 -121
- package/cpp/rnskia/RNSkDomView.h +0 -97
- package/cpp/rnskia/dom/JsiDomApi.h +0 -165
- package/cpp/rnskia/dom/base/BaseNodeProp.h +0 -72
- package/cpp/rnskia/dom/base/ConcatablePaint.cpp +0 -117
- package/cpp/rnskia/dom/base/ConcatablePaint.h +0 -49
- package/cpp/rnskia/dom/base/Declaration.h +0 -86
- package/cpp/rnskia/dom/base/DeclarationContext.h +0 -79
- package/cpp/rnskia/dom/base/DerivedNodeProp.h +0 -203
- package/cpp/rnskia/dom/base/DrawingContext.cpp +0 -55
- package/cpp/rnskia/dom/base/DrawingContext.h +0 -104
- package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +0 -119
- package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +0 -71
- package/cpp/rnskia/dom/base/JsiDomNode.h +0 -572
- package/cpp/rnskia/dom/base/JsiDomRenderNode.h +0 -262
- package/cpp/rnskia/dom/base/NodeProp.h +0 -139
- package/cpp/rnskia/dom/base/NodePropsContainer.h +0 -158
- package/cpp/rnskia/dom/nodes/JsiAtlasNode.h +0 -64
- package/cpp/rnskia/dom/nodes/JsiBackdropFilterNode.h +0 -49
- package/cpp/rnskia/dom/nodes/JsiBlendNode.h +0 -94
- package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +0 -75
- package/cpp/rnskia/dom/nodes/JsiBoxNode.h +0 -94
- package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +0 -33
- package/cpp/rnskia/dom/nodes/JsiCircleNode.h +0 -35
- package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +0 -164
- package/cpp/rnskia/dom/nodes/JsiDiffRectNode.h +0 -37
- package/cpp/rnskia/dom/nodes/JsiFillNode.h +0 -22
- package/cpp/rnskia/dom/nodes/JsiGlyphsNode.h +0 -53
- package/cpp/rnskia/dom/nodes/JsiGroupNode.h +0 -25
- package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +0 -361
- package/cpp/rnskia/dom/nodes/JsiImageNode.h +0 -43
- package/cpp/rnskia/dom/nodes/JsiImageSvgNode.h +0 -63
- package/cpp/rnskia/dom/nodes/JsiLayerNode.h +0 -74
- package/cpp/rnskia/dom/nodes/JsiLineNode.h +0 -38
- package/cpp/rnskia/dom/nodes/JsiOvalNode.h +0 -32
- package/cpp/rnskia/dom/nodes/JsiPaintNode.h +0 -119
- package/cpp/rnskia/dom/nodes/JsiParagraphNode.h +0 -62
- package/cpp/rnskia/dom/nodes/JsiPatchNode.h +0 -50
- package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +0 -268
- package/cpp/rnskia/dom/nodes/JsiPathNode.h +0 -181
- package/cpp/rnskia/dom/nodes/JsiPictureNode.h +0 -31
- package/cpp/rnskia/dom/nodes/JsiPointsNode.h +0 -48
- package/cpp/rnskia/dom/nodes/JsiRRectNode.h +0 -33
- package/cpp/rnskia/dom/nodes/JsiRectNode.h +0 -33
- package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +0 -434
- package/cpp/rnskia/dom/nodes/JsiTextBlobNode.h +0 -44
- package/cpp/rnskia/dom/nodes/JsiTextNode.h +0 -51
- package/cpp/rnskia/dom/nodes/JsiTextPathNode.h +0 -33
- package/cpp/rnskia/dom/nodes/JsiVerticesNode.h +0 -41
- package/cpp/rnskia/dom/props/BezierProps.h +0 -65
- package/cpp/rnskia/dom/props/BlendModeProp.h +0 -103
- package/cpp/rnskia/dom/props/BoxShadowProps.h +0 -62
- package/cpp/rnskia/dom/props/CircleProp.h +0 -49
- package/cpp/rnskia/dom/props/ClipProp.h +0 -57
- package/cpp/rnskia/dom/props/ColorProp.h +0 -96
- package/cpp/rnskia/dom/props/FontProp.h +0 -42
- package/cpp/rnskia/dom/props/GlyphsProp.h +0 -55
- package/cpp/rnskia/dom/props/LayerProp.h +0 -52
- package/cpp/rnskia/dom/props/MatrixProp.h +0 -54
- package/cpp/rnskia/dom/props/NumbersProp.h +0 -67
- package/cpp/rnskia/dom/props/PaintProps.h +0 -133
- package/cpp/rnskia/dom/props/ParagraphProp.h +0 -45
- package/cpp/rnskia/dom/props/PathProp.h +0 -59
- package/cpp/rnskia/dom/props/PictureProp.h +0 -40
- package/cpp/rnskia/dom/props/PointProp.h +0 -65
- package/cpp/rnskia/dom/props/PointsProp.h +0 -81
- package/cpp/rnskia/dom/props/RRectProp.h +0 -222
- package/cpp/rnskia/dom/props/RSXformProp.h +0 -52
- package/cpp/rnskia/dom/props/RadiusProp.h +0 -43
- package/cpp/rnskia/dom/props/RectProp.h +0 -164
- package/cpp/rnskia/dom/props/SamplingProp.h +0 -54
- package/cpp/rnskia/dom/props/SkImageProps.h +0 -196
- package/cpp/rnskia/dom/props/StrokeProps.h +0 -79
- package/cpp/rnskia/dom/props/SvgProp.h +0 -45
- package/cpp/rnskia/dom/props/TextBlobProp.h +0 -133
- package/cpp/rnskia/dom/props/TileModeProp.h +0 -52
- package/cpp/rnskia/dom/props/TransformProp.h +0 -147
- package/cpp/rnskia/dom/props/TransformsProps.h +0 -66
- package/cpp/rnskia/dom/props/UniformsProp.h +0 -159
- package/cpp/rnskia/dom/props/VertexModeProp.h +0 -49
- package/cpp/rnskia/dom/props/VerticesProps.h +0 -63
- package/ios/RNSkia-iOS/SkiaDomView.h +0 -7
- package/ios/RNSkia-iOS/SkiaDomView.mm +0 -63
- package/ios/RNSkia-iOS/SkiaDomViewManager.h +0 -8
- package/ios/RNSkia-iOS/SkiaDomViewManager.mm +0 -51
- package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +0 -64
- package/lib/commonjs/dom/nodes/JsiSkDOM.js +0 -196
- package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +0 -1
- package/lib/commonjs/renderer/CanvasOld.d.ts +0 -11
- package/lib/commonjs/renderer/CanvasOld.js +0 -96
- package/lib/commonjs/renderer/CanvasOld.js.map +0 -1
- package/lib/commonjs/renderer/Container.d.ts +0 -10
- package/lib/commonjs/renderer/Container.js +0 -26
- package/lib/commonjs/renderer/Container.js.map +0 -1
- package/lib/commonjs/renderer/HostComponents.d.ts +0 -129
- package/lib/commonjs/renderer/HostComponents.js +0 -141
- package/lib/commonjs/renderer/HostComponents.js.map +0 -1
- package/lib/commonjs/renderer/HostConfig.d.ts +0 -18
- package/lib/commonjs/renderer/HostConfig.js +0 -157
- package/lib/commonjs/renderer/HostConfig.js.map +0 -1
- package/lib/commonjs/renderer/Reconciler.d.ts +0 -9
- package/lib/commonjs/renderer/Reconciler.js +0 -44
- package/lib/commonjs/renderer/Reconciler.js.map +0 -1
- package/lib/commonjs/specs/SkiaDomViewNativeComponent.d.ts +0 -6
- package/lib/commonjs/specs/SkiaDomViewNativeComponent.js +0 -11
- package/lib/commonjs/specs/SkiaDomViewNativeComponent.js.map +0 -1
- package/lib/commonjs/views/SkiaDomView.d.ts +0 -33
- package/lib/commonjs/views/SkiaDomView.js +0 -119
- package/lib/commonjs/views/SkiaDomView.js.map +0 -1
- package/lib/commonjs/views/SkiaDomView.web.d.ts +0 -0
- package/lib/commonjs/views/SkiaDomView.web.js +0 -2
- package/lib/commonjs/views/SkiaDomView.web.js.map +0 -1
- package/lib/module/dom/nodes/JsiSkDOM.d.ts +0 -64
- package/lib/module/dom/nodes/JsiSkDOM.js +0 -189
- package/lib/module/dom/nodes/JsiSkDOM.js.map +0 -1
- package/lib/module/renderer/CanvasOld.d.ts +0 -11
- package/lib/module/renderer/CanvasOld.js +0 -87
- package/lib/module/renderer/CanvasOld.js.map +0 -1
- package/lib/module/renderer/Container.d.ts +0 -10
- package/lib/module/renderer/Container.js +0 -19
- package/lib/module/renderer/Container.js.map +0 -1
- package/lib/module/renderer/HostComponents.d.ts +0 -129
- package/lib/module/renderer/HostComponents.js +0 -134
- package/lib/module/renderer/HostComponents.js.map +0 -1
- package/lib/module/renderer/HostConfig.d.ts +0 -18
- package/lib/module/renderer/HostConfig.js +0 -150
- package/lib/module/renderer/HostConfig.js.map +0 -1
- package/lib/module/renderer/Reconciler.d.ts +0 -9
- package/lib/module/renderer/Reconciler.js +0 -36
- package/lib/module/renderer/Reconciler.js.map +0 -1
- package/lib/module/specs/SkiaDomViewNativeComponent.d.ts +0 -6
- package/lib/module/specs/SkiaDomViewNativeComponent.js +0 -4
- package/lib/module/specs/SkiaDomViewNativeComponent.js.map +0 -1
- package/lib/module/views/SkiaDomView.d.ts +0 -33
- package/lib/module/views/SkiaDomView.js +0 -111
- package/lib/module/views/SkiaDomView.js.map +0 -1
- package/lib/module/views/SkiaDomView.web.d.ts +0 -0
- package/lib/module/views/SkiaDomView.web.js +0 -2
- package/lib/module/views/SkiaDomView.web.js.map +0 -1
- package/lib/typescript/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +0 -60
- package/lib/typescript/lib/commonjs/renderer/CanvasOld.d.ts +0 -3
- package/lib/typescript/lib/commonjs/renderer/Container.d.ts +0 -9
- package/lib/typescript/lib/commonjs/renderer/HostComponents.d.ts +0 -2
- package/lib/typescript/lib/commonjs/renderer/HostConfig.d.ts +0 -40
- package/lib/typescript/lib/commonjs/renderer/Reconciler.d.ts +0 -10
- package/lib/typescript/lib/commonjs/specs/SkiaDomViewNativeComponent.d.ts +0 -3
- package/lib/typescript/lib/commonjs/views/SkiaDomView.d.ts +0 -30
- package/lib/typescript/lib/commonjs/views/SkiaDomView.web.d.ts +0 -0
- package/lib/typescript/lib/module/dom/nodes/JsiSkDOM.d.ts +0 -59
- package/lib/typescript/lib/module/renderer/CanvasOld.d.ts +0 -3
- package/lib/typescript/lib/module/renderer/Container.d.ts +0 -9
- package/lib/typescript/lib/module/renderer/HostComponents.d.ts +0 -1
- package/lib/typescript/lib/module/renderer/HostConfig.d.ts +0 -39
- package/lib/typescript/lib/module/renderer/Reconciler.d.ts +0 -9
- package/lib/typescript/lib/module/specs/SkiaDomViewNativeComponent.d.ts +0 -2
- package/lib/typescript/lib/module/views/SkiaDomView.d.ts +0 -27
- package/lib/typescript/lib/module/views/SkiaDomView.web.d.ts +0 -0
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +0 -64
- package/lib/typescript/src/renderer/CanvasOld.d.ts +0 -11
- package/lib/typescript/src/renderer/Container.d.ts +0 -10
- package/lib/typescript/src/renderer/HostComponents.d.ts +0 -129
- package/lib/typescript/src/renderer/HostConfig.d.ts +0 -18
- package/lib/typescript/src/renderer/Reconciler.d.ts +0 -9
- package/lib/typescript/src/specs/SkiaDomViewNativeComponent.d.ts +0 -6
- package/lib/typescript/src/views/SkiaDomView.d.ts +0 -33
- package/lib/typescript/src/views/SkiaDomView.web.d.ts +0 -0
- package/src/dom/nodes/JsiSkDOM.ts +0 -298
- package/src/renderer/CanvasOld.tsx +0 -126
- package/src/renderer/Container.tsx +0 -19
- package/src/renderer/HostComponents.ts +0 -399
- package/src/renderer/HostConfig.ts +0 -258
- package/src/renderer/Reconciler.tsx +0 -54
- package/src/specs/SkiaDomViewNativeComponent.ts +0 -9
- package/src/views/SkiaDomView.tsx +0 -124
- package/src/views/SkiaDomView.web.tsx +0 -0
@@ -1,119 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#include "JsiDomDeclarationNode.h"
|
4
|
-
#include "PaintProps.h"
|
5
|
-
|
6
|
-
#include <memory>
|
7
|
-
|
8
|
-
namespace RNSkia {
|
9
|
-
|
10
|
-
class JsiPaintNode : public JsiDomDeclarationNode,
|
11
|
-
public JsiDomNodeCtor<JsiPaintNode> {
|
12
|
-
public:
|
13
|
-
explicit JsiPaintNode(std::shared_ptr<RNSkPlatformContext> context)
|
14
|
-
: JsiDomDeclarationNode(context, "skPaint", DeclarationType::Paint) {}
|
15
|
-
|
16
|
-
void decorate(DeclarationContext *context) override {
|
17
|
-
auto paint = std::make_shared<SkPaint>();
|
18
|
-
paint->setAntiAlias(true);
|
19
|
-
|
20
|
-
if (_paintProps->getOpacity()->isSet()) {
|
21
|
-
paint->setAlphaf(paint->getAlphaf() *
|
22
|
-
_paintProps->getOpacity()->value().getAsNumber());
|
23
|
-
}
|
24
|
-
|
25
|
-
if (_paintProps->getColor()->isSet()) {
|
26
|
-
auto currentOpacity = paint->getAlphaf();
|
27
|
-
paint->setShader(nullptr);
|
28
|
-
paint->setColor(*_paintProps->getColor()->getDerivedValue());
|
29
|
-
paint->setAlphaf(paint->getAlphaf() * currentOpacity);
|
30
|
-
}
|
31
|
-
|
32
|
-
if (_paintProps->getStrokeWidth()->isSet()) {
|
33
|
-
paint->setStrokeWidth(
|
34
|
-
_paintProps->getStrokeWidth()->value().getAsNumber());
|
35
|
-
}
|
36
|
-
|
37
|
-
if (_paintProps->getBlendMode()->isSet()) {
|
38
|
-
paint->setBlendMode(*_paintProps->getBlendMode()->getDerivedValue());
|
39
|
-
}
|
40
|
-
|
41
|
-
if (_paintProps->getStyle()->isSet()) {
|
42
|
-
auto styleValue = _paintProps->getStyle()->value().getAsString();
|
43
|
-
if (styleValue == "stroke") {
|
44
|
-
paint->setStyle(SkPaint::Style::kStroke_Style);
|
45
|
-
} else if (styleValue == "fill") {
|
46
|
-
paint->setStyle(SkPaint::Style::kFill_Style);
|
47
|
-
} else {
|
48
|
-
throw std::runtime_error(
|
49
|
-
styleValue + " is not a valud value for the style property.");
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
if (_paintProps->getStrokeJoin()->isSet()) {
|
54
|
-
paint->setStrokeJoin(*_paintProps->getStrokeJoin()->getDerivedValue());
|
55
|
-
}
|
56
|
-
|
57
|
-
if (_paintProps->getStrokeCap()->isSet()) {
|
58
|
-
paint->setStrokeCap(*_paintProps->getStrokeCap()->getDerivedValue());
|
59
|
-
}
|
60
|
-
|
61
|
-
if (_paintProps->getStrokeMiter()->isSet()) {
|
62
|
-
paint->setStrokeMiter(
|
63
|
-
_paintProps->getStrokeMiter()->value().getAsNumber());
|
64
|
-
}
|
65
|
-
|
66
|
-
if (_paintProps->getAntiAlias()->isSet()) {
|
67
|
-
paint->setAntiAlias(_paintProps->getAntiAlias()->value().getAsBool());
|
68
|
-
}
|
69
|
-
|
70
|
-
if (_paintProps->getDither()->isSet()) {
|
71
|
-
paint->setDither(_paintProps->getDither()->value().getAsBool());
|
72
|
-
}
|
73
|
-
|
74
|
-
context->save();
|
75
|
-
decorateChildren(context);
|
76
|
-
|
77
|
-
auto imageFilter = context->getImageFilters()->popAsOne();
|
78
|
-
auto colorFilter = context->getColorFilters()->popAsOne();
|
79
|
-
auto shader = context->getShaders()->pop();
|
80
|
-
auto maskFilter = context->getMaskFilters()->pop();
|
81
|
-
auto pathEffect = context->getPathEffects()->popAsOne();
|
82
|
-
|
83
|
-
context->restore();
|
84
|
-
|
85
|
-
if (imageFilter) {
|
86
|
-
paint->setImageFilter(imageFilter);
|
87
|
-
}
|
88
|
-
|
89
|
-
if (colorFilter) {
|
90
|
-
paint->setColorFilter(colorFilter);
|
91
|
-
}
|
92
|
-
|
93
|
-
if (shader) {
|
94
|
-
paint->setShader(shader);
|
95
|
-
}
|
96
|
-
|
97
|
-
if (maskFilter) {
|
98
|
-
paint->setMaskFilter(maskFilter);
|
99
|
-
}
|
100
|
-
|
101
|
-
if (pathEffect) {
|
102
|
-
paint->setPathEffect(pathEffect);
|
103
|
-
}
|
104
|
-
|
105
|
-
context->getPaints()->push(paint);
|
106
|
-
}
|
107
|
-
|
108
|
-
protected:
|
109
|
-
void defineProperties(NodePropsContainer *container) override {
|
110
|
-
JsiDomDeclarationNode::defineProperties(container);
|
111
|
-
|
112
|
-
_paintProps = container->defineProperty<PaintProps>();
|
113
|
-
}
|
114
|
-
|
115
|
-
private:
|
116
|
-
PaintProps *_paintProps;
|
117
|
-
};
|
118
|
-
|
119
|
-
} // namespace RNSkia
|
@@ -1,62 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#include "JsiDomDrawingNode.h"
|
4
|
-
#include "ParagraphProp.h"
|
5
|
-
|
6
|
-
#include <memory>
|
7
|
-
|
8
|
-
namespace RNSkia {
|
9
|
-
|
10
|
-
class JsiParagraphNode : public JsiDomDrawingNode,
|
11
|
-
public JsiDomNodeCtor<JsiParagraphNode> {
|
12
|
-
public:
|
13
|
-
explicit JsiParagraphNode(std::shared_ptr<RNSkPlatformContext> context)
|
14
|
-
: JsiDomDrawingNode(context, "skParagraph") {}
|
15
|
-
|
16
|
-
protected:
|
17
|
-
void draw(DrawingContext *context) override {
|
18
|
-
auto x = _xProp->value().getAsNumber();
|
19
|
-
auto y = _yProp->value().getAsNumber();
|
20
|
-
auto width = static_cast<SkScalar>(_widthProp->value().getAsNumber());
|
21
|
-
|
22
|
-
auto p = *_paragraphProp->getDerivedValue();
|
23
|
-
if (p != nullptr) {
|
24
|
-
|
25
|
-
// Let's ensure that we don't perform unnecessary layouts on the
|
26
|
-
// paragraph. We should only layout if we have a new paragraph or if the
|
27
|
-
// layout width has changed.
|
28
|
-
if (_lastLayoutWidth != width || _lastLayoutParagraph != p) {
|
29
|
-
// perform layout!
|
30
|
-
p->layout(width);
|
31
|
-
_lastLayoutWidth = width;
|
32
|
-
_lastLayoutParagraph = p;
|
33
|
-
}
|
34
|
-
// Paint the layout to the canvas
|
35
|
-
p->paint(context->getCanvas(), x, y);
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
void defineProperties(NodePropsContainer *container) override {
|
40
|
-
JsiDomDrawingNode::defineProperties(container);
|
41
|
-
_paragraphProp = container->defineProperty<ParagraphProp>("paragraph");
|
42
|
-
|
43
|
-
_xProp = container->defineProperty<NodeProp>("x");
|
44
|
-
_xProp->require();
|
45
|
-
|
46
|
-
_yProp = container->defineProperty<NodeProp>("y");
|
47
|
-
_yProp->require();
|
48
|
-
|
49
|
-
_widthProp = container->defineProperty<NodeProp>("width");
|
50
|
-
_widthProp->require();
|
51
|
-
}
|
52
|
-
|
53
|
-
private:
|
54
|
-
ParagraphProp *_paragraphProp;
|
55
|
-
NodeProp *_xProp;
|
56
|
-
NodeProp *_yProp;
|
57
|
-
NodeProp *_widthProp;
|
58
|
-
SkScalar _lastLayoutWidth;
|
59
|
-
para::Paragraph *_lastLayoutParagraph = nullptr;
|
60
|
-
};
|
61
|
-
|
62
|
-
} // namespace RNSkia
|
@@ -1,50 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#include "BezierProps.h"
|
4
|
-
#include "BlendModeProp.h"
|
5
|
-
#include "ColorProp.h"
|
6
|
-
#include "JsiDomDrawingNode.h"
|
7
|
-
#include "PointsProp.h"
|
8
|
-
|
9
|
-
#include <memory>
|
10
|
-
|
11
|
-
namespace RNSkia {
|
12
|
-
|
13
|
-
class JsiPatchNode : public JsiDomDrawingNode,
|
14
|
-
public JsiDomNodeCtor<JsiPatchNode> {
|
15
|
-
public:
|
16
|
-
explicit JsiPatchNode(std::shared_ptr<RNSkPlatformContext> context)
|
17
|
-
: JsiDomDrawingNode(context, "skPatch") {}
|
18
|
-
|
19
|
-
protected:
|
20
|
-
void draw(DrawingContext *context) override {
|
21
|
-
SkBlendMode defaultBlendMode =
|
22
|
-
_colorsProp->isSet() ? SkBlendMode::kDstOver : SkBlendMode::kSrcOver;
|
23
|
-
context->getCanvas()->drawPatch(
|
24
|
-
_patchProp->getDerivedValue()->data(),
|
25
|
-
_colorsProp->isSet() ? _colorsProp->getDerivedValue()->data() : nullptr,
|
26
|
-
_textureProp->isSet() ? _textureProp->getDerivedValue()->data()
|
27
|
-
: nullptr,
|
28
|
-
_blendModeProp->isSet() ? *_blendModeProp->getDerivedValue()
|
29
|
-
: defaultBlendMode,
|
30
|
-
*context->getPaint());
|
31
|
-
}
|
32
|
-
|
33
|
-
void defineProperties(NodePropsContainer *container) override {
|
34
|
-
JsiDomDrawingNode::defineProperties(container);
|
35
|
-
_colorsProp = container->defineProperty<ColorsProp>("colors");
|
36
|
-
_textureProp = container->defineProperty<PointsProp>("texture");
|
37
|
-
_blendModeProp = container->defineProperty<BlendModeProp>("blendMode");
|
38
|
-
_patchProp = container->defineProperty<BezierProp>("patch");
|
39
|
-
|
40
|
-
_patchProp->require();
|
41
|
-
}
|
42
|
-
|
43
|
-
private:
|
44
|
-
ColorsProp *_colorsProp;
|
45
|
-
PointsProp *_textureProp;
|
46
|
-
BlendModeProp *_blendModeProp;
|
47
|
-
BezierProp *_patchProp;
|
48
|
-
};
|
49
|
-
|
50
|
-
} // namespace RNSkia
|
@@ -1,268 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#include "JsiDomDeclarationNode.h"
|
4
|
-
|
5
|
-
#include "NodeProp.h"
|
6
|
-
|
7
|
-
#include <memory>
|
8
|
-
#include <string>
|
9
|
-
#include <vector>
|
10
|
-
|
11
|
-
#pragma clang diagnostic push
|
12
|
-
#pragma clang diagnostic ignored "-Wdocumentation"
|
13
|
-
|
14
|
-
#include "include/core/SkPathEffect.h"
|
15
|
-
|
16
|
-
#pragma clang diagnostic pop
|
17
|
-
|
18
|
-
namespace RNSkia {
|
19
|
-
|
20
|
-
class JsiBasePathEffectNode : public JsiDomDeclarationNode {
|
21
|
-
public:
|
22
|
-
JsiBasePathEffectNode(std::shared_ptr<RNSkPlatformContext> context,
|
23
|
-
const char *type)
|
24
|
-
: JsiDomDeclarationNode(context, type, DeclarationType::PathEffect) {}
|
25
|
-
|
26
|
-
protected:
|
27
|
-
void composeAndPush(DeclarationContext *context, sk_sp<SkPathEffect> pe1) {
|
28
|
-
context->save();
|
29
|
-
decorateChildren(context);
|
30
|
-
auto pe2 = context->getPathEffects()->popAsOne();
|
31
|
-
context->restore();
|
32
|
-
auto pe = pe2 ? SkPathEffect::MakeCompose(pe1, pe2) : pe1;
|
33
|
-
context->getPathEffects()->push(pe);
|
34
|
-
}
|
35
|
-
};
|
36
|
-
|
37
|
-
class JsiDashPathEffectNode : public JsiBasePathEffectNode,
|
38
|
-
public JsiDomNodeCtor<JsiDashPathEffectNode> {
|
39
|
-
public:
|
40
|
-
explicit JsiDashPathEffectNode(std::shared_ptr<RNSkPlatformContext> context)
|
41
|
-
: JsiBasePathEffectNode(context, "skDashPathEffect") {}
|
42
|
-
|
43
|
-
void decorate(DeclarationContext *context) override {
|
44
|
-
|
45
|
-
// Phase
|
46
|
-
auto phase = _phase->isSet() ? _phase->value().getAsNumber() : 0;
|
47
|
-
|
48
|
-
// Copy intervals
|
49
|
-
std::vector<SkScalar> intervals;
|
50
|
-
auto intervalsArray = _intervals->value().getAsArray();
|
51
|
-
for (size_t i = 0; i < intervalsArray.size(); ++i) {
|
52
|
-
intervals.push_back(intervalsArray[i].getAsNumber());
|
53
|
-
}
|
54
|
-
|
55
|
-
// Create effect
|
56
|
-
auto pathEffect = SkDashPathEffect::Make(
|
57
|
-
intervals.data(), static_cast<int>(intervals.size()), phase);
|
58
|
-
|
59
|
-
composeAndPush(context, pathEffect);
|
60
|
-
}
|
61
|
-
|
62
|
-
protected:
|
63
|
-
void defineProperties(NodePropsContainer *container) override {
|
64
|
-
JsiDomDeclarationNode::defineProperties(container);
|
65
|
-
|
66
|
-
_intervals = container->defineProperty<NodeProp>("intervals");
|
67
|
-
_phase = container->defineProperty<NodeProp>("phase");
|
68
|
-
|
69
|
-
_intervals->require();
|
70
|
-
}
|
71
|
-
|
72
|
-
private:
|
73
|
-
NodeProp *_intervals;
|
74
|
-
NodeProp *_phase;
|
75
|
-
};
|
76
|
-
|
77
|
-
class JsiDiscretePathEffectNode
|
78
|
-
: public JsiBasePathEffectNode,
|
79
|
-
public JsiDomNodeCtor<JsiDiscretePathEffectNode> {
|
80
|
-
public:
|
81
|
-
explicit JsiDiscretePathEffectNode(
|
82
|
-
std::shared_ptr<RNSkPlatformContext> context)
|
83
|
-
: JsiBasePathEffectNode(context, "skDiscretePathEffect") {}
|
84
|
-
|
85
|
-
void decorate(DeclarationContext *context) override {
|
86
|
-
// Create effect
|
87
|
-
auto pathEffect =
|
88
|
-
SkDiscretePathEffect::Make(_lengthProp->value().getAsNumber(),
|
89
|
-
_deviationProp->value().getAsNumber(),
|
90
|
-
_seedProp->value().getAsNumber());
|
91
|
-
|
92
|
-
composeAndPush(context, pathEffect);
|
93
|
-
}
|
94
|
-
|
95
|
-
protected:
|
96
|
-
void defineProperties(NodePropsContainer *container) override {
|
97
|
-
JsiDomDeclarationNode::defineProperties(container);
|
98
|
-
|
99
|
-
_lengthProp = container->defineProperty<NodeProp>("length");
|
100
|
-
_deviationProp = container->defineProperty<NodeProp>("deviation");
|
101
|
-
_seedProp = container->defineProperty<NodeProp>("seed");
|
102
|
-
|
103
|
-
_lengthProp->require();
|
104
|
-
_deviationProp->require();
|
105
|
-
_seedProp->require();
|
106
|
-
}
|
107
|
-
|
108
|
-
private:
|
109
|
-
NodeProp *_lengthProp;
|
110
|
-
NodeProp *_deviationProp;
|
111
|
-
NodeProp *_seedProp;
|
112
|
-
};
|
113
|
-
|
114
|
-
class JsiCornerPathEffectNode : public JsiBasePathEffectNode,
|
115
|
-
public JsiDomNodeCtor<JsiCornerPathEffectNode> {
|
116
|
-
public:
|
117
|
-
explicit JsiCornerPathEffectNode(std::shared_ptr<RNSkPlatformContext> context)
|
118
|
-
: JsiBasePathEffectNode(context, "skCornerPathEffect") {}
|
119
|
-
|
120
|
-
void decorate(DeclarationContext *context) override {
|
121
|
-
// Create effect
|
122
|
-
auto pathEffect = SkCornerPathEffect::Make(_rProp->value().getAsNumber());
|
123
|
-
|
124
|
-
composeAndPush(context, pathEffect);
|
125
|
-
}
|
126
|
-
|
127
|
-
protected:
|
128
|
-
void defineProperties(NodePropsContainer *container) override {
|
129
|
-
JsiDomDeclarationNode::defineProperties(container);
|
130
|
-
|
131
|
-
_rProp = container->defineProperty<NodeProp>("r");
|
132
|
-
_rProp->require();
|
133
|
-
}
|
134
|
-
|
135
|
-
private:
|
136
|
-
NodeProp *_rProp;
|
137
|
-
};
|
138
|
-
|
139
|
-
class JsiPath1DPathEffectNode : public JsiBasePathEffectNode,
|
140
|
-
public JsiDomNodeCtor<JsiPath1DPathEffectNode> {
|
141
|
-
public:
|
142
|
-
explicit JsiPath1DPathEffectNode(std::shared_ptr<RNSkPlatformContext> context)
|
143
|
-
: JsiBasePathEffectNode(context, "skPath1DPathEffect") {}
|
144
|
-
|
145
|
-
void decorate(DeclarationContext *context) override {
|
146
|
-
// Create effect
|
147
|
-
auto pathEffect = SkPath1DPathEffect::Make(
|
148
|
-
*_pathProp->getDerivedValue(), _advanceProp->value().getAsNumber(),
|
149
|
-
_phaseProp->value().getAsNumber(),
|
150
|
-
getStyleFromStringValue(_styleProp->value().getAsString()));
|
151
|
-
|
152
|
-
composeAndPush(context, pathEffect);
|
153
|
-
}
|
154
|
-
|
155
|
-
protected:
|
156
|
-
void defineProperties(NodePropsContainer *container) override {
|
157
|
-
JsiDomDeclarationNode::defineProperties(container);
|
158
|
-
|
159
|
-
_phaseProp = container->defineProperty<NodeProp>("phase");
|
160
|
-
_advanceProp = container->defineProperty<NodeProp>("advance");
|
161
|
-
_pathProp = container->defineProperty<PathProp>("path");
|
162
|
-
_styleProp = container->defineProperty<NodeProp>("style");
|
163
|
-
|
164
|
-
_phaseProp->require();
|
165
|
-
_advanceProp->require();
|
166
|
-
_pathProp->require();
|
167
|
-
_styleProp->require();
|
168
|
-
}
|
169
|
-
|
170
|
-
private:
|
171
|
-
SkPath1DPathEffect::Style getStyleFromStringValue(const std::string &value) {
|
172
|
-
if (value == "translate") {
|
173
|
-
return SkPath1DPathEffect::kTranslate_Style;
|
174
|
-
} else if (value == "rotate") {
|
175
|
-
return SkPath1DPathEffect::kRotate_Style;
|
176
|
-
} else if (value == "morph") {
|
177
|
-
return SkPath1DPathEffect::kMorph_Style;
|
178
|
-
}
|
179
|
-
throw std::runtime_error("Value \"" + value +
|
180
|
-
"\" is not a valid Path1D effect style.");
|
181
|
-
}
|
182
|
-
|
183
|
-
NodeProp *_phaseProp;
|
184
|
-
NodeProp *_advanceProp;
|
185
|
-
NodeProp *_styleProp;
|
186
|
-
PathProp *_pathProp;
|
187
|
-
};
|
188
|
-
|
189
|
-
class JsiPath2DPathEffectNode : public JsiBasePathEffectNode,
|
190
|
-
public JsiDomNodeCtor<JsiPath2DPathEffectNode> {
|
191
|
-
public:
|
192
|
-
explicit JsiPath2DPathEffectNode(std::shared_ptr<RNSkPlatformContext> context)
|
193
|
-
: JsiBasePathEffectNode(context, "skPath2DPathEffect") {}
|
194
|
-
|
195
|
-
protected:
|
196
|
-
void decorate(DeclarationContext *context) override {
|
197
|
-
|
198
|
-
// Create effect
|
199
|
-
auto pathEffect = SkPath2DPathEffect::Make(*_matrixProp->getDerivedValue(),
|
200
|
-
*_pathProp->getDerivedValue());
|
201
|
-
|
202
|
-
composeAndPush(context, pathEffect);
|
203
|
-
}
|
204
|
-
|
205
|
-
void defineProperties(NodePropsContainer *container) override {
|
206
|
-
JsiDomDeclarationNode::defineProperties(container);
|
207
|
-
|
208
|
-
_matrixProp = container->defineProperty<MatrixProp>("matrix");
|
209
|
-
_pathProp = container->defineProperty<PathProp>("path");
|
210
|
-
|
211
|
-
_matrixProp->require();
|
212
|
-
_pathProp->require();
|
213
|
-
}
|
214
|
-
|
215
|
-
private:
|
216
|
-
MatrixProp *_matrixProp;
|
217
|
-
PathProp *_pathProp;
|
218
|
-
};
|
219
|
-
|
220
|
-
class JsiLine2DPathEffectNode : public JsiBasePathEffectNode,
|
221
|
-
public JsiDomNodeCtor<JsiLine2DPathEffectNode> {
|
222
|
-
public:
|
223
|
-
explicit JsiLine2DPathEffectNode(std::shared_ptr<RNSkPlatformContext> context)
|
224
|
-
: JsiBasePathEffectNode(context, "skLine2DPathEffect") {}
|
225
|
-
|
226
|
-
protected:
|
227
|
-
void decorate(DeclarationContext *context) override {
|
228
|
-
|
229
|
-
// Create effect
|
230
|
-
auto pathEffect = SkLine2DPathEffect::Make(
|
231
|
-
_widthProp->value().getAsNumber(), *_matrixProp->getDerivedValue());
|
232
|
-
|
233
|
-
composeAndPush(context, pathEffect);
|
234
|
-
}
|
235
|
-
|
236
|
-
void defineProperties(NodePropsContainer *container) override {
|
237
|
-
JsiDomDeclarationNode::defineProperties(container);
|
238
|
-
|
239
|
-
_matrixProp = container->defineProperty<MatrixProp>("matrix");
|
240
|
-
_widthProp = container->defineProperty<NodeProp>("width");
|
241
|
-
|
242
|
-
_matrixProp->require();
|
243
|
-
_widthProp->require();
|
244
|
-
}
|
245
|
-
|
246
|
-
private:
|
247
|
-
MatrixProp *_matrixProp;
|
248
|
-
NodeProp *_widthProp;
|
249
|
-
};
|
250
|
-
|
251
|
-
class JsiSumPathEffectNode : public JsiBasePathEffectNode,
|
252
|
-
public JsiDomNodeCtor<JsiSumPathEffectNode> {
|
253
|
-
public:
|
254
|
-
explicit JsiSumPathEffectNode(std::shared_ptr<RNSkPlatformContext> context)
|
255
|
-
: JsiBasePathEffectNode(context, "skSumPathEffect") {}
|
256
|
-
|
257
|
-
protected:
|
258
|
-
void decorate(DeclarationContext *context) override {
|
259
|
-
decorateChildren(context);
|
260
|
-
auto pe =
|
261
|
-
context->getPathEffects()->Declaration<sk_sp<SkPathEffect>>::popAsOne(
|
262
|
-
[=](sk_sp<SkPathEffect> inner, sk_sp<SkPathEffect> outer) {
|
263
|
-
return SkPathEffect::MakeSum(inner, outer);
|
264
|
-
});
|
265
|
-
context->getPathEffects()->push(pe);
|
266
|
-
}
|
267
|
-
};
|
268
|
-
} // namespace RNSkia
|
@@ -1,181 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#include "JsiDomDrawingNode.h"
|
4
|
-
#include "PathProp.h"
|
5
|
-
|
6
|
-
#include <algorithm>
|
7
|
-
#include <memory>
|
8
|
-
#include <string>
|
9
|
-
|
10
|
-
#pragma clang diagnostic push
|
11
|
-
#pragma clang diagnostic ignored "-Wdocumentation"
|
12
|
-
|
13
|
-
#include "include/effects/SkTrimPathEffect.h"
|
14
|
-
|
15
|
-
#pragma clang diagnostic pop
|
16
|
-
|
17
|
-
namespace RNSkia {
|
18
|
-
|
19
|
-
static PropId PropNameMiterLimit = JsiPropId::get("miter_limit");
|
20
|
-
static PropId PropNamePrecision = JsiPropId::get("precision");
|
21
|
-
|
22
|
-
class JsiPathNode : public JsiDomDrawingNode,
|
23
|
-
public JsiDomNodeCtor<JsiPathNode> {
|
24
|
-
public:
|
25
|
-
explicit JsiPathNode(std::shared_ptr<RNSkPlatformContext> context)
|
26
|
-
: JsiDomDrawingNode(context, "skPath") {}
|
27
|
-
|
28
|
-
protected:
|
29
|
-
void draw(DrawingContext *context) override {
|
30
|
-
if (getPropsContainer()->isChanged()) {
|
31
|
-
auto start = saturate(
|
32
|
-
_startProp->isSet() ? _startProp->value().getAsNumber() : 0.0);
|
33
|
-
auto end =
|
34
|
-
saturate(_endProp->isSet() ? _endProp->value().getAsNumber() : 1.0);
|
35
|
-
// Can we use the path directly, or do we need to copy to
|
36
|
-
// mutate / modify the path?
|
37
|
-
auto hasStartOffset = start != 0.0;
|
38
|
-
auto hasEndOffset = end != 1.0;
|
39
|
-
auto hasFillStyle = _fillTypeProp->isSet();
|
40
|
-
auto hasStrokeOptions =
|
41
|
-
_strokeOptsProp->isSet() &&
|
42
|
-
_strokeOptsProp->value().getType() == PropType::Object;
|
43
|
-
|
44
|
-
auto willMutatePath = hasStartOffset == true || hasEndOffset == true ||
|
45
|
-
hasFillStyle == true || hasStrokeOptions == true;
|
46
|
-
|
47
|
-
if (willMutatePath) {
|
48
|
-
// We'll trim the path
|
49
|
-
SkPath filteredPath(*_pathProp->getDerivedValue());
|
50
|
-
auto pe =
|
51
|
-
SkTrimPathEffect::Make(start, end, SkTrimPathEffect::Mode::kNormal);
|
52
|
-
|
53
|
-
if (pe != nullptr) {
|
54
|
-
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
55
|
-
if (!pe->filterPath(&filteredPath, filteredPath, &rec, nullptr)) {
|
56
|
-
throw std::runtime_error(
|
57
|
-
"Failed trimming path with parameters start: " +
|
58
|
-
std::to_string(start) + ", end: " + std::to_string(end));
|
59
|
-
}
|
60
|
-
filteredPath.swap(filteredPath);
|
61
|
-
_path = std::make_shared<const SkPath>(filteredPath);
|
62
|
-
} else if (hasStartOffset || hasEndOffset) {
|
63
|
-
throw std::runtime_error(
|
64
|
-
"Failed trimming path with parameters start: " +
|
65
|
-
std::to_string(start) + ", end: " + std::to_string(end));
|
66
|
-
} else {
|
67
|
-
_path = std::make_shared<const SkPath>(filteredPath);
|
68
|
-
}
|
69
|
-
|
70
|
-
// Set fill style
|
71
|
-
if (_fillTypeProp->isSet()) {
|
72
|
-
auto fillType = _fillTypeProp->value().getAsString();
|
73
|
-
auto p = std::make_shared<SkPath>(*_path.get());
|
74
|
-
p->setFillType(getFillTypeFromStringValue(fillType));
|
75
|
-
_path = std::const_pointer_cast<const SkPath>(p);
|
76
|
-
}
|
77
|
-
|
78
|
-
// do we have a special paint here?
|
79
|
-
if (_strokeOptsProp->isSet()) {
|
80
|
-
auto opts = _strokeOptsProp->value();
|
81
|
-
SkPaint strokePaint;
|
82
|
-
|
83
|
-
if (opts.hasValue(JsiPropId::get("strokeCap"))) {
|
84
|
-
strokePaint.setStrokeCap(StrokeCapProp::getCapFromString(
|
85
|
-
opts.getValue(JsiPropId::get("strokeCap")).getAsString()));
|
86
|
-
}
|
87
|
-
|
88
|
-
if (opts.hasValue(JsiPropId::get("strokeJoin"))) {
|
89
|
-
strokePaint.setStrokeJoin(StrokeJoinProp::getJoinFromString(
|
90
|
-
opts.getValue(JsiPropId::get("strokeJoin")).getAsString()));
|
91
|
-
}
|
92
|
-
|
93
|
-
if (opts.hasValue(PropNameWidth)) {
|
94
|
-
strokePaint.setStrokeWidth(
|
95
|
-
opts.getValue(PropNameWidth).getAsNumber());
|
96
|
-
}
|
97
|
-
|
98
|
-
if (opts.hasValue(PropNameMiterLimit)) {
|
99
|
-
strokePaint.setStrokeMiter(
|
100
|
-
opts.getValue(PropNameMiterLimit).getAsNumber());
|
101
|
-
}
|
102
|
-
|
103
|
-
double precision = 1.0;
|
104
|
-
if (opts.hasValue(PropNamePrecision)) {
|
105
|
-
precision = opts.getValue(PropNamePrecision).getAsNumber();
|
106
|
-
}
|
107
|
-
|
108
|
-
// _path is const so we can't mutate it directly, let's replace the
|
109
|
-
// path like this:
|
110
|
-
auto p = std::make_shared<SkPath>(*_path.get());
|
111
|
-
if (!skpathutils::FillPathWithPaint(*_path.get(), strokePaint,
|
112
|
-
p.get(), nullptr, precision)) {
|
113
|
-
_path = nullptr;
|
114
|
-
} else {
|
115
|
-
_path = std::const_pointer_cast<const SkPath>(p);
|
116
|
-
}
|
117
|
-
}
|
118
|
-
|
119
|
-
} else {
|
120
|
-
// We'll just draw the pure path
|
121
|
-
_path = _pathProp->getDerivedValue();
|
122
|
-
}
|
123
|
-
}
|
124
|
-
|
125
|
-
if (_path == nullptr) {
|
126
|
-
throw std::runtime_error(
|
127
|
-
"Path node could not resolve path props correctly.");
|
128
|
-
}
|
129
|
-
|
130
|
-
context->getCanvas()->drawPath(*_path, *context->getPaint());
|
131
|
-
}
|
132
|
-
|
133
|
-
void defineProperties(NodePropsContainer *container) override {
|
134
|
-
JsiDomDrawingNode::defineProperties(container);
|
135
|
-
_pathProp = container->defineProperty<PathProp>("path");
|
136
|
-
_startProp = container->defineProperty<NodeProp>("start");
|
137
|
-
_endProp = container->defineProperty<NodeProp>("end");
|
138
|
-
_fillTypeProp = container->defineProperty<NodeProp>("fillType");
|
139
|
-
_strokeOptsProp = container->defineProperty<NodeProp>("stroke");
|
140
|
-
|
141
|
-
_pathProp->require();
|
142
|
-
}
|
143
|
-
|
144
|
-
private:
|
145
|
-
float saturate(float x) { return std::max(0.0f, std::min(1.0f, x)); }
|
146
|
-
|
147
|
-
SkPathFillType getFillTypeFromStringValue(const std::string &value) {
|
148
|
-
if (value == "winding") {
|
149
|
-
return SkPathFillType::kWinding;
|
150
|
-
} else if (value == "evenOdd") {
|
151
|
-
return SkPathFillType::kEvenOdd;
|
152
|
-
} else if (value == "inverseWinding") {
|
153
|
-
return SkPathFillType::kInverseWinding;
|
154
|
-
} else if (value == "inverseEvenOdd") {
|
155
|
-
return SkPathFillType::kInverseEvenOdd;
|
156
|
-
}
|
157
|
-
throw std::runtime_error("Could not convert value \"" + value +
|
158
|
-
"\" to path fill type.");
|
159
|
-
}
|
160
|
-
|
161
|
-
PathProp *_pathProp;
|
162
|
-
NodeProp *_startProp;
|
163
|
-
NodeProp *_endProp;
|
164
|
-
NodeProp *_fillTypeProp;
|
165
|
-
NodeProp *_strokeOptsProp;
|
166
|
-
|
167
|
-
std::shared_ptr<const SkPath> _path;
|
168
|
-
};
|
169
|
-
|
170
|
-
class StrokeOptsProps : public BaseDerivedProp {
|
171
|
-
public:
|
172
|
-
explicit StrokeOptsProps(const std::function<void(BaseNodeProp *)> &onChange)
|
173
|
-
: BaseDerivedProp(onChange) {
|
174
|
-
_strokeProp = defineProperty<NodeProp>("stroke");
|
175
|
-
}
|
176
|
-
|
177
|
-
private:
|
178
|
-
NodeProp *_strokeProp;
|
179
|
-
};
|
180
|
-
|
181
|
-
} // namespace RNSkia
|