@nativescript/canvas 2.0.0-alpha.3 → 2.0.0-alpha.31

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 (524) hide show
  1. package/Canvas/common.d.ts +212 -25
  2. package/Canvas/common.js +677 -460
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +9 -0
  5. package/Canvas/index.android.js +162 -53
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.d.ts +12 -0
  8. package/Canvas/index.ios.d.ts +6 -0
  9. package/Canvas/index.ios.js +151 -66
  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 +1 -3
  18. package/Canvas2D/CanvasRenderingContext2D/index.js +104 -214
  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 +6 -6
  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/Dom/Paint.js +2 -3
  28. package/Dom/Paint.js.map +1 -1
  29. package/Dom/shapes/Circle.js +1 -2
  30. package/Dom/shapes/Circle.js.map +1 -1
  31. package/Dom/shapes/Points.js +1 -2
  32. package/Dom/shapes/Points.js.map +1 -1
  33. package/ImageAsset/index.d.ts +2 -2
  34. package/ImageAsset/index.js +33 -37
  35. package/ImageAsset/index.js.map +1 -1
  36. package/ImageBitmap/index.d.ts +0 -2
  37. package/ImageBitmap/index.js +47 -34
  38. package/ImageBitmap/index.js.map +1 -1
  39. package/LICENSE +201 -0
  40. package/SVG/SVG.js +1 -1
  41. package/SVG/SVG.js.map +1 -1
  42. package/TextDecoder/index.d.ts +0 -2
  43. package/TextDecoder/index.js +3 -12
  44. package/TextDecoder/index.js.map +1 -1
  45. package/TextEncoder/index.d.ts +0 -2
  46. package/TextEncoder/index.js +4 -13
  47. package/TextEncoder/index.js.map +1 -1
  48. package/WebGL/WebGLExtensions/index.d.ts +4 -12
  49. package/WebGL/WebGLExtensions/index.js +27 -77
  50. package/WebGL/WebGLExtensions/index.js.map +1 -1
  51. package/WebGL/WebGLProgram.d.ts +0 -1
  52. package/WebGL/WebGLProgram.js +0 -3
  53. package/WebGL/WebGLProgram.js.map +1 -1
  54. package/WebGL/WebGLRenderingContext/common.d.ts +0 -2
  55. package/WebGL/WebGLRenderingContext/common.js +0 -10
  56. package/WebGL/WebGLRenderingContext/common.js.map +1 -1
  57. package/WebGL/WebGLRenderingContext/index.d.ts +15 -15
  58. package/WebGL/WebGLRenderingContext/index.js +183 -578
  59. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  60. package/WebGL2/WebGL2RenderingContext/index.d.ts +1 -1
  61. package/WebGL2/WebGL2RenderingContext/index.js +109 -281
  62. package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
  63. package/angular/esm2020/index.mjs +4 -4
  64. package/angular/fesm2015/nativescript-canvas-angular.mjs +4 -4
  65. package/angular/fesm2020/nativescript-canvas-angular.mjs +4 -4
  66. package/angular/package.json +2 -2
  67. package/index.js.map +1 -1
  68. package/package.json +3 -2
  69. package/platforms/android/canvas-release.aar +0 -0
  70. package/platforms/android/include.gradle +15 -0
  71. package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
  72. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  73. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +137 -64
  74. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative.h +10 -0
  75. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +142 -0
  76. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2673 -68
  77. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  78. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  79. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +5734 -2393
  80. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +42 -19
  81. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  82. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +42 -19
  83. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  84. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  85. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +274 -128
  86. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative.h +10 -0
  87. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +142 -0
  88. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2673 -68
  89. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  90. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  91. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  92. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +5734 -2393
  93. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +42 -19
  94. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  95. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +42 -19
  96. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +5734 -2393
  97. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +42 -19
  98. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  99. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +42 -19
  100. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +42 -31
  101. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  102. package/platforms/ios/Podfile +4 -1
  103. package/platforms/ios/build.xcconfig +3 -3
  104. package/platforms/ios/src/CanvasModule.h +0 -2
  105. package/platforms/ios/src/CanvasModule.mm +4 -4
  106. package/platforms/ios/src/NSOperationQueueWrapper.h +11 -0
  107. package/platforms/ios/src/NSOperationQueueWrapper.mm +74 -0
  108. package/platforms/ios/src/cpp/Caches.cpp +35 -0
  109. package/platforms/ios/src/cpp/Caches.h +190 -0
  110. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +1534 -0
  111. package/platforms/ios/src/cpp/CanvasJSIModule.h +8 -34
  112. package/platforms/ios/src/cpp/Common.h +30 -0
  113. package/platforms/ios/src/cpp/ConcurrentMap.h +54 -0
  114. package/platforms/ios/src/cpp/Helpers.h +304 -36
  115. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +802 -0
  116. package/platforms/ios/src/cpp/ImageAssetImpl.h +44 -12
  117. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +189 -0
  118. package/platforms/ios/src/cpp/ImageBitmapImpl.h +34 -16
  119. package/platforms/ios/src/cpp/JSICallback.h +61 -5
  120. package/platforms/ios/src/cpp/JSIReadFileCallback.h +86 -6
  121. package/platforms/ios/src/cpp/JSIRuntime.cpp +21 -0
  122. package/platforms/ios/src/cpp/JSIRuntime.h +7 -0
  123. package/platforms/ios/src/cpp/OneByteStringResource.cpp +49 -0
  124. package/platforms/ios/src/cpp/OneByteStringResource.h +32 -0
  125. package/platforms/ios/src/cpp/RafImpl.cpp +8 -0
  126. package/platforms/ios/src/cpp/RafImpl.h +11 -8
  127. package/platforms/ios/src/cpp/TextDecoderImpl.cpp +187 -0
  128. package/platforms/ios/src/cpp/TextDecoderImpl.h +20 -14
  129. package/platforms/ios/src/cpp/TextEncoderImpl.cpp +139 -0
  130. package/platforms/ios/src/cpp/TextEncoderImpl.h +20 -11
  131. package/platforms/ios/src/cpp/URLImpl.cpp +464 -0
  132. package/platforms/ios/src/cpp/URLImpl.h +119 -0
  133. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.cpp +71 -0
  134. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +27 -13
  135. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +89 -0
  136. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +26 -13
  137. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +2413 -0
  138. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +267 -16
  139. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +203 -0
  140. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +26 -12
  141. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +806 -0
  142. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +172 -13
  143. package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +449 -0
  144. package/platforms/ios/src/cpp/canvas2d/Path2D.h +41 -12
  145. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.cpp +253 -0
  146. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.h +50 -12
  147. package/platforms/ios/src/cpp/gl.h +57 -7
  148. package/platforms/ios/src/cpp/gl3stub.c +425 -0
  149. package/platforms/ios/src/cpp/gl3stub.h +665 -0
  150. package/platforms/ios/src/cpp/gles3jni.h +37 -0
  151. package/platforms/ios/src/cpp/include/robin_hood.h +2544 -0
  152. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.cpp +91 -0
  153. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +33 -13
  154. package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +41 -6
  155. package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +46 -10
  156. package/platforms/ios/src/cpp/webgl/WebGLProgram.h +40 -5
  157. package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +40 -6
  158. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +6454 -0
  159. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +262 -390
  160. package/platforms/ios/src/cpp/webgl/{WebGLRenderingContextBase.mm → WebGLRenderingContextBase.cpp} +46 -24
  161. package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.h +17 -11
  162. package/platforms/ios/src/cpp/webgl/WebGLShader.h +40 -6
  163. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.cpp +50 -0
  164. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +66 -11
  165. package/platforms/ios/src/cpp/webgl/WebGLTexture.h +40 -6
  166. package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +44 -8
  167. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.cpp +126 -0
  168. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +25 -11
  169. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.cpp +35 -0
  170. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +25 -5
  171. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.cpp +41 -0
  172. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +25 -5
  173. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.cpp +306 -0
  174. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +47 -13
  175. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +49 -6
  176. package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +37 -15
  177. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +47 -6
  178. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +49 -6
  179. package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +51 -0
  180. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +44 -6
  181. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +38 -15
  182. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +37 -16
  183. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +41 -6
  184. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +40 -16
  185. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.cpp +102 -0
  186. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +69 -14
  187. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +51 -8
  188. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +49 -6
  189. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +49 -8
  190. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +76 -6
  191. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +57 -6
  192. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +53 -6
  193. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +59 -6
  194. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +46 -6
  195. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.cpp +35 -0
  196. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +127 -14
  197. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.cpp +32 -0
  198. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +61 -12
  199. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +4375 -0
  200. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +139 -343
  201. package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +40 -4
  202. package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +42 -3
  203. package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +44 -11
  204. package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +42 -4
  205. package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +43 -4
  206. package/platforms/ios/src/module.modulemap +1 -0
  207. package/src-native/ios/Headers/include/APIDesign.md +72 -0
  208. package/src-native/ios/Headers/include/DEPS +10 -0
  209. package/src-native/ios/Headers/include/DIR_METADATA +11 -0
  210. package/src-native/ios/Headers/include/OWNERS +23 -0
  211. package/src-native/ios/Headers/include/cppgc/DEPS +8 -0
  212. package/src-native/ios/Headers/include/cppgc/OWNERS +2 -0
  213. package/src-native/ios/Headers/include/cppgc/README.md +133 -0
  214. package/src-native/ios/Headers/include/cppgc/allocation.h +310 -0
  215. package/src-native/ios/Headers/include/cppgc/common.h +29 -0
  216. package/src-native/ios/Headers/include/cppgc/cross-thread-persistent.h +465 -0
  217. package/src-native/ios/Headers/include/cppgc/custom-space.h +97 -0
  218. package/src-native/ios/Headers/include/cppgc/default-platform.h +67 -0
  219. package/src-native/ios/Headers/include/cppgc/ephemeron-pair.h +30 -0
  220. package/src-native/ios/Headers/include/cppgc/explicit-management.h +100 -0
  221. package/src-native/ios/Headers/include/cppgc/garbage-collected.h +106 -0
  222. package/src-native/ios/Headers/include/cppgc/heap-consistency.h +266 -0
  223. package/src-native/ios/Headers/include/cppgc/heap-state.h +82 -0
  224. package/src-native/ios/Headers/include/cppgc/heap-statistics.h +120 -0
  225. package/src-native/ios/Headers/include/cppgc/heap.h +206 -0
  226. package/src-native/ios/Headers/include/cppgc/internal/api-constants.h +55 -0
  227. package/src-native/ios/Headers/include/cppgc/internal/atomic-entry-flag.h +48 -0
  228. package/src-native/ios/Headers/include/cppgc/internal/caged-heap-local-data.h +79 -0
  229. package/src-native/ios/Headers/include/cppgc/internal/compiler-specific.h +38 -0
  230. package/src-native/ios/Headers/include/cppgc/internal/finalizer-trait.h +93 -0
  231. package/src-native/ios/Headers/include/cppgc/internal/gc-info.h +156 -0
  232. package/src-native/ios/Headers/include/cppgc/internal/logging.h +50 -0
  233. package/src-native/ios/Headers/include/cppgc/internal/name-trait.h +122 -0
  234. package/src-native/ios/Headers/include/cppgc/internal/persistent-node.h +216 -0
  235. package/src-native/ios/Headers/include/cppgc/internal/pointer-policies.h +186 -0
  236. package/src-native/ios/Headers/include/cppgc/internal/write-barrier.h +435 -0
  237. package/src-native/ios/Headers/include/cppgc/liveness-broker.h +77 -0
  238. package/src-native/ios/Headers/include/cppgc/macros.h +26 -0
  239. package/src-native/ios/Headers/include/cppgc/member.h +291 -0
  240. package/src-native/ios/Headers/include/cppgc/name-provider.h +65 -0
  241. package/src-native/ios/Headers/include/cppgc/object-size-trait.h +58 -0
  242. package/src-native/ios/Headers/include/cppgc/persistent.h +370 -0
  243. package/src-native/ios/Headers/include/cppgc/platform.h +156 -0
  244. package/src-native/ios/Headers/include/cppgc/prefinalizer.h +75 -0
  245. package/src-native/ios/Headers/include/cppgc/process-heap-statistics.h +36 -0
  246. package/src-native/ios/Headers/include/cppgc/sentinel-pointer.h +32 -0
  247. package/src-native/ios/Headers/include/cppgc/source-location.h +92 -0
  248. package/src-native/ios/Headers/include/cppgc/testing.h +106 -0
  249. package/src-native/ios/Headers/include/cppgc/trace-trait.h +116 -0
  250. package/src-native/ios/Headers/include/cppgc/type-traits.h +240 -0
  251. package/src-native/ios/Headers/include/cppgc/visitor.h +379 -0
  252. package/src-native/ios/Headers/include/js_protocol-1.2.json +936 -0
  253. package/src-native/ios/Headers/include/js_protocol-1.3.json +1112 -0
  254. package/src-native/ios/Headers/include/js_protocol.pdl +1709 -0
  255. package/src-native/ios/Headers/include/libffi/arm64/ffi.h +524 -0
  256. package/src-native/ios/Headers/include/libffi/arm64/ffitarget.h +92 -0
  257. package/src-native/ios/Headers/include/libffi/x86_64/ffi.h +524 -0
  258. package/src-native/ios/Headers/include/libffi/x86_64/ffitarget.h +147 -0
  259. package/src-native/ios/Headers/include/libffi.h +12 -0
  260. package/src-native/ios/Headers/include/libplatform/DEPS +9 -0
  261. package/src-native/ios/Headers/include/libplatform/libplatform-export.h +29 -0
  262. package/src-native/ios/Headers/include/libplatform/libplatform.h +106 -0
  263. package/src-native/ios/Headers/include/libplatform/v8-tracing.h +333 -0
  264. package/src-native/ios/Headers/include/v8-array-buffer.h +433 -0
  265. package/src-native/ios/Headers/include/v8-callbacks.h +397 -0
  266. package/src-native/ios/Headers/include/v8-container.h +129 -0
  267. package/src-native/ios/Headers/include/v8-context.h +407 -0
  268. package/src-native/ios/Headers/include/v8-cppgc.h +215 -0
  269. package/src-native/ios/Headers/include/v8-data.h +80 -0
  270. package/src-native/ios/Headers/include/v8-date.h +43 -0
  271. package/src-native/ios/Headers/include/v8-debug.h +168 -0
  272. package/src-native/ios/Headers/include/v8-embedder-heap.h +218 -0
  273. package/src-native/ios/Headers/include/v8-embedder-state-scope.h +51 -0
  274. package/src-native/ios/Headers/include/v8-exception.h +217 -0
  275. package/src-native/ios/Headers/include/v8-extension.h +62 -0
  276. package/src-native/ios/Headers/include/v8-external.h +37 -0
  277. package/src-native/ios/Headers/include/v8-fast-api-calls.h +939 -0
  278. package/src-native/ios/Headers/include/v8-forward.h +81 -0
  279. package/src-native/ios/Headers/include/v8-function-callback.h +475 -0
  280. package/src-native/ios/Headers/include/v8-function.h +125 -0
  281. package/src-native/ios/Headers/include/v8-initialization.h +315 -0
  282. package/src-native/ios/Headers/include/v8-inspector-protocol.h +13 -0
  283. package/src-native/ios/Headers/include/v8-inspector.h +376 -0
  284. package/src-native/ios/Headers/include/v8-internal.h +661 -0
  285. package/src-native/ios/Headers/include/v8-isolate.h +1709 -0
  286. package/src-native/ios/Headers/include/v8-json.h +47 -0
  287. package/src-native/ios/Headers/include/v8-local-handle.h +455 -0
  288. package/src-native/ios/Headers/include/v8-locker.h +149 -0
  289. package/src-native/ios/Headers/include/v8-maybe.h +137 -0
  290. package/src-native/ios/Headers/include/v8-memory-span.h +43 -0
  291. package/src-native/ios/Headers/include/v8-message.h +216 -0
  292. package/src-native/ios/Headers/include/v8-metrics.h +255 -0
  293. package/src-native/ios/Headers/include/v8-microtask-queue.h +152 -0
  294. package/src-native/ios/Headers/include/v8-microtask.h +28 -0
  295. package/src-native/ios/Headers/include/v8-object.h +775 -0
  296. package/src-native/ios/Headers/include/v8-persistent-handle.h +590 -0
  297. package/src-native/ios/Headers/include/v8-platform.h +1092 -0
  298. package/src-native/ios/Headers/include/v8-primitive-object.h +118 -0
  299. package/src-native/ios/Headers/include/v8-primitive.h +866 -0
  300. package/src-native/ios/Headers/include/v8-profiler.h +1198 -0
  301. package/src-native/ios/Headers/include/v8-promise.h +174 -0
  302. package/src-native/ios/Headers/include/v8-proxy.h +50 -0
  303. package/src-native/ios/Headers/include/v8-regexp.h +105 -0
  304. package/src-native/ios/Headers/include/v8-script.h +748 -0
  305. package/src-native/ios/Headers/include/v8-snapshot.h +196 -0
  306. package/src-native/ios/Headers/include/v8-statistics.h +217 -0
  307. package/src-native/ios/Headers/include/v8-template.h +1079 -0
  308. package/src-native/ios/Headers/include/v8-traced-handle.h +420 -0
  309. package/src-native/ios/Headers/include/v8-typed-array.h +282 -0
  310. package/src-native/ios/Headers/include/v8-unwinder-state.h +31 -0
  311. package/src-native/ios/Headers/include/v8-unwinder.h +132 -0
  312. package/src-native/ios/Headers/include/v8-util.h +658 -0
  313. package/src-native/ios/Headers/include/v8-value-serializer-version.h +24 -0
  314. package/src-native/ios/Headers/include/v8-value-serializer.h +279 -0
  315. package/src-native/ios/Headers/include/v8-value.h +526 -0
  316. package/src-native/ios/Headers/include/v8-version-string.h +38 -0
  317. package/src-native/ios/Headers/include/v8-version.h +20 -0
  318. package/src-native/ios/Headers/include/v8-wasm-trap-handler-posix.h +31 -0
  319. package/src-native/ios/Headers/include/v8-wasm-trap-handler-win.h +28 -0
  320. package/src-native/ios/Headers/include/v8-wasm.h +257 -0
  321. package/src-native/ios/Headers/include/v8-weak-callback-info.h +86 -0
  322. package/src-native/ios/Headers/include/v8.h +88 -0
  323. package/src-native/ios/Headers/include/v8config.h +605 -0
  324. package/src-native/ios/Headers/inspector/InspectorServer.h +20 -0
  325. package/src-native/ios/Headers/inspector/JsV8InspectorClient.h +66 -0
  326. package/src-native/ios/Headers/inspector/base/trace_event/common/trace_event_common.h +1123 -0
  327. package/src-native/ios/Headers/inspector/base64.h +9 -0
  328. package/src-native/ios/Headers/inspector/src/base/address-region.h +95 -0
  329. package/src-native/ios/Headers/inspector/src/base/atomic-utils.h +219 -0
  330. package/src-native/ios/Headers/inspector/src/base/atomicops.h +332 -0
  331. package/src-native/ios/Headers/inspector/src/base/atomicops_internals_atomicword_compat.h +89 -0
  332. package/src-native/ios/Headers/inspector/src/base/base-export.h +31 -0
  333. package/src-native/ios/Headers/inspector/src/base/bits.h +343 -0
  334. package/src-native/ios/Headers/inspector/src/base/build_config.h +234 -0
  335. package/src-native/ios/Headers/inspector/src/base/compiler-specific.h +136 -0
  336. package/src-native/ios/Headers/inspector/src/base/export-template.h +163 -0
  337. package/src-native/ios/Headers/inspector/src/base/flags.h +130 -0
  338. package/src-native/ios/Headers/inspector/src/base/immediate-crash.h +162 -0
  339. package/src-native/ios/Headers/inspector/src/base/lazy-instance.h +258 -0
  340. package/src-native/ios/Headers/inspector/src/base/logging.h +417 -0
  341. package/src-native/ios/Headers/inspector/src/base/macros.h +423 -0
  342. package/src-native/ios/Headers/inspector/src/base/memory.h +89 -0
  343. package/src-native/ios/Headers/inspector/src/base/once.h +108 -0
  344. package/src-native/ios/Headers/inspector/src/base/optional.h +882 -0
  345. package/src-native/ios/Headers/inspector/src/base/platform/mutex.h +370 -0
  346. package/src-native/ios/Headers/inspector/src/base/platform/platform.h +476 -0
  347. package/src-native/ios/Headers/inspector/src/base/platform/semaphore.h +108 -0
  348. package/src-native/ios/Headers/inspector/src/base/platform/v8-time.h +513 -0
  349. package/src-native/ios/Headers/inspector/src/base/platform/wrappers.h +73 -0
  350. package/src-native/ios/Headers/inspector/src/base/safe_conversions.h +389 -0
  351. package/src-native/ios/Headers/inspector/src/base/safe_conversions_impl.h +822 -0
  352. package/src-native/ios/Headers/inspector/src/base/template-utils.h +113 -0
  353. package/src-native/ios/Headers/inspector/src/base/v8-fallthrough.h +21 -0
  354. package/src-native/ios/Headers/inspector/src/common/checks.h +38 -0
  355. package/src-native/ios/Headers/inspector/src/common/globals.h +1842 -0
  356. package/src-native/ios/Headers/inspector/src/debug/debug-interface.h +667 -0
  357. package/src-native/ios/Headers/inspector/src/debug/interface-types.h +175 -0
  358. package/src-native/ios/Headers/inspector/src/init/v8.h +52 -0
  359. package/src-native/ios/Headers/inspector/src/inspector/custom-preview.h +24 -0
  360. package/src-native/ios/Headers/inspector/src/inspector/injected-script.h +251 -0
  361. package/src-native/ios/Headers/inspector/src/inspector/inspected-context.h +79 -0
  362. package/src-native/ios/Headers/inspector/src/inspector/protocol/CSS.h +2148 -0
  363. package/src-native/ios/Headers/inspector/src/inspector/protocol/Console.h +211 -0
  364. package/src-native/ios/Headers/inspector/src/inspector/protocol/DOM.h +1008 -0
  365. package/src-native/ios/Headers/inspector/src/inspector/protocol/Debugger.h +892 -0
  366. package/src-native/ios/Headers/inspector/src/inspector/protocol/Forward.h +75 -0
  367. package/src-native/ios/Headers/inspector/src/inspector/protocol/HeapProfiler.h +346 -0
  368. package/src-native/ios/Headers/inspector/src/inspector/protocol/Log.h +342 -0
  369. package/src-native/ios/Headers/inspector/src/inspector/protocol/Network.h +2528 -0
  370. package/src-native/ios/Headers/inspector/src/inspector/protocol/Overlay.h +281 -0
  371. package/src-native/ios/Headers/inspector/src/inspector/protocol/Page.h +1189 -0
  372. package/src-native/ios/Headers/inspector/src/inspector/protocol/Profiler.h +1001 -0
  373. package/src-native/ios/Headers/inspector/src/inspector/protocol/Protocol.h +617 -0
  374. package/src-native/ios/Headers/inspector/src/inspector/protocol/Runtime.h +1696 -0
  375. package/src-native/ios/Headers/inspector/src/inspector/protocol/Schema.h +146 -0
  376. package/src-native/ios/Headers/inspector/src/inspector/protocol/Security.h +793 -0
  377. package/src-native/ios/Headers/inspector/src/inspector/remote-object-id.h +54 -0
  378. package/src-native/ios/Headers/inspector/src/inspector/search-util.h +26 -0
  379. package/src-native/ios/Headers/inspector/src/inspector/string-16.h +180 -0
  380. package/src-native/ios/Headers/inspector/src/inspector/string-util.h +128 -0
  381. package/src-native/ios/Headers/inspector/src/inspector/v8-console-agent-impl.h +48 -0
  382. package/src-native/ios/Headers/inspector/src/inspector/v8-console-message.h +147 -0
  383. package/src-native/ios/Headers/inspector/src/inspector/v8-console.h +173 -0
  384. package/src-native/ios/Headers/inspector/src/inspector/v8-css-agent-impl.h +62 -0
  385. package/src-native/ios/Headers/inspector/src/inspector/v8-debugger-agent-impl.h +248 -0
  386. package/src-native/ios/Headers/inspector/src/inspector/v8-debugger-id.h +44 -0
  387. package/src-native/ios/Headers/inspector/src/inspector/v8-debugger-script.h +123 -0
  388. package/src-native/ios/Headers/inspector/src/inspector/v8-debugger.h +257 -0
  389. package/src-native/ios/Headers/inspector/src/inspector/v8-dom-agent-impl.h +91 -0
  390. package/src-native/ios/Headers/inspector/src/inspector/v8-heap-profiler-agent-impl.h +80 -0
  391. package/src-native/ios/Headers/inspector/src/inspector/v8-inspector-impl.h +191 -0
  392. package/src-native/ios/Headers/inspector/src/inspector/v8-inspector-session-impl.h +156 -0
  393. package/src-native/ios/Headers/inspector/src/inspector/v8-log-agent-impl.h +34 -0
  394. package/src-native/ios/Headers/inspector/src/inspector/v8-network-agent-impl.h +71 -0
  395. package/src-native/ios/Headers/inspector/src/inspector/v8-ns-debugger-agent-impl.h +24 -0
  396. package/src-native/ios/Headers/inspector/src/inspector/v8-overlay-agent-impl.h +70 -0
  397. package/src-native/ios/Headers/inspector/src/inspector/v8-page-agent-impl.h +88 -0
  398. package/src-native/ios/Headers/inspector/src/inspector/v8-profiler-agent-impl.h +104 -0
  399. package/src-native/ios/Headers/inspector/src/inspector/v8-regex.h +38 -0
  400. package/src-native/ios/Headers/inspector/src/inspector/v8-runtime-agent-impl.h +157 -0
  401. package/src-native/ios/Headers/inspector/src/inspector/v8-schema-agent-impl.h +38 -0
  402. package/src-native/ios/Headers/inspector/src/inspector/v8-stack-trace-impl.h +164 -0
  403. package/src-native/ios/Headers/inspector/src/inspector/v8-string-conversions.h +17 -0
  404. package/src-native/ios/Headers/inspector/src/inspector/v8-value-utils.h +23 -0
  405. package/src-native/ios/Headers/inspector/src/inspector/value-mirror.h +87 -0
  406. package/src-native/ios/Headers/inspector/src/libplatform/default-platform.h +92 -0
  407. package/src-native/ios/Headers/inspector/src/logging/tracing-flags.h +50 -0
  408. package/src-native/ios/Headers/inspector/src/numbers/conversions.h +183 -0
  409. package/src-native/ios/Headers/inspector/src/tracing/trace-event.h +664 -0
  410. package/src-native/ios/Headers/inspector/src/utils/allocation.h +367 -0
  411. package/src-native/ios/Headers/inspector/src/utils/vector.h +324 -0
  412. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/cbor.h +305 -0
  413. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/dispatch.h +314 -0
  414. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/error_support.h +62 -0
  415. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/export.h +6 -0
  416. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/find_by_first.h +58 -0
  417. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/frontend_channel.h +47 -0
  418. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/glue.h +80 -0
  419. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/json.h +52 -0
  420. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/json_platform.h +26 -0
  421. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/maybe.h +104 -0
  422. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/parser_handler.h +39 -0
  423. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/protocol_core.h +406 -0
  424. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/serializable.h +32 -0
  425. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/serializer_traits.h +158 -0
  426. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/span.h +99 -0
  427. package/src-native/ios/Headers/inspector/third_party/inspector_protocol/crdtp/status.h +139 -0
  428. package/src-native/ios/Headers/inspector/utils.h +32 -0
  429. package/src-native/ios/Headers/inspector/v8-inspector-platform.h +44 -0
  430. package/src-native/ios/Headers/runtime/ArgConverter.h +61 -0
  431. package/src-native/ios/Headers/runtime/ArrayAdapter.h +13 -0
  432. package/src-native/ios/Headers/runtime/Caches.h +98 -0
  433. package/src-native/ios/Headers/runtime/ClassBuilder.h +61 -0
  434. package/src-native/ios/Headers/runtime/Common.h +9 -0
  435. package/src-native/ios/Headers/runtime/ConcurrentMap.h +55 -0
  436. package/src-native/ios/Headers/runtime/ConcurrentQueue.h +28 -0
  437. package/src-native/ios/Headers/runtime/Console.h +27 -0
  438. package/src-native/ios/Headers/runtime/Constants.h +15 -0
  439. package/src-native/ios/Headers/runtime/DataWrapper.h +671 -0
  440. package/src-native/ios/Headers/runtime/DictionaryAdapter.h +13 -0
  441. package/src-native/ios/Headers/runtime/ExtVector.h +21 -0
  442. package/src-native/ios/Headers/runtime/FFICall.h +105 -0
  443. package/src-native/ios/Headers/runtime/FastEnumerationAdapter.h +13 -0
  444. package/src-native/ios/Headers/runtime/FunctionReference.h +18 -0
  445. package/src-native/ios/Headers/runtime/Helpers.h +84 -0
  446. package/src-native/ios/Headers/runtime/InlineFunctions.h +16 -0
  447. package/src-native/ios/Headers/runtime/Interop.h +202 -0
  448. package/src-native/ios/Headers/runtime/KnownUnknownClassPair.h +35 -0
  449. package/src-native/ios/Headers/runtime/Metadata.h +981 -0
  450. package/src-native/ios/Headers/runtime/MetadataBuilder.h +72 -0
  451. package/src-native/ios/Headers/runtime/MetadataInlines.h +157 -0
  452. package/src-native/ios/Headers/runtime/ModuleInternal.h +59 -0
  453. package/src-native/ios/Headers/runtime/NSDataAdapter.h +13 -0
  454. package/src-native/ios/Headers/runtime/NativeScriptException.h +27 -0
  455. package/src-native/ios/Headers/runtime/ObjectManager.h +31 -0
  456. package/src-native/ios/Headers/runtime/OneByteStringResource.h +21 -0
  457. package/src-native/ios/Headers/runtime/Pointer.h +26 -0
  458. package/src-native/ios/Headers/runtime/PromiseProxy.h +15 -0
  459. package/src-native/ios/Headers/runtime/Reference.h +38 -0
  460. package/src-native/ios/Headers/runtime/Runtime.h +67 -0
  461. package/src-native/ios/Headers/runtime/RuntimeConfig.h +17 -0
  462. package/src-native/ios/Headers/runtime/SetTimeout.h +34 -0
  463. package/src-native/ios/Headers/runtime/SimpleAllocator.h +23 -0
  464. package/src-native/ios/Headers/runtime/StringHasher.h +315 -0
  465. package/src-native/ios/Headers/runtime/SymbolIterator.h +18 -0
  466. package/src-native/ios/Headers/runtime/SymbolLoader.h +27 -0
  467. package/src-native/ios/Headers/runtime/TNSDerivedClass.h +8 -0
  468. package/src-native/ios/Headers/runtime/TSHelpers.h +15 -0
  469. package/src-native/ios/Headers/runtime/Tasks.h +19 -0
  470. package/src-native/ios/Headers/runtime/UnmanagedType.h +21 -0
  471. package/src-native/ios/Headers/runtime/WeakRef.h +15 -0
  472. package/src-native/ios/Headers/runtime/Worker.h +26 -0
  473. package/src-native/ios/Headers/runtime/robin_hood.h +2184 -0
  474. package/src-native/ios/NativeScript.podspec +55 -0
  475. package/typings/objc!CanvasNative.d.ts +2038 -0
  476. package/typings/objc!CanvasNative.js +1 -0
  477. package/typings/objc!CanvasNative.js.map +1 -0
  478. package/utils.d.ts +3 -1
  479. package/utils.js +7 -20
  480. package/utils.js.map +1 -1
  481. package/angular/nativescript-canvas-angular.d.ts +0 -5
  482. package/platforms/ios/src/cpp/CanvasJSIModule.mm +0 -1105
  483. package/platforms/ios/src/cpp/ImageAssetImpl.mm +0 -417
  484. package/platforms/ios/src/cpp/ImageBitmapImpl.mm +0 -126
  485. package/platforms/ios/src/cpp/RafImpl.mm +0 -10
  486. package/platforms/ios/src/cpp/TextDecoderImpl.mm +0 -97
  487. package/platforms/ios/src/cpp/TextEncoderImpl.mm +0 -60
  488. package/platforms/ios/src/cpp/VecMutableBuffer.h +0 -51
  489. package/platforms/ios/src/cpp/canvas-cxx/src/lib.rs.cc +0 -6119
  490. package/platforms/ios/src/cpp/canvas-cxx/src/lib.rs.h +0 -2854
  491. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.mm +0 -42
  492. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.mm +0 -49
  493. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.mm +0 -1954
  494. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.mm +0 -68
  495. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.mm +0 -149
  496. package/platforms/ios/src/cpp/canvas2d/Path2D.mm +0 -335
  497. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.mm +0 -68
  498. package/platforms/ios/src/cpp/rust/cxx.cc +0 -793
  499. package/platforms/ios/src/cpp/rust/cxx.h +0 -1111
  500. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.mm +0 -39
  501. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.mm +0 -5879
  502. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.mm +0 -40
  503. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.mm +0 -108
  504. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.mm +0 -28
  505. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.mm +0 -42
  506. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.mm +0 -295
  507. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.mm +0 -40
  508. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.mm +0 -37
  509. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.mm +0 -28
  510. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.mm +0 -31
  511. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.mm +0 -28
  512. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.mm +0 -127
  513. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.mm +0 -45
  514. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.mm +0 -45
  515. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.mm +0 -31
  516. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.mm +0 -70
  517. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.mm +0 -47
  518. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.mm +0 -46
  519. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.mm +0 -49
  520. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.mm +0 -30
  521. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.mm +0 -177
  522. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.mm +0 -64
  523. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.mm +0 -4554
  524. /package/platforms/ios/src/cpp/{OnRafCallback.mm → OnRafCallback.cpp} +0 -0
@@ -0,0 +1,2413 @@
1
+ //
2
+ // Created by Osei Fortune on 22/03/2022.
3
+ //
4
+
5
+ #include "CanvasRenderingContext2DImpl.h"
6
+ #include "Caches.h"
7
+ #include "OneByteStringResource.h"
8
+
9
+ CanvasRenderingContext2DImpl::CanvasRenderingContext2DImpl(
10
+ CanvasRenderingContext2D *context) : context_(context) {
11
+
12
+ auto ctx_ptr = reinterpret_cast<intptr_t>(reinterpret_cast<intptr_t *>(this));
13
+ auto raf_callback = new OnRafCallback(ctx_ptr, 0);
14
+ auto raf_callback_ptr = reinterpret_cast<intptr_t>(reinterpret_cast<intptr_t *>(raf_callback));
15
+ auto raf = canvas_native_raf_create(raf_callback_ptr, OnRafCallbackOnFrame);
16
+
17
+ this->SetRaf(std::make_shared<RafImpl>(raf_callback, raf_callback_ptr, raf));
18
+
19
+ auto _raf = this->GetRaf();
20
+
21
+ if (_raf != nullptr) {
22
+ canvas_native_raf_start(_raf->GetRaf());
23
+ }
24
+
25
+ }
26
+
27
+
28
+ void CanvasRenderingContext2DImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
29
+ v8::Locker locker(isolate);
30
+ v8::Isolate::Scope isolate_scope(isolate);
31
+ v8::HandleScope handle_scope(isolate);
32
+
33
+ auto ctor = GetCtor(isolate);
34
+ auto context = isolate->GetCurrentContext();
35
+ auto func = ctor->GetFunction(context).ToLocalChecked();
36
+
37
+ canvasModule->Set(context, ConvertToV8String(isolate, "CanvasRenderingContext2D"), func);
38
+ }
39
+
40
+ CanvasRenderingContext2DImpl *
41
+ CanvasRenderingContext2DImpl::GetPointer(const v8::Local<v8::Object> &object) {
42
+ auto ptr = object->GetInternalField(0).As<v8::External>()->Value();
43
+ if (ptr == nullptr) {
44
+ return nullptr;
45
+ }
46
+ return static_cast<CanvasRenderingContext2DImpl *>(ptr);
47
+ }
48
+
49
+ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolate *isolate) {
50
+ auto cache = Caches::Get(isolate);
51
+ auto ctor = cache->CanvasRenderingContext2DTmpl.get();
52
+ if (ctor != nullptr) {
53
+ return ctor->Get(isolate);
54
+ }
55
+
56
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
57
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1);
58
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "CanvasRenderingContext2D"));
59
+
60
+ auto tmpl = ctorTmpl->InstanceTemplate();
61
+ tmpl->SetInternalFieldCount(1);
62
+
63
+ tmpl->Set(ConvertToV8String(isolate, "drawPoint"),
64
+ v8::FunctionTemplate::New(isolate, &DrawPoint));
65
+ tmpl->Set(ConvertToV8String(isolate, "drawPoints"),
66
+ v8::FunctionTemplate::New(isolate, &DrawPoints));
67
+ tmpl->Set(ConvertToV8String(isolate, "drawPaint"),
68
+ v8::FunctionTemplate::New(isolate, &DrawPaint));
69
+
70
+
71
+ tmpl->Set(ConvertToV8String(isolate, "__makeDirty"),
72
+ v8::FunctionTemplate::New(isolate, __MakeDirty));
73
+ tmpl->Set(ConvertToV8String(isolate, "__getPointer"),
74
+ v8::FunctionTemplate::New(isolate, __GetPointer));
75
+ tmpl->Set(ConvertToV8String(isolate, "__resize"), v8::FunctionTemplate::New(isolate, __Resize));
76
+
77
+ tmpl->SetAccessor(ConvertToV8String(isolate, "filter"), GetFilter, SetFilter);
78
+ tmpl->SetAccessor(ConvertToV8String(isolate, "font"), GetFont, SetFont);
79
+ tmpl->SetAccessor(ConvertToV8String(isolate, "globalAlpha"), GetGlobalAlpha, SetGlobalAlpha);
80
+ tmpl->SetAccessor(ConvertToV8String(isolate, "imageSmoothingEnabled"), GetImageSmoothingEnabled,
81
+ SetImageSmoothingEnabled);
82
+ tmpl->SetAccessor(ConvertToV8String(isolate, "imageSmoothingQuality"), GetImageSmoothingQuality,
83
+ SetImageSmoothingQuality);
84
+ tmpl->SetAccessor(ConvertToV8String(isolate, "lineDashOffset"), GetLineDashOffset,
85
+ SetLineDashOffset);
86
+ tmpl->SetAccessor(ConvertToV8String(isolate, "lineJoin"), GetLineJoin, SetLineJoin);
87
+ tmpl->SetAccessor(ConvertToV8String(isolate, "lineCap"), GetLineCap, SetLineCap);
88
+ tmpl->SetAccessor(ConvertToV8String(isolate, "miterLimit"), GetMiterLimit, SetMiterLimit);
89
+ tmpl->SetAccessor(ConvertToV8String(isolate, "shadowColor"), GetShadowColor, SetShadowColor);
90
+ tmpl->SetAccessor(ConvertToV8String(isolate, "shadowBlur"), GetShadowBlur, SetShadowBlur);
91
+ tmpl->SetAccessor(ConvertToV8String(isolate, "shadowOffsetX"), GetShadowOffsetX,
92
+ SetShadowOffsetX);
93
+ tmpl->SetAccessor(ConvertToV8String(isolate, "shadowOffsetY"), GetShadowOffsetY,
94
+ SetShadowOffsetY);
95
+ tmpl->SetAccessor(ConvertToV8String(isolate, "textAlign"), GetTextAlign, SetTextAlign);
96
+ tmpl->SetAccessor(ConvertToV8String(isolate, "globalCompositeOperation"),
97
+ GetGlobalCompositeOperation, SetGlobalCompositeOperation);
98
+ tmpl->SetAccessor(ConvertToV8String(isolate, "fillStyle"), GetFillStyle, SetFillStyle);
99
+ tmpl->SetAccessor(ConvertToV8String(isolate, "strokeStyle"), GetStrokeStyle, SetStrokeStyle);
100
+ tmpl->SetAccessor(ConvertToV8String(isolate, "lineWidth"), GetLineWidth, SetLineWidth);
101
+ tmpl->SetAccessor(ConvertToV8String(isolate, "lineDash"), GetLineDash, SetLineDash);
102
+
103
+
104
+ tmpl->Set(ConvertToV8String(isolate, "addHitRegion"),
105
+ v8::FunctionTemplate::New(isolate, &AddHitRegion));
106
+ tmpl->Set(ConvertToV8String(isolate, "arc"), v8::FunctionTemplate::New(isolate, &Arc));
107
+ tmpl->Set(ConvertToV8String(isolate, "arcTo"), v8::FunctionTemplate::New(isolate, &ArcTo));
108
+ tmpl->Set(ConvertToV8String(isolate, "beginPath"),
109
+ v8::FunctionTemplate::New(isolate, &BeginPath));
110
+ tmpl->Set(ConvertToV8String(isolate, "bezierCurveTo"),
111
+ v8::FunctionTemplate::New(isolate, &BezierCurveTo));
112
+ tmpl->Set(ConvertToV8String(isolate, "clearHitRegions"),
113
+ v8::FunctionTemplate::New(isolate, &ClearHitRegions));
114
+ tmpl->Set(ConvertToV8String(isolate, "clearRect"),
115
+ v8::FunctionTemplate::New(isolate, &ClearRect));
116
+ tmpl->Set(ConvertToV8String(isolate, "clip"), v8::FunctionTemplate::New(isolate, &Clip));
117
+ tmpl->Set(ConvertToV8String(isolate, "closePath"),
118
+ v8::FunctionTemplate::New(isolate, &ClosePath));
119
+ tmpl->Set(ConvertToV8String(isolate, "createImageData"),
120
+ v8::FunctionTemplate::New(isolate, &CreateImageData));
121
+ tmpl->Set(ConvertToV8String(isolate, "createPattern"),
122
+ v8::FunctionTemplate::New(isolate, &CreatePattern));
123
+ tmpl->Set(ConvertToV8String(isolate, "createLinearGradient"),
124
+ v8::FunctionTemplate::New(isolate, &CreateLinearGradient));
125
+ tmpl->Set(ConvertToV8String(isolate, "createConicGradient"),
126
+ v8::FunctionTemplate::New(isolate, &CreateConicGradient));
127
+ tmpl->Set(ConvertToV8String(isolate, "__createPatternWithNative"),
128
+ v8::FunctionTemplate::New(isolate, &__CreatePatternWithNative));
129
+ tmpl->Set(ConvertToV8String(isolate, "createRadialGradient"),
130
+ v8::FunctionTemplate::New(isolate, &CreateRadialGradient));
131
+ tmpl->Set(ConvertToV8String(isolate, "drawFocusIfNeeded"),
132
+ v8::FunctionTemplate::New(isolate, &DrawFocusIfNeeded));
133
+ tmpl->Set(ConvertToV8String(isolate, "drawImage"),
134
+ v8::FunctionTemplate::New(isolate, &DrawImage));
135
+ tmpl->Set(ConvertToV8String(isolate, "ellipse"), v8::FunctionTemplate::New(isolate, &Ellipse));
136
+ tmpl->Set(ConvertToV8String(isolate, "fill"), v8::FunctionTemplate::New(isolate, &Fill));
137
+ tmpl->Set(ConvertToV8String(isolate, "fillRect"),
138
+ v8::FunctionTemplate::New(isolate, &FillRect));
139
+ tmpl->Set(ConvertToV8String(isolate, "fillText"),
140
+ v8::FunctionTemplate::New(isolate, &FillText));
141
+ tmpl->Set(ConvertToV8String(isolate, "getImageData"),
142
+ v8::FunctionTemplate::New(isolate, &GetImageData));
143
+ tmpl->Set(ConvertToV8String(isolate, "getLineDash"),
144
+ v8::FunctionTemplate::New(isolate, &GetLineDash));
145
+ tmpl->Set(ConvertToV8String(isolate, "isPointInPath"),
146
+ v8::FunctionTemplate::New(isolate, &IsPointInPath));
147
+ tmpl->Set(ConvertToV8String(isolate, "isPointInStroke"),
148
+ v8::FunctionTemplate::New(isolate, &IsPointInStroke));
149
+ tmpl->Set(ConvertToV8String(isolate, "lineTo"), v8::FunctionTemplate::New(isolate, &LineTo));
150
+ tmpl->Set(ConvertToV8String(isolate, "measureText"),
151
+ v8::FunctionTemplate::New(isolate, &MeasureText));
152
+ tmpl->Set(ConvertToV8String(isolate, "moveTo"), v8::FunctionTemplate::New(isolate, &MoveTo));
153
+ tmpl->Set(ConvertToV8String(isolate, "putImageData"),
154
+ v8::FunctionTemplate::New(isolate, &PutImageData));
155
+ tmpl->Set(ConvertToV8String(isolate, "quadraticCurveTo"),
156
+ v8::FunctionTemplate::New(isolate, &QuadraticCurveTo));
157
+ tmpl->Set(ConvertToV8String(isolate, "roundRect"),
158
+ v8::FunctionTemplate::New(isolate, &RoundRect));
159
+ tmpl->Set(ConvertToV8String(isolate, "rect"), v8::FunctionTemplate::New(isolate, &Rect));
160
+ tmpl->Set(ConvertToV8String(isolate, "removeHitRegion"),
161
+ v8::FunctionTemplate::New(isolate, &RemoveHitRegion));
162
+ tmpl->Set(ConvertToV8String(isolate, "resetTransform"),
163
+ v8::FunctionTemplate::New(isolate, &ResetTransform));
164
+ tmpl->Set(ConvertToV8String(isolate, "restore"), v8::FunctionTemplate::New(isolate, &Restore));
165
+ tmpl->Set(ConvertToV8String(isolate, "rotate"), v8::FunctionTemplate::New(isolate, &Rotate));
166
+ tmpl->Set(ConvertToV8String(isolate, "save"), v8::FunctionTemplate::New(isolate, &Save));
167
+ tmpl->Set(ConvertToV8String(isolate, "scale"), v8::FunctionTemplate::New(isolate, &Scale));
168
+ tmpl->Set(ConvertToV8String(isolate, "scrollPathIntoView"),
169
+ v8::FunctionTemplate::New(isolate, &ScrollPathIntoView));
170
+ tmpl->Set(ConvertToV8String(isolate, "setLineDash"),
171
+ v8::FunctionTemplate::New(isolate, &SetLineDash));
172
+ tmpl->Set(ConvertToV8String(isolate, "setTransform"),
173
+ v8::FunctionTemplate::New(isolate, &SetTransform));
174
+ tmpl->Set(ConvertToV8String(isolate, "stroke"), v8::FunctionTemplate::New(isolate, &Stroke));
175
+ tmpl->Set(ConvertToV8String(isolate, "strokeRect"),
176
+ v8::FunctionTemplate::New(isolate, &StrokeRect));
177
+ tmpl->Set(ConvertToV8String(isolate, "strokeText"),
178
+ v8::FunctionTemplate::New(isolate, &StrokeText));
179
+ tmpl->Set(ConvertToV8String(isolate, "transform"),
180
+ v8::FunctionTemplate::New(isolate, &Transform));
181
+ tmpl->Set(ConvertToV8String(isolate, "translate"),
182
+ v8::FunctionTemplate::New(isolate, &Translate));
183
+ tmpl->Set(ConvertToV8String(isolate, "__toDataURL"),
184
+ v8::FunctionTemplate::New(isolate, &__ToDataURL));
185
+
186
+ cache->CanvasRenderingContext2DTmpl =
187
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
188
+ return ctorTmpl;
189
+ }
190
+
191
+ void CanvasRenderingContext2DImpl::SetRaf(std::shared_ptr<RafImpl> raf) {
192
+ this->raf_ = std::move(raf);
193
+ }
194
+
195
+ RafImpl *CanvasRenderingContext2DImpl::GetRaf() {
196
+ return this->raf_.get();
197
+ }
198
+
199
+ /* Non Standard 2D */
200
+
201
+ void CanvasRenderingContext2DImpl::DrawPoint(const v8::FunctionCallbackInfo<v8::Value> &args) {
202
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
203
+ if (ptr == nullptr) {
204
+ return;
205
+ }
206
+
207
+ auto isolate = args.GetIsolate();
208
+ auto context = isolate->GetCurrentContext();
209
+
210
+ auto x = (float) args[0]->NumberValue(context).ToChecked();
211
+ auto y = (float) args[1]->NumberValue(context).ToChecked();
212
+
213
+ canvas_native_context_draw_point(
214
+ ptr->GetContext(), x, y);
215
+ ptr->UpdateInvalidateState();
216
+ }
217
+
218
+ void CanvasRenderingContext2DImpl::DrawPoints(const v8::FunctionCallbackInfo<v8::Value> &args) {
219
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
220
+ if (ptr == nullptr) {
221
+ return;
222
+ }
223
+
224
+ auto isolate = args.GetIsolate();
225
+ auto context = isolate->GetCurrentContext();
226
+
227
+
228
+ auto mode = ConvertFromV8String(isolate, args[0]);
229
+ auto points = args[1].As<v8::Array>();
230
+ auto size = points->Length();
231
+
232
+
233
+ if ((size % 2) == 0) {
234
+ int32_t pointMode = -1;
235
+ if (mode == "points") {
236
+ pointMode = 0;
237
+ } else if (mode == "lines") {
238
+ pointMode = 1;
239
+ } else if (mode == "polygon") {
240
+ pointMode = 2;
241
+ }
242
+ if (pointMode == -1) {
243
+ return;
244
+ }
245
+ std::vector<float> store;
246
+ store.reserve(size);
247
+ int next = 0;
248
+ for (int i = 0; i < size; i++) {
249
+
250
+ auto object = points->Get(
251
+ context, i).ToLocalChecked().As<v8::Object>();
252
+
253
+ auto x = object->Get(context,
254
+ ConvertToV8String(isolate, "x")).ToLocalChecked()->NumberValue(
255
+ context).ToChecked();
256
+ auto y = object->Get(context,
257
+ ConvertToV8String(isolate, "y")).ToLocalChecked()->NumberValue(
258
+ context).ToChecked();
259
+ store[next] = (float) x;
260
+ store[next + 1] = (float) y;
261
+
262
+ next = i + 2;
263
+ }
264
+
265
+ canvas_native_context_draw_points(
266
+ ptr->GetContext(), pointMode,
267
+ store.data(), store.size());
268
+
269
+
270
+ ptr->UpdateInvalidateState();
271
+ }
272
+ }
273
+
274
+ void CanvasRenderingContext2DImpl::DrawPaint(const v8::FunctionCallbackInfo<v8::Value> &args) {
275
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
276
+ if (ptr == nullptr) {
277
+ return;
278
+ }
279
+
280
+ auto isolate = args.GetIsolate();
281
+
282
+
283
+ auto color = ConvertFromV8String(isolate, args[0]);
284
+ canvas_native_context_draw_paint(
285
+ ptr->GetContext(), color.c_str());
286
+ ptr->UpdateInvalidateState();
287
+ }
288
+
289
+ /* Non Standard 2D */
290
+
291
+
292
+ void CanvasRenderingContext2DImpl::__MakeDirty(const v8::FunctionCallbackInfo<v8::Value> &args) {
293
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
294
+ if (ptr == nullptr) {
295
+ return;
296
+ }
297
+ ptr->UpdateInvalidateState();
298
+ }
299
+
300
+ void CanvasRenderingContext2DImpl::__GetPointer(const v8::FunctionCallbackInfo<v8::Value> &args) {
301
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
302
+ if (ptr == nullptr) {
303
+ args.GetReturnValue().SetEmptyString();
304
+ return;
305
+ }
306
+
307
+ auto isolate = args.GetIsolate();
308
+
309
+ auto pointer = (intptr_t *) ptr->GetContext();
310
+ auto ret = std::to_string((intptr_t) pointer);
311
+ args.GetReturnValue().Set(ConvertToV8String(isolate, ret));
312
+ }
313
+
314
+ void CanvasRenderingContext2DImpl::__Resize(const v8::FunctionCallbackInfo<v8::Value> &args) {
315
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
316
+ if (ptr == nullptr) {
317
+ return;
318
+ }
319
+
320
+ auto isolate = args.GetIsolate();
321
+ auto context = isolate->GetCurrentContext();
322
+
323
+
324
+ auto width = args[0]->NumberValue(context).ToChecked();
325
+ auto height = args[1]->NumberValue(context).ToChecked();
326
+ canvas_native_context_resize(
327
+ ptr->GetContext(),
328
+ static_cast<float>(width),
329
+ static_cast<float>(height));
330
+ }
331
+
332
+
333
+ void CanvasRenderingContext2DImpl::GetFilter(v8::Local<v8::String> property,
334
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
335
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
336
+ if (ptr == nullptr) {
337
+ info.GetReturnValue().SetEmptyString();
338
+ return;
339
+ }
340
+ auto isolate = info.GetIsolate();
341
+ auto filter = canvas_native_context_get_filter(ptr->GetContext());
342
+ info.GetReturnValue().Set(ConvertToV8String(isolate, filter));
343
+ canvas_native_string_destroy((char *) filter);
344
+ }
345
+
346
+ void CanvasRenderingContext2DImpl::SetFilter(v8::Local<v8::String> property,
347
+ v8::Local<v8::Value> value,
348
+ const v8::PropertyCallbackInfo<void> &info) {
349
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
350
+ if (ptr == nullptr) {
351
+ return;
352
+ }
353
+ auto isolate = info.GetIsolate();
354
+ auto val = ConvertFromV8String(isolate, value);
355
+ canvas_native_context_set_filter(ptr->GetContext(), val.c_str());
356
+ }
357
+
358
+ void CanvasRenderingContext2DImpl::GetFont(v8::Local<v8::String> property,
359
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
360
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
361
+ if (ptr == nullptr) {
362
+ info.GetReturnValue().SetEmptyString();
363
+ return;
364
+ }
365
+ auto isolate = info.GetIsolate();
366
+ auto font = canvas_native_context_get_font(ptr->GetContext());
367
+ info.GetReturnValue().Set(ConvertToV8String(isolate, font));
368
+
369
+ canvas_native_string_destroy((char *) font);
370
+ }
371
+
372
+ void CanvasRenderingContext2DImpl::SetFont(v8::Local<v8::String> property,
373
+ v8::Local<v8::Value> value,
374
+ const v8::PropertyCallbackInfo<void> &info) {
375
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
376
+ if (ptr == nullptr) {
377
+ return;
378
+ }
379
+ auto isolate = info.GetIsolate();
380
+ auto val = ConvertFromV8String(isolate, value);
381
+ canvas_native_context_set_font(ptr->GetContext(), val.c_str());
382
+ }
383
+
384
+ void CanvasRenderingContext2DImpl::GetGlobalAlpha(v8::Local<v8::String> property,
385
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
386
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
387
+ if (ptr == nullptr) {
388
+ info.GetReturnValue().Set(1);
389
+ return;
390
+ }
391
+ auto alpha = canvas_native_context_get_global_alpha(ptr->GetContext());
392
+ info.GetReturnValue().Set((double) alpha);
393
+ }
394
+
395
+ void CanvasRenderingContext2DImpl::SetGlobalAlpha(v8::Local<v8::String> property,
396
+ v8::Local<v8::Value> value,
397
+ const v8::PropertyCallbackInfo<void> &info) {
398
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
399
+ if (ptr == nullptr) {
400
+ return;
401
+ }
402
+ auto isolate = info.GetIsolate();
403
+ auto context = isolate->GetCurrentContext();
404
+ canvas_native_context_set_global_alpha(ptr->GetContext(),
405
+ (float) value->NumberValue(context).ToChecked());
406
+ }
407
+
408
+ void CanvasRenderingContext2DImpl::GetImageSmoothingEnabled(v8::Local<v8::String> property,
409
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
410
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
411
+ if (ptr == nullptr) {
412
+ info.GetReturnValue().Set(false);
413
+ return;
414
+ }
415
+ auto enabled = canvas_native_context_get_image_smoothing_enabled(ptr->GetContext());
416
+ info.GetReturnValue().Set(enabled);
417
+ }
418
+
419
+ void CanvasRenderingContext2DImpl::SetImageSmoothingEnabled(v8::Local<v8::String> property,
420
+ v8::Local<v8::Value> value,
421
+ const v8::PropertyCallbackInfo<void> &info) {
422
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
423
+ if (ptr == nullptr) {
424
+ return;
425
+ }
426
+ auto isolate = info.GetIsolate();
427
+ canvas_native_context_set_image_smoothing_enabled(ptr->GetContext(),
428
+ value->BooleanValue(isolate));
429
+ }
430
+
431
+ void CanvasRenderingContext2DImpl::GetImageSmoothingQuality(v8::Local<v8::String> property,
432
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
433
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
434
+ if (ptr == nullptr) {
435
+ info.GetReturnValue().SetEmptyString();
436
+ return;
437
+ }
438
+ auto isolate = info.GetIsolate();
439
+ auto quality = canvas_native_context_get_image_smoothing_quality(ptr->GetContext());
440
+ info.GetReturnValue().Set(
441
+ ConvertToV8String(isolate, quality));
442
+
443
+ canvas_native_string_destroy((char *) quality);
444
+
445
+ }
446
+
447
+ void CanvasRenderingContext2DImpl::SetImageSmoothingQuality(v8::Local<v8::String> property,
448
+ v8::Local<v8::Value> value,
449
+ const v8::PropertyCallbackInfo<void> &info) {
450
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
451
+ if (ptr == nullptr) {
452
+ return;
453
+ }
454
+ auto isolate = info.GetIsolate();
455
+ auto quality = ConvertFromV8String(isolate, value);
456
+ canvas_native_context_set_image_smoothing_quality(ptr->GetContext(), quality.c_str());
457
+ }
458
+
459
+ void CanvasRenderingContext2DImpl::GetLineDashOffset(v8::Local<v8::String> property,
460
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
461
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
462
+ if (ptr == nullptr) {
463
+ info.GetReturnValue().Set(0);
464
+ return;
465
+ }
466
+ auto offset = canvas_native_context_get_line_dash_offset(ptr->GetContext());
467
+ info.GetReturnValue().Set((double) offset);
468
+ }
469
+
470
+ void CanvasRenderingContext2DImpl::SetLineDashOffset(v8::Local<v8::String> property,
471
+ v8::Local<v8::Value> value,
472
+ const v8::PropertyCallbackInfo<void> &info) {
473
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
474
+ if (ptr == nullptr) {
475
+ return;
476
+ }
477
+ auto isolate = info.GetIsolate();
478
+ auto context = isolate->GetCurrentContext();
479
+ canvas_native_context_set_line_dash_offset(ptr->GetContext(),
480
+ (float) value->NumberValue(context).ToChecked());
481
+ }
482
+
483
+
484
+ void CanvasRenderingContext2DImpl::GetLineJoin(v8::Local<v8::String> property,
485
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
486
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
487
+ if (ptr == nullptr) {
488
+ info.GetReturnValue().Set(0);
489
+ return;
490
+ }
491
+ auto isolate = info.GetIsolate();
492
+ auto join = canvas_native_context_get_line_join(ptr->GetContext());
493
+ info.GetReturnValue().Set(ConvertToV8String(isolate, join));
494
+
495
+ canvas_native_string_destroy((char *) join);
496
+ }
497
+
498
+ void CanvasRenderingContext2DImpl::SetLineJoin(v8::Local<v8::String> property,
499
+ v8::Local<v8::Value> value,
500
+ const v8::PropertyCallbackInfo<void> &info) {
501
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
502
+ if (ptr == nullptr) {
503
+ return;
504
+ }
505
+ auto isolate = info.GetIsolate();
506
+ auto join = ConvertFromV8String(isolate, value);
507
+ canvas_native_context_set_line_join(ptr->GetContext(), join.c_str());
508
+ }
509
+
510
+ void CanvasRenderingContext2DImpl::GetLineCap(v8::Local<v8::String> property,
511
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
512
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
513
+ if (ptr == nullptr) {
514
+ info.GetReturnValue().Set(0);
515
+ return;
516
+ }
517
+ auto isolate = info.GetIsolate();
518
+ auto cap = canvas_native_context_get_line_cap(ptr->GetContext());
519
+ info.GetReturnValue().Set(ConvertToV8String(isolate, cap));
520
+
521
+ canvas_native_string_destroy((char *) cap);
522
+ }
523
+
524
+ void CanvasRenderingContext2DImpl::SetLineCap(v8::Local<v8::String> property,
525
+ v8::Local<v8::Value> value,
526
+ const v8::PropertyCallbackInfo<void> &info) {
527
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
528
+ if (ptr == nullptr) {
529
+ return;
530
+ }
531
+ auto isolate = info.GetIsolate();
532
+ auto cap = ConvertFromV8String(isolate, value);
533
+ canvas_native_context_set_line_cap(ptr->GetContext(), cap.c_str());
534
+ }
535
+
536
+
537
+ void CanvasRenderingContext2DImpl::GetMiterLimit(v8::Local<v8::String> property,
538
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
539
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
540
+ if (ptr == nullptr) {
541
+ info.GetReturnValue().Set(0);
542
+ return;
543
+ }
544
+ auto limit = canvas_native_context_get_miter_limit(ptr->GetContext());
545
+ info.GetReturnValue().Set((double) limit);
546
+ }
547
+
548
+ void CanvasRenderingContext2DImpl::SetMiterLimit(v8::Local<v8::String> property,
549
+ v8::Local<v8::Value> value,
550
+ const v8::PropertyCallbackInfo<void> &info) {
551
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
552
+ if (ptr == nullptr) {
553
+ return;
554
+ }
555
+ auto isolate = info.GetIsolate();
556
+ auto context = isolate->GetCurrentContext();
557
+ canvas_native_context_set_miter_limit(ptr->GetContext(),
558
+ (float) value->NumberValue(context).ToChecked());
559
+ }
560
+
561
+
562
+ void CanvasRenderingContext2DImpl::GetShadowColor(v8::Local<v8::String> property,
563
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
564
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
565
+ if (ptr == nullptr) {
566
+ info.GetReturnValue().Set(0);
567
+ return;
568
+ }
569
+ auto isolate = info.GetIsolate();
570
+ auto color = canvas_native_context_get_shadow_color(ptr->GetContext());
571
+ info.GetReturnValue().Set(ConvertToV8String(isolate, color));
572
+ canvas_native_string_destroy((char *) color);
573
+ }
574
+
575
+ void CanvasRenderingContext2DImpl::SetShadowColor(v8::Local<v8::String> property,
576
+ v8::Local<v8::Value> value,
577
+ const v8::PropertyCallbackInfo<void> &info) {
578
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
579
+ if (ptr == nullptr) {
580
+ return;
581
+ }
582
+ auto isolate = info.GetIsolate();
583
+ auto color = ConvertFromV8String(isolate, value);
584
+ canvas_native_context_set_shadow_color(ptr->GetContext(), color.c_str());
585
+ }
586
+
587
+
588
+ void CanvasRenderingContext2DImpl::GetShadowBlur(v8::Local<v8::String> property,
589
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
590
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
591
+ if (ptr == nullptr) {
592
+ info.GetReturnValue().Set(0);
593
+ return;
594
+ }
595
+ auto blur = canvas_native_context_get_shadow_blur(ptr->GetContext());
596
+ info.GetReturnValue().Set((double) blur);
597
+ }
598
+
599
+ void CanvasRenderingContext2DImpl::SetShadowBlur(v8::Local<v8::String> property,
600
+ v8::Local<v8::Value> value,
601
+ const v8::PropertyCallbackInfo<void> &info) {
602
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
603
+ if (ptr == nullptr) {
604
+ return;
605
+ }
606
+ auto isolate = info.GetIsolate();
607
+ auto context = isolate->GetCurrentContext();
608
+ canvas_native_context_set_shadow_blur(ptr->GetContext(),
609
+ (float) value->NumberValue(context).ToChecked());
610
+ }
611
+
612
+ void CanvasRenderingContext2DImpl::GetShadowOffsetX(v8::Local<v8::String> property,
613
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
614
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
615
+ if (ptr == nullptr) {
616
+ info.GetReturnValue().Set(0);
617
+ return;
618
+ }
619
+ auto x = canvas_native_context_get_shadow_offset_x(ptr->GetContext());
620
+ info.GetReturnValue().Set((double) x);
621
+ }
622
+
623
+ void CanvasRenderingContext2DImpl::SetShadowOffsetX(v8::Local<v8::String> property,
624
+ v8::Local<v8::Value> value,
625
+ const v8::PropertyCallbackInfo<void> &info) {
626
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
627
+ if (ptr == nullptr) {
628
+ return;
629
+ }
630
+ auto isolate = info.GetIsolate();
631
+ auto context = isolate->GetCurrentContext();
632
+ canvas_native_context_set_shadow_offset_x(ptr->GetContext(),
633
+ (float) value->NumberValue(context).ToChecked());
634
+ }
635
+
636
+
637
+ void CanvasRenderingContext2DImpl::GetShadowOffsetY(v8::Local<v8::String> property,
638
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
639
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
640
+ if (ptr == nullptr) {
641
+ info.GetReturnValue().Set(0);
642
+ return;
643
+ }
644
+ auto y = canvas_native_context_get_shadow_offset_y(ptr->GetContext());
645
+ info.GetReturnValue().Set((double) y);
646
+ }
647
+
648
+ void CanvasRenderingContext2DImpl::SetShadowOffsetY(v8::Local<v8::String> property,
649
+ v8::Local<v8::Value> value,
650
+ const v8::PropertyCallbackInfo<void> &info) {
651
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
652
+ if (ptr == nullptr) {
653
+ return;
654
+ }
655
+ auto isolate = info.GetIsolate();
656
+ auto context = isolate->GetCurrentContext();
657
+ canvas_native_context_set_shadow_offset_y(ptr->GetContext(),
658
+ (float) value->NumberValue(context).ToChecked());
659
+ }
660
+
661
+
662
+ void CanvasRenderingContext2DImpl::GetTextAlign(v8::Local<v8::String> property,
663
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
664
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
665
+ if (ptr == nullptr) {
666
+ info.GetReturnValue().Set(0);
667
+ return;
668
+ }
669
+ auto isolate = info.GetIsolate();
670
+ auto alignment = canvas_native_context_get_text_align(ptr->GetContext());
671
+ info.GetReturnValue().Set(
672
+ ConvertToV8String(isolate, alignment));
673
+ canvas_native_string_destroy((char *) alignment);
674
+ }
675
+
676
+ void CanvasRenderingContext2DImpl::SetTextAlign(v8::Local<v8::String> property,
677
+ v8::Local<v8::Value> value,
678
+ const v8::PropertyCallbackInfo<void> &info) {
679
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
680
+ if (ptr == nullptr) {
681
+ return;
682
+ }
683
+ auto isolate = info.GetIsolate();
684
+ auto alignment = ConvertFromV8String(isolate, value);
685
+ canvas_native_context_set_text_align(ptr->GetContext(), alignment.c_str());
686
+ }
687
+
688
+
689
+ void CanvasRenderingContext2DImpl::GetGlobalCompositeOperation(v8::Local<v8::String> property,
690
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
691
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
692
+ if (ptr == nullptr) {
693
+ info.GetReturnValue().Set(0);
694
+ return;
695
+ }
696
+ auto operation = canvas_native_context_get_global_composition(ptr->GetContext());
697
+ info.GetReturnValue().Set(
698
+ ConvertToV8String(info.GetIsolate(), operation));
699
+
700
+ canvas_native_string_destroy((char *) operation);
701
+ }
702
+
703
+ void CanvasRenderingContext2DImpl::SetGlobalCompositeOperation(v8::Local<v8::String> property,
704
+ v8::Local<v8::Value> value,
705
+ const v8::PropertyCallbackInfo<void> &info) {
706
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
707
+ if (ptr == nullptr) {
708
+ return;
709
+ }
710
+ auto isolate = info.GetIsolate();
711
+ auto operation = ConvertFromV8String(isolate, value);
712
+ canvas_native_context_set_global_composition(ptr->GetContext(), operation.c_str());
713
+ }
714
+
715
+
716
+ void CanvasRenderingContext2DImpl::GetFillStyle(v8::Local<v8::String> property,
717
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
718
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
719
+ if (ptr == nullptr) {
720
+ info.GetReturnValue().Set(0);
721
+ return;
722
+ }
723
+ auto isolate = info.GetIsolate();
724
+
725
+ PaintStyleType type = canvas_native_context_get_current_fill_style_type(ptr->GetContext());
726
+
727
+ switch (type) {
728
+ case PaintStyleType::PaintStyleTypeColor: {
729
+ auto color = canvas_native_paint_style_get_current_fill_color_string(
730
+ ptr->GetContext());
731
+
732
+
733
+ auto value = new OneByteStringResource((char *) color);
734
+ auto ret = v8::String::NewExternalOneByte(isolate, value);
735
+ info.GetReturnValue().Set(ret.ToLocalChecked());
736
+
737
+ //info.GetReturnValue().Set(ConvertToV8String(isolate, color.c_str()));
738
+ break;
739
+ }
740
+ case PaintStyleType::PaintStyleTypeGradient: {
741
+ auto style = CanvasGradient::NewInstance(isolate, new CanvasGradient(
742
+ canvas_native_context_get_fill_style(ptr->GetContext())));
743
+
744
+ info.GetReturnValue().Set(style);
745
+
746
+ break;
747
+ }
748
+ case PaintStyleType::PaintStyleTypePattern: {
749
+ auto style = CanvasPattern::NewInstance(isolate, new CanvasPattern(
750
+ canvas_native_context_get_fill_style(ptr->GetContext())));
751
+
752
+ info.GetReturnValue().Set(style);
753
+ break;
754
+ }
755
+ case PaintStyleType::PaintStyleTypeNone: {
756
+ info.GetReturnValue().SetUndefined();
757
+ break;
758
+ }
759
+ }
760
+
761
+ }
762
+
763
+ void CanvasRenderingContext2DImpl::SetFillStyle(v8::Local<v8::String> property,
764
+ v8::Local<v8::Value> value,
765
+ const v8::PropertyCallbackInfo<void> &info) {
766
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
767
+ if (ptr == nullptr) {
768
+ return;
769
+ }
770
+ auto isolate = info.GetIsolate();
771
+ auto context = isolate->GetCurrentContext();
772
+
773
+ if (value->IsString()) {
774
+ auto style = ConvertFromV8String(isolate, value);
775
+ canvas_native_paint_style_set_fill_color_with_c_string(ptr->GetContext(),
776
+ style.c_str());
777
+ } else if (value->IsObject()) {
778
+
779
+ auto type = GetNativeType(isolate, value);
780
+
781
+ switch (type) {
782
+ case NativeType::CanvasGradient: {
783
+ auto gradient = CanvasGradient::GetPointer(value.As<v8::Object>());
784
+ canvas_native_context_set_fill_style(ptr->GetContext(),
785
+ gradient->GetPaintStyle());
786
+ }
787
+ break;
788
+ case NativeType::CanvasPattern: {
789
+ auto pattern = CanvasPattern::GetPointer(value.As<v8::Object>());
790
+ canvas_native_context_set_fill_style(ptr->GetContext(),
791
+ pattern->GetPaintStyle());
792
+ }
793
+ break;
794
+ default:
795
+ // noop
796
+ break;
797
+ }
798
+ }
799
+ }
800
+
801
+ void CanvasRenderingContext2DImpl::GetStrokeStyle(v8::Local<v8::String> property,
802
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
803
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
804
+ if (ptr == nullptr) {
805
+ info.GetReturnValue().SetUndefined();
806
+ return;
807
+ }
808
+ auto isolate = info.GetIsolate();
809
+
810
+ PaintStyleType type = canvas_native_context_get_current_stroke_style_type(ptr->GetContext());
811
+
812
+ switch (type) {
813
+ case PaintStyleType::PaintStyleTypeColor: {
814
+ auto color = canvas_native_paint_style_get_current_stroke_color_string(
815
+ ptr->GetContext());
816
+
817
+ auto value = new OneByteStringResource((char *) color);
818
+ auto ret = v8::String::NewExternalOneByte(isolate, value);
819
+ info.GetReturnValue().Set(ret.ToLocalChecked());
820
+
821
+ //info.GetReturnValue().Set(ConvertToV8String(isolate, color.c_str()));
822
+ break;
823
+ }
824
+ case PaintStyleType::PaintStyleTypeGradient: {
825
+ auto style = CanvasGradient::NewInstance(isolate, new CanvasGradient(
826
+ canvas_native_context_get_stroke_style(ptr->GetContext())));
827
+
828
+ info.GetReturnValue().Set(style);
829
+
830
+ break;
831
+ }
832
+ case PaintStyleType::PaintStyleTypePattern: {
833
+ auto style = CanvasPattern::NewInstance(isolate, new CanvasPattern(
834
+ canvas_native_context_get_stroke_style(ptr->GetContext())));
835
+
836
+ info.GetReturnValue().Set(style);
837
+ break;
838
+ }
839
+ case PaintStyleType::PaintStyleTypeNone: {
840
+ info.GetReturnValue().SetUndefined();
841
+ break;
842
+ }
843
+ }
844
+
845
+ }
846
+
847
+
848
+ void CanvasRenderingContext2DImpl::SetStrokeStyle(v8::Local<v8::String> property,
849
+ v8::Local<v8::Value> value,
850
+ const v8::PropertyCallbackInfo<void> &info) {
851
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
852
+ if (ptr == nullptr) {
853
+ return;
854
+ }
855
+ auto isolate = info.GetIsolate();
856
+ auto context = isolate->GetCurrentContext();
857
+
858
+ if (value->IsString()) {
859
+ auto style = ConvertFromV8String(isolate, value);
860
+ canvas_native_paint_style_set_stroke_color_with_c_string(ptr->GetContext(),
861
+ style.c_str());
862
+ } else if (value->IsObject()) {
863
+
864
+ auto type = GetNativeType(isolate, value);
865
+
866
+ switch (type) {
867
+ case NativeType::CanvasGradient: {
868
+ auto gradient = CanvasGradient::GetPointer(value.As<v8::Object>());
869
+ canvas_native_context_set_stroke_style(ptr->GetContext(),
870
+ gradient->GetPaintStyle());
871
+ }
872
+ break;
873
+ case NativeType::CanvasPattern: {
874
+ auto pattern = CanvasPattern::GetPointer(value.As<v8::Object>());
875
+ canvas_native_context_set_stroke_style(ptr->GetContext(),
876
+ pattern->GetPaintStyle());
877
+ }
878
+ break;
879
+ default:
880
+ break;
881
+ }
882
+ }
883
+ }
884
+
885
+
886
+ void CanvasRenderingContext2DImpl::GetLineWidth(v8::Local<v8::String> property,
887
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
888
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
889
+ if (ptr == nullptr) {
890
+ info.GetReturnValue().Set(0);
891
+ return;
892
+ }
893
+
894
+ auto lineWidth = canvas_native_context_get_line_width(ptr->GetContext());
895
+
896
+ info.GetReturnValue().Set((double) lineWidth);
897
+
898
+ }
899
+
900
+
901
+ void CanvasRenderingContext2DImpl::SetLineWidth(v8::Local<v8::String> property,
902
+ v8::Local<v8::Value> value,
903
+ const v8::PropertyCallbackInfo<void> &info) {
904
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
905
+ if (ptr == nullptr) {
906
+ return;
907
+ }
908
+ auto isolate = info.GetIsolate();
909
+ auto context = isolate->GetCurrentContext();
910
+
911
+ auto lineWidth = (float) value->NumberValue(context).ToChecked();
912
+ canvas_native_context_set_line_width(ptr->GetContext(), lineWidth);
913
+ }
914
+
915
+ void CanvasRenderingContext2DImpl::GetLineDash(v8::Local<v8::String> property,
916
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
917
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
918
+ if (ptr == nullptr) {
919
+ info.GetReturnValue().Set(0);
920
+ return;
921
+ }
922
+
923
+ auto isolate = info.GetIsolate();
924
+ auto context = isolate->GetCurrentContext();
925
+
926
+ auto lineDash = canvas_native_context_get_line_dash(ptr->GetContext());
927
+ auto buf = canvas_native_f32_buffer_get_bytes(lineDash);
928
+ auto size = canvas_native_f32_buffer_get_length(lineDash);
929
+ auto ret = v8::Array::New(isolate, (int) size);
930
+ for (int i = 0; i < size; i++) {
931
+ auto item = buf[i];
932
+ ret->Set(context, i, v8::Number::New(isolate, (double) item));
933
+ }
934
+
935
+ }
936
+
937
+
938
+ void CanvasRenderingContext2DImpl::SetLineDash(v8::Local<v8::String> property,
939
+ v8::Local<v8::Value> value,
940
+ const v8::PropertyCallbackInfo<void> &info) {
941
+ CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
942
+ if (ptr == nullptr) {
943
+ return;
944
+ }
945
+ auto isolate = info.GetIsolate();
946
+ auto context = isolate->GetCurrentContext();
947
+
948
+ if (!value->IsNullOrUndefined() && value->IsObject()) {
949
+ auto lineDashObject = value.As<v8::Object>();
950
+ if (lineDashObject->IsArray()) {
951
+ auto lineDash = lineDashObject.As<v8::Array>();
952
+ auto size = lineDash->Length();
953
+ std::vector<float> dash;
954
+ dash.reserve(size);
955
+ for (int i = 0; i < size; ++i) {
956
+ auto val = lineDash->Get(context, i).ToLocalChecked();
957
+ dash[i] = (float) val->NumberValue(context).ToChecked();
958
+ }
959
+ canvas_native_context_set_line_dash(ptr->GetContext(), dash.data(),
960
+ dash.size());
961
+ }
962
+ }
963
+ }
964
+
965
+ void CanvasRenderingContext2DImpl::AddHitRegion(const v8::FunctionCallbackInfo<v8::Value> &args) {
966
+ // todo
967
+ // CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
968
+ // if (ptr == nullptr) {
969
+ // return;
970
+ // }
971
+ }
972
+
973
+ void CanvasRenderingContext2DImpl::Arc(const v8::FunctionCallbackInfo<v8::Value> &args) {
974
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
975
+ if (ptr == nullptr) {
976
+ return;
977
+ }
978
+
979
+ auto isolate = args.GetIsolate();
980
+ auto context = isolate->GetCurrentContext();
981
+
982
+ auto anti_clockwise = false;
983
+ if (args.Length() == 6) {
984
+ anti_clockwise = args[5]->BooleanValue(isolate);
985
+ }
986
+ canvas_native_context_arc(
987
+ ptr->GetContext(),
988
+ static_cast<float>(args[0]->NumberValue(context).ToChecked()),
989
+ static_cast<float>(args[1]->NumberValue(context).ToChecked()),
990
+ static_cast<float>(args[2]->NumberValue(context).ToChecked()),
991
+ static_cast<float>(args[3]->NumberValue(context).ToChecked()),
992
+ static_cast<float>(args[4]->NumberValue(context).ToChecked()),
993
+ anti_clockwise
994
+ );
995
+ }
996
+
997
+ void CanvasRenderingContext2DImpl::ArcTo(const v8::FunctionCallbackInfo<v8::Value> &args) {
998
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
999
+ if (ptr == nullptr) {
1000
+ return;
1001
+ }
1002
+
1003
+ auto isolate = args.GetIsolate();
1004
+ auto context = isolate->GetCurrentContext();
1005
+
1006
+ auto x1 = static_cast<float>(args[0]->NumberValue(context).ToChecked());
1007
+ auto y1 = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1008
+ auto x2 = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1009
+ auto y2 = static_cast<float>(args[3]->NumberValue(context).ToChecked());
1010
+ auto radius = static_cast<float>(args[4]->NumberValue(context).ToChecked());
1011
+ canvas_native_context_arc_to(
1012
+ ptr->GetContext(),
1013
+ x1,
1014
+ y1,
1015
+ x2,
1016
+ y2,
1017
+ radius
1018
+ );
1019
+ }
1020
+
1021
+ void CanvasRenderingContext2DImpl::BeginPath(const v8::FunctionCallbackInfo<v8::Value> &args) {
1022
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1023
+ if (ptr == nullptr) {
1024
+ return;
1025
+ }
1026
+
1027
+ canvas_native_context_begin_path(
1028
+ ptr->GetContext()
1029
+ );
1030
+ }
1031
+
1032
+ void CanvasRenderingContext2DImpl::BezierCurveTo(const v8::FunctionCallbackInfo<v8::Value> &args) {
1033
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1034
+ if (ptr == nullptr) {
1035
+ return;
1036
+ }
1037
+
1038
+ auto isolate = args.GetIsolate();
1039
+ auto context = isolate->GetCurrentContext();
1040
+
1041
+ canvas_native_context_bezier_curve_to(
1042
+ ptr->GetContext(),
1043
+ static_cast<float>(args[0]->NumberValue(context).ToChecked()),
1044
+ static_cast<float>(args[1]->NumberValue(context).ToChecked()),
1045
+ static_cast<float>(args[2]->NumberValue(context).ToChecked()),
1046
+ static_cast<float>(args[3]->NumberValue(context).ToChecked()),
1047
+ static_cast<float>(args[4]->NumberValue(context).ToChecked()),
1048
+ static_cast<float>(args[5]->NumberValue(context).ToChecked())
1049
+ );
1050
+ }
1051
+
1052
+ void
1053
+ CanvasRenderingContext2DImpl::ClearHitRegions(const v8::FunctionCallbackInfo<v8::Value> &args) {
1054
+ // TODO
1055
+ // CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1056
+ // if (ptr == nullptr) {
1057
+ // return;
1058
+ // }
1059
+ }
1060
+
1061
+ void CanvasRenderingContext2DImpl::ClearRect(const v8::FunctionCallbackInfo<v8::Value> &args) {
1062
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1063
+ if (ptr == nullptr) {
1064
+ return;
1065
+ }
1066
+
1067
+ auto isolate = args.GetIsolate();
1068
+ auto context = isolate->GetCurrentContext();
1069
+
1070
+ canvas_native_context_clear_rect(
1071
+ ptr->GetContext(),
1072
+ static_cast<float>(args[0]->NumberValue(context).ToChecked()),
1073
+ static_cast<float>(args[1]->NumberValue(context).ToChecked()),
1074
+ static_cast<float>(args[2]->NumberValue(context).ToChecked()),
1075
+ static_cast<float>(args[3]->NumberValue(context).ToChecked())
1076
+ );
1077
+ ptr->UpdateInvalidateState();
1078
+ }
1079
+
1080
+ void CanvasRenderingContext2DImpl::Clip(const v8::FunctionCallbackInfo<v8::Value> &args) {
1081
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1082
+ if (ptr == nullptr) {
1083
+ return;
1084
+ }
1085
+
1086
+ auto isolate = args.GetIsolate();
1087
+
1088
+ if (args.Length() == 0) {
1089
+ std::string rule("nonzero");
1090
+ canvas_native_context_clip_rule(
1091
+ ptr->GetContext(), rule.c_str());
1092
+ } else if (args[0]->IsString()) {
1093
+ auto val = ConvertFromV8String(isolate, args[0]);
1094
+ canvas_native_context_clip_rule(
1095
+ ptr->GetContext(), val.c_str());
1096
+ }
1097
+ }
1098
+
1099
+ void CanvasRenderingContext2DImpl::ClosePath(const v8::FunctionCallbackInfo<v8::Value> &args) {
1100
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1101
+ if (ptr == nullptr) {
1102
+ return;
1103
+ }
1104
+
1105
+ canvas_native_context_close_path(
1106
+ ptr->GetContext());
1107
+ }
1108
+
1109
+ void
1110
+ CanvasRenderingContext2DImpl::CreateImageData(const v8::FunctionCallbackInfo<v8::Value> &args) {
1111
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1112
+ if (ptr == nullptr) {
1113
+ args.GetReturnValue().SetUndefined();
1114
+ return;
1115
+ }
1116
+
1117
+ auto isolate = args.GetIsolate();
1118
+ auto context = isolate->GetCurrentContext();
1119
+ auto count = args.Length();
1120
+ auto value = args[0];
1121
+ if (count == 1 && value->IsObject()) {
1122
+
1123
+ auto typeValue = GetNativeType(isolate, value);
1124
+
1125
+ if (typeValue == NativeType::ImageData) {
1126
+
1127
+ auto object = ImageDataImpl::GetPointer(value.As<v8::Object>());
1128
+
1129
+ auto width = canvas_native_image_data_get_width(
1130
+ object->GetImageData());
1131
+ auto height = canvas_native_image_data_get_height(
1132
+ object->GetImageData());
1133
+ auto data = new ImageDataImpl(
1134
+ canvas_native_image_data_create(
1135
+ width, height));
1136
+ auto ret = ImageDataImpl::GetCtor(isolate)->GetFunction(
1137
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
1138
+
1139
+ auto ext = v8::External::New(isolate, data);
1140
+
1141
+ ret->SetInternalField(0, ext);
1142
+
1143
+ SetNativeType(isolate, ret, NativeType::ImageData);
1144
+
1145
+ args.GetReturnValue().Set(ret);
1146
+
1147
+ return;
1148
+ }
1149
+
1150
+ } else if (count > 1) {
1151
+
1152
+ auto width = (int) args[0]->NumberValue(context).ToChecked();
1153
+ auto height = (int) args[1]->NumberValue(context).ToChecked();
1154
+ auto data = new ImageDataImpl(
1155
+ canvas_native_image_data_create(
1156
+ width, height));
1157
+
1158
+ auto ret = ImageDataImpl::GetCtor(isolate)->GetFunction(
1159
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
1160
+
1161
+ auto ext = v8::External::New(isolate, data);
1162
+
1163
+ ret->SetInternalField(0, ext);
1164
+
1165
+ SetNativeType(isolate, ret, NativeType::ImageData);
1166
+
1167
+ args.GetReturnValue().Set(ret);
1168
+ }
1169
+
1170
+ args.GetReturnValue().SetUndefined();
1171
+ }
1172
+
1173
+ void
1174
+ CanvasRenderingContext2DImpl::CreatePattern(const v8::FunctionCallbackInfo<v8::Value> &args) {
1175
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1176
+ if (ptr == nullptr) {
1177
+ args.GetReturnValue().SetNull();
1178
+ return;
1179
+ }
1180
+ auto isolate = args.GetIsolate();
1181
+
1182
+ if (args.Length() > 1) {
1183
+ auto value = args[0];
1184
+ auto valueType = GetNativeType(isolate, value);
1185
+
1186
+ switch (valueType) {
1187
+ case NativeType::ImageAsset: {
1188
+ auto image_asset = ImageAssetImpl::GetPointer(value.As<v8::Object>());
1189
+ if (image_asset != nullptr) {
1190
+ auto rep = ConvertFromV8String(isolate, args[1]);
1191
+ auto pattern = canvas_native_context_create_pattern_asset(
1192
+ ptr->GetContext(),
1193
+ image_asset->GetImageAsset(), rep.c_str());
1194
+ auto style_type = canvas_native_context_get_style_type(pattern);
1195
+ if (style_type ==
1196
+ PaintStyleType::PaintStyleTypeNone) {
1197
+ args.GetReturnValue().SetUndefined();
1198
+ canvas_native_paint_style_destroy(pattern);
1199
+ } else {
1200
+ auto data = CanvasPattern::NewInstance(isolate, new CanvasPattern(pattern));
1201
+ args.GetReturnValue().Set(data);
1202
+ }
1203
+ }
1204
+ return;
1205
+ }
1206
+ case NativeType::ImageBitmap: {
1207
+ auto image_bitmap = ImageBitmapImpl::GetPointer(value.As<v8::Object>());
1208
+ if (image_bitmap != nullptr) {
1209
+ auto rep = ConvertFromV8String(isolate, args[1]);
1210
+ auto pattern = canvas_native_context_create_pattern_asset(
1211
+ ptr->GetContext(),
1212
+ image_bitmap->GetImageAsset(), rep.c_str());
1213
+ auto style_type = canvas_native_context_get_style_type(pattern);
1214
+ if (style_type ==
1215
+ PaintStyleType::PaintStyleTypeNone) {
1216
+ args.GetReturnValue().SetUndefined();
1217
+ canvas_native_paint_style_destroy(pattern);
1218
+ } else {
1219
+ auto data = CanvasPattern::NewInstance(isolate, new CanvasPattern(pattern));
1220
+ args.GetReturnValue().Set(data);
1221
+ }
1222
+ }
1223
+ return;
1224
+ }
1225
+ case NativeType::CanvasRenderingContext2D: {
1226
+ auto canvas_2d = CanvasRenderingContext2DImpl::GetPointer(
1227
+ value.As<v8::Object>());
1228
+ if (canvas_2d != nullptr) {
1229
+ auto rep = ConvertFromV8String(isolate, args[1]);
1230
+ auto pattern = canvas_native_context_create_pattern_canvas2d(
1231
+ canvas_2d->GetContext(),
1232
+ ptr->GetContext(), rep.c_str());
1233
+ auto style_type = canvas_native_context_get_style_type(pattern);
1234
+ if (style_type ==
1235
+ PaintStyleType::PaintStyleTypeNone) {
1236
+ args.GetReturnValue().SetUndefined();
1237
+ canvas_native_paint_style_destroy(pattern);
1238
+ } else {
1239
+ auto data = CanvasPattern::NewInstance(isolate, new CanvasPattern(pattern));
1240
+ args.GetReturnValue().Set(data);
1241
+ }
1242
+ }
1243
+ return;
1244
+ }
1245
+ case NativeType::WebGLRenderingContextBase: {
1246
+ auto webgl = WebGLRenderingContextBase::GetPointer(value.As<v8::Object>());
1247
+ if (webgl != nullptr) {
1248
+ auto rep = ConvertFromV8String(isolate, args[1]);
1249
+ auto pattern = canvas_native_context_create_pattern_webgl(
1250
+ webgl->GetState(),
1251
+ ptr->GetContext(), rep.c_str());
1252
+ auto type = canvas_native_context_get_style_type(pattern);
1253
+ if (type ==
1254
+ PaintStyleType::PaintStyleTypeNone) {
1255
+ args.GetReturnValue().SetNull();
1256
+ canvas_native_paint_style_destroy(pattern);
1257
+ return;
1258
+ } else {
1259
+ auto ret = CanvasPattern::NewInstance(isolate, new CanvasPattern(
1260
+ pattern));
1261
+ args.GetReturnValue().Set(ret);
1262
+ return;
1263
+ }
1264
+ }
1265
+ return;
1266
+ }
1267
+ default:
1268
+ args.GetReturnValue().SetNull();
1269
+ return;
1270
+ }
1271
+
1272
+ return;
1273
+ }
1274
+
1275
+ args.GetReturnValue().SetNull();
1276
+ }
1277
+
1278
+ void
1279
+ CanvasRenderingContext2DImpl::CreateLinearGradient(
1280
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
1281
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1282
+ if (ptr == nullptr) {
1283
+ args.GetReturnValue().SetUndefined();
1284
+ return;
1285
+ }
1286
+
1287
+ auto isolate = args.GetIsolate();
1288
+ auto context = isolate->GetCurrentContext();
1289
+
1290
+ if (args.Length() == 4) {
1291
+ auto x0 = static_cast<float>(args[0]->NumberValue(context).ToChecked());
1292
+ auto y0 = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1293
+ auto x1 = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1294
+ auto y1 = static_cast<float>(args[3]->NumberValue(context).ToChecked());
1295
+
1296
+ auto gradient = canvas_native_context_create_linear_gradient(
1297
+ ptr->GetContext(), x0, y0, x1,
1298
+ y1);
1299
+
1300
+ auto data = CanvasGradient::NewInstance(isolate, new CanvasGradient(
1301
+ gradient));
1302
+
1303
+ args.GetReturnValue().Set(data);
1304
+
1305
+ return;
1306
+ }
1307
+
1308
+ args.GetReturnValue().SetNull();
1309
+ }
1310
+
1311
+
1312
+ void CanvasRenderingContext2DImpl::CreateConicGradient(
1313
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
1314
+
1315
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1316
+ if (ptr == nullptr) {
1317
+ args.GetReturnValue().SetUndefined();
1318
+ return;
1319
+ }
1320
+
1321
+ auto isolate = args.GetIsolate();
1322
+ auto context = isolate->GetCurrentContext();
1323
+
1324
+ if (args.Length() == 3) {
1325
+
1326
+ auto startAngle = static_cast<float>(args[0]->NumberValue(context).ToChecked());
1327
+ auto x = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1328
+ auto y = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1329
+
1330
+
1331
+ auto gradient = canvas_native_context_create_conic_gradient(
1332
+ ptr->GetContext(), startAngle, x, y);
1333
+
1334
+ auto data = CanvasGradient::NewInstance(isolate, new CanvasGradient(
1335
+ gradient));
1336
+
1337
+ args.GetReturnValue().Set(data);
1338
+
1339
+ return;
1340
+ }
1341
+
1342
+ args.GetReturnValue().SetNull();
1343
+ }
1344
+
1345
+ void
1346
+ CanvasRenderingContext2DImpl::__CreatePatternWithNative(
1347
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
1348
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1349
+ if (ptr == nullptr) {
1350
+ args.GetReturnValue().SetUndefined();
1351
+ return;
1352
+ }
1353
+
1354
+ auto isolate = args.GetIsolate();
1355
+ auto context = isolate->GetCurrentContext();
1356
+
1357
+
1358
+ auto pointer = args[0]->ToBigInt(context).ToLocalChecked();
1359
+
1360
+ auto pattern = canvas_native_pattern_from_ptr(pointer->Int64Value());
1361
+ auto type = canvas_native_context_get_style_type(pattern);
1362
+ if (type == PaintStyleType::PaintStyleTypeNone) {
1363
+ args.GetReturnValue().SetUndefined();
1364
+ canvas_native_paint_style_destroy(pattern);
1365
+ } else {
1366
+ auto data = CanvasPattern::NewInstance(isolate, new CanvasPattern(pattern));
1367
+
1368
+ args.GetReturnValue().Set(data);
1369
+ }
1370
+
1371
+ }
1372
+
1373
+ void
1374
+ CanvasRenderingContext2DImpl::CreateRadialGradient(
1375
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
1376
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1377
+ if (ptr == nullptr) {
1378
+ args.GetReturnValue().SetNull();
1379
+ return;
1380
+ }
1381
+
1382
+ auto isolate = args.GetIsolate();
1383
+ auto context = isolate->GetCurrentContext();
1384
+
1385
+ if (args.Length() == 6) {
1386
+ auto x0 = static_cast<float>(args[0]->NumberValue(context).ToChecked());
1387
+ auto y0 = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1388
+ auto r0 = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1389
+ auto x1 = static_cast<float>(args[3]->NumberValue(context).ToChecked());
1390
+ auto y1 = static_cast<float>(args[4]->NumberValue(context).ToChecked());
1391
+ auto r1 = static_cast<float>(args[5]->NumberValue(context).ToChecked());
1392
+
1393
+ auto gradient = canvas_native_context_create_radial_gradient(
1394
+ ptr->GetContext(), x0, y0, r0,
1395
+ x1, y1, r1);
1396
+
1397
+ auto data = CanvasGradient::NewInstance(isolate, new CanvasGradient(gradient));
1398
+
1399
+ args.GetReturnValue().Set(data);
1400
+ return;
1401
+ }
1402
+
1403
+ args.GetReturnValue().SetNull();
1404
+ }
1405
+
1406
+
1407
+ void
1408
+ CanvasRenderingContext2DImpl::DrawFocusIfNeeded(const v8::FunctionCallbackInfo<v8::Value> &args) {
1409
+ // TODO
1410
+ // CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1411
+ // if (ptr == nullptr) {
1412
+ // return;
1413
+ // }
1414
+ }
1415
+
1416
+
1417
+ void
1418
+ CanvasRenderingContext2DImpl::DrawImage(const v8::FunctionCallbackInfo<v8::Value> &args) {
1419
+
1420
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1421
+ if (ptr == nullptr) {
1422
+ return;
1423
+ }
1424
+
1425
+ auto count = args.Length();
1426
+ auto value = args[0];
1427
+
1428
+ if (value->IsNullOrUndefined() || !value->IsObject()) {
1429
+ return;
1430
+ }
1431
+
1432
+ auto isolate = args.GetIsolate();
1433
+ auto context = isolate->GetCurrentContext();
1434
+ auto image = value.As<v8::Object>();
1435
+ auto imageType = GetNativeType(isolate, image);
1436
+ if (count == 3) {
1437
+ auto dx = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1438
+ auto dy = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1439
+
1440
+ switch (imageType) {
1441
+ case NativeType::ImageAsset: {
1442
+ auto image_asset = ImageAssetImpl::GetPointer(image);
1443
+
1444
+ if (image_asset != nullptr) {
1445
+ canvas_native_context_draw_image_dx_dy_asset(
1446
+ ptr->GetContext(),
1447
+ image_asset->GetImageAsset(),
1448
+ dx, dy);
1449
+ ptr->UpdateInvalidateState();
1450
+ }
1451
+ }
1452
+ break;
1453
+ case NativeType::ImageBitmap: {
1454
+ auto image_bitmap = ImageBitmapImpl::GetPointer(image);
1455
+ if (image_bitmap != nullptr) {
1456
+ canvas_native_context_draw_image_dx_dy_asset(
1457
+ ptr->GetContext(),
1458
+ image_bitmap->GetImageAsset(),
1459
+ dx, dy);
1460
+ ptr->UpdateInvalidateState();
1461
+ }
1462
+ }
1463
+ break;
1464
+ case NativeType::CanvasRenderingContext2D: {
1465
+ auto image_canvas = CanvasRenderingContext2DImpl::GetPointer(image);
1466
+ if (image_canvas != nullptr) {
1467
+ canvas_native_context_draw_image_dx_dy_context(
1468
+ ptr->GetContext(),
1469
+ image_canvas->GetContext(),
1470
+ dx, dy);
1471
+ ptr->UpdateInvalidateState();
1472
+ }
1473
+ }
1474
+ break;
1475
+ default:
1476
+ break;
1477
+ }
1478
+ } else if (count == 5) {
1479
+ auto dx = (float) args[1]->NumberValue(context).ToChecked();
1480
+ auto dy = (float) args[2]->NumberValue(context).ToChecked();
1481
+ auto dWidth = (float) args[3]->NumberValue(context).ToChecked();
1482
+ auto dHeight = (float) args[4]->NumberValue(context).ToChecked();
1483
+
1484
+ switch (imageType) {
1485
+ case NativeType::ImageAsset: {
1486
+ auto image_asset = ImageAssetImpl::GetPointer(image);
1487
+
1488
+ if (image_asset != nullptr) {
1489
+ canvas_native_context_draw_image_dx_dy_dw_dh_asset(
1490
+ ptr->GetContext(),
1491
+ image_asset->GetImageAsset(),
1492
+ dx, dy,
1493
+ dWidth,
1494
+ dHeight);
1495
+ ptr->UpdateInvalidateState();
1496
+ }
1497
+ }
1498
+ break;
1499
+ case NativeType::ImageBitmap: {
1500
+ auto image_bitmap = ImageBitmapImpl::GetPointer(image);
1501
+ if (image_bitmap != nullptr) {
1502
+ canvas_native_context_draw_image_dx_dy_dw_dh_asset(
1503
+ ptr->GetContext(),
1504
+ image_bitmap->GetImageAsset(),
1505
+ dx, dy,
1506
+ dWidth,
1507
+ dHeight);
1508
+ ptr->UpdateInvalidateState();
1509
+ }
1510
+ }
1511
+ break;
1512
+ case NativeType::CanvasRenderingContext2D: {
1513
+ auto image_canvas = CanvasRenderingContext2DImpl::GetPointer(image);
1514
+ if (image_canvas != nullptr) {
1515
+ canvas_native_context_draw_image_dx_dy_dw_dh_context(
1516
+ ptr->GetContext(),
1517
+ image_canvas->GetContext(),
1518
+ dx, dy,
1519
+ dWidth,
1520
+ dHeight);
1521
+ ptr->UpdateInvalidateState();
1522
+ }
1523
+ }
1524
+ break;
1525
+ default:
1526
+ break;
1527
+ }
1528
+
1529
+ } else if (count == 9) {
1530
+ auto sx = (float) args[1]->NumberValue(context).ToChecked();
1531
+ auto sy = (float) args[2]->NumberValue(context).ToChecked();
1532
+ auto sWidth = (float) args[3]->NumberValue(context).ToChecked();
1533
+ auto sHeight = (float) args[4]->NumberValue(context).ToChecked();
1534
+ auto dx = (float) args[5]->NumberValue(context).ToChecked();
1535
+ auto dy = (float) args[6]->NumberValue(context).ToChecked();
1536
+ auto dWidth = (float) args[7]->NumberValue(context).ToChecked();
1537
+ auto dHeight = (float) args[8]->NumberValue(context).ToChecked();
1538
+
1539
+ switch (imageType) {
1540
+ case NativeType::ImageAsset: {
1541
+ auto image_asset = ImageAssetImpl::GetPointer(image);
1542
+
1543
+ if (image_asset != nullptr) {
1544
+ canvas_native_context_draw_image_asset(
1545
+ ptr->GetContext(),
1546
+ image_asset->GetImageAsset(),
1547
+ sx,
1548
+ sy, sWidth, sHeight,
1549
+ dx,
1550
+ dy, dWidth, dHeight);
1551
+ ptr->UpdateInvalidateState();
1552
+ }
1553
+ }
1554
+ break;
1555
+ case NativeType::ImageBitmap: {
1556
+ auto image_bitmap = ImageBitmapImpl::GetPointer(image);
1557
+ if (image_bitmap != nullptr) {
1558
+ canvas_native_context_draw_image_asset(
1559
+ ptr->GetContext(),
1560
+ image_bitmap->GetImageAsset(),
1561
+ sx,
1562
+ sy, sWidth, sHeight,
1563
+ dx,
1564
+ dy, dWidth, dHeight);
1565
+ ptr->UpdateInvalidateState();
1566
+ }
1567
+ }
1568
+ break;
1569
+ case NativeType::CanvasRenderingContext2D: {
1570
+ auto image_canvas = CanvasRenderingContext2DImpl::GetPointer(image);
1571
+ if (image_canvas != nullptr) {
1572
+ canvas_native_context_draw_image_context(
1573
+ ptr->GetContext(),
1574
+ image_canvas->GetContext(),
1575
+ sx,
1576
+ sy, sWidth, sHeight,
1577
+ dx,
1578
+ dy, dWidth, dHeight);
1579
+ ptr->UpdateInvalidateState();
1580
+ }
1581
+ }
1582
+ break;
1583
+ default:
1584
+ break;
1585
+ }
1586
+ }
1587
+ }
1588
+
1589
+
1590
+ void
1591
+ CanvasRenderingContext2DImpl::Ellipse(const v8::FunctionCallbackInfo<v8::Value> &args) {
1592
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1593
+ if (ptr == nullptr) {
1594
+ return;
1595
+ }
1596
+ auto isolate = args.GetIsolate();
1597
+ auto context = isolate->GetCurrentContext();
1598
+
1599
+ if (args.Length() == 8) {
1600
+ auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
1601
+ auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1602
+ auto radiusX = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1603
+ auto radiusY = static_cast<float>(args[3]->NumberValue(context).ToChecked());
1604
+ auto rotation = static_cast<float>(args[4]->NumberValue(context).ToChecked());
1605
+ auto startAngle = static_cast<float>(args[5]->NumberValue(context).ToChecked());
1606
+ auto endAngle = static_cast<float>(args[6]->NumberValue(context).ToChecked());
1607
+ auto anticlockwise = false;
1608
+ if (args[7]->IsBoolean()) {
1609
+ anticlockwise = args[7]->BooleanValue(isolate);
1610
+ }
1611
+ canvas_native_context_ellipse(
1612
+ ptr->GetContext(), x, y,
1613
+ radiusX,
1614
+ radiusY, rotation,
1615
+ startAngle, endAngle,
1616
+ anticlockwise);
1617
+ }
1618
+ }
1619
+
1620
+ void
1621
+ CanvasRenderingContext2DImpl::Fill(const v8::FunctionCallbackInfo<v8::Value> &args) {
1622
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1623
+ if (ptr == nullptr) {
1624
+ return;
1625
+ }
1626
+ auto isolate = args.GetIsolate();
1627
+
1628
+ auto count = args.Length();
1629
+ auto value = args[0];
1630
+ if (count == 2) {
1631
+ auto type = GetNativeType(isolate, value.As<v8::Object>());
1632
+ if (type == NativeType::Path2D) {
1633
+ auto object = Path2D::GetPointer(value.As<v8::Object>());
1634
+
1635
+ if (object != nullptr) {
1636
+ auto data = ConvertFromV8String(isolate, args[1]);
1637
+ canvas_native_context_fill_with_path(
1638
+ ptr->GetContext(),
1639
+ object->GetPath(),
1640
+ data.c_str());
1641
+ ptr->UpdateInvalidateState();
1642
+ }
1643
+ }
1644
+
1645
+ } else if (count == 1) {
1646
+ if (value->IsString()) {
1647
+ auto rule = ConvertFromV8String(isolate, value);
1648
+ canvas_native_context_fill(
1649
+ ptr->GetContext(), rule.c_str());
1650
+ ptr->UpdateInvalidateState();
1651
+ } else if (value->IsObject()) {
1652
+ auto type = GetNativeType(isolate, value.As<v8::Object>());
1653
+ if (type == NativeType::Path2D) {
1654
+ auto object = Path2D::GetPointer(value.As<v8::Object>());
1655
+
1656
+ std::string rule("nonzero");
1657
+ canvas_native_context_fill_with_path(
1658
+ ptr->GetContext(),
1659
+ object->GetPath(), rule.c_str());
1660
+ ptr->UpdateInvalidateState();
1661
+ }
1662
+ }
1663
+ } else {
1664
+ std::string rule("nonzero");
1665
+ canvas_native_context_fill(
1666
+ ptr->GetContext(), rule.c_str());
1667
+ ptr->UpdateInvalidateState();
1668
+ }
1669
+ }
1670
+
1671
+ void
1672
+ CanvasRenderingContext2DImpl::FillRect(const v8::FunctionCallbackInfo<v8::Value> &args) {
1673
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1674
+ if (ptr == nullptr) {
1675
+ return;
1676
+ }
1677
+ auto isolate = args.GetIsolate();
1678
+ auto context = isolate->GetCurrentContext();
1679
+
1680
+ auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
1681
+ auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1682
+ auto width = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1683
+ auto height = static_cast<float>(args[3]->NumberValue(context).ToChecked());
1684
+ canvas_native_context_fill_rect(
1685
+ ptr->GetContext(), x, y, width,
1686
+ height);
1687
+ ptr->UpdateInvalidateState();
1688
+ }
1689
+
1690
+ void
1691
+ CanvasRenderingContext2DImpl::FillText(const v8::FunctionCallbackInfo<v8::Value> &args) {
1692
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1693
+ if (ptr == nullptr) {
1694
+ return;
1695
+ }
1696
+ auto isolate = args.GetIsolate();
1697
+ auto context = isolate->GetCurrentContext();
1698
+
1699
+ auto text = ConvertFromV8String(isolate, args[0]);
1700
+
1701
+ auto x = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1702
+ auto y = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1703
+ float width = -1;
1704
+ if (args[3]->IsNumber()) {
1705
+ width = static_cast<float>(args[3]->NumberValue(context).ToChecked());
1706
+ }
1707
+ canvas_native_context_fill_text(
1708
+ ptr->GetContext(), text.c_str(), x,
1709
+ y, width);
1710
+ ptr->UpdateInvalidateState();
1711
+
1712
+ }
1713
+
1714
+ void
1715
+ CanvasRenderingContext2DImpl::GetImageData(const v8::FunctionCallbackInfo<v8::Value> &args) {
1716
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1717
+ if (ptr == nullptr) {
1718
+ args.GetReturnValue().SetUndefined();
1719
+ return;
1720
+ }
1721
+ auto isolate = args.GetIsolate();
1722
+ auto context = isolate->GetCurrentContext();
1723
+
1724
+
1725
+ if (args.Length() == 4) {
1726
+ auto sx = static_cast<float>(args[0]->NumberValue(context).ToChecked());
1727
+ auto sy = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1728
+ auto sw = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1729
+ auto sh = static_cast<float>(args[3]->NumberValue(context).ToChecked());
1730
+ auto imageData = canvas_native_context_get_image_data(
1731
+ ptr->GetContext(), sx, sy, sw,
1732
+ sh);
1733
+
1734
+ auto data = new ImageDataImpl(imageData);
1735
+
1736
+ auto ret = ImageDataImpl::GetCtor(isolate)->GetFunction(
1737
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
1738
+
1739
+ auto ext = v8::External::New(isolate, data);
1740
+
1741
+ ret->SetInternalField(0, ext);
1742
+
1743
+ SetNativeType(isolate, ret, NativeType::ImageData);
1744
+
1745
+ args.GetReturnValue().Set(ret);
1746
+ return;
1747
+ }
1748
+
1749
+ args.GetReturnValue().SetUndefined();
1750
+
1751
+
1752
+ }
1753
+
1754
+ void
1755
+ CanvasRenderingContext2DImpl::GetLineDash(const v8::FunctionCallbackInfo<v8::Value> &args) {
1756
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1757
+
1758
+ auto isolate = args.GetIsolate();
1759
+
1760
+ if (ptr == nullptr) {
1761
+ auto ret = v8::Array::New(isolate);
1762
+ args.GetReturnValue().Set(ret);
1763
+ return;
1764
+ }
1765
+ auto context = isolate->GetCurrentContext();
1766
+
1767
+
1768
+ auto dash = canvas_native_context_get_line_dash(
1769
+ ptr->GetContext());
1770
+ auto buf = canvas_native_f32_buffer_get_bytes(dash);
1771
+ auto size = canvas_native_f32_buffer_get_length(dash);
1772
+ auto array = v8::Array::New(isolate, (int) size);
1773
+ for (int i = 0; i < size; ++i) {
1774
+ array->Set(context, i,
1775
+ v8::Number::New(isolate,
1776
+ (double) buf[i]));
1777
+ }
1778
+
1779
+ args.GetReturnValue().Set(array);
1780
+ }
1781
+
1782
+ void
1783
+ CanvasRenderingContext2DImpl::IsPointInPath(const v8::FunctionCallbackInfo<v8::Value> &args) {
1784
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1785
+
1786
+ auto isolate = args.GetIsolate();
1787
+ auto context = isolate->GetCurrentContext();
1788
+ auto count = args.Length();
1789
+
1790
+ if (count == 2) {
1791
+ auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
1792
+ auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1793
+ std::string rule("nonzero");
1794
+ auto ret = canvas_native_context_is_point_in_path(
1795
+ ptr->GetContext(), x, y, rule.c_str());
1796
+ args.GetReturnValue().Set(ret);
1797
+ return;
1798
+ } else if (count == 3 &&
1799
+ args[2]->IsString()) {
1800
+ auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
1801
+ auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1802
+ auto rule = ConvertFromV8String(isolate, args[2]);
1803
+ auto ret = canvas_native_context_is_point_in_path(
1804
+ ptr->GetContext(), x, y, rule.c_str());
1805
+ args.GetReturnValue().Set(ret);
1806
+ return;
1807
+ } else if (count == 4 &&
1808
+ args[0]->IsObject() &&
1809
+ args[3]->IsString()) {
1810
+
1811
+
1812
+ auto value = args[0];
1813
+ auto type = GetNativeType(isolate, value);
1814
+
1815
+ if (type == NativeType::Path2D) {
1816
+ auto path = Path2D::GetPointer(value.As<v8::Object>());
1817
+ auto x = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1818
+ auto y = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1819
+ auto rule = ConvertFromV8String(isolate, args[3]);
1820
+
1821
+
1822
+ if (path != nullptr) {
1823
+ auto ret = canvas_native_context_is_point_in_path_with_path(
1824
+ ptr->GetContext(),
1825
+ path->GetPath(), x, y, rule.c_str());
1826
+ args.GetReturnValue().Set(ret);
1827
+ return;
1828
+ }
1829
+ }
1830
+
1831
+ }
1832
+
1833
+
1834
+ args.GetReturnValue().Set(false);
1835
+ }
1836
+
1837
+ void
1838
+ CanvasRenderingContext2DImpl::IsPointInStroke(const v8::FunctionCallbackInfo<v8::Value> &args) {
1839
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1840
+
1841
+ auto isolate = args.GetIsolate();
1842
+ auto context = isolate->GetCurrentContext();
1843
+ auto count = args.Length();
1844
+
1845
+
1846
+ if (count == 2) {
1847
+ auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
1848
+ auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1849
+ auto ret = canvas_native_context_is_point_in_stroke(
1850
+ ptr->GetContext(), x, y);
1851
+
1852
+ args.GetReturnValue().Set(ret);
1853
+ return;
1854
+ } else if (count == 3 &&
1855
+ args[0]->IsObject()) {
1856
+
1857
+
1858
+ auto value = args[0];
1859
+ auto type = GetNativeType(isolate, value);
1860
+
1861
+ if (type == NativeType::Path2D) {
1862
+ auto path = Path2D::GetPointer(value.As<v8::Object>());
1863
+ auto x = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1864
+ auto y = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1865
+ auto rule = ConvertFromV8String(isolate, args[3]);
1866
+
1867
+
1868
+ if (path != nullptr) {
1869
+ auto ret = canvas_native_context_is_point_in_stroke_with_path(
1870
+ ptr->GetContext(),
1871
+ path->GetPath(), x, y);
1872
+ args.GetReturnValue().Set(ret);
1873
+ return;
1874
+ }
1875
+ }
1876
+ }
1877
+
1878
+ args.GetReturnValue().Set(false);
1879
+ }
1880
+
1881
+ void
1882
+ CanvasRenderingContext2DImpl::LineTo(const v8::FunctionCallbackInfo<v8::Value> &args) {
1883
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1884
+
1885
+ auto isolate = args.GetIsolate();
1886
+ auto context = isolate->GetCurrentContext();
1887
+
1888
+ if (args.Length() > 1) {
1889
+ auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
1890
+ auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1891
+ canvas_native_context_line_to(
1892
+ ptr->GetContext(), x, y);
1893
+ }
1894
+ }
1895
+
1896
+ void
1897
+ CanvasRenderingContext2DImpl::MeasureText(const v8::FunctionCallbackInfo<v8::Value> &args) {
1898
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1899
+
1900
+ auto isolate = args.GetIsolate();
1901
+ auto context = isolate->GetCurrentContext();
1902
+
1903
+ auto text = ConvertFromV8String(isolate, args[0]);
1904
+
1905
+ auto metrics = canvas_native_context_measure_text(
1906
+ ptr->GetContext(), text.c_str());
1907
+
1908
+ auto data = new TextMetricsImpl(metrics);
1909
+
1910
+ auto ret = TextMetricsImpl::GetCtor(isolate)->GetFunction(
1911
+ context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
1912
+
1913
+ auto ext = v8::External::New(isolate, data);
1914
+
1915
+ ret->SetInternalField(0, ext);
1916
+
1917
+ SetNativeType(isolate, ret, NativeType::TextMetrics);
1918
+
1919
+ args.GetReturnValue().Set(ret);
1920
+
1921
+ }
1922
+
1923
+ void
1924
+ CanvasRenderingContext2DImpl::MoveTo(const v8::FunctionCallbackInfo<v8::Value> &args) {
1925
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1926
+
1927
+ auto isolate = args.GetIsolate();
1928
+ auto context = isolate->GetCurrentContext();
1929
+
1930
+ if (args.Length() > 1) {
1931
+ auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
1932
+ auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1933
+ canvas_native_context_move_to(
1934
+ ptr->GetContext(), x, y);
1935
+ }
1936
+ }
1937
+
1938
+ void
1939
+ CanvasRenderingContext2DImpl::PutImageData(const v8::FunctionCallbackInfo<v8::Value> &args) {
1940
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1941
+
1942
+ auto isolate = args.GetIsolate();
1943
+ auto context = isolate->GetCurrentContext();
1944
+
1945
+
1946
+ auto value = args[0];
1947
+ auto typeValue = GetPrivateValue(isolate, value.As<v8::Object>(),
1948
+ ConvertToV8String(isolate, "__type"));
1949
+ auto count = args.Length();
1950
+ if (!typeValue.IsEmpty()) {
1951
+ auto type = (NativeType) typeValue->Int32Value(context).ToChecked();
1952
+ if (type == NativeType::ImageData) {
1953
+
1954
+
1955
+ auto imageData = ImageDataImpl::GetPointer(value.As<v8::Object>());
1956
+ if (count == 3) {
1957
+ auto dx = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1958
+ auto dy = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1959
+ float dirtyX = 0;
1960
+ float dirtyY = 0;
1961
+ auto dirtyWidth = (float) canvas_native_image_data_get_width(
1962
+ imageData->GetImageData());
1963
+ auto dirtyHeight = (float) canvas_native_image_data_get_height(
1964
+ imageData->GetImageData());
1965
+ canvas_native_context_put_image_data(
1966
+ ptr->GetContext(),
1967
+ imageData->GetImageData(), dx,
1968
+ dy, dirtyX, dirtyY,
1969
+ dirtyWidth, dirtyHeight);
1970
+ ptr->UpdateInvalidateState();
1971
+ } else if (count == 7) {
1972
+ auto dx = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1973
+ auto dy = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1974
+ auto dirtyX = static_cast<float>(args[3]->NumberValue(context).ToChecked());
1975
+ auto dirtyY = static_cast<float>(args[4]->NumberValue(context).ToChecked());
1976
+ auto dirtyWidth = static_cast<float>(args[5]->NumberValue(context).ToChecked());
1977
+ auto dirtyHeight = static_cast<float>(args[6]->NumberValue(context).ToChecked());
1978
+ canvas_native_context_put_image_data(
1979
+ ptr->GetContext(),
1980
+ imageData->GetImageData(), dx,
1981
+ dy, dirtyX, dirtyY,
1982
+ dirtyWidth, dirtyHeight);
1983
+ ptr->UpdateInvalidateState();
1984
+ }
1985
+ }
1986
+ }
1987
+
1988
+ }
1989
+
1990
+ void
1991
+ CanvasRenderingContext2DImpl::QuadraticCurveTo(const v8::FunctionCallbackInfo<v8::Value> &args) {
1992
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
1993
+
1994
+ auto isolate = args.GetIsolate();
1995
+ auto context = isolate->GetCurrentContext();
1996
+
1997
+ if (args.Length() == 4) {
1998
+ auto cpx = static_cast<float>(args[0]->NumberValue(context).ToChecked());
1999
+ auto cpy = static_cast<float>(args[1]->NumberValue(context).ToChecked());
2000
+ auto x = static_cast<float>(args[2]->NumberValue(context).ToChecked());
2001
+ auto y = static_cast<float>(args[3]->NumberValue(context).ToChecked());
2002
+ canvas_native_context_quadratic_curve_to(
2003
+ ptr->GetContext(), cpx, cpy,
2004
+ x, y);
2005
+ }
2006
+
2007
+ }
2008
+
2009
+ void
2010
+ CanvasRenderingContext2DImpl::RoundRect(const v8::FunctionCallbackInfo<v8::Value> &args) {
2011
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2012
+
2013
+ auto isolate = args.GetIsolate();
2014
+ auto context = isolate->GetCurrentContext();
2015
+
2016
+ if (args.Length() == 5) {
2017
+ auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
2018
+ auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
2019
+ auto width = static_cast<float>(args[2]->NumberValue(context).ToChecked());
2020
+ auto height = static_cast<float>(args[3]->NumberValue(context).ToChecked());
2021
+ if (args[4]->IsObject()) {
2022
+ auto radii = args[4];
2023
+ if (radii->IsArray()) {
2024
+ auto array = radii.As<v8::Array>();
2025
+ auto size = array->Length();
2026
+ if (size > 1) {
2027
+ std::vector<float> store;
2028
+ store.reserve(size);
2029
+ for (int i = 0;
2030
+ i < size; i++) {
2031
+ store[i] = (float) array->Get(
2032
+ context,
2033
+ i).ToLocalChecked()->NumberValue(context).ToChecked();
2034
+ }
2035
+
2036
+
2037
+ canvas_native_context_round_rect(
2038
+ ptr->GetContext(),
2039
+ x, y,
2040
+ width,
2041
+ height, store.data(), store.size());
2042
+
2043
+ }
2044
+ }
2045
+ } else {
2046
+ auto radii = (float) args[4]->NumberValue(context).ToChecked();
2047
+ canvas_native_context_round_rect_tl_tr_br_bl(
2048
+ ptr->GetContext(), x, y,
2049
+ width,
2050
+ height, radii, radii,
2051
+ radii, radii);
2052
+
2053
+ }
2054
+ }
2055
+
2056
+ }
2057
+
2058
+ void
2059
+ CanvasRenderingContext2DImpl::Rect(const v8::FunctionCallbackInfo<v8::Value> &args) {
2060
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2061
+
2062
+ auto isolate = args.GetIsolate();
2063
+ auto context = isolate->GetCurrentContext();
2064
+
2065
+ if (args.Length() == 4) {
2066
+ auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
2067
+ auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
2068
+ auto width = static_cast<float>(args[2]->NumberValue(context).ToChecked());
2069
+ auto height = static_cast<float>(args[3]->NumberValue(context).ToChecked());
2070
+ canvas_native_context_rect(
2071
+ ptr->GetContext(), x, y,
2072
+ width,
2073
+ height);
2074
+ }
2075
+
2076
+ }
2077
+
2078
+ void
2079
+ CanvasRenderingContext2DImpl::RemoveHitRegion(const v8::FunctionCallbackInfo<v8::Value> &args) {
2080
+ // CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2081
+ }
2082
+
2083
+ void
2084
+ CanvasRenderingContext2DImpl::ResetTransform(const v8::FunctionCallbackInfo<v8::Value> &args) {
2085
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2086
+ if (ptr == nullptr) {
2087
+ return;
2088
+ }
2089
+
2090
+ canvas_native_context_reset_transform(
2091
+ ptr->GetContext());
2092
+ }
2093
+
2094
+ void
2095
+ CanvasRenderingContext2DImpl::Restore(const v8::FunctionCallbackInfo<v8::Value> &args) {
2096
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2097
+ if (ptr == nullptr) {
2098
+ return;
2099
+ }
2100
+
2101
+ canvas_native_context_restore(
2102
+ ptr->GetContext());
2103
+ }
2104
+
2105
+ void
2106
+ CanvasRenderingContext2DImpl::Rotate(const v8::FunctionCallbackInfo<v8::Value> &args) {
2107
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2108
+
2109
+ auto isolate = args.GetIsolate();
2110
+ auto context = isolate->GetCurrentContext();
2111
+
2112
+ auto value = args[0];
2113
+
2114
+ if (args.Length() == 1 && value->IsNumber()) {
2115
+ canvas_native_context_rotate(
2116
+ ptr->GetContext(),
2117
+ (float) args[0]->NumberValue(context).ToChecked());
2118
+ }
2119
+ }
2120
+
2121
+ void
2122
+ CanvasRenderingContext2DImpl::Save(const v8::FunctionCallbackInfo<v8::Value> &args) {
2123
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2124
+ if (ptr == nullptr) {
2125
+ return;
2126
+ }
2127
+
2128
+ canvas_native_context_save(
2129
+ ptr->GetContext());
2130
+ }
2131
+
2132
+ void
2133
+ CanvasRenderingContext2DImpl::Scale(const v8::FunctionCallbackInfo<v8::Value> &args) {
2134
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2135
+
2136
+ auto isolate = args.GetIsolate();
2137
+ auto context = isolate->GetCurrentContext();
2138
+
2139
+ if (args.Length() == 2) {
2140
+ auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
2141
+ auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
2142
+ canvas_native_context_scale(
2143
+ ptr->GetContext(), x, y);
2144
+ }
2145
+ }
2146
+
2147
+ void
2148
+ CanvasRenderingContext2DImpl::ScrollPathIntoView(const v8::FunctionCallbackInfo<v8::Value> &args) {
2149
+ // CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2150
+ }
2151
+
2152
+ void
2153
+ CanvasRenderingContext2DImpl::SetLineDash(const v8::FunctionCallbackInfo<v8::Value> &args) {
2154
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2155
+
2156
+ auto isolate = args.GetIsolate();
2157
+ auto context = isolate->GetCurrentContext();
2158
+
2159
+ auto value = args[0];
2160
+
2161
+ if (value->IsArray()) {
2162
+ auto segments = value.As<v8::Array>();
2163
+ auto len = segments->Length();
2164
+ std::vector<float> data;
2165
+ for (int i = 0; i < len; ++i) {
2166
+ auto item = segments->Get(
2167
+ context, i).ToLocalChecked()->NumberValue(context).ToChecked();
2168
+ data.push_back(
2169
+ static_cast<float>(item));
2170
+ }
2171
+
2172
+ canvas_native_context_set_line_dash(
2173
+ ptr->GetContext(), data.data(), data.size());
2174
+ }
2175
+ }
2176
+
2177
+ void
2178
+ CanvasRenderingContext2DImpl::SetTransform(const v8::FunctionCallbackInfo<v8::Value> &args) {
2179
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2180
+
2181
+ auto isolate = args.GetIsolate();
2182
+ auto context = isolate->GetCurrentContext();
2183
+
2184
+ auto count = args.Length();
2185
+ auto value = args[0];
2186
+ if (count == 1 && value->IsObject()) {
2187
+
2188
+ auto typeValue = GetPrivateValue(isolate, value.As<v8::Object>(),
2189
+ ConvertToV8String(isolate, "__type"));
2190
+
2191
+ if (!typeValue.IsEmpty()) {
2192
+ auto type = (NativeType) typeValue->Int32Value(context).ToChecked();
2193
+
2194
+ if (type == NativeType::Matrix) {
2195
+ auto matrix = MatrixImpl::GetPointer(value.As<v8::Object>());
2196
+ if (matrix != nullptr) {
2197
+ canvas_native_context_set_transform_matrix(
2198
+ ptr->GetContext(),
2199
+ matrix->GetMatrix());
2200
+ }
2201
+ }
2202
+
2203
+ }
2204
+ } else if (count == 6) {
2205
+ auto a = static_cast<float>(args[0]->NumberValue(context).ToChecked());
2206
+ auto b = static_cast<float>(args[1]->NumberValue(context).ToChecked());
2207
+ auto c = static_cast<float>(args[2]->NumberValue(context).ToChecked());
2208
+ auto d = static_cast<float>(args[3]->NumberValue(context).ToChecked());
2209
+ auto e = static_cast<float>(args[4]->NumberValue(context).ToChecked());
2210
+ auto f = static_cast<float>(args[5]->NumberValue(context).ToChecked());
2211
+ canvas_native_context_set_transform(
2212
+ ptr->GetContext(), a, b, c, d,
2213
+ e,
2214
+ f);
2215
+ }
2216
+ }
2217
+
2218
+ void
2219
+ CanvasRenderingContext2DImpl::Stroke(const v8::FunctionCallbackInfo<v8::Value> &args) {
2220
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2221
+
2222
+ auto isolate = args.GetIsolate();
2223
+
2224
+ auto value = args[0];
2225
+ auto type = GetNativeType(isolate, value);
2226
+ if (type == NativeType::Path2D) {
2227
+ auto path = Path2D::GetPointer(value.As<v8::Object>());
2228
+ if (path != nullptr) {
2229
+ canvas_native_context_stroke_with_path(
2230
+ ptr->GetContext(),
2231
+ path->GetPath());
2232
+ ptr->UpdateInvalidateState();
2233
+ }
2234
+ } else {
2235
+ canvas_native_context_stroke(
2236
+ ptr->GetContext());
2237
+ ptr->UpdateInvalidateState();
2238
+ }
2239
+ }
2240
+
2241
+ void
2242
+ CanvasRenderingContext2DImpl::StrokeRect(const v8::FunctionCallbackInfo<v8::Value> &args) {
2243
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2244
+
2245
+ auto isolate = args.GetIsolate();
2246
+ auto context = isolate->GetCurrentContext();
2247
+
2248
+ if (args.Length() == 4) {
2249
+ auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
2250
+ auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
2251
+ auto width = static_cast<float>(args[2]->NumberValue(context).ToChecked());
2252
+ auto height = static_cast<float>(args[3]->NumberValue(context).ToChecked());
2253
+ canvas_native_context_stroke_rect(
2254
+ ptr->GetContext(), x, y,
2255
+ width,
2256
+ height);
2257
+ ptr->UpdateInvalidateState();
2258
+ }
2259
+ }
2260
+
2261
+ void
2262
+ CanvasRenderingContext2DImpl::StrokeText(const v8::FunctionCallbackInfo<v8::Value> &args) {
2263
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2264
+
2265
+ auto isolate = args.GetIsolate();
2266
+ auto context = isolate->GetCurrentContext();
2267
+
2268
+ auto count = args.Length();
2269
+ if (count >= 3) {
2270
+ auto text = ConvertFromV8String(isolate, args[0]);
2271
+ auto x = static_cast<float>(args[1]->NumberValue(context).ToChecked());
2272
+ auto y = static_cast<float>(args[2]->NumberValue(context).ToChecked());
2273
+ float maxWidth = -1;
2274
+
2275
+ if (count > 3) {
2276
+ maxWidth = static_cast<float>(args[3]->NumberValue(context).ToChecked());
2277
+ }
2278
+
2279
+ canvas_native_context_stroke_text(
2280
+ ptr->GetContext(), text.c_str(),
2281
+ x, y, maxWidth);
2282
+ ptr->UpdateInvalidateState();
2283
+ }
2284
+ }
2285
+
2286
+ void
2287
+ CanvasRenderingContext2DImpl::Transform(const v8::FunctionCallbackInfo<v8::Value> &args) {
2288
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2289
+
2290
+ auto isolate = args.GetIsolate();
2291
+ auto context = isolate->GetCurrentContext();
2292
+
2293
+
2294
+ if (args.Length() == 6) {
2295
+ auto a = static_cast<float>(args[0]->NumberValue(context).ToChecked());
2296
+ auto b = static_cast<float>(args[1]->NumberValue(context).ToChecked());
2297
+ auto c = static_cast<float>(args[2]->NumberValue(context).ToChecked());
2298
+ auto d = static_cast<float>(args[3]->NumberValue(context).ToChecked());
2299
+ auto e = static_cast<float>(args[4]->NumberValue(context).ToChecked());
2300
+ auto f = static_cast<float>(args[5]->NumberValue(context).ToChecked());
2301
+ canvas_native_context_transform(
2302
+ ptr->GetContext(), a, b, c, d,
2303
+ e,
2304
+ f);
2305
+ }
2306
+ }
2307
+
2308
+ void
2309
+ CanvasRenderingContext2DImpl::Translate(const v8::FunctionCallbackInfo<v8::Value> &args) {
2310
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2311
+
2312
+ auto isolate = args.GetIsolate();
2313
+ auto context = isolate->GetCurrentContext();
2314
+
2315
+
2316
+ if (args.Length() == 2) {
2317
+ auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
2318
+ auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
2319
+ canvas_native_context_translate(
2320
+ ptr->GetContext(), x, y);
2321
+ }
2322
+ }
2323
+
2324
+ void
2325
+ CanvasRenderingContext2DImpl::__ToDataURL(const v8::FunctionCallbackInfo<v8::Value> &args) {
2326
+ CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
2327
+
2328
+ auto isolate = args.GetIsolate();
2329
+ auto context = isolate->GetCurrentContext();
2330
+
2331
+
2332
+ std::string type("image/png");
2333
+ int quality = 92;
2334
+ if (args[0]->IsString()) {
2335
+ type = ConvertFromV8String(isolate, args[0]);
2336
+ }
2337
+
2338
+
2339
+ if (args[1]->IsNumber()) {
2340
+ quality = (int) args[1]->NumberValue(context).ToChecked();
2341
+ }
2342
+
2343
+
2344
+ auto data = canvas_native_to_data_url(
2345
+ ptr->GetContext(), type.c_str(),
2346
+ quality);
2347
+
2348
+ auto value = new OneByteStringResource((char *) data);
2349
+ auto ret = v8::String::NewExternalOneByte(isolate, value);
2350
+ args.GetReturnValue().Set(ret.ToLocalChecked());
2351
+
2352
+ // args.GetReturnValue().Set(ConvertToV8String(isolate, data.c_str()));
2353
+ }
2354
+
2355
+ CanvasRenderingContext2DImpl::~CanvasRenderingContext2DImpl() {
2356
+ auto raf = this->raf_.get();
2357
+ if (raf != nullptr) {
2358
+ canvas_native_raf_stop(raf->GetRaf());
2359
+ }
2360
+
2361
+ canvas_native_context_destroy(this->GetContext());
2362
+ this->context_ = nullptr;
2363
+ }
2364
+
2365
+ void CanvasRenderingContext2DImpl::UpdateInvalidateState() {
2366
+ auto raf = this->GetRaf();
2367
+ if (raf != nullptr) {
2368
+ if (!canvas_native_raf_get_started(raf->GetRaf())) {
2369
+ canvas_native_raf_start(raf->GetRaf());
2370
+ }
2371
+ }
2372
+
2373
+ auto state = this->GetInvalidateState();
2374
+ this->SetInvalidateState((int) state | (int) InvalidateState::InvalidateStatePending);
2375
+ }
2376
+
2377
+ InvalidateState CanvasRenderingContext2DImpl::GetInvalidateState() const {
2378
+ return (InvalidateState)
2379
+ this->invalidateState_;
2380
+ }
2381
+
2382
+ void CanvasRenderingContext2DImpl::SetInvalidateState(InvalidateState state) {
2383
+ this->invalidateState_ = (int) state;
2384
+ }
2385
+
2386
+ void CanvasRenderingContext2DImpl::SetInvalidateState(int state) {
2387
+ this->invalidateState_ = state;
2388
+ }
2389
+
2390
+
2391
+ void CanvasRenderingContext2DImpl::Flush() {
2392
+ auto state = (int) this->GetInvalidateState() & (int) InvalidateState::InvalidateStatePending;
2393
+ if (state == (int) InvalidateState::InvalidateStatePending) {
2394
+ this->SetInvalidateState(InvalidateState::InvalidateStateInvalidating);
2395
+ // canvas_native_context_flush(ptr->GetContext());
2396
+ canvas_native_context_render(this->GetContext());
2397
+ // canvas_native_context_gl_make_current(ptr->GetContext());
2398
+ // canvas_native_context_gl_swap_buffers(ptr->GetContext());
2399
+ this->SetInvalidateState(InvalidateState::InvalidateStateNone);
2400
+ }
2401
+ }
2402
+
2403
+ void CanvasRenderingContext2DImpl::Flush(intptr_t context) {
2404
+ auto ctx = reinterpret_cast<CanvasRenderingContext2DImpl *>(reinterpret_cast<intptr_t *>(context));
2405
+ if (ctx != nullptr) {
2406
+ ctx->Flush();
2407
+ }
2408
+ }
2409
+
2410
+
2411
+ CanvasRenderingContext2D *CanvasRenderingContext2DImpl::GetContext() {
2412
+ return this->context_;
2413
+ }