@nativescript/canvas 2.0.0-webgpu.35 → 2.0.0-webgpu.37

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.
Files changed (56) hide show
  1. package/Canvas/common.d.ts +1 -1
  2. package/Canvas/common.js +24 -18
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.js.map +1 -1
  5. package/Canvas/index.ios.js +1 -1
  6. package/Canvas/index.ios.js.map +1 -1
  7. package/Canvas2D/CanvasRenderingContext2D/index.d.ts +2 -1
  8. package/Canvas2D/CanvasRenderingContext2D/index.js +1 -4
  9. package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
  10. package/ImageAsset/index.d.ts +4 -2
  11. package/ImageAsset/index.js +76 -6
  12. package/ImageAsset/index.js.map +1 -1
  13. package/WebGL/WebGLRenderingContext/common.d.ts +1 -1
  14. package/WebGL/WebGLRenderingContext/index.js +4 -3
  15. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  16. package/WebGPU/GPUCanvasContext.d.ts +2 -1
  17. package/WebGPU/GPUCanvasContext.js.map +1 -1
  18. package/WebGPU/GPUQueue.js +9 -0
  19. package/WebGPU/GPUQueue.js.map +1 -1
  20. package/WebGPU/GPURenderPassEncoder.d.ts +3 -0
  21. package/WebGPU/GPURenderPassEncoder.js +9 -0
  22. package/WebGPU/GPURenderPassEncoder.js.map +1 -1
  23. package/angular/esm2022/index.mjs +4 -4
  24. package/angular/fesm2022/nativescript-canvas-angular.mjs +4 -4
  25. package/angular/fesm2022/nativescript-canvas-angular.mjs.map +1 -1
  26. package/common.js.map +1 -1
  27. package/index.d.ts +2 -1
  28. package/index.js +2 -1
  29. package/index.js.map +1 -1
  30. package/package.json +1 -1
  31. package/platforms/android/canvas-release.aar +0 -0
  32. package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
  33. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  34. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +85 -0
  35. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  36. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +7293 -7997
  37. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  38. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +681 -681
  39. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  40. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +85 -0
  41. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  42. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  43. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +7293 -7997
  44. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +7293 -7997
  45. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +6 -6
  46. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  47. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +683 -683
  48. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +736 -736
  49. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +129 -0
  50. package/platforms/ios/src/cpp/CanvasJSIModule.h +2 -0
  51. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +572 -397
  52. package/platforms/ios/src/cpp/ImageAssetImpl.h +4 -0
  53. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +40 -8
  54. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +67 -0
  55. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +4 -0
  56. package/utils.d.ts +1 -1
@@ -61,6 +61,10 @@ public:
61
61
 
62
62
  static void FromBytesCb(const v8::FunctionCallbackInfo<v8::Value> &args);
63
63
 
64
+ static void FromEncodedBytesSync(const v8::FunctionCallbackInfo<v8::Value> &args);
65
+
66
+ static void FromEncodedBytesCb(const v8::FunctionCallbackInfo<v8::Value> &args);
67
+
64
68
  /* static void SaveSync(const v8::FunctionCallbackInfo<v8::Value> &args);
65
69
 
66
70
  static void SaveCb(const v8::FunctionCallbackInfo<v8::Value> &args);*/
@@ -91,7 +91,7 @@ v8::Local<v8::FunctionTemplate> GPUQueueImpl::GetCtor(v8::Isolate *isolate) {
91
91
 
92
92
  void
93
93
  GPUQueueImpl::GetLabel(v8::Local<v8::Name> name,
94
- const v8::PropertyCallbackInfo<v8::Value> &info) {
94
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
95
95
  auto ptr = GetPointer(info.This());
96
96
  if (ptr != nullptr) {
97
97
  auto label = canvas_native_webgpu_queue_get_label(ptr->queue_);
@@ -136,7 +136,9 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
136
136
  U8Buffer *buffer = nullptr;
137
137
  uint32_t width = 0;
138
138
  uint32_t height = 0;
139
- const ImageAsset* imageAsset = nullptr;
139
+ const ImageAsset *imageAsset = nullptr;
140
+ const WebGLState *gl = nullptr;
141
+ const CanvasRenderingContext2D *c2d = nullptr;
140
142
  if (sourceType == NativeType::ImageBitmap) {
141
143
  auto bitmap = ImageBitmapImpl::GetPointer(sourceSourceValue.As<v8::Object>());
142
144
  imageAsset = bitmap->GetImageAsset();
@@ -149,12 +151,14 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
149
151
  width = canvas_native_image_data_get_width(imageData->GetImageData());
150
152
  height = canvas_native_image_data_get_height(imageData->GetImageData());
151
153
  } else if (sourceType == NativeType::CanvasRenderingContext2D) {
152
- auto c2d = CanvasRenderingContext2DImpl::GetPointer(sourceSourceValue.As<v8::Object>());
154
+ auto ctx = CanvasRenderingContext2DImpl::GetPointer(sourceSourceValue.As<v8::Object>());
155
+ c2d = ctx->GetContext();
153
156
  } else if (sourceType == NativeType::WebGLRenderingContextBase) {
154
157
  auto webgl = WebGLRenderingContextBase::GetPointer(sourceSourceValue.As<v8::Object>());
158
+ gl = webgl->GetState();
155
159
  }
156
160
 
157
- if (buffer == nullptr && imageAsset == nullptr) {
161
+ if (buffer == nullptr && imageAsset == nullptr && gl == nullptr && c2d == nullptr) {
158
162
  // todo error ??
159
163
  return;
160
164
  }
@@ -260,7 +264,7 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
260
264
 
261
265
  CanvasExtent3d extent3D = ParseExtent3d(isolate, sizeVal);
262
266
 
263
- if (imageAsset != nullptr){
267
+ if (imageAsset != nullptr) {
264
268
  CanvasImageCopyImageAsset source{
265
269
  imageAsset,
266
270
  sourceOrigin,
@@ -269,8 +273,37 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
269
273
 
270
274
 
271
275
  canvas_native_webgpu_queue_copy_image_asset_to_texture(ptr->GetGPUQueue(), &source,
272
- &destination,
273
- &extent3D);
276
+ &destination,
277
+ &extent3D);
278
+ return;
279
+ }
280
+
281
+
282
+ if (c2d != nullptr) {
283
+ CanvasImageCopyCanvasRenderingContext2D source{
284
+ c2d,
285
+ sourceOrigin,
286
+ flipY,
287
+ };
288
+
289
+
290
+ canvas_native_webgpu_queue_copy_context_to_texture(ptr->GetGPUQueue(), &source,
291
+ &destination,
292
+ &extent3D);
293
+ return;
294
+ }
295
+
296
+ if (gl != nullptr) {
297
+ CanvasImageCopyWebGL source{
298
+ gl,
299
+ sourceOrigin,
300
+ flipY,
301
+ };
302
+
303
+
304
+ canvas_native_webgpu_queue_copy_webgl_to_texture(ptr->GetGPUQueue(), &source,
305
+ &destination,
306
+ &extent3D);
274
307
  return;
275
308
  }
276
309
 
@@ -279,7 +312,6 @@ void GPUQueueImpl::CopyExternalImageToTexture(const v8::FunctionCallbackInfo<v8:
279
312
  auto size = canvas_native_u8_buffer_get_length(buffer);
280
313
 
281
314
 
282
-
283
315
  if (data == nullptr || size == 0) {
284
316
  // todo error
285
317
  return;
@@ -79,6 +79,14 @@ v8::Local<v8::FunctionTemplate> GPURenderPassEncoderImpl::GetCtor(v8::Isolate *i
79
79
  ConvertToV8String(isolate, "drawIndirect"),
80
80
  v8::FunctionTemplate::New(isolate, &DrawIndirect));
81
81
 
82
+ tmpl->Set(
83
+ ConvertToV8String(isolate, "multiDrawIndexedIndirect"),
84
+ v8::FunctionTemplate::New(isolate, &MultiDrawIndexedIndirect));
85
+
86
+ tmpl->Set(
87
+ ConvertToV8String(isolate, "multiDrawIndirect"),
88
+ v8::FunctionTemplate::New(isolate, &MultiDrawIndirect));
89
+
82
90
  tmpl->Set(
83
91
  ConvertToV8String(isolate, "end"),
84
92
  v8::FunctionTemplate::New(isolate, &End));
@@ -291,6 +299,36 @@ GPURenderPassEncoderImpl::DrawIndexedIndirect(const v8::FunctionCallbackInfo<v8:
291
299
  }
292
300
 
293
301
 
302
+ }
303
+
304
+ void
305
+ GPURenderPassEncoderImpl::MultiDrawIndexedIndirect(
306
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
307
+ auto *ptr = GetPointer(args.This());
308
+ if (ptr == nullptr) {
309
+ return;
310
+ }
311
+
312
+ auto isolate = args.GetIsolate();
313
+ auto context = isolate->GetCurrentContext();
314
+
315
+ auto indirectBufferVal = args[0];
316
+ auto indirectOffsetVal = args[1];
317
+ auto countVal = args[2];
318
+
319
+
320
+ auto indirectBufferType = GetNativeType(indirectBufferVal);
321
+
322
+ if (indirectBufferType == NativeType::GPUBuffer) {
323
+ auto indirectBuffer = GPUBufferImpl::GetPointer(indirectBufferVal.As<v8::Object>());
324
+ uint64_t offset = (uint64_t) indirectOffsetVal->NumberValue(context).FromJust();
325
+ uint32_t count = countVal->Uint32Value(context).FromJust();
326
+ canvas_native_webgpu_render_pass_encoder_multi_draw_indexed_indirect(ptr->GetPass(),
327
+ indirectBuffer->GetGPUBuffer(),
328
+ offset, count);
329
+ }
330
+
331
+
294
332
  }
295
333
 
296
334
  void
@@ -318,6 +356,35 @@ GPURenderPassEncoderImpl::DrawIndirect(const v8::FunctionCallbackInfo<v8::Value>
318
356
  }
319
357
 
320
358
 
359
+ }
360
+
361
+ void
362
+ GPURenderPassEncoderImpl::MultiDrawIndirect(const v8::FunctionCallbackInfo<v8::Value> &args) {
363
+ auto *ptr = GetPointer(args.This());
364
+ if (ptr == nullptr) {
365
+ return;
366
+ }
367
+
368
+ auto isolate = args.GetIsolate();
369
+ auto context = isolate->GetCurrentContext();
370
+
371
+ auto indirectBufferVal = args[0];
372
+ auto indirectOffsetVal = args[1];
373
+ auto countVal = args[2];
374
+
375
+
376
+ auto indirectBufferType = GetNativeType(indirectBufferVal);
377
+
378
+ if (indirectBufferType == NativeType::GPUBuffer) {
379
+ auto indirectBuffer = GPUBufferImpl::GetPointer(indirectBufferVal.As<v8::Object>());
380
+ uint64_t offset = (uint64_t) indirectOffsetVal->NumberValue(context).FromJust();
381
+ uint32_t count = countVal->Uint32Value(context).FromJust();
382
+ canvas_native_webgpu_render_pass_encoder_multi_draw_indirect(ptr->GetPass(),
383
+ indirectBuffer->GetGPUBuffer(),
384
+ offset, count);
385
+ }
386
+
387
+
321
388
  }
322
389
 
323
390
  void GPURenderPassEncoderImpl::End(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -51,6 +51,10 @@ public:
51
51
 
52
52
  static void DrawIndirect(const v8::FunctionCallbackInfo<v8::Value> &args);
53
53
 
54
+ static void MultiDrawIndexedIndirect(const v8::FunctionCallbackInfo<v8::Value> &args);
55
+
56
+ static void MultiDrawIndirect(const v8::FunctionCallbackInfo<v8::Value> &args);
57
+
54
58
  static void End(const v8::FunctionCallbackInfo<v8::Value> &args);
55
59
 
56
60
  static void EndOcclusionQuery(const v8::FunctionCallbackInfo<v8::Value> &args);
package/utils.d.ts CHANGED
@@ -4,6 +4,6 @@ export declare class Utils {
4
4
  static _CHECKED_FOR_SUPPORT: boolean;
5
5
  static toJSArray(array: any): any[];
6
6
  static get IS_SUPPORTED_TYPED_ARRAYS_VERSION(): boolean;
7
- static isTypedArray(value: any): value is Uint32Array | Uint8Array | Uint8ClampedArray | Int8Array | Uint16Array | Int16Array | Int32Array | Float32Array;
7
+ static isTypedArray(value: any): value is Uint32Array | Uint8ClampedArray | Uint8Array | Int32Array | Float32Array | Int8Array | Uint16Array | Int16Array;
8
8
  }
9
9
  export default function lazy<T>(action: () => T): () => T;