@nativescript/canvas 2.0.0-alpha.20 → 2.0.0-alpha.22

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 (234) hide show
  1. package/Canvas/common.d.ts +2 -0
  2. package/Canvas/common.js +6 -0
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +0 -2
  5. package/Canvas/index.android.js +8 -24
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.d.ts +7 -0
  8. package/Canvas/index.ios.d.ts +0 -2
  9. package/Canvas/index.ios.js +7 -26
  10. package/Canvas/index.ios.js.map +1 -1
  11. package/Canvas2D/CanvasGradient/index.d.ts +1 -3
  12. package/Canvas2D/CanvasGradient/index.js +1 -10
  13. package/Canvas2D/CanvasGradient/index.js.map +1 -1
  14. package/Canvas2D/CanvasPattern/index.d.ts +1 -3
  15. package/Canvas2D/CanvasPattern/index.js +1 -10
  16. package/Canvas2D/CanvasPattern/index.js.map +1 -1
  17. package/Canvas2D/CanvasRenderingContext2D/index.d.ts +0 -2
  18. package/Canvas2D/CanvasRenderingContext2D/index.js +120 -138
  19. package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
  20. package/Canvas2D/DOMMatrix/index.js +3 -3
  21. package/Canvas2D/DOMMatrix/index.js.map +1 -1
  22. package/Canvas2D/ImageData/index.js +5 -5
  23. package/Canvas2D/ImageData/index.js.map +1 -1
  24. package/Canvas2D/Path2D/index.d.ts +0 -2
  25. package/Canvas2D/Path2D/index.js +34 -39
  26. package/Canvas2D/Path2D/index.js.map +1 -1
  27. package/ImageAsset/index.d.ts +2 -2
  28. package/ImageAsset/index.js +33 -37
  29. package/ImageAsset/index.js.map +1 -1
  30. package/ImageBitmap/index.d.ts +0 -2
  31. package/ImageBitmap/index.js +23 -29
  32. package/ImageBitmap/index.js.map +1 -1
  33. package/SVG/SVG.js +1 -1
  34. package/TextDecoder/index.d.ts +0 -2
  35. package/TextDecoder/index.js +3 -12
  36. package/TextDecoder/index.js.map +1 -1
  37. package/TextEncoder/index.d.ts +0 -2
  38. package/TextEncoder/index.js +4 -13
  39. package/TextEncoder/index.js.map +1 -1
  40. package/WebGL/WebGLExtensions/index.d.ts +0 -9
  41. package/WebGL/WebGLExtensions/index.js +17 -74
  42. package/WebGL/WebGLExtensions/index.js.map +1 -1
  43. package/WebGL/WebGLRenderingContext/common.d.ts +0 -2
  44. package/WebGL/WebGLRenderingContext/common.js +0 -10
  45. package/WebGL/WebGLRenderingContext/common.js.map +1 -1
  46. package/WebGL/WebGLRenderingContext/index.js +159 -298
  47. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  48. package/WebGL2/WebGL2RenderingContext/index.js +107 -195
  49. package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
  50. package/angular/esm2020/index.mjs +5 -5
  51. package/angular/fesm2015/nativescript-canvas-angular.mjs +4 -4
  52. package/angular/fesm2015/nativescript-canvas-angular.mjs.map +1 -1
  53. package/angular/fesm2020/nativescript-canvas-angular.mjs +4 -4
  54. package/angular/fesm2020/nativescript-canvas-angular.mjs.map +1 -1
  55. package/index.js.map +1 -1
  56. package/package.json +1 -1
  57. package/platforms/android/canvas-release.aar +0 -0
  58. package/platforms/android/include.gradle +15 -0
  59. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  60. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +87 -57
  61. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative.h +10 -0
  62. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +142 -0
  63. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2589 -110
  64. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  65. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  66. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +1174 -89
  67. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +2 -2
  68. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  69. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +2 -2
  70. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  71. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  72. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +174 -114
  73. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative.h +10 -0
  74. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +142 -0
  75. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2589 -110
  76. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  77. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  78. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  79. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +1174 -89
  80. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +2 -2
  81. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  82. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -2
  83. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +1174 -89
  84. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +2 -2
  85. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  86. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +2 -2
  87. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +42 -31
  88. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  89. package/platforms/ios/Podfile +3 -0
  90. package/platforms/ios/build.xcconfig +3 -3
  91. package/platforms/ios/src/CanvasModule.h +0 -2
  92. package/platforms/ios/src/CanvasModule.mm +4 -4
  93. package/platforms/ios/src/NSOperationQueueWrapper.h +11 -0
  94. package/platforms/ios/src/NSOperationQueueWrapper.mm +74 -0
  95. package/platforms/ios/src/cpp/Caches.cpp +35 -0
  96. package/platforms/ios/src/cpp/Caches.h +186 -0
  97. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +1582 -0
  98. package/platforms/ios/src/cpp/CanvasJSIModule.h +7 -34
  99. package/platforms/ios/src/cpp/Common.h +30 -0
  100. package/platforms/ios/src/cpp/ConcurrentMap.h +54 -0
  101. package/platforms/ios/src/cpp/Helpers.h +304 -38
  102. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +802 -0
  103. package/platforms/ios/src/cpp/ImageAssetImpl.h +44 -12
  104. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +189 -0
  105. package/platforms/ios/src/cpp/ImageBitmapImpl.h +22 -16
  106. package/platforms/ios/src/cpp/JSICallback.h +61 -5
  107. package/platforms/ios/src/cpp/JSIReadFileCallback.h +86 -6
  108. package/platforms/ios/src/cpp/JSIRuntime.cpp +21 -0
  109. package/platforms/ios/src/cpp/JSIRuntime.h +7 -0
  110. package/platforms/ios/src/cpp/OneByteStringResource.cpp +25 -0
  111. package/platforms/ios/src/cpp/OneByteStringResource.h +21 -0
  112. package/platforms/ios/src/cpp/RafImpl.cpp +8 -0
  113. package/platforms/ios/src/cpp/RafImpl.h +11 -8
  114. package/platforms/ios/src/cpp/TextDecoderImpl.cpp +188 -0
  115. package/platforms/ios/src/cpp/TextDecoderImpl.h +20 -14
  116. package/platforms/ios/src/cpp/TextEncoderImpl.cpp +139 -0
  117. package/platforms/ios/src/cpp/TextEncoderImpl.h +20 -11
  118. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.cpp +71 -0
  119. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +27 -13
  120. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +89 -0
  121. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +26 -13
  122. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +2391 -0
  123. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +264 -21
  124. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +203 -0
  125. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +26 -12
  126. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +800 -0
  127. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +172 -13
  128. package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +449 -0
  129. package/platforms/ios/src/cpp/canvas2d/Path2D.h +41 -12
  130. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.cpp +253 -0
  131. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.h +50 -12
  132. package/platforms/ios/src/cpp/gl.h +57 -7
  133. package/platforms/ios/src/cpp/gl3stub.c +425 -0
  134. package/platforms/ios/src/cpp/gl3stub.h +665 -0
  135. package/platforms/ios/src/cpp/gles3jni.h +37 -0
  136. package/platforms/ios/src/cpp/include/robin_hood.h +2544 -0
  137. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.cpp +93 -0
  138. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +33 -13
  139. package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +41 -6
  140. package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +46 -10
  141. package/platforms/ios/src/cpp/webgl/WebGLProgram.h +40 -5
  142. package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +40 -6
  143. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +6457 -0
  144. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +261 -390
  145. package/platforms/ios/src/cpp/webgl/{WebGLRenderingContextBase.mm → WebGLRenderingContextBase.cpp} +17 -16
  146. package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.h +15 -36
  147. package/platforms/ios/src/cpp/webgl/WebGLShader.h +40 -6
  148. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.cpp +50 -0
  149. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +66 -11
  150. package/platforms/ios/src/cpp/webgl/WebGLTexture.h +40 -6
  151. package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +44 -8
  152. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.cpp +126 -0
  153. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +25 -12
  154. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.cpp +35 -0
  155. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +25 -5
  156. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.cpp +41 -0
  157. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +25 -5
  158. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.cpp +323 -0
  159. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +47 -13
  160. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +49 -6
  161. package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +37 -15
  162. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +47 -6
  163. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +49 -6
  164. package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +36 -15
  165. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +44 -6
  166. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +38 -15
  167. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +37 -16
  168. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +41 -6
  169. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +40 -16
  170. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.cpp +102 -0
  171. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +69 -14
  172. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +51 -8
  173. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +49 -6
  174. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +49 -8
  175. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +76 -6
  176. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +57 -6
  177. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +53 -6
  178. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +59 -6
  179. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +46 -6
  180. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.cpp +43 -0
  181. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +126 -14
  182. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.cpp +32 -0
  183. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +61 -12
  184. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +4380 -0
  185. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +139 -343
  186. package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +40 -4
  187. package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +42 -3
  188. package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +44 -11
  189. package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +42 -4
  190. package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +43 -4
  191. package/platforms/ios/src/module.modulemap +1 -0
  192. package/platforms/ios/src/cpp/CanvasJSIModule.mm +0 -1105
  193. package/platforms/ios/src/cpp/ImageAssetImpl.mm +0 -417
  194. package/platforms/ios/src/cpp/ImageBitmapImpl.mm +0 -126
  195. package/platforms/ios/src/cpp/RafImpl.mm +0 -10
  196. package/platforms/ios/src/cpp/TextDecoderImpl.mm +0 -97
  197. package/platforms/ios/src/cpp/TextEncoderImpl.mm +0 -60
  198. package/platforms/ios/src/cpp/VecMutableBuffer.h +0 -46
  199. package/platforms/ios/src/cpp/canvas-cxx/src/lib.rs.cc +0 -6156
  200. package/platforms/ios/src/cpp/canvas-cxx/src/lib.rs.h +0 -2867
  201. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.mm +0 -42
  202. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.mm +0 -49
  203. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.mm +0 -1972
  204. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.mm +0 -68
  205. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.mm +0 -149
  206. package/platforms/ios/src/cpp/canvas2d/Path2D.mm +0 -335
  207. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.mm +0 -68
  208. package/platforms/ios/src/cpp/rust/cxx.cc +0 -793
  209. package/platforms/ios/src/cpp/rust/cxx.h +0 -1111
  210. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.mm +0 -39
  211. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.mm +0 -5958
  212. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.mm +0 -40
  213. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.mm +0 -108
  214. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.mm +0 -28
  215. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.mm +0 -42
  216. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.mm +0 -295
  217. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.mm +0 -40
  218. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.mm +0 -37
  219. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.mm +0 -28
  220. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.mm +0 -31
  221. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.mm +0 -28
  222. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.mm +0 -127
  223. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.mm +0 -45
  224. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.mm +0 -45
  225. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.mm +0 -31
  226. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.mm +0 -70
  227. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.mm +0 -47
  228. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.mm +0 -46
  229. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.mm +0 -49
  230. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.mm +0 -30
  231. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.mm +0 -177
  232. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.mm +0 -64
  233. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.mm +0 -4551
  234. /package/platforms/ios/src/cpp/{OnRafCallback.mm → OnRafCallback.cpp} +0 -0
@@ -4,9 +4,9 @@
4
4
 
5
5
  #include "WebGLRenderingContextBase.h"
6
6
 
7
- WebGLRenderingContextBase::WebGLRenderingContextBase(rust::Box<WebGLState> state,
7
+ WebGLRenderingContextBase::WebGLRenderingContextBase(WebGLState* state,
8
8
  WebGLRenderingVersion version)
9
- : state_(std::move(state)), version_(version) {
9
+ : state_(state), version_(version) {
10
10
 
11
11
 
12
12
  auto ctx_ptr = reinterpret_cast<intptr_t>(reinterpret_cast<intptr_t *>(this));
@@ -14,14 +14,11 @@ WebGLRenderingContextBase::WebGLRenderingContextBase(rust::Box<WebGLState> state
14
14
  ctx_ptr,
15
15
  version == WebGLRenderingVersion::V2 ? 2 : 1);
16
16
  auto raf_callback_ptr = reinterpret_cast<intptr_t>(reinterpret_cast<intptr_t *>(raf_callback));
17
- auto raf = canvas_native_raf_create(
18
- raf_callback_ptr);
17
+ auto raf = canvas_native_raf_create(raf_callback_ptr, OnRafCallbackOnFrame);
19
18
  this->SetRaf(
20
19
  std::make_shared<RafImpl>(
21
20
  raf_callback,
22
- raf_callback_ptr,
23
- std::move(
24
- raf)));
21
+ raf_callback_ptr, raf));
25
22
 
26
23
  auto _raf = this->GetRaf();
27
24
 
@@ -29,7 +26,6 @@ WebGLRenderingContextBase::WebGLRenderingContextBase(rust::Box<WebGLState> state
29
26
  canvas_native_raf_start(_raf->GetRaf());
30
27
  }
31
28
 
32
- UpdateBindings();
33
29
  }
34
30
 
35
31
 
@@ -52,6 +48,7 @@ void WebGLRenderingContextBase::StopRaf() {
52
48
  }
53
49
  }
54
50
 
51
+
55
52
  void WebGLRenderingContextBase::UpdateInvalidateState() {
56
53
  auto raf = this->GetRaf();
57
54
  if (raf != nullptr) {
@@ -60,16 +57,16 @@ void WebGLRenderingContextBase::UpdateInvalidateState() {
60
57
  }
61
58
  }
62
59
  auto state = this->GetInvalidateState();
63
- this->SetInvalidateState(state | (int) InvalidateState::PENDING);
60
+ this->SetInvalidateState(state | (int) InvalidateState::InvalidateStatePending);
64
61
  }
65
62
 
66
63
  void WebGLRenderingContextBase::Flush() {
67
- auto state = this->GetInvalidateState() & (int) InvalidateState::PENDING;
68
- if (state == (int) InvalidateState::PENDING) {
69
- this->SetInvalidateState((int) InvalidateState::INVALIDATING);
64
+ auto state = this->GetInvalidateState() & (int) InvalidateState::InvalidateStatePending;
65
+ if (state == (int) InvalidateState::InvalidateStatePending) {
66
+ this->SetInvalidateState((int) InvalidateState::InvalidateStateInvalidating);
70
67
  canvas_native_webgl_make_current(this->GetState());
71
68
  canvas_native_webgl_swap_buffers(this->GetState());
72
- this->SetInvalidateState((int) InvalidateState::NONE);
69
+ this->SetInvalidateState((int) InvalidateState::InvalidateStateNone);
73
70
  }
74
71
  }
75
72
 
@@ -80,8 +77,8 @@ void WebGLRenderingContextBase::Flush(intptr_t context) {
80
77
  }
81
78
  }
82
79
 
83
- WebGLState &WebGLRenderingContextBase::GetState() {
84
- return *this->state_;
80
+ WebGLState* WebGLRenderingContextBase::GetState() {
81
+ return this->state_;
85
82
  }
86
83
 
87
84
  void WebGLRenderingContextBase::SetRaf(std::shared_ptr<RafImpl> raf) {
@@ -113,6 +110,10 @@ WebGLRenderingContextBase::~WebGLRenderingContextBase() {
113
110
  auto _raf = this->GetRaf();
114
111
  if (_raf != nullptr) {
115
112
  canvas_native_raf_stop(
116
- _raf->GetRaf());
113
+ _raf->GetRaf());
117
114
  }
115
+ canvas_native_raf_destroy(_raf->GetRaf());
116
+ this->raf_ = nullptr;
117
+ canvas_native_webgl_state_destroy(this->GetState());
118
+ this->state_ = nullptr;
118
119
  }
@@ -5,29 +5,31 @@
5
5
  #pragma once
6
6
  #pragma process_pending_includes
7
7
 
8
- #import <NativeScript/JSIRuntime.h>
9
- #include "rust/cxx.h"
10
8
  #include <vector>
11
9
  #include <cstdint>
12
10
  #include <memory>
13
- #include "canvas-cxx/src/lib.rs.h"
14
11
 
15
12
  #include "Helpers.h"
16
13
  #include "RafImpl.h"
17
14
  #include "OnRafCallback.h"
18
- #include "gl.h"
15
+ #include "Common.h"
19
16
 
20
17
  enum class WebGLRenderingVersion : uint8_t {
21
18
  V1,
22
19
  V2
23
20
  };
24
21
 
25
- using namespace facebook;
26
- using namespace org::nativescript::canvas;
27
-
28
- class WebGLRenderingContextBase : public jsi::HostObject {
22
+ class WebGLRenderingContextBase {
29
23
  public:
30
- WebGLRenderingContextBase(rust::Box<WebGLState> state, WebGLRenderingVersion version);
24
+ WebGLRenderingContextBase(WebGLState* state, WebGLRenderingVersion version);
25
+
26
+ static WebGLRenderingContextBase *GetPointer(const v8::Local<v8::Object> &object) {
27
+ auto ptr = object->GetInternalField(0).As<v8::External>()->Value();
28
+ if (ptr == nullptr) {
29
+ return nullptr;
30
+ }
31
+ return static_cast<WebGLRenderingContextBase *>(ptr);
32
+ }
31
33
 
32
34
  ~WebGLRenderingContextBase();
33
35
 
@@ -43,48 +45,25 @@ public:
43
45
 
44
46
  static void Flush(intptr_t context);
45
47
 
46
- WebGLState &GetState();
48
+ WebGLState* GetState();
47
49
 
48
50
  void SetRaf(std::shared_ptr<RafImpl> raf);
49
51
 
50
52
  RafImpl *GetRaf();
51
53
 
52
54
  WebGLRenderingVersion GetVersion() const;
53
-
54
- int GetDisplayFramebuffer(){
55
- return displayFramebuffer_;
56
- }
57
55
 
58
- int GetDisplayRenderbuffer(){
59
- return displayRenderbuffer_;
60
- }
61
-
62
56
  void StartRaf();
57
+
63
58
  void StopRaf();
64
-
65
- void UpdateBindings(){
66
- auto displayFramebuffer = canvas_native_webgl_get_parameter(GL_FRAMEBUFFER_BINDING, *state_);
67
-
68
- auto displayRenderbuffer = canvas_native_webgl_get_parameter(GL_RENDERER, *state_);
69
-
70
- if(!canvas_native_webgl_result_get_is_none(*displayFramebuffer)){
71
- displayFramebuffer_ = canvas_native_webgl_result_get_i32(*displayFramebuffer);
72
- }
73
-
74
- if(!canvas_native_webgl_result_get_is_none(*displayRenderbuffer)){
75
- displayRenderbuffer_ = canvas_native_webgl_result_get_i32(*displayRenderbuffer);
76
- }
77
- }
78
59
 
79
60
  private:
80
- rust::Box<WebGLState> state_;
61
+ WebGLState* state_;
81
62
 
82
63
  WebGLRenderingVersion version_;
83
64
 
84
- int invalidateState_ = static_cast<int>(InvalidateState::NONE);
65
+ int invalidateState_ = static_cast<int>(InvalidateState::InvalidateStateNone);
85
66
 
86
67
  std::shared_ptr<RafImpl> raf_;
87
- int displayFramebuffer_;
88
- int displayRenderbuffer_;
89
68
  };
90
69
 
@@ -4,16 +4,50 @@
4
4
 
5
5
  #pragma once
6
6
 
7
- #include "rust/cxx.h"
8
- #include "canvas-cxx/src/lib.rs.h"
9
- #import <NativeScript/JSIRuntime.h>
7
+ #include "Helpers.h"
10
8
 
11
- using namespace facebook;
12
-
13
- class JSI_EXPORT WebGLShader : public jsi::HostObject {
9
+ class WebGLShader {
14
10
  public:
15
11
  WebGLShader(uint32_t shader) : shader_(shader) {}
16
12
 
13
+ static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate) {
14
+ auto cache = Caches::Get(isolate);
15
+ auto ctor = cache->WebGLShaderTmpl.get();
16
+ if (ctor != nullptr) {
17
+ return ctor->Get(isolate);
18
+ }
19
+
20
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
21
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1);
22
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "WebGLShader"));
23
+
24
+ auto tmpl = ctorTmpl->InstanceTemplate();
25
+ tmpl->SetInternalFieldCount(1);
26
+
27
+ cache->WebGLShaderTmpl =
28
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
29
+ return ctorTmpl;
30
+ }
31
+
32
+ static v8::Local<v8::Object> NewInstance(v8::Isolate *isolate, WebGLShader *shader) {
33
+ auto context = isolate->GetCurrentContext();
34
+ v8::EscapableHandleScope scope(isolate);
35
+ auto object = WebGLShader::GetCtor(isolate)->GetFunction(
36
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
37
+ SetNativeType(isolate, object, NativeType::WebGLShader);
38
+ auto ext = v8::External::New(isolate, shader);
39
+ object->SetInternalField(0, ext);
40
+ return scope.Escape(object);
41
+ }
42
+
43
+ static WebGLShader *GetPointer(const v8::Local<v8::Object> &object) {
44
+ auto ptr = object->GetInternalField(0).As<v8::External>()->Value();
45
+ if (ptr == nullptr) {
46
+ return nullptr;
47
+ }
48
+ return static_cast<WebGLShader *>(ptr);
49
+ }
50
+
17
51
  uint32_t GetShader() {
18
52
  return this->shader_;
19
53
  }
@@ -0,0 +1,50 @@
1
+ //
2
+ // Created by Osei Fortune on 27/04/2022.
3
+ //
4
+
5
+ #include "WebGLShaderPrecisionFormatImpl.h"
6
+
7
+ WebGLShaderPrecisionFormatImpl::WebGLShaderPrecisionFormatImpl(
8
+ WebGLShaderPrecisionFormat* shader) : shader_(shader) {}
9
+
10
+
11
+ void WebGLShaderPrecisionFormatImpl::GetRangeMin(v8::Local<v8::String> property,
12
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
13
+ WebGLShaderPrecisionFormatImpl *ptr = GetPointer(info.This());
14
+ if (ptr == nullptr) {
15
+ info.GetReturnValue().Set(0);
16
+ return;
17
+ }
18
+
19
+ info.GetReturnValue().Set((double) canvas_native_webgl_shader_precision_format_get_range_min(
20
+ ptr->GetShaderPrecisionFormat()));
21
+ }
22
+
23
+ void WebGLShaderPrecisionFormatImpl::GetRangeMax(v8::Local<v8::String> property,
24
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
25
+ WebGLShaderPrecisionFormatImpl *ptr = GetPointer(info.This());
26
+ if (ptr == nullptr) {
27
+ info.GetReturnValue().Set(0);
28
+ return;
29
+ }
30
+
31
+ info.GetReturnValue().Set((double) canvas_native_webgl_shader_precision_format_get_range_max(
32
+ ptr->GetShaderPrecisionFormat()));
33
+ }
34
+
35
+
36
+ void WebGLShaderPrecisionFormatImpl::GetPrecision(v8::Local<v8::String> property,
37
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
38
+ WebGLShaderPrecisionFormatImpl *ptr = GetPointer(info.This());
39
+ if (ptr == nullptr) {
40
+ info.GetReturnValue().Set(0);
41
+ return;
42
+ }
43
+
44
+ info.GetReturnValue().Set((double) canvas_native_webgl_shader_precision_format_get_precision(
45
+ ptr->GetShaderPrecisionFormat()));
46
+ }
47
+
48
+ WebGLShaderPrecisionFormat* WebGLShaderPrecisionFormatImpl::GetShaderPrecisionFormat() {
49
+ return this->shader_;
50
+ }
@@ -4,25 +4,80 @@
4
4
 
5
5
  #pragma once
6
6
 
7
- #include "rust/cxx.h"
8
- #include "canvas-cxx/src/lib.rs.h"
9
- #import <NativeScript/JSIRuntime.h>
10
7
  #include <vector>
8
+ #include "Helpers.h"
9
+ #include "Caches.h"
10
+ #include "Common.h"
11
11
 
12
- using namespace facebook;
13
- using namespace org::nativescript::canvas;
14
12
 
15
- class WebGLShaderPrecisionFormatImpl : public jsi::HostObject {
13
+ class WebGLShaderPrecisionFormatImpl {
16
14
  public:
17
- WebGLShaderPrecisionFormatImpl(rust::Box<WebGLShaderPrecisionFormat> shader);
15
+ WebGLShaderPrecisionFormatImpl(WebGLShaderPrecisionFormat* shader);
16
+
17
+ ~WebGLShaderPrecisionFormatImpl() {
18
+ canvas_native_webgl_shader_precision_format_destroy(this->GetShaderPrecisionFormat());
19
+ this->shader_ = nullptr;
20
+ }
18
21
 
19
- jsi::Value get(jsi::Runtime &, const jsi::PropNameID &name) override;
22
+ static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate) {
23
+ auto cache = Caches::Get(isolate);
24
+ auto ctor = cache->WebGLShaderPrecisionFormatTmpl.get();
25
+ if (ctor != nullptr) {
26
+ return ctor->Get(isolate);
27
+ }
20
28
 
21
- std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
29
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
30
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1);
31
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "WebGLShaderPrecisionFormat"));
22
32
 
23
- WebGLShaderPrecisionFormat &GetShaderPrecisionFormat();
33
+ auto tmpl = ctorTmpl->InstanceTemplate();
34
+ tmpl->SetInternalFieldCount(1);
35
+
36
+ tmpl->SetAccessor(ConvertToV8String(isolate, "rangeMin"), &GetRangeMin);
37
+ tmpl->SetAccessor(ConvertToV8String(isolate, "rangeMax"), &GetRangeMax);
38
+ tmpl->SetAccessor(ConvertToV8String(isolate, "precision"), &GetPrecision);
39
+
40
+ tmpl->Set(ConvertToV8String(isolate, "ext_name"),
41
+ ConvertToV8String(isolate, "WebGLShaderPrecisionFormat"));
42
+
43
+ cache->WebGLShaderPrecisionFormatTmpl =
44
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
45
+ return ctorTmpl;
46
+ }
47
+
48
+ static v8::Local<v8::Object>
49
+ NewInstance(v8::Isolate *isolate, WebGLShaderPrecisionFormatImpl *shaderPrecisionFormat) {
50
+ auto context = isolate->GetCurrentContext();
51
+ v8::EscapableHandleScope scope(isolate);
52
+ auto object = WebGLShaderPrecisionFormatImpl::GetCtor(isolate)->GetFunction(
53
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
54
+ SetNativeType(isolate, object, NativeType::WebGLShaderPrecisionFormat);
55
+ auto ext = v8::External::New(isolate, shaderPrecisionFormat);
56
+ object->SetInternalField(0, ext);
57
+ return scope.Escape(object);
58
+ }
59
+
60
+ static WebGLShaderPrecisionFormatImpl *GetPointer(const v8::Local<v8::Object> &object) {
61
+ auto ptr = object->GetInternalField(0).As<v8::External>()->Value();
62
+ if (ptr == nullptr) {
63
+ return nullptr;
64
+ }
65
+ return static_cast<WebGLShaderPrecisionFormatImpl *>(ptr);
66
+ }
67
+
68
+
69
+ static void GetRangeMin(v8::Local<v8::String> property,
70
+ const v8::PropertyCallbackInfo<v8::Value> &info);
71
+
72
+ static void GetRangeMax(v8::Local<v8::String> property,
73
+ const v8::PropertyCallbackInfo<v8::Value> &info);
74
+
75
+ static void GetPrecision(v8::Local<v8::String> property,
76
+ const v8::PropertyCallbackInfo<v8::Value> &info);
77
+
78
+ WebGLShaderPrecisionFormat* GetShaderPrecisionFormat();
24
79
 
25
80
  private:
26
- rust::Box<WebGLShaderPrecisionFormat> shader_;
81
+ WebGLShaderPrecisionFormat* shader_;
27
82
  };
28
83
 
@@ -4,16 +4,50 @@
4
4
 
5
5
  #pragma once
6
6
 
7
- #include "rust/cxx.h"
8
- #include "canvas-cxx/src/lib.rs.h"
9
- #import <NativeScript/JSIRuntime.h>
7
+ #include "Helpers.h"
10
8
 
11
- using namespace facebook;
12
-
13
- class JSI_EXPORT WebGLTexture : public jsi::HostObject {
9
+ class WebGLTexture {
14
10
  public:
15
11
  WebGLTexture(uint32_t texture) : texture_(texture) {}
16
12
 
13
+ static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate) {
14
+ auto cache = Caches::Get(isolate);
15
+ auto ctor = cache->WebGLTextureTmpl.get();
16
+ if (ctor != nullptr) {
17
+ return ctor->Get(isolate);
18
+ }
19
+
20
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
21
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1);
22
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "WebGLTexture"));
23
+
24
+ auto tmpl = ctorTmpl->InstanceTemplate();
25
+ tmpl->SetInternalFieldCount(1);
26
+
27
+ cache->WebGLTextureTmpl =
28
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
29
+ return ctorTmpl;
30
+ }
31
+
32
+ static v8::Local<v8::Object> NewInstance(v8::Isolate *isolate, WebGLTexture *texture) {
33
+ auto context = isolate->GetCurrentContext();
34
+ v8::EscapableHandleScope scope(isolate);
35
+ auto object = WebGLTexture::GetCtor(isolate)->GetFunction(
36
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
37
+ SetNativeType(isolate, object, NativeType::WebGLTexture);
38
+ auto ext = v8::External::New(isolate, texture);
39
+ object->SetInternalField(0, ext);
40
+ return scope.Escape(object);
41
+ }
42
+
43
+ static WebGLTexture *GetPointer(const v8::Local<v8::Object> &object) {
44
+ auto ptr = object->GetInternalField(0).As<v8::External>()->Value();
45
+ if (ptr == nullptr) {
46
+ return nullptr;
47
+ }
48
+ return static_cast<WebGLTexture *>(ptr);
49
+ }
50
+
17
51
  uint32_t GetTexture() {
18
52
  return this->texture_;
19
53
  }
@@ -4,21 +4,57 @@
4
4
 
5
5
  #pragma once
6
6
 
7
- #include "rust/cxx.h"
8
- #include "canvas-cxx/src/lib.rs.h"
9
- #import <NativeScript/JSIRuntime.h>
7
+ #include "Helpers.h"
8
+ #include "Common.h"
9
+ #include "Caches.h"
10
10
 
11
- using namespace facebook;
12
11
 
13
-
14
- class JSI_EXPORT WebGLUniformLocation
15
-
16
- : public jsi::HostObject {
12
+ class WebGLUniformLocation {
17
13
  public:
18
14
  WebGLUniformLocation(int32_t
19
15
  uniformLocation) :
20
16
  uniformLocation_(uniformLocation) {}
21
17
 
18
+
19
+ static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate) {
20
+ auto cache = Caches::Get(isolate);
21
+ auto ctor = cache->WebGLUniformLocationTmpl.get();
22
+ if (ctor != nullptr) {
23
+ return ctor->Get(isolate);
24
+ }
25
+
26
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
27
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1);
28
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "WebGLUniformLocation"));
29
+
30
+ auto tmpl = ctorTmpl->InstanceTemplate();
31
+ tmpl->SetInternalFieldCount(1);
32
+
33
+ cache->WebGLUniformLocationTmpl =
34
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
35
+ return ctorTmpl;
36
+ }
37
+
38
+ static v8::Local<v8::Object>
39
+ NewInstance(v8::Isolate *isolate, WebGLUniformLocation *uniformLocation) {
40
+ auto context = isolate->GetCurrentContext();
41
+ v8::EscapableHandleScope scope(isolate);
42
+ auto object = WebGLUniformLocation::GetCtor(isolate)->GetFunction(
43
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
44
+ SetNativeType(isolate, object, NativeType::WebGLUniformLocation);
45
+ auto ext = v8::External::New(isolate, uniformLocation);
46
+ object->SetInternalField(0, ext);
47
+ return scope.Escape(object);
48
+ }
49
+
50
+ static WebGLUniformLocation *GetPointer(const v8::Local<v8::Object> &object) {
51
+ auto ptr = object->GetInternalField(0).As<v8::External>()->Value();
52
+ if (ptr == nullptr) {
53
+ return nullptr;
54
+ }
55
+ return static_cast<WebGLUniformLocation *>(ptr);
56
+ }
57
+
22
58
  int32_t GetUniformLocation() {
23
59
  return this->uniformLocation_;
24
60
  }
@@ -0,0 +1,126 @@
1
+ //
2
+ // Created by Osei Fortune on 29/04/2022.
3
+ //
4
+
5
+ #include "ANGLE_instanced_arraysImpl.h"
6
+ #include "Caches.h"
7
+
8
+ ANGLE_instanced_arraysImpl::ANGLE_instanced_arraysImpl(ANGLE_instanced_arrays * arrays)
9
+ : arrays_(arrays) {}
10
+
11
+ ANGLE_instanced_arraysImpl *
12
+ ANGLE_instanced_arraysImpl::GetPointer(const v8::Local<v8::Object> &object) {
13
+ auto ptr = object->GetInternalField(0).As<v8::External>()->Value();
14
+ if (ptr == nullptr) {
15
+ return nullptr;
16
+ }
17
+ return static_cast<ANGLE_instanced_arraysImpl *>(ptr);
18
+ }
19
+
20
+ void ANGLE_instanced_arraysImpl::DrawArraysInstancedANGLE(
21
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
22
+ ANGLE_instanced_arraysImpl *ptr = GetPointer(args.This());
23
+ if (ptr == nullptr) {
24
+ return;
25
+ }
26
+ auto isolate = args.GetIsolate();
27
+ auto context = isolate->GetCurrentContext();
28
+
29
+ auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
30
+ auto first = (int32_t) args[1]->NumberValue(context).ToChecked();
31
+ auto count_ = (int32_t) args[2]->NumberValue(context).ToChecked();
32
+ auto primcount = (int32_t) args[3]->NumberValue(context).ToChecked();
33
+
34
+ canvas_native_webgl_angle_instanced_arrays_draw_arrays_instanced_angle(
35
+ mode,
36
+ first,
37
+ count_,
38
+ primcount,
39
+ ptr->GetArrays()
40
+ );
41
+ }
42
+
43
+ void ANGLE_instanced_arraysImpl::DrawElementsInstancedANGLE(
44
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
45
+ ANGLE_instanced_arraysImpl *ptr = GetPointer(args.This());
46
+ if (ptr == nullptr) {
47
+ return;
48
+ }
49
+ auto isolate = args.GetIsolate();
50
+ auto context = isolate->GetCurrentContext();
51
+
52
+ auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
53
+ auto count_ = (int32_t) args[1]->NumberValue(context).ToChecked();
54
+ auto type = (uint32_t) args[2]->NumberValue(context).ToChecked();
55
+ auto offset = (int32_t) args[3]->NumberValue(context).ToChecked();
56
+ auto primcount = (int32_t) args[4]->NumberValue(context).ToChecked();
57
+ canvas_native_webgl_angle_instanced_arrays_draw_elements_instanced_angle(
58
+ mode,
59
+ count_,
60
+ type,
61
+ offset,
62
+ primcount,
63
+ ptr->GetArrays()
64
+ );
65
+ }
66
+
67
+ void ANGLE_instanced_arraysImpl::VertexAttribDivisorANGLE(
68
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
69
+ ANGLE_instanced_arraysImpl *ptr = GetPointer(args.This());
70
+ if (ptr == nullptr) {
71
+ return;
72
+ }
73
+ auto isolate = args.GetIsolate();
74
+ auto context = isolate->GetCurrentContext();
75
+
76
+ auto index = (u_int32_t) args[0]->NumberValue(context).ToChecked();
77
+ auto divisor = (u_int32_t) args[1]->NumberValue(context).ToChecked();
78
+ canvas_native_webgl_angle_instanced_arrays_vertex_attrib_divisor_angle(
79
+ index,
80
+ divisor,
81
+ ptr->GetArrays()
82
+ );
83
+ }
84
+
85
+
86
+ v8::Local<v8::FunctionTemplate> ANGLE_instanced_arraysImpl::GetCtor(v8::Isolate *isolate) {
87
+ auto cache = Caches::Get(isolate);
88
+ auto ctor = cache->ANGLE_instanced_arraysTmpl.get();
89
+ if (ctor != nullptr) {
90
+ return ctor->Get(isolate);
91
+ }
92
+
93
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
94
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1);
95
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "ANGLE_instanced_arrays"));
96
+
97
+ auto tmpl = ctorTmpl->InstanceTemplate();
98
+ tmpl->SetInternalFieldCount(1);
99
+
100
+ tmpl->Set(ConvertToV8String(isolate, "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE"),
101
+ v8::Number::New(isolate, 0x88FE));
102
+
103
+ tmpl->Set(ConvertToV8String(isolate, "ext_name"),
104
+ ConvertToV8String(isolate, "ANGLE_instanced_arrays"));
105
+
106
+ tmpl->Set(
107
+ ConvertToV8String(isolate, "drawArraysInstancedANGLE"),
108
+ v8::FunctionTemplate::New(isolate, &DrawArraysInstancedANGLE));
109
+
110
+ tmpl->Set(
111
+ ConvertToV8String(isolate, "drawElementsInstancedANGLE"),
112
+ v8::FunctionTemplate::New(isolate, &DrawElementsInstancedANGLE));
113
+
114
+ tmpl->Set(
115
+ ConvertToV8String(isolate, "vertexAttribDivisorANGLE"),
116
+ v8::FunctionTemplate::New(isolate, &VertexAttribDivisorANGLE));
117
+
118
+
119
+ cache->ANGLE_instanced_arraysTmpl =
120
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
121
+ return ctorTmpl;
122
+ }
123
+
124
+ ANGLE_instanced_arrays* ANGLE_instanced_arraysImpl::GetArrays() {
125
+ return this->arrays_;
126
+ }
@@ -3,26 +3,39 @@
3
3
  //
4
4
 
5
5
  #pragma once
6
-
7
- #include "rust/cxx.h"
8
- #include "canvas-cxx/src/lib.rs.h"
9
- #import <NativeScript/JSIRuntime.h>
6
+ #include "Helpers.h"
10
7
  #include <vector>
11
8
 
12
- using namespace facebook;
13
- using namespace org::nativescript::canvas;
14
9
 
15
- class JSI_EXPORT ANGLE_instanced_arraysImpl : public jsi::HostObject {
10
+ class ANGLE_instanced_arraysImpl {
16
11
  public:
17
- ANGLE_instanced_arraysImpl(rust::Box<ANGLE_instanced_arrays> arrays);
12
+ ANGLE_instanced_arraysImpl(ANGLE_instanced_arrays* arrays);
13
+
14
+ ANGLE_instanced_arrays* GetArrays();
15
+
16
+ static ANGLE_instanced_arraysImpl *GetPointer(const v8::Local<v8::Object> &object);
17
+
18
+ static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
19
+
20
+ static v8::Local<v8::Object>
21
+ NewInstance(v8::Isolate *isolate, ANGLE_instanced_arraysImpl *arrays) {
22
+ auto context = isolate->GetCurrentContext();
23
+ v8::EscapableHandleScope scope(isolate);
24
+ auto object = ANGLE_instanced_arraysImpl::GetCtor(isolate)->GetFunction(
25
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
26
+ SetNativeType(isolate, object, NativeType::ANGLE_instanced_arrays);
27
+ auto ext = v8::External::New(isolate, arrays);
28
+ object->SetInternalField(0, ext);
29
+ return scope.Escape(object);
30
+ }
18
31
 
19
- jsi::Value get(jsi::Runtime &, const jsi::PropNameID &name) override;
32
+ static void DrawArraysInstancedANGLE(const v8::FunctionCallbackInfo<v8::Value> &args);
20
33
 
21
- std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
34
+ static void DrawElementsInstancedANGLE(const v8::FunctionCallbackInfo<v8::Value> &args);
22
35
 
23
- ANGLE_instanced_arrays &GetArrays();
36
+ static void VertexAttribDivisorANGLE(const v8::FunctionCallbackInfo<v8::Value> &args);
24
37
 
25
38
  private:
26
- rust::Box<ANGLE_instanced_arrays> arrays_;
39
+ ANGLE_instanced_arrays* arrays_;
27
40
  };
28
41