@shopify/react-native-skia 0.1.155 → 0.1.156
Sign up to get free protection for your applications and to get access to all the features.
- package/android/cpp/jni/JniLoad.cpp +5 -5
- package/android/cpp/jni/JniPlatformContext.cpp +107 -119
- package/android/cpp/jni/JniSkiaManager.cpp +18 -20
- package/android/cpp/jni/include/JniPlatformContext.h +41 -45
- package/android/cpp/jni/include/JniSkiaBaseView.h +52 -55
- package/android/cpp/jni/include/JniSkiaDrawView.h +72 -77
- package/android/cpp/jni/include/JniSkiaManager.h +51 -53
- package/android/cpp/jni/include/JniSkiaPictureView.h +74 -78
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +36 -45
- package/android/cpp/rnskia-android/RNSkAndroidView.h +87 -92
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +62 -65
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +20 -17
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +257 -313
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +107 -110
- package/cpp/api/JsiSkApi.h +66 -62
- package/cpp/api/JsiSkCanvas.h +38 -30
- package/cpp/api/JsiSkColor.h +58 -56
- package/cpp/api/JsiSkColorFilter.h +5 -3
- package/cpp/api/JsiSkColorFilterFactory.h +23 -21
- package/cpp/api/JsiSkContourMeasure.h +74 -85
- package/cpp/api/JsiSkContourMeasureIter.h +68 -75
- package/cpp/api/JsiSkData.h +16 -22
- package/cpp/api/JsiSkDataFactory.h +86 -79
- package/cpp/api/JsiSkFont.h +286 -311
- package/cpp/api/JsiSkHostObjects.h +15 -16
- package/cpp/api/JsiSkImage.h +107 -103
- package/cpp/api/JsiSkImageFactory.h +34 -36
- package/cpp/api/JsiSkImageFilter.h +5 -3
- package/cpp/api/JsiSkImageFilterFactory.h +71 -68
- package/cpp/api/JsiSkImageInfo.h +41 -38
- package/cpp/api/JsiSkMaskFilter.h +5 -3
- package/cpp/api/JsiSkMaskFilterFactory.h +2 -3
- package/cpp/api/JsiSkMatrix.h +26 -36
- package/cpp/api/JsiSkPaint.h +20 -13
- package/cpp/api/JsiSkPath.h +70 -85
- package/cpp/api/JsiSkPathEffect.h +5 -3
- package/cpp/api/JsiSkPathEffectFactory.h +33 -28
- package/cpp/api/JsiSkPathFactory.h +68 -67
- package/cpp/api/JsiSkPicture.h +28 -22
- package/cpp/api/JsiSkPictureFactory.h +13 -12
- package/cpp/api/JsiSkPictureRecorder.h +21 -19
- package/cpp/api/JsiSkPoint.h +6 -8
- package/cpp/api/JsiSkRRect.h +11 -7
- package/cpp/api/JsiSkRSXform.h +82 -85
- package/cpp/api/JsiSkRect.h +9 -9
- package/cpp/api/JsiSkRuntimeEffect.h +182 -186
- package/cpp/api/JsiSkRuntimeEffectFactory.h +10 -11
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +64 -61
- package/cpp/api/JsiSkSVG.h +4 -5
- package/cpp/api/JsiSkSVGFactory.h +28 -27
- package/cpp/api/JsiSkShader.h +3 -2
- package/cpp/api/JsiSkShaderFactory.h +37 -25
- package/cpp/api/JsiSkSurface.h +44 -40
- package/cpp/api/JsiSkSurfaceFactory.h +22 -22
- package/cpp/api/JsiSkTextBlob.h +28 -31
- package/cpp/api/JsiSkTextBlobFactory.h +88 -87
- package/cpp/api/JsiSkTypeface.h +6 -5
- package/cpp/api/JsiSkTypefaceFactory.h +22 -21
- package/cpp/api/JsiSkVertices.h +137 -124
- package/cpp/api/third_party/CSSColorParser.cpp +161 -174
- package/cpp/api/third_party/CSSColorParser.h +172 -96
- package/cpp/jsi/JsiHostObject.cpp +11 -9
- package/cpp/jsi/JsiHostObject.h +31 -24
- package/cpp/jsi/JsiSimpleValueWrapper.h +74 -83
- package/cpp/jsi/JsiValueWrapper.h +52 -54
- package/cpp/rnskia/RNSkAnimation.h +26 -29
- package/cpp/rnskia/RNSkDispatchQueue.cpp +50 -61
- package/cpp/rnskia/RNSkDispatchQueue.h +3 -1
- package/cpp/rnskia/RNSkInfoParameter.h +12 -12
- package/cpp/rnskia/RNSkJsView.cpp +82 -81
- package/cpp/rnskia/RNSkJsView.h +45 -41
- package/cpp/rnskia/RNSkJsiViewApi.h +99 -89
- package/cpp/rnskia/RNSkManager.cpp +8 -7
- package/cpp/rnskia/RNSkManager.h +8 -6
- package/cpp/rnskia/RNSkPictureView.h +44 -37
- package/cpp/rnskia/RNSkPlatformContext.h +39 -28
- package/cpp/rnskia/RNSkValueApi.h +33 -34
- package/cpp/rnskia/RNSkView.h +108 -93
- package/cpp/rnskia/values/RNSkClockValue.h +63 -64
- package/cpp/rnskia/values/RNSkComputedValue.h +32 -30
- package/cpp/rnskia/values/RNSkReadonlyValue.h +60 -59
- package/cpp/rnskia/values/RNSkValue.h +38 -40
- package/cpp/utils/RNSkLog.h +9 -7
- package/cpp/utils/RNSkMeasureTime.h +7 -7
- package/cpp/utils/RNSkTimingInfo.h +27 -24
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.h +8 -9
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +24 -23
- package/ios/RNSkia-iOS/RNSkiOSView.h +16 -13
- package/ios/RNSkia-iOS/SkiaUIView.h +9 -8
- package/lib/commonjs/dom/nodes/JsiSkDOM.js +6 -0
- package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/commonjs/dom/nodes/LayerNode.js +43 -0
- package/lib/commonjs/dom/nodes/LayerNode.js.map +1 -0
- package/lib/commonjs/dom/types/NodeType.js +1 -0
- package/lib/commonjs/dom/types/NodeType.js.map +1 -1
- package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
- package/lib/commonjs/renderer/HostComponents.js +3 -0
- package/lib/commonjs/renderer/HostComponents.js.map +1 -1
- package/lib/commonjs/renderer/components/Group.js +19 -4
- package/lib/commonjs/renderer/components/Group.js.map +1 -1
- package/lib/commonjs/renderer/components/Paint.js +6 -1
- package/lib/commonjs/renderer/components/Paint.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.js +3 -2
- package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
- package/lib/commonjs/views/SkiaView.js +6 -3
- package/lib/commonjs/views/SkiaView.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.js +5 -0
- package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/module/dom/nodes/LayerNode.js +32 -0
- package/lib/module/dom/nodes/LayerNode.js.map +1 -0
- package/lib/module/dom/types/NodeType.js +1 -0
- package/lib/module/dom/types/NodeType.js.map +1 -1
- package/lib/module/dom/types/SkDOM.js.map +1 -1
- package/lib/module/renderer/HostComponents.js +3 -0
- package/lib/module/renderer/HostComponents.js.map +1 -1
- package/lib/module/renderer/components/Group.js +16 -3
- package/lib/module/renderer/components/Group.js.map +1 -1
- package/lib/module/renderer/components/Paint.js +7 -1
- package/lib/module/renderer/components/Paint.js.map +1 -1
- package/lib/module/views/SkiaPictureView.js +2 -2
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/SkiaView.js +4 -2
- package/lib/module/views/SkiaView.js.map +1 -1
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +2 -0
- package/lib/typescript/src/dom/nodes/LayerNode.d.ts +8 -0
- package/lib/typescript/src/dom/types/NodeType.d.ts +1 -0
- package/lib/typescript/src/dom/types/SkDOM.d.ts +1 -0
- package/lib/typescript/src/renderer/HostComponents.d.ts +2 -1
- package/lib/typescript/src/renderer/components/Group.d.ts +5 -1
- package/lib/typescript/src/views/SkiaView.d.ts +3 -0
- package/libs/android/arm64-v8a/libskottie.a +0 -0
- package/libs/android/arm64-v8a/libsksg.a +0 -0
- package/libs/android/armeabi-v7a/libskottie.a +0 -0
- package/libs/android/armeabi-v7a/libsksg.a +0 -0
- package/libs/android/x86/libskottie.a +0 -0
- package/libs/android/x86/libsksg.a +0 -0
- package/libs/android/x86_64/libskottie.a +0 -0
- package/libs/android/x86_64/libsksg.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/ios/libskottie.xcframework/Info.plist +42 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/ios/libsksg.xcframework/Info.plist +42 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/ios/libsvg.xcframework/Info.plist +5 -5
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +3 -1
- package/src/dom/nodes/JsiSkDOM.ts +5 -0
- package/src/dom/nodes/LayerNode.ts +35 -0
- package/src/dom/types/NodeType.ts +1 -0
- package/src/dom/types/SkDOM.ts +1 -0
- package/src/renderer/HostComponents.ts +3 -0
- package/src/renderer/components/Group.tsx +16 -3
- package/src/renderer/components/Paint.tsx +7 -1
- package/src/views/SkiaPictureView.tsx +2 -3
- package/src/views/SkiaView.tsx +2 -2
@@ -2,13 +2,14 @@
|
|
2
2
|
|
3
3
|
#include <RNSkLog.h>
|
4
4
|
|
5
|
+
#include "EGL/egl.h"
|
6
|
+
#include "GLES2/gl2.h"
|
5
7
|
#include "android/native_window.h"
|
6
8
|
#include <fbjni/fbjni.h>
|
7
9
|
#include <jni.h>
|
8
|
-
#include "EGL/egl.h"
|
9
|
-
#include "GLES2/gl2.h"
|
10
10
|
|
11
11
|
#include <condition_variable>
|
12
|
+
#include <memory>
|
12
13
|
#include <thread>
|
13
14
|
#include <unordered_map>
|
14
15
|
|
@@ -17,116 +18,112 @@
|
|
17
18
|
|
18
19
|
#include "include/gpu/GrDirectContext.h"
|
19
20
|
#include "include/gpu/gl/GrGLInterface.h"
|
20
|
-
#include <SkColorSpace.h>
|
21
21
|
#include <SkCanvas.h>
|
22
|
-
#include <
|
22
|
+
#include <SkColorSpace.h>
|
23
23
|
#include <SkPicture.h>
|
24
|
+
#include <SkSurface.h>
|
24
25
|
|
25
26
|
#pragma clang diagnostic pop
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
std::atomic<RenderState> _renderState = { RenderState::Initializing };
|
130
|
-
};
|
131
|
-
|
132
|
-
}
|
28
|
+
namespace RNSkia {
|
29
|
+
using DrawingContext = struct {
|
30
|
+
EGLContext glContext;
|
31
|
+
EGLDisplay glDisplay;
|
32
|
+
EGLConfig glConfig;
|
33
|
+
sk_sp<GrDirectContext> skContext;
|
34
|
+
};
|
35
|
+
|
36
|
+
static std::unordered_map<std::thread::id, std::shared_ptr<DrawingContext>>
|
37
|
+
threadContexts;
|
38
|
+
|
39
|
+
enum RenderState : int {
|
40
|
+
Initializing,
|
41
|
+
Rendering,
|
42
|
+
Finishing,
|
43
|
+
Done,
|
44
|
+
};
|
45
|
+
|
46
|
+
class SkiaOpenGLRenderer {
|
47
|
+
public:
|
48
|
+
explicit SkiaOpenGLRenderer(jobject surface);
|
49
|
+
~SkiaOpenGLRenderer();
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Initializes, renders and tears down the render pipeline depending on the
|
53
|
+
* state of the renderer. All OpenGL/Skia context operations are done on a
|
54
|
+
* separate thread which must be the same for all calls to the render method.
|
55
|
+
*
|
56
|
+
* @param callback Render callback
|
57
|
+
* @param width Width of surface to render if there is a picture
|
58
|
+
* @param height Height of surface to render if there is a picture
|
59
|
+
*/
|
60
|
+
void run(const std::function<void(SkCanvas *)> &cb, int width, int height);
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Sets the state to finishing. Next time the renderer will be called it
|
64
|
+
* will tear down and release its resources. It is important that this
|
65
|
+
* is done on the same thread as the other OpenGL context stuff is handled.
|
66
|
+
*
|
67
|
+
* Teardown can be called fom whatever thread we want - but we must ensure
|
68
|
+
* that at least one call to render on the render thread is done after calling
|
69
|
+
* teardown.
|
70
|
+
*/
|
71
|
+
void teardown();
|
72
|
+
|
73
|
+
private:
|
74
|
+
/**
|
75
|
+
* Initializes all required OpenGL and Skia objects
|
76
|
+
* @return True if initialization went well.
|
77
|
+
*/
|
78
|
+
bool ensureInitialised();
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Initializes the static OpenGL context that is shared between
|
82
|
+
* all instances of the renderer.
|
83
|
+
* @return True if initialization went well
|
84
|
+
*/
|
85
|
+
bool initStaticGLContext();
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Initializes the static Skia context that is shared between
|
89
|
+
* all instances of the renderer
|
90
|
+
* @return True if initialization went well
|
91
|
+
*/
|
92
|
+
bool initStaticSkiaContext();
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Inititalizes the OpenGL surface from the native view pointer we
|
96
|
+
* got on initialization. Each renderer has its own OpenGL surface to
|
97
|
+
* render on.
|
98
|
+
* @return True if initialization went well
|
99
|
+
*/
|
100
|
+
bool initGLSurface();
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Ensures that we have a valid Skia surface to draw to. The surface will
|
104
|
+
* be recreated if the width/height change.
|
105
|
+
* @param width Width of the underlying view
|
106
|
+
* @param height Height of the underlying view
|
107
|
+
* @return True if initialization went well
|
108
|
+
*/
|
109
|
+
bool ensureSkiaSurface(int width, int height);
|
110
|
+
|
111
|
+
/**
|
112
|
+
* To be able to use static contexts (and avoid reloading the skia context for
|
113
|
+
* each new view, we track the OpenGL and Skia drawing context per thread.
|
114
|
+
* @return The drawing context for the current thread
|
115
|
+
*/
|
116
|
+
static std::shared_ptr<DrawingContext> getThreadDrawingContext();
|
117
|
+
|
118
|
+
EGLSurface _glSurface = EGL_NO_SURFACE;
|
119
|
+
|
120
|
+
ANativeWindow *_nativeWindow = nullptr;
|
121
|
+
GrBackendRenderTarget _skRenderTarget;
|
122
|
+
sk_sp<SkSurface> _skSurface;
|
123
|
+
|
124
|
+
int _prevWidth = 0;
|
125
|
+
int _prevHeight = 0;
|
126
|
+
|
127
|
+
std::atomic<RenderState> _renderState = {RenderState::Initializing};
|
128
|
+
};
|
129
|
+
} // namespace RNSkia
|
package/cpp/api/JsiSkApi.h
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
|
+
#include <memory>
|
4
|
+
|
3
5
|
#include "RNSkPlatformContext.h"
|
4
6
|
|
5
7
|
#include "JsiSkHostObjects.h"
|
6
8
|
|
7
|
-
#include "
|
9
|
+
#include "JsiSkColor.h"
|
8
10
|
#include "JsiSkColorFilter.h"
|
9
11
|
#include "JsiSkColorFilterFactory.h"
|
12
|
+
#include "JsiSkContourMeasureIter.h"
|
13
|
+
#include "JsiSkDataFactory.h"
|
10
14
|
#include "JsiSkFont.h"
|
11
15
|
#include "JsiSkImage.h"
|
12
16
|
#include "JsiSkImageFactory.h"
|
@@ -16,86 +20,86 @@
|
|
16
20
|
#include "JsiSkMaskFilterFactory.h"
|
17
21
|
#include "JsiSkMatrix.h"
|
18
22
|
#include "JsiSkPaint.h"
|
19
|
-
#include "JsiSkRSXform.h"
|
20
23
|
#include "JsiSkPath.h"
|
21
24
|
#include "JsiSkPathEffect.h"
|
22
25
|
#include "JsiSkPathEffectFactory.h"
|
23
26
|
#include "JsiSkPathFactory.h"
|
27
|
+
#include "JsiSkPictureFactory.h"
|
28
|
+
#include "JsiSkPictureRecorder.h"
|
24
29
|
#include "JsiSkPoint.h"
|
25
30
|
#include "JsiSkRRect.h"
|
31
|
+
#include "JsiSkRSXform.h"
|
26
32
|
#include "JsiSkRect.h"
|
33
|
+
#include "JsiSkRuntimeEffect.h"
|
27
34
|
#include "JsiSkRuntimeEffectFactory.h"
|
28
|
-
#include "
|
29
|
-
#include "JsiSkShaderFactory.h"
|
35
|
+
#include "JsiSkRuntimeShaderBuilder.h"
|
30
36
|
#include "JsiSkSVG.h"
|
31
37
|
#include "JsiSkSVGFactory.h"
|
32
|
-
#include "
|
33
|
-
#include "
|
34
|
-
#include "JsiSkTypefaceFactory.h"
|
35
|
-
#include "JsiSkDataFactory.h"
|
38
|
+
#include "JsiSkShader.h"
|
39
|
+
#include "JsiSkShaderFactory.h"
|
36
40
|
#include "JsiSkSurfaceFactory.h"
|
37
41
|
#include "JsiSkTextBlobFactory.h"
|
38
|
-
#include "
|
39
|
-
#include "
|
40
|
-
#include "
|
41
|
-
#include "JsiSkRuntimeShaderBuilder.h"
|
42
|
-
#include "JsiSkColor.h"
|
42
|
+
#include "JsiSkTypeface.h"
|
43
|
+
#include "JsiSkTypefaceFactory.h"
|
44
|
+
#include "JsiSkVertices.h"
|
43
45
|
|
44
|
-
namespace RNSkia
|
45
|
-
{
|
46
|
+
namespace RNSkia {
|
46
47
|
|
47
|
-
|
48
|
+
namespace jsi = facebook::jsi;
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
/**
|
50
|
+
class JsiSkApi : public JsiSkHostObject {
|
51
|
+
public:
|
52
|
+
/**
|
53
53
|
* Constructs the Skia Api object that can be installed into a runtime
|
54
54
|
* and provide functions for accessing and creating the Skia wrapper objects
|
55
55
|
* @param context Platform context
|
56
56
|
*/
|
57
|
-
|
58
|
-
|
59
|
-
{
|
57
|
+
JsiSkApi(jsi::Runtime &runtime, std::shared_ptr<RNSkPlatformContext> context)
|
58
|
+
: JsiSkHostObject(context) {
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
60
|
+
installFunction("Font", JsiSkFont::createCtor(context));
|
61
|
+
installFunction("Paint", JsiSkPaint::createCtor(context));
|
62
|
+
installFunction("RSXform", JsiSkRSXform::createCtor(context));
|
63
|
+
installFunction("Matrix", JsiSkMatrix::createCtor(context));
|
64
|
+
installFunction("XYWHRect", JsiSkRect::createCtor(context));
|
65
|
+
installFunction("RRectXY", JsiSkRRect::createCtor(context));
|
66
|
+
installFunction("Point", JsiSkPoint::createCtor(context));
|
67
|
+
installFunction("RuntimeShaderBuilder",
|
68
|
+
JsiSkRuntimeShaderBuilder::createCtor(context));
|
69
|
+
installFunction("ContourMeasureIter",
|
70
|
+
JsiSkContourMeasureIter::createCtor(context));
|
71
|
+
installFunction("MakeVertices", JsiSkVertices::createCtor(context));
|
72
|
+
installFunction("PictureRecorder",
|
73
|
+
JsiSkPictureRecorder::createCtor(context));
|
74
|
+
installFunction("Color", JsiSkColor::createCtor());
|
73
75
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
76
|
+
installReadonlyProperty("SVG", std::make_shared<JsiSkSVGFactory>(context));
|
77
|
+
installReadonlyProperty("Image",
|
78
|
+
std::make_shared<JsiSkImageFactory>(context));
|
79
|
+
installReadonlyProperty("Typeface",
|
80
|
+
std::make_shared<JsiSkTypefaceFactory>(context));
|
81
|
+
installReadonlyProperty("Data",
|
82
|
+
std::make_shared<JsiSkDataFactory>(context));
|
83
|
+
installReadonlyProperty("ImageFilter",
|
84
|
+
std::make_shared<JsiSkImageFilterFactory>(context));
|
85
|
+
installReadonlyProperty("PathEffect",
|
86
|
+
std::make_shared<JsiSkPathEffectFactory>(context));
|
87
|
+
installReadonlyProperty("Path",
|
88
|
+
std::make_shared<JsiSkPathFactory>(context));
|
89
|
+
installReadonlyProperty("ColorFilter",
|
90
|
+
std::make_shared<JsiSkColorFilterFactory>(context));
|
91
|
+
installReadonlyProperty("MaskFilter",
|
92
|
+
std::make_shared<JsiSkMaskFilterFactory>(context));
|
93
|
+
installReadonlyProperty(
|
94
|
+
"RuntimeEffect", std::make_shared<JsiSkRuntimeEffectFactory>(context));
|
95
|
+
installReadonlyProperty("Shader",
|
96
|
+
std::make_shared<JsiSkShaderFactory>(context));
|
97
|
+
installReadonlyProperty("TextBlob",
|
98
|
+
std::make_shared<JsiSkTextBlobFactory>(context));
|
99
|
+
installReadonlyProperty("Surface",
|
100
|
+
std::make_shared<JsiSkSurfaceFactory>(context));
|
101
|
+
installReadonlyProperty("Picture",
|
102
|
+
std::make_shared<JsiSkPictureFactory>(context));
|
103
|
+
}
|
104
|
+
};
|
101
105
|
} // namespace RNSkia
|
package/cpp/api/JsiSkCanvas.h
CHANGED
@@ -10,12 +10,12 @@
|
|
10
10
|
#include "JsiSkMatrix.h"
|
11
11
|
#include "JsiSkPaint.h"
|
12
12
|
#include "JsiSkPath.h"
|
13
|
+
#include "JsiSkPicture.h"
|
13
14
|
#include "JsiSkPoint.h"
|
14
15
|
#include "JsiSkRRect.h"
|
15
16
|
#include "JsiSkSVG.h"
|
16
|
-
#include "JsiSkVertices.h"
|
17
17
|
#include "JsiSkTextBlob.h"
|
18
|
-
#include "
|
18
|
+
#include "JsiSkVertices.h"
|
19
19
|
|
20
20
|
#include <jsi/jsi.h>
|
21
21
|
|
@@ -26,15 +26,15 @@
|
|
26
26
|
#include <SkFont.h>
|
27
27
|
#include <SkPaint.h>
|
28
28
|
#include <SkPath.h>
|
29
|
+
#include <SkPicture.h>
|
29
30
|
#include <SkRegion.h>
|
30
31
|
#include <SkSurface.h>
|
31
32
|
#include <SkTypeface.h>
|
32
|
-
#include <SkPicture.h>
|
33
33
|
|
34
34
|
#pragma clang diagnostic pop
|
35
35
|
|
36
36
|
namespace RNSkia {
|
37
|
-
|
37
|
+
namespace jsi = facebook::jsi;
|
38
38
|
|
39
39
|
class JsiSkCanvas : public JsiSkHostObject {
|
40
40
|
public:
|
@@ -97,7 +97,7 @@ public:
|
|
97
97
|
paint = JsiSkPaint::fromValue(runtime, arguments[5]);
|
98
98
|
}
|
99
99
|
}
|
100
|
-
_canvas->drawImage(image, x, y, SkSamplingOptions({
|
100
|
+
_canvas->drawImage(image, x, y, SkSamplingOptions({B, C}), paint.get());
|
101
101
|
return jsi::Value::undefined();
|
102
102
|
}
|
103
103
|
|
@@ -128,7 +128,8 @@ public:
|
|
128
128
|
paint = JsiSkPaint::fromValue(runtime, arguments[4]);
|
129
129
|
}
|
130
130
|
}
|
131
|
-
_canvas->drawImageNine(image.get(), center->round(), *dest, fm,
|
131
|
+
_canvas->drawImageNine(image.get(), center->round(), *dest, fm,
|
132
|
+
paint.get());
|
132
133
|
return jsi::Value::undefined();
|
133
134
|
}
|
134
135
|
|
@@ -144,8 +145,10 @@ public:
|
|
144
145
|
paint = JsiSkPaint::fromValue(runtime, arguments[5]);
|
145
146
|
}
|
146
147
|
}
|
147
|
-
auto constraint =
|
148
|
-
|
148
|
+
auto constraint =
|
149
|
+
SkCanvas::kStrict_SrcRectConstraint; // TODO: get from caller
|
150
|
+
_canvas->drawImageRect(image.get(), *src, *dest, SkSamplingOptions({B, C}),
|
151
|
+
paint.get(), constraint);
|
149
152
|
return jsi::Value::undefined();
|
150
153
|
}
|
151
154
|
|
@@ -162,7 +165,8 @@ public:
|
|
162
165
|
}
|
163
166
|
}
|
164
167
|
auto constraint = SkCanvas::kStrict_SrcRectConstraint;
|
165
|
-
_canvas->drawImageRect(image.get(), *src, *dest, {filter, mipmap},
|
168
|
+
_canvas->drawImageRect(image.get(), *src, *dest, {filter, mipmap},
|
169
|
+
paint.get(), constraint);
|
166
170
|
return jsi::Value::undefined();
|
167
171
|
}
|
168
172
|
|
@@ -250,7 +254,6 @@ public:
|
|
250
254
|
return jsi::Value::undefined();
|
251
255
|
}
|
252
256
|
|
253
|
-
|
254
257
|
JSI_HOST_FUNCTION(drawVertices) {
|
255
258
|
auto vertices = JsiSkVertices::fromValue(runtime, arguments[0]);
|
256
259
|
auto blendMode = (SkBlendMode)arguments[1].getNumber();
|
@@ -278,7 +281,8 @@ public:
|
|
278
281
|
auto colorsSize = jsiColors.size(runtime);
|
279
282
|
colors.reserve(colorsSize);
|
280
283
|
for (int i = 0; i < colorsSize; i++) {
|
281
|
-
SkColor color = JsiSkColor::fromValue(
|
284
|
+
SkColor color = JsiSkColor::fromValue(
|
285
|
+
runtime, jsiColors.getValueAtIndex(runtime, i));
|
282
286
|
colors.push_back(color);
|
283
287
|
}
|
284
288
|
}
|
@@ -289,14 +293,16 @@ public:
|
|
289
293
|
texs.reserve(texsSize);
|
290
294
|
for (int i = 0; i < texsSize; i++) {
|
291
295
|
auto point = JsiSkPoint::fromValue(
|
292
|
-
|
296
|
+
runtime, jsiTexs.getValueAtIndex(runtime, i).asObject(runtime));
|
293
297
|
texs.push_back(*point.get());
|
294
298
|
}
|
295
299
|
}
|
296
300
|
|
297
|
-
auto paint =
|
301
|
+
auto paint =
|
302
|
+
count >= 4 ? JsiSkPaint::fromValue(runtime, arguments[4]) : nullptr;
|
298
303
|
auto blendMode = static_cast<SkBlendMode>(arguments[3].asNumber());
|
299
|
-
_canvas->drawPatch(cubics.data(), colors.data(), texs.data(), blendMode,
|
304
|
+
_canvas->drawPatch(cubics.data(), colors.data(), texs.data(), blendMode,
|
305
|
+
*paint);
|
300
306
|
return jsi::Value::undefined();
|
301
307
|
}
|
302
308
|
|
@@ -347,7 +353,7 @@ public:
|
|
347
353
|
positions.reserve(pointsSize);
|
348
354
|
for (int i = 0; i < pointsSize; i++) {
|
349
355
|
std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
|
350
|
-
|
356
|
+
runtime, jsiPositions.getValueAtIndex(runtime, i).asObject(runtime));
|
351
357
|
positions.push_back(*point.get());
|
352
358
|
}
|
353
359
|
|
@@ -358,14 +364,8 @@ public:
|
|
358
364
|
glyphs.push_back(jsiGlyphs.getValueAtIndex(runtime, i).asNumber());
|
359
365
|
}
|
360
366
|
|
361
|
-
_canvas->drawGlyphs(
|
362
|
-
|
363
|
-
glyphs.data(),
|
364
|
-
positions.data(),
|
365
|
-
origin,
|
366
|
-
*font,
|
367
|
-
*paint
|
368
|
-
);
|
367
|
+
_canvas->drawGlyphs(glyphsSize, glyphs.data(), positions.data(), origin,
|
368
|
+
*font, *paint);
|
369
369
|
|
370
370
|
return jsi::Value::undefined();
|
371
371
|
}
|
@@ -412,10 +412,17 @@ public:
|
|
412
412
|
JSI_HOST_FUNCTION(save) { return jsi::Value(_canvas->save()); }
|
413
413
|
|
414
414
|
JSI_HOST_FUNCTION(saveLayer) {
|
415
|
-
SkPaint *paint = (count >= 1 && !arguments[0].isUndefined())
|
416
|
-
JsiSkPaint::fromValue(runtime, arguments[0]).get()
|
417
|
-
|
418
|
-
|
415
|
+
SkPaint *paint = (count >= 1 && !arguments[0].isUndefined())
|
416
|
+
? JsiSkPaint::fromValue(runtime, arguments[0]).get()
|
417
|
+
: nullptr;
|
418
|
+
SkRect *bounds =
|
419
|
+
count >= 2 && !arguments[1].isNull() && !arguments[1].isUndefined()
|
420
|
+
? JsiSkRect::fromValue(runtime, arguments[1]).get()
|
421
|
+
: nullptr;
|
422
|
+
SkImageFilter *backdrop =
|
423
|
+
count >= 3 && !arguments[2].isNull() && !arguments[2].isUndefined()
|
424
|
+
? JsiSkImageFilter::fromValue(runtime, arguments[2]).get()
|
425
|
+
: nullptr;
|
419
426
|
SkCanvas::SaveLayerFlags flags = count >= 4 ? arguments[3].asNumber() : 0;
|
420
427
|
return jsi::Value(_canvas->saveLayer(
|
421
428
|
SkCanvas::SaveLayerRec(bounds, paint, backdrop, flags)));
|
@@ -477,7 +484,7 @@ public:
|
|
477
484
|
_canvas->concat(*matrix.get());
|
478
485
|
return jsi::Value::undefined();
|
479
486
|
}
|
480
|
-
|
487
|
+
|
481
488
|
JSI_HOST_FUNCTION(drawPicture) {
|
482
489
|
auto picture = JsiSkPicture::fromValue(runtime, arguments[0]);
|
483
490
|
_canvas->drawPicture(picture);
|
@@ -524,10 +531,11 @@ public:
|
|
524
531
|
JSI_EXPORT_FUNC(JsiSkCanvas, concat),
|
525
532
|
JSI_EXPORT_FUNC(JsiSkCanvas, drawPicture))
|
526
533
|
|
527
|
-
JsiSkCanvas(std::shared_ptr<RNSkPlatformContext> context)
|
534
|
+
explicit JsiSkCanvas(std::shared_ptr<RNSkPlatformContext> context)
|
528
535
|
: JsiSkHostObject(std::move(context)) {}
|
529
536
|
|
530
|
-
JsiSkCanvas(std::shared_ptr<RNSkPlatformContext> context, SkCanvas*
|
537
|
+
JsiSkCanvas(std::shared_ptr<RNSkPlatformContext> context, SkCanvas *canvas)
|
538
|
+
: JsiSkCanvas(std::move(context)) {
|
531
539
|
setCanvas(canvas);
|
532
540
|
}
|
533
541
|
|