@shopify/react-native-skia 2.9.1 → 2.10.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 -5
- package/cpp/api/JsiNativeBuffer.h +15 -10
- package/cpp/api/JsiSkAnimatedImage.h +21 -19
- package/cpp/api/JsiSkAnimatedImageFactory.h +13 -14
- package/cpp/api/JsiSkApi.h +246 -92
- package/cpp/api/JsiSkCanvas.h +76 -58
- package/cpp/api/JsiSkColor.h +7 -5
- package/cpp/api/JsiSkColorFilter.h +15 -8
- package/cpp/api/JsiSkColorFilterFactory.h +45 -45
- package/cpp/api/JsiSkContourMeasure.h +24 -21
- package/cpp/api/JsiSkContourMeasureIter.h +18 -21
- package/cpp/api/JsiSkData.h +13 -7
- package/cpp/api/JsiSkDataFactory.h +22 -21
- package/cpp/api/JsiSkFont.h +56 -44
- package/cpp/api/JsiSkFontMgr.h +22 -13
- package/cpp/api/JsiSkFontMgrFactory.h +12 -10
- package/cpp/api/JsiSkFontStyle.h +14 -12
- package/cpp/api/JsiSkImage.h +45 -34
- package/cpp/api/JsiSkImageFactory.h +47 -52
- package/cpp/api/JsiSkImageFilter.h +21 -11
- package/cpp/api/JsiSkImageFilterFactory.h +96 -96
- package/cpp/api/JsiSkImageInfo.h +22 -19
- package/cpp/api/JsiSkMaskFilter.h +21 -11
- package/cpp/api/JsiSkMaskFilterFactory.h +16 -13
- package/cpp/api/JsiSkMatrix.h +31 -31
- package/cpp/api/JsiSkNativeObjects.h +419 -0
- package/cpp/api/JsiSkPaint.h +59 -39
- package/cpp/api/JsiSkParagraph.h +39 -32
- package/cpp/api/JsiSkParagraphBuilder.h +24 -21
- package/cpp/api/JsiSkParagraphBuilderFactory.h +13 -12
- package/cpp/api/JsiSkPath.h +95 -70
- package/cpp/api/JsiSkPathBuilder.h +83 -67
- package/cpp/api/JsiSkPathBuilderFactory.h +16 -17
- package/cpp/api/JsiSkPathEffect.h +21 -11
- package/cpp/api/JsiSkPathEffectFactory.h +33 -32
- package/cpp/api/JsiSkPathFactory.h +79 -103
- package/cpp/api/JsiSkPicture.h +24 -13
- package/cpp/api/JsiSkPictureFactory.h +21 -26
- package/cpp/api/JsiSkPictureRecorder.h +21 -22
- package/cpp/api/JsiSkPoint.h +19 -22
- package/cpp/api/JsiSkRRect.h +22 -29
- package/cpp/api/JsiSkRSXform.h +26 -30
- package/cpp/api/JsiSkRect.h +28 -30
- package/cpp/api/JsiSkRuntimeEffect.h +39 -30
- package/cpp/api/JsiSkRuntimeEffectFactory.h +12 -12
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +25 -18
- package/cpp/api/JsiSkSVG.h +13 -13
- package/cpp/api/JsiSkSVGFactory.h +17 -20
- package/cpp/api/JsiSkShader.h +15 -8
- package/cpp/api/JsiSkShaderFactory.h +41 -48
- package/cpp/api/JsiSkSkottie.h +49 -39
- package/cpp/api/JsiSkSurface.h +24 -24
- package/cpp/api/JsiSkSurfaceFactory.h +15 -16
- package/cpp/api/JsiSkTextBlob.h +15 -8
- package/cpp/api/JsiSkTextBlobFactory.h +25 -28
- package/cpp/api/JsiSkTypeface.h +19 -12
- package/cpp/api/JsiSkTypefaceFactory.h +12 -12
- package/cpp/api/JsiSkTypefaceFontProvider.h +30 -25
- package/cpp/api/JsiSkTypefaceFontProviderFactory.h +14 -12
- package/cpp/api/JsiSkVertices.h +21 -18
- package/cpp/api/JsiSkiaContext.h +17 -17
- package/cpp/api/JsiSkottieFactory.h +16 -17
- package/cpp/api/JsiVideo.h +27 -25
- package/cpp/api/recorder/Convertor.h +31 -61
- package/cpp/api/recorder/DataTypes.h +8 -16
- package/cpp/api/recorder/JsiRecorder.h +83 -55
- package/cpp/api/recorder/RNRecorder.h +1 -1
- package/cpp/jsi/BoxedNativeObject.h +146 -0
- package/cpp/{jsi2 → jsi}/EnumMapper.h +4 -1
- package/cpp/{jsi2 → jsi}/NativeObject.h +120 -146
- package/cpp/jsi/RuntimeAwareCache.cpp +1 -1
- package/cpp/jsi/RuntimeAwareCache.h +26 -8
- package/cpp/jsi/ViewProperty.h +5 -11
- package/cpp/rnskia/RNSkJsiViewApi.h +20 -11
- package/cpp/rnskia/RNSkManager.cpp +23 -25
- package/cpp/rnskia/RNSkPictureView.h +1 -1
- package/cpp/rnwgpu/ArrayBuffer.h +5 -6
- package/cpp/rnwgpu/Canvas.h +4 -2
- package/cpp/rnwgpu/api/GPU.cpp +4 -4
- package/cpp/rnwgpu/api/GPU.h +1 -1
- package/cpp/rnwgpu/api/GPUAdapter.cpp +2 -3
- package/cpp/rnwgpu/api/GPUAdapter.h +4 -4
- package/cpp/rnwgpu/api/GPUAdapterInfo.h +1 -1
- package/cpp/rnwgpu/api/GPUBindGroup.h +1 -1
- package/cpp/rnwgpu/api/GPUBindGroupLayout.h +1 -1
- package/cpp/rnwgpu/api/GPUBuffer.h +1 -1
- package/cpp/rnwgpu/api/GPUCanvasContext.h +1 -1
- package/cpp/rnwgpu/api/GPUCommandBuffer.h +1 -1
- package/cpp/rnwgpu/api/GPUCommandEncoder.h +1 -1
- package/cpp/rnwgpu/api/GPUCompilationInfo.h +1 -1
- package/cpp/rnwgpu/api/GPUCompilationMessage.h +1 -1
- package/cpp/rnwgpu/api/GPUComputePassEncoder.h +1 -1
- package/cpp/rnwgpu/api/GPUComputePipeline.h +1 -1
- package/cpp/rnwgpu/api/GPUDevice.cpp +6 -7
- package/cpp/rnwgpu/api/GPUDevice.h +3 -3
- package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +1 -1
- package/cpp/rnwgpu/api/GPUError.h +1 -1
- package/cpp/rnwgpu/api/GPUExtent3D.h +1 -1
- package/cpp/rnwgpu/api/GPUExternalTexture.h +1 -1
- package/cpp/rnwgpu/api/GPUInternalError.h +1 -1
- package/cpp/rnwgpu/api/GPUOrigin2D.h +1 -1
- package/cpp/rnwgpu/api/GPUOrigin3D.h +1 -1
- package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +1 -1
- package/cpp/rnwgpu/api/GPUPipelineLayout.h +1 -1
- package/cpp/rnwgpu/api/GPUQuerySet.h +1 -1
- package/cpp/rnwgpu/api/GPUQueue.h +1 -1
- package/cpp/rnwgpu/api/GPURenderBundle.h +1 -1
- package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +1 -1
- package/cpp/rnwgpu/api/GPURenderPassEncoder.h +1 -1
- package/cpp/rnwgpu/api/GPURenderPipeline.h +1 -1
- package/cpp/rnwgpu/api/GPUSampler.h +1 -1
- package/cpp/rnwgpu/api/GPUShaderModule.cpp +1 -1
- package/cpp/rnwgpu/api/GPUShaderModule.h +1 -1
- package/cpp/rnwgpu/api/GPUSharedFence.h +1 -1
- package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +1 -1
- package/cpp/rnwgpu/api/GPUSupportedLimits.h +1 -1
- package/cpp/rnwgpu/api/GPUTexture.h +1 -1
- package/cpp/rnwgpu/api/GPUTextureView.h +1 -1
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +1 -1
- package/cpp/rnwgpu/api/GPUValidationError.h +1 -1
- package/cpp/rnwgpu/api/ImageBitmap.h +1 -1
- package/cpp/rnwgpu/api/RNWebGPU.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUColor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +1 -1
- package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +1 -1
- package/cpp/rnwgpu/api/descriptors/Unions.h +1 -1
- package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +20 -21
- package/lib/commonjs/external/reanimated/renderHelpers.d.ts +15 -0
- package/lib/commonjs/external/reanimated/renderHelpers.js +30 -1
- package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/commonjs/skia/NativeSetup.js +4 -0
- package/lib/commonjs/skia/NativeSetup.js.map +1 -1
- package/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +1 -0
- package/lib/commonjs/skia/SkiaWorkletSerialization.js +66 -0
- package/lib/commonjs/skia/SkiaWorkletSerialization.js.map +1 -0
- package/lib/commonjs/sksg/Container.native.js +20 -1
- package/lib/commonjs/sksg/Container.native.js.map +1 -1
- package/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
- package/lib/module/external/reanimated/renderHelpers.js +29 -0
- package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/module/skia/NativeSetup.js +4 -0
- package/lib/module/skia/NativeSetup.js.map +1 -1
- package/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
- package/lib/module/skia/SkiaWorkletSerialization.js +59 -0
- package/lib/module/skia/SkiaWorkletSerialization.js.map +1 -0
- package/lib/module/sksg/Container.native.js +21 -2
- package/lib/module/sksg/Container.native.js.map +1 -1
- package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +2 -0
- package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
- package/lib/typescript/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
- package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +15 -0
- package/lib/typescript/src/skia/SkiaWorkletSerialization.d.ts +1 -0
- package/package.json +6 -2
- package/react-native-skia.podspec +1 -2
- package/src/external/reanimated/renderHelpers.ts +30 -0
- package/src/skia/NativeSetup.ts +5 -0
- package/src/skia/SkiaWorkletSerialization.ts +67 -0
- package/src/sksg/Container.native.ts +40 -2
- package/cpp/api/JsiSkHostObjects.h +0 -257
- package/cpp/jsi/JsiHostObject.cpp +0 -137
- package/cpp/jsi/JsiHostObject.h +0 -385
- /package/cpp/{jsi2 → jsi}/JSIConverter.h +0 -0
- /package/cpp/{jsi2 → jsi}/Promise.cpp +0 -0
- /package/cpp/{jsi2 → jsi}/Promise.h +0 -0
|
@@ -5,27 +5,27 @@
|
|
|
5
5
|
|
|
6
6
|
#include <jsi/jsi.h>
|
|
7
7
|
|
|
8
|
-
#include "api/JsiSkApi.h"
|
|
9
8
|
#include "RNSkJsiViewApi.h"
|
|
10
9
|
#include "RNSkView.h"
|
|
10
|
+
#include "api/JsiSkApi.h"
|
|
11
11
|
|
|
12
12
|
#include "jsi/RuntimeAwareCache.h"
|
|
13
13
|
|
|
14
14
|
#ifdef SK_GRAPHITE
|
|
15
15
|
#include "RNDawnContext.h"
|
|
16
|
+
#include "jsi/Promise.h"
|
|
16
17
|
#include "rnwgpu/ArrayBuffer.h"
|
|
17
18
|
#include "rnwgpu/api/GPU.h"
|
|
18
19
|
#include "rnwgpu/api/GPUUncapturedErrorEvent.h"
|
|
19
20
|
#include "rnwgpu/api/ImageBitmap.h"
|
|
20
21
|
#include "rnwgpu/api/RNWebGPU.h"
|
|
22
|
+
#include "rnwgpu/api/WebGPUConstants.h"
|
|
21
23
|
#include "rnwgpu/api/descriptors/GPUBufferUsage.h"
|
|
22
24
|
#include "rnwgpu/api/descriptors/GPUColorWrite.h"
|
|
23
25
|
#include "rnwgpu/api/descriptors/GPUMapMode.h"
|
|
24
26
|
#include "rnwgpu/api/descriptors/GPUShaderStage.h"
|
|
25
27
|
#include "rnwgpu/api/descriptors/GPUTextureUsage.h"
|
|
26
|
-
#include "rnwgpu/api/WebGPUConstants.h"
|
|
27
28
|
#include "rnwgpu/async/RuntimeContext.h"
|
|
28
|
-
#include "jsi2/Promise.h"
|
|
29
29
|
|
|
30
30
|
#include "include/core/SkData.h"
|
|
31
31
|
#include "include/core/SkImage.h"
|
|
@@ -82,19 +82,18 @@ void RNSkManager::installBindings() {
|
|
|
82
82
|
// provided runtime.
|
|
83
83
|
auto skiaApi = std::make_shared<JsiSkApi>(_platformContext);
|
|
84
84
|
_jsRuntime->global().setProperty(
|
|
85
|
-
*_jsRuntime, "SkiaApi",
|
|
86
|
-
jsi::Object::createFromHostObject(*_jsRuntime, std::move(skiaApi)));
|
|
85
|
+
*_jsRuntime, "SkiaApi", makeJsiObject(*_jsRuntime, std::move(skiaApi)));
|
|
87
86
|
|
|
88
|
-
_jsRuntime->global().setProperty(
|
|
89
|
-
|
|
90
|
-
jsi::Object::createFromHostObject(*_jsRuntime, _viewApi));
|
|
87
|
+
_jsRuntime->global().setProperty(*_jsRuntime, "SkiaViewApi",
|
|
88
|
+
makeJsiObject(*_jsRuntime, _viewApi));
|
|
91
89
|
|
|
92
90
|
#ifdef SK_GRAPHITE
|
|
93
91
|
// Register the main runtime + its CallInvoker so spontaneous events
|
|
94
92
|
// (device.lost / uncapturederror) on main-runtime devices can be delivered to
|
|
95
93
|
// the JS thread without the ProcessEvents pump. Worklet-runtime devices have
|
|
96
94
|
// no invoker (best-effort; see the RuntimeContext "Threading model" doc).
|
|
97
|
-
rnwgpu::async::RuntimeContext::registerMainRuntime(_jsRuntime,
|
|
95
|
+
rnwgpu::async::RuntimeContext::registerMainRuntime(_jsRuntime,
|
|
96
|
+
_jsCallInvoker);
|
|
98
97
|
|
|
99
98
|
// Install WebGPU constructors
|
|
100
99
|
rnwgpu::GPU::installConstructor(*_jsRuntime);
|
|
@@ -121,13 +120,14 @@ void RNSkManager::installBindings() {
|
|
|
121
120
|
// Install WebGPU constant objects as plain JS objects on the main runtime.
|
|
122
121
|
rnwgpu::installWebGPUConstants(*_jsRuntime);
|
|
123
122
|
|
|
124
|
-
// Install a global `installWebGPU()` host function so worklet runtimes can
|
|
125
|
-
// the same constants. A host function captured into a worklet is
|
|
126
|
-
// a SerializableHostFunction and re-created on the worklet
|
|
127
|
-
// runs there (its `rt` is the worklet runtime) and
|
|
128
|
-
// that runtime. The constants come from the native
|
|
129
|
-
// values stay a single source of truth across
|
|
130
|
-
// runtime that already has the globals is a
|
|
123
|
+
// Install a global `installWebGPU()` host function so worklet runtimes can
|
|
124
|
+
// get the same constants. A host function captured into a worklet is
|
|
125
|
+
// serialized as a SerializableHostFunction and re-created on the worklet
|
|
126
|
+
// runtime, so the body runs there (its `rt` is the worklet runtime) and
|
|
127
|
+
// installs the constants on that runtime. The constants come from the native
|
|
128
|
+
// wgpu::*Usage enums, so the values stay a single source of truth across
|
|
129
|
+
// every runtime. Calling it on a runtime that already has the globals is a
|
|
130
|
+
// safe, idempotent no-op.
|
|
131
131
|
_jsRuntime->global().setProperty(
|
|
132
132
|
*_jsRuntime, "installWebGPU",
|
|
133
133
|
jsi::Function::createFromHostFunction(
|
|
@@ -172,9 +172,8 @@ void RNSkManager::installBindings() {
|
|
|
172
172
|
bool isBufferSource = obj.isArrayBuffer(rt);
|
|
173
173
|
if (!isBufferSource && obj.hasProperty(rt, "buffer")) {
|
|
174
174
|
auto bufferProp = obj.getProperty(rt, "buffer");
|
|
175
|
-
isBufferSource =
|
|
176
|
-
|
|
177
|
-
bufferProp.getObject(rt).isArrayBuffer(rt);
|
|
175
|
+
isBufferSource = bufferProp.isObject() &&
|
|
176
|
+
bufferProp.getObject(rt).isArrayBuffer(rt);
|
|
178
177
|
}
|
|
179
178
|
if (!isBufferSource) {
|
|
180
179
|
throw jsi::JSError(rt, "createImageBitmap: unsupported source "
|
|
@@ -183,9 +182,9 @@ void RNSkManager::installBindings() {
|
|
|
183
182
|
}
|
|
184
183
|
// Validates bounds and THROWS synchronously on a spoofed view, so
|
|
185
184
|
// the bad pointer never reaches the copy below.
|
|
186
|
-
auto buffer =
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
auto buffer = rnwgpu::JSIConverter<
|
|
186
|
+
std::shared_ptr<rnwgpu::ArrayBuffer>>::fromJSI(rt, args[0],
|
|
187
|
+
false);
|
|
189
188
|
// Copy the encoded bytes off the JS-owned ArrayBuffer.
|
|
190
189
|
const uint8_t *bytes = buffer->data();
|
|
191
190
|
std::vector<uint8_t> encoded(bytes, bytes + buffer->size());
|
|
@@ -204,9 +203,8 @@ void RNSkManager::installBindings() {
|
|
|
204
203
|
}
|
|
205
204
|
const int w = image->width();
|
|
206
205
|
const int h = image->height();
|
|
207
|
-
auto info =
|
|
208
|
-
|
|
209
|
-
kUnpremul_SkAlphaType);
|
|
206
|
+
auto info = SkImageInfo::Make(w, h, kRGBA_8888_SkColorType,
|
|
207
|
+
kUnpremul_SkAlphaType);
|
|
210
208
|
std::vector<uint8_t> pixels(info.computeMinByteSize());
|
|
211
209
|
// nullptr context: decode/read on the CPU (raster).
|
|
212
210
|
if (!image->readPixels(nullptr, info, pixels.data(),
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
#include "RNSkView.h"
|
|
14
14
|
#include "jsi/ViewProperty.h"
|
|
15
15
|
|
|
16
|
+
#include "RNSkPlatformContext.h"
|
|
16
17
|
#include "api/JsiSkPicture.h"
|
|
17
18
|
#include "utils/RNSkLog.h"
|
|
18
|
-
#include "RNSkPlatformContext.h"
|
|
19
19
|
#include "utils/RNSkTimingInfo.h"
|
|
20
20
|
|
|
21
21
|
#pragma clang diagnostic push
|
package/cpp/rnwgpu/ArrayBuffer.h
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
#include <cstdint>
|
|
6
6
|
#include <memory>
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "jsi/JSIConverter.h"
|
|
9
9
|
|
|
10
10
|
namespace rnwgpu {
|
|
11
11
|
|
|
@@ -77,8 +77,7 @@ template <> struct JSIConverter<std::shared_ptr<ArrayBuffer>> {
|
|
|
77
77
|
const size_t byteLength = static_cast<size_t>(byteLengthValue);
|
|
78
78
|
|
|
79
79
|
// Overflow-safe bounds check: byteOffset + byteLength <= bufferSize.
|
|
80
|
-
if (byteOffset > bufferSize ||
|
|
81
|
-
byteLength > bufferSize - byteOffset) {
|
|
80
|
+
if (byteOffset > bufferSize || byteLength > bufferSize - byteOffset) {
|
|
82
81
|
throw std::runtime_error(
|
|
83
82
|
"ArrayBuffer::fromJSI: view bounds [byteOffset, byteOffset + "
|
|
84
83
|
"byteLength) exceed the backing ArrayBuffer size");
|
|
@@ -98,9 +97,9 @@ template <> struct JSIConverter<std::shared_ptr<ArrayBuffer>> {
|
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
return std::make_shared<ArrayBuffer>(
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
return std::make_shared<ArrayBuffer>(arrayBuffer.data(runtime) +
|
|
101
|
+
byteOffset,
|
|
102
|
+
byteLength, bytesPerElements);
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
}
|
package/cpp/rnwgpu/Canvas.h
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#include <memory>
|
|
4
4
|
|
|
5
|
-
#include "
|
|
5
|
+
#include "jsi/NativeObject.h"
|
|
6
6
|
|
|
7
7
|
namespace rnwgpu {
|
|
8
8
|
|
|
@@ -10,7 +10,9 @@ namespace jsi = facebook::jsi;
|
|
|
10
10
|
|
|
11
11
|
class Canvas : public NativeObject<Canvas> {
|
|
12
12
|
public:
|
|
13
|
-
|
|
13
|
+
// Note: not "Canvas" — that brand belongs to RNSkia::JsiSkCanvas, and
|
|
14
|
+
// boxing brands must be unique process-wide (see BoxedNativeObjectRegistry).
|
|
15
|
+
static constexpr const char *CLASS_NAME = "WebGPUCanvas";
|
|
14
16
|
|
|
15
17
|
Canvas(void *nativeSurface, int width, int height)
|
|
16
18
|
: NativeObject(CLASS_NAME), _nativeSurface(nativeSurface), _width(width),
|
package/cpp/rnwgpu/api/GPU.cpp
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
#include <vector>
|
|
9
9
|
|
|
10
10
|
#include "Convertors.h"
|
|
11
|
-
#include "
|
|
11
|
+
#include "jsi/JSIConverter.h"
|
|
12
12
|
#include "rnwgpu/async/RuntimeContext.h"
|
|
13
13
|
|
|
14
14
|
namespace rnwgpu {
|
|
@@ -40,9 +40,9 @@ async::AsyncTaskHandle GPU::requestAdapter(
|
|
|
40
40
|
const async::AsyncTaskHandle::RejectFunction &reject) {
|
|
41
41
|
_instance.RequestAdapter(
|
|
42
42
|
&aOptions, wgpu::CallbackMode::AllowProcessEvents,
|
|
43
|
-
[context, resolve,
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
[context, resolve, reject](wgpu::RequestAdapterStatus status,
|
|
44
|
+
wgpu::Adapter adapter,
|
|
45
|
+
wgpu::StringView message) {
|
|
46
46
|
if (message.length) {
|
|
47
47
|
fprintf(stderr, "%s", message.data);
|
|
48
48
|
}
|
package/cpp/rnwgpu/api/GPU.h
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
#include "GPUInternalError.h"
|
|
14
14
|
#include "GPUOutOfMemoryError.h"
|
|
15
15
|
#include "GPUValidationError.h"
|
|
16
|
-
#include "
|
|
16
|
+
#include "jsi/JSIConverter.h"
|
|
17
17
|
|
|
18
18
|
namespace rnwgpu {
|
|
19
19
|
|
|
@@ -147,8 +147,7 @@ async::AsyncTaskHandle GPUAdapter::requestDevice(
|
|
|
147
147
|
&deviceDesc, wgpu::CallbackMode::AllowProcessEvents,
|
|
148
148
|
[context, resolve, reject, label, creationRuntime,
|
|
149
149
|
deviceLostBinding](wgpu::RequestDeviceStatus status,
|
|
150
|
-
wgpu::Device device,
|
|
151
|
-
wgpu::StringView message) {
|
|
150
|
+
wgpu::Device device, wgpu::StringView message) {
|
|
152
151
|
if (message.length) {
|
|
153
152
|
fprintf(stderr, "%s", message.data);
|
|
154
153
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
#include "descriptors/Unions.h"
|
|
8
8
|
|
|
9
|
-
#include "
|
|
9
|
+
#include "jsi/NativeObject.h"
|
|
10
10
|
|
|
11
11
|
#include "rnwgpu/async/AsyncTaskHandle.h"
|
|
12
12
|
#include "rnwgpu/async/RuntimeContext.h"
|
|
@@ -33,9 +33,9 @@ public:
|
|
|
33
33
|
public:
|
|
34
34
|
std::string getBrand() { return CLASS_NAME; }
|
|
35
35
|
|
|
36
|
-
async::AsyncTaskHandle
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
async::AsyncTaskHandle
|
|
37
|
+
requestDevice(jsi::Runtime &runtime,
|
|
38
|
+
std::optional<std::shared_ptr<GPUDeviceDescriptor>> descriptor);
|
|
39
39
|
|
|
40
40
|
std::unordered_set<std::string> getFeatures();
|
|
41
41
|
std::shared_ptr<GPUSupportedLimits> getLimits();
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
#include "Convertors.h"
|
|
12
12
|
#include "NativeBufferUtils.h"
|
|
13
|
-
#include "
|
|
13
|
+
#include "jsi/JSIConverter.h"
|
|
14
14
|
|
|
15
15
|
#include "GPUFeatures.h"
|
|
16
16
|
#include "GPUInternalError.h"
|
|
@@ -363,9 +363,9 @@ async::AsyncTaskHandle GPUDevice::createComputePipelineAsync(
|
|
|
363
363
|
runtime, pipelineHolder);
|
|
364
364
|
});
|
|
365
365
|
} else {
|
|
366
|
-
std::string error =
|
|
367
|
-
|
|
368
|
-
|
|
366
|
+
std::string error = msg.length
|
|
367
|
+
? std::string(msg.data, msg.length)
|
|
368
|
+
: "Failed to create compute pipeline";
|
|
369
369
|
reject(std::move(error));
|
|
370
370
|
}
|
|
371
371
|
});
|
|
@@ -410,9 +410,8 @@ async::AsyncTaskHandle GPUDevice::createRenderPipelineAsync(
|
|
|
410
410
|
runtime, pipelineHolder);
|
|
411
411
|
});
|
|
412
412
|
} else {
|
|
413
|
-
std::string error =
|
|
414
|
-
|
|
415
|
-
: "Failed to create render pipeline";
|
|
413
|
+
std::string error = msg.length ? std::string(msg.data, msg.length)
|
|
414
|
+
: "Failed to create render pipeline";
|
|
416
415
|
reject(std::move(error));
|
|
417
416
|
}
|
|
418
417
|
});
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
#include "descriptors/Unions.h"
|
|
15
15
|
|
|
16
|
-
#include "
|
|
16
|
+
#include "jsi/NativeObject.h"
|
|
17
17
|
|
|
18
18
|
#include "rnwgpu/async/AsyncTaskHandle.h"
|
|
19
19
|
#include "rnwgpu/async/RuntimeContext.h"
|
|
@@ -240,8 +240,8 @@ private:
|
|
|
240
240
|
std::shared_ptr<async::RuntimeContext> _async;
|
|
241
241
|
std::string _label;
|
|
242
242
|
// Guards the device-lost state below. In the ProcessEvents model both
|
|
243
|
-
// notifyDeviceLost() (fired by Dawn during ProcessEvents) and getLost() run
|
|
244
|
-
// the owning runtime's own thread, but device destruction can also trigger
|
|
243
|
+
// notifyDeviceLost() (fired by Dawn during ProcessEvents) and getLost() run
|
|
244
|
+
// on the owning runtime's own thread, but device destruction can also trigger
|
|
245
245
|
// notifyDeviceLost() synchronously, so the mutex keeps these fields safe.
|
|
246
246
|
std::mutex _lostMutex;
|
|
247
247
|
std::optional<async::AsyncTaskHandle> _lostHandle;
|