@shopify/react-native-skia 0.1.163 → 0.1.165
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkPaint.h +6 -0
- package/cpp/api/JsiSkRuntimeEffect.h +7 -2
- package/cpp/jsi/JsiHostObject.h +25 -25
- package/cpp/rnskia/RNSkDomView.cpp +1 -1
- package/cpp/rnskia/RNSkPlatformContext.h +2 -6
- package/cpp/rnskia/dom/base/DrawingContext.cpp +23 -41
- package/cpp/rnskia/dom/base/DrawingContext.h +6 -19
- package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +12 -2
- package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +4 -4
- package/cpp/rnskia/dom/base/JsiDomNode.h +68 -10
- package/cpp/rnskia/dom/base/JsiDomRenderNode.h +26 -61
- package/cpp/rnskia/dom/base/NodeProp.h +2 -1
- package/cpp/rnskia/dom/base/NodePropsContainer.h +10 -0
- package/cpp/rnskia/dom/nodes/JsiBlendNode.h +1 -2
- package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +3 -6
- package/cpp/rnskia/dom/nodes/JsiBoxNode.h +2 -4
- package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +1 -2
- package/cpp/rnskia/dom/nodes/JsiCircleNode.h +2 -5
- package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +4 -8
- package/cpp/rnskia/dom/nodes/JsiCustomDrawingNode.h +2 -5
- package/cpp/rnskia/dom/nodes/JsiDiffRectNode.h +2 -7
- package/cpp/rnskia/dom/nodes/JsiGlyphsNode.h +4 -8
- package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +20 -38
- package/cpp/rnskia/dom/nodes/JsiImageNode.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiImageSvgNode.h +2 -4
- package/cpp/rnskia/dom/nodes/JsiLineNode.h +2 -7
- package/cpp/rnskia/dom/nodes/JsiOvalNode.h +1 -3
- package/cpp/rnskia/dom/nodes/JsiPaintNode.h +2 -3
- package/cpp/rnskia/dom/nodes/JsiPatchNode.h +4 -8
- package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +14 -28
- package/cpp/rnskia/dom/nodes/JsiPathNode.h +6 -16
- package/cpp/rnskia/dom/nodes/JsiPictureNode.h +1 -2
- package/cpp/rnskia/dom/nodes/JsiPointsNode.h +2 -5
- package/cpp/rnskia/dom/nodes/JsiRRectNode.h +1 -2
- package/cpp/rnskia/dom/nodes/JsiRectNode.h +1 -2
- package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +37 -69
- package/cpp/rnskia/dom/nodes/JsiTextBlobNode.h +3 -6
- package/cpp/rnskia/dom/nodes/JsiTextNode.h +4 -8
- package/cpp/rnskia/dom/nodes/JsiTextPathNode.h +1 -2
- package/cpp/rnskia/dom/nodes/JsiVerticesNode.h +2 -4
- package/cpp/rnskia/dom/props/CircleProp.h +2 -0
- package/cpp/rnskia/dom/props/ColorProp.h +9 -4
- package/cpp/rnskia/dom/props/ImageProps.h +3 -2
- package/cpp/rnskia/dom/props/PaintProps.h +15 -7
- package/cpp/rnskia/dom/props/RectProp.h +11 -4
- package/cpp/rnskia/dom/props/TransformProp.h +0 -2
- package/cpp/rnskia/dom/props/UniformsProp.h +86 -123
- package/cpp/rnskia/values/RNSkReadonlyValue.h +2 -6
- package/cpp/utils/RNSkLog.h +1 -1
- package/lib/commonjs/dom/nodes/RenderNode.js +12 -16
- package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Circle.js +6 -1
- package/lib/commonjs/dom/nodes/datatypes/Circle.js.map +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Rect.js +3 -3
- package/lib/commonjs/dom/nodes/datatypes/Rect.js.map +1 -1
- package/lib/commonjs/dom/nodes/datatypes/index.js +0 -13
- package/lib/commonjs/dom/nodes/datatypes/index.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/Box.js +6 -6
- package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/ImageNode.js +2 -2
- package/lib/commonjs/dom/nodes/drawings/ImageNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/PatchNode.js +3 -7
- package/lib/commonjs/dom/nodes/drawings/PatchNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/VerticesNode.js +1 -1
- package/lib/commonjs/dom/nodes/drawings/VerticesNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/ColorFilters.js +1 -3
- package/lib/commonjs/dom/nodes/paint/ColorFilters.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/ImageFilters.js +1 -1
- package/lib/commonjs/dom/nodes/paint/ImageFilters.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/Shaders.js +1 -3
- package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/commonjs/dom/types/Common.js.map +1 -1
- package/lib/commonjs/dom/types/DrawingContext.js.map +1 -1
- package/lib/commonjs/dom/types/Drawings.js.map +1 -1
- package/lib/commonjs/renderer/DrawingContext.js.map +1 -1
- package/lib/commonjs/renderer/components/Mask.js +2 -6
- package/lib/commonjs/renderer/components/Mask.js.map +1 -1
- package/lib/commonjs/renderer/components/image/Image.js +0 -5
- package/lib/commonjs/renderer/components/image/Image.js.map +1 -1
- package/lib/commonjs/renderer/components/image/ImageShader.js +20 -10
- package/lib/commonjs/renderer/components/image/ImageShader.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Blur.js +10 -5
- package/lib/commonjs/renderer/components/imageFilters/Blur.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Morphology.js +10 -5
- package/lib/commonjs/renderer/components/imageFilters/Morphology.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Offset.js +12 -6
- package/lib/commonjs/renderer/components/imageFilters/Offset.js.map +1 -1
- package/lib/commonjs/renderer/components/maskFilters/Blur.js +12 -6
- package/lib/commonjs/renderer/components/maskFilters/Blur.js.map +1 -1
- package/lib/commonjs/renderer/components/pathEffects/Discrete.js +10 -5
- package/lib/commonjs/renderer/components/pathEffects/Discrete.js.map +1 -1
- package/lib/commonjs/renderer/components/shaders/FractalNoise.js +14 -7
- package/lib/commonjs/renderer/components/shaders/FractalNoise.js.map +1 -1
- package/lib/commonjs/renderer/components/shaders/Shader.js +10 -5
- package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/commonjs/renderer/components/shaders/Turbulence.js +14 -7
- package/lib/commonjs/renderer/components/shaders/Turbulence.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/Circle.js +0 -6
- package/lib/commonjs/renderer/components/shapes/Circle.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/FitBox.js +1 -4
- package/lib/commonjs/renderer/components/shapes/FitBox.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/Oval.js +0 -4
- package/lib/commonjs/renderer/components/shapes/Oval.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/Path.js +12 -6
- package/lib/commonjs/renderer/components/shapes/Path.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/Points.js +10 -5
- package/lib/commonjs/renderer/components/shapes/Points.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/RoundedRect.js +0 -3
- package/lib/commonjs/renderer/components/shapes/RoundedRect.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/Vertices.js +10 -5
- package/lib/commonjs/renderer/components/shapes/Vertices.js.map +1 -1
- package/lib/commonjs/renderer/components/text/Glyphs.js +12 -6
- package/lib/commonjs/renderer/components/text/Glyphs.js.map +1 -1
- package/lib/commonjs/renderer/components/text/Text.js +12 -6
- package/lib/commonjs/renderer/components/text/Text.js.map +1 -1
- package/lib/commonjs/renderer/components/text/TextBlob.js +12 -6
- package/lib/commonjs/renderer/components/text/TextBlob.js.map +1 -1
- package/lib/commonjs/renderer/components/text/TextPath.js +10 -5
- package/lib/commonjs/renderer/components/text/TextPath.js.map +1 -1
- package/lib/commonjs/renderer/processors/Animations/Animations.js.map +1 -1
- package/lib/commonjs/skia/types/Paint/Paint.js.map +1 -1
- package/lib/commonjs/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
- package/lib/commonjs/skia/types/Shader/Shader.js +3 -2
- package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPaint.js +4 -0
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js +6 -1
- package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRuntimeEffectFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkRuntimeEffectFactory.js.map +1 -1
- package/lib/commonjs/web/LoadSkiaWeb.js +1 -1
- package/lib/commonjs/web/LoadSkiaWeb.js.map +1 -1
- package/lib/module/dom/nodes/RenderNode.js +12 -16
- package/lib/module/dom/nodes/RenderNode.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Circle.js +8 -1
- package/lib/module/dom/nodes/datatypes/Circle.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Rect.js +7 -3
- package/lib/module/dom/nodes/datatypes/Rect.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/index.js +0 -1
- package/lib/module/dom/nodes/datatypes/index.js.map +1 -1
- package/lib/module/dom/nodes/drawings/Box.js +6 -5
- package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
- package/lib/module/dom/nodes/drawings/ImageNode.js +4 -2
- package/lib/module/dom/nodes/drawings/ImageNode.js.map +1 -1
- package/lib/module/dom/nodes/drawings/PatchNode.js +4 -8
- package/lib/module/dom/nodes/drawings/PatchNode.js.map +1 -1
- package/lib/module/dom/nodes/drawings/VerticesNode.js +2 -2
- package/lib/module/dom/nodes/drawings/VerticesNode.js.map +1 -1
- package/lib/module/dom/nodes/paint/ColorFilters.js +1 -2
- package/lib/module/dom/nodes/paint/ColorFilters.js.map +1 -1
- package/lib/module/dom/nodes/paint/ImageFilters.js +2 -2
- package/lib/module/dom/nodes/paint/ImageFilters.js.map +1 -1
- package/lib/module/dom/nodes/paint/Shaders.js +1 -2
- package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/module/dom/types/Common.js.map +1 -1
- package/lib/module/dom/types/DrawingContext.js.map +1 -1
- package/lib/module/dom/types/Drawings.js.map +1 -1
- package/lib/module/renderer/DrawingContext.js.map +1 -1
- package/lib/module/renderer/components/Mask.js +2 -6
- package/lib/module/renderer/components/Mask.js.map +1 -1
- package/lib/module/renderer/components/image/Image.js +0 -5
- package/lib/module/renderer/components/image/Image.js.map +1 -1
- package/lib/module/renderer/components/image/ImageShader.js +20 -10
- package/lib/module/renderer/components/image/ImageShader.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/Blur.js +10 -5
- package/lib/module/renderer/components/imageFilters/Blur.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/Morphology.js +10 -5
- package/lib/module/renderer/components/imageFilters/Morphology.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/Offset.js +12 -6
- package/lib/module/renderer/components/imageFilters/Offset.js.map +1 -1
- package/lib/module/renderer/components/maskFilters/Blur.js +12 -6
- package/lib/module/renderer/components/maskFilters/Blur.js.map +1 -1
- package/lib/module/renderer/components/pathEffects/Discrete.js +10 -5
- package/lib/module/renderer/components/pathEffects/Discrete.js.map +1 -1
- package/lib/module/renderer/components/shaders/FractalNoise.js +14 -7
- package/lib/module/renderer/components/shaders/FractalNoise.js.map +1 -1
- package/lib/module/renderer/components/shaders/Shader.js +10 -5
- package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/module/renderer/components/shaders/Turbulence.js +14 -7
- package/lib/module/renderer/components/shaders/Turbulence.js.map +1 -1
- package/lib/module/renderer/components/shapes/Circle.js +0 -6
- package/lib/module/renderer/components/shapes/Circle.js.map +1 -1
- package/lib/module/renderer/components/shapes/FitBox.js +1 -4
- package/lib/module/renderer/components/shapes/FitBox.js.map +1 -1
- package/lib/module/renderer/components/shapes/Oval.js +0 -4
- package/lib/module/renderer/components/shapes/Oval.js.map +1 -1
- package/lib/module/renderer/components/shapes/Path.js +12 -6
- package/lib/module/renderer/components/shapes/Path.js.map +1 -1
- package/lib/module/renderer/components/shapes/Points.js +10 -5
- package/lib/module/renderer/components/shapes/Points.js.map +1 -1
- package/lib/module/renderer/components/shapes/RoundedRect.js +0 -3
- package/lib/module/renderer/components/shapes/RoundedRect.js.map +1 -1
- package/lib/module/renderer/components/shapes/Vertices.js +10 -5
- package/lib/module/renderer/components/shapes/Vertices.js.map +1 -1
- package/lib/module/renderer/components/text/Glyphs.js +12 -6
- package/lib/module/renderer/components/text/Glyphs.js.map +1 -1
- package/lib/module/renderer/components/text/Text.js +12 -6
- package/lib/module/renderer/components/text/Text.js.map +1 -1
- package/lib/module/renderer/components/text/TextBlob.js +12 -6
- package/lib/module/renderer/components/text/TextBlob.js.map +1 -1
- package/lib/module/renderer/components/text/TextPath.js +10 -5
- package/lib/module/renderer/components/text/TextPath.js.map +1 -1
- package/lib/module/renderer/processors/Animations/Animations.js.map +1 -1
- package/lib/module/skia/types/Paint/Paint.js.map +1 -1
- package/lib/module/skia/types/RuntimeEffect/RuntimeEffect.js.map +1 -1
- package/lib/module/skia/types/Shader/Shader.js +3 -2
- package/lib/module/skia/types/Shader/Shader.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.js +4 -0
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/skia/web/JsiSkRuntimeEffect.js +6 -1
- package/lib/module/skia/web/JsiSkRuntimeEffect.js.map +1 -1
- package/lib/module/skia/web/JsiSkRuntimeEffectFactory.js +1 -1
- package/lib/module/skia/web/JsiSkRuntimeEffectFactory.js.map +1 -1
- package/lib/module/web/LoadSkiaWeb.js +1 -1
- package/lib/module/web/LoadSkiaWeb.js.map +1 -1
- package/lib/typescript/src/dom/nodes/datatypes/Circle.d.ts +4 -1
- package/lib/typescript/src/dom/nodes/datatypes/index.d.ts +0 -1
- package/lib/typescript/src/dom/nodes/drawings/Box.d.ts +1 -1
- package/lib/typescript/src/dom/nodes/drawings/PatchNode.d.ts +1 -1
- package/lib/typescript/src/dom/types/Common.d.ts +4 -4
- package/lib/typescript/src/dom/types/DrawingContext.d.ts +0 -1
- package/lib/typescript/src/dom/types/Drawings.d.ts +1 -1
- package/lib/typescript/src/renderer/DrawingContext.d.ts +3 -5
- package/lib/typescript/src/renderer/components/Mask.d.ts +3 -9
- package/lib/typescript/src/renderer/components/image/Image.d.ts +1 -8
- package/lib/typescript/src/renderer/components/image/ImageShader.d.ts +2 -12
- package/lib/typescript/src/renderer/components/imageFilters/Blur.d.ts +2 -7
- package/lib/typescript/src/renderer/components/imageFilters/Morphology.d.ts +2 -7
- package/lib/typescript/src/renderer/components/imageFilters/Offset.d.ts +2 -8
- package/lib/typescript/src/renderer/components/maskFilters/Blur.d.ts +2 -8
- package/lib/typescript/src/renderer/components/pathEffects/Discrete.d.ts +2 -7
- package/lib/typescript/src/renderer/components/shaders/FractalNoise.d.ts +2 -9
- package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +2 -7
- package/lib/typescript/src/renderer/components/shaders/Turbulence.d.ts +2 -9
- package/lib/typescript/src/renderer/components/shapes/Circle.d.ts +1 -9
- package/lib/typescript/src/renderer/components/shapes/FitBox.d.ts +2 -7
- package/lib/typescript/src/renderer/components/shapes/Oval.d.ts +1 -7
- package/lib/typescript/src/renderer/components/shapes/Path.d.ts +2 -8
- package/lib/typescript/src/renderer/components/shapes/Points.d.ts +2 -7
- package/lib/typescript/src/renderer/components/shapes/RoundedRect.d.ts +1 -6
- package/lib/typescript/src/renderer/components/shapes/Vertices.d.ts +2 -7
- package/lib/typescript/src/renderer/components/text/Glyphs.d.ts +2 -8
- package/lib/typescript/src/renderer/components/text/Text.d.ts +2 -8
- package/lib/typescript/src/renderer/components/text/TextBlob.d.ts +2 -8
- package/lib/typescript/src/renderer/components/text/TextPath.d.ts +2 -7
- package/lib/typescript/src/renderer/processors/Animations/Animations.d.ts +5 -0
- package/lib/typescript/src/skia/types/Paint/Paint.d.ts +4 -0
- package/lib/typescript/src/skia/types/RuntimeEffect/RuntimeEffect.d.ts +4 -0
- package/lib/typescript/src/skia/types/Shader/Shader.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkRuntimeEffect.d.ts +3 -1
- package/package.json +1 -1
- package/src/dom/nodes/RenderNode.ts +11 -21
- package/src/dom/nodes/datatypes/Circle.ts +1 -1
- package/src/dom/nodes/datatypes/Rect.ts +3 -3
- package/src/dom/nodes/datatypes/index.ts +0 -1
- package/src/dom/nodes/drawings/Box.ts +7 -4
- package/src/dom/nodes/drawings/ImageNode.ts +2 -1
- package/src/dom/nodes/drawings/PatchNode.ts +4 -18
- package/src/dom/nodes/drawings/VerticesNode.ts +2 -2
- package/src/dom/nodes/paint/ColorFilters.ts +1 -2
- package/src/dom/nodes/paint/ImageFilters.ts +2 -2
- package/src/dom/nodes/paint/Shaders.ts +1 -2
- package/src/dom/types/Common.ts +4 -4
- package/src/dom/types/DrawingContext.ts +0 -1
- package/src/dom/types/Drawings.ts +1 -1
- package/src/renderer/DrawingContext.ts +5 -5
- package/src/renderer/components/Mask.tsx +8 -8
- package/src/renderer/components/image/Image.tsx +0 -6
- package/src/renderer/components/image/ImageShader.tsx +24 -12
- package/src/renderer/components/imageFilters/Blur.tsx +6 -7
- package/src/renderer/components/imageFilters/Morphology.tsx +6 -7
- package/src/renderer/components/imageFilters/Offset.tsx +7 -8
- package/src/renderer/components/maskFilters/Blur.tsx +7 -8
- package/src/renderer/components/pathEffects/Discrete.tsx +6 -9
- package/src/renderer/components/shaders/FractalNoise.tsx +18 -9
- package/src/renderer/components/shaders/Shader.tsx +6 -7
- package/src/renderer/components/shaders/Turbulence.tsx +15 -9
- package/src/renderer/components/shapes/Circle.tsx +0 -4
- package/src/renderer/components/shapes/FitBox.tsx +2 -6
- package/src/renderer/components/shapes/Oval.tsx +0 -5
- package/src/renderer/components/shapes/Path.tsx +7 -8
- package/src/renderer/components/shapes/Points.tsx +6 -7
- package/src/renderer/components/shapes/RoundedRect.tsx +0 -4
- package/src/renderer/components/shapes/Vertices.tsx +6 -7
- package/src/renderer/components/text/Glyphs.tsx +7 -8
- package/src/renderer/components/text/Text.tsx +7 -8
- package/src/renderer/components/text/TextBlob.tsx +7 -8
- package/src/renderer/components/text/TextPath.tsx +6 -7
- package/src/renderer/processors/Animations/Animations.ts +9 -3
- package/src/skia/types/Paint/Paint.ts +5 -0
- package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +5 -0
- package/src/skia/types/Shader/Shader.ts +5 -3
- package/src/skia/web/JsiSkPaint.ts +4 -0
- package/src/skia/web/JsiSkRuntimeEffect.ts +5 -1
- package/src/skia/web/JsiSkRuntimeEffectFactory.ts +1 -1
- package/src/web/LoadSkiaWeb.tsx +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Color.js +0 -27
- package/lib/commonjs/dom/nodes/datatypes/Color.js.map +0 -1
- package/lib/module/dom/nodes/datatypes/Color.js +0 -11
- package/lib/module/dom/nodes/datatypes/Color.js.map +0 -1
- package/lib/typescript/src/dom/nodes/datatypes/Color.d.ts +0 -7
- package/src/dom/nodes/datatypes/Color.ts +0 -15
@@ -16,6 +16,68 @@
|
|
16
16
|
|
17
17
|
namespace RNSkia {
|
18
18
|
|
19
|
+
bool isJSPoint(const JsiValue &value) {
|
20
|
+
return value.getType() == PropType::Object && value.hasValue(PropNameX) &&
|
21
|
+
value.hasValue(PropNameY);
|
22
|
+
}
|
23
|
+
|
24
|
+
bool isSkPoint(const JsiValue &value) {
|
25
|
+
return value.getType() == PropType::HostObject &&
|
26
|
+
std::dynamic_pointer_cast<JsiSkPoint>(value.getAsHostObject()) !=
|
27
|
+
nullptr;
|
28
|
+
}
|
29
|
+
|
30
|
+
bool isIndexable(const JsiValue &value) {
|
31
|
+
return value.getType() == PropType::Object && value.hasValue(PropName0);
|
32
|
+
}
|
33
|
+
|
34
|
+
void processValue(std::vector<SkScalar> &values, const JsiValue &value) {
|
35
|
+
if (value.getType() == PropType::Number) {
|
36
|
+
auto n = value.getAsNumber();
|
37
|
+
values.push_back(n);
|
38
|
+
} else if (value.getType() == PropType::Array) {
|
39
|
+
auto arrayValue = value.getAsArray();
|
40
|
+
for (size_t i = 0; i < arrayValue.size(); ++i) {
|
41
|
+
auto a = arrayValue[i];
|
42
|
+
processValue(values, a);
|
43
|
+
}
|
44
|
+
} else if (isJSPoint(value) || isSkPoint(value)) {
|
45
|
+
auto pointValue = PointProp::processValue(value);
|
46
|
+
values.push_back(pointValue.x());
|
47
|
+
values.push_back(pointValue.y());
|
48
|
+
} else if (isIndexable(value)) {
|
49
|
+
auto length = value.getKeys().size();
|
50
|
+
for (size_t i = 0; i < length; ++i) {
|
51
|
+
values.push_back(
|
52
|
+
value.getValue(JsiPropId::get(std::to_string(i))).getAsNumber());
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
void processUniform(std::vector<SkScalar> &values, SkRuntimeEffect *source,
|
58
|
+
const JsiValue &uniforms, SkRuntimeShaderBuilder *rtb) {
|
59
|
+
auto uniformsCount = source->uniforms().size();
|
60
|
+
for (size_t i = 0; i < uniformsCount; ++i) {
|
61
|
+
auto it = source->uniforms().begin() + i;
|
62
|
+
auto name = JsiPropId::get(std::string(it->name));
|
63
|
+
if (!uniforms.hasValue(name)) {
|
64
|
+
throw std::runtime_error("The runtime effect has the uniform value \"" +
|
65
|
+
std::string(name) +
|
66
|
+
"\" declared, but it is missing from the "
|
67
|
+
"uniforms property of the Runtime effect.");
|
68
|
+
}
|
69
|
+
auto value = uniforms.getValue(name);
|
70
|
+
if (rtb == nullptr) {
|
71
|
+
processValue(values, value);
|
72
|
+
} else {
|
73
|
+
std::vector<SkScalar> uniformValue;
|
74
|
+
processValue(uniformValue, value);
|
75
|
+
rtb->uniform(name).set(uniformValue.data(),
|
76
|
+
static_cast<int>(uniformValue.size()));
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
19
81
|
class UniformsProp : public DerivedSkProp<SkData> {
|
20
82
|
public:
|
21
83
|
UniformsProp(PropId name, NodeProp *sourceProp) : DerivedSkProp<SkData>() {
|
@@ -32,7 +94,9 @@ public:
|
|
32
94
|
auto source = _sourceProp->value().getAs<JsiSkRuntimeEffect>()->getObject();
|
33
95
|
|
34
96
|
// Flatten uniforms from property
|
35
|
-
|
97
|
+
std::vector<SkScalar> uniformValues;
|
98
|
+
processUniform(uniformValues, source.get(), _uniformsProp->value(),
|
99
|
+
nullptr);
|
36
100
|
|
37
101
|
// Cast uniforms according to the declaration in the shader
|
38
102
|
auto uniformsData = castUniforms(source.get(), uniformValues);
|
@@ -41,11 +105,30 @@ public:
|
|
41
105
|
setDerivedValue(uniformsData);
|
42
106
|
}
|
43
107
|
|
108
|
+
void processUniforms(SkRuntimeShaderBuilder &rtb) {
|
109
|
+
if (!_uniformsProp->isSet()) {
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
|
113
|
+
// Get the effect
|
114
|
+
auto source = _sourceProp->value().getAs<JsiSkRuntimeEffect>()->getObject();
|
115
|
+
// Flatten uniforms from property
|
116
|
+
std::vector<SkScalar> uniformValues;
|
117
|
+
processUniform(uniformValues, source.get(), _uniformsProp->value(), &rtb);
|
118
|
+
}
|
119
|
+
|
44
120
|
private:
|
45
121
|
sk_sp<SkData> castUniforms(SkRuntimeEffect *source,
|
46
122
|
const std::vector<SkScalar> &values) {
|
47
123
|
// Create memory for uniforms
|
48
|
-
auto
|
124
|
+
auto uniformSize = source->uniformSize();
|
125
|
+
if (values.size() * sizeof(float) != uniformSize) {
|
126
|
+
throw std::runtime_error(
|
127
|
+
"Uniforms size differs from effect's uniform size. Received " +
|
128
|
+
std::to_string(values.size()) + " expected " +
|
129
|
+
std::to_string(uniformSize / sizeof(float)));
|
130
|
+
}
|
131
|
+
auto uniformsData = SkData::MakeUninitialized(uniformSize);
|
49
132
|
|
50
133
|
// Loop through all uniforms in the effect and load data from the flattened
|
51
134
|
// array of values
|
@@ -57,7 +140,7 @@ private:
|
|
57
140
|
const std::size_t offset = reu.slot + j;
|
58
141
|
float fValue = values.at(offset);
|
59
142
|
int iValue = static_cast<int>(fValue);
|
60
|
-
auto value = reu.isInteger ? iValue : fValue;
|
143
|
+
auto value = reu.isInteger ? SkBits2Float(iValue) : fValue;
|
61
144
|
memcpy(SkTAddOffset<void>(uniformsData->writable_data(),
|
62
145
|
offset * sizeof(value)),
|
63
146
|
&value, sizeof(value));
|
@@ -67,126 +150,6 @@ private:
|
|
67
150
|
return uniformsData;
|
68
151
|
}
|
69
152
|
|
70
|
-
std::vector<SkScalar> flattenUniforms(SkRuntimeEffect *source,
|
71
|
-
const JsiValue &propObject) {
|
72
|
-
auto uniformsCount = source->uniforms().size();
|
73
|
-
std::vector<SkScalar> uniformValues;
|
74
|
-
|
75
|
-
for (size_t i = 0; i < uniformsCount; ++i) {
|
76
|
-
auto it = source->uniforms().begin() + i;
|
77
|
-
auto name = JsiPropId::get(std::string(it->name));
|
78
|
-
|
79
|
-
if (!propObject.hasValue(name)) {
|
80
|
-
throw std::runtime_error("The runtime effect has the uniform value \"" +
|
81
|
-
std::string(name) +
|
82
|
-
"\" declared, but it is missing from the "
|
83
|
-
"uniforms property of the Runtime effect.");
|
84
|
-
}
|
85
|
-
|
86
|
-
auto value = propObject.getValue(name);
|
87
|
-
|
88
|
-
// A uniform value can be a single number, a vector or an array of numbers
|
89
|
-
// Or an array of the above
|
90
|
-
if (value.getType() == PropType::Number) {
|
91
|
-
// Set numeric uniform
|
92
|
-
uniformValues.push_back(value.getAsNumber());
|
93
|
-
} else if (value.getType() == PropType::Array) {
|
94
|
-
// Array
|
95
|
-
auto arrayValue = value.getAsArray();
|
96
|
-
for (size_t n = 0; n < arrayValue.size(); ++n) {
|
97
|
-
auto a = arrayValue[n];
|
98
|
-
if (a.getType() == PropType::Number) {
|
99
|
-
uniformValues.push_back(a.getAsNumber());
|
100
|
-
} else {
|
101
|
-
for (size_t j = 0; j < a.getAsArray().size(); ++j) {
|
102
|
-
uniformValues.push_back(a.getAsArray()[j].getAsNumber());
|
103
|
-
}
|
104
|
-
}
|
105
|
-
}
|
106
|
-
} else if (value.getType() == PropType::HostObject ||
|
107
|
-
value.getType() == PropType::Object) {
|
108
|
-
// Vector (JsiSkPoint / JsiSkRect)
|
109
|
-
auto pointValue = PointProp::processValue(value);
|
110
|
-
uniformValues.push_back(pointValue.x());
|
111
|
-
uniformValues.push_back(pointValue.y());
|
112
|
-
}
|
113
|
-
}
|
114
|
-
return uniformValues;
|
115
|
-
}
|
116
|
-
|
117
|
-
NodeProp *_uniformsProp;
|
118
|
-
NodeProp *_sourceProp;
|
119
|
-
};
|
120
|
-
|
121
|
-
class SimpleUniformsProp : public BaseDerivedProp {
|
122
|
-
public:
|
123
|
-
SimpleUniformsProp(PropId name, NodeProp *sourceProp) : BaseDerivedProp() {
|
124
|
-
_uniformsProp = addProperty(std::make_shared<NodeProp>(name));
|
125
|
-
_sourceProp = sourceProp;
|
126
|
-
}
|
127
|
-
|
128
|
-
void processUniforms(SkRuntimeShaderBuilder &rtb) {
|
129
|
-
if (!_uniformsProp->isSet()) {
|
130
|
-
return;
|
131
|
-
}
|
132
|
-
|
133
|
-
auto propObject = _uniformsProp->value();
|
134
|
-
auto source = _sourceProp->value().getAs<JsiSkRuntimeEffect>()->getObject();
|
135
|
-
|
136
|
-
auto uniformsCount = source->uniforms().size();
|
137
|
-
|
138
|
-
for (size_t i = 0; i < uniformsCount; ++i) {
|
139
|
-
auto it = source->uniforms().begin() + i;
|
140
|
-
auto name = JsiPropId::get(std::string(it->name));
|
141
|
-
|
142
|
-
if (!propObject.hasValue(name)) {
|
143
|
-
throw std::runtime_error("The runtime effect has the uniform value \"" +
|
144
|
-
std::string(name) +
|
145
|
-
"\" declared, but it is missing from the "
|
146
|
-
"uniforms property of the Runtime effect.");
|
147
|
-
}
|
148
|
-
|
149
|
-
auto value = propObject.getValue(name);
|
150
|
-
|
151
|
-
// A uniform value can be a single number, a vector or an array of numbers
|
152
|
-
// Or an array of the above
|
153
|
-
if (value.getType() == PropType::Number) {
|
154
|
-
// Set numeric uniform
|
155
|
-
rtb.uniform(name) = value.getAsNumber();
|
156
|
-
} else if (value.getType() == PropType::Array) {
|
157
|
-
// Array
|
158
|
-
auto arrayValue = value.getAsArray();
|
159
|
-
std::vector<SkScalar> set;
|
160
|
-
for (size_t n = 0; n < arrayValue.size(); ++n) {
|
161
|
-
auto a = arrayValue[n];
|
162
|
-
if (a.getType() == PropType::Number) {
|
163
|
-
set.push_back(a.getAsNumber());
|
164
|
-
} else {
|
165
|
-
for (size_t j = 0; j < a.getAsArray().size(); ++j) {
|
166
|
-
set.push_back(a.getAsArray()[j].getAsNumber());
|
167
|
-
}
|
168
|
-
}
|
169
|
-
}
|
170
|
-
rtb.uniform(name).set(set.data(), static_cast<int>(set.size()));
|
171
|
-
|
172
|
-
} else if (value.getType() == PropType::HostObject ||
|
173
|
-
value.getType() == PropType::Object) {
|
174
|
-
// Vector (JsiSkPoint / JsiSkRect)
|
175
|
-
auto pointValue = PointProp::processValue(value);
|
176
|
-
std::vector<SkScalar> set = {pointValue.x(), pointValue.y()};
|
177
|
-
|
178
|
-
rtb.uniform(name).set(set.data(), static_cast<int>(set.size()));
|
179
|
-
} else {
|
180
|
-
throw std::runtime_error("Unexpected type for uniform prop \"" +
|
181
|
-
std::string(name) + "\". Got " +
|
182
|
-
value.getTypeAsString(value.getType()));
|
183
|
-
}
|
184
|
-
}
|
185
|
-
}
|
186
|
-
|
187
|
-
void updateDerivedValue() override {}
|
188
|
-
|
189
|
-
private:
|
190
153
|
NodeProp *_uniformsProp;
|
191
154
|
NodeProp *_sourceProp;
|
192
155
|
};
|
@@ -142,12 +142,8 @@ protected:
|
|
142
142
|
@param runtime Current JS Runtime
|
143
143
|
*/
|
144
144
|
void notifyListeners(jsi::Runtime &runtime) {
|
145
|
-
std::
|
146
|
-
{
|
147
|
-
std::lock_guard<std::mutex> lock(_mutex);
|
148
|
-
tmp.insert(_listeners.cbegin(), _listeners.cend());
|
149
|
-
}
|
150
|
-
for (const auto &listener : tmp) {
|
145
|
+
std::lock_guard<std::mutex> lock(_mutex);
|
146
|
+
for (const auto &listener : _listeners) {
|
151
147
|
listener.second(runtime);
|
152
148
|
}
|
153
149
|
}
|
package/cpp/utils/RNSkLog.h
CHANGED
@@ -115,7 +115,9 @@ class JsiRenderNode extends _Node.JsiNode {
|
|
115
115
|
} = this.props;
|
116
116
|
|
117
117
|
if (color !== undefined || strokeWidth !== undefined || blendMode !== undefined || style !== undefined || strokeJoin !== undefined || strokeCap !== undefined || strokeMiter !== undefined || opacity !== undefined || antiAlias !== undefined) {
|
118
|
-
ctx = {
|
118
|
+
ctx = {
|
119
|
+
opacity: 1
|
120
|
+
};
|
119
121
|
|
120
122
|
if (color !== undefined) {
|
121
123
|
ctx.color = this.Skia.Color(color);
|
@@ -193,11 +195,10 @@ class JsiRenderNode extends _Node.JsiNode {
|
|
193
195
|
const {
|
194
196
|
canvas
|
195
197
|
} = parentCtx;
|
196
|
-
const opacity = this.props.opacity !== undefined ? parentCtx.opacity * this.props.opacity : parentCtx.opacity;
|
197
198
|
|
198
199
|
if (this.paintCache === null || this.paintCache.parent !== parentCtx.paint) {
|
199
200
|
const paintCtx = this.getPaintCtx();
|
200
|
-
const child = paintCtx ? concatPaint(parentCtx.paint, paintCtx
|
201
|
+
const child = paintCtx ? concatPaint(parentCtx.paint.copy(), paintCtx) : parentCtx.paint;
|
201
202
|
this.paintCache = {
|
202
203
|
parent: parentCtx.paint,
|
203
204
|
child
|
@@ -207,7 +208,6 @@ class JsiRenderNode extends _Node.JsiNode {
|
|
207
208
|
const paint = this.paintCache.child; // TODO: can we only recreate a new context here if needed?
|
208
209
|
|
209
210
|
const ctx = { ...parentCtx,
|
210
|
-
opacity,
|
211
211
|
paint
|
212
212
|
};
|
213
213
|
const hasTransform = matrix !== undefined || transform !== undefined;
|
@@ -250,7 +250,7 @@ class JsiRenderNode extends _Node.JsiNode {
|
|
250
250
|
|
251
251
|
exports.JsiRenderNode = JsiRenderNode;
|
252
252
|
|
253
|
-
const concatPaint = (
|
253
|
+
const concatPaint = (paint, _ref) => {
|
254
254
|
let {
|
255
255
|
color,
|
256
256
|
strokeWidth,
|
@@ -261,22 +261,22 @@ const concatPaint = (parent, _ref, opacity) => {
|
|
261
261
|
imageFilter,
|
262
262
|
maskFilter,
|
263
263
|
pathEffect,
|
264
|
-
opacity
|
264
|
+
opacity,
|
265
265
|
strokeCap,
|
266
266
|
strokeJoin,
|
267
267
|
strokeMiter,
|
268
268
|
style
|
269
269
|
} = _ref;
|
270
|
-
|
270
|
+
|
271
|
+
if (opacity !== undefined) {
|
272
|
+
paint.setAlphaf(paint.getAlphaf() * opacity);
|
273
|
+
}
|
271
274
|
|
272
275
|
if (color !== undefined) {
|
276
|
+
const currentOpacity = paint.getAlphaf();
|
273
277
|
paint.setShader(null);
|
274
|
-
color[3] *= opacity;
|
275
278
|
paint.setColor(color);
|
276
|
-
|
277
|
-
const cl = paint.getColor();
|
278
|
-
cl[3] = opacity;
|
279
|
-
paint.setColor(cl);
|
279
|
+
paint.setAlphaf(currentOpacity * paint.getAlphaf());
|
280
280
|
}
|
281
281
|
|
282
282
|
if (strokeWidth !== undefined) {
|
@@ -311,10 +311,6 @@ const concatPaint = (parent, _ref, opacity) => {
|
|
311
311
|
paint.setPathEffect(pathEffect);
|
312
312
|
}
|
313
313
|
|
314
|
-
if (alpha !== undefined) {
|
315
|
-
paint.setAlphaf(alpha * opacity);
|
316
|
-
}
|
317
|
-
|
318
314
|
if (strokeCap !== undefined) {
|
319
315
|
paint.setStrokeCap(strokeCap);
|
320
316
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["paintProps","JsiRenderNode","JsiNode","constructor","ctx","type","props","matrix","Skia","Matrix","onPropChange","setProps","paintCache","setProp","key","value","hasChanged","includes","identity","clipPath","undefined","clipRect","clipRRect","computeMatrix","computeClip","addChild","child","JsiDeclarationNode","setInvalidate","insertChildBefore","before","clip","isPathDef","processPath","isRRect","processTransformProps","getPaintCtx","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","opacity","antiAlias","Color","BlendMode","enumKey","PaintStyle","StrokeJoin","StrokeCap","_children","forEach","isColorFilter","cf","materialize","colorFilter","ColorFilter","MakeCompose","isShader","shader","isPathEffect","pe","pathEffect","PathEffect","isImageFilter","filter","imageFilter","ImageFilter","isMaskFilter","maskFilter","render","parentCtx","invertClip","layer","transform","canvas","parent","paint","paintCtx","concatPaint","hasTransform","hasClip","shouldSave","op","ClipOp","Difference","Intersect","saveLayer","save","concat","renderNode","restore","alpha","copy","setShader","setColor","cl","getColor","setStrokeWidth","setAntiAlias","setBlendMode","setColorFilter","setImageFilter","setMaskFilter","setPathEffect","setAlphaf","setStrokeCap","setStrokeJoin","setStrokeMiter","setStyle"],"sources":["RenderNode.ts"],"sourcesContent":["import type {\n SkMatrix,\n SkRect,\n SkRRect,\n SkPath,\n SkPaint,\n} from \"../../skia/types\";\nimport {\n StrokeCap,\n StrokeJoin,\n PaintStyle,\n BlendMode,\n ClipOp,\n isRRect,\n} from \"../../skia/types\";\nimport type {\n RenderNode,\n GroupProps,\n DrawingContext,\n NodeType,\n Node,\n} from \"../types\";\n\nimport { isPathDef, processPath, processTransformProps } from \"./datatypes\";\nimport type { NodeContext } from \"./Node\";\nimport { JsiNode, JsiDeclarationNode } from \"./Node\";\nimport type { PaintContext } from \"./PaintContext\";\nimport { enumKey } from \"./datatypes/Enum\";\n\nconst paintProps = [\n \"color\",\n \"strokeWidth\",\n \"blendMode\",\n \"strokeCap\",\n \"strokeJoin\",\n \"strokeMiter\",\n \"style\",\n \"antiAlias\",\n \"opacity\",\n];\n\ninterface PaintCache {\n parent: SkPaint;\n child: SkPaint;\n}\n\nexport abstract class JsiRenderNode<P extends GroupProps>\n extends JsiNode<P>\n implements RenderNode<P>\n{\n paintCache: PaintCache | null = null;\n matrix: SkMatrix;\n clipRect?: SkRect;\n clipRRect?: SkRRect;\n clipPath?: SkPath;\n\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, type, props);\n this.matrix = this.Skia.Matrix();\n this.onPropChange();\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.onPropChange();\n this.paintCache = null;\n }\n\n setProp<K extends keyof P>(key: K, value: P[K]) {\n const hasChanged = super.setProp(key, value);\n if (hasChanged) {\n this.onPropChange();\n if (paintProps.includes(key as string)) {\n this.paintCache = null;\n }\n }\n return hasChanged;\n }\n\n protected onPropChange() {\n this.matrix.identity();\n this.clipPath = undefined;\n this.clipRect = undefined;\n this.clipRRect = undefined;\n this.computeMatrix();\n this.computeClip();\n }\n\n addChild(child: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.addChild(child);\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.insertChildBefore(child, before);\n }\n\n private computeClip() {\n const { clip } = this.props;\n if (clip) {\n if (isPathDef(clip)) {\n this.clipPath = processPath(this.Skia, clip);\n } else if (isRRect(clip)) {\n this.clipRRect = clip;\n } else {\n this.clipRect = clip;\n }\n }\n }\n\n private computeMatrix() {\n processTransformProps(this.matrix, this.props);\n }\n\n private getPaintCtx() {\n let ctx: PaintContext | undefined;\n const {\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n antiAlias,\n } = this.props;\n if (\n color !== undefined ||\n strokeWidth !== undefined ||\n blendMode !== undefined ||\n style !== undefined ||\n strokeJoin !== undefined ||\n strokeCap !== undefined ||\n strokeMiter !== undefined ||\n opacity !== undefined ||\n antiAlias !== undefined\n ) {\n ctx = {};\n if (color !== undefined) {\n ctx.color = this.Skia.Color(color);\n }\n if (strokeWidth !== undefined) {\n ctx.strokeWidth = strokeWidth;\n }\n if (blendMode !== undefined) {\n ctx.blendMode = BlendMode[enumKey(blendMode)];\n }\n if (style !== undefined) {\n ctx.style = PaintStyle[enumKey(style)];\n }\n if (strokeJoin !== undefined) {\n ctx.strokeJoin = StrokeJoin[enumKey(strokeJoin)];\n }\n if (strokeCap !== undefined) {\n ctx.strokeCap = StrokeCap[enumKey(strokeCap)];\n }\n if (strokeMiter !== undefined) {\n ctx.strokeMiter = strokeMiter;\n }\n if (opacity !== undefined) {\n ctx.opacity = opacity;\n }\n if (antiAlias !== undefined) {\n ctx.antiAlias = antiAlias;\n }\n }\n this._children.forEach((child) => {\n if (child instanceof JsiDeclarationNode) {\n if (child.isColorFilter()) {\n ctx = ctx || {};\n const cf = child.materialize();\n ctx.colorFilter = ctx.colorFilter\n ? this.Skia.ColorFilter.MakeCompose(cf, ctx.colorFilter)\n : cf;\n } else if (child.isShader()) {\n ctx = ctx || {};\n const shader = child.materialize();\n ctx.shader = shader;\n } else if (child.isPathEffect()) {\n ctx = ctx || {};\n const pe = child.materialize();\n ctx.pathEffect = ctx.pathEffect\n ? this.Skia.PathEffect.MakeCompose(pe, ctx.pathEffect)\n : pe;\n } else if (child.isImageFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.imageFilter = ctx.imageFilter\n ? this.Skia.ImageFilter.MakeCompose(filter, ctx.imageFilter)\n : filter;\n } else if (child.isMaskFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.maskFilter = filter;\n }\n }\n });\n return ctx;\n }\n\n render(parentCtx: DrawingContext) {\n const { invertClip, layer, matrix, transform } = this.props;\n const { canvas } = parentCtx;\n\n const opacity =\n this.props.opacity !== undefined\n ? parentCtx.opacity * this.props.opacity\n : parentCtx.opacity;\n\n if (\n this.paintCache === null ||\n this.paintCache.parent !== parentCtx.paint\n ) {\n const paintCtx = this.getPaintCtx();\n const child = paintCtx\n ? concatPaint(parentCtx.paint, paintCtx, parentCtx.opacity)\n : parentCtx.paint;\n this.paintCache = { parent: parentCtx.paint, child };\n }\n const paint = this.paintCache.child;\n // TODO: can we only recreate a new context here if needed?\n const ctx = { ...parentCtx, opacity, paint };\n const hasTransform = matrix !== undefined || transform !== undefined;\n const hasClip =\n this.clipRect !== undefined ||\n this.clipPath !== undefined ||\n this.clipRRect !== undefined;\n const shouldSave = hasTransform || hasClip || !!layer;\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n if (shouldSave) {\n if (layer) {\n if (typeof layer === \"boolean\") {\n canvas.saveLayer();\n } else {\n canvas.saveLayer(layer);\n }\n } else {\n canvas.save();\n }\n }\n\n if (this.matrix) {\n canvas.concat(this.matrix);\n }\n if (this.clipRect) {\n canvas.clipRect(this.clipRect, op, true);\n } else if (this.clipRRect) {\n canvas.clipRRect(this.clipRRect, op, true);\n } else if (this.clipPath) {\n canvas.clipPath(this.clipPath, op, true);\n }\n\n this.renderNode(ctx);\n\n if (shouldSave) {\n canvas.restore();\n }\n }\n\n abstract renderNode(ctx: DrawingContext): void;\n}\n\nconst concatPaint = (\n parent: SkPaint,\n {\n color,\n strokeWidth,\n shader,\n antiAlias,\n blendMode,\n colorFilter,\n imageFilter,\n maskFilter,\n pathEffect,\n opacity: alpha,\n strokeCap,\n strokeJoin,\n strokeMiter,\n style,\n }: PaintContext,\n opacity: number\n) => {\n const paint = parent.copy();\n if (color !== undefined) {\n paint.setShader(null);\n color[3] *= opacity;\n paint.setColor(color);\n } else {\n const cl = paint.getColor();\n cl[3] = opacity;\n paint.setColor(cl);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (shader !== undefined) {\n paint.setShader(shader);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(blendMode);\n }\n if (colorFilter !== undefined) {\n paint.setColorFilter(colorFilter);\n }\n if (imageFilter !== undefined) {\n paint.setImageFilter(imageFilter);\n }\n if (maskFilter !== undefined) {\n paint.setMaskFilter(maskFilter);\n }\n if (pathEffect !== undefined) {\n paint.setPathEffect(pathEffect);\n }\n if (alpha !== undefined) {\n paint.setAlphaf(alpha * opacity);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(strokeCap);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(strokeJoin);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (style !== undefined) {\n paint.setStyle(style);\n }\n return paint;\n};\n"],"mappings":";;;;;;;AAOA;;AAgBA;;AAEA;;AAEA;;;;AAEA,MAAMA,UAAU,GAAG,CACjB,OADiB,EAEjB,aAFiB,EAGjB,WAHiB,EAIjB,WAJiB,EAKjB,YALiB,EAMjB,aANiB,EAOjB,OAPiB,EAQjB,WARiB,EASjB,SATiB,CAAnB;;AAiBO,MAAeC,aAAf,SACGC,aADH,CAGP;EAOEC,WAAW,CAACC,GAAD,EAAmBC,IAAnB,EAAmCC,KAAnC,EAA6C;IACtD,MAAMF,GAAN,EAAWC,IAAX,EAAiBC,KAAjB;;IADsD,oCANxB,IAMwB;;IAAA;;IAAA;;IAAA;;IAAA;;IAEtD,KAAKC,MAAL,GAAc,KAAKC,IAAL,CAAUC,MAAV,EAAd;IACA,KAAKC,YAAL;EACD;;EAEDC,QAAQ,CAACL,KAAD,EAAW;IACjB,MAAMK,QAAN,CAAeL,KAAf;IACA,KAAKI,YAAL;IACA,KAAKE,UAAL,GAAkB,IAAlB;EACD;;EAEDC,OAAO,CAAoBC,GAApB,EAA4BC,KAA5B,EAAyC;IAC9C,MAAMC,UAAU,GAAG,MAAMH,OAAN,CAAcC,GAAd,EAAmBC,KAAnB,CAAnB;;IACA,IAAIC,UAAJ,EAAgB;MACd,KAAKN,YAAL;;MACA,IAAIV,UAAU,CAACiB,QAAX,CAAoBH,GAApB,CAAJ,EAAwC;QACtC,KAAKF,UAAL,GAAkB,IAAlB;MACD;IACF;;IACD,OAAOI,UAAP;EACD;;EAESN,YAAY,GAAG;IACvB,KAAKH,MAAL,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,SAAnB,EAA8B;IAC5B2D,KAAK,CAAC0B,aAAN,CAAoBlC,UAApB;EACD;;EACD,IAAIP,UAAU,KAAK5C,SAAnB,EAA8B;IAC5B2D,KAAK,CAAC2B,aAAN,CAAoB1C,UAApB;EACD;;EACD,IAAI8B,KAAK,KAAK1E,SAAd,EAAyB;IACvB2D,KAAK,CAAC4B,SAAN,CAAgBb,KAAK,GAAGlD,OAAxB;EACD;;EACD,IAAIF,SAAS,KAAKtB,SAAlB,EAA6B;IAC3B2D,KAAK,CAAC6B,YAAN,CAAmBlE,SAAnB;EACD;;EACD,IAAID,UAAU,KAAKrB,SAAnB,EAA8B;IAC5B2D,KAAK,CAAC8B,aAAN,CAAoBpE,UAApB;EACD;;EACD,IAAIE,WAAW,KAAKvB,SAApB,EAA+B;IAC7B2D,KAAK,CAAC+B,cAAN,CAAqBnE,WAArB;EACD;;EACD,IAAIH,KAAK,KAAKpB,SAAd,EAAyB;IACvB2D,KAAK,CAACgC,QAAN,CAAevE,KAAf;EACD;;EACD,OAAOuC,KAAP;AACD,CAtED"}
|
1
|
+
{"version":3,"names":["paintProps","JsiRenderNode","JsiNode","constructor","ctx","type","props","matrix","Skia","Matrix","onPropChange","setProps","paintCache","setProp","key","value","hasChanged","includes","identity","clipPath","undefined","clipRect","clipRRect","computeMatrix","computeClip","addChild","child","JsiDeclarationNode","setInvalidate","insertChildBefore","before","clip","isPathDef","processPath","isRRect","processTransformProps","getPaintCtx","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","opacity","antiAlias","Color","BlendMode","enumKey","PaintStyle","StrokeJoin","StrokeCap","_children","forEach","isColorFilter","cf","materialize","colorFilter","ColorFilter","MakeCompose","isShader","shader","isPathEffect","pe","pathEffect","PathEffect","isImageFilter","filter","imageFilter","ImageFilter","isMaskFilter","maskFilter","render","parentCtx","invertClip","layer","transform","canvas","parent","paint","paintCtx","concatPaint","copy","hasTransform","hasClip","shouldSave","op","ClipOp","Difference","Intersect","saveLayer","save","concat","renderNode","restore","setAlphaf","getAlphaf","currentOpacity","setShader","setColor","setStrokeWidth","setAntiAlias","setBlendMode","setColorFilter","setImageFilter","setMaskFilter","setPathEffect","setStrokeCap","setStrokeJoin","setStrokeMiter","setStyle"],"sources":["RenderNode.ts"],"sourcesContent":["import type {\n SkMatrix,\n SkRect,\n SkRRect,\n SkPath,\n SkPaint,\n} from \"../../skia/types\";\nimport {\n StrokeCap,\n StrokeJoin,\n PaintStyle,\n BlendMode,\n ClipOp,\n isRRect,\n} from \"../../skia/types\";\nimport type {\n RenderNode,\n GroupProps,\n DrawingContext,\n NodeType,\n Node,\n} from \"../types\";\n\nimport { isPathDef, processPath, processTransformProps } from \"./datatypes\";\nimport type { NodeContext } from \"./Node\";\nimport { JsiNode, JsiDeclarationNode } from \"./Node\";\nimport type { PaintContext } from \"./PaintContext\";\nimport { enumKey } from \"./datatypes/Enum\";\n\nconst paintProps = [\n \"color\",\n \"strokeWidth\",\n \"blendMode\",\n \"strokeCap\",\n \"strokeJoin\",\n \"strokeMiter\",\n \"style\",\n \"antiAlias\",\n \"opacity\",\n];\n\ninterface PaintCache {\n parent: SkPaint;\n child: SkPaint;\n}\n\nexport abstract class JsiRenderNode<P extends GroupProps>\n extends JsiNode<P>\n implements RenderNode<P>\n{\n paintCache: PaintCache | null = null;\n matrix: SkMatrix;\n clipRect?: SkRect;\n clipRRect?: SkRRect;\n clipPath?: SkPath;\n\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, type, props);\n this.matrix = this.Skia.Matrix();\n this.onPropChange();\n }\n\n setProps(props: P) {\n super.setProps(props);\n this.onPropChange();\n this.paintCache = null;\n }\n\n setProp<K extends keyof P>(key: K, value: P[K]) {\n const hasChanged = super.setProp(key, value);\n if (hasChanged) {\n this.onPropChange();\n if (paintProps.includes(key as string)) {\n this.paintCache = null;\n }\n }\n return hasChanged;\n }\n\n protected onPropChange() {\n this.matrix.identity();\n this.clipPath = undefined;\n this.clipRect = undefined;\n this.clipRRect = undefined;\n this.computeMatrix();\n this.computeClip();\n }\n\n addChild(child: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.addChild(child);\n }\n\n insertChildBefore(child: Node<unknown>, before: Node<unknown>) {\n if (child instanceof JsiDeclarationNode) {\n child.setInvalidate(() => (this.paintCache = null));\n }\n super.insertChildBefore(child, before);\n }\n\n private computeClip() {\n const { clip } = this.props;\n if (clip) {\n if (isPathDef(clip)) {\n this.clipPath = processPath(this.Skia, clip);\n } else if (isRRect(clip)) {\n this.clipRRect = clip;\n } else {\n this.clipRect = clip;\n }\n }\n }\n\n private computeMatrix() {\n processTransformProps(this.matrix, this.props);\n }\n\n private getPaintCtx() {\n let ctx: PaintContext | undefined;\n const {\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n opacity,\n antiAlias,\n } = this.props;\n if (\n color !== undefined ||\n strokeWidth !== undefined ||\n blendMode !== undefined ||\n style !== undefined ||\n strokeJoin !== undefined ||\n strokeCap !== undefined ||\n strokeMiter !== undefined ||\n opacity !== undefined ||\n antiAlias !== undefined\n ) {\n ctx = { opacity: 1 };\n if (color !== undefined) {\n ctx.color = this.Skia.Color(color);\n }\n if (strokeWidth !== undefined) {\n ctx.strokeWidth = strokeWidth;\n }\n if (blendMode !== undefined) {\n ctx.blendMode = BlendMode[enumKey(blendMode)];\n }\n if (style !== undefined) {\n ctx.style = PaintStyle[enumKey(style)];\n }\n if (strokeJoin !== undefined) {\n ctx.strokeJoin = StrokeJoin[enumKey(strokeJoin)];\n }\n if (strokeCap !== undefined) {\n ctx.strokeCap = StrokeCap[enumKey(strokeCap)];\n }\n if (strokeMiter !== undefined) {\n ctx.strokeMiter = strokeMiter;\n }\n if (opacity !== undefined) {\n ctx.opacity = opacity;\n }\n if (antiAlias !== undefined) {\n ctx.antiAlias = antiAlias;\n }\n }\n this._children.forEach((child) => {\n if (child instanceof JsiDeclarationNode) {\n if (child.isColorFilter()) {\n ctx = ctx || {};\n const cf = child.materialize();\n ctx.colorFilter = ctx.colorFilter\n ? this.Skia.ColorFilter.MakeCompose(cf, ctx.colorFilter)\n : cf;\n } else if (child.isShader()) {\n ctx = ctx || {};\n const shader = child.materialize();\n ctx.shader = shader;\n } else if (child.isPathEffect()) {\n ctx = ctx || {};\n const pe = child.materialize();\n ctx.pathEffect = ctx.pathEffect\n ? this.Skia.PathEffect.MakeCompose(pe, ctx.pathEffect)\n : pe;\n } else if (child.isImageFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.imageFilter = ctx.imageFilter\n ? this.Skia.ImageFilter.MakeCompose(filter, ctx.imageFilter)\n : filter;\n } else if (child.isMaskFilter()) {\n ctx = ctx || {};\n const filter = child.materialize();\n ctx.maskFilter = filter;\n }\n }\n });\n return ctx;\n }\n\n render(parentCtx: DrawingContext) {\n const { invertClip, layer, matrix, transform } = this.props;\n const { canvas } = parentCtx;\n\n if (\n this.paintCache === null ||\n this.paintCache.parent !== parentCtx.paint\n ) {\n const paintCtx = this.getPaintCtx();\n const child = paintCtx\n ? concatPaint(parentCtx.paint.copy(), paintCtx)\n : parentCtx.paint;\n this.paintCache = { parent: parentCtx.paint, child };\n }\n const paint = this.paintCache.child;\n // TODO: can we only recreate a new context here if needed?\n const ctx = { ...parentCtx, paint };\n const hasTransform = matrix !== undefined || transform !== undefined;\n const hasClip =\n this.clipRect !== undefined ||\n this.clipPath !== undefined ||\n this.clipRRect !== undefined;\n const shouldSave = hasTransform || hasClip || !!layer;\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n if (shouldSave) {\n if (layer) {\n if (typeof layer === \"boolean\") {\n canvas.saveLayer();\n } else {\n canvas.saveLayer(layer);\n }\n } else {\n canvas.save();\n }\n }\n\n if (this.matrix) {\n canvas.concat(this.matrix);\n }\n if (this.clipRect) {\n canvas.clipRect(this.clipRect, op, true);\n } else if (this.clipRRect) {\n canvas.clipRRect(this.clipRRect, op, true);\n } else if (this.clipPath) {\n canvas.clipPath(this.clipPath, op, true);\n }\n\n this.renderNode(ctx);\n\n if (shouldSave) {\n canvas.restore();\n }\n }\n\n abstract renderNode(ctx: DrawingContext): void;\n}\n\nconst concatPaint = (\n paint: SkPaint,\n {\n color,\n strokeWidth,\n shader,\n antiAlias,\n blendMode,\n colorFilter,\n imageFilter,\n maskFilter,\n pathEffect,\n opacity,\n strokeCap,\n strokeJoin,\n strokeMiter,\n style,\n }: PaintContext\n) => {\n if (opacity !== undefined) {\n paint.setAlphaf(paint.getAlphaf() * opacity);\n }\n if (color !== undefined) {\n const currentOpacity = paint.getAlphaf();\n paint.setShader(null);\n paint.setColor(color);\n paint.setAlphaf(currentOpacity * paint.getAlphaf());\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (shader !== undefined) {\n paint.setShader(shader);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(blendMode);\n }\n if (colorFilter !== undefined) {\n paint.setColorFilter(colorFilter);\n }\n if (imageFilter !== undefined) {\n paint.setImageFilter(imageFilter);\n }\n if (maskFilter !== undefined) {\n paint.setMaskFilter(maskFilter);\n }\n if (pathEffect !== undefined) {\n paint.setPathEffect(pathEffect);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(strokeCap);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(strokeJoin);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (style !== undefined) {\n paint.setStyle(style);\n }\n return paint;\n};\n"],"mappings":";;;;;;;AAOA;;AAgBA;;AAEA;;AAEA;;;;AAEA,MAAMA,UAAU,GAAG,CACjB,OADiB,EAEjB,aAFiB,EAGjB,WAHiB,EAIjB,WAJiB,EAKjB,YALiB,EAMjB,aANiB,EAOjB,OAPiB,EAQjB,WARiB,EASjB,SATiB,CAAnB;;AAiBO,MAAeC,aAAf,SACGC,aADH,CAGP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,WAArB;EACD;;EACD,IAAIuB,MAAM,KAAKzC,SAAf,EAA0B;IACxB2D,KAAK,CAACmB,SAAN,CAAgBrC,MAAhB;EACD;;EACD,IAAIhB,SAAS,KAAKzB,SAAlB,EAA6B;IAC3B2D,KAAK,CAACsB,YAAN,CAAmBxD,SAAnB;EACD;;EACD,IAAIN,SAAS,KAAKnB,SAAlB,EAA6B;IAC3B2D,KAAK,CAACuB,YAAN,CAAmB/D,SAAnB;EACD;;EACD,IAAIkB,WAAW,KAAKrC,SAApB,EAA+B;IAC7B2D,KAAK,CAACwB,cAAN,CAAqB9C,WAArB;EACD;;EACD,IAAIW,WAAW,KAAKhD,SAApB,EAA+B;IAC7B2D,KAAK,CAACyB,cAAN,CAAqBpC,WAArB;EACD;;EACD,IAAIG,UAAU,KAAKnD,SAAnB,EAA8B;IAC5B2D,KAAK,CAAC0B,aAAN,CAAoBlC,UAApB;EACD;;EACD,IAAIP,UAAU,KAAK5C,SAAnB,EAA8B;IAC5B2D,KAAK,CAAC2B,aAAN,CAAoB1C,UAApB;EACD;;EACD,IAAItB,SAAS,KAAKtB,SAAlB,EAA6B;IAC3B2D,KAAK,CAAC4B,YAAN,CAAmBjE,SAAnB;EACD;;EACD,IAAID,UAAU,KAAKrB,SAAnB,EAA8B;IAC5B2D,KAAK,CAAC6B,aAAN,CAAoBnE,UAApB;EACD;;EACD,IAAIE,WAAW,KAAKvB,SAApB,EAA+B;IAC7B2D,KAAK,CAAC8B,cAAN,CAAqBlE,WAArB;EACD;;EACD,IAAIH,KAAK,KAAKpB,SAAd,EAAyB;IACvB2D,KAAK,CAAC+B,QAAN,CAAetE,KAAf;EACD;;EACD,OAAOuC,KAAP;AACD,CAjED"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isCircleScalarDef","def","cx","undefined","processCircle","Skia","c","Point","cy","r"],"sources":["Circle.ts"],"sourcesContent":["import type { Skia } from \"../../../skia/types\";\nimport type { CircleDef, ScalarCircleDef } from \"../../types\";\n\nexport const isCircleScalarDef = (def: CircleDef): def is ScalarCircleDef =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (def as any).cx !== undefined;\n\nexport const processCircle = (Skia: Skia, def: CircleDef) => {\n if (isCircleScalarDef(def)) {\n return { c: Skia.Point(def.cx, def.cy), r: def.r };\n }\n return def;\n};\n"],"mappings":";;;;;;;AAGO,MAAMA,iBAAiB,GAAIC,GAAD,IAC/B;AACA;AACCA,GAAD,CAAaC,EAAb,KAAoBC,SAHf;;;;AAKA,MAAMC,aAAa,GAAG,CAACC,IAAD,EAAaJ,GAAb,KAAgC;EAC3D,IAAID,iBAAiB,CAACC,GAAD,CAArB,EAA4B;IAC1B,OAAO;MAAEK,CAAC,EAAED,IAAI,CAACE,KAAL,CAAWN,GAAG,CAACC,EAAf,EAAmBD,GAAG,CAACO,EAAvB,CAAL;MAAiCC,CAAC,EAAER,GAAG,CAACQ;IAAxC,CAAP;EACD;;EACD,
|
1
|
+
{"version":3,"names":["isCircleScalarDef","def","cx","undefined","processCircle","Skia","c","Point","cy","r","x","y"],"sources":["Circle.ts"],"sourcesContent":["import type { Skia } from \"../../../skia/types\";\nimport type { CircleDef, ScalarCircleDef } from \"../../types\";\n\nexport const isCircleScalarDef = (def: CircleDef): def is ScalarCircleDef =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (def as any).cx !== undefined;\n\nexport const processCircle = (Skia: Skia, def: CircleDef) => {\n if (isCircleScalarDef(def)) {\n return { c: Skia.Point(def.cx, def.cy), r: def.r };\n }\n return { ...def, c: def.c ?? { x: 0, y: 0 } };\n};\n"],"mappings":";;;;;;;AAGO,MAAMA,iBAAiB,GAAIC,GAAD,IAC/B;AACA;AACCA,GAAD,CAAaC,EAAb,KAAoBC,SAHf;;;;AAKA,MAAMC,aAAa,GAAG,CAACC,IAAD,EAAaJ,GAAb,KAAgC;EAC3D,IAAID,iBAAiB,CAACC,GAAD,CAArB,EAA4B;IAC1B,OAAO;MAAEK,CAAC,EAAED,IAAI,CAACE,KAAL,CAAWN,GAAG,CAACC,EAAf,EAAmBD,GAAG,CAACO,EAAvB,CAAL;MAAiCC,CAAC,EAAER,GAAG,CAACQ;IAAxC,CAAP;EACD;;EACD,OAAO,EAAE,GAAGR,GAAL;IAAUK,CAAC,EAAEL,GAAG,CAACK,CAAJ,IAAS;MAAEI,CAAC,EAAE,CAAL;MAAQC,CAAC,EAAE;IAAX;EAAtB,CAAP;AACD,CALM"}
|
@@ -20,7 +20,7 @@ const isRectCtor = def => def.rect === undefined;
|
|
20
20
|
|
21
21
|
const processRect = (Skia, def) => {
|
22
22
|
if (isRectCtor(def)) {
|
23
|
-
return Skia.XYWHRect(def.x, def.y, def.width, def.height);
|
23
|
+
return Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height);
|
24
24
|
} else {
|
25
25
|
return def.rect;
|
26
26
|
}
|
@@ -30,8 +30,8 @@ exports.processRect = processRect;
|
|
30
30
|
|
31
31
|
const processRRect = (Skia, def) => {
|
32
32
|
if (isRRectCtor(def)) {
|
33
|
-
const r = (0, _Radius.processRadius)(Skia, def.r);
|
34
|
-
return Skia.RRectXY(Skia.XYWHRect(def.x, def.y, def.width, def.height), r.x, r.y);
|
33
|
+
const r = (0, _Radius.processRadius)(Skia, def.r ?? 0);
|
34
|
+
return Skia.RRectXY(Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height), r.x, r.y);
|
35
35
|
} else {
|
36
36
|
return def.rect;
|
37
37
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isEdge","pos","b","x","y","width","height","isRRectCtor","def","rect","undefined","isRectCtor","processRect","Skia","XYWHRect","processRRect","r","processRadius","RRectXY"],"sources":["Rect.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Skia, SkRect, Vector } from \"../../../skia/types\";\nimport type { RectCtor, RectDef, RRectCtor, RRectDef } from \"../../types\";\n\nimport { processRadius } from \"./Radius\";\n\nexport const isEdge = (pos: Vector, b: SkRect) =>\n pos.x === b.x || pos.y === b.y || pos.x === b.width || pos.y === b.height;\n\n// We have an issue to check property existence on JSI backed instances\nconst isRRectCtor = (def: RRectDef): def is RRectCtor =>\n (def as any).rect === undefined;\n// We have an issue to check property existence on JSI backed instances\nconst isRectCtor = (def: RectDef): def is RectCtor =>\n (def as any).rect === undefined;\n\nexport const processRect = (Skia: Skia, def: RectDef) => {\n if (isRectCtor(def)) {\n return Skia.XYWHRect(def.x, def.y, def.width, def.height);\n } else {\n return def.rect;\n }\n};\n\nexport const processRRect = (Skia: Skia, def: RRectDef) => {\n if (isRRectCtor(def)) {\n const r = processRadius(Skia, def.r);\n return Skia.RRectXY(\n Skia.XYWHRect(def.x, def.y, def.width, def.height),\n r.x,\n r.y\n );\n } else {\n return def.rect;\n }\n};\n"],"mappings":";;;;;;;AAIA;;AAJA;AAMO,MAAMA,MAAM,GAAG,CAACC,GAAD,EAAcC,CAAd,KACpBD,GAAG,CAACE,CAAJ,KAAUD,CAAC,CAACC,CAAZ,IAAiBF,GAAG,CAACG,CAAJ,KAAUF,CAAC,CAACE,CAA7B,IAAkCH,GAAG,CAACE,CAAJ,KAAUD,CAAC,CAACG,KAA9C,IAAuDJ,GAAG,CAACG,CAAJ,KAAUF,CAAC,CAACI,MAD9D,C,CAGP;;;;;AACA,MAAMC,WAAW,GAAIC,GAAD,IACjBA,GAAD,CAAaC,IAAb,KAAsBC,SADxB,C,CAEA;;;AACA,MAAMC,UAAU,GAAIH,GAAD,IAChBA,GAAD,CAAaC,IAAb,KAAsBC,SADxB;;AAGO,MAAME,WAAW,GAAG,CAACC,IAAD,EAAaL,GAAb,KAA8B;EACvD,IAAIG,UAAU,CAACH,GAAD,CAAd,EAAqB;IACnB,OAAOK,IAAI,CAACC,QAAL,CAAcN,GAAG,CAACL,
|
1
|
+
{"version":3,"names":["isEdge","pos","b","x","y","width","height","isRRectCtor","def","rect","undefined","isRectCtor","processRect","Skia","XYWHRect","processRRect","r","processRadius","RRectXY"],"sources":["Rect.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Skia, SkRect, Vector } from \"../../../skia/types\";\nimport type { RectCtor, RectDef, RRectCtor, RRectDef } from \"../../types\";\n\nimport { processRadius } from \"./Radius\";\n\nexport const isEdge = (pos: Vector, b: SkRect) =>\n pos.x === b.x || pos.y === b.y || pos.x === b.width || pos.y === b.height;\n\n// We have an issue to check property existence on JSI backed instances\nconst isRRectCtor = (def: RRectDef): def is RRectCtor =>\n (def as any).rect === undefined;\n// We have an issue to check property existence on JSI backed instances\nconst isRectCtor = (def: RectDef): def is RectCtor =>\n (def as any).rect === undefined;\n\nexport const processRect = (Skia: Skia, def: RectDef) => {\n if (isRectCtor(def)) {\n return Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height);\n } else {\n return def.rect;\n }\n};\n\nexport const processRRect = (Skia: Skia, def: RRectDef) => {\n if (isRRectCtor(def)) {\n const r = processRadius(Skia, def.r ?? 0);\n return Skia.RRectXY(\n Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height),\n r.x,\n r.y\n );\n } else {\n return def.rect;\n }\n};\n"],"mappings":";;;;;;;AAIA;;AAJA;AAMO,MAAMA,MAAM,GAAG,CAACC,GAAD,EAAcC,CAAd,KACpBD,GAAG,CAACE,CAAJ,KAAUD,CAAC,CAACC,CAAZ,IAAiBF,GAAG,CAACG,CAAJ,KAAUF,CAAC,CAACE,CAA7B,IAAkCH,GAAG,CAACE,CAAJ,KAAUD,CAAC,CAACG,KAA9C,IAAuDJ,GAAG,CAACG,CAAJ,KAAUF,CAAC,CAACI,MAD9D,C,CAGP;;;;;AACA,MAAMC,WAAW,GAAIC,GAAD,IACjBA,GAAD,CAAaC,IAAb,KAAsBC,SADxB,C,CAEA;;;AACA,MAAMC,UAAU,GAAIH,GAAD,IAChBA,GAAD,CAAaC,IAAb,KAAsBC,SADxB;;AAGO,MAAME,WAAW,GAAG,CAACC,IAAD,EAAaL,GAAb,KAA8B;EACvD,IAAIG,UAAU,CAACH,GAAD,CAAd,EAAqB;IACnB,OAAOK,IAAI,CAACC,QAAL,CAAcN,GAAG,CAACL,CAAJ,IAAS,CAAvB,EAA0BK,GAAG,CAACJ,CAAJ,IAAS,CAAnC,EAAsCI,GAAG,CAACH,KAA1C,EAAiDG,GAAG,CAACF,MAArD,CAAP;EACD,CAFD,MAEO;IACL,OAAOE,GAAG,CAACC,IAAX;EACD;AACF,CANM;;;;AAQA,MAAMM,YAAY,GAAG,CAACF,IAAD,EAAaL,GAAb,KAA+B;EACzD,IAAID,WAAW,CAACC,GAAD,CAAf,EAAsB;IACpB,MAAMQ,CAAC,GAAG,IAAAC,qBAAA,EAAcJ,IAAd,EAAoBL,GAAG,CAACQ,CAAJ,IAAS,CAA7B,CAAV;IACA,OAAOH,IAAI,CAACK,OAAL,CACLL,IAAI,CAACC,QAAL,CAAcN,GAAG,CAACL,CAAJ,IAAS,CAAvB,EAA0BK,GAAG,CAACJ,CAAJ,IAAS,CAAnC,EAAsCI,GAAG,CAACH,KAA1C,EAAiDG,GAAG,CAACF,MAArD,CADK,EAELU,CAAC,CAACb,CAFG,EAGLa,CAAC,CAACZ,CAHG,CAAP;EAKD,CAPD,MAOO;IACL,OAAOI,GAAG,CAACC,IAAX;EACD;AACF,CAXM"}
|
@@ -43,19 +43,6 @@ Object.keys(_Fitting).forEach(function (key) {
|
|
43
43
|
});
|
44
44
|
});
|
45
45
|
|
46
|
-
var _Color = require("./Color");
|
47
|
-
|
48
|
-
Object.keys(_Color).forEach(function (key) {
|
49
|
-
if (key === "default" || key === "__esModule") return;
|
50
|
-
if (key in exports && exports[key] === _Color[key]) return;
|
51
|
-
Object.defineProperty(exports, key, {
|
52
|
-
enumerable: true,
|
53
|
-
get: function () {
|
54
|
-
return _Color[key];
|
55
|
-
}
|
56
|
-
});
|
57
|
-
});
|
58
|
-
|
59
46
|
var _Rect = require("./Rect");
|
60
47
|
|
61
48
|
Object.keys(_Rect).forEach(function (key) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Enum\";\nexport * from \"./Path\";\nexport * from \"./Fitting\";\nexport * from \"./
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Enum\";\nexport * from \"./Path\";\nexport * from \"./Fitting\";\nexport * from \"./Rect\";\nexport * from \"./Radius\";\nexport * from \"./Circle\";\nexport * from \"./Gradient\";\nexport * from \"./Transform\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
@@ -11,8 +11,6 @@ var _types2 = require("../../types");
|
|
11
11
|
|
12
12
|
var _Node = require("../Node");
|
13
13
|
|
14
|
-
var _datatypes = require("../datatypes");
|
15
|
-
|
16
14
|
var _RenderNode = require("../RenderNode");
|
17
15
|
|
18
16
|
const inflate = function (Skia, box, dx, dy) {
|
@@ -48,12 +46,12 @@ class BoxNode extends _RenderNode.JsiRenderNode {
|
|
48
46
|
renderNode(_ref) {
|
49
47
|
let {
|
50
48
|
canvas,
|
51
|
-
paint
|
52
|
-
opacity
|
49
|
+
paint
|
53
50
|
} = _ref;
|
54
51
|
const {
|
55
52
|
box: defaultBox
|
56
53
|
} = this.props;
|
54
|
+
const opacity = paint.getAlphaf();
|
57
55
|
const box = (0, _types.isRRect)(defaultBox) ? defaultBox : this.Skia.RRectXY(defaultBox, 0, 0);
|
58
56
|
|
59
57
|
const shadows = this._children.map(node => {
|
@@ -73,7 +71,8 @@ class BoxNode extends _RenderNode.JsiRenderNode {
|
|
73
71
|
dy = 0
|
74
72
|
} = shadow;
|
75
73
|
const lPaint = this.Skia.Paint();
|
76
|
-
lPaint.setColor(
|
74
|
+
lPaint.setColor(this.Skia.Color(color));
|
75
|
+
lPaint.setAlphaf(paint.getAlphaf() * opacity);
|
77
76
|
lPaint.setMaskFilter(this.Skia.MaskFilter.MakeBlur(_types.BlurStyle.Normal, blur, true));
|
78
77
|
canvas.drawRRect(inflate(this.Skia, box, spread, spread, dx, dy), lPaint);
|
79
78
|
});
|
@@ -90,7 +89,8 @@ class BoxNode extends _RenderNode.JsiRenderNode {
|
|
90
89
|
canvas.save();
|
91
90
|
canvas.clipRRect(box, _types.ClipOp.Intersect, false);
|
92
91
|
const lPaint = this.Skia.Paint();
|
93
|
-
lPaint.setColor(
|
92
|
+
lPaint.setColor(this.Skia.Color(color));
|
93
|
+
lPaint.setAlphaf(paint.getAlphaf() * opacity);
|
94
94
|
lPaint.setMaskFilter(this.Skia.MaskFilter.MakeBlur(_types.BlurStyle.Normal, blur, true));
|
95
95
|
const inner = deflate(this.Skia, box, spread, spread, dx, dy);
|
96
96
|
const outer = inflate(this.Skia, box, delta.x, delta.y);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["inflate","Skia","box","dx","dy","tx","ty","RRectXY","XYWHRect","rect","x","y","width","height","rx","ry","deflate","BoxShadowNode","JsiDeclarationNode","constructor","ctx","props","DeclarationType","Unknown","NodeType","Box","materialize","BoxNode","JsiRenderNode","renderNode","canvas","paint","opacity","
|
1
|
+
{"version":3,"names":["inflate","Skia","box","dx","dy","tx","ty","RRectXY","XYWHRect","rect","x","y","width","height","rx","ry","deflate","BoxShadowNode","JsiDeclarationNode","constructor","ctx","props","DeclarationType","Unknown","NodeType","Box","materialize","BoxNode","JsiRenderNode","renderNode","canvas","paint","defaultBox","opacity","getAlphaf","isRRect","shadows","_children","map","node","filter","n","shadow","inner","color","blur","spread","lPaint","Paint","setColor","Color","setAlphaf","setMaskFilter","MaskFilter","MakeBlur","BlurStyle","Normal","drawRRect","delta","Point","Math","abs","save","clipRRect","ClipOp","Intersect","outer","drawDRRect","restore"],"sources":["Box.ts"],"sourcesContent":["import type { SkRRect, Skia } from \"../../../skia/types\";\nimport { BlurStyle, ClipOp, isRRect } from \"../../../skia/types\";\nimport type { DrawingContext } from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport type { BoxShadowProps, BoxProps } from \"../../types/Drawings\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport { JsiRenderNode } from \"../RenderNode\";\n\nconst inflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) =>\n Skia.RRectXY(\n Skia.XYWHRect(\n box.rect.x - dx + tx,\n box.rect.y - dy + ty,\n box.rect.width + 2 * dx,\n box.rect.height + 2 * dy\n ),\n box.rx + dx,\n box.ry + dy\n );\n\nconst deflate = (\n Skia: Skia,\n box: SkRRect,\n dx: number,\n dy: number,\n tx = 0,\n ty = 0\n) => inflate(Skia, box, -dx, -dy, tx, ty);\n\nexport class BoxShadowNode extends JsiDeclarationNode<\n BoxShadowProps,\n BoxShadowProps\n> {\n constructor(ctx: NodeContext, props: BoxShadowProps) {\n super(ctx, DeclarationType.Unknown, NodeType.Box, props);\n }\n\n materialize() {\n return this.props;\n }\n}\n\nexport class BoxNode extends JsiRenderNode<BoxProps> {\n constructor(ctx: NodeContext, props: BoxProps) {\n super(ctx, NodeType.Box, props);\n }\n\n renderNode({ canvas, paint }: DrawingContext) {\n const { box: defaultBox } = this.props;\n const opacity = paint.getAlphaf();\n const box = isRRect(defaultBox)\n ? defaultBox\n : this.Skia.RRectXY(defaultBox, 0, 0);\n const shadows = this._children\n .map((node) => {\n if (node instanceof BoxShadowNode) {\n return node.materialize();\n }\n return null;\n })\n .filter((n): n is BoxShadowProps => n !== null);\n shadows\n .filter((shadow) => !shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const lPaint = this.Skia.Paint();\n lPaint.setColor(this.Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n lPaint.setMaskFilter(\n this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n canvas.drawRRect(\n inflate(this.Skia, box, spread, spread, dx, dy),\n lPaint\n );\n });\n\n canvas.drawRRect(box, paint);\n\n shadows\n .filter((shadow) => shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const delta = this.Skia.Point(10 + Math.abs(dx), 10 + Math.abs(dy));\n canvas.save();\n canvas.clipRRect(box, ClipOp.Intersect, false);\n const lPaint = this.Skia.Paint();\n lPaint.setColor(this.Skia.Color(color));\n lPaint.setAlphaf(paint.getAlphaf() * opacity);\n\n lPaint.setMaskFilter(\n this.Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n const inner = deflate(this.Skia, box, spread, spread, dx, dy);\n const outer = inflate(this.Skia, box, delta.x, delta.y);\n canvas.drawDRRect(outer, inner, lPaint);\n canvas.restore();\n });\n }\n}\n"],"mappings":";;;;;;;AACA;;AAEA;;AAGA;;AACA;;AAEA,MAAMA,OAAO,GAAG,UACdC,IADc,EAEdC,GAFc,EAGdC,EAHc,EAIdC,EAJc;EAAA,IAKdC,EALc,uEAKT,CALS;EAAA,IAMdC,EANc,uEAMT,CANS;EAAA,OAQdL,IAAI,CAACM,OAAL,CACEN,IAAI,CAACO,QAAL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lBH;EAmBD;;AAxDkD"}
|
@@ -18,9 +18,9 @@ class ImageNode extends _DrawingNode.JsiDrawingNode {
|
|
18
18
|
|
19
19
|
deriveProps() {
|
20
20
|
const {
|
21
|
-
image
|
22
|
-
fit
|
21
|
+
image
|
23
22
|
} = this.props;
|
23
|
+
const fit = this.props.fit ?? "contain";
|
24
24
|
const rect = (0, _datatypes.processRect)(this.Skia, this.props);
|
25
25
|
const {
|
26
26
|
src,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ImageNode","JsiDrawingNode","constructor","ctx","props","NodeType","Image","deriveProps","image","fit","rect","processRect","Skia","src","dst","fitRects","x","y","width","height","draw","canvas","paint","derived","Error","drawImageRect"],"sources":["ImageNode.ts"],"sourcesContent":["import type { SkRect } from \"../../../skia/types\";\nimport type { DrawingContext, ImageProps } from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { fitRects, processRect } from \"../datatypes\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class ImageNode extends JsiDrawingNode<\n ImageProps,\n { src: SkRect; dst: SkRect }\n> {\n constructor(ctx: NodeContext, props: ImageProps) {\n super(ctx, NodeType.Image, props);\n }\n\n deriveProps() {\n const { image
|
1
|
+
{"version":3,"names":["ImageNode","JsiDrawingNode","constructor","ctx","props","NodeType","Image","deriveProps","image","fit","rect","processRect","Skia","src","dst","fitRects","x","y","width","height","draw","canvas","paint","derived","Error","drawImageRect"],"sources":["ImageNode.ts"],"sourcesContent":["import type { SkRect } from \"../../../skia/types\";\nimport type { DrawingContext, ImageProps } from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { fitRects, processRect } from \"../datatypes\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class ImageNode extends JsiDrawingNode<\n ImageProps,\n { src: SkRect; dst: SkRect }\n> {\n constructor(ctx: NodeContext, props: ImageProps) {\n super(ctx, NodeType.Image, props);\n }\n\n deriveProps() {\n const { image } = this.props;\n const fit = this.props.fit ?? \"contain\";\n const rect = processRect(this.Skia, this.props);\n const { src, dst } = fitRects(\n fit,\n {\n x: 0,\n y: 0,\n width: image.width(),\n height: image.height(),\n },\n rect\n );\n return { src, dst };\n }\n\n draw({ canvas, paint }: DrawingContext) {\n const { image } = this.props;\n if (!this.derived) {\n throw new Error(\"ImageNode: src and dst are undefined\");\n }\n const { src, dst } = this.derived;\n canvas.drawImageRect(image, src, dst, paint);\n }\n}\n"],"mappings":";;;;;;;AAEA;;AACA;;AACA;;AAGO,MAAMA,SAAN,SAAwBC,2BAAxB,CAGL;EACAC,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAsC;IAC/C,MAAMD,GAAN,EAAWE,eAAA,CAASC,KAApB,EAA2BF,KAA3B;EACD;;EAEDG,WAAW,GAAG;IACZ,MAAM;MAAEC;IAAF,IAAY,KAAKJ,KAAvB;IACA,MAAMK,GAAG,GAAG,KAAKL,KAAL,CAAWK,GAAX,IAAkB,SAA9B;IACA,MAAMC,IAAI,GAAG,IAAAC,sBAAA,EAAY,KAAKC,IAAjB,EAAuB,KAAKR,KAA5B,CAAb;IACA,MAAM;MAAES,GAAF;MAAOC;IAAP,IAAe,IAAAC,mBAAA,EACnBN,GADmB,EAEnB;MACEO,CAAC,EAAE,CADL;MAEEC,CAAC,EAAE,CAFL;MAGEC,KAAK,EAAEV,KAAK,CAACU,KAAN,EAHT;MAIEC,MAAM,EAAEX,KAAK,CAACW,MAAN;IAJV,CAFmB,EAQnBT,IARmB,CAArB;IAUA,OAAO;MAAEG,GAAF;MAAOC;IAAP,CAAP;EACD;;EAEDM,IAAI,OAAoC;IAAA,IAAnC;MAAEC,MAAF;MAAUC;IAAV,CAAmC;IACtC,MAAM;MAAEd;IAAF,IAAY,KAAKJ,KAAvB;;IACA,IAAI,CAAC,KAAKmB,OAAV,EAAmB;MACjB,MAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;IACD;;IACD,MAAM;MAAEX,GAAF;MAAOC;IAAP,IAAe,KAAKS,OAA1B;IACAF,MAAM,CAACI,aAAP,CAAqBjB,KAArB,EAA4BK,GAA5B,EAAiCC,GAAjC,EAAsCQ,KAAtC;EACD;;AA7BD"}
|