@shopify/react-native-skia 2.5.2 → 2.5.4
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 +11 -0
- package/android/cpp/jni/JniWebGPUView.cpp +67 -0
- package/android/cpp/rnskia-android/SkiaPlatformContext.h +26 -0
- package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +4 -1
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUSurfaceView.java +41 -0
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUTextureView.java +44 -0
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUView.java +95 -0
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewAPI.java +14 -0
- package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +58 -0
- package/apple/RNSkUIKit.h +13 -0
- package/apple/SkiaPlatformContext.h +20 -0
- package/apple/SkiaPlatformContext.mm +21 -0
- package/apple/WebGPUMetalView.h +12 -0
- package/apple/WebGPUMetalView.mm +93 -0
- package/apple/WebGPUView.h +20 -0
- package/apple/WebGPUView.mm +77 -0
- package/cpp/jsi2/JSIConverter.h +11 -0
- package/cpp/rnskia/RNDawnContext.h +2 -2
- package/cpp/rnskia/RNDawnWindowContext.h +3 -0
- package/cpp/rnskia/RNSkManager.cpp +11 -4
- package/cpp/rnwgpu/Canvas.h +50 -0
- package/cpp/rnwgpu/PlatformContext.h +18 -0
- package/cpp/rnwgpu/SurfaceRegistry.h +229 -0
- package/cpp/rnwgpu/api/GPU.cpp +12 -0
- package/cpp/rnwgpu/api/GPUAdapter.cpp +26 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +64 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.h +65 -0
- package/cpp/rnwgpu/api/GPUDevice.cpp +52 -0
- package/cpp/rnwgpu/api/GPUDevice.h +62 -1
- package/cpp/rnwgpu/api/GPUQueue.cpp +1 -1
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +61 -0
- package/cpp/rnwgpu/api/RNWebGPU.h +62 -0
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +4 -0
- package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +76 -0
- package/lib/commonjs/external/reanimated/useVideo.js +1 -4
- package/lib/commonjs/external/reanimated/useVideo.js.map +1 -1
- package/lib/commonjs/mock/index.js +1 -0
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/commonjs/sksg/Container.native.js +4 -0
- package/lib/commonjs/sksg/Container.native.js.map +1 -1
- package/lib/commonjs/sksg/Container.web.js +4 -0
- package/lib/commonjs/sksg/Container.web.js.map +1 -1
- package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +8 -0
- package/lib/commonjs/specs/WebGPUViewNativeComponent.js +11 -0
- package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +8 -0
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +101 -0
- package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +1 -0
- package/lib/commonjs/specs/utils.d.ts +1 -0
- package/lib/commonjs/specs/utils.js +11 -0
- package/lib/commonjs/specs/utils.js.map +1 -0
- package/lib/commonjs/views/WebGPUCanvas.d.ts +32 -0
- package/lib/commonjs/views/WebGPUCanvas.js +66 -0
- package/lib/commonjs/views/WebGPUCanvas.js.map +1 -0
- package/lib/commonjs/views/WebGPUCanvas.web.d.ts +23 -0
- package/lib/commonjs/views/WebGPUCanvas.web.js +20 -0
- package/lib/commonjs/views/WebGPUCanvas.web.js.map +1 -0
- package/lib/commonjs/views/index.d.ts +1 -0
- package/lib/commonjs/views/index.js +11 -0
- package/lib/commonjs/views/index.js.map +1 -1
- package/lib/module/external/reanimated/useVideo.js +1 -4
- package/lib/module/external/reanimated/useVideo.js.map +1 -1
- package/lib/module/mock/index.js +1 -0
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/module/sksg/Container.native.js +5 -0
- package/lib/module/sksg/Container.native.js.map +1 -1
- package/lib/module/sksg/Container.web.js +5 -0
- package/lib/module/sksg/Container.web.js.map +1 -1
- package/lib/module/specs/WebGPUViewNativeComponent.d.ts +8 -0
- package/lib/module/specs/WebGPUViewNativeComponent.js +4 -0
- package/lib/module/specs/WebGPUViewNativeComponent.js.map +1 -0
- package/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +8 -0
- package/lib/module/specs/WebGPUViewNativeComponent.web.js +94 -0
- package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +1 -0
- package/lib/module/specs/utils.d.ts +1 -0
- package/lib/module/specs/utils.js +5 -0
- package/lib/module/specs/utils.js.map +1 -0
- package/lib/module/views/WebGPUCanvas.d.ts +32 -0
- package/lib/module/views/WebGPUCanvas.js +57 -0
- package/lib/module/views/WebGPUCanvas.js.map +1 -0
- package/lib/module/views/WebGPUCanvas.web.d.ts +23 -0
- package/lib/module/views/WebGPUCanvas.web.js +12 -0
- package/lib/module/views/WebGPUCanvas.web.js.map +1 -0
- package/lib/module/views/index.d.ts +1 -0
- package/lib/module/views/index.js +1 -0
- package/lib/module/views/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/mock/index.d.ts +1 -0
- package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +3 -0
- package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +3 -0
- package/lib/typescript/lib/commonjs/specs/utils.d.ts +2 -0
- package/lib/typescript/lib/commonjs/views/WebGPUCanvas.d.ts +6 -0
- package/lib/typescript/lib/commonjs/views/WebGPUCanvas.web.d.ts +6 -0
- package/lib/typescript/lib/module/mock/index.d.ts +3 -1
- package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +2 -0
- package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +2 -0
- package/lib/typescript/lib/module/specs/utils.d.ts +1 -0
- package/lib/typescript/lib/module/views/WebGPUCanvas.d.ts +7 -0
- package/lib/typescript/lib/module/views/WebGPUCanvas.web.d.ts +8 -0
- package/lib/typescript/lib/module/views/index.d.ts +1 -0
- package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +8 -0
- package/lib/typescript/src/specs/WebGPUViewNativeComponent.web.d.ts +8 -0
- package/lib/typescript/src/specs/utils.d.ts +1 -0
- package/lib/typescript/src/views/WebGPUCanvas.d.ts +32 -0
- package/lib/typescript/src/views/WebGPUCanvas.web.d.ts +23 -0
- package/lib/typescript/src/views/index.d.ts +1 -0
- package/package.json +3 -2
- package/react-native-skia.podspec +3 -0
- package/scripts/install-libs.js +24 -32
- package/src/external/reanimated/useVideo.ts +1 -4
- package/src/mock/index.ts +1 -0
- package/src/skia/types/Surface/SurfaceFactory.ts +5 -1
- package/src/sksg/Container.native.ts +3 -0
- package/src/sksg/Container.web.ts +3 -0
- package/src/specs/WebGPUViewNativeComponent.ts +11 -0
- package/src/specs/WebGPUViewNativeComponent.web.ts +108 -0
- package/src/specs/utils.ts +4 -0
- package/src/views/WebGPUCanvas.tsx +109 -0
- package/src/views/WebGPUCanvas.web.tsx +36 -0
- package/src/views/index.ts +1 -0
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <functional>
|
|
4
|
+
#include <map>
|
|
3
5
|
#include <memory>
|
|
6
|
+
#include <mutex>
|
|
4
7
|
#include <optional>
|
|
5
8
|
#include <string>
|
|
6
9
|
#include <unordered_set>
|
|
7
10
|
#include <utility>
|
|
8
11
|
#include <variant>
|
|
12
|
+
#include <vector>
|
|
9
13
|
|
|
10
14
|
#include "descriptors/Unions.h"
|
|
11
15
|
|
|
@@ -16,6 +20,8 @@
|
|
|
16
20
|
|
|
17
21
|
#include "webgpu/webgpu_cpp.h"
|
|
18
22
|
|
|
23
|
+
#include "GPUUncapturedErrorEvent.h"
|
|
24
|
+
|
|
19
25
|
#include "GPUBindGroup.h"
|
|
20
26
|
#include "GPUBindGroupLayout.h"
|
|
21
27
|
#include "GPUBuffer.h"
|
|
@@ -51,6 +57,39 @@ namespace rnwgpu {
|
|
|
51
57
|
|
|
52
58
|
namespace jsi = facebook::jsi;
|
|
53
59
|
|
|
60
|
+
// Forward declaration
|
|
61
|
+
class GPUDevice;
|
|
62
|
+
|
|
63
|
+
// Static registry to map wgpu::Device handles to GPUDevice instances
|
|
64
|
+
class GPUDeviceRegistry {
|
|
65
|
+
public:
|
|
66
|
+
static GPUDeviceRegistry &getInstance() {
|
|
67
|
+
static GPUDeviceRegistry instance;
|
|
68
|
+
return instance;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void registerDevice(WGPUDevice handle, GPUDevice *device) {
|
|
72
|
+
std::lock_guard<std::mutex> lock(_mutex);
|
|
73
|
+
_devices[handle] = device;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void unregisterDevice(WGPUDevice handle) {
|
|
77
|
+
std::lock_guard<std::mutex> lock(_mutex);
|
|
78
|
+
_devices.erase(handle);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
GPUDevice *getDevice(WGPUDevice handle) {
|
|
82
|
+
std::lock_guard<std::mutex> lock(_mutex);
|
|
83
|
+
auto it = _devices.find(handle);
|
|
84
|
+
return it != _devices.end() ? it->second : nullptr;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private:
|
|
88
|
+
GPUDeviceRegistry() = default;
|
|
89
|
+
std::mutex _mutex;
|
|
90
|
+
std::map<WGPUDevice, GPUDevice *> _devices;
|
|
91
|
+
};
|
|
92
|
+
|
|
54
93
|
class GPUDevice : public NativeObject<GPUDevice> {
|
|
55
94
|
public:
|
|
56
95
|
static constexpr const char *CLASS_NAME = "GPUDevice";
|
|
@@ -59,7 +98,15 @@ public:
|
|
|
59
98
|
std::shared_ptr<async::AsyncRunner> async,
|
|
60
99
|
std::string label)
|
|
61
100
|
: NativeObject(CLASS_NAME), _instance(instance), _async(async),
|
|
62
|
-
_label(label) {
|
|
101
|
+
_label(label) {
|
|
102
|
+
// Register this device in the global registry
|
|
103
|
+
GPUDeviceRegistry::getInstance().registerDevice(_instance.Get(), this);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
~GPUDevice() {
|
|
107
|
+
// Unregister from the global registry
|
|
108
|
+
GPUDeviceRegistry::getInstance().unregisterDevice(_instance.Get());
|
|
109
|
+
}
|
|
63
110
|
|
|
64
111
|
public:
|
|
65
112
|
std::string getBrand() { return CLASS_NAME; }
|
|
@@ -105,6 +152,11 @@ public:
|
|
|
105
152
|
void notifyDeviceLost(wgpu::DeviceLostReason reason, std::string message);
|
|
106
153
|
void forceLossForTesting();
|
|
107
154
|
|
|
155
|
+
// Event listener methods
|
|
156
|
+
void addEventListener(std::string type, jsi::Function callback);
|
|
157
|
+
void removeEventListener(std::string type, jsi::Function callback);
|
|
158
|
+
void notifyUncapturedError(GPUErrorVariant error);
|
|
159
|
+
|
|
108
160
|
std::string getLabel() { return _label; }
|
|
109
161
|
void setLabel(const std::string &label) {
|
|
110
162
|
_label = label;
|
|
@@ -155,6 +207,10 @@ public:
|
|
|
155
207
|
&GPUDevice::setLabel);
|
|
156
208
|
installMethod(runtime, prototype, "forceLossForTesting",
|
|
157
209
|
&GPUDevice::forceLossForTesting);
|
|
210
|
+
installMethod(runtime, prototype, "addEventListener",
|
|
211
|
+
&GPUDevice::addEventListener);
|
|
212
|
+
installMethod(runtime, prototype, "removeEventListener",
|
|
213
|
+
&GPUDevice::removeEventListener);
|
|
158
214
|
}
|
|
159
215
|
|
|
160
216
|
inline const wgpu::Device get() { return _instance; }
|
|
@@ -169,6 +225,11 @@ private:
|
|
|
169
225
|
std::shared_ptr<GPUDeviceLostInfo> _lostInfo;
|
|
170
226
|
bool _lostSettled = false;
|
|
171
227
|
std::optional<async::AsyncTaskHandle::ResolveFunction> _lostResolve;
|
|
228
|
+
|
|
229
|
+
// Event listeners storage
|
|
230
|
+
std::mutex _listenersMutex;
|
|
231
|
+
std::map<std::string, std::vector<std::shared_ptr<jsi::Function>>>
|
|
232
|
+
_eventListeners;
|
|
172
233
|
};
|
|
173
234
|
|
|
174
235
|
} // namespace rnwgpu
|
|
@@ -124,7 +124,7 @@ void GPUQueue::copyExternalImageToTexture(
|
|
|
124
124
|
// throw std::runtime_error("Invalid input for GPUQueue::writeTexture()");
|
|
125
125
|
// }
|
|
126
126
|
//
|
|
127
|
-
// if (source->flipY) {
|
|
127
|
+
// if (source->flipY.value_or(false)) {
|
|
128
128
|
// // Calculate the row size and total size
|
|
129
129
|
// uint32_t rowSize = bytesPerPixel * source->source->getWidth();
|
|
130
130
|
// uint32_t totalSize = source->source->getSize();
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <variant>
|
|
6
|
+
|
|
7
|
+
#include "jsi2/NativeObject.h"
|
|
8
|
+
|
|
9
|
+
#include "GPUError.h"
|
|
10
|
+
#include "GPUInternalError.h"
|
|
11
|
+
#include "GPUOutOfMemoryError.h"
|
|
12
|
+
#include "GPUValidationError.h"
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
namespace jsi = facebook::jsi;
|
|
17
|
+
|
|
18
|
+
using GPUErrorVariant =
|
|
19
|
+
std::variant<std::shared_ptr<GPUValidationError>,
|
|
20
|
+
std::shared_ptr<GPUOutOfMemoryError>,
|
|
21
|
+
std::shared_ptr<GPUInternalError>>;
|
|
22
|
+
|
|
23
|
+
class GPUUncapturedErrorEvent : public NativeObject<GPUUncapturedErrorEvent> {
|
|
24
|
+
public:
|
|
25
|
+
static constexpr const char *CLASS_NAME = "GPUUncapturedErrorEvent";
|
|
26
|
+
|
|
27
|
+
explicit GPUUncapturedErrorEvent(GPUErrorVariant error)
|
|
28
|
+
: NativeObject(CLASS_NAME), _error(std::move(error)) {}
|
|
29
|
+
|
|
30
|
+
GPUErrorVariant getError() { return _error; }
|
|
31
|
+
|
|
32
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
33
|
+
installGetter(runtime, prototype, "error",
|
|
34
|
+
&GPUUncapturedErrorEvent::getError);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private:
|
|
38
|
+
GPUErrorVariant _error;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
} // namespace rnwgpu
|
|
42
|
+
|
|
43
|
+
namespace rnwgpu {
|
|
44
|
+
|
|
45
|
+
template <> struct JSIConverter<GPUErrorVariant> {
|
|
46
|
+
static jsi::Value toJSI(jsi::Runtime &runtime, GPUErrorVariant arg) {
|
|
47
|
+
return std::visit(
|
|
48
|
+
[&runtime](auto &&error) -> jsi::Value {
|
|
49
|
+
using T = std::decay_t<decltype(error)>;
|
|
50
|
+
return JSIConverter<T>::toJSI(runtime, error);
|
|
51
|
+
},
|
|
52
|
+
arg);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static GPUErrorVariant fromJSI(jsi::Runtime &runtime, const jsi::Value &arg,
|
|
56
|
+
bool outOfBounds) {
|
|
57
|
+
throw std::runtime_error("GPUErrorVariant::fromJSI not implemented");
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace rnwgpu
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "jsi2/NativeObject.h"
|
|
7
|
+
|
|
8
|
+
#include "rnwgpu/Canvas.h"
|
|
9
|
+
#include "GPU.h"
|
|
10
|
+
#include "GPUCanvasContext.h"
|
|
11
|
+
#include "rnwgpu/PlatformContext.h"
|
|
12
|
+
|
|
13
|
+
namespace rnwgpu {
|
|
14
|
+
|
|
15
|
+
namespace jsi = facebook::jsi;
|
|
16
|
+
|
|
17
|
+
class RNWebGPU : public NativeObject<RNWebGPU> {
|
|
18
|
+
public:
|
|
19
|
+
static constexpr const char *CLASS_NAME = "RNWebGPU";
|
|
20
|
+
|
|
21
|
+
explicit RNWebGPU(std::shared_ptr<GPU> gpu,
|
|
22
|
+
std::shared_ptr<PlatformContext> platformContext)
|
|
23
|
+
: NativeObject(CLASS_NAME), _gpu(gpu), _platformContext(platformContext) {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
std::shared_ptr<GPU> getGPU() { return _gpu; }
|
|
27
|
+
|
|
28
|
+
bool getFabric() { return true; }
|
|
29
|
+
|
|
30
|
+
std::shared_ptr<GPUCanvasContext>
|
|
31
|
+
MakeWebGPUCanvasContext(int contextId, float width, float height) {
|
|
32
|
+
auto ctx =
|
|
33
|
+
std::make_shared<GPUCanvasContext>(_gpu, contextId, width, height);
|
|
34
|
+
return ctx;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
std::shared_ptr<Canvas> getNativeSurface(int contextId) {
|
|
38
|
+
auto ®istry = rnwgpu::SurfaceRegistry::getInstance();
|
|
39
|
+
auto info = registry.getSurfaceInfo(contextId);
|
|
40
|
+
if (info == nullptr) {
|
|
41
|
+
return std::make_shared<Canvas>(nullptr, 0, 0);
|
|
42
|
+
}
|
|
43
|
+
auto nativeInfo = info->getNativeInfo();
|
|
44
|
+
return std::make_shared<Canvas>(nativeInfo.nativeSurface, nativeInfo.width,
|
|
45
|
+
nativeInfo.height);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
49
|
+
installGetter(runtime, prototype, "fabric", &RNWebGPU::getFabric);
|
|
50
|
+
installGetter(runtime, prototype, "gpu", &RNWebGPU::getGPU);
|
|
51
|
+
installMethod(runtime, prototype, "getNativeSurface",
|
|
52
|
+
&RNWebGPU::getNativeSurface);
|
|
53
|
+
installMethod(runtime, prototype, "MakeWebGPUCanvasContext",
|
|
54
|
+
&RNWebGPU::MakeWebGPUCanvasContext);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private:
|
|
58
|
+
std::shared_ptr<GPU> _gpu;
|
|
59
|
+
std::shared_ptr<PlatformContext> _platformContext;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
} // namespace rnwgpu
|
|
@@ -45,6 +45,10 @@ template <> struct JSIConverter<std::shared_ptr<rnwgpu::GPUBindGroupEntry>> {
|
|
|
45
45
|
} else if (obj.hasNativeState<rnwgpu::GPUTextureView>(runtime)) {
|
|
46
46
|
result->textureView =
|
|
47
47
|
obj.getNativeState<rnwgpu::GPUTextureView>(runtime);
|
|
48
|
+
} else if (obj.hasNativeState<rnwgpu::GPUBuffer>(runtime)) {
|
|
49
|
+
auto binding = std::make_shared<rnwgpu::GPUBufferBinding>();
|
|
50
|
+
binding->buffer = obj.getNativeState<rnwgpu::GPUBuffer>(runtime);
|
|
51
|
+
result->buffer = binding;
|
|
48
52
|
} else {
|
|
49
53
|
result->buffer = JSIConverter<
|
|
50
54
|
std::shared_ptr<rnwgpu::GPUBufferBinding>>::fromJSI(runtime,
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <vector>
|
|
5
|
+
|
|
6
|
+
#include "webgpu/webgpu_cpp.h"
|
|
7
|
+
|
|
8
|
+
#include "jsi2/JSIConverter.h"
|
|
9
|
+
|
|
10
|
+
#include "GPUDevice.h"
|
|
11
|
+
|
|
12
|
+
namespace jsi = facebook::jsi;
|
|
13
|
+
|
|
14
|
+
namespace rnwgpu {
|
|
15
|
+
|
|
16
|
+
struct GPUCanvasConfiguration {
|
|
17
|
+
std::shared_ptr<GPUDevice> device; // GPUDevice
|
|
18
|
+
wgpu::TextureFormat format; // GPUTextureFormat
|
|
19
|
+
std::optional<double> usage; // GPUTextureUsageFlags
|
|
20
|
+
std::optional<std::vector<wgpu::TextureFormat>>
|
|
21
|
+
viewFormats; // Iterable<GPUTextureFormat>
|
|
22
|
+
wgpu::CompositeAlphaMode alphaMode = wgpu::CompositeAlphaMode::Opaque;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
} // namespace rnwgpu
|
|
26
|
+
|
|
27
|
+
namespace rnwgpu {
|
|
28
|
+
|
|
29
|
+
template <>
|
|
30
|
+
struct JSIConverter<std::shared_ptr<rnwgpu::GPUCanvasConfiguration>> {
|
|
31
|
+
static std::shared_ptr<rnwgpu::GPUCanvasConfiguration>
|
|
32
|
+
fromJSI(jsi::Runtime &runtime, const jsi::Value &arg, bool outOfBounds) {
|
|
33
|
+
auto result = std::make_unique<rnwgpu::GPUCanvasConfiguration>();
|
|
34
|
+
if (!outOfBounds && arg.isObject()) {
|
|
35
|
+
auto value = arg.getObject(runtime);
|
|
36
|
+
if (value.hasProperty(runtime, "device")) {
|
|
37
|
+
auto prop = value.getProperty(runtime, "device");
|
|
38
|
+
result->device = JSIConverter<std::shared_ptr<GPUDevice>>::fromJSI(
|
|
39
|
+
runtime, prop, false);
|
|
40
|
+
}
|
|
41
|
+
if (value.hasProperty(runtime, "format")) {
|
|
42
|
+
auto prop = value.getProperty(runtime, "format");
|
|
43
|
+
result->format =
|
|
44
|
+
JSIConverter<wgpu::TextureFormat>::fromJSI(runtime, prop, false);
|
|
45
|
+
}
|
|
46
|
+
if (value.hasProperty(runtime, "usage")) {
|
|
47
|
+
auto prop = value.getProperty(runtime, "usage");
|
|
48
|
+
result->usage =
|
|
49
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, prop, false);
|
|
50
|
+
}
|
|
51
|
+
if (value.hasProperty(runtime, "viewFormats")) {
|
|
52
|
+
auto prop = value.getProperty(runtime, "viewFormats");
|
|
53
|
+
result->viewFormats = JSIConverter<
|
|
54
|
+
std::optional<std::vector<wgpu::TextureFormat>>>::fromJSI(runtime,
|
|
55
|
+
prop,
|
|
56
|
+
false);
|
|
57
|
+
}
|
|
58
|
+
if (value.hasProperty(runtime, "alphaMode")) {
|
|
59
|
+
auto prop = value.getProperty(runtime, "alphaMode")
|
|
60
|
+
.asString(runtime)
|
|
61
|
+
.utf8(runtime);
|
|
62
|
+
if (prop == "premultiplied") {
|
|
63
|
+
result->alphaMode = wgpu::CompositeAlphaMode::Premultiplied;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
static jsi::Value toJSI(jsi::Runtime &runtime,
|
|
71
|
+
std::shared_ptr<rnwgpu::GPUCanvasConfiguration> arg) {
|
|
72
|
+
throw std::runtime_error("Invalid GPUCanvasConfiguration::toJSI()");
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace rnwgpu
|
|
@@ -16,7 +16,7 @@ const copyFrameOnAndroid = currentFrame => {
|
|
|
16
16
|
if (_Platform.Platform.OS === "android") {
|
|
17
17
|
const tex = currentFrame.value;
|
|
18
18
|
if (tex) {
|
|
19
|
-
currentFrame.value = tex
|
|
19
|
+
currentFrame.value = tex; //.makeNonTextureImage();
|
|
20
20
|
tex.dispose();
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -26,9 +26,6 @@ const setFrame = (video, currentFrame) => {
|
|
|
26
26
|
|
|
27
27
|
const img = video.nextImage();
|
|
28
28
|
if (img) {
|
|
29
|
-
if (currentFrame.value) {
|
|
30
|
-
currentFrame.value.dispose();
|
|
31
|
-
}
|
|
32
29
|
currentFrame.value = img;
|
|
33
30
|
copyFrameOnAndroid(currentFrame);
|
|
34
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_Platform","_ReanimatedProxy","_interopRequireDefault","_useVideoLoading","e","__esModule","default","copyFrameOnAndroid","currentFrame","Platform","OS","tex","value","
|
|
1
|
+
{"version":3,"names":["_react","require","_Platform","_ReanimatedProxy","_interopRequireDefault","_useVideoLoading","e","__esModule","default","copyFrameOnAndroid","currentFrame","Platform","OS","tex","value","dispose","setFrame","video","img","nextImage","defaultOptions","looping","paused","seek","volume","useOption","defaultValue","Rea","useSharedValue","isSharedValue","disposeVideo","useVideo","source","userOptions","_userOptions$paused","_userOptions$looping","_userOptions$seek","_userOptions$volume","useVideoLoading","isPaused","currentTime","duration","useMemo","_video$duration","framerate","_video$framerate","size","_video$size","width","height","rotation","_video$rotation","useAnimatedReaction","pause","play","setVolume","setLooping","useFrameCallback","_frameInfo","useEffect","runOnUI","exports"],"sources":["useVideo.ts"],"sourcesContent":["import type { SharedValue, FrameInfo } from \"react-native-reanimated\";\nimport { useEffect, useMemo } from \"react\";\n\nimport type { SkImage, Video } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nimport Rea from \"./ReanimatedProxy\";\nimport { useVideoLoading } from \"./useVideoLoading\";\n\ntype MaybeAnimated<T> = SharedValue<T> | T;\n\ninterface PlaybackOptions {\n looping: MaybeAnimated<boolean>;\n paused: MaybeAnimated<boolean>;\n seek: MaybeAnimated<number | null>;\n volume: MaybeAnimated<number>;\n}\n\nconst copyFrameOnAndroid = (currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n // on android we need to copy the texture before it's invalidated\n if (Platform.OS === \"android\") {\n const tex = currentFrame.value;\n if (tex) {\n currentFrame.value = tex; //.makeNonTextureImage();\n tex.dispose();\n }\n }\n};\n\nconst setFrame = (video: Video, currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n const img = video.nextImage();\n if (img) {\n currentFrame.value = img;\n copyFrameOnAndroid(currentFrame);\n }\n};\n\nconst defaultOptions = {\n looping: true,\n paused: false,\n seek: null,\n volume: 0,\n};\n\nconst useOption = <T>(value: MaybeAnimated<T>) => {\n \"worklet\";\n const defaultValue = Rea.useSharedValue(\n Rea.isSharedValue(value) ? value.value : value\n );\n return Rea.isSharedValue(value)\n ? (value as SharedValue<T>)\n : (defaultValue as SharedValue<T>);\n};\n\nconst disposeVideo = (video: Video | null) => {\n \"worklet\";\n video?.dispose();\n};\n\nexport const useVideo = (\n source: string | null,\n userOptions?: Partial<PlaybackOptions>\n) => {\n const video = useVideoLoading(source);\n const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);\n const looping = useOption(userOptions?.looping ?? defaultOptions.looping);\n const seek = useOption(userOptions?.seek ?? defaultOptions.seek);\n const volume = useOption(userOptions?.volume ?? defaultOptions.volume);\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const currentTime = Rea.useSharedValue(0);\n const duration = useMemo(() => video?.duration() ?? 0, [video]);\n const framerate = useMemo(\n () => (Platform.OS === \"web\" ? -1 : (video?.framerate() ?? 0)),\n [video]\n );\n const size = useMemo(() => video?.size() ?? { width: 0, height: 0 }, [video]);\n const rotation = useMemo(() => video?.rotation() ?? 0, [video]);\n\n // Handle pause/play state changes\n Rea.useAnimatedReaction(\n () => isPaused.value,\n (paused) => {\n if (paused) {\n video?.pause();\n } else {\n video?.play();\n }\n }\n );\n\n // Handle seek\n Rea.useAnimatedReaction(\n () => seek.value,\n (value) => {\n if (value !== null) {\n video?.seek(value);\n seek.value = null;\n }\n }\n );\n\n // Handle volume changes\n Rea.useAnimatedReaction(\n () => volume.value,\n (value) => {\n video?.setVolume(value);\n }\n );\n\n // Handle looping changes\n Rea.useAnimatedReaction(\n () => looping.value,\n (value) => {\n video?.setLooping(value);\n }\n );\n\n // Frame callback - simplified since native handles frame timing\n Rea.useFrameCallback((_frameInfo: FrameInfo) => {\n \"worklet\";\n if (!video) {\n return;\n }\n // Update current time from native player\n currentTime.value = video.currentTime();\n // Get the latest frame (native handles timing via CADisplayLink/etc)\n setFrame(video, currentFrame);\n });\n\n // Apply initial state when video becomes available\n useEffect(() => {\n if (video) {\n video.setLooping(looping.value);\n video.setVolume(volume.value);\n if (isPaused.value) {\n video.pause();\n } else {\n video.play();\n }\n }\n return () => {\n Rea.runOnUI(disposeVideo)(video);\n };\n }, [video, isPaused, looping, volume]);\n\n return {\n currentFrame,\n currentTime,\n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E,CAACA,KAAK,EAAEsB,QAAQ,EAAElB,OAAO,EAAEG,MAAM,CAAC,CAAC;EAEtC,OAAO;IACLd,YAAY;IACZ8B,WAAW;IACXC,QAAQ;IACRG,SAAS;IACTM,QAAQ;IACRJ;EACF,CAAC;AACH,CAAC;AAACe,OAAA,CAAA9B,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -29,6 +29,7 @@ const Mock = CanvasKit => {
|
|
|
29
29
|
...require("../dom/types"),
|
|
30
30
|
...require("../dom/nodes"),
|
|
31
31
|
Canvas: require("react-native").View,
|
|
32
|
+
WebGPUCanvas: require("react-native").View,
|
|
32
33
|
SkiaPictureView: require("react-native").View,
|
|
33
34
|
JsiSkImage: _JsiSkImage.JsiSkImage,
|
|
34
35
|
drawAsPicture: Noop,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_web","require","_JsiSkImage","Noop","undefined","NoopValue","current","NoopSharedValue","value","Mock","CanvasKit","global","SkiaApi","JsiSkApi","Skia","Canvas","View","SkiaPictureView","JsiSkImage","drawAsPicture","drawAsImage","drawAsImageFromPicture","useCanvasRef","useCanvasSize","ref","size","width","height","useValue","useComputedValue","useTiming","useLoop","useSpring","useClockValue","useValueEffect","isOnMainThread","isFabric","useClock","usePathInterpolation","useImageAsTexture","useTextureValue","useTextureValueFromPicture","useRSXformBuffer","usePointBuffer","useColorBuffer","useRectBuffer","useBuffer","useRawData","useData","useFont","Font","useFonts","useTypeface","useImage","useSVG","useVideo","exports"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { JsiSkImage } from \"../skia/web/JsiSkImage\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\nconst NoopSharedValue = () => ({ value: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n global.SkiaApi = JsiSkApi(CanvasKit);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n Canvas: require(\"react-native\").View,\n SkiaPictureView: require(\"react-native\").View,\n JsiSkImage: JsiSkImage,\n drawAsPicture: Noop,\n drawAsImage: Noop,\n drawAsImageFromPicture: Noop,\n useCanvasRef: NoopValue,\n useCanvasSize: () => ({\n ref: {\n current: 0,\n },\n size: {\n width: 0,\n height: 0,\n },\n }),\n // Skia Animations\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n // Reanimated hooks\n isOnMainThread: () => true,\n isFabric: true,\n useClock: NoopSharedValue,\n usePathInterpolation: NoopSharedValue,\n useImageAsTexture: NoopSharedValue,\n useTextureValue: NoopSharedValue,\n useTextureValueFromPicture: NoopSharedValue,\n useRSXformBuffer: NoopSharedValue,\n usePointBuffer: NoopSharedValue,\n useColorBuffer: NoopSharedValue,\n useRectBuffer: NoopSharedValue,\n useBuffer: NoopSharedValue,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useFonts: Noop,\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n useVideo: () => null,\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA;AACA,MAAME,IAAe,GAAGA,CAAA,KAAMC,SAAS;AACvC,MAAMC,SAAS,GAAGA,CAAA,MAAO;EAAEC,OAAO,EAAE;AAAE,CAAC,CAAC;AACxC,MAAMC,eAAe,GAAGA,CAAA,MAAO;EAAEC,KAAK,EAAE;AAAE,CAAC,CAAC;AAErC,MAAMC,IAAI,GAAIC,SAAoB,IAAK;EAC5C;EACA;EACAC,MAAM,CAACC,OAAO,GAAG,IAAAC,aAAQ,EAACH,SAAS,CAAC;EACpC;EACA;EACA,MAAMI,IAAI,GAAGH,MAAM,CAACC,OAAO;EAC3B,OAAO;IACLE,IAAI;IACJ,GAAGb,OAAO,CAAC,wBAAwB,CAAC;IACpC,GAAGA,OAAO,CAAC,SAAS,CAAC;IACrB,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1B,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1B,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1Bc,MAAM,EAAEd,OAAO,CAAC,cAAc,CAAC,CAACe,IAAI;IACpCC,
|
|
1
|
+
{"version":3,"names":["_web","require","_JsiSkImage","Noop","undefined","NoopValue","current","NoopSharedValue","value","Mock","CanvasKit","global","SkiaApi","JsiSkApi","Skia","Canvas","View","WebGPUCanvas","SkiaPictureView","JsiSkImage","drawAsPicture","drawAsImage","drawAsImageFromPicture","useCanvasRef","useCanvasSize","ref","size","width","height","useValue","useComputedValue","useTiming","useLoop","useSpring","useClockValue","useValueEffect","isOnMainThread","isFabric","useClock","usePathInterpolation","useImageAsTexture","useTextureValue","useTextureValueFromPicture","useRSXformBuffer","usePointBuffer","useColorBuffer","useRectBuffer","useBuffer","useRawData","useData","useFont","Font","useFonts","useTypeface","useImage","useSVG","useVideo","exports"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { JsiSkImage } from \"../skia/web/JsiSkImage\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\nconst NoopSharedValue = () => ({ value: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n global.SkiaApi = JsiSkApi(CanvasKit);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n Canvas: require(\"react-native\").View,\n WebGPUCanvas: require(\"react-native\").View,\n SkiaPictureView: require(\"react-native\").View,\n JsiSkImage: JsiSkImage,\n drawAsPicture: Noop,\n drawAsImage: Noop,\n drawAsImageFromPicture: Noop,\n useCanvasRef: NoopValue,\n useCanvasSize: () => ({\n ref: {\n current: 0,\n },\n size: {\n width: 0,\n height: 0,\n },\n }),\n // Skia Animations\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n // Reanimated hooks\n isOnMainThread: () => true,\n isFabric: true,\n useClock: NoopSharedValue,\n usePathInterpolation: NoopSharedValue,\n useImageAsTexture: NoopSharedValue,\n useTextureValue: NoopSharedValue,\n useTextureValueFromPicture: NoopSharedValue,\n useRSXformBuffer: NoopSharedValue,\n usePointBuffer: NoopSharedValue,\n useColorBuffer: NoopSharedValue,\n useRectBuffer: NoopSharedValue,\n useBuffer: NoopSharedValue,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useFonts: Noop,\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n useVideo: () => null,\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA;AACA,MAAME,IAAe,GAAGA,CAAA,KAAMC,SAAS;AACvC,MAAMC,SAAS,GAAGA,CAAA,MAAO;EAAEC,OAAO,EAAE;AAAE,CAAC,CAAC;AACxC,MAAMC,eAAe,GAAGA,CAAA,MAAO;EAAEC,KAAK,EAAE;AAAE,CAAC,CAAC;AAErC,MAAMC,IAAI,GAAIC,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ElC,eAAe;IAChCmC,0BAA0B,EAAEnC,eAAe;IAC3CoC,gBAAgB,EAAEpC,eAAe;IACjCqC,cAAc,EAAErC,eAAe;IAC/BsC,cAAc,EAAEtC,eAAe;IAC/BuC,aAAa,EAAEvC,eAAe;IAC9BwC,SAAS,EAAExC,eAAe;IAC1ByC,UAAU,EAAE7C,IAAI;IAChB8C,OAAO,EAAE9C,IAAI;IACb+C,OAAO,EAAEA,CAAA,KAAMpC,IAAI,CAACqC,IAAI,CAAC/C,SAAS,EAAE,CAAC,CAAC;IACtCgD,QAAQ,EAAEjD,IAAI;IACdkD,WAAW,EAAEA,CAAA,KAAM,IAAI;IACvBC,QAAQ,EAAEA,CAAA,KAAM,IAAI;IACpBC,MAAM,EAAEA,CAAA,KAAM,IAAI;IAClBC,QAAQ,EAAEA,CAAA,KAAM;EAClB,CAAC;AACH,CAAC;AAACC,OAAA,CAAAhD,IAAA,GAAAA,IAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ColorSpace","exports","SRGB","DisplayP3"],"sources":["SurfaceFactory.ts"],"sourcesContent":["import type { SkSurface } from \"./Surface\";\n\nexport const ColorSpace = {\n SRGB: \"srgb\",\n DisplayP3: \"display-p3\",\n} as const;\n\nexport type ColorSpaceValue = (typeof ColorSpace)[keyof typeof ColorSpace];\n\nexport interface SurfaceOptions {\n colorSpace: ColorSpaceValue;\n}\n\nexport interface SurfaceFactory {\n /**\n * Returns a CPU backed surface with the given dimensions, an SRGB colorspace, Unpremul\n * alphaType and 8888 color type. The pixels belonging to this surface will be in memory and\n * not visible.\n * @param width - number of pixels of the width of the drawable area.\n * @param height - number of pixels of the height of the drawable area.\n */\n Make: (width: number, height: number) => SkSurface | null;\n\n /**\n * Creates a GPU backed surface.\n * @param width - number of pixels of the width of the drawable area.\n * @param height - number of pixels of the height of the drawable area.\n * @param opts - optional surface options (e.g. colorSpace: \"display-p3\" | \"srgb\").\n */\n MakeOffscreen: (width: number
|
|
1
|
+
{"version":3,"names":["ColorSpace","exports","SRGB","DisplayP3"],"sources":["SurfaceFactory.ts"],"sourcesContent":["import type { SkSurface } from \"./Surface\";\n\nexport const ColorSpace = {\n SRGB: \"srgb\",\n DisplayP3: \"display-p3\",\n} as const;\n\nexport type ColorSpaceValue = (typeof ColorSpace)[keyof typeof ColorSpace];\n\nexport interface SurfaceOptions {\n colorSpace: ColorSpaceValue;\n}\n\nexport interface SurfaceFactory {\n /**\n * Returns a CPU backed surface with the given dimensions, an SRGB colorspace, Unpremul\n * alphaType and 8888 color type. The pixels belonging to this surface will be in memory and\n * not visible.\n * @param width - number of pixels of the width of the drawable area.\n * @param height - number of pixels of the height of the drawable area.\n */\n Make: (width: number, height: number) => SkSurface | null;\n\n /**\n * Creates a GPU backed surface.\n * @param width - number of pixels of the width of the drawable area.\n * @param height - number of pixels of the height of the drawable area.\n * @param opts - optional surface options (e.g. colorSpace: \"display-p3\" | \"srgb\").\n */\n MakeOffscreen: (\n width: number,\n height: number,\n opts?: SurfaceOptions\n ) => SkSurface | null;\n}\n"],"mappings":";;;;;;AAEO,MAAMA,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG;EACxBE,IAAI,EAAE,MAAM;EACZC,SAAS,EAAE;AACb,CAAU","ignoreList":[]}
|
|
@@ -15,6 +15,10 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
15
15
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
16
16
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
17
17
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
+
// create local reference for `strictGlobal` option in Worklets
|
|
19
|
+
const {
|
|
20
|
+
SkiaViewApi
|
|
21
|
+
} = globalThis;
|
|
18
22
|
const nativeDrawOnscreen = (nativeId, recorder, picture) => {
|
|
19
23
|
"worklet";
|
|
20
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ReanimatedProxy","_interopRequireDefault","require","_renderHelpers","_ReanimatedRecorder","_StaticContainer","_Visitor","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","nativeDrawOnscreen","nativeId","recorder","picture","play","
|
|
1
|
+
{"version":3,"names":["_ReanimatedProxy","_interopRequireDefault","require","_renderHelpers","_ReanimatedRecorder","_StaticContainer","_Visitor","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SkiaViewApi","globalThis","nativeDrawOnscreen","nativeId","recorder","picture","play","setJsiProperty","NativeReanimatedContainer","Container","constructor","Skia","Picture","MakePicture","redraw","mapperId","Rea","stopMapper","unmounted","ReanimatedRecorder","visit","root","sharedValues","getSharedValues","sharedRecorder","getRecorder","runOnUI","length","startMapper","applyUpdates","createContainer","HAS_REANIMATED_3","StaticContainer","exports"],"sources":["Container.native.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkPicture } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\nimport { visit } from \"./Recorder/Visitor\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\n// create local reference for `strictGlobal` option in Worklets\nconst { SkiaViewApi } = globalThis;\n\nconst nativeDrawOnscreen = (\n nativeId: number,\n recorder: JsiRecorder,\n picture: SkPicture\n) => {\n \"worklet\";\n\n //const start = performance.now();\n recorder.play(picture);\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n private picture: SkPicture;\n\n constructor(\n Skia: Skia,\n private nativeId: number\n ) {\n super(Skia);\n this.picture = Skia.Picture.MakePicture(null)!;\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new ReanimatedRecorder(this.Skia);\n const { nativeId, picture } = this;\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n // Draw first frame\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder, picture);\n })();\n // Animate\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder, picture);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAGA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAEAA,OAAA;AACAA,OAAA;AAAsB,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,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AAAC8B,OAAA,CAAAH,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -17,6 +17,10 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
17
17
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
18
18
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
19
19
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
|
+
// create local reference for `strictGlobal` option in Worklets
|
|
21
|
+
const {
|
|
22
|
+
SkiaViewApi
|
|
23
|
+
} = globalThis;
|
|
20
24
|
const drawOnscreen = (Skia, nativeId, recording) => {
|
|
21
25
|
"worklet";
|
|
22
26
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ReanimatedProxy","_interopRequireDefault","require","_renderHelpers","_Recorder","_Visitor","_Player","_DrawingContext","_StaticContainer","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","createDrawingContext","paintPool","replay","commands","picture","finishRecordingAsPicture","dispose","
|
|
1
|
+
{"version":3,"names":["_ReanimatedProxy","_interopRequireDefault","require","_renderHelpers","_Recorder","_Visitor","_Player","_DrawingContext","_StaticContainer","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SkiaViewApi","globalThis","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","createDrawingContext","paintPool","replay","commands","picture","finishRecordingAsPicture","dispose","setJsiProperty","ReanimatedContainer","Container","constructor","redraw","mapperId","Rea","stopMapper","unmounted","recorder","Recorder","visit","root","record","getRecording","animationValues","size","startMapper","Array","from","runOnUI","createContainer","HAS_REANIMATED_3","StaticContainer","exports"],"sources":["Container.web.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\n\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\n// create local reference for `strictGlobal` option in Worklets\nconst { SkiaViewApi } = globalThis;\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n const ctx = createDrawingContext(Skia, recording.paintPool, canvas);\n replay(ctx, recording.commands);\n const picture = rec.finishRecordingAsPicture();\n rec.dispose();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(\n Skia: Skia,\n private nativeId: number\n ) {\n super(Skia);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new Recorder();\n visit(recorder, this.root);\n const record = recorder.getRecording();\n const { animationValues } = record;\n this.recording = {\n commands: record.commands,\n paintPool: record.paintPool,\n };\n const { nativeId, Skia, recording } = this;\n if (animationValues.size > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n }, Array.from(animationValues));\n }\n Rea.runOnUI(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n })();\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new ReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAGA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AAEAA,OAAA;AACAA,OAAA;AAAsB,SAAAD,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,EAAAL,CAAA;AAAA,SAAAM,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAL,CAAA,GAAAK,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAhB,CAAA,QAAAa,CAAA,GAAAb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,CAACG,IAAI,CAAC;IAC1B,MAAMC,MAAM,GAAGJ,QAAQ,CAACK,YAAY,CAAC,CAAC;IACtC,MAAM;MAAEC;IAAgB,CAAC,GAAGF,MAAM;IAClC,IAAI,CAAC1B,SAAS,GAAG;MACfS,QAAQ,EAAEiB,MAAM,CAACjB,QAAQ;MACzBF,SAAS,EAAEmB,MAAM,CAACnB;IACpB,CAAC;IACD,MAAM;MAAER,QAAQ;MAAED,IAAI;MAAEE;IAAU,CAAC,GAAG,IAAI;IAC1C,IAAI4B,eAAe,CAACC,IAAI,GAAG,CAAC,EAAE;MAC5B,IAAI,CAACX,QAAQ,GAAGC,wBAAG,CAACW,WAAW,CAAC,MAAM;QACpC,SAAS;;QACTjC,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAU,CAAC;MAC1C,CAAC,EAAE+B,KAAK,CAACC,IAAI,CAACJ,eAAe,CAAC,CAAC;IACjC;IACAT,wBAAG,CAACc,OAAO,CAAC,MAAM;MAChB,SAAS;;MACTpC,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAU,CAAC;IAC1C,CAAC,CAAC,CAAC,CAAC;EACN;AACF;AAEO,MAAMkC,eAAe,GAAGA,CAACpC,IAAU,EAAEC,QAAgB,KAAK;EAC/D,IAAIoC,+BAAgB,IAAIpC,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,OAAO,IAAIe,mBAAmB,CAAChB,IAAI,EAAEC,QAAQ,CAAC;EAChD,CAAC,MAAM;IACL,OAAO,IAAIqC,gCAAe,CAACtC,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC;AAACsC,OAAA,CAAAH,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Int32 } from "react-native/Libraries/Types/CodegenTypes";
|
|
2
|
+
import type { ViewProps } from "react-native";
|
|
3
|
+
export interface NativeProps extends ViewProps {
|
|
4
|
+
contextId: Int32;
|
|
5
|
+
transparent: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _codegenNativeComponent = _interopRequireDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
// eslint-disable-next-line import/no-default-export
|
|
10
|
+
var _default = exports.default = (0, _codegenNativeComponent.default)("WebGPUView");
|
|
11
|
+
//# sourceMappingURL=WebGPUViewNativeComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_codegenNativeComponent","_interopRequireDefault","require","e","__esModule","default","_default","exports","codegenNativeComponent"],"sources":["WebGPUViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\nimport type { Int32 } from \"react-native/Libraries/Types/CodegenTypes\";\nimport type { ViewProps } from \"react-native\";\n\nexport interface NativeProps extends ViewProps {\n contextId: Int32;\n transparent: boolean;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default codegenNativeComponent<NativeProps>(\"WebGPUView\");\n"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA6F,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAS7F;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GACe,IAAAG,+BAAsB,EAAc,YAAY,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Int32 } from "react-native/Libraries/Types/CodegenTypes";
|
|
3
|
+
import type { ViewProps } from "react-native";
|
|
4
|
+
export interface NativeProps extends ViewProps {
|
|
5
|
+
contextId: Int32;
|
|
6
|
+
transparent: boolean;
|
|
7
|
+
}
|
|
8
|
+
export default function WebGPUViewNativeComponent(props: NativeProps): React.JSX.Element;
|