@shopify/react-native-skia 2.1.0 → 2.2.0
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/CMakeLists.txt +1 -1
- package/android/cpp/rnskia-android/OpenGLWindowContext.h +1 -1
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +1 -1
- package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +1 -1
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +1 -1
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +1 -1
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaPictureViewManager.java +6 -0
- package/apple/MetalContext.h +2 -2
- package/apple/MetalWindowContext.h +2 -2
- package/apple/MetalWindowContext.mm +7 -4
- package/apple/RNSkApplePlatformContext.mm +1 -1
- package/apple/RNSkAppleView.h +7 -1
- package/apple/RNSkMetalCanvasProvider.h +4 -1
- package/apple/RNSkMetalCanvasProvider.mm +9 -4
- package/apple/SkiaPictureView.mm +4 -0
- package/apple/SkiaUIView.h +1 -0
- package/apple/SkiaUIView.mm +9 -0
- package/cpp/api/JsiSkImage.h +1 -1
- package/cpp/api/JsiSkSurface.h +1 -1
- package/cpp/api/JsiSkiaContext.h +1 -1
- package/cpp/api/recorder/Convertor.h +16 -0
- package/cpp/api/recorder/ImageFilters.h +20 -0
- package/cpp/api/recorder/Paint.h +4 -0
- package/cpp/api/recorder/RNRecorder.h +6 -0
- package/cpp/rnskia/{DawnContext.h → RNDawnContext.h} +3 -3
- package/cpp/rnskia/{DawnWindowContext.cpp → RNDawnWindowContext.cpp} +3 -3
- package/cpp/rnskia/{DawnWindowContext.h → RNDawnWindowContext.h} +2 -2
- package/cpp/rnskia/RNSkPlatformContext.h +1 -1
- package/lib/commonjs/dom/types/Drawings.d.ts +4 -1
- package/lib/commonjs/dom/types/Drawings.js.map +1 -1
- package/lib/commonjs/dom/types/NodeType.d.ts +2 -1
- package/lib/commonjs/dom/types/NodeType.js +2 -0
- package/lib/commonjs/dom/types/NodeType.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.d.ts +2 -1
- package/lib/commonjs/renderer/Canvas.js +2 -0
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/__tests__/e2e/ImageFilter.spec.d.ts +1 -0
- package/lib/commonjs/renderer/components/ImageFilter.d.ts +4 -0
- package/lib/commonjs/renderer/components/ImageFilter.js +13 -0
- package/lib/commonjs/renderer/components/ImageFilter.js.map +1 -0
- package/lib/commonjs/renderer/components/index.d.ts +1 -0
- package/lib/commonjs/renderer/components/index.js +11 -0
- package/lib/commonjs/renderer/components/index.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix4.d.ts +4 -0
- package/lib/commonjs/skia/types/Matrix4.js +18 -1
- package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
- package/lib/commonjs/sksg/Elements.d.ts +2 -1
- package/lib/commonjs/sksg/Elements.js.map +1 -1
- package/lib/commonjs/sksg/Node.d.ts +1 -1
- package/lib/commonjs/sksg/Node.js +1 -1
- package/lib/commonjs/sksg/Node.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Player.js +9 -3
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +11 -1
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/module/dom/types/Drawings.d.ts +4 -1
- package/lib/module/dom/types/Drawings.js.map +1 -1
- package/lib/module/dom/types/NodeType.d.ts +2 -1
- package/lib/module/dom/types/NodeType.js +2 -0
- package/lib/module/dom/types/NodeType.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +2 -1
- package/lib/module/renderer/Canvas.js +2 -0
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/__tests__/e2e/ImageFilter.spec.d.ts +1 -0
- package/lib/module/renderer/components/ImageFilter.d.ts +4 -0
- package/lib/module/renderer/components/ImageFilter.js +5 -0
- package/lib/module/renderer/components/ImageFilter.js.map +1 -0
- package/lib/module/renderer/components/index.d.ts +1 -0
- package/lib/module/renderer/components/index.js +1 -0
- package/lib/module/renderer/components/index.js.map +1 -1
- package/lib/module/skia/types/Matrix4.d.ts +4 -0
- package/lib/module/skia/types/Matrix4.js +16 -0
- package/lib/module/skia/types/Matrix4.js.map +1 -1
- package/lib/module/sksg/Elements.d.ts +2 -1
- package/lib/module/sksg/Elements.js.map +1 -1
- package/lib/module/sksg/Node.d.ts +1 -1
- package/lib/module/sksg/Node.js +1 -1
- package/lib/module/sksg/Node.js.map +1 -1
- package/lib/module/sksg/Recorder/Player.js +9 -3
- package/lib/module/sksg/Recorder/Player.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js +11 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/typescript/lib/commonjs/renderer/Canvas.d.ts +2 -1
- package/lib/typescript/lib/commonjs/renderer/components/ImageFilter.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/types/Matrix4.d.ts +1 -0
- package/lib/typescript/lib/module/mock/index.d.ts +2 -0
- package/lib/typescript/lib/module/renderer/Canvas.d.ts +2 -1
- package/lib/typescript/lib/module/renderer/components/ImageFilter.d.ts +2 -0
- package/lib/typescript/lib/module/renderer/components/index.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Matrix4.d.ts +1 -0
- package/lib/typescript/src/dom/types/Drawings.d.ts +4 -1
- package/lib/typescript/src/dom/types/NodeType.d.ts +2 -1
- package/lib/typescript/src/renderer/Canvas.d.ts +2 -1
- package/lib/typescript/src/renderer/__tests__/e2e/ImageFilter.spec.d.ts +1 -0
- package/lib/typescript/src/renderer/components/ImageFilter.d.ts +4 -0
- package/lib/typescript/src/renderer/components/index.d.ts +1 -0
- package/lib/typescript/src/skia/types/Matrix4.d.ts +4 -0
- package/lib/typescript/src/sksg/Elements.d.ts +2 -1
- package/lib/typescript/src/sksg/Node.d.ts +1 -1
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
- package/libs/android/arm64-v8a/libskia.a +0 -0
- package/libs/android/armeabi-v7a/libskia.a +0 -0
- package/libs/android/x86/libskia.a +0 -0
- package/libs/android/x86_64/libskia.a +0 -0
- package/libs/apple/libpathops.xcframework/Info.plist +15 -15
- package/libs/apple/libskia.xcframework/Info.plist +11 -11
- package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/apple/libskottie.xcframework/Info.plist +16 -16
- package/libs/apple/libskparagraph.xcframework/Info.plist +8 -8
- package/libs/apple/libsksg.xcframework/Info.plist +6 -6
- package/libs/apple/libskshaper.xcframework/Info.plist +10 -10
- package/libs/apple/libskunicode_core.xcframework/Info.plist +10 -10
- package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +14 -14
- package/libs/apple/libsvg.xcframework/Info.plist +15 -15
- package/package.json +1 -1
- package/react-native-skia.podspec +5 -5
- package/src/dom/types/Drawings.ts +5 -0
- package/src/dom/types/NodeType.ts +2 -0
- package/src/renderer/Canvas.tsx +3 -0
- package/src/renderer/__tests__/FitBox.spec.tsx +556 -4
- package/src/renderer/__tests__/e2e/ImageFilter.spec.tsx +99 -0
- package/src/renderer/__tests__/e2e/Paint.spec.tsx +18 -0
- package/src/renderer/__tests__/e2e/Skottie.spec.tsx +24 -1
- package/src/renderer/__tests__/setup.tsx +10 -0
- package/src/renderer/components/ImageFilter.tsx +8 -0
- package/src/renderer/components/index.ts +1 -0
- package/src/skia/types/Matrix4.ts +16 -0
- package/src/sksg/Elements.tsx +2 -0
- package/src/sksg/Node.ts +1 -0
- package/src/sksg/Recorder/Player.ts +7 -7
- package/src/sksg/Recorder/commands/ImageFilters.ts +11 -1
- package/src/specs/SkiaPictureViewNativeComponent.ts +1 -0
- /package/cpp/rnskia/{DawnUtils.h → RNDawnUtils.h} +0 -0
- /package/cpp/rnskia/{ImageProvider.h → RNImageProvider.h} +0 -0
- /package/cpp/rnskia/{WindowContext.h → RNWindowContext.h} +0 -0
package/android/CMakeLists.txt
CHANGED
@@ -85,7 +85,7 @@ if(SK_GRAPHITE)
|
|
85
85
|
add_definitions(-DSK_GRAPHITE)
|
86
86
|
set(BACKEND_SOURCES
|
87
87
|
#TODO: is this source needed to be added?
|
88
|
-
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/
|
88
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNDawnWindowContext.cpp"
|
89
89
|
)
|
90
90
|
else()
|
91
91
|
add_definitions(-DSK_GL -DSK_GANESH)
|
@@ -5,6 +5,7 @@ import com.facebook.react.viewmanagers.SkiaPictureViewManagerDelegate;
|
|
5
5
|
import com.facebook.react.viewmanagers.SkiaPictureViewManagerInterface;
|
6
6
|
|
7
7
|
import androidx.annotation.NonNull;
|
8
|
+
import androidx.annotation.Nullable;
|
8
9
|
|
9
10
|
public class SkiaPictureViewManager extends SkiaBaseViewManager<SkiaPictureView> implements SkiaPictureViewManagerInterface<SkiaPictureView> {
|
10
11
|
|
@@ -30,4 +31,9 @@ public class SkiaPictureViewManager extends SkiaBaseViewManager<SkiaPictureView>
|
|
30
31
|
public SkiaPictureView createViewInstance(@NonNull ThemedReactContext reactContext) {
|
31
32
|
return new SkiaPictureView(reactContext);
|
32
33
|
}
|
34
|
+
|
35
|
+
@Override
|
36
|
+
public void setColorSpace(SkiaPictureView view, @Nullable String value) {
|
37
|
+
// nothing to do here at the moment
|
38
|
+
}
|
33
39
|
}
|
package/apple/MetalContext.h
CHANGED
@@ -113,10 +113,10 @@ public:
|
|
113
113
|
}
|
114
114
|
|
115
115
|
std::unique_ptr<RNSkia::WindowContext> MakeWindow(CALayer *window, int width,
|
116
|
-
int height) {
|
116
|
+
int height, bool useP3ColorSpace = true) {
|
117
117
|
auto device = MetalSharedContext::getInstance().getDevice();
|
118
118
|
return std::make_unique<MetalWindowContext>(
|
119
|
-
_directContext.get(), device, _commandQueue, window, width, height);
|
119
|
+
_directContext.get(), device, _commandQueue, window, width, height, useP3ColorSpace);
|
120
120
|
}
|
121
121
|
|
122
122
|
GrDirectContext *getDirectContext() { return _directContext.get(); }
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
#import <MetalKit/MetalKit.h>
|
4
4
|
|
5
|
-
#include "
|
5
|
+
#include "RNWindowContext.h"
|
6
6
|
|
7
7
|
class SkiaMetalContext;
|
8
8
|
|
@@ -10,7 +10,7 @@ class MetalWindowContext : public RNSkia::WindowContext {
|
|
10
10
|
public:
|
11
11
|
MetalWindowContext(GrDirectContext *directContext, id<MTLDevice> device,
|
12
12
|
id<MTLCommandQueue> commandQueue, CALayer *layer,
|
13
|
-
int width, int height);
|
13
|
+
int width, int height, bool useP3ColorSpace = true);
|
14
14
|
~MetalWindowContext() = default;
|
15
15
|
|
16
16
|
sk_sp<SkSurface> getSurface() override;
|
@@ -6,7 +6,8 @@
|
|
6
6
|
MetalWindowContext::MetalWindowContext(GrDirectContext *directContext,
|
7
7
|
id<MTLDevice> device,
|
8
8
|
id<MTLCommandQueue> commandQueue,
|
9
|
-
CALayer *layer, int width, int height
|
9
|
+
CALayer *layer, int width, int height,
|
10
|
+
bool useP3ColorSpace)
|
10
11
|
: _directContext(directContext), _commandQueue(commandQueue) {
|
11
12
|
#pragma clang diagnostic push
|
12
13
|
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
@@ -24,9 +25,11 @@ MetalWindowContext::MetalWindowContext(GrDirectContext *directContext,
|
|
24
25
|
_layer.contentsGravity = kCAGravityBottomLeft;
|
25
26
|
_layer.drawableSize = CGSizeMake(width, height);
|
26
27
|
BOOL supportsWideColor = NO;
|
27
|
-
if (
|
28
|
-
|
29
|
-
|
28
|
+
if (useP3ColorSpace) {
|
29
|
+
if (@available(iOS 10.0, *)) {
|
30
|
+
supportsWideColor =
|
31
|
+
[UIScreen mainScreen].traitCollection.displayGamut == UIDisplayGamutP3;
|
32
|
+
}
|
30
33
|
}
|
31
34
|
if (supportsWideColor) {
|
32
35
|
CGColorSpaceRef colorSpace =
|
package/apple/RNSkAppleView.h
CHANGED
@@ -10,6 +10,7 @@ class RNSkBaseAppleView {
|
|
10
10
|
public:
|
11
11
|
virtual CALayer *getLayer() = 0;
|
12
12
|
virtual void setSize(int width, int height) = 0;
|
13
|
+
virtual void setUseP3ColorSpace(bool useP3ColorSpace) = 0;
|
13
14
|
virtual std::shared_ptr<RNSkia::RNSkView> getDrawView() = 0;
|
14
15
|
};
|
15
16
|
|
@@ -18,7 +19,7 @@ public:
|
|
18
19
|
RNSkAppleView(std::shared_ptr<RNSkia::RNSkPlatformContext> context)
|
19
20
|
: T(context,
|
20
21
|
std::make_shared<RNSkMetalCanvasProvider>(
|
21
|
-
std::bind(&RNSkia::RNSkView::requestRedraw, this), context)) {}
|
22
|
+
std::bind(&RNSkia::RNSkView::requestRedraw, this), context, true)) {}
|
22
23
|
|
23
24
|
CALayer *getLayer() override {
|
24
25
|
return std::static_pointer_cast<RNSkMetalCanvasProvider>(
|
@@ -31,6 +32,11 @@ public:
|
|
31
32
|
->setSize(width, height);
|
32
33
|
}
|
33
34
|
|
35
|
+
void setUseP3ColorSpace(bool useP3ColorSpace) override {
|
36
|
+
std::static_pointer_cast<RNSkMetalCanvasProvider>(this->getCanvasProvider())
|
37
|
+
->setUseP3ColorSpace(useP3ColorSpace);
|
38
|
+
}
|
39
|
+
|
34
40
|
std::shared_ptr<RNSkia::RNSkView> getDrawView() override {
|
35
41
|
return this->shared_from_this();
|
36
42
|
}
|
@@ -16,7 +16,8 @@
|
|
16
16
|
class RNSkMetalCanvasProvider : public RNSkia::RNSkCanvasProvider {
|
17
17
|
public:
|
18
18
|
RNSkMetalCanvasProvider(std::function<void()> requestRedraw,
|
19
|
-
std::shared_ptr<RNSkia::RNSkPlatformContext> context
|
19
|
+
std::shared_ptr<RNSkia::RNSkPlatformContext> context,
|
20
|
+
bool useP3ColorSpace = true);
|
20
21
|
|
21
22
|
~RNSkMetalCanvasProvider();
|
22
23
|
|
@@ -26,6 +27,7 @@ public:
|
|
26
27
|
bool renderToCanvas(const std::function<void(SkCanvas *)> &cb) override;
|
27
28
|
|
28
29
|
void setSize(int width, int height);
|
30
|
+
void setUseP3ColorSpace(bool useP3ColorSpace);
|
29
31
|
CALayer *getLayer();
|
30
32
|
|
31
33
|
private:
|
@@ -35,4 +37,5 @@ private:
|
|
35
37
|
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
36
38
|
CAMetalLayer *_layer;
|
37
39
|
#pragma clang diagnostic pop
|
40
|
+
bool _useP3ColorSpace = true;
|
38
41
|
};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#import "RNSkLog.h"
|
4
4
|
|
5
5
|
#if defined(SK_GRAPHITE)
|
6
|
-
#import "
|
6
|
+
#import "RNDawnContext.h"
|
7
7
|
#else
|
8
8
|
#import "MetalContext.h"
|
9
9
|
#endif
|
@@ -23,8 +23,9 @@
|
|
23
23
|
|
24
24
|
RNSkMetalCanvasProvider::RNSkMetalCanvasProvider(
|
25
25
|
std::function<void()> requestRedraw,
|
26
|
-
std::shared_ptr<RNSkia::RNSkPlatformContext> context
|
27
|
-
|
26
|
+
std::shared_ptr<RNSkia::RNSkPlatformContext> context,
|
27
|
+
bool useP3ColorSpace)
|
28
|
+
: RNSkCanvasProvider(requestRedraw), _context(context), _useP3ColorSpace(useP3ColorSpace) {
|
28
29
|
#pragma clang diagnostic push
|
29
30
|
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
30
31
|
_layer = [CAMetalLayer layer];
|
@@ -100,9 +101,13 @@ void RNSkMetalCanvasProvider::setSize(int width, int height) {
|
|
100
101
|
_ctx = RNSkia::DawnContext::getInstance().MakeWindow((__bridge void *)_layer,
|
101
102
|
w, h);
|
102
103
|
#else
|
103
|
-
_ctx = MetalContext::getInstance().MakeWindow(_layer, w, h);
|
104
|
+
_ctx = MetalContext::getInstance().MakeWindow(_layer, w, h, _useP3ColorSpace);
|
104
105
|
#endif
|
105
106
|
_requestRedraw();
|
106
107
|
}
|
107
108
|
|
108
109
|
CALayer *RNSkMetalCanvasProvider::getLayer() { return _layer; }
|
110
|
+
|
111
|
+
void RNSkMetalCanvasProvider::setUseP3ColorSpace(bool useP3ColorSpace) {
|
112
|
+
_useP3ColorSpace = useP3ColorSpace;
|
113
|
+
}
|
package/apple/SkiaPictureView.mm
CHANGED
@@ -55,6 +55,10 @@ using namespace facebook::react;
|
|
55
55
|
[self setNativeId:nativeId];
|
56
56
|
[self setDebugMode:newProps.debug];
|
57
57
|
[self setOpaque:newProps.opaque];
|
58
|
+
if (newProps.colorSpace == "" || newProps.colorSpace == "srgb") {
|
59
|
+
bool useP3 = false;
|
60
|
+
[self setUseP3ColorSpace:useP3];
|
61
|
+
}
|
58
62
|
}
|
59
63
|
|
60
64
|
@end
|
package/apple/SkiaUIView.h
CHANGED
package/apple/SkiaUIView.mm
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
_factory;
|
17
17
|
bool _debugMode;
|
18
18
|
bool _opaque;
|
19
|
+
bool _useP3ColorSpace;
|
19
20
|
size_t _nativeId;
|
20
21
|
}
|
21
22
|
|
@@ -73,6 +74,7 @@
|
|
73
74
|
_manager->setSkiaView(_nativeId, _impl->getDrawView());
|
74
75
|
}
|
75
76
|
_impl->getDrawView()->setShowDebugOverlays(_debugMode);
|
77
|
+
_impl->setUseP3ColorSpace(_useP3ColorSpace);
|
76
78
|
}
|
77
79
|
}
|
78
80
|
}
|
@@ -163,6 +165,13 @@
|
|
163
165
|
}
|
164
166
|
}
|
165
167
|
|
168
|
+
- (void)setUseP3ColorSpace:(bool)useP3ColorSpace {
|
169
|
+
_useP3ColorSpace = useP3ColorSpace;
|
170
|
+
if (_impl != nullptr) {
|
171
|
+
_impl->setUseP3ColorSpace(_useP3ColorSpace);
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
166
175
|
#pragma mark External API
|
167
176
|
|
168
177
|
- (std::shared_ptr<RNSkBaseAppleView>)impl {
|
package/cpp/api/JsiSkImage.h
CHANGED
package/cpp/api/JsiSkSurface.h
CHANGED
package/cpp/api/JsiSkiaContext.h
CHANGED
@@ -450,6 +450,22 @@ sk_sp<skottie::Animation> getPropertyValue(jsi::Runtime &runtime,
|
|
450
450
|
"Expected JsiSkSkottie object or null for the svg property.");
|
451
451
|
}
|
452
452
|
|
453
|
+
template <>
|
454
|
+
sk_sp<SkImageFilter> getPropertyValue(jsi::Runtime &runtime,
|
455
|
+
const jsi::Value &value) {
|
456
|
+
if (value.isObject() && value.asObject(runtime).isHostObject(runtime)) {
|
457
|
+
auto ptr = std::dynamic_pointer_cast<JsiSkImageFilter>(
|
458
|
+
value.asObject(runtime).asHostObject(runtime));
|
459
|
+
if (ptr != nullptr) {
|
460
|
+
return ptr->getObject();
|
461
|
+
}
|
462
|
+
} else if (value.isNull()) {
|
463
|
+
return nullptr;
|
464
|
+
}
|
465
|
+
throw std::runtime_error(
|
466
|
+
"Expected JsiSkImageFilter object or null for the imageFilter property.");
|
467
|
+
}
|
468
|
+
|
453
469
|
template <>
|
454
470
|
sk_sp<SkPicture> getPropertyValue(jsi::Runtime &runtime,
|
455
471
|
const jsi::Value &value) {
|
@@ -289,4 +289,24 @@ public:
|
|
289
289
|
}
|
290
290
|
};
|
291
291
|
|
292
|
+
struct ImageFilterCmdProps {
|
293
|
+
sk_sp<SkImageFilter> filter;
|
294
|
+
};
|
295
|
+
|
296
|
+
class ImageFilterCmd : public Command {
|
297
|
+
private:
|
298
|
+
ImageFilterCmdProps props;
|
299
|
+
|
300
|
+
public:
|
301
|
+
ImageFilterCmd(jsi::Runtime &runtime, const jsi::Object &object,
|
302
|
+
Variables &variables)
|
303
|
+
: Command(CommandType::PushImageFilter, "skImageFilter") {
|
304
|
+
convertProperty(runtime, object, "filter", props.filter, variables);
|
305
|
+
}
|
306
|
+
|
307
|
+
void pushImageFilter(DrawingCtx *ctx) {
|
308
|
+
ctx->imageFilters.push_back(props.filter);
|
309
|
+
}
|
310
|
+
};
|
311
|
+
|
292
312
|
} // namespace RNSkia
|
package/cpp/api/recorder/Paint.h
CHANGED
@@ -142,6 +142,9 @@ public:
|
|
142
142
|
} else if (nodeType == "skRuntimeShaderImageFilter") {
|
143
143
|
commands.push_back(std::make_unique<RuntimeShaderImageFilterCmd>(
|
144
144
|
runtime, props, variables));
|
145
|
+
} else if (nodeType == "skImageFilter") {
|
146
|
+
commands.push_back(
|
147
|
+
std::make_unique<ImageFilterCmd>(runtime, props, variables));
|
145
148
|
}
|
146
149
|
}
|
147
150
|
|
@@ -419,6 +422,9 @@ public:
|
|
419
422
|
auto *runtimeShaderCmd =
|
420
423
|
static_cast<RuntimeShaderImageFilterCmd *>(cmd.get());
|
421
424
|
runtimeShaderCmd->pushImageFilter(ctx);
|
425
|
+
} else if (nodeType == "skImageFilter") {
|
426
|
+
auto *imageFilterCmd = static_cast<ImageFilterCmd *>(cmd.get());
|
427
|
+
imageFilterCmd->pushImageFilter(ctx);
|
422
428
|
} else {
|
423
429
|
throw std::runtime_error("Invalid image filter type: " + nodeType);
|
424
430
|
}
|
@@ -3,9 +3,9 @@
|
|
3
3
|
#include <memory>
|
4
4
|
#include <mutex>
|
5
5
|
|
6
|
-
#include "
|
7
|
-
#include "
|
8
|
-
#include "
|
6
|
+
#include "RNDawnWindowContext.h"
|
7
|
+
#include "RNImageProvider.h"
|
8
|
+
#include "RNDawnUtils.h"
|
9
9
|
|
10
10
|
#include "include/core/SkData.h"
|
11
11
|
#include "include/gpu/graphite/BackendTexture.h"
|
@@ -1,6 +1,6 @@
|
|
1
|
-
#include "
|
1
|
+
#include "RNDawnWindowContext.h"
|
2
2
|
|
3
|
-
#include "
|
3
|
+
#include "RNDawnContext.h"
|
4
4
|
|
5
5
|
namespace RNSkia {
|
6
6
|
|
@@ -16,4 +16,4 @@ void DawnWindowContext::present() {
|
|
16
16
|
_surface.Present();
|
17
17
|
}
|
18
18
|
|
19
|
-
} // namespace RNSkia
|
19
|
+
} // namespace RNSkia
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { FillType, SkImage, StrokeOpts, Vector, Color, SkPoint, BlendMode, PointMode, VertexMode, SkFont, SkRRect, SkTextBlob, SkPicture, SkSVG, SkPaint, SkRect, SkRSXform, SkColor, SamplingOptions, SkSkottieAnimation } from "../../skia/types";
|
1
|
+
import type { FillType, SkImage, StrokeOpts, Vector, Color, SkPoint, BlendMode, PointMode, VertexMode, SkFont, SkRRect, SkTextBlob, SkPicture, SkSVG, SkPaint, SkRect, SkRSXform, SkColor, SamplingOptions, SkSkottieAnimation, SkImageFilter } from "../../skia/types";
|
2
2
|
import type { CircleDef, Fit, GroupProps, PathDef, RectDef, RRectDef, SkEnum } from "./Common";
|
3
3
|
export interface DrawingNodeProps extends GroupProps {
|
4
4
|
paint?: SkPaint;
|
@@ -115,3 +115,6 @@ export interface BoxShadowProps {
|
|
115
115
|
color?: Color;
|
116
116
|
inner?: boolean;
|
117
117
|
}
|
118
|
+
export interface ImageFilterProps extends GroupProps {
|
119
|
+
filter: SkImageFilter;
|
120
|
+
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["Drawings.ts"],"sourcesContent":["import type {\n FillType,\n SkImage,\n StrokeOpts,\n Vector,\n Color,\n SkPoint,\n BlendMode,\n PointMode,\n VertexMode,\n SkFont,\n SkRRect,\n SkTextBlob,\n SkPicture,\n SkSVG,\n SkPaint,\n SkRect,\n SkRSXform,\n SkColor,\n SamplingOptions,\n SkSkottieAnimation,\n} from \"../../skia/types\";\n\nimport type {\n CircleDef,\n Fit,\n GroupProps,\n PathDef,\n RectDef,\n RRectDef,\n SkEnum,\n} from \"./Common\";\n\nexport interface DrawingNodeProps extends GroupProps {\n paint?: SkPaint;\n}\n\nexport type ImageProps = DrawingNodeProps &\n RectDef & {\n fit?: Fit;\n image: SkImage | null;\n sampling?: SamplingOptions;\n };\n\nexport type CircleProps = CircleDef & DrawingNodeProps;\n\nexport interface PathProps extends DrawingNodeProps {\n path: PathDef;\n start: number;\n end: number;\n stroke?: StrokeOpts;\n fillType?: SkEnum<typeof FillType>;\n}\n\nexport interface LineProps extends DrawingNodeProps {\n p1: Vector;\n p2: Vector;\n}\n\nexport type OvalProps = RectDef & DrawingNodeProps;\n\nexport type RectProps = RectDef & DrawingNodeProps;\n\nexport type RoundedRectProps = RRectDef & DrawingNodeProps;\n\nexport interface AtlasProps extends DrawingNodeProps {\n image: SkImage | null;\n sprites: SkRect[];\n transforms: SkRSXform[];\n colors?: SkColor[];\n sampling?: SamplingOptions;\n}\n\nexport interface CubicBezierHandle {\n pos: Vector;\n c1: Vector;\n c2: Vector;\n}\n\nexport interface PatchProps extends DrawingNodeProps {\n colors?: Color[];\n patch: [\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle\n ];\n texture?: readonly [SkPoint, SkPoint, SkPoint, SkPoint];\n blendMode?: SkEnum<typeof BlendMode>;\n}\n\nexport interface VerticesProps extends DrawingNodeProps {\n colors?: string[];\n vertices: SkPoint[];\n textures?: SkPoint[];\n mode: SkEnum<typeof VertexMode>;\n blendMode?: SkEnum<typeof BlendMode>;\n indices?: number[];\n}\n\nexport interface ImageSVGProps extends DrawingNodeProps {\n svg: SkSVG | null;\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n rect?: SkRect;\n}\n\nexport interface SkottieProps extends DrawingNodeProps {\n animation: SkSkottieAnimation;\n frame: number;\n}\n\nexport interface PictureProps extends DrawingNodeProps {\n picture: SkPicture;\n}\n\nexport interface PointsProps extends DrawingNodeProps {\n points: SkPoint[];\n mode: SkEnum<typeof PointMode>;\n}\n\nexport interface DiffRectProps extends DrawingNodeProps {\n inner: SkRRect;\n outer: SkRRect;\n}\n\nexport interface TextProps extends DrawingNodeProps {\n font: SkFont | null;\n text: string;\n x: number;\n y: number;\n}\n\nexport interface TextPathProps extends DrawingNodeProps {\n font: SkFont | null;\n text: string;\n path: PathDef;\n initialOffset: number;\n}\n\nexport interface TextBlobProps extends DrawingNodeProps {\n blob: SkTextBlob;\n x: number;\n y: number;\n}\n\nexport interface Glyph {\n id: number;\n pos: SkPoint;\n}\n\nexport interface GlyphsProps extends DrawingNodeProps {\n font: SkFont | null;\n x: number;\n y: number;\n glyphs: Glyph[];\n}\n\nexport interface BoxProps extends DrawingNodeProps {\n box: SkRRect | SkRect;\n}\n\nexport interface BoxShadowProps {\n dx?: number;\n dy?: number;\n spread?: number;\n blur: number;\n color?: Color;\n inner?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
1
|
+
{"version":3,"names":[],"sources":["Drawings.ts"],"sourcesContent":["import type {\n FillType,\n SkImage,\n StrokeOpts,\n Vector,\n Color,\n SkPoint,\n BlendMode,\n PointMode,\n VertexMode,\n SkFont,\n SkRRect,\n SkTextBlob,\n SkPicture,\n SkSVG,\n SkPaint,\n SkRect,\n SkRSXform,\n SkColor,\n SamplingOptions,\n SkSkottieAnimation,\n SkImageFilter,\n} from \"../../skia/types\";\n\nimport type {\n CircleDef,\n Fit,\n GroupProps,\n PathDef,\n RectDef,\n RRectDef,\n SkEnum,\n} from \"./Common\";\n\nexport interface DrawingNodeProps extends GroupProps {\n paint?: SkPaint;\n}\n\nexport type ImageProps = DrawingNodeProps &\n RectDef & {\n fit?: Fit;\n image: SkImage | null;\n sampling?: SamplingOptions;\n };\n\nexport type CircleProps = CircleDef & DrawingNodeProps;\n\nexport interface PathProps extends DrawingNodeProps {\n path: PathDef;\n start: number;\n end: number;\n stroke?: StrokeOpts;\n fillType?: SkEnum<typeof FillType>;\n}\n\nexport interface LineProps extends DrawingNodeProps {\n p1: Vector;\n p2: Vector;\n}\n\nexport type OvalProps = RectDef & DrawingNodeProps;\n\nexport type RectProps = RectDef & DrawingNodeProps;\n\nexport type RoundedRectProps = RRectDef & DrawingNodeProps;\n\nexport interface AtlasProps extends DrawingNodeProps {\n image: SkImage | null;\n sprites: SkRect[];\n transforms: SkRSXform[];\n colors?: SkColor[];\n sampling?: SamplingOptions;\n}\n\nexport interface CubicBezierHandle {\n pos: Vector;\n c1: Vector;\n c2: Vector;\n}\n\nexport interface PatchProps extends DrawingNodeProps {\n colors?: Color[];\n patch: [\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle\n ];\n texture?: readonly [SkPoint, SkPoint, SkPoint, SkPoint];\n blendMode?: SkEnum<typeof BlendMode>;\n}\n\nexport interface VerticesProps extends DrawingNodeProps {\n colors?: string[];\n vertices: SkPoint[];\n textures?: SkPoint[];\n mode: SkEnum<typeof VertexMode>;\n blendMode?: SkEnum<typeof BlendMode>;\n indices?: number[];\n}\n\nexport interface ImageSVGProps extends DrawingNodeProps {\n svg: SkSVG | null;\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n rect?: SkRect;\n}\n\nexport interface SkottieProps extends DrawingNodeProps {\n animation: SkSkottieAnimation;\n frame: number;\n}\n\nexport interface PictureProps extends DrawingNodeProps {\n picture: SkPicture;\n}\n\nexport interface PointsProps extends DrawingNodeProps {\n points: SkPoint[];\n mode: SkEnum<typeof PointMode>;\n}\n\nexport interface DiffRectProps extends DrawingNodeProps {\n inner: SkRRect;\n outer: SkRRect;\n}\n\nexport interface TextProps extends DrawingNodeProps {\n font: SkFont | null;\n text: string;\n x: number;\n y: number;\n}\n\nexport interface TextPathProps extends DrawingNodeProps {\n font: SkFont | null;\n text: string;\n path: PathDef;\n initialOffset: number;\n}\n\nexport interface TextBlobProps extends DrawingNodeProps {\n blob: SkTextBlob;\n x: number;\n y: number;\n}\n\nexport interface Glyph {\n id: number;\n pos: SkPoint;\n}\n\nexport interface GlyphsProps extends DrawingNodeProps {\n font: SkFont | null;\n x: number;\n y: number;\n glyphs: Glyph[];\n}\n\nexport interface BoxProps extends DrawingNodeProps {\n box: SkRRect | SkRect;\n}\n\nexport interface BoxShadowProps {\n dx?: number;\n dy?: number;\n spread?: number;\n blur: number;\n color?: Color;\n inner?: boolean;\n}\n\nexport interface ImageFilterProps extends GroupProps {\n filter: SkImageFilter;\n}\n"],"mappings":"","ignoreList":[]}
|
@@ -72,6 +72,8 @@ let NodeType = exports.NodeType = /*#__PURE__*/function (NodeType) {
|
|
72
72
|
NodeType["Paragraph"] = "skParagraph";
|
73
73
|
// Skottie
|
74
74
|
NodeType["Skottie"] = "skSkottie";
|
75
|
+
// ImageFilter
|
76
|
+
NodeType["ImageFilter"] = "skImageFilter";
|
75
77
|
return NodeType;
|
76
78
|
}({});
|
77
79
|
//# sourceMappingURL=NodeType.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NodeType","exports"],"sources":["NodeType.ts"],"sourcesContent":["export const enum NodeType {\n // Shaders\n Layer = \"skLayer\",\n Shader = \"skShader\",\n ImageShader = \"skImageShader\",\n ColorShader = \"skColorShader\",\n Turbulence = \"skTurbulence\",\n FractalNoise = \"skFractalNoise\",\n LinearGradient = \"skLinearGradient\",\n RadialGradient = \"skRadialGradient\",\n SweepGradient = \"skSweepGradient\",\n TwoPointConicalGradient = \"skTwoPointConicalGradient\",\n\n // Mask Filters\n BlurMaskFilter = \"skBlurMaskFilter\",\n\n // Path Effects\n DiscretePathEffect = \"skDiscretePathEffect\",\n DashPathEffect = \"skDashPathEffect\",\n Path1DPathEffect = \"skPath1DPathEffect\",\n Path2DPathEffect = \"skPath2DPathEffect\",\n CornerPathEffect = \"skCornerPathEffect\",\n SumPathEffect = \"skSumPathEffect\",\n Line2DPathEffect = \"skLine2DPathEffect\",\n\n // Color Filters\n MatrixColorFilter = \"skMatrixColorFilter\",\n BlendColorFilter = \"skBlendColorFilter\",\n LinearToSRGBGammaColorFilter = \"skLinearToSRGBGammaColorFilter\",\n SRGBToLinearGammaColorFilter = \"skSRGBToLinearGammaColorFilter\",\n LumaColorFilter = \"skLumaColorFilter\",\n LerpColorFilter = \"skLerpColorFilter\",\n\n // Image Filters\n OffsetImageFilter = \"skOffsetImageFilter\",\n DisplacementMapImageFilter = \"skDisplacementMapImageFilter\",\n BlurImageFilter = \"skBlurImageFilter\",\n DropShadowImageFilter = \"skDropShadowImageFilter\",\n MorphologyImageFilter = \"skMorphologyImageFilter\",\n BlendImageFilter = \"skBlendImageFilter\",\n RuntimeShaderImageFilter = \"skRuntimeShaderImageFilter\",\n\n // Mixed\n Blend = \"skBlend\",\n BackdropFilter = \"skBackdropFilter\",\n Box = \"skBox\",\n BoxShadow = \"skBoxShadow\",\n\n // Drawings\n Group = \"skGroup\",\n Paint = \"skPaint\",\n Circle = \"skCircle\",\n Fill = \"skFill\",\n Image = \"skImage\",\n Points = \"skPoints\",\n Path = \"skPath\",\n Rect = \"skRect\",\n RRect = \"skRRect\",\n Oval = \"skOval\",\n Line = \"skLine\",\n Patch = \"skPatch\",\n Vertices = \"skVertices\",\n DiffRect = \"skDiffRect\",\n Text = \"skText\",\n TextPath = \"skTextPath\",\n TextBlob = \"skTextBlob\",\n Glyphs = \"skGlyphs\",\n Picture = \"skPicture\",\n ImageSVG = \"skImageSVG\",\n Atlas = \"skAtlas\",\n\n // Paragraph\n Paragraph = \"skParagraph\",\n // Skottie\n Skottie = \"skSkottie\",\n}\n"],"mappings":";;;;;;IAAkBA,QAAQ,GAAAC,OAAA,CAAAD,QAAA,0BAARA,QAAQ;EACxB;EADgBA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAaxB;EAbgBA,QAAQ;EAgBxB;EAhBgBA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAyBxB;EAzBgBA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAiCxB;EAjCgBA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EA0CxB;EA1CgBA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAgDxB;EAhDgBA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAuExB;EAvEgBA,QAAQ;EAyExB;EAzEgBA,QAAQ;EAAA,OAARA,QAAQ;AAAA","ignoreList":[]}
|
1
|
+
{"version":3,"names":["NodeType","exports"],"sources":["NodeType.ts"],"sourcesContent":["export const enum NodeType {\n // Shaders\n Layer = \"skLayer\",\n Shader = \"skShader\",\n ImageShader = \"skImageShader\",\n ColorShader = \"skColorShader\",\n Turbulence = \"skTurbulence\",\n FractalNoise = \"skFractalNoise\",\n LinearGradient = \"skLinearGradient\",\n RadialGradient = \"skRadialGradient\",\n SweepGradient = \"skSweepGradient\",\n TwoPointConicalGradient = \"skTwoPointConicalGradient\",\n\n // Mask Filters\n BlurMaskFilter = \"skBlurMaskFilter\",\n\n // Path Effects\n DiscretePathEffect = \"skDiscretePathEffect\",\n DashPathEffect = \"skDashPathEffect\",\n Path1DPathEffect = \"skPath1DPathEffect\",\n Path2DPathEffect = \"skPath2DPathEffect\",\n CornerPathEffect = \"skCornerPathEffect\",\n SumPathEffect = \"skSumPathEffect\",\n Line2DPathEffect = \"skLine2DPathEffect\",\n\n // Color Filters\n MatrixColorFilter = \"skMatrixColorFilter\",\n BlendColorFilter = \"skBlendColorFilter\",\n LinearToSRGBGammaColorFilter = \"skLinearToSRGBGammaColorFilter\",\n SRGBToLinearGammaColorFilter = \"skSRGBToLinearGammaColorFilter\",\n LumaColorFilter = \"skLumaColorFilter\",\n LerpColorFilter = \"skLerpColorFilter\",\n\n // Image Filters\n OffsetImageFilter = \"skOffsetImageFilter\",\n DisplacementMapImageFilter = \"skDisplacementMapImageFilter\",\n BlurImageFilter = \"skBlurImageFilter\",\n DropShadowImageFilter = \"skDropShadowImageFilter\",\n MorphologyImageFilter = \"skMorphologyImageFilter\",\n BlendImageFilter = \"skBlendImageFilter\",\n RuntimeShaderImageFilter = \"skRuntimeShaderImageFilter\",\n\n // Mixed\n Blend = \"skBlend\",\n BackdropFilter = \"skBackdropFilter\",\n Box = \"skBox\",\n BoxShadow = \"skBoxShadow\",\n\n // Drawings\n Group = \"skGroup\",\n Paint = \"skPaint\",\n Circle = \"skCircle\",\n Fill = \"skFill\",\n Image = \"skImage\",\n Points = \"skPoints\",\n Path = \"skPath\",\n Rect = \"skRect\",\n RRect = \"skRRect\",\n Oval = \"skOval\",\n Line = \"skLine\",\n Patch = \"skPatch\",\n Vertices = \"skVertices\",\n DiffRect = \"skDiffRect\",\n Text = \"skText\",\n TextPath = \"skTextPath\",\n TextBlob = \"skTextBlob\",\n Glyphs = \"skGlyphs\",\n Picture = \"skPicture\",\n ImageSVG = \"skImageSVG\",\n Atlas = \"skAtlas\",\n\n // Paragraph\n Paragraph = \"skParagraph\",\n // Skottie\n Skottie = \"skSkottie\",\n // ImageFilter\n ImageFilter = \"skImageFilter\",\n}\n"],"mappings":";;;;;;IAAkBA,QAAQ,GAAAC,OAAA,CAAAD,QAAA,0BAARA,QAAQ;EACxB;EADgBA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAaxB;EAbgBA,QAAQ;EAgBxB;EAhBgBA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAyBxB;EAzBgBA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAiCxB;EAjCgBA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EA0CxB;EA1CgBA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAgDxB;EAhDgBA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAuExB;EAvEgBA,QAAQ;EAyExB;EAzEgBA,QAAQ;EA2ExB;EA3EgBA,QAAQ;EAAA,OAARA,QAAQ;AAAA","ignoreList":[]}
|
@@ -14,6 +14,7 @@ export interface CanvasProps extends ViewProps {
|
|
14
14
|
debug?: boolean;
|
15
15
|
opaque?: boolean;
|
16
16
|
onSize?: SharedValue<SkSize>;
|
17
|
+
colorSpace?: "p3" | "srgb";
|
17
18
|
ref?: React.Ref<CanvasRef>;
|
18
19
|
}
|
19
|
-
export declare const Canvas: ({ debug, opaque, children, onSize, onLayout: _onLayout, ref, ...viewProps }: CanvasProps) => React.JSX.Element;
|
20
|
+
export declare const Canvas: ({ debug, opaque, children, onSize, onLayout: _onLayout, colorSpace, ref, ...viewProps }: CanvasProps) => React.JSX.Element;
|
@@ -42,6 +42,7 @@ const Canvas = ({
|
|
42
42
|
children,
|
43
43
|
onSize,
|
44
44
|
onLayout: _onLayout,
|
45
|
+
colorSpace = "p3",
|
45
46
|
ref,
|
46
47
|
...viewProps
|
47
48
|
}) => {
|
@@ -84,6 +85,7 @@ const Canvas = ({
|
|
84
85
|
nativeID: `${nativeId}`,
|
85
86
|
debug: debug,
|
86
87
|
opaque: opaque,
|
88
|
+
colorSpace: colorSpace,
|
87
89
|
onLayout: onLayout
|
88
90
|
}, viewProps));
|
89
91
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_interopRequireDefault","_Reconciler","_skia","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","value","Canvas","debug","opaque","children","onSize","_onLayout","ref","viewProps","nativeId","useMemo","SkiaViewNativeId","current","root","SkiaSGRoot","Skia","useLayoutEffect","render","useEffect","unmount","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type { LayoutChangeEvent, ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\nimport type { SkiaBaseViewProps } from \"../views\";\n\nexport interface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\n//const NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\n// TODO: no need to go through the JS thread for this\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport interface CanvasProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n ref?: React.Ref<CanvasRef>;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n onLayout: _onLayout,\n ref,\n ...viewProps\n}: CanvasProps) => {\n const onLayout = useOnSizeEvent(onSize, _onLayout);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);\n\n // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n } as CanvasRef)\n );\n return (\n <SkiaPictureViewNativeComponent\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n onLayout={onLayout}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAWA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,+BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAA+B,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAE,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBAAAe,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAe,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAd,CAAA,EAAAe,CAAA,UAAAG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CAAC;AACH,CAAC;
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_interopRequireDefault","_Reconciler","_skia","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","value","Canvas","debug","opaque","children","onSize","_onLayout","colorSpace","ref","viewProps","nativeId","useMemo","SkiaViewNativeId","current","root","SkiaSGRoot","Skia","useLayoutEffect","render","useEffect","unmount","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type { LayoutChangeEvent, ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\nimport type { SkiaBaseViewProps } from \"../views\";\n\nexport interface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\n//const NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\n// TODO: no need to go through the JS thread for this\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport interface CanvasProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n colorSpace?: \"p3\" | \"srgb\";\n ref?: React.Ref<CanvasRef>;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n onLayout: _onLayout,\n colorSpace = \"p3\",\n ref,\n ...viewProps\n}: CanvasProps) => {\n const onLayout = useOnSizeEvent(onSize, _onLayout);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);\n\n // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n } as CanvasRef)\n );\n return (\n <SkiaPictureViewNativeComponent\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n colorSpace={colorSpace}\n onLayout={onLayout}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAWA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,+BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAA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AAA,GAAAA,MAAA","ignoreList":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.ImageFilter = void 0;
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
9
|
+
const ImageFilter = props => {
|
10
|
+
return /*#__PURE__*/_react.default.createElement("skImageFilter", props);
|
11
|
+
};
|
12
|
+
exports.ImageFilter = ImageFilter;
|
13
|
+
//# sourceMappingURL=ImageFilter.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","e","__esModule","default","ImageFilter","props","createElement","exports"],"sources":["ImageFilter.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { ImageFilterProps } from \"../../dom/types\";\nimport type { SkiaProps } from \"../processors\";\n\nexport const ImageFilter = (props: SkiaProps<ImageFilterProps>) => {\n return <skImageFilter {...props} />;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAKnB,MAAMG,WAAW,GAAIC,KAAkC,IAAK;EACjE,oBAAOP,MAAA,CAAAK,OAAA,CAAAG,aAAA,kBAAmBD,KAAQ,CAAC;AACrC,CAAC;AAACE,OAAA,CAAAH,WAAA,GAAAA,WAAA","ignoreList":[]}
|