@shopify/react-native-skia 0.1.184 → 0.1.186
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +2 -1
- package/android/cpp/jni/JniPlatformContext.cpp +92 -3
- package/android/cpp/jni/include/JniPlatformContext.h +4 -0
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +8 -0
- package/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +17 -1
- package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +180 -0
- package/cpp/api/JsiSkFont.h +1 -1
- package/cpp/api/JsiSkHostObjects.h +1 -1
- package/cpp/api/JsiSkImage.h +8 -1
- package/cpp/api/JsiSkImageFactory.h +29 -0
- package/cpp/api/JsiSkPaint.h +7 -7
- package/cpp/api/JsiSkPathFactory.h +1 -1
- package/cpp/api/JsiSkPicture.h +2 -2
- package/cpp/api/JsiSkRuntimeEffect.h +3 -3
- package/cpp/api/JsiSkSVG.h +12 -2
- package/cpp/api/JsiSkShader.h +1 -1
- package/cpp/api/JsiSkSurface.h +3 -3
- package/cpp/api/JsiSkSurfaceFactory.h +1 -1
- package/cpp/api/JsiSkTypeface.h +1 -1
- package/cpp/rnskia/RNSkAnimation.h +3 -3
- package/cpp/rnskia/RNSkDomView.h +9 -9
- package/cpp/rnskia/RNSkInfoParameter.h +2 -2
- package/cpp/rnskia/RNSkJsView.h +8 -8
- package/cpp/rnskia/RNSkJsiViewApi.h +5 -5
- package/cpp/rnskia/RNSkPictureView.h +8 -8
- package/cpp/rnskia/RNSkPlatformContext.h +32 -3
- package/cpp/rnskia/RNSkValueApi.h +5 -5
- package/cpp/rnskia/RNSkView.h +10 -8
- package/cpp/rnskia/dom/base/ConcatablePaint.h +6 -6
- package/cpp/rnskia/dom/base/Declaration.h +1 -1
- package/cpp/rnskia/dom/base/DeclarationContext.h +7 -7
- package/cpp/rnskia/dom/base/DrawingContext.h +3 -3
- package/cpp/rnskia/dom/base/NodePropsContainer.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiGlyphsNode.h +8 -7
- package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +9 -6
- package/cpp/rnskia/dom/nodes/JsiImageNode.h +5 -2
- package/cpp/rnskia/dom/nodes/JsiImageSvgNode.h +9 -9
- package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiPathNode.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiPointsNode.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +7 -3
- package/cpp/rnskia/dom/nodes/JsiTextNode.h +5 -4
- package/cpp/rnskia/dom/nodes/JsiTextPathNode.h +3 -1
- package/cpp/rnskia/dom/props/BlendModeProp.h +1 -1
- package/cpp/rnskia/dom/props/CircleProp.h +1 -1
- package/cpp/rnskia/dom/props/ClipProp.h +1 -1
- package/cpp/rnskia/dom/props/FontProp.h +15 -10
- package/cpp/rnskia/dom/props/ImageProps.h +30 -16
- package/cpp/rnskia/dom/props/PaintProps.h +1 -1
- package/cpp/rnskia/dom/props/PathProp.h +1 -1
- package/cpp/rnskia/dom/props/PointProp.h +1 -1
- package/cpp/rnskia/dom/props/PointsProp.h +1 -1
- package/cpp/rnskia/dom/props/RRectProp.h +2 -2
- package/cpp/rnskia/dom/props/RadiusProp.h +1 -1
- package/cpp/rnskia/dom/props/RectProp.h +1 -1
- package/cpp/rnskia/dom/props/StrokeProps.h +1 -1
- package/cpp/rnskia/dom/props/SvgProp.h +18 -12
- package/cpp/rnskia/dom/props/TextBlobProp.h +60 -57
- package/cpp/rnskia/dom/props/TileModeProp.h +1 -1
- package/cpp/rnskia/dom/props/UniformsProp.h +1 -1
- package/cpp/rnskia/dom/props/VertexModeProp.h +1 -1
- package/cpp/rnskia/dom/props/VerticesProps.h +1 -1
- package/cpp/rnskia/values/RNSkClockValue.h +2 -2
- package/cpp/rnskia/values/RNSkComputedValue.h +1 -1
- package/cpp/rnskia/values/RNSkReadonlyValue.h +3 -3
- package/cpp/rnskia/values/RNSkValue.h +4 -4
- package/cpp/utils/RNSkMeasureTime.h +1 -1
- package/cpp/utils/RNSkTimingInfo.h +1 -1
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +16 -13
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +8 -0
- package/ios/RNSkia-iOS/SkiaManager.mm +20 -1
- package/ios/RNSkia-iOS/ViewScreenshotService.h +21 -0
- package/ios/RNSkia-iOS/ViewScreenshotService.mm +79 -0
- package/lib/commonjs/dom/nodes/drawings/ImageNode.js +22 -1
- package/lib/commonjs/dom/nodes/drawings/ImageNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/ImageSVG.js +5 -0
- package/lib/commonjs/dom/nodes/drawings/ImageSVG.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/Text.d.ts +2 -2
- package/lib/commonjs/dom/nodes/drawings/Text.js +13 -2
- package/lib/commonjs/dom/nodes/drawings/Text.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/Shaders.js +5 -0
- package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/commonjs/dom/types/Drawings.d.ts +5 -5
- package/lib/commonjs/dom/types/Drawings.js.map +1 -1
- package/lib/commonjs/dom/types/Shaders.d.ts +1 -1
- package/lib/commonjs/dom/types/Shaders.js.map +1 -1
- package/lib/commonjs/mock/index.js +2 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/skia/core/Image.d.ts +14 -2
- package/lib/commonjs/skia/core/Image.js +37 -1
- package/lib/commonjs/skia/core/Image.js.map +1 -1
- package/lib/commonjs/skia/types/Image/Image.d.ts +6 -0
- package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +7 -0
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/SVG/SVG.d.ts +4 -1
- package/lib/commonjs/skia/types/SVG/SVG.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkImage.js +4 -0
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +7 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/dom/nodes/drawings/ImageNode.js +22 -1
- package/lib/module/dom/nodes/drawings/ImageNode.js.map +1 -1
- package/lib/module/dom/nodes/drawings/ImageSVG.js +5 -0
- package/lib/module/dom/nodes/drawings/ImageSVG.js.map +1 -1
- package/lib/module/dom/nodes/drawings/Text.d.ts +2 -2
- package/lib/module/dom/nodes/drawings/Text.js +13 -2
- package/lib/module/dom/nodes/drawings/Text.js.map +1 -1
- package/lib/module/dom/nodes/paint/Shaders.js +5 -0
- package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/module/dom/types/Drawings.d.ts +5 -5
- package/lib/module/dom/types/Drawings.js.map +1 -1
- package/lib/module/dom/types/Shaders.d.ts +1 -1
- package/lib/module/dom/types/Shaders.js.map +1 -1
- package/lib/module/mock/index.js +2 -1
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/skia/core/Image.d.ts +14 -2
- package/lib/module/skia/core/Image.js +32 -0
- package/lib/module/skia/core/Image.js.map +1 -1
- package/lib/module/skia/types/Image/Image.d.ts +6 -0
- package/lib/module/skia/types/Image/Image.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +7 -0
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/SVG/SVG.d.ts +4 -1
- package/lib/module/skia/types/SVG/SVG.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/module/skia/web/JsiSkImage.js +4 -0
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -1
- package/lib/module/skia/web/JsiSkImageFactory.js +7 -0
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/typescript/src/dom/nodes/drawings/Text.d.ts +2 -2
- package/lib/typescript/src/dom/types/Drawings.d.ts +5 -5
- package/lib/typescript/src/dom/types/Shaders.d.ts +1 -1
- package/lib/typescript/src/skia/core/Image.d.ts +14 -2
- package/lib/typescript/src/skia/types/Image/Image.d.ts +6 -0
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +7 -0
- package/lib/typescript/src/skia/types/SVG/SVG.d.ts +4 -1
- package/lib/typescript/src/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -1
- package/package.json +2 -2
- package/scripts/install-npm.js +3 -2
- package/src/dom/nodes/drawings/ImageNode.ts +9 -1
- package/src/dom/nodes/drawings/ImageSVG.ts +3 -0
- package/src/dom/nodes/drawings/Text.ts +13 -3
- package/src/dom/nodes/paint/Shaders.ts +4 -0
- package/src/dom/types/Drawings.ts +5 -5
- package/src/dom/types/Shaders.ts +1 -1
- package/src/mock/index.ts +1 -0
- package/src/skia/core/Image.ts +43 -1
- package/src/skia/types/Image/Image.ts +7 -0
- package/src/skia/types/Image/ImageFactory.ts +8 -0
- package/src/skia/types/SVG/SVG.ts +4 -1
- package/src/skia/web/JsiSkImage.ts +7 -0
- package/src/skia/web/JsiSkImageFactory.ts +8 -1
package/cpp/rnskia/RNSkJsView.h
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
#include <jsi/jsi.h>
|
|
11
11
|
|
|
12
|
-
#include
|
|
13
|
-
#include
|
|
14
|
-
|
|
15
|
-
#include
|
|
16
|
-
#include
|
|
17
|
-
#include
|
|
18
|
-
#include
|
|
19
|
-
#include
|
|
12
|
+
#include "JsiValueWrapper.h"
|
|
13
|
+
#include "RNSkView.h"
|
|
14
|
+
|
|
15
|
+
#include "JsiSkCanvas.h"
|
|
16
|
+
#include "RNSkInfoParameter.h"
|
|
17
|
+
#include "RNSkLog.h"
|
|
18
|
+
#include "RNSkPlatformContext.h"
|
|
19
|
+
#include "RNSkTimingInfo.h"
|
|
20
20
|
|
|
21
21
|
#pragma clang diagnostic push
|
|
22
22
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
#include <unordered_map>
|
|
8
8
|
#include <vector>
|
|
9
9
|
|
|
10
|
-
#include
|
|
11
|
-
#include
|
|
12
|
-
#include
|
|
13
|
-
#include
|
|
14
|
-
#include
|
|
10
|
+
#include "JsiHostObject.h"
|
|
11
|
+
#include "JsiValueWrapper.h"
|
|
12
|
+
#include "RNSkPlatformContext.h"
|
|
13
|
+
#include "RNSkValue.h"
|
|
14
|
+
#include "RNSkView.h"
|
|
15
15
|
#include <jsi/jsi.h>
|
|
16
16
|
|
|
17
17
|
namespace RNSkia {
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
#include <jsi/jsi.h>
|
|
11
11
|
|
|
12
|
-
#include
|
|
13
|
-
#include
|
|
14
|
-
|
|
15
|
-
#include
|
|
16
|
-
#include
|
|
17
|
-
#include
|
|
18
|
-
#include
|
|
19
|
-
#include
|
|
12
|
+
#include "JsiValueWrapper.h"
|
|
13
|
+
#include "RNSkView.h"
|
|
14
|
+
|
|
15
|
+
#include "JsiSkPicture.h"
|
|
16
|
+
#include "RNSkInfoParameter.h"
|
|
17
|
+
#include "RNSkLog.h"
|
|
18
|
+
#include "RNSkPlatformContext.h"
|
|
19
|
+
#include "RNSkTimingInfo.h"
|
|
20
20
|
|
|
21
21
|
#pragma clang diagnostic push
|
|
22
22
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
#include <unordered_map>
|
|
10
10
|
#include <utility>
|
|
11
11
|
|
|
12
|
-
#include
|
|
12
|
+
#include "RNSkDispatchQueue.h"
|
|
13
13
|
|
|
14
14
|
#pragma clang diagnostic push
|
|
15
15
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
16
16
|
|
|
17
|
+
#include "SkData.h"
|
|
18
|
+
#include "SkImage.h"
|
|
17
19
|
#include "SkStream.h"
|
|
18
20
|
#include "SkSurface.h"
|
|
19
21
|
|
|
@@ -88,6 +90,18 @@ public:
|
|
|
88
90
|
_dispatchQueue->dispatch(std::move(func));
|
|
89
91
|
}
|
|
90
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Runs the passed function on the main thread
|
|
95
|
+
* @param func Function to run.
|
|
96
|
+
*/
|
|
97
|
+
virtual void runOnMainThread(std::function<void()> func) = 0;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Takes a screenshot of a given view represented by the view tag
|
|
101
|
+
* @param tag React view tag
|
|
102
|
+
*/
|
|
103
|
+
virtual sk_sp<SkImage> takeScreenshotFromViewTag(size_t tag) = 0;
|
|
104
|
+
|
|
91
105
|
/**
|
|
92
106
|
Returns the javascript runtime
|
|
93
107
|
*/
|
|
@@ -112,12 +126,27 @@ public:
|
|
|
112
126
|
|
|
113
127
|
/**
|
|
114
128
|
* Creates an offscreen surface
|
|
115
|
-
* @param width
|
|
116
|
-
* @param height
|
|
129
|
+
* @param width Width of the offscreen surface
|
|
130
|
+
* @param height Height of the offscreen surface
|
|
117
131
|
* @return sk_sp<SkSurface>
|
|
118
132
|
*/
|
|
119
133
|
virtual sk_sp<SkSurface> makeOffscreenSurface(int width, int height) = 0;
|
|
120
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Creates an skImage containing the screenshot of a native view and its
|
|
137
|
+
* children.
|
|
138
|
+
* @param viewTag React viewtag
|
|
139
|
+
* @param callback Called when image is ready or with null if something
|
|
140
|
+
* failed.
|
|
141
|
+
*/
|
|
142
|
+
virtual void
|
|
143
|
+
makeViewScreenshot(int viewTag,
|
|
144
|
+
std::function<void(sk_sp<SkImage>)> callback) {
|
|
145
|
+
runOnMainThread([this, callback, viewTag]() {
|
|
146
|
+
callback(takeScreenshotFromViewTag(viewTag));
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
121
150
|
/**
|
|
122
151
|
* Raises an exception on the platform. This function does not necessarily
|
|
123
152
|
* throw an exception and stop execution, so it is important to stop execution
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
4
|
|
|
5
|
-
#include
|
|
6
|
-
#include
|
|
7
|
-
#include
|
|
8
|
-
#include
|
|
9
|
-
#include
|
|
5
|
+
#include "JsiHostObject.h"
|
|
6
|
+
#include "RNSkAnimation.h"
|
|
7
|
+
#include "RNSkComputedValue.h"
|
|
8
|
+
#include "RNSkPlatformContext.h"
|
|
9
|
+
#include "RNSkValue.h"
|
|
10
10
|
#include <jsi/jsi.h>
|
|
11
11
|
|
|
12
12
|
namespace RNSkia {
|
package/cpp/rnskia/RNSkView.h
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
#include <unordered_map>
|
|
7
7
|
#include <vector>
|
|
8
8
|
|
|
9
|
-
#include
|
|
10
|
-
#include
|
|
11
|
-
#include
|
|
9
|
+
#include "JsiValueWrapper.h"
|
|
10
|
+
#include "RNSkPlatformContext.h"
|
|
11
|
+
#include "RNSkValue.h"
|
|
12
12
|
|
|
13
|
-
#include
|
|
14
|
-
#include
|
|
15
|
-
#include
|
|
13
|
+
#include "JsiSkImage.h"
|
|
14
|
+
#include "JsiSkPoint.h"
|
|
15
|
+
#include "JsiSkRect.h"
|
|
16
16
|
|
|
17
17
|
#pragma clang diagnostic push
|
|
18
18
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -99,13 +99,15 @@ public:
|
|
|
99
99
|
Returns a snapshot of the current surface/canvas
|
|
100
100
|
*/
|
|
101
101
|
sk_sp<SkImage> makeSnapshot(std::shared_ptr<SkRect> bounds) {
|
|
102
|
+
sk_sp<SkImage> image;
|
|
102
103
|
if (bounds != nullptr) {
|
|
103
104
|
SkIRect b = SkIRect::MakeXYWH(bounds->x(), bounds->y(), bounds->width(),
|
|
104
105
|
bounds->height());
|
|
105
|
-
|
|
106
|
+
image = _surface->makeImageSnapshot(b);
|
|
106
107
|
} else {
|
|
107
|
-
|
|
108
|
+
image = _surface->makeImageSnapshot();
|
|
108
109
|
}
|
|
110
|
+
return image->makeNonTextureImage();
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
/**
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
#pragma clang diagnostic push
|
|
7
7
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
8
8
|
|
|
9
|
-
#include
|
|
10
|
-
#include
|
|
11
|
-
#include
|
|
12
|
-
#include
|
|
13
|
-
#include
|
|
14
|
-
#include
|
|
9
|
+
#include "SkColorFilter.h"
|
|
10
|
+
#include "SkImageFilter.h"
|
|
11
|
+
#include "SkMaskFilter.h"
|
|
12
|
+
#include "SkPaint.h"
|
|
13
|
+
#include "SkPathEffect.h"
|
|
14
|
+
#include "SkShader.h"
|
|
15
15
|
|
|
16
16
|
#pragma clang diagnostic pop
|
|
17
17
|
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
#pragma clang diagnostic push
|
|
10
10
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
11
11
|
|
|
12
|
-
#include
|
|
13
|
-
#include
|
|
14
|
-
#include
|
|
15
|
-
#include
|
|
16
|
-
#include
|
|
17
|
-
#include
|
|
18
|
-
#include
|
|
12
|
+
#include "SkColorFilter.h"
|
|
13
|
+
#include "SkImageFilter.h"
|
|
14
|
+
#include "SkImageFilters.h"
|
|
15
|
+
#include "SkMaskFilter.h"
|
|
16
|
+
#include "SkPaint.h"
|
|
17
|
+
#include "SkPathEffect.h"
|
|
18
|
+
#include "SkShader.h"
|
|
19
19
|
|
|
20
20
|
#pragma clang diagnostic pop
|
|
21
21
|
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
#pragma clang diagnostic push
|
|
14
14
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
15
15
|
|
|
16
|
-
#include
|
|
17
|
-
#include
|
|
18
|
-
#include
|
|
16
|
+
#include "SkCanvas.h"
|
|
17
|
+
#include "SkPaint.h"
|
|
18
|
+
#include "SkRefCnt.h"
|
|
19
19
|
|
|
20
20
|
#pragma clang diagnostic pop
|
|
21
21
|
|
|
@@ -54,7 +54,7 @@ public:
|
|
|
54
54
|
void updatePendingValues() {
|
|
55
55
|
for (auto &prop : _properties) {
|
|
56
56
|
prop->updatePendingChanges();
|
|
57
|
-
if (
|
|
57
|
+
if (prop->isRequired() && !prop->isSet()) {
|
|
58
58
|
throw std::runtime_error("Missing one or more required properties " +
|
|
59
59
|
std::string(prop->getName()) + " in the " +
|
|
60
60
|
_type + " component.");
|
|
@@ -20,12 +20,14 @@ protected:
|
|
|
20
20
|
auto x = _xProp->value().getAsNumber();
|
|
21
21
|
auto y = _yProp->value().getAsNumber();
|
|
22
22
|
auto font = _fontProp->getDerivedValue();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
if (font != nullptr) {
|
|
24
|
+
auto glyphInfo = _glyphsProp->getDerivedValue();
|
|
25
|
+
|
|
26
|
+
context->getCanvas()->drawGlyphs(
|
|
27
|
+
static_cast<int>(glyphInfo->glyphIds.size()),
|
|
28
|
+
glyphInfo->glyphIds.data(), glyphInfo->positions.data(),
|
|
29
|
+
SkPoint::Make(x, y), *font, *context->getPaint());
|
|
30
|
+
}
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
void defineProperties(NodePropsContainer *container) override {
|
|
@@ -36,7 +38,6 @@ protected:
|
|
|
36
38
|
_xProp = container->defineProperty<NodeProp>("x");
|
|
37
39
|
_yProp = container->defineProperty<NodeProp>("y");
|
|
38
40
|
|
|
39
|
-
_fontProp->require();
|
|
40
41
|
_glyphsProp->require();
|
|
41
42
|
_xProp->require();
|
|
42
43
|
_yProp->require();
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
#pragma clang diagnostic push
|
|
17
17
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
18
18
|
|
|
19
|
-
#include
|
|
19
|
+
#include "SkImageFilter.h"
|
|
20
20
|
|
|
21
21
|
#pragma clang diagnostic pop
|
|
22
22
|
|
|
@@ -107,11 +107,14 @@ public:
|
|
|
107
107
|
auto f2 = SkImageFilters::Offset(dx, dy, f1);
|
|
108
108
|
auto f3 = SkImageFilters::Blur(blur, blur, SkTileMode::kDecal, f2);
|
|
109
109
|
auto f4 = SkImageFilters::Blend(SkBlendMode::kSrcIn, srcAlpha, f3);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
if (shadowOnly) {
|
|
111
|
+
composeAndPush(context, f4);
|
|
112
|
+
} else {
|
|
113
|
+
composeAndPush(context, SkImageFilters::Compose(
|
|
114
|
+
input ? input : nullptr,
|
|
115
|
+
SkImageFilters::Blend(SkBlendMode::kSrcOver,
|
|
116
|
+
srcGraphic, f4)));
|
|
117
|
+
}
|
|
115
118
|
|
|
116
119
|
} else {
|
|
117
120
|
composeAndPush(
|
|
@@ -16,16 +16,19 @@ public:
|
|
|
16
16
|
protected:
|
|
17
17
|
void draw(DrawingContext *context) override {
|
|
18
18
|
auto rects = _imageProps->getDerivedValue();
|
|
19
|
+
auto image = _imageProps->getImage();
|
|
20
|
+
if (image == nullptr) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
19
23
|
|
|
20
24
|
context->getCanvas()->drawImageRect(
|
|
21
|
-
|
|
25
|
+
image, rects->src, rects->dst, SkSamplingOptions(),
|
|
22
26
|
context->getPaint().get(), SkCanvas::kStrict_SrcRectConstraint);
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
void defineProperties(NodePropsContainer *container) override {
|
|
26
30
|
JsiDomDrawingNode::defineProperties(container);
|
|
27
31
|
_imageProps = container->defineProperty<ImageProps>();
|
|
28
|
-
_imageProps->require();
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
private:
|
|
@@ -17,21 +17,21 @@ public:
|
|
|
17
17
|
protected:
|
|
18
18
|
void draw(DrawingContext *context) override {
|
|
19
19
|
auto svgDom = _svgDomProp->getDerivedValue();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
if (svgDom != nullptr) {
|
|
21
|
+
auto rect = _rectProp->getDerivedValue();
|
|
22
|
+
|
|
23
|
+
context->getCanvas()->save();
|
|
24
|
+
context->getCanvas()->translate(rect->x(), rect->y());
|
|
25
|
+
svgDom->setContainerSize(SkSize::Make(rect->width(), rect->height()));
|
|
26
|
+
svgDom->render(context->getCanvas());
|
|
27
|
+
context->getCanvas()->restore();
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
void defineProperties(NodePropsContainer *container) override {
|
|
30
32
|
JsiDomDrawingNode::defineProperties(container);
|
|
31
33
|
_svgDomProp = container->defineProperty<SvgProp>("svg");
|
|
32
34
|
_rectProp = container->defineProperty<RectProps>("rect");
|
|
33
|
-
|
|
34
|
-
_svgDomProp->require();
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
private:
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
#pragma clang diagnostic push
|
|
18
18
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
19
19
|
|
|
20
|
-
#include
|
|
20
|
+
#include "SkShader.h"
|
|
21
21
|
|
|
22
22
|
#pragma clang diagnostic pop
|
|
23
23
|
|
|
@@ -91,6 +91,10 @@ public:
|
|
|
91
91
|
void decorate(DeclarationContext *context) override {
|
|
92
92
|
|
|
93
93
|
auto image = _imageProps->getImage();
|
|
94
|
+
if (image == nullptr) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
94
98
|
auto rect = _imageProps->getRect();
|
|
95
99
|
auto lm =
|
|
96
100
|
_transformProp->isSet() ? _transformProp->getDerivedValue() : nullptr;
|
|
@@ -98,7 +102,7 @@ public:
|
|
|
98
102
|
if (rect != nullptr && lm != nullptr) {
|
|
99
103
|
auto rc = _imageProps->getDerivedValue();
|
|
100
104
|
auto m3 = _imageProps->rect2rect(rc->src, rc->dst);
|
|
101
|
-
if (_transformProp->isChanged()) {
|
|
105
|
+
if (_transformProp->isChanged() || _imageProps->isChanged()) {
|
|
102
106
|
// To modify the matrix we need to copy it since we're not allowed to
|
|
103
107
|
// modify values contained in properties - this would have caused the
|
|
104
108
|
// matrix to be translated and scaled more and more for each render
|
|
@@ -144,7 +148,7 @@ protected:
|
|
|
144
148
|
_transformProp->require();
|
|
145
149
|
|
|
146
150
|
// Add and require the image
|
|
147
|
-
container->defineProperty<NodeProp>("image")
|
|
151
|
+
container->defineProperty<NodeProp>("image");
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
private:
|
|
@@ -21,9 +21,11 @@ protected:
|
|
|
21
21
|
auto y = _yProp->value().getAsNumber();
|
|
22
22
|
auto font = _fontProp->getDerivedValue();
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
if (font != nullptr) {
|
|
25
|
+
context->getCanvas()->drawSimpleText(text, strlen(text),
|
|
26
|
+
SkTextEncoding::kUTF8, x, y, *font,
|
|
27
|
+
*context->getPaint());
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
void defineProperties(NodePropsContainer *container) override {
|
|
@@ -34,7 +36,6 @@ protected:
|
|
|
34
36
|
_xProp = container->defineProperty<NodeProp>("x");
|
|
35
37
|
_yProp = container->defineProperty<NodeProp>("y");
|
|
36
38
|
|
|
37
|
-
_fontProp->require();
|
|
38
39
|
_textProp->require();
|
|
39
40
|
_xProp->require();
|
|
40
41
|
_yProp->require();
|
|
@@ -16,7 +16,9 @@ public:
|
|
|
16
16
|
protected:
|
|
17
17
|
void draw(DrawingContext *context) override {
|
|
18
18
|
auto blob = _textBlobProp->getDerivedValue();
|
|
19
|
-
|
|
19
|
+
if (blob != nullptr) {
|
|
20
|
+
context->getCanvas()->drawTextBlob(blob, 0, 0, *context->getPaint());
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
void defineProperties(NodePropsContainer *container) override {
|
|
@@ -17,17 +17,22 @@ public:
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
void updateDerivedValue() override {
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
if (_fontProp->isSet()) {
|
|
21
|
+
if (_fontProp->value().getType() == PropType::HostObject) {
|
|
22
|
+
auto ptr = _fontProp->value().getAs<JsiSkFont>();
|
|
23
|
+
if (ptr == nullptr) {
|
|
24
|
+
throw std::runtime_error(
|
|
25
|
+
"Expected SkFont object for the Font property.");
|
|
26
|
+
}
|
|
27
|
+
setDerivedValue(ptr->getObject());
|
|
28
|
+
|
|
29
|
+
} else {
|
|
30
|
+
throw std::runtime_error(
|
|
31
|
+
"Expected SkFont object or null/undefined for the Font property.");
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
setDerivedValue(nullptr);
|
|
23
35
|
}
|
|
24
|
-
|
|
25
|
-
auto ptr = _fontProp->value().getAs<JsiSkFont>();
|
|
26
|
-
if (ptr == nullptr) {
|
|
27
|
-
throw std::runtime_error("Expected SkFont object for the Font property.");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
setDerivedValue(ptr->getObject());
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
private:
|
|
@@ -32,20 +32,32 @@ public:
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
void updateDerivedValue() override {
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
if (_imageProp->isSet()) {
|
|
36
|
+
// Check for host object
|
|
37
|
+
if (_imageProp->value().getType() == PropType::HostObject) {
|
|
38
|
+
// This should be an SkImage wrapper:
|
|
39
|
+
auto ptr = std::dynamic_pointer_cast<JsiSkImage>(
|
|
40
|
+
_imageProp->value().getAsHostObject());
|
|
41
|
+
if (ptr == nullptr) {
|
|
42
|
+
// If not - throw an exception
|
|
43
|
+
throw std::runtime_error("Expected SkImage object for the " +
|
|
44
|
+
std::string(getName()) +
|
|
45
|
+
" property. Got a " +
|
|
46
|
+
_imageProp->value().getTypeAsString(
|
|
47
|
+
_imageProp->value().getType()) +
|
|
48
|
+
".");
|
|
49
|
+
}
|
|
50
|
+
setDerivedValue(ptr->getObject());
|
|
51
|
+
} else {
|
|
52
|
+
// Should be a host object if set
|
|
53
|
+
throw std::runtime_error(
|
|
54
|
+
"Expected SkImage object or null/undefined for the " +
|
|
55
|
+
std::string(getName()) + " property.");
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
// Set to null
|
|
59
|
+
setDerivedValue(nullptr);
|
|
46
60
|
}
|
|
47
|
-
|
|
48
|
-
setDerivedValue(ptr->getObject());
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
private:
|
|
@@ -62,11 +74,12 @@ public:
|
|
|
62
74
|
}
|
|
63
75
|
|
|
64
76
|
void updateDerivedValue() override {
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
auto image = _imageProp->getDerivedValue();
|
|
78
|
+
if (image == nullptr) {
|
|
79
|
+
setDerivedValue(nullptr);
|
|
80
|
+
return;
|
|
67
81
|
}
|
|
68
82
|
|
|
69
|
-
auto image = _imageProp->getDerivedValue();
|
|
70
83
|
auto imageRect = SkRect::MakeXYWH(0, 0, image->width(), image->height());
|
|
71
84
|
|
|
72
85
|
auto rect = _rectProp->getDerivedValue() ? *_rectProp->getDerivedValue()
|
|
@@ -77,6 +90,7 @@ public:
|
|
|
77
90
|
}
|
|
78
91
|
|
|
79
92
|
sk_sp<SkImage> getImage() { return _imageProp->getDerivedValue(); }
|
|
93
|
+
|
|
80
94
|
std::shared_ptr<const SkRect> getRect() {
|
|
81
95
|
return _rectProp->getDerivedValue();
|
|
82
96
|
}
|