@shopify/react-native-skia 0.1.160 → 0.1.163
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +9 -9
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +2 -0
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +2 -2
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +2 -2
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +5 -5
- package/cpp/api/JsiSkCanvas.h +8 -8
- package/cpp/api/JsiSkColor.h +1 -1
- package/cpp/api/JsiSkColorFilter.h +1 -1
- package/cpp/api/JsiSkColorFilterFactory.h +2 -2
- package/cpp/api/JsiSkContourMeasure.h +1 -1
- package/cpp/api/JsiSkContourMeasureIter.h +2 -2
- package/cpp/api/JsiSkData.h +2 -2
- package/cpp/api/JsiSkDataFactory.h +1 -1
- package/cpp/api/JsiSkFont.h +2 -2
- package/cpp/api/JsiSkImage.h +3 -3
- package/cpp/api/JsiSkImageFilter.h +1 -1
- package/cpp/api/JsiSkImageFilterFactory.h +1 -1
- package/cpp/api/JsiSkImageInfo.h +1 -1
- package/cpp/api/JsiSkMaskFilter.h +1 -1
- package/cpp/api/JsiSkMaskFilterFactory.h +1 -1
- package/cpp/api/JsiSkMatrix.h +1 -1
- package/cpp/api/JsiSkPaint.h +1 -1
- package/cpp/api/JsiSkPath.h +15 -15
- package/cpp/api/JsiSkPathEffect.h +1 -1
- package/cpp/api/JsiSkPathEffectFactory.h +4 -4
- package/cpp/api/JsiSkPathFactory.h +2 -2
- package/cpp/api/JsiSkPicture.h +1 -1
- package/cpp/api/JsiSkPictureFactory.h +2 -2
- package/cpp/api/JsiSkPictureRecorder.h +2 -2
- package/cpp/api/JsiSkPoint.h +1 -1
- package/cpp/api/JsiSkRRect.h +1 -1
- package/cpp/api/JsiSkRSXform.h +1 -1
- package/cpp/api/JsiSkRect.h +1 -1
- package/cpp/api/JsiSkRuntimeEffect.h +1 -1
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +1 -1
- package/cpp/api/JsiSkSVGFactory.h +1 -1
- package/cpp/api/JsiSkShader.h +2 -2
- package/cpp/api/JsiSkShaderFactory.h +3 -3
- package/cpp/api/JsiSkSurface.h +1 -1
- package/cpp/api/JsiSkSurfaceFactory.h +2 -2
- package/cpp/api/JsiSkTextBlob.h +1 -1
- package/cpp/api/JsiSkTextBlobFactory.h +1 -1
- package/cpp/api/JsiSkTypeface.h +2 -2
- package/cpp/api/JsiSkVertices.h +1 -1
- package/cpp/rnskia/RNSkDomView.cpp +1 -2
- package/cpp/rnskia/RNSkJsView.h +3 -3
- package/cpp/rnskia/RNSkPictureView.h +3 -3
- package/cpp/rnskia/RNSkPlatformContext.h +5 -3
- package/cpp/rnskia/RNSkView.h +2 -2
- package/cpp/rnskia/dom/nodes/JsiBlendNode.h +6 -7
- package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiPathNode.h +10 -8
- package/cpp/rnskia/dom/props/BlendModeProp.h +2 -2
- package/cpp/rnskia/dom/props/PaintProps.h +5 -1
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +8 -7
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +2 -1
- package/ios/RNSkia-iOS/SkiaDrawViewManager.mm +4 -4
- package/ios/RNSkia-iOS/SkiaManager.mm +5 -5
- package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +3 -3
- package/ios/RNSkia-iOS/SkiaUIView.mm +10 -10
- package/lib/commonjs/renderer/Canvas.js +2 -11
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/Container.js +2 -1
- package/lib/commonjs/renderer/Container.js.map +1 -1
- package/lib/commonjs/renderer/components/Mask.js +11 -25
- package/lib/commonjs/renderer/components/Mask.js.map +1 -1
- package/lib/commonjs/renderer/index.js +0 -13
- package/lib/commonjs/renderer/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +3 -10
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/Container.js +2 -1
- package/lib/module/renderer/Container.js.map +1 -1
- package/lib/module/renderer/components/Mask.js +9 -21
- package/lib/module/renderer/components/Mask.js.map +1 -1
- package/lib/module/renderer/index.js +0 -1
- package/lib/module/renderer/index.js.map +1 -1
- package/lib/typescript/src/renderer/Container.d.ts +1 -1
- package/lib/typescript/src/renderer/index.d.ts +0 -1
- package/libs/android/arm64-v8a/libskottie.a +0 -0
- package/libs/android/arm64-v8a/libskshaper.a +0 -0
- package/libs/android/armeabi-v7a/libskottie.a +0 -0
- package/libs/android/armeabi-v7a/libskshaper.a +0 -0
- package/libs/android/x86/libskottie.a +0 -0
- package/libs/android/x86/libskshaper.a +0 -0
- package/libs/android/x86_64/libskottie.a +0 -0
- package/libs/android/x86_64/libskshaper.a +0 -0
- package/libs/ios/libskia.xcframework/Info.plist +5 -5
- 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/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/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/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 +9 -4
- package/react-native-skia.podspec +2 -2
- package/src/renderer/Canvas.tsx +2 -12
- package/src/renderer/Container.tsx +1 -1
- package/src/renderer/components/Mask.tsx +11 -20
- package/src/renderer/index.ts +0 -1
- package/lib/commonjs/renderer/useCanvas.js +0 -32
- package/lib/commonjs/renderer/useCanvas.js.map +0 -1
- package/lib/module/renderer/useCanvas.js +0 -15
- package/lib/module/renderer/useCanvas.js.map +0 -1
- package/lib/typescript/src/renderer/useCanvas.d.ts +0 -9
- package/libs/android/arm64-v8a/libskparagraph.a +0 -0
- package/libs/android/arm64-v8a/libskunicode.a +0 -0
- package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
- package/libs/android/armeabi-v7a/libskunicode.a +0 -0
- package/libs/android/x86/libskparagraph.a +0 -0
- package/libs/android/x86/libskunicode.a +0 -0
- package/libs/android/x86_64/libskparagraph.a +0 -0
- package/libs/android/x86_64/libskunicode.a +0 -0
- package/libs/ios/libskparagraph.xcframework/Info.plist +0 -42
- package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/ios/libskunicode.xcframework/Info.plist +0 -42
- package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
- package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
- package/src/renderer/useCanvas.ts +0 -21
@@ -21,9 +21,9 @@
|
|
21
21
|
#pragma clang diagnostic push
|
22
22
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
23
23
|
|
24
|
-
#include
|
25
|
-
#include
|
26
|
-
#include
|
24
|
+
#include "SkBBHFactory.h"
|
25
|
+
#include "SkCanvas.h"
|
26
|
+
#include "SkPictureRecorder.h"
|
27
27
|
|
28
28
|
#pragma clang diagnostic pop
|
29
29
|
|
@@ -14,7 +14,7 @@
|
|
14
14
|
#pragma clang diagnostic push
|
15
15
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
16
16
|
|
17
|
-
#include
|
17
|
+
#include "SkStream.h"
|
18
18
|
|
19
19
|
#pragma clang diagnostic pop
|
20
20
|
|
@@ -188,8 +188,10 @@ public:
|
|
188
188
|
}
|
189
189
|
}
|
190
190
|
|
191
|
-
|
192
|
-
|
191
|
+
// default implementation does nothing, so it can be called from virtual
|
192
|
+
// destructor.
|
193
|
+
virtual void startDrawLoop() {}
|
194
|
+
virtual void stopDrawLoop() {}
|
193
195
|
|
194
196
|
private:
|
195
197
|
float _pixelDensity;
|
package/cpp/rnskia/RNSkView.h
CHANGED
@@ -41,19 +41,18 @@ protected:
|
|
41
41
|
auto maybeImageFilter =
|
42
42
|
std::dynamic_pointer_cast<JsiBaseImageFilterNode>(child);
|
43
43
|
|
44
|
-
if (
|
44
|
+
if (maybeShader) {
|
45
45
|
sk_sp<SkShader> outer = maybeShader->getCurrent();
|
46
46
|
if (innerShader != nullptr) {
|
47
|
-
innerShader = SkShaders::Blend(blendMode,
|
47
|
+
innerShader = SkShaders::Blend(blendMode, outer, innerShader);
|
48
48
|
} else {
|
49
49
|
innerShader = outer;
|
50
50
|
}
|
51
|
-
|
52
|
-
} else {
|
51
|
+
} else if (maybeImageFilter) {
|
53
52
|
sk_sp<SkImageFilter> outer = maybeImageFilter->getCurrent();
|
54
|
-
if (
|
55
|
-
innerImageFilter = SkImageFilters::Blend(
|
56
|
-
|
53
|
+
if (outer != nullptr) {
|
54
|
+
innerImageFilter = SkImageFilters::Blend(blendMode, outer,
|
55
|
+
innerImageFilter, nullptr);
|
57
56
|
} else {
|
58
57
|
innerImageFilter = outer;
|
59
58
|
}
|
@@ -44,7 +44,7 @@ protected:
|
|
44
44
|
if (paint->getColorFilter() != nullptr &&
|
45
45
|
paint->getColorFilter() != getCurrent().get()) {
|
46
46
|
paint->setColorFilter(
|
47
|
-
SkColorFilters::Compose(paint->refColorFilter()
|
47
|
+
SkColorFilters::Compose(ColorFilter, paint->refColorFilter()));
|
48
48
|
} else {
|
49
49
|
paint->setColorFilter(ColorFilter);
|
50
50
|
}
|
@@ -43,25 +43,27 @@ protected:
|
|
43
43
|
_strokeOptsProp->isSet() &&
|
44
44
|
_strokeOptsProp->value().getType() == PropType::Object;
|
45
45
|
|
46
|
-
auto willMutatePath =
|
47
|
-
|
46
|
+
auto willMutatePath = hasStartOffset == true || hasEndOffset == true ||
|
47
|
+
hasFillStyle == true || hasStrokeOptions == true;
|
48
48
|
|
49
49
|
if (willMutatePath) {
|
50
50
|
// We'll trim the path
|
51
51
|
SkPath filteredPath(*_pathProp->getDerivedValue());
|
52
|
-
auto
|
53
|
-
|
54
|
-
|
52
|
+
auto start =
|
53
|
+
_startProp->isSet() ? _startProp->value().getAsNumber() : 0.0;
|
54
|
+
auto end = _endProp->isSet() ? _endProp->value().getAsNumber() : 1.0;
|
55
|
+
auto pe =
|
56
|
+
SkTrimPathEffect::Make(start, end, SkTrimPathEffect::Mode::kNormal);
|
55
57
|
|
56
58
|
if (pe != nullptr) {
|
57
59
|
SkStrokeRec rec(SkStrokeRec::InitStyle::kHairline_InitStyle);
|
58
|
-
if (!pe->filterPath(
|
59
|
-
&rec, nullptr)) {
|
60
|
+
if (!pe->filterPath(&filteredPath, filteredPath, &rec, nullptr)) {
|
60
61
|
throw std::runtime_error(
|
61
62
|
"Failed trimming path with parameters start: " +
|
62
63
|
std::to_string(_startProp->value().getAsNumber()) +
|
63
64
|
", end: " + std::to_string(_endProp->value().getAsNumber()));
|
64
65
|
}
|
66
|
+
filteredPath.swap(filteredPath);
|
65
67
|
_path = std::make_shared<SkPath>(filteredPath);
|
66
68
|
} else if (hasStartOffset || hasEndOffset) {
|
67
69
|
throw std::runtime_error(
|
@@ -69,7 +71,7 @@ protected:
|
|
69
71
|
std::to_string(_startProp->value().getAsNumber()) +
|
70
72
|
", end: " + std::to_string(_endProp->value().getAsNumber()));
|
71
73
|
} else {
|
72
|
-
_path = std::make_shared<SkPath>(
|
74
|
+
_path = std::make_shared<SkPath>(filteredPath);
|
73
75
|
}
|
74
76
|
|
75
77
|
// Set fill style
|
@@ -43,11 +43,11 @@ private:
|
|
43
43
|
return SkBlendMode::kDstOver;
|
44
44
|
} else if (value == "srcIn") {
|
45
45
|
return SkBlendMode::kSrcIn;
|
46
|
-
} else if (value == "
|
46
|
+
} else if (value == "dstIn") {
|
47
47
|
return SkBlendMode::kDstIn;
|
48
48
|
} else if (value == "srcOut") {
|
49
49
|
return SkBlendMode::kSrcOut;
|
50
|
-
} else if (value == "
|
50
|
+
} else if (value == "dstOut") {
|
51
51
|
return SkBlendMode::kDstOut;
|
52
52
|
} else if (value == "srcATop") {
|
53
53
|
return SkBlendMode::kSrcATop;
|
@@ -93,7 +93,8 @@ public:
|
|
93
93
|
// Opacity
|
94
94
|
if (_opacity->isChanged() || context->isChanged()) {
|
95
95
|
if (_opacity->isSet()) {
|
96
|
-
context->setOpacity(
|
96
|
+
context->setOpacity(context->getOpacity() *
|
97
|
+
_opacity->value().getAsNumber());
|
97
98
|
} else {
|
98
99
|
context->clearOpacity();
|
99
100
|
}
|
@@ -105,6 +106,9 @@ public:
|
|
105
106
|
paint->setShader(nullptr);
|
106
107
|
paint->setColor(*_color->getDerivedValue());
|
107
108
|
paint->setAlphaf(context->getOpacity() * paint->getColor4f().fA);
|
109
|
+
} else if (context->isChanged()) {
|
110
|
+
auto paint = context->getMutablePaint();
|
111
|
+
paint->setAlphaf(context->getOpacity());
|
108
112
|
}
|
109
113
|
|
110
114
|
// Style
|
@@ -4,9 +4,9 @@
|
|
4
4
|
#pragma clang diagnostic push
|
5
5
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
6
6
|
|
7
|
-
#import
|
8
|
-
#import
|
9
|
-
#import
|
7
|
+
#import "SkColorSpace.h"
|
8
|
+
#import "SkSurface.h"
|
9
|
+
#import "SkCanvas.h"
|
10
10
|
|
11
11
|
#import <include/gpu/GrDirectContext.h>
|
12
12
|
|
@@ -33,9 +33,9 @@ RNSkCanvasProvider(requestRedraw),
|
|
33
33
|
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
34
34
|
_layer = [CAMetalLayer layer];
|
35
35
|
#pragma clang diagnostic pop
|
36
|
-
|
36
|
+
|
37
37
|
auto device = MTLCreateSystemDefaultDevice();
|
38
|
-
|
38
|
+
|
39
39
|
_layer.framebufferOnly = NO;
|
40
40
|
_layer.device = device;
|
41
41
|
_layer.opaque = false;
|
@@ -74,12 +74,13 @@ void RNSkMetalCanvasProvider::renderToCanvas(const std::function<void(SkCanvas*)
|
|
74
74
|
renderContext->commandQueue = id<MTLCommandQueue>(CFRetain((GrMTLHandle)[device newCommandQueue]));
|
75
75
|
renderContext->skContext = GrDirectContext::MakeMetal((__bridge void*)device, (__bridge void*)renderContext->commandQueue);
|
76
76
|
}
|
77
|
-
|
77
|
+
|
78
78
|
// Wrap in auto release pool since we want the system to clean up after rendering
|
79
79
|
// and not wait until later - we've seen some example of memory usage growing very
|
80
80
|
// fast in the simulator without this.
|
81
81
|
@autoreleasepool
|
82
82
|
{
|
83
|
+
|
83
84
|
GrMTLHandle drawableHandle;
|
84
85
|
auto skSurface = SkSurface::MakeFromCAMetalLayer(renderContext->skContext.get(),
|
85
86
|
(__bridge GrMTLHandle)_layer,
|
@@ -114,7 +115,7 @@ void RNSkMetalCanvasProvider::setSize(int width, int height) {
|
|
114
115
|
_layer.frame = CGRectMake(0, 0, width, height);
|
115
116
|
_layer.drawableSize = CGSizeMake(width * _context->getPixelDensity(),
|
116
117
|
height* _context->getPixelDensity());
|
117
|
-
|
118
|
+
|
118
119
|
_requestRedraw();
|
119
120
|
}
|
120
121
|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
#pragma clang diagnostic push
|
13
13
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
14
14
|
|
15
|
-
#include
|
15
|
+
#include "SkStream.h"
|
16
16
|
|
17
17
|
#pragma clang diagnostic pop
|
18
18
|
|
@@ -48,6 +48,7 @@ public:
|
|
48
48
|
~RNSkiOSPlatformContext() {
|
49
49
|
CFNotificationCenterRemoveEveryObserver(
|
50
50
|
CFNotificationCenterGetLocalCenter(), this);
|
51
|
+
stopDrawLoop();
|
51
52
|
}
|
52
53
|
|
53
54
|
void startDrawLoop() override;
|
@@ -1,13 +1,13 @@
|
|
1
|
-
#include
|
1
|
+
#include "SkiaDrawViewManager.h"
|
2
2
|
#include <React/RCTBridge+Private.h>
|
3
3
|
|
4
4
|
#include <RNSkPlatformContext.h>
|
5
5
|
#include <RNSkJsView.h>
|
6
6
|
#include <RNSkIOSView.h>
|
7
7
|
|
8
|
-
#include
|
8
|
+
#include "SkiaManager.h"
|
9
9
|
#include <RNSkiaModule.h>
|
10
|
-
#include
|
10
|
+
#include "SkiaUIView.h"
|
11
11
|
|
12
12
|
|
13
13
|
|
@@ -24,7 +24,7 @@ RCT_EXPORT_MODULE(SkiaDrawView)
|
|
24
24
|
RCT_CUSTOM_VIEW_PROPERTY(nativeID, NSNumber, SkiaUIView) {
|
25
25
|
// Get parameter
|
26
26
|
int nativeId = [[RCTConvert NSString:json] intValue];
|
27
|
-
[(SkiaUIView*)view setNativeId:nativeId];
|
27
|
+
[(SkiaUIView*)view setNativeId:nativeId];
|
28
28
|
}
|
29
29
|
|
30
30
|
RCT_CUSTOM_VIEW_PROPERTY(mode, NSString, SkiaUIView) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#import
|
1
|
+
#import "SkiaManager.h"
|
2
2
|
|
3
3
|
#import <Foundation/Foundation.h>
|
4
4
|
|
@@ -32,16 +32,16 @@
|
|
32
32
|
if (self) {
|
33
33
|
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
|
34
34
|
if (cxxBridge.runtime) {
|
35
|
-
|
35
|
+
|
36
36
|
auto callInvoker = bridge.jsCallInvoker;
|
37
37
|
facebook::jsi::Runtime* jsRuntime = (facebook::jsi::Runtime*)cxxBridge.runtime;
|
38
|
-
|
38
|
+
|
39
39
|
// Create platform context
|
40
40
|
_platformContext = std::make_shared<RNSkia::RNSkiOSPlatformContext>(jsRuntime, callInvoker);
|
41
|
-
|
41
|
+
|
42
42
|
// Create the RNSkiaManager (cross platform)
|
43
43
|
_skManager = std::make_shared<RNSkia::RNSkManager>(jsRuntime, callInvoker, _platformContext);
|
44
|
-
|
44
|
+
|
45
45
|
}
|
46
46
|
}
|
47
47
|
return self;
|
@@ -1,14 +1,14 @@
|
|
1
1
|
|
2
|
-
#include
|
2
|
+
#include "SkiaPictureViewManager.h"
|
3
3
|
#include <React/RCTBridge+Private.h>
|
4
4
|
|
5
5
|
#include <RNSkPlatformContext.h>
|
6
6
|
#include <RNSkPictureView.h>
|
7
7
|
#include <RNSkIOSView.h>
|
8
8
|
|
9
|
-
#include
|
9
|
+
#include "SkiaManager.h"
|
10
10
|
#include <RNSkiaModule.h>
|
11
|
-
#include
|
11
|
+
#include "SkiaUIView.h"
|
12
12
|
|
13
13
|
|
14
14
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#import <React/RCTBridge.h>
|
2
2
|
|
3
|
-
#import
|
3
|
+
#import "SkiaUIView.h"
|
4
4
|
|
5
5
|
#include <utility>
|
6
6
|
#include <vector>
|
@@ -29,7 +29,7 @@
|
|
29
29
|
_debugMode = false;
|
30
30
|
_drawingMode = RNSkia::RNSkDrawingMode::Default;
|
31
31
|
_factory = factory;
|
32
|
-
|
32
|
+
|
33
33
|
// Listen to notifications about module invalidation
|
34
34
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
35
35
|
selector:@selector(willInvalidateModules)
|
@@ -51,11 +51,11 @@
|
|
51
51
|
// Remove implementation view when the parent view is not set
|
52
52
|
if(_impl != nullptr) {
|
53
53
|
[_impl->getLayer() removeFromSuperlayer];
|
54
|
-
|
54
|
+
|
55
55
|
if(_nativeId != 0 && _manager != nullptr) {
|
56
56
|
_manager->setSkiaView(_nativeId, nullptr);
|
57
57
|
}
|
58
|
-
|
58
|
+
|
59
59
|
_impl = nullptr;
|
60
60
|
}
|
61
61
|
} else {
|
@@ -79,9 +79,9 @@
|
|
79
79
|
if(_manager != nullptr && _nativeId != 0) {
|
80
80
|
_manager->unregisterSkiaView(_nativeId);
|
81
81
|
}
|
82
|
-
|
82
|
+
|
83
83
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:RCTBridgeWillInvalidateModulesNotification object:nil];
|
84
|
-
|
84
|
+
|
85
85
|
assert(_impl == nullptr);
|
86
86
|
}
|
87
87
|
|
@@ -98,7 +98,7 @@
|
|
98
98
|
|
99
99
|
-(void) setDrawingMode:(std::string) mode {
|
100
100
|
_drawingMode = mode.compare("continuous") == 0 ? RNSkia::RNSkDrawingMode::Continuous : RNSkia::RNSkDrawingMode::Default;
|
101
|
-
|
101
|
+
|
102
102
|
if(_impl != nullptr) {
|
103
103
|
_impl->getDrawView()->setDrawingMode(_drawingMode);
|
104
104
|
}
|
@@ -113,7 +113,7 @@
|
|
113
113
|
|
114
114
|
- (void) setNativeId:(size_t) nativeId {
|
115
115
|
_nativeId = nativeId;
|
116
|
-
|
116
|
+
|
117
117
|
if(_impl != nullptr) {
|
118
118
|
_manager->registerSkiaView(nativeId, _impl->getDrawView());
|
119
119
|
}
|
@@ -147,7 +147,7 @@
|
|
147
147
|
RNSkia::RNSkTouchInfo nextTouch;
|
148
148
|
nextTouch.x = position.x;
|
149
149
|
nextTouch.y = position.y;
|
150
|
-
nextTouch.force = [touch force];
|
150
|
+
nextTouch.force = [touch force];
|
151
151
|
nextTouch.id = [touch hash];
|
152
152
|
auto phase = [touch phase];
|
153
153
|
switch(phase) {
|
@@ -167,7 +167,7 @@
|
|
167
167
|
nextTouch.type = RNSkia::RNSkTouchInfo::TouchType::Active;
|
168
168
|
break;
|
169
169
|
}
|
170
|
-
|
170
|
+
|
171
171
|
nextTouches.push_back(nextTouch);
|
172
172
|
}
|
173
173
|
if(_impl != nullptr) {
|
@@ -9,8 +9,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
10
10
|
var _reactReconciler = _interopRequireDefault(require("react-reconciler"));
|
11
11
|
|
12
|
-
var _reactNative = require("react-native");
|
13
|
-
|
14
12
|
var _views = require("../views");
|
15
13
|
|
16
14
|
var _Skia = require("../skia/Skia");
|
@@ -21,8 +19,6 @@ var _Container = require("./Container");
|
|
21
19
|
|
22
20
|
var _DependencyManager = require("./DependencyManager");
|
23
21
|
|
24
|
-
var _useCanvas = require("./useCanvas");
|
25
|
-
|
26
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
27
23
|
|
28
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
@@ -64,11 +60,10 @@ const Canvas = /*#__PURE__*/(0, _react.forwardRef)((_ref, forwardedRef) => {
|
|
64
60
|
} = _ref;
|
65
61
|
const innerRef = useCanvasRef();
|
66
62
|
const ref = useCombinedRefs(forwardedRef, innerRef);
|
67
|
-
const [, setTick] = (0, _react.useState)(0);
|
68
63
|
const redraw = (0, _react.useCallback)(() => {
|
69
64
|
var _innerRef$current;
|
70
65
|
|
71
|
-
|
66
|
+
(_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.redraw();
|
72
67
|
}, [innerRef]);
|
73
68
|
const registerValues = (0, _react.useCallback)(values => {
|
74
69
|
if (ref.current === null) {
|
@@ -83,11 +78,7 @@ const Canvas = /*#__PURE__*/(0, _react.forwardRef)((_ref, forwardedRef) => {
|
|
83
78
|
const root = (0, _react.useMemo)(() => skiaReconciler.createContainer(container, 0, null, true, null, "", console.error, null), [container]); // Render effect
|
84
79
|
|
85
80
|
(0, _react.useEffect)(() => {
|
86
|
-
render(
|
87
|
-
value: {
|
88
|
-
Skia: _Skia.Skia
|
89
|
-
}
|
90
|
-
}, children), root, container);
|
81
|
+
render(children, root, container);
|
91
82
|
}, [children, root, redraw, container]);
|
92
83
|
(0, _react.useEffect)(() => {
|
93
84
|
return () => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["skiaReconciler","ReactReconciler","skHostConfig","injectIntoDevTools","bundleType","version","rendererPackageName","render","element","root","container","updateContainer","hostDebug","depMgr","update","useCanvasRef","useRef","createDependencyManager","registerValues","global","SkiaDomApi","DependencyManager","Canvas","forwardRef","forwardedRef","children","style","debug","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","
|
1
|
+
{"version":3,"names":["skiaReconciler","ReactReconciler","skHostConfig","injectIntoDevTools","bundleType","version","rendererPackageName","render","element","root","container","updateContainer","hostDebug","depMgr","update","useCanvasRef","useRef","createDependencyManager","registerValues","global","SkiaDomApi","DependencyManager","Canvas","forwardRef","forwardedRef","children","style","debug","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","redraw","useCallback","current","values","Error","useMemo","Container","Skia","createContainer","console","error","useEffect","remove","refs","targetRef","React","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n ComponentProps,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport { SkiaDomView } from \"../views\";\nimport type { TouchHandler } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { SkiaValue } from \"../values\";\n\nimport { debug as hostDebug, skHostConfig } from \"./HostConfig\";\n// import { debugTree } from \"./nodes\";\nimport { Container } from \"./Container\";\nimport { DependencyManager } from \"./DependencyManager\";\n\nexport const skiaReconciler = ReactReconciler(skHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nconst render = (element: ReactNode, root: OpaqueRoot, container: Container) => {\n skiaReconciler.updateContainer(element, root, null, () => {\n hostDebug(\"updateContainer\");\n container.depMgr.update();\n });\n};\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nconst createDependencyManager = (\n registerValues: (values: Array<SkiaValue<unknown>>) => () => void\n) =>\n global.SkiaDomApi && global.SkiaDomApi.DependencyManager\n ? global.SkiaDomApi.DependencyManager(registerValues)\n : new DependencyManager(registerValues);\n\nexport interface CanvasProps extends ComponentProps<typeof SkiaDomView> {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize, ...props },\n forwardedRef\n ) => {\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current === null) {\n throw new Error(\"Canvas ref is not set\");\n }\n return ref.current.registerValues(values);\n },\n [ref]\n );\n\n const container = useMemo(() => {\n return new Container(\n Skia,\n createDependencyManager(registerValues),\n redraw\n );\n }, [redraw, registerValues]);\n\n const root = useMemo(\n () =>\n skiaReconciler.createContainer(\n container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n ),\n [container]\n );\n\n // Render effect\n useEffect(() => {\n render(children, root, container);\n }, [children, root, redraw, container]);\n\n useEffect(() => {\n return () => {\n skiaReconciler.updateContainer(null, root, null, () => {\n container.depMgr.remove();\n });\n };\n }, [container, root]);\n\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={container.root}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n);\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":"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"}
|
@@ -10,7 +10,8 @@ var _nodes = require("../dom/nodes");
|
|
10
10
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
11
11
|
|
12
12
|
class Container {
|
13
|
-
constructor(Skia, depMgr
|
13
|
+
constructor(Skia, depMgr) {
|
14
|
+
let redraw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
|
14
15
|
this.depMgr = depMgr;
|
15
16
|
this.redraw = redraw;
|
16
17
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Container","constructor","Skia","depMgr","redraw","Sk","JsiSkDOM","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nimport type { DependencyManager } from \"./DependencyManager\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public depMgr: DependencyManager,\n public redraw: () => void\n ) {\n this.Sk = new JsiSkDOM({ Skia, depMgr });\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;;;;;;AAAA;;;;AAWO,MAAMA,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,EAEFC,MAFE,
|
1
|
+
{"version":3,"names":["Container","constructor","Skia","depMgr","redraw","Sk","JsiSkDOM","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nimport type { DependencyManager } from \"./DependencyManager\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public depMgr: DependencyManager,\n public redraw: () => void = () => {}\n ) {\n this.Sk = new JsiSkDOM({ Skia, depMgr });\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;;;;;;AAAA;;;;AAWO,MAAMA,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,EAEFC,MAFE,EAIT;IAAA,IADOC,MACP,uEAD4B,MAAM,CAAE,CACpC;IAAA,KAFOD,MAEP,GAFOA,MAEP;IAAA,KADOC,MACP,GADOA,MACP;;IAAA;;IAAA;;IACA,KAAKC,EAAL,GAAU,IAAIC,eAAJ,CAAa;MAAEJ,IAAF;MAAQC;IAAR,CAAb,CAAV;IACA,KAAKI,KAAL,GAAa,KAAKF,EAAL,CAAQG,KAAR,EAAb;EACD;;EAEDC,IAAI,CAACC,GAAD,EAAsB;IACxB,KAAKH,KAAL,CAAWI,MAAX,CAAkBD,GAAlB;EACD;;EAEO,IAAJE,IAAI,GAAG;IACT,OAAO,KAAKL,KAAZ;EACD;;AAlBoB"}
|
@@ -5,17 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.Mask = void 0;
|
7
7
|
|
8
|
-
var _react =
|
9
|
-
|
10
|
-
var _types = require("../../skia/types");
|
11
|
-
|
12
|
-
var _useCanvas = require("../useCanvas");
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
13
9
|
|
14
10
|
var _Group = require("./Group");
|
15
11
|
|
16
|
-
|
12
|
+
var _LumaColorFilter = require("./colorFilters/LumaColorFilter");
|
13
|
+
|
14
|
+
var _Paint = require("./Paint");
|
17
15
|
|
18
|
-
function
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
17
|
|
20
18
|
const Mask = _ref => {
|
21
19
|
let {
|
@@ -24,28 +22,16 @@ const Mask = _ref => {
|
|
24
22
|
mode,
|
25
23
|
clip
|
26
24
|
} = _ref;
|
27
|
-
const Skia = (0, _useCanvas.useSkiaPrivate)();
|
28
|
-
const maskPaint = (0, _react.useMemo)(() => {
|
29
|
-
const paint = Skia.Paint();
|
30
|
-
paint.setBlendMode(_types.BlendMode.Src);
|
31
|
-
|
32
|
-
if (mode === "luminance") {
|
33
|
-
paint.setColorFilter(Skia.ColorFilter.MakeLumaColorFilter());
|
34
|
-
}
|
35
|
-
|
36
|
-
return paint;
|
37
|
-
}, [Skia, mode]);
|
38
|
-
const clippingPaint = (0, _react.useMemo)(() => {
|
39
|
-
const paint = Skia.Paint();
|
40
|
-
paint.setBlendMode(_types.BlendMode.DstIn);
|
41
|
-
return paint;
|
42
|
-
}, [Skia]);
|
43
25
|
return /*#__PURE__*/_react.default.createElement(_Group.Group, {
|
44
26
|
layer: true
|
45
27
|
}, /*#__PURE__*/_react.default.createElement(_Group.Group, {
|
46
|
-
layer:
|
28
|
+
layer: /*#__PURE__*/_react.default.createElement(_Paint.Paint, {
|
29
|
+
blendMode: "src"
|
30
|
+
}, mode === "luminance" && /*#__PURE__*/_react.default.createElement(_LumaColorFilter.LumaColorFilter, null))
|
47
31
|
}, mask, clip && /*#__PURE__*/_react.default.createElement(_Group.Group, {
|
48
|
-
layer:
|
32
|
+
layer: /*#__PURE__*/_react.default.createElement(_Paint.Paint, {
|
33
|
+
blendMode: "dstIn"
|
34
|
+
})
|
49
35
|
}, children)), /*#__PURE__*/_react.default.createElement(_Group.Group, {
|
50
36
|
blendMode: "srcIn"
|
51
37
|
}, children));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Mask","children","mask","mode","clip","
|
1
|
+
{"version":3,"names":["Mask","children","mask","mode","clip","defaultProps"],"sources":["Mask.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport React from \"react\";\n\nimport { Group } from \"./Group\";\nimport { LumaColorFilter } from \"./colorFilters/LumaColorFilter\";\nimport { Paint } from \"./Paint\";\n\ninterface MaskProps {\n mode: \"luminance\" | \"alpha\";\n clip: boolean;\n mask: ReactNode | ReactNode[];\n children: ReactNode | ReactNode[];\n}\n\nexport const Mask = ({ children, mask, mode, clip }: MaskProps) => {\n return (\n <Group layer>\n <Group\n layer={\n <Paint blendMode=\"src\">\n {mode === \"luminance\" && <LumaColorFilter />}\n </Paint>\n }\n >\n {mask}\n {clip && <Group layer={<Paint blendMode=\"dstIn\" />}>{children}</Group>}\n </Group>\n <Group blendMode=\"srcIn\">{children}</Group>\n </Group>\n );\n};\n\nMask.defaultProps = {\n mode: \"alpha\",\n clip: true,\n};\n"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;AACA;;;;AASO,MAAMA,IAAI,GAAG,QAA+C;EAAA,IAA9C;IAAEC,QAAF;IAAYC,IAAZ;IAAkBC,IAAlB;IAAwBC;EAAxB,CAA8C;EACjE,oBACE,6BAAC,YAAD;IAAO,KAAK;EAAZ,gBACE,6BAAC,YAAD;IACE,KAAK,eACH,6BAAC,YAAD;MAAO,SAAS,EAAC;IAAjB,GACGD,IAAI,KAAK,WAAT,iBAAwB,6BAAC,gCAAD,OAD3B;EAFJ,GAOGD,IAPH,EAQGE,IAAI,iBAAI,6BAAC,YAAD;IAAO,KAAK,eAAE,6BAAC,YAAD;MAAO,SAAS,EAAC;IAAjB;EAAd,GAA4CH,QAA5C,CARX,CADF,eAWE,6BAAC,YAAD;IAAO,SAAS,EAAC;EAAjB,GAA0BA,QAA1B,CAXF,CADF;AAeD,CAhBM;;;AAkBPD,IAAI,CAACK,YAAL,GAAoB;EAClBF,IAAI,EAAE,OADY;EAElBC,IAAI,EAAE;AAFY,CAApB"}
|
@@ -42,17 +42,4 @@ Object.keys(_DependencyManager).forEach(function (key) {
|
|
42
42
|
}
|
43
43
|
});
|
44
44
|
});
|
45
|
-
|
46
|
-
var _useCanvas = require("./useCanvas");
|
47
|
-
|
48
|
-
Object.keys(_useCanvas).forEach(function (key) {
|
49
|
-
if (key === "default" || key === "__esModule") return;
|
50
|
-
if (key in exports && exports[key] === _useCanvas[key]) return;
|
51
|
-
Object.defineProperty(exports, key, {
|
52
|
-
enumerable: true,
|
53
|
-
get: function () {
|
54
|
-
return _useCanvas[key];
|
55
|
-
}
|
56
|
-
});
|
57
|
-
});
|
58
45
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./useContextBridge\";\nexport * from \"./DependencyManager\";\
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./useContextBridge\";\nexport * from \"./DependencyManager\";\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"}
|
@@ -1,15 +1,13 @@
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
2
|
|
3
|
-
import React, { useEffect, useCallback, useMemo, forwardRef, useRef
|
3
|
+
import React, { useEffect, useCallback, useMemo, forwardRef, useRef } from "react";
|
4
4
|
import ReactReconciler from "react-reconciler";
|
5
|
-
import { Platform } from "react-native";
|
6
5
|
import { SkiaDomView } from "../views";
|
7
6
|
import { Skia } from "../skia/Skia";
|
8
7
|
import { debug as hostDebug, skHostConfig } from "./HostConfig"; // import { debugTree } from "./nodes";
|
9
8
|
|
10
9
|
import { Container } from "./Container";
|
11
10
|
import { DependencyManager } from "./DependencyManager";
|
12
|
-
import { CanvasProvider } from "./useCanvas";
|
13
11
|
export const skiaReconciler = ReactReconciler(skHostConfig);
|
14
12
|
skiaReconciler.injectIntoDevTools({
|
15
13
|
bundleType: 1,
|
@@ -40,11 +38,10 @@ export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
|
|
40
38
|
} = _ref;
|
41
39
|
const innerRef = useCanvasRef();
|
42
40
|
const ref = useCombinedRefs(forwardedRef, innerRef);
|
43
|
-
const [, setTick] = useState(0);
|
44
41
|
const redraw = useCallback(() => {
|
45
42
|
var _innerRef$current;
|
46
43
|
|
47
|
-
|
44
|
+
(_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.redraw();
|
48
45
|
}, [innerRef]);
|
49
46
|
const registerValues = useCallback(values => {
|
50
47
|
if (ref.current === null) {
|
@@ -59,11 +56,7 @@ export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
|
|
59
56
|
const root = useMemo(() => skiaReconciler.createContainer(container, 0, null, true, null, "", console.error, null), [container]); // Render effect
|
60
57
|
|
61
58
|
useEffect(() => {
|
62
|
-
render(
|
63
|
-
value: {
|
64
|
-
Skia
|
65
|
-
}
|
66
|
-
}, children), root, container);
|
59
|
+
render(children, root, container);
|
67
60
|
}, [children, root, redraw, container]);
|
68
61
|
useEffect(() => {
|
69
62
|
return () => {
|