@nativescript/canvas 2.0.0-webgpu.30 → 2.0.0-webgpu.33

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 (47) hide show
  1. package/Canvas/index.android.d.ts +6 -4
  2. package/Canvas/index.android.js +9 -5
  3. package/Canvas/index.android.js.map +1 -1
  4. package/Canvas/index.d.ts +2 -0
  5. package/Canvas/index.ios.d.ts +2 -0
  6. package/Canvas/index.ios.js +11 -13
  7. package/Canvas/index.ios.js.map +1 -1
  8. package/Canvas/utils.js +2 -2
  9. package/Canvas/utils.js.map +1 -1
  10. package/WebGL/WebGLRenderingContext/index.js +1 -0
  11. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  12. package/package.json +1 -1
  13. package/platforms/android/canvas-release.aar +0 -0
  14. package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
  15. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  16. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +22 -22
  17. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative.h +1 -0
  18. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/NSCMTLView.h +32 -0
  19. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +143 -182
  20. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +28 -10
  21. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  22. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +7178 -8061
  23. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +24 -23
  24. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +24 -23
  25. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  26. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +671 -690
  27. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  28. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +44 -44
  29. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative.h +1 -0
  30. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/NSCMTLView.h +32 -0
  31. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +143 -182
  32. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +28 -10
  33. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  34. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  35. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +7178 -8061
  36. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +24 -23
  37. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +24 -23
  38. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +7178 -8061
  39. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +24 -23
  40. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +24 -23
  41. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +39 -28
  42. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  43. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +673 -692
  44. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +726 -730
  45. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +17 -55
  46. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +6 -10
  47. package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.cpp +5 -5
@@ -346,23 +346,20 @@ SWIFT_CLASS_NAMED("CanvasHelpers")
346
346
  + (BOOL)drawImageWithContext:(int64_t)context image:(UIImage * _Nonnull)image dx:(float)dx dy:(float)dy SWIFT_WARN_UNUSED_RESULT;
347
347
  + (BOOL)drawImageWithContext:(int64_t)context image:(UIImage * _Nonnull)image dx:(float)dx dy:(float)dy dw:(float)dw dh:(float)dh SWIFT_WARN_UNUSED_RESULT;
348
348
  + (BOOL)drawImageWithContext:(int64_t)context image:(UIImage * _Nonnull)image sx:(float)sx sy:(float)sy sw:(float)sw sh:(float)sh dx:(float)dx dy:(float)dy dw:(float)dw dh:(float)dh SWIFT_WARN_UNUSED_RESULT;
349
- + (int64_t)initWebGPUWithViewLayer:(int64_t)instance :(int64_t)view :(uint32_t)width :(uint32_t)height SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
350
- + (int64_t)initWebGPUWithView:(int64_t)instance :(int64_t)view :(uint32_t)width :(uint32_t)height SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
351
- + (void)resizeWebGPUWithView:(int64_t)context :(int64_t)view :(uint32_t)width :(uint32_t)height;
352
- + (int64_t)initGLWithView:(int64_t)view :(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)fail_if_major_performance_caveat :(int32_t)power_preference :(BOOL)premultiplied_alpha :(BOOL)preserve_drawing_buffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xr_compatible :(int32_t)version :(BOOL)is_canvas SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
353
- + (int64_t)initSharedGLWithView:(int64_t)view :(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)fail_if_major_performance_caveat :(int32_t)power_preference :(BOOL)premultiplied_alpha :(BOOL)preserve_drawing_buffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xr_compatible :(int32_t)version :(BOOL)is_canvas :(int64_t)shared_context SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
354
- + (int64_t)initGLWithWidthAndHeight:(int32_t)width :(int32_t)height :(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)fail_if_major_performance_caveat :(int32_t)power_preference :(BOOL)premultiplied_alpha :(BOOL)preserve_drawing_buffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xr_compatible :(int32_t)version :(BOOL)is_canvas SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
355
- + (int64_t)initSharedGLWidthAndHeight:(int32_t)width :(int32_t)height :(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)fail_if_major_performance_caveat :(int32_t)power_preference :(BOOL)premultiplied_alpha :(BOOL)preserve_drawing_buffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xr_compatible :(int32_t)version :(BOOL)is_canvas :(int64_t)shared_context SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
349
+ + (int64_t)initWebGPUWithViewLayer:(int64_t)instance :(NSCCanvas * _Nonnull)view :(uint32_t)width :(uint32_t)height SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
350
+ + (int64_t)initWebGPUWithView:(int64_t)instance :(NSCCanvas * _Nonnull)view :(uint32_t)width :(uint32_t)height SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
351
+ + (void)resizeWebGPUWithView:(int64_t)context :(NSCCanvas * _Nonnull)view :(uint32_t)width :(uint32_t)height;
352
+ + (int64_t)initWebGLWithView:(NSCCanvas * _Nonnull)view :(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)fail_if_major_performance_caveat :(int32_t)power_preference :(BOOL)premultiplied_alpha :(BOOL)preserve_drawing_buffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xr_compatible :(int32_t)version SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
353
+ + (int64_t)initWebGLWithWidthAndHeight:(int32_t)width :(int32_t)height :(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)fail_if_major_performance_caveat :(int32_t)power_preference :(BOOL)premultiplied_alpha :(BOOL)preserve_drawing_buffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xr_compatible :(int32_t)version SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
356
354
  + (void)resize2DContext:(int64_t)context :(float)width :(float)height;
357
355
  + (void)flush2DContext:(int64_t)context;
358
- + (BOOL)flushGL:(int64_t)context SWIFT_WARN_UNUSED_RESULT;
359
- + (void)releaseGL:(int64_t)context;
360
- + (int64_t)getGLPointer:(int64_t)context SWIFT_WARN_UNUSED_RESULT;
361
- + (void)releaseGLPointer:(int64_t)context;
362
- + (int64_t)create2DContext:(int64_t)context :(int32_t)width :(int32_t)height :(BOOL)alpha :(float)density :(int32_t)samples :(int32_t)font_color :(float)ppi :(int32_t)direction SWIFT_WARN_UNUSED_RESULT;
363
- + (void)updateGLSurfaceWithView:(int64_t)view :(int32_t)width :(int32_t)height :(int64_t)context;
364
- + (void)test2D:(int64_t)context;
365
- + (NSString * _Nonnull)testToDataURL:(int64_t)context SWIFT_WARN_UNUSED_RESULT;
356
+ + (void)flush2DContextAndSyncCPU:(int64_t)context;
357
+ + (void)presentDrawable:(int64_t)context;
358
+ + (BOOL)flushWebGL:(int64_t)context SWIFT_WARN_UNUSED_RESULT;
359
+ + (void)releaseWebGL:(int64_t)context;
360
+ + (int64_t)create2DContext:(NSCCanvas * _Nonnull)view :(int32_t)width :(int32_t)height :(BOOL)alpha :(float)density :(int32_t)fontColor :(float)ppi :(int32_t)direction SWIFT_WARN_UNUSED_RESULT;
361
+ + (int64_t)create2DContextMetal:(NSCCanvas * _Nonnull)view :(BOOL)alpha :(float)density :(int32_t)fontColor :(float)ppi :(int32_t)direction SWIFT_WARN_UNUSED_RESULT;
362
+ + (void)updateWebGLSurfaceWithView:(int64_t)view :(int32_t)width :(int32_t)height :(int64_t)context;
366
363
  + (void)writeFile:(NSData * _Nonnull)data :(NSString * _Nonnull)path :(void (^ _Nonnull)(NSString * _Nullable, NSString * _Nullable))callback;
367
364
  + (void)readFile:(NSString * _Nonnull)path :(void (^ _Nonnull)(NSString * _Nullable, NSData * _Nullable))callback;
368
365
  + (void)deleteFile:(NSString * _Nonnull)path :(void (^ _Nonnull)(NSError * _Nullable, BOOL))callback;
@@ -383,15 +380,19 @@ enum CanvasFit : NSInteger;
383
380
 
384
381
  SWIFT_CLASS_NAMED("NSCCanvas")
385
382
  @interface NSCCanvas : UIView
383
+ SWIFT_CLASS_PROPERTY(@property (nonatomic, class) BOOL forceGL;)
384
+ + (BOOL)forceGL SWIFT_WARN_UNUSED_RESULT;
385
+ + (void)setForceGL:(BOOL)value;
386
386
  @property (nonatomic) enum CanvasFit fit;
387
387
  SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, strong) NSMutableDictionary * _Nonnull store;)
388
388
  + (NSMutableDictionary * _Nonnull)store SWIFT_WARN_UNUSED_RESULT;
389
389
  + (NSMapTable<NSString *, NSCCanvas *> * _Nonnull)getViews SWIFT_WARN_UNUSED_RESULT;
390
- - (void * _Nonnull)getViewPtr SWIFT_WARN_UNUSED_RESULT;
390
+ - (void * _Nonnull)getGlViewPtr SWIFT_WARN_UNUSED_RESULT;
391
391
  - (void * _Nonnull)getMtlViewPtr SWIFT_WARN_UNUSED_RESULT;
392
+ - (void * _Nonnull)getMtlLayerPtr SWIFT_WARN_UNUSED_RESULT;
392
393
  @property (nonatomic) BOOL autoScale;
393
- @property (nonatomic, readonly) int64_t nativeGL;
394
394
  @property (nonatomic, readonly) int64_t nativeContext;
395
+ @property (nonatomic, readonly) BOOL is2D;
395
396
  @property (nonatomic, readonly) CGFloat drawingBufferWidth;
396
397
  @property (nonatomic, readonly) CGFloat drawingBufferHeight;
397
398
  @property (nonatomic, readonly) float width;
@@ -401,15 +402,16 @@ SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, strong) NSMutableDic
401
402
  - (int64_t)create2DContext:(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)failIfMajorPerformanceCaveat :(int32_t)powerPreference :(BOOL)premultipliedAlpha :(BOOL)preserveDrawingBuffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xrCompatible :(int32_t)fontColor SWIFT_WARN_UNUSED_RESULT;
402
403
  - (UIImage * _Nullable)snapshot:(BOOL)flip SWIFT_WARN_UNUSED_RESULT;
403
404
  - (BOOL)render;
404
- - (void)context2DTest:(int64_t)context;
405
- - (NSString * _Nonnull)context2DTestToDataURL:(int64_t)context SWIFT_WARN_UNUSED_RESULT;
406
405
  @property (nonatomic, copy) void (^ _Nullable touchEventListener)(NSString * _Nonnull, UIGestureRecognizer * _Nonnull);
407
406
  - (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder SWIFT_UNAVAILABLE;
408
407
  - (nonnull instancetype)initWithFrame:(CGRect)frame OBJC_DESIGNATED_INITIALIZER;
408
+ @property (nonatomic) BOOL ignoreTouchEvents;
409
409
  - (void)setListener:(id <NSCCanvasListener> _Nullable)listener;
410
410
  @property (nonatomic) NSInteger surfaceWidth;
411
411
  @property (nonatomic) NSInteger surfaceHeight;
412
412
  - (void)forceLayout:(CGFloat)width :(CGFloat)height;
413
+ - (void)context2DTest:(int64_t)context;
414
+ - (void)context2DPathTest:(int64_t)context;
413
415
  - (void)layoutSubviews;
414
416
  + (void)getBoundingClientRect:(UIView * _Nonnull)view :(void * _Nonnull)buffer;
415
417
  @end
@@ -453,7 +455,7 @@ SWIFT_CLASS_NAMED("NSCCanvasUtils")
453
455
  + (CVOpenGLESTextureCacheRef _Nullable)createTextureCache SWIFT_WARN_UNUSED_RESULT;
454
456
  + (CVOpenGLESTextureRef _Nullable)createImage:(CVOpenGLESTextureCacheRef _Nonnull)texturecache :(CVImageBufferRef _Nonnull)buffer :(CFDictionaryRef _Nullable)textureAttributes :(GLenum)target :(GLint)internalFormat :(GLsizei)width :(GLsizei)height :(GLenum)format :(GLenum)type :(NSInteger)planeIndex SWIFT_WARN_UNUSED_RESULT;
455
457
  + (NSCRender * _Nonnull)setupRender SWIFT_WARN_UNUSED_RESULT;
456
- + (void)drawFrame:(AVPlayer * _Nonnull)player :(AVPlayerItemVideoOutput * _Nonnull)output :(CGSize)videoSize :(NSCRender * _Nonnull)render :(int32_t)internalFormat :(int32_t)format :(BOOL)flipYWebGL;
458
+ + (void)drawFrame:(AVPlayer * _Nonnull)player :(AVPlayerItemVideoOutput * _Nonnull)output :(CGSize)videoSize :(int32_t)internalFormat :(int32_t)format :(BOOL)flipYWebGL;
457
459
  + (BOOL)writeToFile:(NSData * _Nonnull)data :(NSString * _Nonnull)path error:(NSError * _Nullable * _Nullable)error;
458
460
  - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
459
461
  @end
@@ -480,8 +482,6 @@ SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, strong) dispatch_que
480
482
  SWIFT_CLASS_NAMED("NSCRender")
481
483
  @interface NSCRender : NSObject
482
484
  - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
483
- - (void)texImage2D:(int32_t)target :(int32_t)level :(int32_t)internalFormat :(int32_t)format :(int32_t)type :(NSCCanvas * _Nonnull)source :(NSCCanvas * _Nonnull)dest :(BOOL)flipYWebGL;
484
- - (void)createSurface;
485
485
  @end
486
486
 
487
487
 
@@ -872,23 +872,20 @@ SWIFT_CLASS_NAMED("CanvasHelpers")
872
872
  + (BOOL)drawImageWithContext:(int64_t)context image:(UIImage * _Nonnull)image dx:(float)dx dy:(float)dy SWIFT_WARN_UNUSED_RESULT;
873
873
  + (BOOL)drawImageWithContext:(int64_t)context image:(UIImage * _Nonnull)image dx:(float)dx dy:(float)dy dw:(float)dw dh:(float)dh SWIFT_WARN_UNUSED_RESULT;
874
874
  + (BOOL)drawImageWithContext:(int64_t)context image:(UIImage * _Nonnull)image sx:(float)sx sy:(float)sy sw:(float)sw sh:(float)sh dx:(float)dx dy:(float)dy dw:(float)dw dh:(float)dh SWIFT_WARN_UNUSED_RESULT;
875
- + (int64_t)initWebGPUWithViewLayer:(int64_t)instance :(int64_t)view :(uint32_t)width :(uint32_t)height SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
876
- + (int64_t)initWebGPUWithView:(int64_t)instance :(int64_t)view :(uint32_t)width :(uint32_t)height SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
877
- + (void)resizeWebGPUWithView:(int64_t)context :(int64_t)view :(uint32_t)width :(uint32_t)height;
878
- + (int64_t)initGLWithView:(int64_t)view :(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)fail_if_major_performance_caveat :(int32_t)power_preference :(BOOL)premultiplied_alpha :(BOOL)preserve_drawing_buffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xr_compatible :(int32_t)version :(BOOL)is_canvas SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
879
- + (int64_t)initSharedGLWithView:(int64_t)view :(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)fail_if_major_performance_caveat :(int32_t)power_preference :(BOOL)premultiplied_alpha :(BOOL)preserve_drawing_buffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xr_compatible :(int32_t)version :(BOOL)is_canvas :(int64_t)shared_context SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
880
- + (int64_t)initGLWithWidthAndHeight:(int32_t)width :(int32_t)height :(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)fail_if_major_performance_caveat :(int32_t)power_preference :(BOOL)premultiplied_alpha :(BOOL)preserve_drawing_buffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xr_compatible :(int32_t)version :(BOOL)is_canvas SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
881
- + (int64_t)initSharedGLWidthAndHeight:(int32_t)width :(int32_t)height :(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)fail_if_major_performance_caveat :(int32_t)power_preference :(BOOL)premultiplied_alpha :(BOOL)preserve_drawing_buffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xr_compatible :(int32_t)version :(BOOL)is_canvas :(int64_t)shared_context SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
875
+ + (int64_t)initWebGPUWithViewLayer:(int64_t)instance :(NSCCanvas * _Nonnull)view :(uint32_t)width :(uint32_t)height SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
876
+ + (int64_t)initWebGPUWithView:(int64_t)instance :(NSCCanvas * _Nonnull)view :(uint32_t)width :(uint32_t)height SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
877
+ + (void)resizeWebGPUWithView:(int64_t)context :(NSCCanvas * _Nonnull)view :(uint32_t)width :(uint32_t)height;
878
+ + (int64_t)initWebGLWithView:(NSCCanvas * _Nonnull)view :(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)fail_if_major_performance_caveat :(int32_t)power_preference :(BOOL)premultiplied_alpha :(BOOL)preserve_drawing_buffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xr_compatible :(int32_t)version SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
879
+ + (int64_t)initWebGLWithWidthAndHeight:(int32_t)width :(int32_t)height :(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)fail_if_major_performance_caveat :(int32_t)power_preference :(BOOL)premultiplied_alpha :(BOOL)preserve_drawing_buffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xr_compatible :(int32_t)version SWIFT_METHOD_FAMILY(none) SWIFT_WARN_UNUSED_RESULT;
882
880
  + (void)resize2DContext:(int64_t)context :(float)width :(float)height;
883
881
  + (void)flush2DContext:(int64_t)context;
884
- + (BOOL)flushGL:(int64_t)context SWIFT_WARN_UNUSED_RESULT;
885
- + (void)releaseGL:(int64_t)context;
886
- + (int64_t)getGLPointer:(int64_t)context SWIFT_WARN_UNUSED_RESULT;
887
- + (void)releaseGLPointer:(int64_t)context;
888
- + (int64_t)create2DContext:(int64_t)context :(int32_t)width :(int32_t)height :(BOOL)alpha :(float)density :(int32_t)samples :(int32_t)font_color :(float)ppi :(int32_t)direction SWIFT_WARN_UNUSED_RESULT;
889
- + (void)updateGLSurfaceWithView:(int64_t)view :(int32_t)width :(int32_t)height :(int64_t)context;
890
- + (void)test2D:(int64_t)context;
891
- + (NSString * _Nonnull)testToDataURL:(int64_t)context SWIFT_WARN_UNUSED_RESULT;
882
+ + (void)flush2DContextAndSyncCPU:(int64_t)context;
883
+ + (void)presentDrawable:(int64_t)context;
884
+ + (BOOL)flushWebGL:(int64_t)context SWIFT_WARN_UNUSED_RESULT;
885
+ + (void)releaseWebGL:(int64_t)context;
886
+ + (int64_t)create2DContext:(NSCCanvas * _Nonnull)view :(int32_t)width :(int32_t)height :(BOOL)alpha :(float)density :(int32_t)fontColor :(float)ppi :(int32_t)direction SWIFT_WARN_UNUSED_RESULT;
887
+ + (int64_t)create2DContextMetal:(NSCCanvas * _Nonnull)view :(BOOL)alpha :(float)density :(int32_t)fontColor :(float)ppi :(int32_t)direction SWIFT_WARN_UNUSED_RESULT;
888
+ + (void)updateWebGLSurfaceWithView:(int64_t)view :(int32_t)width :(int32_t)height :(int64_t)context;
892
889
  + (void)writeFile:(NSData * _Nonnull)data :(NSString * _Nonnull)path :(void (^ _Nonnull)(NSString * _Nullable, NSString * _Nullable))callback;
893
890
  + (void)readFile:(NSString * _Nonnull)path :(void (^ _Nonnull)(NSString * _Nullable, NSData * _Nullable))callback;
894
891
  + (void)deleteFile:(NSString * _Nonnull)path :(void (^ _Nonnull)(NSError * _Nullable, BOOL))callback;
@@ -909,15 +906,19 @@ enum CanvasFit : NSInteger;
909
906
 
910
907
  SWIFT_CLASS_NAMED("NSCCanvas")
911
908
  @interface NSCCanvas : UIView
909
+ SWIFT_CLASS_PROPERTY(@property (nonatomic, class) BOOL forceGL;)
910
+ + (BOOL)forceGL SWIFT_WARN_UNUSED_RESULT;
911
+ + (void)setForceGL:(BOOL)value;
912
912
  @property (nonatomic) enum CanvasFit fit;
913
913
  SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, strong) NSMutableDictionary * _Nonnull store;)
914
914
  + (NSMutableDictionary * _Nonnull)store SWIFT_WARN_UNUSED_RESULT;
915
915
  + (NSMapTable<NSString *, NSCCanvas *> * _Nonnull)getViews SWIFT_WARN_UNUSED_RESULT;
916
- - (void * _Nonnull)getViewPtr SWIFT_WARN_UNUSED_RESULT;
916
+ - (void * _Nonnull)getGlViewPtr SWIFT_WARN_UNUSED_RESULT;
917
917
  - (void * _Nonnull)getMtlViewPtr SWIFT_WARN_UNUSED_RESULT;
918
+ - (void * _Nonnull)getMtlLayerPtr SWIFT_WARN_UNUSED_RESULT;
918
919
  @property (nonatomic) BOOL autoScale;
919
- @property (nonatomic, readonly) int64_t nativeGL;
920
920
  @property (nonatomic, readonly) int64_t nativeContext;
921
+ @property (nonatomic, readonly) BOOL is2D;
921
922
  @property (nonatomic, readonly) CGFloat drawingBufferWidth;
922
923
  @property (nonatomic, readonly) CGFloat drawingBufferHeight;
923
924
  @property (nonatomic, readonly) float width;
@@ -927,15 +928,16 @@ SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, strong) NSMutableDic
927
928
  - (int64_t)create2DContext:(BOOL)alpha :(BOOL)antialias :(BOOL)depth :(BOOL)failIfMajorPerformanceCaveat :(int32_t)powerPreference :(BOOL)premultipliedAlpha :(BOOL)preserveDrawingBuffer :(BOOL)stencil :(BOOL)desynchronized :(BOOL)xrCompatible :(int32_t)fontColor SWIFT_WARN_UNUSED_RESULT;
928
929
  - (UIImage * _Nullable)snapshot:(BOOL)flip SWIFT_WARN_UNUSED_RESULT;
929
930
  - (BOOL)render;
930
- - (void)context2DTest:(int64_t)context;
931
- - (NSString * _Nonnull)context2DTestToDataURL:(int64_t)context SWIFT_WARN_UNUSED_RESULT;
932
931
  @property (nonatomic, copy) void (^ _Nullable touchEventListener)(NSString * _Nonnull, UIGestureRecognizer * _Nonnull);
933
932
  - (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder SWIFT_UNAVAILABLE;
934
933
  - (nonnull instancetype)initWithFrame:(CGRect)frame OBJC_DESIGNATED_INITIALIZER;
934
+ @property (nonatomic) BOOL ignoreTouchEvents;
935
935
  - (void)setListener:(id <NSCCanvasListener> _Nullable)listener;
936
936
  @property (nonatomic) NSInteger surfaceWidth;
937
937
  @property (nonatomic) NSInteger surfaceHeight;
938
938
  - (void)forceLayout:(CGFloat)width :(CGFloat)height;
939
+ - (void)context2DTest:(int64_t)context;
940
+ - (void)context2DPathTest:(int64_t)context;
939
941
  - (void)layoutSubviews;
940
942
  + (void)getBoundingClientRect:(UIView * _Nonnull)view :(void * _Nonnull)buffer;
941
943
  @end
@@ -979,7 +981,7 @@ SWIFT_CLASS_NAMED("NSCCanvasUtils")
979
981
  + (CVOpenGLESTextureCacheRef _Nullable)createTextureCache SWIFT_WARN_UNUSED_RESULT;
980
982
  + (CVOpenGLESTextureRef _Nullable)createImage:(CVOpenGLESTextureCacheRef _Nonnull)texturecache :(CVImageBufferRef _Nonnull)buffer :(CFDictionaryRef _Nullable)textureAttributes :(GLenum)target :(GLint)internalFormat :(GLsizei)width :(GLsizei)height :(GLenum)format :(GLenum)type :(NSInteger)planeIndex SWIFT_WARN_UNUSED_RESULT;
981
983
  + (NSCRender * _Nonnull)setupRender SWIFT_WARN_UNUSED_RESULT;
982
- + (void)drawFrame:(AVPlayer * _Nonnull)player :(AVPlayerItemVideoOutput * _Nonnull)output :(CGSize)videoSize :(NSCRender * _Nonnull)render :(int32_t)internalFormat :(int32_t)format :(BOOL)flipYWebGL;
984
+ + (void)drawFrame:(AVPlayer * _Nonnull)player :(AVPlayerItemVideoOutput * _Nonnull)output :(CGSize)videoSize :(int32_t)internalFormat :(int32_t)format :(BOOL)flipYWebGL;
983
985
  + (BOOL)writeToFile:(NSData * _Nonnull)data :(NSString * _Nonnull)path error:(NSError * _Nullable * _Nullable)error;
984
986
  - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
985
987
  @end
@@ -1006,8 +1008,6 @@ SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, strong) dispatch_que
1006
1008
  SWIFT_CLASS_NAMED("NSCRender")
1007
1009
  @interface NSCRender : NSObject
1008
1010
  - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
1009
- - (void)texImage2D:(int32_t)target :(int32_t)level :(int32_t)internalFormat :(int32_t)format :(int32_t)type :(NSCCanvas * _Nonnull)source :(NSCCanvas * _Nonnull)dest :(BOOL)flipYWebGL;
1010
- - (void)createSurface;
1011
1011
  @end
1012
1012
 
1013
1013
 
@@ -13,6 +13,7 @@ extern "C" {
13
13
 
14
14
  #import "canvas_native.h"
15
15
  #import "canvas_ios.h"
16
+ #import "NSCMTLView.h"
16
17
 
17
18
  //! Project version number for CanvasNative.
18
19
 
@@ -0,0 +1,32 @@
1
+ //
2
+ // NSCMTLView.h
3
+ // CanvasNative
4
+ //
5
+ // Created by Osei Fortune on 08/10/2024.
6
+ //
7
+ #ifndef NSCMTLView_h
8
+ #define NSCMTLView_h
9
+
10
+ #import <Foundation/Foundation.h>
11
+ #import <UIKit/UIKit.h>
12
+ #import <MetalKit/MetalKit.h>
13
+ typedef enum {
14
+ kNone,
15
+ kPending,
16
+ kInvalidating
17
+ } NSCSurfaceState;
18
+
19
+ @interface NSCMTLView : UIView
20
+ @property(weak, nonatomic) UIView* canvas;
21
+ @property id<MTLCommandQueue> queue;
22
+ @property int state;
23
+ @property (nonatomic) CGSize drawableSize;
24
+ @property NSUInteger sampleCount;
25
+ -(void) present;
26
+ -(void) setup;
27
+ -(void*) getDevicePtr;
28
+ -(void*) getQueuePtr;
29
+ @end
30
+
31
+
32
+ #endif /* NSCMTLView_h */
@@ -8,196 +8,107 @@
8
8
  #include <stdint.h>
9
9
  #include <stdlib.h>
10
10
 
11
- long long canvas_native_init_ios_webgpu(int64_t instance,
12
- int64_t view,
13
- uint32_t width,
14
- uint32_t height);
11
+ long long canvas_native_ios_create_webgl_context(void *view,
12
+ bool alpha,
13
+ bool antialias,
14
+ bool depth,
15
+ bool fail_if_major_performance_caveat,
16
+ int32_t power_preference,
17
+ bool premultiplied_alpha,
18
+ bool preserve_drawing_buffer,
19
+ bool stencil,
20
+ bool desynchronized,
21
+ bool xr_compatible,
22
+ uint32_t version);
23
+
24
+ bool canvas_native_ios_flush_webgl(int64_t context);
15
25
 
16
- #if defined(TARGET_OS_IOS)
17
- long long canvas_native_init_ios_webgpu_uiview(int64_t instance,
18
- int64_t view,
19
- uint32_t width,
20
- uint32_t height);
21
- #endif
26
+ void canvas_native_ios_flush_2d_context(int64_t context);
22
27
 
23
- #if defined(TARGET_OS_IOS)
24
- void canvas_native_resize_ios_webgpu_uiview(int64_t context,
25
- int64_t view,
26
- uint32_t width,
27
- uint32_t height);
28
- #endif
28
+ void canvas_native_ios_present_drawable(int64_t context);
29
29
 
30
- long long canvas_native_init_ios_gl(int64_t view,
31
- bool alpha,
32
- bool antialias,
33
- bool depth,
34
- bool fail_if_major_performance_caveat,
35
- int32_t power_preference,
36
- bool premultiplied_alpha,
37
- bool preserve_drawing_buffer,
38
- bool stencil,
39
- bool desynchronized,
40
- bool xr_compatible,
41
- int32_t version,
42
- bool is_canvas);
43
-
44
- long long canvas_native_init_ios_gl_with_shared_gl(int64_t view,
45
- bool alpha,
46
- bool antialias,
47
- bool depth,
48
- bool fail_if_major_performance_caveat,
49
- int32_t power_preference,
50
- bool premultiplied_alpha,
51
- bool preserve_drawing_buffer,
52
- bool stencil,
53
- bool desynchronized,
54
- bool xr_compatible,
55
- int32_t version,
56
- bool is_canvas,
57
- int64_t shared_context);
58
-
59
- long long canvas_native_init_offscreen_ios_gl(int32_t width,
60
- int32_t height,
61
- bool alpha,
62
- bool antialias,
63
- bool depth,
64
- bool fail_if_major_performance_caveat,
65
- int32_t power_preference,
66
- bool premultiplied_alpha,
67
- bool preserve_drawing_buffer,
68
- bool stencil,
69
- bool desynchronized,
70
- bool xr_compatible,
71
- int32_t version,
72
- bool is_canvas);
73
-
74
- long long canvas_native_init_offscreen_ios_gl_with_shared_gl(int32_t width,
75
- int32_t height,
76
- bool alpha,
77
- bool antialias,
78
- bool depth,
79
- bool fail_if_major_performance_caveat,
80
- int32_t power_preference,
81
- bool premultiplied_alpha,
82
- bool preserve_drawing_buffer,
83
- bool stencil,
84
- bool desynchronized,
85
- bool xr_compatible,
86
- int32_t version,
87
- bool is_canvas,
88
- int64_t shared_context);
89
-
90
- bool canvas_native_ios_flush_gl(int64_t context);
30
+ void canvas_native_ios_flush_2d_context_and_sync_cpu(int64_t context);
91
31
 
92
- void canvas_native_ios_flush_2d_context(int64_t context);
32
+ void canvas_native_ios_resize_context_2d(int64_t context, float width, float height);
33
+
34
+ int64_t canvas_native_ios_create_2d_context(void *view,
35
+ int32_t width,
36
+ int32_t height,
37
+ bool alpha,
38
+ float density,
39
+ int32_t font_color,
40
+ float ppi,
41
+ int32_t direction);
42
+
43
+ void canvas_native_ios_update_webgl_surface(int64_t view,
44
+ int32_t _width,
45
+ int32_t _height,
46
+ int64_t context);
47
+
48
+ void canvas_native_ios_release_webgl(int64_t context);
49
+
50
+ void canvas_native_ios_gl_make_current(int64_t context);
93
51
 
94
- void canvas_native_resize_context_2d(int64_t context, float width, float height);
95
-
96
- int64_t canvas_native_create_2d_context(int64_t context,
97
- int32_t width,
98
- int32_t height,
99
- bool alpha,
100
- float density,
101
- int32_t samples,
102
- int32_t font_color,
103
- float ppi,
104
- int32_t direction);
105
-
106
- void canvas_native_update_gl_surface(int64_t view, int32_t width, int32_t height, int64_t context);
107
-
108
- void canvas_native_release_ios_gl(int64_t context);
109
-
110
- int64_t canvas_native_get_gl_pointer(int64_t gl_context);
111
-
112
- void canvas_native_release_gl_pointer(int64_t gl_context);
113
-
114
- void canvas_native_context_2d_test(int64_t context);
115
-
116
- void canvas_native_gl_make_current(int64_t gl_context);
117
-
118
- char *canvas_native_context_2d_test_to_data_url(int64_t context);
119
-
120
- void canvas_native_context_2d_destroy_string(char *string);
121
-
122
- bool canvas_native_imageasset_load_from_bytes(int64_t asset, uint8_t *bytes, uintptr_t size);
123
-
124
- int64_t canvas_native_context_create_pattern_raw(int64_t context,
125
- int32_t width,
126
- int32_t height,
127
- uint8_t *bytes,
128
- uintptr_t size,
129
- const char *repetition);
130
-
131
- bool canvas_native_context_draw_image_dx_dy_with_bytes(int64_t context,
132
- uint8_t *bytes,
133
- uintptr_t size,
134
- float width,
135
- float height,
136
- float dx,
137
- float dy);
138
-
139
- bool canvas_native_context_draw_image_dx_dy_dw_dh_with_bytes(int64_t context,
140
- uint8_t *bytes,
141
- uintptr_t size,
142
- float width,
143
- float height,
144
- float dx,
145
- float dy,
146
- float d_width,
147
- float d_height);
148
-
149
- bool canvas_native_context_draw_image_with_bytes(int64_t context,
150
- uint8_t *bytes,
151
- uintptr_t size,
152
- float width,
153
- float height,
154
- float sx,
155
- float sy,
156
- float s_width,
157
- float s_height,
158
- float dx,
159
- float dy,
160
- float d_width,
161
- float d_height);
162
-
163
- void canvas_native_context_custom_with_buffer_flush(int64_t context,
164
- uint8_t *bytes,
165
- uintptr_t size,
166
- float width,
167
- float height,
168
- bool alpha);
169
-
170
- long long canvas_native_context_init_context_with_custom_surface(float width,
52
+ bool canvas_native_ios_image_asset_load_from_bytes(int64_t asset, uint8_t *bytes, uintptr_t size);
53
+
54
+ int64_t canvas_native_ios_context_create_pattern_raw(int64_t context,
55
+ int32_t width,
56
+ int32_t height,
57
+ uint8_t *bytes,
58
+ uintptr_t size,
59
+ const char *repetition);
60
+
61
+ bool canvas_native_ios_context_draw_image_dx_dy_with_bytes(int64_t context,
62
+ uint8_t *bytes,
63
+ uintptr_t size,
64
+ float width,
65
+ float height,
66
+ float dx,
67
+ float dy);
68
+
69
+ bool canvas_native_ios_context_draw_image_dx_dy_dw_dh_with_bytes(int64_t context,
70
+ uint8_t *bytes,
71
+ uintptr_t size,
72
+ float width,
171
73
  float height,
172
- float density,
173
- bool alpha,
174
- int font_color,
175
- float ppi,
176
- int direction);
177
-
178
- int64_t canvas_native_context_get_texture_from_2d(int64_t context);
179
-
180
- uint32_t canvas_native_context_backend_texture_get_id(int64_t texture);
181
-
182
- void canvas_native_context_backend_texture_destroy(int64_t texture);
183
-
184
- void canvas_native_webgl_tex_image_2d(int64_t context,
185
- int32_t target,
186
- int32_t level,
187
- int32_t internalformat,
188
- int32_t format,
189
- int32_t type_,
190
- uint8_t *bytes,
191
- uintptr_t size,
192
- float width,
193
- float height,
194
- bool flip_y);
195
-
196
- void canvas_native_webgl_tex_sub_image_2d(int64_t context,
74
+ float dx,
75
+ float dy,
76
+ float d_width,
77
+ float d_height);
78
+
79
+ bool canvas_native_ios_context_draw_image_with_bytes(int64_t context,
80
+ uint8_t *bytes,
81
+ uintptr_t size,
82
+ float width,
83
+ float height,
84
+ float sx,
85
+ float sy,
86
+ float s_width,
87
+ float s_height,
88
+ float dx,
89
+ float dy,
90
+ float d_width,
91
+ float d_height);
92
+
93
+ void canvas_native_ios_context_custom_with_buffer_flush(int64_t context,
94
+ uint8_t *bytes,
95
+ uintptr_t size,
96
+ float width,
97
+ float height,
98
+ bool alpha);
99
+
100
+ long long canvas_native_ios_context_init_context_with_custom_surface(float width,
101
+ float height,
102
+ float density,
103
+ bool alpha,
104
+ int font_color,
105
+ float ppi,
106
+ int direction);
107
+
108
+ void canvas_native_ios_webgl_tex_image_2d(int64_t context,
197
109
  int32_t target,
198
110
  int32_t level,
199
- int32_t xoffset,
200
- int32_t yoffset,
111
+ int32_t internalformat,
201
112
  int32_t format,
202
113
  int32_t type_,
203
114
  uint8_t *bytes,
@@ -206,4 +117,54 @@ void canvas_native_webgl_tex_sub_image_2d(int64_t context,
206
117
  float height,
207
118
  bool flip_y);
208
119
 
120
+ void canvas_native_ios_webgl_tex_sub_image_2d(int64_t context,
121
+ int32_t target,
122
+ int32_t level,
123
+ int32_t xoffset,
124
+ int32_t yoffset,
125
+ int32_t format,
126
+ int32_t type_,
127
+ uint8_t *bytes,
128
+ uintptr_t size,
129
+ float width,
130
+ float height,
131
+ bool flip_y);
132
+
133
+ int64_t canvas_native_ios_create_2d_context_metal(void *view,
134
+ bool alpha,
135
+ float density,
136
+ uintptr_t samples,
137
+ int32_t font_color,
138
+ float ppi,
139
+ int32_t direction);
140
+
141
+ int64_t canvas_native_ios_create_2d_context_metal_device_queue(void *view,
142
+ void *device,
143
+ void *queue,
144
+ bool alpha,
145
+ float density,
146
+ uintptr_t samples,
147
+ int32_t font_color,
148
+ float ppi,
149
+ int32_t direction);
150
+
151
+ long long canvas_native_init_ios_webgpu(int64_t instance,
152
+ void *view,
153
+ uint32_t width,
154
+ uint32_t height);
155
+
156
+ #if defined(TARGET_OS_MACOS)
157
+ long long canvas_native_init_ios_webgpu_nsview(int64_t instance,
158
+ void *view,
159
+ uint32_t width,
160
+ uint32_t height);
161
+ #endif
162
+
163
+ #if defined(TARGET_OS_IOS)
164
+ void canvas_native_resize_ios_webgpu_uiview(int64_t context,
165
+ void *view,
166
+ uint32_t width,
167
+ uint32_t height);
168
+ #endif
169
+
209
170
  #endif /* CANVAS_IOS_H */