@shopify/react-native-skia 2.13.0 → 2.14.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 +2 -0
- package/android/cpp/jni/include/JniSkiaPictureView.h +16 -15
- package/android/cpp/rnskia-android/OpenGLContext.h +1 -1
- package/android/cpp/rnskia-android/gl/Surface.h +1 -1
- package/apple/RNSkApplePlatformContext.h +3 -4
- package/apple/RNSkiaModule.h +11 -3
- package/apple/RNSkiaModule.mm +46 -19
- package/apple/SkiaPictureView.mm +2 -2
- package/apple/SkiaUIView.h +0 -1
- package/apple/SkiaUIView.mm +1 -1
- package/apple/ViewScreenshotService.h +2 -2
- package/apple/ViewScreenshotService.mm +5 -4
- package/cpp/api/JsiSkImage.h +1 -1
- package/cpp/api/JsiSkImageFilter.h +3 -1
- package/cpp/api/JsiSkParagraph.h +2 -1
- package/cpp/api/JsiSkParagraphBuilder.h +1 -1
- package/cpp/api/JsiSkParagraphBuilderFactory.h +1 -1
- package/cpp/api/JsiSkPath.h +11 -435
- package/cpp/api/JsiSkPathBuilder.h +11 -4
- package/cpp/api/JsiSkPictureRecorder.h +2 -1
- package/cpp/api/JsiSkShader.h +3 -1
- package/cpp/api/JsiSkSkottie.h +29 -28
- package/cpp/api/JsiSkStrutStyle.h +1 -1
- package/cpp/api/JsiSkSurfaceFactory.h +41 -0
- package/cpp/api/recorder/Command.h +1 -1
- package/cpp/api/recorder/Convertor.h +153 -132
- package/cpp/api/recorder/DataTypes.h +12 -12
- package/cpp/api/recorder/DrawingCtx.h +1 -1
- package/cpp/api/recorder/ImageFit.h +8 -5
- package/cpp/api/recorder/JsiRecorder.h +14 -31
- package/cpp/api/recorder/Paint.h +3 -3
- package/cpp/api/recorder/RNRecorder.h +56 -0
- package/cpp/api/third_party/base64.cpp +1 -1
- package/cpp/jsi/JSICache.cpp +23 -0
- package/cpp/jsi/JSICache.h +28 -1
- package/cpp/jsi/NativeObject.h +36 -7
- package/cpp/jsi/ViewProperty.cpp +23 -0
- package/cpp/jsi/ViewProperty.h +31 -10
- package/cpp/rnskia/RNDawnContext.h +34 -1
- package/cpp/rnskia/RNSkJsiViewApi.h +69 -2
- package/cpp/rnskia/RNSkPictureView.cpp +58 -0
- package/cpp/rnskia/RNSkPictureView.h +110 -24
- package/lib/commonjs/Platform/IPlatform.js.map +1 -1
- package/lib/commonjs/animation/functions/interpolate.js.map +1 -1
- package/lib/commonjs/animation/functions/interpolatePaths.js +18 -0
- package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/commonjs/skia/core/Image.js.map +1 -1
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Path/Path.d.ts +2 -336
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/types/Recorder.d.ts +10 -0
- package/lib/commonjs/skia/types/Recorder.js.map +1 -1
- package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +16 -0
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.d.ts +4 -38
- package/lib/commonjs/skia/web/JsiSkPath.js +3 -275
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +3 -0
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/commonjs/sksg/Container.native.d.ts +15 -1
- package/lib/commonjs/sksg/Container.native.js +34 -33
- package/lib/commonjs/sksg/Container.native.js.map +1 -1
- package/lib/commonjs/specs/NativeSkiaModule.web.js +4 -0
- package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/commonjs/views/types.d.ts +9 -0
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/Platform/IPlatform.js.map +1 -1
- package/lib/module/animation/functions/interpolate.js.map +1 -1
- package/lib/module/animation/functions/interpolatePaths.js +18 -0
- package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/module/skia/core/Image.js.map +1 -1
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/module/skia/types/Path/Path.d.ts +2 -336
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/types/Recorder.d.ts +10 -0
- package/lib/module/skia/types/Recorder.js.map +1 -1
- package/lib/module/skia/types/Shader/Shader.js.map +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +16 -0
- package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.d.ts +4 -38
- package/lib/module/skia/web/JsiSkPath.js +4 -276
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js +4 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/module/sksg/Container.native.d.ts +15 -1
- package/lib/module/sksg/Container.native.js +34 -33
- package/lib/module/sksg/Container.native.js.map +1 -1
- package/lib/module/specs/NativeSkiaModule.web.js +4 -0
- package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/module/views/types.d.ts +9 -0
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +1 -35
- package/lib/typescript/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +15 -1
- package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +3 -37
- package/lib/typescript/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Container.native.d.ts +15 -1
- package/lib/typescript/src/skia/types/Path/Path.d.ts +2 -336
- package/lib/typescript/src/skia/types/Recorder.d.ts +10 -0
- package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +16 -0
- package/lib/typescript/src/skia/web/JsiSkPath.d.ts +4 -38
- package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/typescript/src/sksg/Container.native.d.ts +15 -1
- package/lib/typescript/src/views/types.d.ts +9 -0
- package/package.json +2 -2
- package/src/Platform/IPlatform.ts +1 -4
- package/src/animation/functions/interpolate.ts +1 -4
- package/src/animation/functions/interpolatePaths.ts +24 -0
- package/src/skia/core/Image.ts +1 -2
- package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +2 -5
- package/src/skia/types/Path/Path.ts +2 -420
- package/src/skia/types/Recorder.ts +10 -0
- package/src/skia/types/Shader/Shader.ts +1 -5
- package/src/skia/types/Surface/SurfaceFactory.ts +17 -0
- package/src/skia/web/JsiSkPath.ts +4 -495
- package/src/skia/web/JsiSkSurfaceFactory.ts +6 -2
- package/src/sksg/Container.native.ts +34 -37
- package/src/specs/NativeSkiaModule.web.ts +4 -0
- package/src/views/types.ts +13 -0
- package/apple/SkiaManager.h +0 -23
- package/apple/SkiaManager.mm +0 -63
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
#include "JsiSkSurface.h"
|
|
12
12
|
|
|
13
|
+
#ifdef SK_GRAPHITE
|
|
14
|
+
#include "rnskia/RNDawnContext.h"
|
|
15
|
+
#endif
|
|
16
|
+
|
|
13
17
|
#pragma clang diagnostic push
|
|
14
18
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
15
19
|
|
|
@@ -59,12 +63,49 @@ public:
|
|
|
59
63
|
getContext(), std::move(surface)));
|
|
60
64
|
}
|
|
61
65
|
|
|
66
|
+
// Pointer-based texture interop with react-native-webgpu, the surface
|
|
67
|
+
// counterpart of JsiSkImageFactory::MakeImageFromNativeTexture: Skia draws
|
|
68
|
+
// directly into a texture created on the shared device, so WebGPU can
|
|
69
|
+
// sample what Skia drew without any copy.
|
|
70
|
+
JSI_HOST_FUNCTION(MakeFromNativeTexture) {
|
|
71
|
+
#ifdef SK_GRAPHITE
|
|
72
|
+
if (count < 1 || !arguments[0].isBigInt()) {
|
|
73
|
+
throw std::runtime_error("MakeFromNativeTexture requires a WGPUTexture "
|
|
74
|
+
"pointer (BigInt), e.g. texture.nativePointer");
|
|
75
|
+
}
|
|
76
|
+
auto raw = reinterpret_cast<WGPUTexture>(
|
|
77
|
+
arguments[0].asBigInt(runtime).asUint64(runtime));
|
|
78
|
+
if (raw == nullptr) {
|
|
79
|
+
throw std::runtime_error(
|
|
80
|
+
"MakeFromNativeTexture: pointer must be non-null");
|
|
81
|
+
}
|
|
82
|
+
// AddRef so our wgpu::Texture holds its own reference: the surface keeps
|
|
83
|
+
// the texture alive for its lifetime, and the JS GPUTexture keeps its own
|
|
84
|
+
// reference, which the caller may release once the surface exists.
|
|
85
|
+
wgpuTextureAddRef(raw);
|
|
86
|
+
wgpu::Texture texture = wgpu::Texture::Acquire(raw);
|
|
87
|
+
auto surface = DawnContext::getInstance().MakeSurfaceFromTexture(texture);
|
|
88
|
+
if (surface == nullptr) {
|
|
89
|
+
throw std::runtime_error(
|
|
90
|
+
"MakeFromNativeTexture: failed to wrap the texture");
|
|
91
|
+
}
|
|
92
|
+
return makeJsiObject(runtime, std::make_shared<JsiSkSurface>(
|
|
93
|
+
getContext(), std::move(surface)));
|
|
94
|
+
#else
|
|
95
|
+
throw std::runtime_error(
|
|
96
|
+
"MakeFromNativeTexture is only available with the Graphite backend. "
|
|
97
|
+
"Rebuild with SK_GRAPHITE enabled.");
|
|
98
|
+
#endif
|
|
99
|
+
}
|
|
100
|
+
|
|
62
101
|
size_t getMemoryPressure() override { return 2048; }
|
|
63
102
|
|
|
64
103
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
65
104
|
installMethod(runtime, prototype, "Make", &JsiSkSurfaceFactory::Make);
|
|
66
105
|
installHostMethod(runtime, prototype, "MakeOffscreen",
|
|
67
106
|
&JsiSkSurfaceFactory::MakeOffscreen);
|
|
107
|
+
installHostMethod(runtime, prototype, "MakeFromNativeTexture",
|
|
108
|
+
&JsiSkSurfaceFactory::MakeFromNativeTexture);
|
|
68
109
|
}
|
|
69
110
|
|
|
70
111
|
explicit JsiSkSurfaceFactory(std::shared_ptr<RNSkPlatformContext> context)
|