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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/Canvas/common.d.ts +2 -0
  2. package/Canvas/common.js +6 -0
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +0 -2
  5. package/Canvas/index.android.js +8 -24
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.d.ts +7 -0
  8. package/Canvas/index.ios.d.ts +0 -2
  9. package/Canvas/index.ios.js +7 -26
  10. package/Canvas/index.ios.js.map +1 -1
  11. package/Canvas2D/CanvasGradient/index.d.ts +1 -3
  12. package/Canvas2D/CanvasGradient/index.js +1 -10
  13. package/Canvas2D/CanvasGradient/index.js.map +1 -1
  14. package/Canvas2D/CanvasPattern/index.d.ts +1 -3
  15. package/Canvas2D/CanvasPattern/index.js +1 -10
  16. package/Canvas2D/CanvasPattern/index.js.map +1 -1
  17. package/Canvas2D/CanvasRenderingContext2D/index.d.ts +0 -2
  18. package/Canvas2D/CanvasRenderingContext2D/index.js +120 -138
  19. package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
  20. package/Canvas2D/DOMMatrix/index.js +3 -3
  21. package/Canvas2D/DOMMatrix/index.js.map +1 -1
  22. package/Canvas2D/ImageData/index.js +5 -5
  23. package/Canvas2D/ImageData/index.js.map +1 -1
  24. package/Canvas2D/Path2D/index.d.ts +0 -2
  25. package/Canvas2D/Path2D/index.js +34 -39
  26. package/Canvas2D/Path2D/index.js.map +1 -1
  27. package/ImageAsset/index.d.ts +2 -2
  28. package/ImageAsset/index.js +33 -37
  29. package/ImageAsset/index.js.map +1 -1
  30. package/ImageBitmap/index.d.ts +0 -2
  31. package/ImageBitmap/index.js +23 -29
  32. package/ImageBitmap/index.js.map +1 -1
  33. package/SVG/SVG.js +1 -1
  34. package/TextDecoder/index.d.ts +0 -2
  35. package/TextDecoder/index.js +3 -12
  36. package/TextDecoder/index.js.map +1 -1
  37. package/TextEncoder/index.d.ts +0 -2
  38. package/TextEncoder/index.js +4 -13
  39. package/TextEncoder/index.js.map +1 -1
  40. package/WebGL/WebGLExtensions/index.d.ts +0 -9
  41. package/WebGL/WebGLExtensions/index.js +17 -74
  42. package/WebGL/WebGLExtensions/index.js.map +1 -1
  43. package/WebGL/WebGLRenderingContext/common.d.ts +0 -2
  44. package/WebGL/WebGLRenderingContext/common.js +0 -10
  45. package/WebGL/WebGLRenderingContext/common.js.map +1 -1
  46. package/WebGL/WebGLRenderingContext/index.js +159 -298
  47. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  48. package/WebGL2/WebGL2RenderingContext/index.js +107 -195
  49. package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
  50. package/angular/esm2020/index.mjs +5 -5
  51. package/angular/fesm2015/nativescript-canvas-angular.mjs +4 -4
  52. package/angular/fesm2015/nativescript-canvas-angular.mjs.map +1 -1
  53. package/angular/fesm2020/nativescript-canvas-angular.mjs +4 -4
  54. package/angular/fesm2020/nativescript-canvas-angular.mjs.map +1 -1
  55. package/index.js.map +1 -1
  56. package/package.json +1 -1
  57. package/platforms/android/canvas-release.aar +0 -0
  58. package/platforms/android/include.gradle +15 -0
  59. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  60. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +87 -57
  61. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative.h +10 -0
  62. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +142 -0
  63. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2589 -110
  64. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  65. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  66. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +1174 -89
  67. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +2 -2
  68. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  69. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +2 -2
  70. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  71. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  72. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +174 -114
  73. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative.h +10 -0
  74. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +142 -0
  75. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2589 -110
  76. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  77. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  78. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  79. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +1174 -89
  80. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +2 -2
  81. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  82. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -2
  83. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +1174 -89
  84. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +2 -2
  85. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  86. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +2 -2
  87. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +42 -31
  88. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  89. package/platforms/ios/Podfile +3 -0
  90. package/platforms/ios/build.xcconfig +3 -3
  91. package/platforms/ios/src/CanvasModule.h +0 -2
  92. package/platforms/ios/src/CanvasModule.mm +4 -4
  93. package/platforms/ios/src/NSOperationQueueWrapper.h +11 -0
  94. package/platforms/ios/src/NSOperationQueueWrapper.mm +74 -0
  95. package/platforms/ios/src/cpp/Caches.cpp +35 -0
  96. package/platforms/ios/src/cpp/Caches.h +186 -0
  97. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +1582 -0
  98. package/platforms/ios/src/cpp/CanvasJSIModule.h +7 -34
  99. package/platforms/ios/src/cpp/Common.h +30 -0
  100. package/platforms/ios/src/cpp/ConcurrentMap.h +54 -0
  101. package/platforms/ios/src/cpp/Helpers.h +304 -38
  102. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +802 -0
  103. package/platforms/ios/src/cpp/ImageAssetImpl.h +44 -12
  104. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +189 -0
  105. package/platforms/ios/src/cpp/ImageBitmapImpl.h +22 -16
  106. package/platforms/ios/src/cpp/JSICallback.h +61 -5
  107. package/platforms/ios/src/cpp/JSIReadFileCallback.h +86 -6
  108. package/platforms/ios/src/cpp/JSIRuntime.cpp +21 -0
  109. package/platforms/ios/src/cpp/JSIRuntime.h +7 -0
  110. package/platforms/ios/src/cpp/OneByteStringResource.cpp +25 -0
  111. package/platforms/ios/src/cpp/OneByteStringResource.h +21 -0
  112. package/platforms/ios/src/cpp/RafImpl.cpp +8 -0
  113. package/platforms/ios/src/cpp/RafImpl.h +11 -8
  114. package/platforms/ios/src/cpp/TextDecoderImpl.cpp +188 -0
  115. package/platforms/ios/src/cpp/TextDecoderImpl.h +20 -14
  116. package/platforms/ios/src/cpp/TextEncoderImpl.cpp +139 -0
  117. package/platforms/ios/src/cpp/TextEncoderImpl.h +20 -11
  118. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.cpp +71 -0
  119. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +27 -13
  120. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +89 -0
  121. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +26 -13
  122. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +2391 -0
  123. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +264 -21
  124. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +203 -0
  125. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +26 -12
  126. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +800 -0
  127. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +172 -13
  128. package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +449 -0
  129. package/platforms/ios/src/cpp/canvas2d/Path2D.h +41 -12
  130. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.cpp +253 -0
  131. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.h +50 -12
  132. package/platforms/ios/src/cpp/gl.h +57 -7
  133. package/platforms/ios/src/cpp/gl3stub.c +425 -0
  134. package/platforms/ios/src/cpp/gl3stub.h +665 -0
  135. package/platforms/ios/src/cpp/gles3jni.h +37 -0
  136. package/platforms/ios/src/cpp/include/robin_hood.h +2544 -0
  137. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.cpp +93 -0
  138. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +33 -13
  139. package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +41 -6
  140. package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +46 -10
  141. package/platforms/ios/src/cpp/webgl/WebGLProgram.h +40 -5
  142. package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +40 -6
  143. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +6457 -0
  144. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +261 -390
  145. package/platforms/ios/src/cpp/webgl/{WebGLRenderingContextBase.mm → WebGLRenderingContextBase.cpp} +17 -16
  146. package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.h +15 -36
  147. package/platforms/ios/src/cpp/webgl/WebGLShader.h +40 -6
  148. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.cpp +50 -0
  149. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +66 -11
  150. package/platforms/ios/src/cpp/webgl/WebGLTexture.h +40 -6
  151. package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +44 -8
  152. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.cpp +126 -0
  153. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +25 -12
  154. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.cpp +35 -0
  155. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +25 -5
  156. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.cpp +41 -0
  157. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +25 -5
  158. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.cpp +323 -0
  159. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +47 -13
  160. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +49 -6
  161. package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +37 -15
  162. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +47 -6
  163. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +49 -6
  164. package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +36 -15
  165. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +44 -6
  166. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +38 -15
  167. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +37 -16
  168. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +41 -6
  169. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +40 -16
  170. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.cpp +102 -0
  171. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +69 -14
  172. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +51 -8
  173. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +49 -6
  174. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +49 -8
  175. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +76 -6
  176. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +57 -6
  177. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +53 -6
  178. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +59 -6
  179. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +46 -6
  180. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.cpp +43 -0
  181. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +126 -14
  182. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.cpp +32 -0
  183. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +61 -12
  184. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +4380 -0
  185. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +139 -343
  186. package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +40 -4
  187. package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +42 -3
  188. package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +44 -11
  189. package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +42 -4
  190. package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +43 -4
  191. package/platforms/ios/src/module.modulemap +1 -0
  192. package/platforms/ios/src/cpp/CanvasJSIModule.mm +0 -1105
  193. package/platforms/ios/src/cpp/ImageAssetImpl.mm +0 -417
  194. package/platforms/ios/src/cpp/ImageBitmapImpl.mm +0 -126
  195. package/platforms/ios/src/cpp/RafImpl.mm +0 -10
  196. package/platforms/ios/src/cpp/TextDecoderImpl.mm +0 -97
  197. package/platforms/ios/src/cpp/TextEncoderImpl.mm +0 -60
  198. package/platforms/ios/src/cpp/VecMutableBuffer.h +0 -46
  199. package/platforms/ios/src/cpp/canvas-cxx/src/lib.rs.cc +0 -6156
  200. package/platforms/ios/src/cpp/canvas-cxx/src/lib.rs.h +0 -2867
  201. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.mm +0 -42
  202. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.mm +0 -49
  203. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.mm +0 -1972
  204. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.mm +0 -68
  205. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.mm +0 -149
  206. package/platforms/ios/src/cpp/canvas2d/Path2D.mm +0 -335
  207. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.mm +0 -68
  208. package/platforms/ios/src/cpp/rust/cxx.cc +0 -793
  209. package/platforms/ios/src/cpp/rust/cxx.h +0 -1111
  210. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.mm +0 -39
  211. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.mm +0 -5958
  212. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.mm +0 -40
  213. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.mm +0 -108
  214. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.mm +0 -28
  215. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.mm +0 -42
  216. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.mm +0 -295
  217. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.mm +0 -40
  218. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.mm +0 -37
  219. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.mm +0 -28
  220. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.mm +0 -31
  221. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.mm +0 -28
  222. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.mm +0 -127
  223. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.mm +0 -45
  224. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.mm +0 -45
  225. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.mm +0 -31
  226. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.mm +0 -70
  227. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.mm +0 -47
  228. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.mm +0 -46
  229. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.mm +0 -49
  230. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.mm +0 -30
  231. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.mm +0 -177
  232. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.mm +0 -64
  233. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.mm +0 -4551
  234. /package/platforms/ios/src/cpp/{OnRafCallback.mm → OnRafCallback.cpp} +0 -0
@@ -0,0 +1,4380 @@
1
+ //
2
+ // Created by Osei Fortune on 22/03/2022.
3
+ //
4
+
5
+ #include "WebGL2RenderingContext.h"
6
+
7
+ WebGL2RenderingContext::WebGL2RenderingContext(WebGLState* state) : WebGLRenderingContext(
8
+ state, WebGLRenderingVersion::V2) {
9
+ }
10
+
11
+
12
+ WebGL2RenderingContext::WebGL2RenderingContext(WebGLState* state,
13
+ WebGLRenderingVersion version)
14
+ : WebGLRenderingContext(state, version) {
15
+ }
16
+
17
+
18
+ v8::Local<v8::FunctionTemplate> WebGL2RenderingContext::GetCtor(v8::Isolate *isolate) {
19
+ auto cache = Caches::Get(isolate);
20
+ auto ctor = cache->WebGL2RenderingContextTmpl.get();
21
+ if (ctor != nullptr) {
22
+ return ctor->Get(isolate);
23
+ }
24
+
25
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
26
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1);
27
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "WebGL2RenderingContext"));
28
+
29
+ auto tmpl = ctorTmpl->InstanceTemplate();
30
+ tmpl->SetInternalFieldCount(1);
31
+ WebGLRenderingContext::SetConstants(isolate, tmpl);
32
+ SetConstants(isolate, tmpl);
33
+
34
+ WebGLRenderingContext::SetMethods(isolate, tmpl);
35
+ SetMethods(isolate, tmpl);
36
+
37
+ WebGLRenderingContext::SetProps(isolate, tmpl);
38
+ SetProps(isolate, tmpl);
39
+ cache->WebGL2RenderingContextTmpl =
40
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
41
+ return ctorTmpl;
42
+ }
43
+
44
+ WebGL2RenderingContext *WebGL2RenderingContext::GetPointer(const v8::Local<v8::Object> &object) {
45
+ auto ptr = object->GetInternalField(0).As<v8::External>()->Value();
46
+ if (ptr == nullptr) {
47
+ return nullptr;
48
+ }
49
+ return static_cast<WebGL2RenderingContext *>(ptr);
50
+ }
51
+
52
+ void WebGL2RenderingContext::BeginQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
53
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
54
+ if (ptr == nullptr) {
55
+ return;
56
+ }
57
+
58
+ auto isolate = args.GetIsolate();
59
+ auto context = isolate->GetCurrentContext();
60
+
61
+ auto value = args[1];
62
+ auto type = GetNativeType(isolate, value);
63
+ if (type == NativeType::WebGLQuery) {
64
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
65
+ auto query = WebGLQuery::GetPointer(value.As<v8::Object>());
66
+
67
+ if (query != nullptr) {
68
+ canvas_native_webgl2_begin_query(
69
+ target,
70
+ query->GetQuery(),
71
+ ptr->GetState()
72
+ );
73
+ }
74
+ }
75
+ }
76
+
77
+ void
78
+ WebGL2RenderingContext::BeginTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
79
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
80
+ if (ptr == nullptr) {
81
+ return;
82
+ }
83
+
84
+ auto isolate = args.GetIsolate();
85
+ auto context = isolate->GetCurrentContext();
86
+
87
+ auto value = args[0];
88
+ if (value->IsNumber()) {
89
+ canvas_native_webgl2_begin_transform_feedback(
90
+ (uint32_t) args[0]->NumberValue(context).ToChecked(),
91
+ ptr->GetState()
92
+ );
93
+ }
94
+ }
95
+
96
+ void WebGL2RenderingContext::BindBufferBase(const v8::FunctionCallbackInfo<v8::Value> &args) {
97
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
98
+ if (ptr == nullptr) {
99
+ return;
100
+ }
101
+
102
+ auto isolate = args.GetIsolate();
103
+ auto context = isolate->GetCurrentContext();
104
+
105
+ auto bufferValue = args[2];
106
+ auto type = GetNativeType(isolate, bufferValue);
107
+
108
+ if (type == NativeType::WebGLBuffer) {
109
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
110
+ auto index = (uint32_t) args[1]->NumberValue(context).ToChecked();
111
+
112
+ auto buffer = WebGLBuffer::GetPointer(bufferValue.As<v8::Object>());
113
+
114
+ canvas_native_webgl2_bind_buffer_base(
115
+ target,
116
+ index,
117
+ buffer->GetBuffer(),
118
+ ptr->GetState()
119
+ );
120
+ }
121
+ }
122
+
123
+ void WebGL2RenderingContext::BindBufferRange(const v8::FunctionCallbackInfo<v8::Value> &args) {
124
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
125
+ if (ptr == nullptr) {
126
+ return;
127
+ }
128
+
129
+ auto isolate = args.GetIsolate();
130
+ auto context = isolate->GetCurrentContext();
131
+
132
+ auto bufferValue = args[2];
133
+ auto type = GetNativeType(isolate, bufferValue);
134
+ if (args.Length() > 4 && type == NativeType::WebGLBuffer) {
135
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
136
+ auto index = (uint32_t) args[1]->NumberValue(context).ToChecked();
137
+ auto offset = args[3]->NumberValue(context).ToChecked();
138
+ auto size = args[4]->NumberValue(context).ToChecked();
139
+ auto buffer = WebGLBuffer::GetPointer(bufferValue.As<v8::Object>());
140
+ canvas_native_webgl2_bind_buffer_range(
141
+ target,
142
+ index,
143
+ buffer->GetBuffer(),
144
+ static_cast<ssize_t>(offset),
145
+ static_cast<ssize_t>(size),
146
+ ptr->GetState()
147
+ );
148
+ }
149
+ }
150
+
151
+ void WebGL2RenderingContext::BindSampler(const v8::FunctionCallbackInfo<v8::Value> &args) {
152
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
153
+ if (ptr == nullptr) {
154
+ return;
155
+ }
156
+
157
+ auto isolate = args.GetIsolate();
158
+ auto context = isolate->GetCurrentContext();
159
+
160
+ auto samplerValue = args[1];
161
+ auto type = GetNativeType(isolate, samplerValue);
162
+ if (type == NativeType::WebGLSampler) {
163
+ auto unit = (uint32_t) args[0]->NumberValue(context).ToChecked();
164
+ auto sampler = WebGLSampler::GetPointer(samplerValue.As<v8::Object>());
165
+
166
+ canvas_native_webgl2_bind_sampler(
167
+ unit,
168
+ sampler->GetSampler(),
169
+ ptr->GetState()
170
+ );
171
+ }
172
+ }
173
+
174
+ void
175
+ WebGL2RenderingContext::BindTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
176
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
177
+ if (ptr == nullptr) {
178
+ return;
179
+ }
180
+
181
+ auto isolate = args.GetIsolate();
182
+ auto context = isolate->GetCurrentContext();
183
+
184
+ auto transformFeedbackValue = args[1];
185
+ auto type = GetNativeType(isolate, transformFeedbackValue);
186
+
187
+ if (type == NativeType::WebGLTransformFeedback) {
188
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
189
+ auto transformFeedback = WebGLTransformFeedback::GetPointer(
190
+ transformFeedbackValue.As<v8::Object>());
191
+
192
+ canvas_native_webgl2_bind_transform_feedback(
193
+ target,
194
+ transformFeedback->GetFeedback(),
195
+ ptr->GetState()
196
+ );
197
+ }
198
+ }
199
+
200
+ void WebGL2RenderingContext::BindVertexArray(const v8::FunctionCallbackInfo<v8::Value> &args) {
201
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
202
+ if (ptr == nullptr) {
203
+ return;
204
+ }
205
+
206
+ auto isolate = args.GetIsolate();
207
+
208
+ auto value = args[0];
209
+ if (value->IsNull()) {
210
+ canvas_native_webgl2_bind_vertex_array(
211
+ 0,
212
+ ptr->GetState()
213
+ );
214
+ return;
215
+ }
216
+
217
+ auto type = GetNativeType(isolate, value);
218
+ if (type == NativeType::WebGLVertexArrayObject) {
219
+ auto vertexArray = WebGLVertexArrayObject::GetPointer(value.As<v8::Object>());
220
+
221
+ if (vertexArray != nullptr) {
222
+ canvas_native_webgl2_bind_vertex_array(
223
+ vertexArray->GetVertexArrayObject(),
224
+ ptr->GetState()
225
+ );
226
+ }
227
+ }
228
+ }
229
+
230
+ void WebGL2RenderingContext::BlitFramebuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
231
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
232
+ if (ptr == nullptr) {
233
+ return;
234
+ }
235
+
236
+ auto isolate = args.GetIsolate();
237
+ auto context = isolate->GetCurrentContext();
238
+
239
+ if (args.Length() > 9) {
240
+ auto srcX0 = (int32_t) args[0]->NumberValue(context).ToChecked();
241
+ auto srcY0 = (int32_t) args[1]->NumberValue(context).ToChecked();
242
+
243
+ auto srcX1 = (int32_t) args[2]->NumberValue(context).ToChecked();
244
+ auto srcY1 = (int32_t) args[3]->NumberValue(context).ToChecked();
245
+
246
+ auto dstX0 = (int32_t) args[4]->NumberValue(context).ToChecked();
247
+ auto dstY0 = (int32_t) args[5]->NumberValue(context).ToChecked();
248
+
249
+ auto dstX1 = (int32_t) args[6]->NumberValue(context).ToChecked();
250
+ auto dstY1 = (int32_t) args[7]->NumberValue(context).ToChecked();
251
+
252
+ auto mask = (uint32_t) args[8]->NumberValue(context).ToChecked();
253
+ auto filter = (uint32_t) args[9]->NumberValue(context).ToChecked();
254
+ canvas_native_webgl2_blit_framebuffer(
255
+ srcX0,
256
+ srcY0,
257
+ srcX1,
258
+ srcY1,
259
+ dstX0,
260
+ dstY0,
261
+ dstX1,
262
+ dstY1,
263
+ mask,
264
+ filter,
265
+ ptr->GetState()
266
+ );
267
+ }
268
+ }
269
+
270
+ void WebGL2RenderingContext::ClearBufferfv(const v8::FunctionCallbackInfo<v8::Value> &args) {
271
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
272
+ if (ptr == nullptr) {
273
+ return;
274
+ }
275
+
276
+ auto isolate = args.GetIsolate();
277
+ auto context = isolate->GetCurrentContext();
278
+
279
+ auto bufferValue = args[0];
280
+ auto type = GetNativeType(isolate, bufferValue);
281
+ auto values = args[2];
282
+ if (args.Length() > 2 && type == NativeType::WebGLBuffer &&
283
+ args[1]->IsObject()) {
284
+ auto drawbuffer = (int32_t) args[1]->NumberValue(context).ToChecked();
285
+ auto buffer = WebGLBuffer::GetPointer(bufferValue.As<v8::Object>());
286
+ if (values->IsArray()) {
287
+ auto array = values.As<v8::Array>();
288
+ auto len = array->Length();
289
+ std::vector<float> buf;
290
+ buf.reserve(len);
291
+ for (int j = 0; j < len; ++j) {
292
+ auto item = array->Get(
293
+ context, j).ToLocalChecked();
294
+ if (!item->IsNumber()) {
295
+ buf.push_back(
296
+ std::nanf(""));
297
+ } else {
298
+ buf.push_back(
299
+ static_cast<float>(item->NumberValue(context).ToChecked())
300
+ );
301
+ }
302
+ }
303
+
304
+ canvas_native_webgl2_clear_bufferfv(
305
+ buffer->GetBuffer(),
306
+ drawbuffer,
307
+ buf.data(),
308
+ buf.size(),
309
+ ptr->GetState()
310
+ );
311
+
312
+ } else if (values->IsFloat32Array()) {
313
+ auto buf = values.As<v8::Float32Array>();
314
+ auto array = buf->Buffer();
315
+ auto offset = buf->ByteOffset();
316
+ auto size = buf->Length();
317
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
318
+ auto data = static_cast<float *>((void*) data_ptr);
319
+
320
+
321
+ canvas_native_webgl2_clear_bufferfv(
322
+ buffer->GetBuffer(),
323
+ drawbuffer,
324
+ data,
325
+ size,
326
+ ptr->GetState()
327
+ );
328
+ }
329
+ }
330
+ }
331
+
332
+ void WebGL2RenderingContext::ClearBufferiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
333
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
334
+ if (ptr == nullptr) {
335
+ return;
336
+ }
337
+
338
+ auto isolate = args.GetIsolate();
339
+ auto context = isolate->GetCurrentContext();
340
+
341
+ auto bufferValue = args[0];
342
+ auto type = GetNativeType(isolate, bufferValue);
343
+ auto values = args[2];
344
+ if (args.Length() > 2 && type == NativeType::WebGLBuffer &&
345
+ args[1]->IsObject()) {
346
+ auto drawbuffer = (int32_t) args[1]->NumberValue(context).ToChecked();
347
+ auto buffer = WebGLBuffer::GetPointer(bufferValue.As<v8::Object>());
348
+ if (values->IsArray()) {
349
+ auto array = values.As<v8::Array>();
350
+ auto len = array->Length();
351
+ std::vector<int32_t> buf;
352
+ buf.reserve(len);
353
+ for (int j = 0; j < len; ++j) {
354
+ auto item = array->Get(
355
+ context, j).ToLocalChecked();
356
+ buf.push_back(
357
+ static_cast<int32_t>(item->NumberValue(context).ToChecked())
358
+ );
359
+ }
360
+
361
+
362
+ canvas_native_webgl2_clear_bufferiv(
363
+ buffer->GetBuffer(),
364
+ drawbuffer,
365
+ buf.data(),
366
+ buf.size(),
367
+ ptr->GetState()
368
+ );
369
+
370
+ } else if (values->IsInt32Array()) {
371
+ auto buf = values.As<v8::Int32Array>();
372
+
373
+ auto array = buf->Buffer();
374
+ auto offset = buf->ByteOffset();
375
+ auto size = buf->Length();
376
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
377
+ auto data = static_cast<int32_t *>((void*) data_ptr);
378
+
379
+
380
+
381
+
382
+ canvas_native_webgl2_clear_bufferiv(
383
+ buffer->GetBuffer(),
384
+ drawbuffer,
385
+ data,
386
+ size,
387
+ ptr->GetState()
388
+ );
389
+ }
390
+ }
391
+ }
392
+
393
+ void WebGL2RenderingContext::ClearBufferfi(const v8::FunctionCallbackInfo<v8::Value> &args) {
394
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
395
+ if (ptr == nullptr) {
396
+ return;
397
+ }
398
+
399
+ auto isolate = args.GetIsolate();
400
+ auto context = isolate->GetCurrentContext();
401
+
402
+ auto bufferValue = args[0];
403
+ auto type = GetNativeType(isolate, bufferValue);
404
+ if (args.Length() > 3 && type == NativeType::WebGLBuffer) {
405
+ auto buffer = WebGLBuffer::GetPointer(bufferValue.As<v8::Object>());
406
+ if (buffer != nullptr) {
407
+ auto drawbuffer = (int32_t) args[1]->NumberValue(context).ToChecked();
408
+ auto depth = args[2]->NumberValue(context).ToChecked();
409
+ auto stencil = (int32_t) args[3]->NumberValue(context).ToChecked();
410
+ canvas_native_webgl2_clear_bufferfi(
411
+ buffer->GetBuffer(),
412
+ drawbuffer,
413
+ static_cast<float>(depth),
414
+ stencil,
415
+ ptr->GetState()
416
+ );
417
+ }
418
+ }
419
+ }
420
+
421
+ void WebGL2RenderingContext::ClearBufferuiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
422
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
423
+ if (ptr == nullptr) {
424
+ return;
425
+ }
426
+
427
+ auto isolate = args.GetIsolate();
428
+ auto context = isolate->GetCurrentContext();
429
+
430
+ auto bufferValue = args[0];
431
+ auto type = GetNativeType(isolate, bufferValue);
432
+ auto values = args[2];
433
+ if (args.Length() > 2 && type == NativeType::WebGLBuffer &&
434
+ args[1]->IsObject()) {
435
+ auto drawbuffer = (int32_t) args[1]->NumberValue(context).ToChecked();
436
+ auto buffer = WebGLBuffer::GetPointer(bufferValue.As<v8::Object>());
437
+ if (values->IsArray()) {
438
+ auto array = values.As<v8::Array>();
439
+ auto len = array->Length();
440
+ std::vector<uint32_t> buf;
441
+ buf.reserve(len);
442
+ for (int j = 0; j < len; ++j) {
443
+ auto item = array->Get(
444
+ context, j).ToLocalChecked();
445
+ buf.push_back(
446
+ static_cast<uint32_t>(item->NumberValue(context).ToChecked())
447
+ );
448
+ }
449
+
450
+
451
+ canvas_native_webgl2_clear_bufferuiv(
452
+ buffer->GetBuffer(),
453
+ drawbuffer,
454
+ buf.data(),
455
+ buf.size(),
456
+ ptr->GetState()
457
+ );
458
+
459
+ } else if (values->IsUint32Array()) {
460
+ auto buf = values.As<v8::Uint32Array>();
461
+ auto array = buf->Buffer();
462
+ auto offset = buf->ByteOffset();
463
+ auto size = buf->Length();
464
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
465
+ auto data = static_cast<uint32_t *>((void*) data_ptr);
466
+
467
+
468
+
469
+ canvas_native_webgl2_clear_bufferuiv(
470
+ buffer->GetBuffer(),
471
+ drawbuffer,
472
+ data, size,
473
+ ptr->GetState()
474
+ );
475
+ }
476
+ }
477
+ }
478
+
479
+ void WebGL2RenderingContext::ClientWaitSync(const v8::FunctionCallbackInfo<v8::Value> &args) {
480
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
481
+ if (ptr == nullptr) {
482
+ return;
483
+ }
484
+
485
+ auto isolate = args.GetIsolate();
486
+ auto context = isolate->GetCurrentContext();
487
+
488
+ auto syncValue = args[0];
489
+ auto type = GetNativeType(isolate, syncValue);
490
+ if (args.Length() > 2 && type == NativeType::WebGLSync) {
491
+ auto sync = WebGLSyncImpl::GetPointer(syncValue.As<v8::Object>());
492
+ if (sync != nullptr) {
493
+ auto flags = (uint32_t) args[1]->NumberValue(context).ToChecked();
494
+ auto timeout = args[2]->NumberValue(context).ToChecked();
495
+ auto ret = canvas_native_webgl2_client_wait_sync(
496
+ sync->GetSync(),
497
+ flags,
498
+ static_cast<ssize_t>(timeout),
499
+ ptr->GetState()
500
+ );
501
+
502
+ args.GetReturnValue().Set((int32_t) ret);
503
+ return;
504
+ }
505
+ }
506
+ // todo decide if WAIT_FAILED should be returned here
507
+ args.GetReturnValue().SetUndefined();
508
+ }
509
+
510
+ void
511
+ WebGL2RenderingContext::CompressedTexSubImage3D(const v8::FunctionCallbackInfo<v8::Value> &args) {
512
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
513
+ if (ptr == nullptr) {
514
+ return;
515
+ }
516
+
517
+ auto isolate = args.GetIsolate();
518
+ auto context = isolate->GetCurrentContext();
519
+
520
+ if (args.Length() > 8) {
521
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
522
+ auto level = (int32_t) args[1]->NumberValue(context).ToChecked();
523
+ auto xoffset = (int32_t) args[2]->NumberValue(context).ToChecked();
524
+ auto yoffset = (int32_t) args[3]->NumberValue(context).ToChecked();
525
+ auto zoffset = (int32_t) args[4]->NumberValue(context).ToChecked();
526
+ auto width = (int32_t) args[5]->NumberValue(context).ToChecked();
527
+ auto height = (int32_t) args[6]->NumberValue(context).ToChecked();
528
+ auto depth = (int32_t) args[7]->NumberValue(context).ToChecked();
529
+ auto format = (uint32_t) args[8]->NumberValue(context).ToChecked();
530
+
531
+ auto imageSizeOrBufValue = args[0];
532
+ if (args[9]->IsObject()) {
533
+ if (imageSizeOrBufValue->IsArrayBufferView()) {
534
+ auto buf = imageSizeOrBufValue.As<v8::ArrayBufferView>();
535
+ auto array = buf->Buffer();
536
+ auto offset = buf->ByteOffset();
537
+ auto size = buf->ByteLength();
538
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
539
+ auto data = static_cast<uint8_t *>((void*) data_ptr);
540
+
541
+ size_t srcOffset = 0;
542
+ if (args[10]->IsNumber()) {
543
+ srcOffset = static_cast<size_t>(args[10]->NumberValue(context).ToChecked());
544
+ }
545
+ size_t srcLengthOverride = 0;
546
+ if (args[11]->IsNumber()) {
547
+ srcLengthOverride = static_cast<size_t>(args[11]->NumberValue(
548
+ context).ToChecked());
549
+ }
550
+
551
+
552
+ canvas_native_webgl2_compressed_tex_sub_image3d(
553
+ target,
554
+ level,
555
+ xoffset,
556
+ yoffset,
557
+ zoffset,
558
+ width,
559
+ height,
560
+ depth,
561
+ format,
562
+ data,
563
+ size,
564
+ srcOffset,
565
+ srcLengthOverride,
566
+ ptr->GetState()
567
+ );
568
+ }
569
+ } else {
570
+ auto imageSizeOrBuf = (int32_t) imageSizeOrBufValue->NumberValue(context).ToChecked();
571
+ auto offset = 0;
572
+ if (args[10]->IsNumber()) {
573
+ offset = (int32_t) args[10]->NumberValue(context).ToChecked();
574
+ }
575
+ canvas_native_webgl2_compressed_tex_sub_image3d_none(
576
+ target,
577
+ level,
578
+ xoffset,
579
+ yoffset,
580
+ zoffset,
581
+ width,
582
+ height,
583
+ depth,
584
+ format,
585
+ imageSizeOrBuf,
586
+ offset,
587
+ ptr->GetState()
588
+ );
589
+ }
590
+ }
591
+ }
592
+
593
+ void WebGL2RenderingContext::CopyBufferSubData(const v8::FunctionCallbackInfo<v8::Value> &args) {
594
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
595
+ if (ptr == nullptr) {
596
+ return;
597
+ }
598
+
599
+ auto isolate = args.GetIsolate();
600
+ auto context = isolate->GetCurrentContext();
601
+
602
+ if (args.Length() > 4) {
603
+ auto readTarget = (uint32_t) args[0]->NumberValue(context).ToChecked();
604
+ auto writeTarget = (uint32_t) args[1]->NumberValue(context).ToChecked();
605
+ auto readOffset = args[2]->NumberValue(context).ToChecked();
606
+ auto writeOffset = args[3]->NumberValue(context).ToChecked();
607
+ auto size = args[4]->NumberValue(context).ToChecked();
608
+ canvas_native_webgl2_copy_buffer_sub_data(
609
+ readTarget,
610
+ writeTarget,
611
+ static_cast<ssize_t>(readOffset),
612
+ static_cast<ssize_t>(writeOffset),
613
+ static_cast<ssize_t>(size),
614
+ ptr->GetState()
615
+ );
616
+ }
617
+ }
618
+
619
+ void WebGL2RenderingContext::CopyTexSubImage3D(const v8::FunctionCallbackInfo<v8::Value> &args) {
620
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
621
+ if (ptr == nullptr) {
622
+ return;
623
+ }
624
+
625
+ auto isolate = args.GetIsolate();
626
+ auto context = isolate->GetCurrentContext();
627
+
628
+ if (args.Length() > 8) {
629
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
630
+ auto level = (int32_t) args[1]->NumberValue(context).ToChecked();
631
+ auto xoffset = (int32_t) args[2]->NumberValue(context).ToChecked();
632
+ auto yoffset = (int32_t) args[3]->NumberValue(context).ToChecked();
633
+ auto zoffset = (int32_t) args[4]->NumberValue(context).ToChecked();
634
+ auto x = (int32_t) args[5]->NumberValue(context).ToChecked();
635
+ auto y = (int32_t) args[6]->NumberValue(context).ToChecked();
636
+ auto width = (int32_t) args[7]->NumberValue(context).ToChecked();
637
+ auto height = (int32_t) args[8]->NumberValue(context).ToChecked();
638
+ canvas_native_webgl2_copy_tex_sub_image3d(
639
+ target,
640
+ level,
641
+ xoffset,
642
+ yoffset,
643
+ zoffset,
644
+ x,
645
+ y,
646
+ width,
647
+ height,
648
+ ptr->GetState()
649
+ );
650
+ }
651
+ }
652
+
653
+ void WebGL2RenderingContext::CreateQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
654
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
655
+ if (ptr == nullptr) {
656
+ args.GetReturnValue().SetUndefined();
657
+ return;
658
+ }
659
+
660
+ auto isolate = args.GetIsolate();
661
+
662
+ auto ret = canvas_native_webgl2_create_query(
663
+ ptr->GetState());
664
+ auto query = WebGLQuery::NewInstance(isolate, new WebGLQuery(ret));
665
+
666
+ args.GetReturnValue().Set(query);
667
+ }
668
+
669
+ void WebGL2RenderingContext::CreateSampler(const v8::FunctionCallbackInfo<v8::Value> &args) {
670
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
671
+ if (ptr == nullptr) {
672
+ args.GetReturnValue().SetUndefined();
673
+ return;
674
+ }
675
+
676
+ auto isolate = args.GetIsolate();
677
+
678
+ auto ret = canvas_native_webgl2_create_sampler(
679
+ ptr->GetState());
680
+ auto sampler = WebGLSampler::NewInstance(isolate, new WebGLSampler(ret));
681
+
682
+ args.GetReturnValue().Set(sampler);
683
+ }
684
+
685
+ void
686
+ WebGL2RenderingContext::CreateTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
687
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
688
+ if (ptr == nullptr) {
689
+ args.GetReturnValue().SetUndefined();
690
+ return;
691
+ }
692
+
693
+ auto isolate = args.GetIsolate();
694
+
695
+ auto ret = canvas_native_webgl2_create_transform_feedback(
696
+ ptr->GetState());
697
+
698
+ auto feedback = WebGLTransformFeedback::NewInstance(isolate, new WebGLTransformFeedback(
699
+ ret));
700
+
701
+ args.GetReturnValue().Set(feedback);
702
+ }
703
+
704
+ void WebGL2RenderingContext::CreateVertexArray(const v8::FunctionCallbackInfo<v8::Value> &args) {
705
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
706
+ if (ptr == nullptr) {
707
+ args.GetReturnValue().SetUndefined();
708
+ return;
709
+ }
710
+
711
+ auto isolate = args.GetIsolate();
712
+
713
+ auto ret = canvas_native_webgl2_create_vertex_array(
714
+ ptr->GetState());
715
+
716
+ auto vertexArrayObject = WebGLVertexArrayObject::NewInstance(isolate,
717
+ new WebGLVertexArrayObject(ret));
718
+
719
+ args.GetReturnValue().Set(vertexArrayObject);
720
+ }
721
+
722
+ void WebGL2RenderingContext::DeleteQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
723
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
724
+ if (ptr == nullptr) {
725
+ return;
726
+ }
727
+
728
+ auto isolate = args.GetIsolate();
729
+
730
+ auto queryValue = args[0];
731
+ auto type = GetNativeType(isolate, queryValue);
732
+ if (type == NativeType::WebGLQuery) {
733
+ auto query = WebGLQuery::GetPointer(queryValue.As<v8::Object>());
734
+
735
+ if (query != nullptr) {
736
+ canvas_native_webgl2_delete_query_with_query(
737
+ query->GetQuery(),
738
+ ptr->GetState()
739
+ );
740
+ }
741
+ }
742
+ }
743
+
744
+ void WebGL2RenderingContext::DeleteSampler(const v8::FunctionCallbackInfo<v8::Value> &args) {
745
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
746
+ if (ptr == nullptr) {
747
+ return;
748
+ }
749
+
750
+ auto isolate = args.GetIsolate();
751
+
752
+
753
+ auto samplerValue = args[0];
754
+ auto type = GetNativeType(isolate, samplerValue);
755
+
756
+ if (type == NativeType::WebGLSampler) {
757
+ auto sampler = WebGLSampler::GetPointer(samplerValue.As<v8::Object>());
758
+
759
+ if (sampler != nullptr) {
760
+ canvas_native_webgl2_delete_sampler_with_sampler(
761
+ sampler->GetSampler(),
762
+ ptr->GetState()
763
+ );
764
+ }
765
+ }
766
+ }
767
+
768
+ void WebGL2RenderingContext::DeleteSync(const v8::FunctionCallbackInfo<v8::Value> &args) {
769
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
770
+ if (ptr == nullptr) {
771
+ return;
772
+ }
773
+
774
+ auto isolate = args.GetIsolate();
775
+
776
+
777
+ auto syncValue = args[0];
778
+ auto type = GetNativeType(isolate, syncValue);
779
+ if (type == NativeType::WebGLSync) {
780
+ auto sync = WebGLSyncImpl::GetPointer(syncValue.As<v8::Object>());
781
+
782
+ if (sync != nullptr) {
783
+ canvas_native_webgl2_delete_sync_with_sync(
784
+ sync->GetSync(),
785
+ ptr->GetState()
786
+ );
787
+ }
788
+ }
789
+ }
790
+
791
+ void
792
+ WebGL2RenderingContext::DeleteTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
793
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
794
+ if (ptr == nullptr) {
795
+ return;
796
+ }
797
+
798
+ auto isolate = args.GetIsolate();
799
+
800
+
801
+ auto transformFeedbackValue = args[0];
802
+ auto type = GetNativeType(isolate, transformFeedbackValue);
803
+ if (type == NativeType::WebGLTransformFeedback) {
804
+ auto transformFeedback = WebGLTransformFeedback::GetPointer(
805
+ transformFeedbackValue.As<v8::Object>());
806
+
807
+ if (transformFeedback != nullptr) {
808
+ canvas_native_webgl2_delete_transform_feedback(
809
+ transformFeedback->GetFeedback(),
810
+ ptr->GetState()
811
+ );
812
+ }
813
+ }
814
+ }
815
+
816
+ void WebGL2RenderingContext::DeleteVertexArray(const v8::FunctionCallbackInfo<v8::Value> &args) {
817
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
818
+ if (ptr == nullptr) {
819
+ return;
820
+ }
821
+
822
+ auto isolate = args.GetIsolate();
823
+
824
+
825
+ auto vertexArrayValue = args[0];
826
+ auto type = GetNativeType(isolate, vertexArrayValue);
827
+ if (type == NativeType::WebGLVertexArrayObject) {
828
+
829
+ auto vertexArray = WebGLVertexArrayObject::GetPointer(vertexArrayValue.As<v8::Object>());
830
+ if (vertexArray != nullptr) {
831
+ canvas_native_webgl2_delete_vertex_array_with_vertex_array(
832
+ vertexArray->GetVertexArrayObject(),
833
+ ptr->GetState()
834
+ );
835
+ }
836
+ }
837
+ }
838
+
839
+ void WebGL2RenderingContext::DrawArraysInstanced(const v8::FunctionCallbackInfo<v8::Value> &args) {
840
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
841
+ if (ptr == nullptr) {
842
+ return;
843
+ }
844
+
845
+ auto isolate = args.GetIsolate();
846
+ auto context = isolate->GetCurrentContext();
847
+
848
+ auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
849
+ auto first = (int32_t) args[1]->NumberValue(context).ToChecked();
850
+ auto count_ = (int32_t) args[2]->NumberValue(context).ToChecked();
851
+ auto instanceCount = (int32_t) args[3]->NumberValue(context).ToChecked();
852
+ canvas_native_webgl2_draw_arrays_instanced(
853
+ mode,
854
+ first,
855
+ count_,
856
+ instanceCount,
857
+ ptr->GetState()
858
+ );
859
+
860
+ ptr->UpdateInvalidateState();
861
+ }
862
+
863
+ void WebGL2RenderingContext::DrawBuffers(const v8::FunctionCallbackInfo<v8::Value> &args) {
864
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
865
+ if (ptr == nullptr) {
866
+ return;
867
+ }
868
+
869
+ auto isolate = args.GetIsolate();
870
+ auto context = isolate->GetCurrentContext();
871
+
872
+ auto buffersObject = args[0];
873
+ if (buffersObject->IsArray()) {
874
+ auto array = buffersObject.As<v8::Array>();
875
+ auto len = array->Length();
876
+ std::vector<uint32_t> buf;
877
+ buf.reserve(len);
878
+ for (int j = 0; j < len; ++j) {
879
+ auto item = array->Get(
880
+ context, j).ToLocalChecked();
881
+ buf.emplace_back(
882
+ (uint32_t) item->NumberValue(context).ToChecked());
883
+ }
884
+
885
+ canvas_native_webgl2_draw_buffers(
886
+ buf.data(), buf.size(),
887
+ ptr->GetState());
888
+ }
889
+ }
890
+
891
+ void
892
+ WebGL2RenderingContext::DrawElementsInstanced(const v8::FunctionCallbackInfo<v8::Value> &args) {
893
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
894
+ if (ptr == nullptr) {
895
+ return;
896
+ }
897
+
898
+ auto isolate = args.GetIsolate();
899
+ auto context = isolate->GetCurrentContext();
900
+
901
+ auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
902
+ auto count_ = (int32_t) args[1]->NumberValue(context).ToChecked();
903
+ auto type = (uint32_t) args[2]->NumberValue(context).ToChecked();
904
+ auto offset = args[3]->NumberValue(context).ToChecked();
905
+ auto instanceCount = (int32_t) args[4]->NumberValue(context).ToChecked();
906
+ canvas_native_webgl2_draw_elements_instanced(
907
+ mode,
908
+ count_,
909
+ type,
910
+ static_cast<ssize_t>(offset),
911
+ instanceCount,
912
+ ptr->GetState()
913
+ );
914
+
915
+ ptr->UpdateInvalidateState();
916
+ }
917
+
918
+ void WebGL2RenderingContext::DrawRangeElements(const v8::FunctionCallbackInfo<v8::Value> &args) {
919
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
920
+ if (ptr == nullptr) {
921
+ return;
922
+ }
923
+
924
+ auto isolate = args.GetIsolate();
925
+ auto context = isolate->GetCurrentContext();
926
+
927
+ auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
928
+ auto start = (uint32_t) args[1]->NumberValue(context).ToChecked();
929
+ auto end = (uint32_t) args[2]->NumberValue(context).ToChecked();
930
+ auto count_ = (int32_t) args[3]->NumberValue(context).ToChecked();
931
+ auto type = (uint32_t) args[4]->NumberValue(context).ToChecked();
932
+ auto offset = args[5]->NumberValue(context).ToChecked();
933
+ canvas_native_webgl2_draw_range_elements(
934
+ mode,
935
+ start,
936
+ end,
937
+ count_,
938
+ type,
939
+ static_cast<ssize_t>(offset),
940
+ ptr->GetState()
941
+ );
942
+
943
+ ptr->UpdateInvalidateState();
944
+ }
945
+
946
+ void WebGL2RenderingContext::EndQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
947
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
948
+ if (ptr == nullptr) {
949
+ return;
950
+ }
951
+
952
+ auto isolate = args.GetIsolate();
953
+ auto context = isolate->GetCurrentContext();
954
+
955
+ if (args[0]->IsNumber()) {
956
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
957
+ canvas_native_webgl2_end_query(target,
958
+ ptr->GetState());
959
+ }
960
+ }
961
+
962
+ void WebGL2RenderingContext::EndTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
963
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
964
+ if (ptr == nullptr) {
965
+ return;
966
+ }
967
+
968
+ auto isolate = args.GetIsolate();
969
+
970
+
971
+ canvas_native_webgl2_end_transform_feedback(
972
+ ptr->GetState());
973
+ }
974
+
975
+ void WebGL2RenderingContext::FenceSync(const v8::FunctionCallbackInfo<v8::Value> &args) {
976
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
977
+ if (ptr == nullptr) {
978
+ args.GetReturnValue().SetUndefined();
979
+ return;
980
+ }
981
+
982
+ auto isolate = args.GetIsolate();
983
+ auto context = isolate->GetCurrentContext();
984
+
985
+ auto condition = (uint32_t) args[0]->NumberValue(context).ToChecked();
986
+ auto flags = (uint32_t) args[1]->NumberValue(context).ToChecked();
987
+ auto sync = canvas_native_webgl2_fence_sync(
988
+ condition,
989
+ flags,
990
+ ptr->GetState()
991
+ );
992
+ auto ret = WebGLSyncImpl::NewInstance(isolate, new WebGLSyncImpl(sync));
993
+
994
+ args.GetReturnValue().Set(ret);
995
+ }
996
+
997
+ void
998
+ WebGL2RenderingContext::FramebufferTextureLayer(const v8::FunctionCallbackInfo<v8::Value> &args) {
999
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1000
+ if (ptr == nullptr) {
1001
+ args.GetReturnValue().SetUndefined();
1002
+ return;
1003
+ }
1004
+
1005
+ auto isolate = args.GetIsolate();
1006
+ auto context = isolate->GetCurrentContext();
1007
+
1008
+
1009
+ auto textureValue = args[2];
1010
+ auto type = GetNativeType(isolate, textureValue);
1011
+ if (type == NativeType::WebGLTexture) {
1012
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1013
+ auto attachment = (uint32_t) args[1]->NumberValue(context).ToChecked();
1014
+ auto texture = WebGLTexture::GetPointer(textureValue.As<v8::Object>());
1015
+ auto level = (int32_t) args[3]->NumberValue(context).ToChecked();
1016
+ auto layer = (int32_t) args[4]->NumberValue(context).ToChecked();
1017
+ if (texture != nullptr) {
1018
+ canvas_native_webgl2_framebuffer_texture_layer(
1019
+ target,
1020
+ attachment,
1021
+ texture->GetTexture(),
1022
+ level,
1023
+ layer,
1024
+ ptr->GetState()
1025
+ );
1026
+ }
1027
+
1028
+ }
1029
+ }
1030
+
1031
+ void
1032
+ WebGL2RenderingContext::GetActiveUniformBlockName(const v8::FunctionCallbackInfo<v8::Value> &args) {
1033
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1034
+ if (ptr == nullptr) {
1035
+ args.GetReturnValue().SetEmptyString();
1036
+ return;
1037
+ }
1038
+
1039
+ auto isolate = args.GetIsolate();
1040
+ auto context = isolate->GetCurrentContext();
1041
+
1042
+ auto programValue = args[0];
1043
+ auto type = GetNativeType(isolate, programValue);
1044
+ if (type == NativeType::WebGLProgram) {
1045
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1046
+ if (program != nullptr) {
1047
+ auto uniformBlockIndex = (uint32_t) args[1]->NumberValue(context).ToChecked();
1048
+ auto name = canvas_native_webgl2_get_active_uniform_block_name(
1049
+ program->GetProgram(),
1050
+ uniformBlockIndex,
1051
+ ptr->GetState()
1052
+ );
1053
+ args.GetReturnValue().Set(ConvertToV8OneByteString(isolate, (char*)name));
1054
+ return;
1055
+ }
1056
+
1057
+ }
1058
+
1059
+ args.GetReturnValue().SetEmptyString();
1060
+ }
1061
+
1062
+ void WebGL2RenderingContext::GetActiveUniformBlockParameter(
1063
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
1064
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1065
+ if (ptr == nullptr) {
1066
+ args.GetReturnValue().SetNull();
1067
+ return;
1068
+ }
1069
+
1070
+ auto isolate = args.GetIsolate();
1071
+ auto context = isolate->GetCurrentContext();
1072
+
1073
+ auto programValue = args[0];
1074
+ auto type = GetNativeType(isolate, programValue);
1075
+
1076
+ if (type == NativeType::WebGLProgram) {
1077
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1078
+
1079
+ if (program != nullptr) {
1080
+ auto uniformBlockIndex = (uint32_t) args[1]->NumberValue(context).ToChecked();
1081
+ auto pname = (uint32_t) args[2]->NumberValue(context).ToChecked();
1082
+ auto ret = canvas_native_webgl2_get_active_uniform_block_parameter(
1083
+ program->GetProgram(),
1084
+ uniformBlockIndex,
1085
+ pname,
1086
+ ptr->GetState()
1087
+ );
1088
+
1089
+ switch (pname) {
1090
+ case GL_UNIFORM_BLOCK_BINDING:
1091
+ case GL_UNIFORM_BLOCK_DATA_SIZE:
1092
+ case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
1093
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1094
+ ret));
1095
+ canvas_native_webgl_WebGLResult_destroy(ret);
1096
+ return;
1097
+ case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: {
1098
+ auto value = canvas_native_webgl_result_get_u32_array(
1099
+ ret);
1100
+
1101
+ auto buf = (uint8_t*)canvas_native_u32_buffer_get_bytes(value);
1102
+ auto size = canvas_native_u32_buffer_get_length(value);
1103
+ auto bytes_size = size * sizeof(uint32_t);
1104
+
1105
+ auto store = v8::ArrayBuffer::NewBackingStore(buf, bytes_size,
1106
+ [](void *data, size_t length,
1107
+ void *deleter_data) {
1108
+ if (deleter_data != nullptr) {
1109
+ canvas_native_u32_buffer_destroy((U32Buffer *) deleter_data);
1110
+ }
1111
+ },
1112
+ value);
1113
+
1114
+ auto arraybuffer = v8::ArrayBuffer::New(isolate, std::move(store));
1115
+ args.GetReturnValue().Set(v8::Uint32Array::New(arraybuffer, 0, size));
1116
+
1117
+ canvas_native_webgl_WebGLResult_destroy(ret);
1118
+
1119
+ return;
1120
+ }
1121
+ case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
1122
+ case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
1123
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_bool(
1124
+ ret));
1125
+
1126
+ canvas_native_webgl_WebGLResult_destroy(ret);
1127
+ return;
1128
+ default:
1129
+ args.GetReturnValue().SetNull();
1130
+ canvas_native_webgl_WebGLResult_destroy(ret);
1131
+ return;
1132
+ }
1133
+ }
1134
+ }
1135
+ }
1136
+
1137
+ void WebGL2RenderingContext::GetActiveUniforms(const v8::FunctionCallbackInfo<v8::Value> &args) {
1138
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1139
+ if (ptr == nullptr) {
1140
+ args.GetReturnValue().SetNull();
1141
+ return;
1142
+ }
1143
+
1144
+ auto isolate = args.GetIsolate();
1145
+ auto context = isolate->GetCurrentContext();
1146
+
1147
+ auto programValue = args[0];
1148
+ auto type = GetNativeType(isolate, programValue);
1149
+ if (type == NativeType::WebGLProgram) {
1150
+
1151
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1152
+ auto uniformIndicesObject = args[1];
1153
+ auto pname = (uint32_t) args[2]->NumberValue(context).ToChecked();
1154
+
1155
+ if (uniformIndicesObject->IsArray()) {
1156
+ auto uniformIndices = uniformIndicesObject.As<v8::Array>();
1157
+ auto size = uniformIndices->Length();
1158
+ std::vector<uint32_t> buf;
1159
+ buf.reserve(size);
1160
+ for (int j = 0; j < size; j++) {
1161
+ auto item = (uint32_t) uniformIndices->Get(
1162
+ context, j).ToLocalChecked()->NumberValue(context).ToChecked();
1163
+ buf.emplace_back(item);
1164
+ }
1165
+
1166
+ auto ret = canvas_native_webgl2_get_active_uniforms(
1167
+ program->GetProgram(),
1168
+ buf.data(), buf.size(),
1169
+ pname,
1170
+ ptr->GetState()
1171
+ );
1172
+
1173
+ switch (pname) {
1174
+ case GL_UNIFORM_TYPE:
1175
+ case GL_UNIFORM_SIZE: {
1176
+ auto value = canvas_native_webgl_result_get_u32_array(
1177
+ ret);
1178
+ auto len = canvas_native_u32_buffer_get_length(value);
1179
+ auto buffer = canvas_native_u32_buffer_get_bytes(value);
1180
+
1181
+ auto array = v8::Array::New(
1182
+ isolate, (int) len);
1183
+
1184
+ for (int j = 0;
1185
+ j < len; ++j) {
1186
+ auto item = buffer[j];
1187
+ array->Set(
1188
+ context, j,
1189
+ v8::Number::New(isolate, (double) item));
1190
+ }
1191
+ args.GetReturnValue().Set(array);
1192
+ canvas_native_u32_buffer_destroy(value);
1193
+ canvas_native_webgl_WebGLResult_destroy(ret);
1194
+ return;
1195
+ }
1196
+ case GL_UNIFORM_BLOCK_INDEX:
1197
+ case GL_UNIFORM_OFFSET:
1198
+ case GL_UNIFORM_ARRAY_STRIDE:
1199
+ case GL_UNIFORM_MATRIX_STRIDE: {
1200
+ auto value = canvas_native_webgl_result_get_i32_array(
1201
+ ret);
1202
+ auto len = canvas_native_i32_buffer_get_length(value);
1203
+ auto buffer = canvas_native_i32_buffer_get_bytes(value);
1204
+ auto array = v8::Array::New(
1205
+ isolate, (int) len);
1206
+ for (int j = 0;
1207
+ j < len; ++j) {
1208
+ auto item = buffer[j];
1209
+ array->Set(
1210
+ context, j,
1211
+ v8::Number::New(isolate,
1212
+ (double) item));
1213
+ }
1214
+ args.GetReturnValue().Set(array);
1215
+ canvas_native_i32_buffer_destroy(value);
1216
+ canvas_native_webgl_WebGLResult_destroy(ret);
1217
+ return;
1218
+ }
1219
+ case GL_UNIFORM_IS_ROW_MAJOR: {
1220
+ auto value = canvas_native_webgl_result_get_bool_array(
1221
+ ret);
1222
+ auto len = canvas_native_u8_buffer_get_length(value);
1223
+ auto buffer = canvas_native_u8_buffer_get_bytes(value);
1224
+ auto array = v8::Array::New(
1225
+ isolate,
1226
+ (int) len);
1227
+ for (int j = 0;
1228
+ j < len; ++j) {
1229
+ bool item =
1230
+ buffer[j] == 1;
1231
+ array->Set(
1232
+ context, j,
1233
+ v8::Boolean::New(isolate, item));
1234
+ }
1235
+ args.GetReturnValue().Set(array);
1236
+ canvas_native_u8_buffer_destroy(value);
1237
+ canvas_native_webgl_WebGLResult_destroy(ret);
1238
+ return;
1239
+ }
1240
+ default:
1241
+ args.GetReturnValue().SetNull();
1242
+ canvas_native_webgl_WebGLResult_destroy(ret);
1243
+ return;
1244
+ }
1245
+ }
1246
+
1247
+
1248
+ }
1249
+ }
1250
+
1251
+ void WebGL2RenderingContext::GetBufferSubData(const v8::FunctionCallbackInfo<v8::Value> &args) {
1252
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1253
+ if (ptr == nullptr) {
1254
+ args.GetReturnValue().SetNull();
1255
+ return;
1256
+ }
1257
+
1258
+ auto isolate = args.GetIsolate();
1259
+ auto context = isolate->GetCurrentContext();
1260
+
1261
+ auto dstDataObject = args[2];
1262
+ if (dstDataObject->IsArrayBufferView()) {
1263
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1264
+ auto srcByteOffset = args[1]->NumberValue(context).ToChecked();
1265
+
1266
+ auto array = dstDataObject.As<v8::ArrayBufferView>();
1267
+
1268
+ auto buf = array->Buffer();
1269
+ auto offset = array->ByteOffset();
1270
+ auto size = buf->ByteLength();
1271
+ auto data = reinterpret_cast<uint8_t *>(buf->GetBackingStore()->Data()) + offset;
1272
+
1273
+
1274
+
1275
+ auto BYTES_PER_ELEMENT = (ssize_t) array->Get(
1276
+ context,
1277
+ ConvertToV8String(isolate, "BYTES_PER_ELEMENT")).ToLocalChecked()->NumberValue(
1278
+ context).ToChecked();
1279
+
1280
+ ssize_t dstOffsetValue = 0;
1281
+ if (args[3]->IsNumber()) {
1282
+ dstOffsetValue =
1283
+ static_cast<ssize_t>(args[3]->NumberValue(context).ToChecked()) *
1284
+ BYTES_PER_ELEMENT;
1285
+ }
1286
+
1287
+ ssize_t lengthValue = 0;
1288
+ if (args[4]->IsNumber()) {
1289
+ lengthValue =
1290
+ static_cast<ssize_t>(args[4]->NumberValue(context).ToChecked()) *
1291
+ BYTES_PER_ELEMENT;
1292
+ }
1293
+
1294
+ canvas_native_webgl2_get_buffer_sub_data(
1295
+ target,
1296
+ static_cast<ssize_t>(srcByteOffset),
1297
+ data, size,
1298
+ dstOffsetValue,
1299
+ lengthValue,
1300
+ ptr->GetState()
1301
+ );
1302
+ }
1303
+ }
1304
+
1305
+ void WebGL2RenderingContext::GetFragDataLocation(const v8::FunctionCallbackInfo<v8::Value> &args) {
1306
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1307
+ if (ptr == nullptr) {
1308
+ args.GetReturnValue().SetNull();
1309
+ return;
1310
+ }
1311
+
1312
+ auto isolate = args.GetIsolate();
1313
+ auto context = isolate->GetCurrentContext();
1314
+
1315
+ auto programValue = args[0];
1316
+ auto nameValue = args[1];
1317
+ auto type = GetNativeType(isolate, programValue);
1318
+ if (type == NativeType::WebGLProgram && nameValue->IsString()) {
1319
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1320
+
1321
+ if (program != nullptr) {
1322
+ auto name = ConvertFromV8String(isolate, nameValue);
1323
+
1324
+ auto ret = canvas_native_webgl2_get_frag_data_location(
1325
+ program->GetProgram(),
1326
+ name.c_str(),
1327
+ ptr->GetState()
1328
+ );
1329
+
1330
+ args.GetReturnValue().Set(ret);
1331
+
1332
+ return;
1333
+ }
1334
+ }
1335
+ args.GetReturnValue().SetNull();
1336
+ }
1337
+
1338
+ void WebGL2RenderingContext::GetIndexedParameter(const v8::FunctionCallbackInfo<v8::Value> &args) {
1339
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1340
+ if (ptr == nullptr) {
1341
+ args.GetReturnValue().SetNull();
1342
+ return;
1343
+ }
1344
+
1345
+ auto isolate = args.GetIsolate();
1346
+ auto context = isolate->GetCurrentContext();
1347
+
1348
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1349
+ auto index = (uint32_t) args[1]->NumberValue(context).ToChecked();
1350
+ auto ret = canvas_native_webgl2_get_indexed_parameter(
1351
+ target,
1352
+ index,
1353
+ ptr->GetState()
1354
+ );
1355
+
1356
+ switch (target) {
1357
+ case GL_UNIFORM_BUFFER_BINDING:
1358
+ case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: {
1359
+ auto buffer = canvas_native_webgl2_indexed_parameter_get_buffer_value(
1360
+ ret);
1361
+
1362
+ args.GetReturnValue().Set(
1363
+ WebGLBuffer::NewInstance(isolate, new WebGLBuffer(buffer)));
1364
+ }
1365
+ return;
1366
+ case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
1367
+ case GL_TRANSFORM_FEEDBACK_BUFFER_START:
1368
+ case GL_UNIFORM_BUFFER_SIZE:
1369
+ case GL_UNIFORM_BUFFER_START: {
1370
+ auto value = canvas_native_webgl2_indexed_parameter_get_value(
1371
+ ret);
1372
+ args.GetReturnValue().Set(static_cast<double>(value));
1373
+ return;
1374
+ }
1375
+ break;
1376
+ default:
1377
+ args.GetReturnValue().SetNull();
1378
+ return;
1379
+ }
1380
+ }
1381
+
1382
+ void WebGL2RenderingContext::GetInternalformatParameter(
1383
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
1384
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1385
+ if (ptr == nullptr) {
1386
+ args.GetReturnValue().SetNull();
1387
+ return;
1388
+ }
1389
+
1390
+ auto isolate = args.GetIsolate();
1391
+ auto context = isolate->GetCurrentContext();
1392
+
1393
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1394
+ auto internalformat = (uint32_t) args[1]->NumberValue(context).ToChecked();
1395
+ auto pname = (uint32_t) args[2]->NumberValue(context).ToChecked();
1396
+ switch (internalformat) {
1397
+ case GL_RGB:
1398
+ case GL_RGBA:
1399
+ case GL_R8UI:
1400
+ case GL_R8I:
1401
+ case GL_R16UI:
1402
+ case GL_R16I:
1403
+ case GL_R32UI:
1404
+ case GL_R32I:
1405
+ case GL_RG8UI:
1406
+ case GL_RG8I:
1407
+ case GL_RG16UI:
1408
+ case GL_RG16I:
1409
+ case GL_RG32UI:
1410
+ case GL_RG32I:
1411
+ case GL_RGBA8UI:
1412
+ case GL_RGBA8I:
1413
+ case GL_RGB10_A2UI:
1414
+ case GL_RGBA16UI:
1415
+ case GL_RGBA16I:
1416
+ case GL_RGBA32UI:
1417
+ case GL_RGBA32I: {
1418
+ // empty
1419
+ auto arraybuffer = v8::ArrayBuffer::New(isolate, 0);
1420
+
1421
+ args.GetReturnValue().Set(v8::Int32Array::New(arraybuffer, 0, 0));
1422
+ return;
1423
+ }
1424
+ case GL_R8:
1425
+ case GL_RG8:
1426
+ case GL_RGB565:
1427
+ case GL_RGBA8:
1428
+ case GL_SRGB8_ALPHA8:
1429
+ case GL_RGB5_A1:
1430
+ case GL_RGBA4:
1431
+ case GL_RGB10_A2:
1432
+ case GL_DEPTH_COMPONENT16:
1433
+ case GL_DEPTH_COMPONENT24:
1434
+ case GL_DEPTH_COMPONENT32F:
1435
+ case GL_DEPTH24_STENCIL8:
1436
+ case GL_DEPTH32F_STENCIL8:
1437
+ case GL_STENCIL_INDEX8:
1438
+ // noop
1439
+ break;
1440
+ case GL_R16F:
1441
+ case GL_RG16F:
1442
+ case GL_R32F:
1443
+ case GL_RG32F:
1444
+ case GL_RGBA32F:
1445
+ case GL_R11F_G11F_B10F:
1446
+ // noop
1447
+ break;
1448
+ default:
1449
+ args.GetReturnValue().SetNull();
1450
+ return;
1451
+ }
1452
+
1453
+
1454
+ auto ret = canvas_native_webgl2_get_internalformat_parameter(
1455
+ target,
1456
+ internalformat,
1457
+ pname,
1458
+ ptr->GetState()
1459
+ );
1460
+
1461
+ if (pname == GL_SAMPLES) {
1462
+ auto value = canvas_native_webgl_result_get_i32_array(ret);
1463
+
1464
+ auto buf = (uint8_t*)canvas_native_i32_buffer_get_bytes(value);
1465
+ auto size = canvas_native_i32_buffer_get_length(value);
1466
+ auto bytes_size = size * sizeof(int32_t);
1467
+
1468
+ auto store = v8::ArrayBuffer::NewBackingStore(buf, bytes_size,
1469
+ [](void *data, size_t length,
1470
+ void *deleter_data) {
1471
+ if (deleter_data != nullptr) {
1472
+ canvas_native_i32_buffer_destroy((I32Buffer *) deleter_data);
1473
+ }
1474
+ },
1475
+ value);
1476
+
1477
+ auto arraybuffer = v8::ArrayBuffer::New(isolate, std::move(store));
1478
+ args.GetReturnValue().Set(v8::Int32Array::New(arraybuffer, 0, size));
1479
+ canvas_native_webgl_WebGLResult_destroy(ret);
1480
+ return;
1481
+ } else {
1482
+ args.GetReturnValue().SetNull();
1483
+ canvas_native_webgl_WebGLResult_destroy(ret);
1484
+ return;
1485
+ }
1486
+ }
1487
+
1488
+ void WebGL2RenderingContext::GetParameter(const v8::FunctionCallbackInfo<v8::Value> &args) {
1489
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1490
+ if (ptr == nullptr) {
1491
+ args.GetReturnValue().SetNull();
1492
+ return;
1493
+ }
1494
+
1495
+ auto isolate = args.GetIsolate();
1496
+ auto context = isolate->GetCurrentContext();
1497
+
1498
+ auto pname = (uint32_t) args[0]->NumberValue(context).ToChecked();
1499
+ auto result = canvas_native_webgl2_get_parameter(
1500
+ pname,
1501
+ ptr->GetState());
1502
+ switch (pname) {
1503
+ case GL_COPY_READ_BUFFER_BINDING:
1504
+ case GL_COPY_WRITE_BUFFER_BINDING:
1505
+ case GL_DRAW_FRAMEBUFFER_BINDING:
1506
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1507
+ result));
1508
+
1509
+ canvas_native_webgl_WebGLResult_destroy(result);
1510
+ return;
1511
+ default: {
1512
+ auto ret = ptr->GetParameterInternal(
1513
+ isolate, pname,result);
1514
+
1515
+ canvas_native_webgl_WebGLResult_destroy(result);
1516
+
1517
+ args.GetReturnValue().Set(ret);
1518
+ return;
1519
+ }
1520
+ }
1521
+ }
1522
+
1523
+ void WebGL2RenderingContext::GetQueryParameter(const v8::FunctionCallbackInfo<v8::Value> &args) {
1524
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1525
+ if (ptr == nullptr) {
1526
+ args.GetReturnValue().SetNull();
1527
+ return;
1528
+ }
1529
+
1530
+ auto isolate = args.GetIsolate();
1531
+ auto context = isolate->GetCurrentContext();
1532
+
1533
+ auto queryValue = args[0];
1534
+ auto type = GetNativeType(isolate, queryValue);
1535
+ if (type == NativeType::WebGLQuery) {
1536
+ auto query = WebGLQuery::GetPointer(queryValue.As<v8::Object>());
1537
+ if (query != nullptr) {
1538
+ auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
1539
+
1540
+
1541
+ auto ret = canvas_native_webgl2_get_query_parameter(
1542
+ query->GetQuery(),
1543
+ pname,
1544
+ ptr->GetState());
1545
+ if (pname == GL_QUERY_RESULT) {
1546
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_bool(
1547
+ ret));
1548
+ canvas_native_webgl_WebGLResult_destroy(ret);
1549
+ return;
1550
+ } else if (pname ==
1551
+ GL_QUERY_RESULT_AVAILABLE) {
1552
+ args.GetReturnValue().Set((int32_t) canvas_native_webgl_result_get_u32(
1553
+ ret));
1554
+ canvas_native_webgl_WebGLResult_destroy(ret);
1555
+ return;
1556
+ }
1557
+ //clean up
1558
+ canvas_native_webgl_WebGLResult_destroy(ret);
1559
+
1560
+ }
1561
+ }
1562
+
1563
+ args.GetReturnValue().SetNull();
1564
+ }
1565
+
1566
+ void WebGL2RenderingContext::GetQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
1567
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1568
+ if (ptr == nullptr) {
1569
+ args.GetReturnValue().SetNull();
1570
+ return;
1571
+ }
1572
+
1573
+ auto isolate = args.GetIsolate();
1574
+ auto context = isolate->GetCurrentContext();
1575
+
1576
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1577
+ auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
1578
+ auto ret = canvas_native_webgl2_get_query(
1579
+ target,
1580
+ pname,
1581
+ ptr->GetState());
1582
+ if (pname == GL_CURRENT_QUERY) {
1583
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1584
+ ret));
1585
+ canvas_native_webgl_WebGLResult_destroy(ret);
1586
+ return;
1587
+ }
1588
+ // clean up
1589
+ canvas_native_webgl_WebGLResult_destroy(ret);
1590
+ }
1591
+
1592
+ void WebGL2RenderingContext::GetSamplerParameter(const v8::FunctionCallbackInfo<v8::Value> &args) {
1593
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1594
+ if (ptr == nullptr) {
1595
+ args.GetReturnValue().SetNull();
1596
+ return;
1597
+ }
1598
+
1599
+ auto isolate = args.GetIsolate();
1600
+ auto context = isolate->GetCurrentContext();
1601
+
1602
+ auto samplerValue = args[0];
1603
+ auto type = GetNativeType(isolate, samplerValue);
1604
+ if (type == NativeType::WebGLSampler) {
1605
+ auto sampler = WebGLSampler::GetPointer(samplerValue.As<v8::Object>());
1606
+ if (sampler != nullptr) {
1607
+ auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
1608
+ auto ret = canvas_native_webgl2_get_sampler_parameter(
1609
+ sampler->GetSampler(),
1610
+ pname,
1611
+ ptr->GetState());
1612
+
1613
+ switch (pname) {
1614
+ case GL_TEXTURE_MAX_LOD:
1615
+ case GL_TEXTURE_MIN_LOD:
1616
+ args.GetReturnValue().Set(
1617
+ static_cast<double>(canvas_native_webgl_result_get_f32(
1618
+ ret)));
1619
+ canvas_native_webgl_WebGLResult_destroy(ret);
1620
+ return;
1621
+ case GL_TEXTURE_COMPARE_FUNC:
1622
+ case GL_TEXTURE_COMPARE_MODE:
1623
+ case GL_TEXTURE_MAG_FILTER:
1624
+ case GL_TEXTURE_MIN_FILTER:
1625
+ case GL_TEXTURE_WRAP_R:
1626
+ case GL_TEXTURE_WRAP_S:
1627
+ case GL_TEXTURE_WRAP_T:
1628
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1629
+ ret));
1630
+ canvas_native_webgl_WebGLResult_destroy(ret);
1631
+ return;
1632
+ default:
1633
+ args.GetReturnValue().SetNull();
1634
+ canvas_native_webgl_WebGLResult_destroy(ret);
1635
+ return;
1636
+ }
1637
+ }
1638
+ }
1639
+
1640
+ args.GetReturnValue().SetNull();
1641
+ }
1642
+
1643
+ void WebGL2RenderingContext::GetSyncParameter(const v8::FunctionCallbackInfo<v8::Value> &args) {
1644
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1645
+ if (ptr == nullptr) {
1646
+ args.GetReturnValue().SetNull();
1647
+ return;
1648
+ }
1649
+
1650
+ auto isolate = args.GetIsolate();
1651
+ auto context = isolate->GetCurrentContext();
1652
+
1653
+ auto syncValue = args[0];
1654
+ auto sync = WebGLSyncImpl::GetPointer(syncValue.As<v8::Object>());
1655
+ if (sync != nullptr) {
1656
+ auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
1657
+ auto ret = canvas_native_webgl2_get_sync_parameter(
1658
+ sync->GetSync(),
1659
+ pname,
1660
+ ptr->GetState());
1661
+
1662
+ switch (pname) {
1663
+ case GL_OBJECT_TYPE:
1664
+ case GL_SYNC_STATUS:
1665
+ case GL_SYNC_CONDITION:
1666
+ case GL_SYNC_FLAGS:
1667
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1668
+ ret));
1669
+
1670
+ canvas_native_webgl_WebGLResult_destroy(ret);
1671
+ return;
1672
+ default:
1673
+ args.GetReturnValue().SetNull();
1674
+ canvas_native_webgl_WebGLResult_destroy(ret);
1675
+ return;
1676
+ }
1677
+ }
1678
+ args.GetReturnValue().SetNull();
1679
+ }
1680
+
1681
+ void WebGL2RenderingContext::GetTransformFeedbackVarying(
1682
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
1683
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1684
+ if (ptr == nullptr) {
1685
+ args.GetReturnValue().SetNull();
1686
+ return;
1687
+ }
1688
+
1689
+ auto isolate = args.GetIsolate();
1690
+ auto context = isolate->GetCurrentContext();
1691
+
1692
+ auto programValue = args[0];
1693
+ auto type = GetNativeType(isolate, programValue);
1694
+ if (type == NativeType::WebGLProgram) {
1695
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1696
+ auto index = (uint32_t) args[1]->NumberValue(context).ToChecked();
1697
+ if (program != nullptr) {
1698
+ auto ret = canvas_native_webgl2_get_transform_feedback_varying(
1699
+ program->GetProgram(),
1700
+ index,
1701
+ ptr->GetState()
1702
+ );
1703
+
1704
+ if (canvas_native_webgl_active_info_get_is_empty(
1705
+ ret)) {
1706
+ canvas_native_webgl_active_info_destroy(ret);
1707
+ args.GetReturnValue().SetNull();
1708
+ return;
1709
+ }
1710
+
1711
+ auto info = WebGLActiveInfoImpl::NewInstance(isolate, new WebGLActiveInfoImpl(ret));
1712
+ args.GetReturnValue().Set(info);
1713
+ return;
1714
+ }
1715
+ }
1716
+
1717
+ args.GetReturnValue().SetNull();
1718
+ }
1719
+
1720
+ void WebGL2RenderingContext::GetUniformBlockIndex(const v8::FunctionCallbackInfo<v8::Value> &args) {
1721
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1722
+ if (ptr == nullptr) {
1723
+ args.GetReturnValue().SetNull();
1724
+ return;
1725
+ }
1726
+
1727
+ auto isolate = args.GetIsolate();
1728
+ auto context = isolate->GetCurrentContext();
1729
+
1730
+ auto programValue = args[0];
1731
+ auto type = GetNativeType(isolate, programValue);
1732
+ if (type == NativeType::WebGLProgram) {
1733
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1734
+ auto index = ConvertFromV8String(isolate, args[1]);
1735
+ if (program != nullptr) {
1736
+ auto ret = canvas_native_webgl2_get_uniform_block_index(
1737
+ program->GetProgram(),
1738
+ index.c_str(),
1739
+ ptr->GetState());
1740
+ args.GetReturnValue().Set((int) ret);
1741
+ return;
1742
+ }
1743
+ }
1744
+
1745
+ args.GetReturnValue().SetNull();
1746
+ }
1747
+
1748
+ void WebGL2RenderingContext::GetUniformIndices(const v8::FunctionCallbackInfo<v8::Value> &args) {
1749
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1750
+ if (ptr == nullptr) {
1751
+ args.GetReturnValue().SetNull();
1752
+ return;
1753
+ }
1754
+
1755
+ auto isolate = args.GetIsolate();
1756
+ auto context = isolate->GetCurrentContext();
1757
+
1758
+ auto programValue = args[0];
1759
+ auto type = GetNativeType(isolate, programValue);
1760
+ if (type == NativeType::WebGLProgram) {
1761
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1762
+ auto uniformNamesObject = args[1];
1763
+ if (program != nullptr &&
1764
+ uniformNamesObject->IsArray()) {
1765
+ auto uniformNames = uniformNamesObject.As<v8::Array>();
1766
+ auto len = uniformNames->Length();
1767
+
1768
+ std::vector<std::string> store;
1769
+ store.reserve(len);
1770
+
1771
+ for (int j = 0; j < len; ++j) {
1772
+ auto name = ConvertFromV8String(isolate, uniformNames->Get(
1773
+ context, j).ToLocalChecked());
1774
+
1775
+ store.push_back(name);
1776
+ }
1777
+
1778
+
1779
+ const char* cStrings[store.size()];
1780
+ for (size_t i = 0; i < store.size(); ++i) {
1781
+ cStrings[i] = store[i].c_str();
1782
+ }
1783
+
1784
+
1785
+ auto ret = canvas_native_webgl2_get_uniform_indices(
1786
+ program->GetProgram(),
1787
+ cStrings,
1788
+ store.size(),
1789
+ ptr->GetState());
1790
+
1791
+
1792
+ auto retSize = canvas_native_u32_buffer_get_length(ret);
1793
+ auto buf = canvas_native_u32_buffer_get_bytes(ret);
1794
+ auto result = v8::Array::New(isolate, (int) retSize);
1795
+ for (int j = 0; j < retSize; ++j) {
1796
+ auto item = buf[j];
1797
+ result->Set(context,
1798
+ j,
1799
+ v8::Number::New(isolate,
1800
+ (int32_t) item));
1801
+ }
1802
+
1803
+ args.GetReturnValue().Set(result);
1804
+ canvas_native_u32_buffer_destroy(ret);
1805
+ return;
1806
+ }
1807
+ }
1808
+
1809
+ args.GetReturnValue().SetNull();
1810
+ }
1811
+
1812
+ void
1813
+ WebGL2RenderingContext::InvalidateFramebuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
1814
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1815
+ if (ptr == nullptr) {
1816
+ return;
1817
+ }
1818
+
1819
+ auto isolate = args.GetIsolate();
1820
+ auto context = isolate->GetCurrentContext();
1821
+
1822
+ auto attachments = args[1];
1823
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1824
+
1825
+ if (attachments->IsArray()) {
1826
+ auto array = attachments.As<v8::Array>();
1827
+ auto len = array->Length();
1828
+ std::vector<uint32_t> buf;
1829
+ buf.reserve(len);
1830
+ for (int j = 0; j < len; ++j) {
1831
+ auto item = (uint32_t) array->Get(
1832
+ context, j).ToLocalChecked()->NumberValue(context).ToChecked();
1833
+ buf.push_back(item);
1834
+ }
1835
+
1836
+ canvas_native_webgl2_invalidate_framebuffer(
1837
+ target, buf.data(), buf.size(),
1838
+ ptr->GetState());
1839
+ }
1840
+ }
1841
+
1842
+ void
1843
+ WebGL2RenderingContext::InvalidateSubFramebuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
1844
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1845
+ if (ptr == nullptr) {
1846
+ return;
1847
+ }
1848
+
1849
+ auto isolate = args.GetIsolate();
1850
+ auto context = isolate->GetCurrentContext();
1851
+
1852
+ auto attachments = args[1];
1853
+ if (attachments->IsArray()) {
1854
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1855
+ auto x = (int32_t) args[2]->NumberValue(context).ToChecked();
1856
+ auto y = (int32_t) args[3]->NumberValue(context).ToChecked();
1857
+ auto width = (int32_t) args[4]->NumberValue(context).ToChecked();
1858
+ auto height = (int32_t) args[5]->NumberValue(context).ToChecked();
1859
+
1860
+ auto array = attachments.As<v8::Array>();
1861
+ auto len = array->Length();
1862
+ std::vector<uint32_t> buf;
1863
+ buf.reserve(len);
1864
+ for (int j = 0; j < len; ++j) {
1865
+ auto item = (uint32_t) array->Get(
1866
+ context, j).ToLocalChecked()->NumberValue(context).ToChecked();
1867
+ buf.push_back(item);
1868
+ }
1869
+
1870
+ canvas_native_webgl2_invalidate_sub_framebuffer(
1871
+ target,
1872
+ buf.data(), buf.size(),
1873
+ x,
1874
+ y,
1875
+ width,
1876
+ height,
1877
+ ptr->GetState());
1878
+ }
1879
+ }
1880
+
1881
+ void WebGL2RenderingContext::IsQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
1882
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1883
+ if (ptr == nullptr) {
1884
+ return;
1885
+ }
1886
+
1887
+ auto isolate = args.GetIsolate();
1888
+ auto context = isolate->GetCurrentContext();
1889
+
1890
+ auto value = args[0];
1891
+ auto type = GetNativeType(isolate, value);
1892
+ if (type == NativeType::WebGLQuery) {
1893
+ auto query = WebGLQuery::GetPointer(value.As<v8::Object>());
1894
+ if (query != nullptr) {
1895
+ auto ret = canvas_native_webgl2_is_query(
1896
+ query->GetQuery(),
1897
+ ptr->GetState());
1898
+ args.GetReturnValue().Set(ret);
1899
+ return;
1900
+ }
1901
+ }
1902
+ // todo check return
1903
+ args.GetReturnValue().Set(false);
1904
+ }
1905
+
1906
+ void WebGL2RenderingContext::IsSampler(const v8::FunctionCallbackInfo<v8::Value> &args) {
1907
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1908
+ if (ptr == nullptr) {
1909
+ return;
1910
+ }
1911
+
1912
+ auto isolate = args.GetIsolate();
1913
+ auto context = isolate->GetCurrentContext();
1914
+
1915
+ auto value = args[0];
1916
+ auto type = GetNativeType(isolate, value);
1917
+ if (type == NativeType::WebGLSampler) {
1918
+ auto query = WebGLSampler::GetPointer(value.As<v8::Object>());
1919
+ if (query != nullptr) {
1920
+ auto ret = canvas_native_webgl2_is_sampler(
1921
+ query->GetSampler(),
1922
+ ptr->GetState());
1923
+ args.GetReturnValue().Set(ret);
1924
+ return;
1925
+ }
1926
+ }
1927
+ // todo check return
1928
+ args.GetReturnValue().Set(false);
1929
+ }
1930
+
1931
+ void WebGL2RenderingContext::IsSync(const v8::FunctionCallbackInfo<v8::Value> &args) {
1932
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1933
+ if (ptr == nullptr) {
1934
+ return;
1935
+ }
1936
+
1937
+ auto isolate = args.GetIsolate();
1938
+ auto context = isolate->GetCurrentContext();
1939
+
1940
+ auto value = args[0];
1941
+ auto type = GetNativeType(isolate, value);
1942
+ if (type == NativeType::WebGLSync) {
1943
+ auto query = WebGLSyncImpl::GetPointer(value.As<v8::Object>());
1944
+ if (query != nullptr) {
1945
+ auto ret = canvas_native_webgl2_is_sync(
1946
+ query->GetSync(),
1947
+ ptr->GetState());
1948
+ args.GetReturnValue().Set(ret);
1949
+ return;
1950
+ }
1951
+ }
1952
+ // todo check return
1953
+ args.GetReturnValue().Set(false);
1954
+ }
1955
+
1956
+ void WebGL2RenderingContext::IsTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
1957
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1958
+ if (ptr == nullptr) {
1959
+ return;
1960
+ }
1961
+
1962
+ auto isolate = args.GetIsolate();
1963
+ auto context = isolate->GetCurrentContext();
1964
+
1965
+ auto value = args[0];
1966
+ auto type = GetNativeType(isolate, value);
1967
+ if (type == NativeType::WebGLTransformFeedback) {
1968
+ auto query = WebGLTransformFeedback::GetPointer(value.As<v8::Object>());
1969
+ if (query != nullptr) {
1970
+ auto ret = canvas_native_webgl2_is_transform_feedback(
1971
+ query->GetFeedback(),
1972
+ ptr->GetState());
1973
+ args.GetReturnValue().Set(ret);
1974
+ return;
1975
+ }
1976
+ }
1977
+ // todo check return
1978
+ args.GetReturnValue().Set(false);
1979
+ }
1980
+
1981
+ void WebGL2RenderingContext::IsVertexArray(const v8::FunctionCallbackInfo<v8::Value> &args) {
1982
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1983
+ if (ptr == nullptr) {
1984
+ return;
1985
+ }
1986
+
1987
+ auto isolate = args.GetIsolate();
1988
+ auto context = isolate->GetCurrentContext();
1989
+
1990
+ auto value = args[0];
1991
+ auto type = GetNativeType(isolate, value);
1992
+ if (type == NativeType::WebGLVertexArrayObject) {
1993
+ auto query = WebGLVertexArrayObject::GetPointer(value.As<v8::Object>());
1994
+ if (query != nullptr) {
1995
+ auto ret = canvas_native_webgl2_is_vertex_array(
1996
+ query->GetVertexArrayObject(),
1997
+ ptr->GetState());
1998
+ args.GetReturnValue().Set(ret);
1999
+ return;
2000
+ }
2001
+ }
2002
+ // todo check return
2003
+ args.GetReturnValue().Set(false);
2004
+ }
2005
+
2006
+ void
2007
+ WebGL2RenderingContext::PauseTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
2008
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2009
+ if (ptr == nullptr) {
2010
+ return;
2011
+ }
2012
+ canvas_native_webgl2_pause_transform_feedback(
2013
+ ptr->GetState());
2014
+ }
2015
+
2016
+ void WebGL2RenderingContext::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
2017
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2018
+ if (ptr == nullptr) {
2019
+ return;
2020
+ }
2021
+
2022
+ auto isolate = args.GetIsolate();
2023
+ auto context = isolate->GetCurrentContext();
2024
+
2025
+ auto src = (uint32_t) args[0]->NumberValue(context).ToChecked();
2026
+ canvas_native_webgl2_read_buffer(
2027
+ src,
2028
+ ptr->GetState()
2029
+ );
2030
+ }
2031
+
2032
+ void WebGL2RenderingContext::RenderbufferStorageMultisample(
2033
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
2034
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2035
+ if (ptr == nullptr) {
2036
+ return;
2037
+ }
2038
+
2039
+ auto isolate = args.GetIsolate();
2040
+ auto context = isolate->GetCurrentContext();
2041
+
2042
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
2043
+ auto samples = (int32_t) args[1]->NumberValue(context).ToChecked();
2044
+ auto internalFormat = (uint32_t) args[2]->NumberValue(context).ToChecked();
2045
+ auto width = (int32_t) args[3]->NumberValue(context).ToChecked();
2046
+ auto height = (int32_t) args[4]->NumberValue(context).ToChecked();
2047
+ canvas_native_webgl2_renderbuffer_storage_multisample(
2048
+ target,
2049
+ samples,
2050
+ internalFormat,
2051
+ width,
2052
+ height,
2053
+ ptr->GetState()
2054
+ );
2055
+ }
2056
+
2057
+ void
2058
+ WebGL2RenderingContext::ResumeTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
2059
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2060
+ if (ptr == nullptr) {
2061
+ return;
2062
+ }
2063
+
2064
+ canvas_native_webgl2_resume_transform_feedback(
2065
+ ptr->GetState());
2066
+ }
2067
+
2068
+ void WebGL2RenderingContext::SamplerParameterf(const v8::FunctionCallbackInfo<v8::Value> &args) {
2069
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2070
+ if (ptr == nullptr) {
2071
+ return;
2072
+ }
2073
+
2074
+ auto isolate = args.GetIsolate();
2075
+ auto context = isolate->GetCurrentContext();
2076
+
2077
+ auto samplerValue = args[0];
2078
+ auto type = GetNativeType(isolate, samplerValue);
2079
+ if (type == NativeType::WebGLSampler) {
2080
+ auto sampler = WebGLSampler::GetPointer(samplerValue.As<v8::Object>());
2081
+ auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
2082
+ auto param = args[2]->NumberValue(context).ToChecked();
2083
+ if (sampler != nullptr) {
2084
+ canvas_native_webgl2_sampler_parameterf(
2085
+ sampler->GetSampler(),
2086
+ pname,
2087
+ static_cast<float>(param),
2088
+ ptr->GetState());
2089
+ }
2090
+ }
2091
+
2092
+ }
2093
+
2094
+ void WebGL2RenderingContext::SamplerParameteri(const v8::FunctionCallbackInfo<v8::Value> &args) {
2095
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2096
+ if (ptr == nullptr) {
2097
+ return;
2098
+ }
2099
+
2100
+ auto isolate = args.GetIsolate();
2101
+ auto context = isolate->GetCurrentContext();
2102
+
2103
+ auto samplerValue = args[0];
2104
+ auto type = GetNativeType(isolate, samplerValue);
2105
+ if (type == NativeType::WebGLSampler) {
2106
+ auto sampler = WebGLSampler::GetPointer(samplerValue.As<v8::Object>());
2107
+ auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
2108
+ auto param = (int32_t) args[2]->NumberValue(context).ToChecked();
2109
+ if (sampler != nullptr) {
2110
+ canvas_native_webgl2_sampler_parameteri(
2111
+ sampler->GetSampler(),
2112
+ pname,
2113
+ param,
2114
+ ptr->GetState());
2115
+ }
2116
+ }
2117
+
2118
+ }
2119
+
2120
+ void WebGL2RenderingContext::TexImage3D(const v8::FunctionCallbackInfo<v8::Value> &args) {
2121
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2122
+ if (ptr == nullptr) {
2123
+ return;
2124
+ }
2125
+
2126
+ auto isolate = args.GetIsolate();
2127
+ auto context = isolate->GetCurrentContext();
2128
+
2129
+ auto count = args.Length();
2130
+
2131
+
2132
+ if (count == 10) {
2133
+ auto target = (int32_t) args[0]->NumberValue(
2134
+ context).ToChecked();
2135
+ auto level = (int32_t) args[1]->NumberValue(
2136
+ context).ToChecked();
2137
+ auto internalformat = (int32_t) args[2]->NumberValue(
2138
+ context).ToChecked();
2139
+ auto width = (int32_t) args[3]->NumberValue(
2140
+ context).ToChecked();
2141
+ auto height = (int32_t) args[4]->NumberValue(
2142
+ context).ToChecked();
2143
+ auto depth = (int32_t) args[5]->NumberValue(
2144
+ context).ToChecked();
2145
+ auto border = (int32_t) args[6]->NumberValue(
2146
+ context).ToChecked();
2147
+ auto format = (int32_t) args[7]->NumberValue(
2148
+ context).ToChecked();
2149
+ auto type = (uint32_t) args[8]->NumberValue(
2150
+ context).ToChecked();
2151
+
2152
+ auto imageOrPixelsOrOffset = args[9];
2153
+
2154
+ if (imageOrPixelsOrOffset->IsNumber()) {
2155
+ auto offset = imageOrPixelsOrOffset->NumberValue(
2156
+ context).ToChecked();
2157
+ canvas_native_webgl2_tex_image3d_none(
2158
+ target,
2159
+ level,
2160
+ internalformat,
2161
+ width,
2162
+ height,
2163
+ depth,
2164
+ border,
2165
+ format,
2166
+ type,
2167
+ static_cast<ssize_t>(offset),
2168
+ ptr->GetState()
2169
+ );
2170
+ return;
2171
+ }
2172
+
2173
+
2174
+ if (imageOrPixelsOrOffset->IsArrayBufferView()) {
2175
+ auto buf = imageOrPixelsOrOffset.As<v8::ArrayBufferView>();
2176
+
2177
+ auto array = buf->Buffer();
2178
+ auto offset = buf->ByteOffset();
2179
+ auto size = buf->ByteLength();
2180
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2181
+ auto data = static_cast<uint8_t *>((void*) data_ptr);
2182
+
2183
+
2184
+ canvas_native_webgl2_tex_image3d(
2185
+ target,
2186
+ level,
2187
+ internalformat,
2188
+ width,
2189
+ height,
2190
+ depth,
2191
+ border,
2192
+ format,
2193
+ type,
2194
+ data,
2195
+ size,
2196
+ ptr->GetState()
2197
+ );
2198
+ return;
2199
+ }
2200
+
2201
+ auto imageType = GetNativeType(isolate, imageOrPixelsOrOffset);
2202
+
2203
+ switch (imageType) {
2204
+ case NativeType::ImageAsset: {
2205
+ auto image_asset = ImageAssetImpl::GetPointer(
2206
+ imageOrPixelsOrOffset.As<v8::Object>());
2207
+ if (image_asset != nullptr) {
2208
+ canvas_native_webgl2_tex_image3d_asset(
2209
+ target,
2210
+ level,
2211
+ internalformat,
2212
+ width,
2213
+ height,
2214
+ depth,
2215
+ border,
2216
+ format,
2217
+ type,
2218
+ image_asset->GetImageAsset(),
2219
+ ptr->GetState()
2220
+ );
2221
+
2222
+ return;
2223
+ }
2224
+ return;
2225
+ }
2226
+ case NativeType::ImageBitmap: {
2227
+ auto image_bitmap = ImageBitmapImpl::GetPointer(
2228
+ imageOrPixelsOrOffset.As<v8::Object>());
2229
+ if (image_bitmap != nullptr) {
2230
+ canvas_native_webgl2_tex_image3d_asset(
2231
+ target,
2232
+ level,
2233
+ internalformat,
2234
+ width,
2235
+ height,
2236
+ depth,
2237
+ border,
2238
+ format,
2239
+ type,
2240
+ image_bitmap->GetImageAsset(),
2241
+ ptr->GetState()
2242
+ );
2243
+
2244
+ return;
2245
+ }
2246
+ return;
2247
+ }
2248
+ default:
2249
+ return;
2250
+ }
2251
+ } else if (args.Length() > 10) {
2252
+
2253
+ auto target = (int32_t) args[0]->NumberValue(
2254
+ context).ToChecked();
2255
+ auto level = (int32_t) args[1]->NumberValue(
2256
+ context).ToChecked();
2257
+ auto internalformat = (int32_t) args[2]->NumberValue(
2258
+ context).ToChecked();
2259
+ auto width = (int32_t) args[3]->NumberValue(
2260
+ context).ToChecked();
2261
+ auto height = (int32_t) args[4]->NumberValue(
2262
+ context).ToChecked();
2263
+ auto depth = (int32_t) args[5]->NumberValue(
2264
+ context).ToChecked();
2265
+ auto border = (int32_t) args[6]->NumberValue(
2266
+ context).ToChecked();
2267
+ auto format = (int32_t) args[7]->NumberValue(
2268
+ context).ToChecked();
2269
+ auto type = (uint32_t) args[8]->NumberValue(
2270
+ context).ToChecked();
2271
+
2272
+ auto imageOrPixelsOrOffset = args[9];
2273
+
2274
+ size_t srcOffsetValue = 0;
2275
+ if (args[9]->IsNumber()) {
2276
+ srcOffsetValue = static_cast<size_t>(args[9]->NumberValue(
2277
+ context).ToChecked());
2278
+ }
2279
+
2280
+ if (imageOrPixelsOrOffset->IsArrayBufferView()) {
2281
+ auto buf = imageOrPixelsOrOffset.As<v8::ArrayBufferView>();
2282
+
2283
+ auto array = buf->Buffer();
2284
+ auto offset = buf->ByteOffset();
2285
+ auto size = buf->ByteLength();
2286
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2287
+ auto data = static_cast<uint8_t *>((void*) data_ptr);
2288
+
2289
+ srcOffsetValue =
2290
+ srcOffsetValue * size;
2291
+ if (srcOffsetValue >
2292
+ size) {
2293
+ return;
2294
+ }
2295
+
2296
+ canvas_native_webgl2_tex_image3d_offset(
2297
+ target,
2298
+ level,
2299
+ internalformat,
2300
+ width,
2301
+ height,
2302
+ depth,
2303
+ border,
2304
+ format,
2305
+ type,
2306
+ data, size,
2307
+ srcOffsetValue,
2308
+ ptr->GetState()
2309
+ );
2310
+ return;
2311
+ }
2312
+
2313
+ }
2314
+ }
2315
+
2316
+ void WebGL2RenderingContext::TexStorage2D(const v8::FunctionCallbackInfo<v8::Value> &args) {
2317
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2318
+ if (ptr == nullptr) {
2319
+ return;
2320
+ }
2321
+
2322
+ auto isolate = args.GetIsolate();
2323
+ auto context = isolate->GetCurrentContext();
2324
+
2325
+ auto target = (uint32_t) args[0]->NumberValue(
2326
+ context).ToChecked();
2327
+ auto levels = (int32_t) args[1]->NumberValue(
2328
+ context).ToChecked();
2329
+ auto internalFormat = (uint32_t) args[2]->NumberValue(
2330
+ context).ToChecked();
2331
+ auto width = (int32_t) args[3]->NumberValue(
2332
+ context).ToChecked();
2333
+ auto height = (int32_t) args[4]->NumberValue(
2334
+ context).ToChecked();
2335
+ canvas_native_webgl2_tex_storage2d(
2336
+ target,
2337
+ levels,
2338
+ internalFormat,
2339
+ width,
2340
+ height,
2341
+ ptr->GetState()
2342
+ );
2343
+ }
2344
+
2345
+ void WebGL2RenderingContext::TexStorage3D(const v8::FunctionCallbackInfo<v8::Value> &args) {
2346
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2347
+ if (ptr == nullptr) {
2348
+ return;
2349
+ }
2350
+
2351
+ auto isolate = args.GetIsolate();
2352
+ auto context = isolate->GetCurrentContext();
2353
+
2354
+ auto target = (uint32_t) args[0]->NumberValue(
2355
+ context).ToChecked();
2356
+ auto levels = (int32_t) args[1]->NumberValue(
2357
+ context).ToChecked();
2358
+ auto internalFormat = (uint32_t) args[2]->NumberValue(
2359
+ context).ToChecked();
2360
+ auto width = (int32_t) args[3]->NumberValue(
2361
+ context).ToChecked();
2362
+ auto height = (int32_t) args[4]->NumberValue(
2363
+ context).ToChecked();
2364
+ auto depth = (int32_t) args[5]->NumberValue(
2365
+ context).ToChecked();
2366
+ canvas_native_webgl2_tex_storage3d(
2367
+ target,
2368
+ levels,
2369
+ internalFormat,
2370
+ width,
2371
+ height,
2372
+ depth,
2373
+ ptr->GetState()
2374
+ );
2375
+ }
2376
+
2377
+ void WebGL2RenderingContext::TexSubImage3D(const v8::FunctionCallbackInfo<v8::Value> &args) {
2378
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2379
+ if (ptr == nullptr) {
2380
+ return;
2381
+ }
2382
+
2383
+ auto isolate = args.GetIsolate();
2384
+ auto context = isolate->GetCurrentContext();
2385
+
2386
+ auto count = args.Length();
2387
+ if (count == 11) {
2388
+ auto target = (uint32_t) args[0]->NumberValue(
2389
+ context).ToChecked();
2390
+ auto level = (int32_t) args[1]->NumberValue(
2391
+ context).ToChecked();
2392
+ auto xoffset = (int32_t) args[2]->NumberValue(
2393
+ context).ToChecked();
2394
+ auto yoffset = (int32_t) args[3]->NumberValue(
2395
+ context).ToChecked();
2396
+ auto zoffset = (int32_t) args[4]->NumberValue(
2397
+ context).ToChecked();
2398
+ auto width = (int32_t) args[5]->NumberValue(
2399
+ context).ToChecked();
2400
+ auto height = (int32_t) args[6]->NumberValue(
2401
+ context).ToChecked();
2402
+ auto depth = (int32_t) args[7]->NumberValue(
2403
+ context).ToChecked();
2404
+ auto format = (uint32_t) args[8]->NumberValue(
2405
+ context).ToChecked();
2406
+ auto type = (int32_t) args[9]->NumberValue(
2407
+ context).ToChecked();
2408
+
2409
+ if (args[10]->IsNumber()) {
2410
+ auto imageOrPixelsOrOffset = args[10]->NumberValue(
2411
+ context).ToChecked();
2412
+ canvas_native_webgl2_tex_sub_image3d_none(
2413
+ target,
2414
+ level,
2415
+ xoffset,
2416
+ yoffset,
2417
+ zoffset,
2418
+ width,
2419
+ height,
2420
+ depth,
2421
+ format,
2422
+ type,
2423
+ static_cast<ssize_t>(imageOrPixelsOrOffset),
2424
+ ptr->GetState()
2425
+ );
2426
+ return;
2427
+ }
2428
+
2429
+ auto imageOrPixelsOrOffsetObject = args[10];
2430
+
2431
+ if (imageOrPixelsOrOffsetObject->IsArrayBufferView()) {
2432
+ auto buf = imageOrPixelsOrOffsetObject.As<v8::ArrayBufferView>();
2433
+
2434
+ auto array = buf->Buffer();
2435
+ auto offset = buf->ByteOffset();
2436
+ auto size = buf->ByteLength();
2437
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2438
+ auto data = static_cast<uint8_t *>((void*) data_ptr);
2439
+
2440
+
2441
+
2442
+ canvas_native_webgl2_tex_sub_image3d(
2443
+ target,
2444
+ level,
2445
+ xoffset,
2446
+ yoffset,
2447
+ zoffset,
2448
+ width,
2449
+ height,
2450
+ depth,
2451
+ format,
2452
+ type,
2453
+ data, size,
2454
+ ptr->GetState()
2455
+ );
2456
+
2457
+ return;
2458
+ }
2459
+
2460
+
2461
+ auto imageType = GetNativeType(isolate, imageOrPixelsOrOffsetObject);
2462
+
2463
+ if (imageType == NativeType::ImageAsset) {
2464
+ auto asset = ImageAssetImpl::GetPointer(imageOrPixelsOrOffsetObject.As<v8::Object>());
2465
+ if (asset != nullptr) {
2466
+
2467
+ canvas_native_webgl2_tex_sub_image3d_asset(
2468
+ target,
2469
+ level,
2470
+ xoffset,
2471
+ yoffset,
2472
+ zoffset,
2473
+ width,
2474
+ height,
2475
+ depth,
2476
+ format,
2477
+ type,
2478
+ asset->GetImageAsset(),
2479
+ ptr->GetState()
2480
+ );
2481
+ }
2482
+ }
2483
+
2484
+ } else if (count > 11) {
2485
+ auto target = (uint32_t) args[0]->NumberValue(
2486
+ context).ToChecked();
2487
+ auto level = (int32_t) args[1]->NumberValue(
2488
+ context).ToChecked();
2489
+ auto xoffset = (int32_t) args[2]->NumberValue(
2490
+ context).ToChecked();
2491
+ auto yoffset = (int32_t) args[3]->NumberValue(
2492
+ context).ToChecked();
2493
+ auto zoffset = (int32_t) args[4]->NumberValue(
2494
+ context).ToChecked();
2495
+ auto width = (int32_t) args[5]->NumberValue(
2496
+ context).ToChecked();
2497
+ auto height = (int32_t) args[6]->NumberValue(
2498
+ context).ToChecked();
2499
+ auto depth = (int32_t) args[7]->NumberValue(
2500
+ context).ToChecked();
2501
+ auto format = (uint32_t) args[8]->NumberValue(
2502
+ context).ToChecked();
2503
+ auto type = (uint32_t) args[9]->NumberValue(
2504
+ context).ToChecked();
2505
+
2506
+ size_t srcOffsetValue = 0;
2507
+
2508
+ if (args[11]->IsNumber()) {
2509
+ srcOffsetValue = static_cast<size_t>(args[11]->NumberValue(
2510
+ context).ToChecked());
2511
+ }
2512
+
2513
+ auto imageOrPixelsOrOffsetObject = args[10];
2514
+
2515
+
2516
+ if (imageOrPixelsOrOffsetObject->IsArrayBufferView()) {
2517
+ auto buf = imageOrPixelsOrOffsetObject.As<v8::ArrayBufferView>();
2518
+
2519
+ auto array = buf->Buffer();
2520
+ auto offset = buf->ByteOffset();
2521
+ auto size = buf->ByteLength();
2522
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2523
+ auto data = static_cast<uint8_t *>((void*) data_ptr);
2524
+
2525
+
2526
+ srcOffsetValue =
2527
+ srcOffsetValue * size;
2528
+ if (srcOffsetValue > size) {
2529
+ return;
2530
+ }
2531
+
2532
+
2533
+ canvas_native_webgl2_tex_sub_image3d_offset(
2534
+ target,
2535
+ level,
2536
+ xoffset,
2537
+ yoffset,
2538
+ zoffset,
2539
+ width,
2540
+ height,
2541
+ depth,
2542
+ format,
2543
+ type,
2544
+ data, size,
2545
+ srcOffsetValue,
2546
+ ptr->GetState()
2547
+ );
2548
+ }
2549
+ }
2550
+ }
2551
+
2552
+ void
2553
+ WebGL2RenderingContext::TransformFeedbackVaryings(const v8::FunctionCallbackInfo<v8::Value> &args) {
2554
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2555
+ if (ptr == nullptr) {
2556
+ return;
2557
+ }
2558
+
2559
+ auto isolate = args.GetIsolate();
2560
+ auto context = isolate->GetCurrentContext();
2561
+
2562
+ auto programValue = args[0];
2563
+ auto type = GetNativeType(isolate, programValue);
2564
+ if (type == NativeType::WebGLProgram) {
2565
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2566
+ auto varyingsObject = args[1];
2567
+ auto bufferMode = (uint32_t) args[2]->NumberValue(
2568
+ context).ToChecked();
2569
+
2570
+ if (program != nullptr &&
2571
+ varyingsObject->IsArray()) {
2572
+ auto varyings = varyingsObject.As<v8::Array>();
2573
+ auto len = varyings->Length();
2574
+
2575
+
2576
+ std::vector<std::string> store;
2577
+ store.reserve(len);
2578
+
2579
+ for (int j = 0; j < len; ++j) {
2580
+ auto name = ConvertFromV8String(isolate, varyings->Get(
2581
+ context, j).ToLocalChecked());
2582
+
2583
+ store.push_back(name);
2584
+ }
2585
+
2586
+
2587
+ const char* cStrings[store.size()];
2588
+ for (size_t i = 0; i < store.size(); ++i) {
2589
+ cStrings[i] = store[i].c_str();
2590
+ }
2591
+
2592
+ canvas_native_webgl2_transform_feedback_varyings(
2593
+ program->GetProgram(),
2594
+ cStrings, store.size(),
2595
+ bufferMode,
2596
+ ptr->GetState()
2597
+ );
2598
+ }
2599
+ }
2600
+
2601
+ }
2602
+
2603
+ void WebGL2RenderingContext::Uniform1ui(const v8::FunctionCallbackInfo<v8::Value> &args) {
2604
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2605
+ if (ptr == nullptr) {
2606
+ return;
2607
+ }
2608
+
2609
+ auto isolate = args.GetIsolate();
2610
+ auto context = isolate->GetCurrentContext();
2611
+
2612
+ auto locationValue = args[0];
2613
+ auto type = GetNativeType(isolate, locationValue);
2614
+
2615
+ auto v0Value = args[1];
2616
+ if (type == NativeType::WebGLUniformLocation) {
2617
+
2618
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2619
+ auto v0 = (uint32_t) v0Value->NumberValue(
2620
+ context).ToChecked();
2621
+
2622
+ if (location != nullptr) {
2623
+ canvas_native_webgl2_uniform1ui(
2624
+ location->GetUniformLocation(),
2625
+ v0,
2626
+ ptr->GetState()
2627
+ );
2628
+ }
2629
+ }
2630
+
2631
+ }
2632
+
2633
+ void WebGL2RenderingContext::Uniform2ui(const v8::FunctionCallbackInfo<v8::Value> &args) {
2634
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2635
+ if (ptr == nullptr) {
2636
+ return;
2637
+ }
2638
+
2639
+ auto isolate = args.GetIsolate();
2640
+ auto context = isolate->GetCurrentContext();
2641
+
2642
+ auto locationValue = args[0];
2643
+ auto type = GetNativeType(isolate, locationValue);
2644
+
2645
+ if (type == NativeType::WebGLUniformLocation) {
2646
+
2647
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2648
+ auto v0 = (uint32_t) args[1]->NumberValue(
2649
+ context).ToChecked();
2650
+ auto v1 = (uint32_t) args[2]->NumberValue(
2651
+ context).ToChecked();
2652
+
2653
+ if (location != nullptr) {
2654
+ canvas_native_webgl2_uniform2ui(
2655
+ location->GetUniformLocation(),
2656
+ v0,
2657
+ v1,
2658
+ ptr->GetState()
2659
+ );
2660
+ }
2661
+ }
2662
+
2663
+ }
2664
+
2665
+ void WebGL2RenderingContext::Uniform3ui(const v8::FunctionCallbackInfo<v8::Value> &args) {
2666
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2667
+ if (ptr == nullptr) {
2668
+ return;
2669
+ }
2670
+
2671
+ auto isolate = args.GetIsolate();
2672
+ auto context = isolate->GetCurrentContext();
2673
+
2674
+ auto locationValue = args[0];
2675
+ auto type = GetNativeType(isolate, locationValue);
2676
+
2677
+ if (type == NativeType::WebGLUniformLocation) {
2678
+
2679
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2680
+ auto v0 = (uint32_t) args[1]->NumberValue(
2681
+ context).ToChecked();
2682
+
2683
+ auto v1 = (uint32_t) args[2]->NumberValue(
2684
+ context).ToChecked();
2685
+
2686
+ auto v2 = (uint32_t) args[3]->NumberValue(
2687
+ context).ToChecked();
2688
+
2689
+ if (location != nullptr) {
2690
+ canvas_native_webgl2_uniform3ui(
2691
+ location->GetUniformLocation(),
2692
+ v0,
2693
+ v1,
2694
+ v2,
2695
+ ptr->GetState()
2696
+ );
2697
+ }
2698
+ }
2699
+
2700
+ }
2701
+
2702
+ void WebGL2RenderingContext::Uniform4ui(const v8::FunctionCallbackInfo<v8::Value> &args) {
2703
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2704
+ if (ptr == nullptr) {
2705
+ return;
2706
+ }
2707
+
2708
+ auto isolate = args.GetIsolate();
2709
+ auto context = isolate->GetCurrentContext();
2710
+
2711
+ auto locationValue = args[0];
2712
+ auto type = GetNativeType(isolate, locationValue);
2713
+
2714
+ if (type == NativeType::WebGLUniformLocation) {
2715
+
2716
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2717
+ auto v0 = (uint32_t) args[1]->NumberValue(
2718
+ context).ToChecked();
2719
+
2720
+ auto v1 = (uint32_t) args[2]->NumberValue(
2721
+ context).ToChecked();
2722
+
2723
+ auto v2 = (uint32_t) args[3]->NumberValue(
2724
+ context).ToChecked();
2725
+ auto v3 = (uint32_t) args[4]->NumberValue(
2726
+ context).ToChecked();
2727
+
2728
+
2729
+ if (location != nullptr) {
2730
+ canvas_native_webgl2_uniform4ui(
2731
+ location->GetUniformLocation(),
2732
+ v0,
2733
+ v1,
2734
+ v2,
2735
+ v3,
2736
+ ptr->GetState()
2737
+ );
2738
+ }
2739
+ }
2740
+
2741
+ }
2742
+
2743
+ void WebGL2RenderingContext::Uniform1uiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
2744
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2745
+ if (ptr == nullptr) {
2746
+ return;
2747
+ }
2748
+
2749
+ auto isolate = args.GetIsolate();
2750
+ auto context = isolate->GetCurrentContext();
2751
+
2752
+
2753
+ auto locationValue = args[0];
2754
+ auto type = GetNativeType(isolate, locationValue);
2755
+
2756
+
2757
+ if (type == NativeType::WebGLUniformLocation) {
2758
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2759
+ auto dataValue = args[1];
2760
+ if (location != nullptr &&
2761
+ dataValue->IsUint32Array()) {
2762
+ auto buf = dataValue.As<v8::Uint32Array>();
2763
+ auto array = buf->Buffer();
2764
+ auto offset = buf->ByteOffset();
2765
+ auto size = buf->Length();
2766
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2767
+ auto data = static_cast<uint32_t *>((void*) data_ptr);
2768
+
2769
+
2770
+ canvas_native_webgl2_uniform1uiv(
2771
+ location->GetUniformLocation(),
2772
+ data, size,
2773
+ ptr->GetState()
2774
+ );
2775
+ } else {
2776
+ std::vector<uint32_t> buf;
2777
+ auto array = dataValue.As<v8::Array>();
2778
+ auto len = array->Length();
2779
+ buf.reserve(len);
2780
+ for (int i = 0; i < len; i++) {
2781
+ auto item = (uint32_t) array->Get(
2782
+ context,
2783
+ i).ToLocalChecked()->NumberValue(
2784
+ context).ToChecked();
2785
+ buf.push_back(item);
2786
+ }
2787
+
2788
+ canvas_native_webgl2_uniform1uiv(
2789
+ location->GetUniformLocation(),
2790
+ buf.data(), buf.size(),
2791
+ ptr->GetState()
2792
+ );
2793
+ }
2794
+
2795
+
2796
+ }
2797
+
2798
+ }
2799
+
2800
+ void WebGL2RenderingContext::Uniform2uiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
2801
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2802
+ if (ptr == nullptr) {
2803
+ return;
2804
+ }
2805
+
2806
+ auto isolate = args.GetIsolate();
2807
+ auto context = isolate->GetCurrentContext();
2808
+
2809
+
2810
+ auto locationValue = args[0];
2811
+ auto type = GetNativeType(isolate, locationValue);
2812
+
2813
+
2814
+ if (type == NativeType::WebGLUniformLocation) {
2815
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2816
+ auto dataValue = args[1];
2817
+ if (location != nullptr &&
2818
+ dataValue->IsUint32Array()) {
2819
+ auto buf = dataValue.As<v8::Uint32Array>();
2820
+ auto array = buf->Buffer();
2821
+ auto offset = buf->ByteOffset();
2822
+ auto size = buf->Length();
2823
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2824
+ auto data = static_cast<uint32_t *>((void*) data_ptr);
2825
+
2826
+
2827
+
2828
+ canvas_native_webgl2_uniform2uiv(
2829
+ location->GetUniformLocation(),
2830
+ data, size,
2831
+ ptr->GetState()
2832
+ );
2833
+ } else {
2834
+ std::vector<uint32_t> buf;
2835
+ auto array = dataValue.As<v8::Array>();
2836
+ auto len = array->Length();
2837
+ buf.reserve(len);
2838
+ for (int i = 0; i < len; i++) {
2839
+ auto item = (uint32_t) array->Get(
2840
+ context,
2841
+ i).ToLocalChecked()->NumberValue(
2842
+ context).ToChecked();
2843
+ buf.push_back(item);
2844
+ }
2845
+ canvas_native_webgl2_uniform2uiv(
2846
+ location->GetUniformLocation(),
2847
+ buf.data(), buf.size(),
2848
+ ptr->GetState()
2849
+ );
2850
+ }
2851
+
2852
+
2853
+ }
2854
+
2855
+ }
2856
+
2857
+ void WebGL2RenderingContext::Uniform3uiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
2858
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2859
+ if (ptr == nullptr) {
2860
+ return;
2861
+ }
2862
+
2863
+ auto isolate = args.GetIsolate();
2864
+ auto context = isolate->GetCurrentContext();
2865
+
2866
+
2867
+ auto locationValue = args[0];
2868
+ auto type = GetNativeType(isolate, locationValue);
2869
+
2870
+
2871
+ if (type == NativeType::WebGLUniformLocation) {
2872
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2873
+ auto dataValue = args[1];
2874
+ if (location != nullptr &&
2875
+ dataValue->IsUint32Array()) {
2876
+ auto buf = dataValue.As<v8::Uint32Array>();
2877
+
2878
+ auto array = buf->Buffer();
2879
+ auto offset = buf->ByteOffset();
2880
+ auto size = buf->Length();
2881
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2882
+ auto data = static_cast<uint32_t *>((void*) data_ptr);
2883
+
2884
+
2885
+ canvas_native_webgl2_uniform3uiv(
2886
+ location->GetUniformLocation(),
2887
+ data, size,
2888
+ ptr->GetState()
2889
+ );
2890
+ } else {
2891
+ std::vector<uint32_t> buf;
2892
+ auto array = dataValue.As<v8::Array>();
2893
+ auto len = array->Length();
2894
+ buf.reserve(len);
2895
+ for (int i = 0; i < len; i++) {
2896
+ auto item = (uint32_t) array->Get(
2897
+ context,
2898
+ i).ToLocalChecked()->NumberValue(
2899
+ context).ToChecked();
2900
+ buf.push_back(item);
2901
+ }
2902
+ canvas_native_webgl2_uniform3uiv(
2903
+ location->GetUniformLocation(),
2904
+ buf.data(), buf.size(),
2905
+ ptr->GetState()
2906
+ );
2907
+ }
2908
+
2909
+
2910
+ }
2911
+
2912
+ }
2913
+
2914
+ void WebGL2RenderingContext::Uniform4uiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
2915
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2916
+ if (ptr == nullptr) {
2917
+ return;
2918
+ }
2919
+
2920
+ auto isolate = args.GetIsolate();
2921
+ auto context = isolate->GetCurrentContext();
2922
+
2923
+
2924
+ auto locationValue = args[0];
2925
+ auto type = GetNativeType(isolate, locationValue);
2926
+
2927
+
2928
+ if (type == NativeType::WebGLUniformLocation) {
2929
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2930
+ auto dataValue = args[1];
2931
+ if (location != nullptr &&
2932
+ dataValue->IsUint32Array()) {
2933
+ auto buf = dataValue.As<v8::Uint32Array>();
2934
+
2935
+ auto array = buf->Buffer();
2936
+ auto offset = buf->ByteOffset();
2937
+ auto size = buf->Length();
2938
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2939
+ auto data = static_cast<uint32_t *>((void*) data_ptr);
2940
+
2941
+
2942
+ canvas_native_webgl2_uniform4uiv(
2943
+ location->GetUniformLocation(),
2944
+ data, size,
2945
+ ptr->GetState()
2946
+ );
2947
+ } else {
2948
+ std::vector<uint32_t> buf;
2949
+ auto array = dataValue.As<v8::Array>();
2950
+ auto len = array->Length();
2951
+ buf.reserve(len);
2952
+ for (int i = 0; i < len; i++) {
2953
+ auto item = (uint32_t) array->Get(
2954
+ context,
2955
+ i).ToLocalChecked()->NumberValue(
2956
+ context).ToChecked();
2957
+ buf.push_back(item);
2958
+ }
2959
+
2960
+ canvas_native_webgl2_uniform4uiv(
2961
+ location->GetUniformLocation(),
2962
+ buf.data(), buf.size(),
2963
+ ptr->GetState()
2964
+ );
2965
+ }
2966
+
2967
+ }
2968
+
2969
+ }
2970
+
2971
+ void WebGL2RenderingContext::UniformBlockBinding(const v8::FunctionCallbackInfo<v8::Value> &args) {
2972
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2973
+ if (ptr == nullptr) {
2974
+ return;
2975
+ }
2976
+
2977
+ auto isolate = args.GetIsolate();
2978
+ auto context = isolate->GetCurrentContext();
2979
+
2980
+
2981
+ auto programValue = args[0];
2982
+ auto type = GetNativeType(isolate, programValue);
2983
+ if (type == NativeType::WebGLProgram) {
2984
+
2985
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2986
+ auto uniformBlockIndex = args[1]->NumberValue(
2987
+ context).ToChecked();
2988
+ auto uniformBlockBinding = args[2]->NumberValue(
2989
+ context).ToChecked();
2990
+
2991
+ if (program != nullptr) {
2992
+ canvas_native_webgl2_uniform_block_binding(
2993
+ program->GetProgram(),
2994
+ (uint32_t) uniformBlockIndex,
2995
+ (uint32_t) uniformBlockBinding,
2996
+ ptr->GetState()
2997
+ );
2998
+ }
2999
+
3000
+ }
3001
+
3002
+ }
3003
+
3004
+ void WebGL2RenderingContext::UniformMatrix2x3fv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3005
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3006
+ if (ptr == nullptr) {
3007
+ return;
3008
+ }
3009
+
3010
+ auto isolate = args.GetIsolate();
3011
+ auto context = isolate->GetCurrentContext();
3012
+
3013
+
3014
+ auto locationValue = args[0];
3015
+ auto type = GetNativeType(isolate, locationValue);
3016
+ if (type == NativeType::WebGLUniformLocation) {
3017
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3018
+ auto transpose = args[1]->BooleanValue(isolate);
3019
+ auto dataValue = args[2];
3020
+
3021
+ if (dataValue->IsFloat32Array()) {
3022
+ auto buf = dataValue.As<v8::Float32Array>();
3023
+ auto array = buf->Buffer();
3024
+ auto offset = buf->ByteOffset();
3025
+ auto size = buf->Length();
3026
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3027
+ auto data = static_cast<float *>((void*) data_ptr);
3028
+
3029
+
3030
+ canvas_native_webgl2_uniform_matrix2x3fv(
3031
+ location->GetUniformLocation(),
3032
+ transpose,
3033
+ data, size,
3034
+ ptr->GetState()
3035
+ );
3036
+ } else if (dataValue->IsArray()) {
3037
+ std::vector<float> buf;
3038
+ auto array = dataValue.As<v8::Array>();
3039
+ auto len = array->Length();
3040
+ for (int i = 0; i < len; i++) {
3041
+ auto item = array->Get(
3042
+ context, i).ToLocalChecked();
3043
+ buf.push_back(
3044
+ static_cast<float>(item->NumberValue(
3045
+ context).ToChecked()));
3046
+ }
3047
+
3048
+
3049
+ canvas_native_webgl2_uniform_matrix2x3fv(
3050
+ location->GetUniformLocation(),
3051
+ transpose,
3052
+ buf.data(), buf.size(),
3053
+ ptr->GetState()
3054
+ );
3055
+ }
3056
+ }
3057
+
3058
+ }
3059
+
3060
+ void WebGL2RenderingContext::UniformMatrix2x4fv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3061
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3062
+ if (ptr == nullptr) {
3063
+ return;
3064
+ }
3065
+
3066
+ auto isolate = args.GetIsolate();
3067
+ auto context = isolate->GetCurrentContext();
3068
+
3069
+
3070
+ auto locationValue = args[0];
3071
+ auto type = GetNativeType(isolate, locationValue);
3072
+ if (type == NativeType::WebGLUniformLocation) {
3073
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3074
+ auto transpose = args[1]->BooleanValue(isolate);
3075
+ auto dataValue = args[2];
3076
+
3077
+ if (dataValue->IsFloat32Array()) {
3078
+ auto buf = dataValue.As<v8::Float32Array>();
3079
+
3080
+ auto array = buf->Buffer();
3081
+ auto offset = buf->ByteOffset();
3082
+ auto size = buf->Length();
3083
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3084
+ auto data = static_cast<float *>((void*) data_ptr);
3085
+
3086
+
3087
+ canvas_native_webgl2_uniform_matrix2x4fv(
3088
+ location->GetUniformLocation(),
3089
+ transpose,
3090
+ data, size,
3091
+ ptr->GetState()
3092
+ );
3093
+ } else if (dataValue->IsArray()) {
3094
+ std::vector<float> buf;
3095
+ auto array = dataValue.As<v8::Array>();
3096
+ auto len = array->Length();
3097
+ for (int i = 0; i < len; i++) {
3098
+ auto item = array->Get(
3099
+ context, i).ToLocalChecked();
3100
+ buf.push_back(
3101
+ static_cast<float>(item->NumberValue(
3102
+ context).ToChecked()));
3103
+ }
3104
+
3105
+
3106
+
3107
+ canvas_native_webgl2_uniform_matrix2x4fv(
3108
+ location->GetUniformLocation(),
3109
+ transpose,
3110
+ buf.data(), buf.size(),
3111
+ ptr->GetState()
3112
+ );
3113
+ }
3114
+ }
3115
+
3116
+ }
3117
+
3118
+ void WebGL2RenderingContext::UniformMatrix3x2fv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3119
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3120
+ if (ptr == nullptr) {
3121
+ return;
3122
+ }
3123
+
3124
+ auto isolate = args.GetIsolate();
3125
+ auto context = isolate->GetCurrentContext();
3126
+
3127
+
3128
+ auto locationValue = args[0];
3129
+ auto type = GetNativeType(isolate, locationValue);
3130
+ if (type == NativeType::WebGLUniformLocation) {
3131
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3132
+ auto transpose = args[1]->BooleanValue(isolate);
3133
+ auto dataValue = args[2];
3134
+
3135
+ if (dataValue->IsFloat32Array()) {
3136
+ auto buf = dataValue.As<v8::Float32Array>();
3137
+
3138
+
3139
+ auto array = buf->Buffer();
3140
+ auto offset = buf->ByteOffset();
3141
+ auto size = buf->Length();
3142
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3143
+ auto data = static_cast<float *>((void*) data_ptr);
3144
+
3145
+
3146
+ canvas_native_webgl2_uniform_matrix3x2fv(
3147
+ location->GetUniformLocation(),
3148
+ transpose,
3149
+ data, size,
3150
+ ptr->GetState()
3151
+ );
3152
+ } else if (dataValue->IsArray()) {
3153
+ std::vector<float> buf;
3154
+ auto array = dataValue.As<v8::Array>();
3155
+ auto len = array->Length();
3156
+ for (int i = 0; i < len; i++) {
3157
+ auto item = array->Get(
3158
+ context, i).ToLocalChecked();
3159
+ buf.push_back(
3160
+ static_cast<float>(item->NumberValue(
3161
+ context).ToChecked()));
3162
+ }
3163
+
3164
+
3165
+
3166
+ canvas_native_webgl2_uniform_matrix3x2fv(
3167
+ location->GetUniformLocation(),
3168
+ transpose,
3169
+ buf.data(), buf.size(),
3170
+ ptr->GetState()
3171
+ );
3172
+ }
3173
+ }
3174
+
3175
+ }
3176
+
3177
+ void WebGL2RenderingContext::UniformMatrix3x4fv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3178
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3179
+ if (ptr == nullptr) {
3180
+ return;
3181
+ }
3182
+
3183
+ auto isolate = args.GetIsolate();
3184
+ auto context = isolate->GetCurrentContext();
3185
+
3186
+
3187
+ auto locationValue = args[0];
3188
+ auto type = GetNativeType(isolate, locationValue);
3189
+ if (type == NativeType::WebGLUniformLocation) {
3190
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3191
+ auto transpose = args[1]->BooleanValue(isolate);
3192
+ auto dataValue = args[2];
3193
+
3194
+ if (dataValue->IsFloat32Array()) {
3195
+ auto buf = dataValue.As<v8::Float32Array>();
3196
+ auto array = buf->Buffer();
3197
+ auto offset = buf->ByteOffset();
3198
+ auto size = buf->Length();
3199
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3200
+ auto data = static_cast<float *>((void*) data_ptr);
3201
+
3202
+
3203
+ canvas_native_webgl2_uniform_matrix3x4fv(
3204
+ location->GetUniformLocation(),
3205
+ transpose,
3206
+ data, size,
3207
+ ptr->GetState()
3208
+ );
3209
+ } else if (dataValue->IsArray()) {
3210
+ std::vector<float> buf;
3211
+ auto array = dataValue.As<v8::Array>();
3212
+ auto len = array->Length();
3213
+ for (int i = 0; i < len; i++) {
3214
+ auto item = array->Get(
3215
+ context, i).ToLocalChecked();
3216
+ buf.push_back(
3217
+ static_cast<float>(item->NumberValue(
3218
+ context).ToChecked()));
3219
+ }
3220
+
3221
+
3222
+
3223
+ canvas_native_webgl2_uniform_matrix3x4fv(
3224
+ location->GetUniformLocation(),
3225
+ transpose,
3226
+ buf.data(), buf.size(),
3227
+ ptr->GetState()
3228
+ );
3229
+ }
3230
+ }
3231
+
3232
+ }
3233
+
3234
+ void WebGL2RenderingContext::UniformMatrix4x2fv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3235
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3236
+ if (ptr == nullptr) {
3237
+ return;
3238
+ }
3239
+
3240
+ auto isolate = args.GetIsolate();
3241
+ auto context = isolate->GetCurrentContext();
3242
+
3243
+
3244
+ auto locationValue = args[0];
3245
+ auto type = GetNativeType(isolate, locationValue);
3246
+ if (type == NativeType::WebGLUniformLocation) {
3247
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3248
+ auto transpose = args[1]->BooleanValue(isolate);
3249
+ auto dataValue = args[2];
3250
+
3251
+ if (dataValue->IsFloat32Array()) {
3252
+ auto buf = dataValue.As<v8::Float32Array>();
3253
+
3254
+ auto array = buf->Buffer();
3255
+ auto offset = buf->ByteOffset();
3256
+ auto size = buf->Length();
3257
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3258
+ auto data = static_cast<float *>((void*) data_ptr);
3259
+
3260
+ canvas_native_webgl2_uniform_matrix4x2fv(
3261
+ location->GetUniformLocation(),
3262
+ transpose,
3263
+ data, size,
3264
+ ptr->GetState()
3265
+ );
3266
+ } else if (dataValue->IsArray()) {
3267
+ std::vector<float> buf;
3268
+ auto array = dataValue.As<v8::Array>();
3269
+ auto len = array->Length();
3270
+ for (int i = 0; i < len; i++) {
3271
+ auto item = array->Get(
3272
+ context, i).ToLocalChecked();
3273
+ buf.push_back(
3274
+ static_cast<float>(item->NumberValue(
3275
+ context).ToChecked()));
3276
+ }
3277
+
3278
+
3279
+
3280
+ canvas_native_webgl2_uniform_matrix4x2fv(
3281
+ location->GetUniformLocation(),
3282
+ transpose,
3283
+ buf.data(), buf.size(),
3284
+ ptr->GetState()
3285
+ );
3286
+ }
3287
+ }
3288
+
3289
+ }
3290
+
3291
+ void WebGL2RenderingContext::UniformMatrix4x3fv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3292
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3293
+ if (ptr == nullptr) {
3294
+ return;
3295
+ }
3296
+
3297
+ auto isolate = args.GetIsolate();
3298
+ auto context = isolate->GetCurrentContext();
3299
+
3300
+
3301
+ auto locationValue = args[0];
3302
+ auto type = GetNativeType(isolate, locationValue);
3303
+ if (type == NativeType::WebGLUniformLocation) {
3304
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3305
+ auto transpose = args[1]->BooleanValue(isolate);
3306
+ auto dataValue = args[2];
3307
+
3308
+ if (dataValue->IsFloat32Array()) {
3309
+ auto buf = dataValue.As<v8::Float32Array>();
3310
+ auto array = buf->Buffer();
3311
+ auto offset = buf->ByteOffset();
3312
+ auto size = buf->Length();
3313
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3314
+ auto data = static_cast<float *>((void*) data_ptr);
3315
+
3316
+ canvas_native_webgl2_uniform_matrix4x3fv(
3317
+ location->GetUniformLocation(),
3318
+ transpose,
3319
+ data, size,
3320
+ ptr->GetState()
3321
+ );
3322
+ } else if (dataValue->IsArray()) {
3323
+ std::vector<float> buf;
3324
+ auto array = dataValue.As<v8::Array>();
3325
+ auto len = array->Length();
3326
+ for (int i = 0; i < len; i++) {
3327
+ auto item = array->Get(
3328
+ context, i).ToLocalChecked();
3329
+ buf.push_back(
3330
+ static_cast<float>(item->NumberValue(
3331
+ context).ToChecked()));
3332
+ }
3333
+
3334
+
3335
+ canvas_native_webgl2_uniform_matrix4x3fv(
3336
+ location->GetUniformLocation(),
3337
+ transpose,
3338
+ buf.data(), buf.size(),
3339
+ ptr->GetState()
3340
+ );
3341
+ }
3342
+ }
3343
+
3344
+ }
3345
+
3346
+ void WebGL2RenderingContext::VertexAttribDivisor(const v8::FunctionCallbackInfo<v8::Value> &args) {
3347
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3348
+ if (ptr == nullptr) {
3349
+ return;
3350
+ }
3351
+
3352
+ auto isolate = args.GetIsolate();
3353
+ auto context = isolate->GetCurrentContext();
3354
+
3355
+
3356
+ auto index = args[0]->NumberValue(
3357
+ context).ToChecked();
3358
+ auto divisor = args[1]->NumberValue(
3359
+ context).ToChecked();
3360
+ canvas_native_webgl2_vertex_attrib_divisor(
3361
+ (uint32_t) index,
3362
+ (uint32_t) divisor,
3363
+ ptr->GetState()
3364
+ );
3365
+
3366
+ }
3367
+
3368
+ void WebGL2RenderingContext::VertexAttribI4i(const v8::FunctionCallbackInfo<v8::Value> &args) {
3369
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3370
+ if (ptr == nullptr) {
3371
+ return;
3372
+ }
3373
+
3374
+ auto isolate = args.GetIsolate();
3375
+ auto context = isolate->GetCurrentContext();
3376
+
3377
+
3378
+ auto index = args[0]->NumberValue(
3379
+ context).ToChecked();
3380
+ auto v0 = args[1]->NumberValue(
3381
+ context).ToChecked();
3382
+ auto v1 = args[2]->NumberValue(
3383
+ context).ToChecked();
3384
+ auto v2 = args[3]->NumberValue(
3385
+ context).ToChecked();
3386
+ auto v3 = args[4]->NumberValue(
3387
+ context).ToChecked();
3388
+ canvas_native_webgl2_vertex_attrib_i4i(
3389
+ (uint32_t) index,
3390
+ (int32_t) v0,
3391
+ (int32_t) v1,
3392
+ (int32_t) v2,
3393
+ (int32_t) v3,
3394
+ ptr->GetState()
3395
+ );
3396
+
3397
+ }
3398
+
3399
+ void WebGL2RenderingContext::VertexAttribI4iv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3400
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3401
+ if (ptr == nullptr) {
3402
+ return;
3403
+ }
3404
+
3405
+ auto isolate = args.GetIsolate();
3406
+ auto context = isolate->GetCurrentContext();
3407
+
3408
+
3409
+ auto index = (uint32_t) args[0]->NumberValue(
3410
+ context).ToChecked();
3411
+ auto value = args[1];
3412
+ if (value->IsInt32Array()) {
3413
+ auto buf = value.As<v8::Int32Array>();
3414
+
3415
+ auto array = buf->Buffer();
3416
+ auto offset = buf->ByteOffset();
3417
+ auto size = buf->Length();
3418
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3419
+ auto data = static_cast<int32_t *>((void*) data_ptr);
3420
+
3421
+
3422
+ canvas_native_webgl2_vertex_attrib_i4iv(
3423
+ index,
3424
+ data, size,
3425
+ ptr->GetState()
3426
+ );
3427
+ } else if (value->IsArray()) {
3428
+ auto array = value.As<v8::Array>();
3429
+ auto len = array->Length();
3430
+ std::vector<int32_t> buf;
3431
+ buf.reserve(len);
3432
+ for (int i = 0; i < len; i++) {
3433
+ auto item = (int32_t) array->Get(
3434
+ context,
3435
+ i).ToLocalChecked()->NumberValue(
3436
+ context).ToChecked();
3437
+ buf.push_back(item);
3438
+ }
3439
+
3440
+
3441
+ canvas_native_webgl2_vertex_attrib_i4iv(
3442
+ index,
3443
+ buf.data(), buf.size(),
3444
+ ptr->GetState()
3445
+ );
3446
+ }
3447
+
3448
+ }
3449
+
3450
+ void WebGL2RenderingContext::VertexAttribI4ui(const v8::FunctionCallbackInfo<v8::Value> &args) {
3451
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3452
+ if (ptr == nullptr) {
3453
+ return;
3454
+ }
3455
+
3456
+ auto isolate = args.GetIsolate();
3457
+ auto context = isolate->GetCurrentContext();
3458
+
3459
+
3460
+ auto index = (uint32_t) args[0]->NumberValue(
3461
+ context).ToChecked();
3462
+ auto v0 = (uint32_t) args[1]->NumberValue(
3463
+ context).ToChecked();
3464
+ auto v1 = (uint32_t) args[2]->NumberValue(
3465
+ context).ToChecked();
3466
+ auto v2 = (uint32_t) args[3]->NumberValue(
3467
+ context).ToChecked();
3468
+ auto v3 = (uint32_t) args[4]->NumberValue(
3469
+ context).ToChecked();
3470
+
3471
+ canvas_native_webgl2_vertex_attrib_i4ui(
3472
+ index,
3473
+ v0,
3474
+ v1,
3475
+ v2,
3476
+ v3,
3477
+ ptr->GetState()
3478
+ );
3479
+
3480
+ }
3481
+
3482
+ void WebGL2RenderingContext::VertexAttribI4uiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3483
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3484
+ if (ptr == nullptr) {
3485
+ return;
3486
+ }
3487
+
3488
+ auto isolate = args.GetIsolate();
3489
+ auto context = isolate->GetCurrentContext();
3490
+
3491
+ auto index = (uint32_t) args[0]->NumberValue(
3492
+ context).ToChecked();
3493
+ auto value = args[1];
3494
+ if (value->IsUint32Array()) {
3495
+ auto buf = value.As<v8::Uint32Array>();
3496
+ auto array = buf->Buffer();
3497
+ auto offset = buf->ByteOffset();
3498
+ auto size = buf->Length();
3499
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3500
+ auto data = static_cast<uint32_t *>((void*) data_ptr);
3501
+
3502
+
3503
+ canvas_native_webgl2_vertex_attrib_i4uiv(
3504
+ index,
3505
+ data, size,
3506
+ ptr->GetState()
3507
+ );
3508
+ } else if (value->IsArray()) {
3509
+ auto array = value.As<v8::Array>();
3510
+ auto len = array->Length();
3511
+ std::vector<uint32_t> buf;
3512
+ buf.reserve(len);
3513
+ for (int i = 0; i < len; i++) {
3514
+ auto item = (uint32_t) array->Get(
3515
+ context,
3516
+ i).ToLocalChecked()->NumberValue(
3517
+ context).ToChecked();
3518
+ buf.push_back(item);
3519
+ }
3520
+
3521
+
3522
+ canvas_native_webgl2_vertex_attrib_i4uiv(
3523
+ index,
3524
+ buf.data(), buf.size(),
3525
+ ptr->GetState()
3526
+ );
3527
+ }
3528
+
3529
+ }
3530
+
3531
+ void WebGL2RenderingContext::SetConstants(v8::Isolate *isolate,
3532
+ const v8::Local<v8::ObjectTemplate> &tmpl) {
3533
+ /* Getting GL parameter information */
3534
+
3535
+ tmpl->Set(isolate, "READ_BUFFER", v8::Uint32::New(isolate, 0x0C02));
3536
+
3537
+ tmpl->Set(isolate, "UNPACK_ROW_LENGTH", v8::Uint32::New(isolate, 0x0CF2));
3538
+
3539
+ tmpl->Set(isolate, "UNPACK_SKIP_ROWS", v8::Uint32::New(isolate, 0x0CF3));
3540
+
3541
+ tmpl->Set(isolate, "UNPACK_SKIP_PIXELS", v8::Uint32::New(isolate, 0x0CF4));
3542
+
3543
+ tmpl->Set(isolate, "PACK_ROW_LENGTH", v8::Uint32::New(isolate, 0x0D02));
3544
+
3545
+ tmpl->Set(isolate, "PACK_SKIP_ROWS", v8::Uint32::New(isolate, 0x0D03));
3546
+
3547
+ tmpl->Set(isolate, "PACK_SKIP_PIXELS", v8::Uint32::New(isolate, 0x0D04));
3548
+
3549
+ tmpl->Set(isolate, "TEXTURE_BINDING_3D", v8::Uint32::New(isolate, 0x806A));
3550
+
3551
+ tmpl->Set(isolate, "UNPACK_SKIP_IMAGES", v8::Uint32::New(isolate, 0x806D));
3552
+
3553
+ tmpl->Set(isolate, "UNPACK_IMAGE_HEIGHT", v8::Uint32::New(isolate, 0x806E));
3554
+
3555
+ tmpl->Set(isolate, "MAX_3D_TEXTURE_SIZE", v8::Uint32::New(isolate, 0x8073));
3556
+
3557
+ tmpl->Set(isolate, "MAX_ELEMENTS_VERTICES", v8::Uint32::New(isolate, 0x80E8));
3558
+
3559
+ tmpl->Set(isolate, "MAX_ELEMENTS_INDICES", v8::Uint32::New(isolate, 0x80E9));
3560
+
3561
+ tmpl->Set(isolate, "MAX_TEXTURE_LOD_BIAS", v8::Uint32::New(isolate, 0x84FD));
3562
+
3563
+ tmpl->Set(isolate, "MAX_FRAGMENT_UNIFORM_COMPONENTS", v8::Uint32::New(isolate, 0x8B49));
3564
+
3565
+ tmpl->Set(isolate, "MAX_VERTEX_UNIFORM_COMPONENTS", v8::Uint32::New(isolate, 0x8B4A));
3566
+
3567
+ tmpl->Set(isolate, "MAX_ARRAY_TEXTURE_LAYERS", v8::Uint32::New(isolate, 0x88FF));
3568
+
3569
+ tmpl->Set(isolate, "MIN_PROGRAM_TEXEL_OFFSET", v8::Uint32::New(isolate, 0x8904));
3570
+
3571
+ tmpl->Set(isolate, "MAX_PROGRAM_TEXEL_OFFSET", v8::Uint32::New(isolate, 0x8905));
3572
+
3573
+ tmpl->Set(isolate, "MAX_VARYING_COMPONENTS", v8::Uint32::New(isolate, 0x8B4B));
3574
+
3575
+ tmpl->Set(isolate, "FRAGMENT_SHADER_DERIVATIVE_HINT", v8::Uint32::New(isolate, 0x8B8B));
3576
+
3577
+ tmpl->Set(isolate, "RASTERIZER_DISCARD", v8::Uint32::New(isolate, 0x8C89));
3578
+
3579
+ tmpl->Set(isolate, "VERTEX_ARRAY_BINDING", v8::Uint32::New(isolate, 0x85B5));
3580
+ tmpl->Set(isolate, "MAX_VERTEX_OUTPUT_COMPONENTS", v8::Uint32::New(isolate, 0x9122));
3581
+ tmpl->Set(isolate, "MAX_FRAGMENT_INPUT_COMPONENTS", v8::Uint32::New(isolate, 0x9125));
3582
+ tmpl->Set(isolate, "MAX_SERVER_WAIT_TIMEOUT", v8::Uint32::New(isolate, 0x9111));
3583
+ tmpl->Set(isolate, "MAX_ELEMENT_INDEX", v8::Uint32::New(isolate, 0x8D6B));
3584
+
3585
+ tmpl->Set(isolate, "RED", v8::Uint32::New(isolate, 0x1903));
3586
+ tmpl->Set(isolate, "RGB8", v8::Uint32::New(isolate, 0x8051));
3587
+ tmpl->Set(isolate, "RGBA8", v8::Uint32::New(isolate, 0x8058));
3588
+ tmpl->Set(isolate, "RGB10_A2", v8::Uint32::New(isolate, 0x8059));
3589
+ tmpl->Set(isolate, "TEXTURE_3D", v8::Uint32::New(isolate, 0x806F));
3590
+
3591
+ tmpl->Set(isolate, "TEXTURE_WRAP_R", v8::Uint32::New(isolate, 0x8072));
3592
+ tmpl->Set(isolate, "TEXTURE_MIN_LOD", v8::Uint32::New(isolate, 0x813A));
3593
+ tmpl->Set(isolate, "TEXTURE_MAX_LOD", v8::Uint32::New(isolate, 0x813B));
3594
+ tmpl->Set(isolate, "TEXTURE_BASE_LEVEL", v8::Uint32::New(isolate, 0x813C));
3595
+ tmpl->Set(isolate, "TEXTURE_MAX_LEVEL", v8::Uint32::New(isolate, 0x813D));
3596
+
3597
+
3598
+ tmpl->Set(isolate, "TEXTURE_COMPARE_MODE", v8::Uint32::New(isolate, 0x884C));
3599
+ tmpl->Set(isolate, "TEXTURE_COMPARE_FUNC", v8::Uint32::New(isolate, 0x884D));
3600
+ tmpl->Set(isolate, "SRGB", v8::Uint32::New(isolate, 0x8C40));
3601
+ tmpl->Set(isolate, "SRGB8", v8::Uint32::New(isolate, 0x8C41));
3602
+ tmpl->Set(isolate, "SRGB8_ALPHA8", v8::Uint32::New(isolate, 0x8C43));
3603
+
3604
+ tmpl->Set(isolate, "COMPARE_REF_TO_TEXTURE", v8::Uint32::New(isolate, 0x884E));
3605
+ tmpl->Set(isolate, "RGBA32F", v8::Uint32::New(isolate, 0x8814));
3606
+ tmpl->Set(isolate, "RGB32F", v8::Uint32::New(isolate, 0x8815));
3607
+ tmpl->Set(isolate, "RGBA16F", v8::Uint32::New(isolate, 0x881A));
3608
+ tmpl->Set(isolate, "RGB16F", v8::Uint32::New(isolate, 0x881B));
3609
+
3610
+ tmpl->Set(isolate, "TEXTURE_2D_ARRAY", v8::Uint32::New(isolate, 0x8C1A));
3611
+ tmpl->Set(isolate, "TEXTURE_BINDING_2D_ARRAY", v8::Uint32::New(isolate, 0x8C1D));
3612
+ tmpl->Set(isolate, "R11F_G11F_B10F", v8::Uint32::New(isolate, 0x8C3A));
3613
+ tmpl->Set(isolate, "RGB9_E5", v8::Uint32::New(isolate, 0x8C3D));
3614
+ tmpl->Set(isolate, "RGBA32UI", v8::Uint32::New(isolate, 0x8D70));
3615
+
3616
+
3617
+ tmpl->Set(isolate, "RGB32UI", v8::Uint32::New(isolate, 0x8D71));
3618
+ tmpl->Set(isolate, "RGBA16UI", v8::Uint32::New(isolate, 0x8D76));
3619
+ tmpl->Set(isolate, "RGB16UI", v8::Uint32::New(isolate, 0x8D77));
3620
+ tmpl->Set(isolate, "RGBA8UI", v8::Uint32::New(isolate, 0x8D7C));
3621
+ tmpl->Set(isolate, "RGB8UI", v8::Uint32::New(isolate, 0x8D7D));
3622
+
3623
+
3624
+ tmpl->Set(isolate, "RGBA32I", v8::Uint32::New(isolate, 0x8D82));
3625
+ tmpl->Set(isolate, "RGB32I", v8::Uint32::New(isolate, 0x8D83));
3626
+ tmpl->Set(isolate, "RGBA16I", v8::Uint32::New(isolate, 0x8D88));
3627
+ tmpl->Set(isolate, "RGB16I", v8::Uint32::New(isolate, 0x8D89));
3628
+ tmpl->Set(isolate, "RGBA8I", v8::Uint32::New(isolate, 0x8D8E));
3629
+
3630
+
3631
+ tmpl->Set(isolate, "RGB8I", v8::Uint32::New(isolate, 0x8D8F));
3632
+ tmpl->Set(isolate, "RED_INTEGER", v8::Uint32::New(isolate, 0x8D94));
3633
+ tmpl->Set(isolate, "RGB_INTEGER", v8::Uint32::New(isolate, 0x8D98));
3634
+ tmpl->Set(isolate, "RGBA_INTEGER", v8::Uint32::New(isolate, 0x8D99));
3635
+ tmpl->Set(isolate, "R8", v8::Uint32::New(isolate, 0x8229));
3636
+
3637
+
3638
+ tmpl->Set(isolate, "RG8", v8::Uint32::New(isolate, 0x822B));
3639
+ tmpl->Set(isolate, "R16F", v8::Uint32::New(isolate, 0x822D));
3640
+ tmpl->Set(isolate, "R32F", v8::Uint32::New(isolate, 0x822E));
3641
+ tmpl->Set(isolate, "RG16F", v8::Uint32::New(isolate, 0x822F));
3642
+ tmpl->Set(isolate, "RG32F", v8::Uint32::New(isolate, 0x8230));
3643
+
3644
+
3645
+ tmpl->Set(isolate, "R8I", v8::Uint32::New(isolate, 0x8231));
3646
+ tmpl->Set(isolate, "R8UI", v8::Uint32::New(isolate, 0x8232));
3647
+ tmpl->Set(isolate, "R16I", v8::Uint32::New(isolate, 0x8233));
3648
+ tmpl->Set(isolate, "R16UI", v8::Uint32::New(isolate, 0x8234));
3649
+ tmpl->Set(isolate, "R32I", v8::Uint32::New(isolate, 0x8235));
3650
+
3651
+
3652
+ tmpl->Set(isolate, "R32UI", v8::Uint32::New(isolate, 0x8236));
3653
+ tmpl->Set(isolate, "RG8I", v8::Uint32::New(isolate, 0x8237));
3654
+ tmpl->Set(isolate, "RG8UI", v8::Uint32::New(isolate, 0x8238));
3655
+ tmpl->Set(isolate, "RG16I", v8::Uint32::New(isolate, 0x8239));
3656
+ tmpl->Set(isolate, "RG16UI", v8::Uint32::New(isolate, 0x823A));
3657
+
3658
+ tmpl->Set(isolate, "RG32I", v8::Uint32::New(isolate, 0x823B));
3659
+ tmpl->Set(isolate, "RG32UI", v8::Uint32::New(isolate, 0x823C));
3660
+ tmpl->Set(isolate, "R8_SNORM", v8::Uint32::New(isolate, 0x8F94));
3661
+ tmpl->Set(isolate, "RG8_SNORM", v8::Uint32::New(isolate, 0x8F95));
3662
+ tmpl->Set(isolate, "RGB8_SNORM", v8::Uint32::New(isolate, 0x8F96));
3663
+
3664
+
3665
+ tmpl->Set(isolate, "RGBA8_SNORM", v8::Uint32::New(isolate, 0x8F97));
3666
+ tmpl->Set(isolate, "RGB10_A2UI", v8::Uint32::New(isolate, 0x906F));
3667
+ tmpl->Set(isolate, "TEXTURE_IMMUTABLE_FORMAT", v8::Uint32::New(isolate, 0x912F));
3668
+ tmpl->Set(isolate, "TEXTURE_IMMUTABLE_LEVELS", v8::Uint32::New(isolate, 0x82DF));
3669
+ tmpl->Set(isolate, "UNSIGNED_INT_2_10_10_10_REV", v8::Uint32::New(isolate, 0x8368));
3670
+
3671
+
3672
+ tmpl->Set(isolate, "UNSIGNED_INT_10F_11F_11F_REV", v8::Uint32::New(isolate, 0x8C3B));
3673
+ tmpl->Set(isolate, "UNSIGNED_INT_5_9_9_9_REV", v8::Uint32::New(isolate, 0x8C3E));
3674
+ tmpl->Set(isolate, "FLOAT_32_UNSIGNED_INT_24_8_REV", v8::Uint32::New(isolate, 0x8DAD));
3675
+ tmpl->Set(isolate, "UNSIGNED_INT_24_8", v8::Uint32::New(isolate, 0x84FA));
3676
+ tmpl->Set(isolate, "HALF_FLOAT", v8::Uint32::New(isolate, 0x140B));
3677
+
3678
+
3679
+ tmpl->Set(isolate, "RG", v8::Uint32::New(isolate, 0x8227));
3680
+ tmpl->Set(isolate, "RG_INTEGER", v8::Uint32::New(isolate, 0x8228));
3681
+ tmpl->Set(isolate, "INT_2_10_10_10_REV", v8::Uint32::New(isolate, 0x8D9F));
3682
+ tmpl->Set(isolate, "QUERY_RESULT_AVAILABLE", v8::Uint32::New(isolate, 0x8865));
3683
+ tmpl->Set(isolate, "QUERY_RESULT", v8::Uint32::New(isolate, 0x8866));
3684
+
3685
+
3686
+ tmpl->Set(isolate, "CURRENT_QUERY", v8::Uint32::New(isolate, 0x8867));
3687
+ tmpl->Set(isolate, "ANY_SAMPLES_PASSED", v8::Uint32::New(isolate, 0x8C2F));
3688
+ tmpl->Set(isolate, "ANY_SAMPLES_PASSED_CONSERVATIVE", v8::Uint32::New(isolate, 0x8D6A));
3689
+ tmpl->Set(isolate, "MAX_DRAW_BUFFERS", v8::Uint32::New(isolate, 0x8824));
3690
+
3691
+ tmpl->Set(isolate, "DRAW_BUFFER0", v8::Uint32::New(isolate, 0x8825));
3692
+ tmpl->Set(isolate, "DRAW_BUFFER1", v8::Uint32::New(isolate, 0x8826));
3693
+ tmpl->Set(isolate, "DRAW_BUFFER2", v8::Uint32::New(isolate, 0x8827));
3694
+ tmpl->Set(isolate, "DRAW_BUFFER3", v8::Uint32::New(isolate, 0x8828));
3695
+ tmpl->Set(isolate, "DRAW_BUFFER4", v8::Uint32::New(isolate, 0x8829));
3696
+ tmpl->Set(isolate, "DRAW_BUFFER5", v8::Uint32::New(isolate, 0x882A));
3697
+ tmpl->Set(isolate, "DRAW_BUFFER6", v8::Uint32::New(isolate, 0x882B));
3698
+ tmpl->Set(isolate, "DRAW_BUFFER7", v8::Uint32::New(isolate, 0x882C));
3699
+ tmpl->Set(isolate, "DRAW_BUFFER8", v8::Uint32::New(isolate, 0x882D));
3700
+ tmpl->Set(isolate, "DRAW_BUFFER9", v8::Uint32::New(isolate, 0x882E));
3701
+ tmpl->Set(isolate, "DRAW_BUFFER10", v8::Uint32::New(isolate, 0x882F));
3702
+
3703
+ /* Getting GL parameter information */
3704
+
3705
+ /* Textures */
3706
+
3707
+ tmpl->Set(isolate, "DRAW_BUFFER11", v8::Uint32::New(isolate, 0x8830));
3708
+ tmpl->Set(isolate, "DRAW_BUFFER12", v8::Uint32::New(isolate, 0x8831));
3709
+ tmpl->Set(isolate, "DRAW_BUFFER13", v8::Uint32::New(isolate, 0x8832));
3710
+ tmpl->Set(isolate, "DRAW_BUFFER14", v8::Uint32::New(isolate, 0x8833));
3711
+ tmpl->Set(isolate, "DRAW_BUFFER15", v8::Uint32::New(isolate, 0x8834));
3712
+
3713
+ tmpl->Set(isolate, "MAX_COLOR_ATTACHMENTS", v8::Uint32::New(isolate, 0x8CDF));
3714
+ tmpl->Set(isolate, "COLOR_ATTACHMENT1", v8::Uint32::New(isolate, 0x8CE1));
3715
+ tmpl->Set(isolate, "COLOR_ATTACHMENT2", v8::Uint32::New(isolate, 0x8CE2));
3716
+ tmpl->Set(isolate, "COLOR_ATTACHMENT3", v8::Uint32::New(isolate, 0x8CE3));
3717
+ tmpl->Set(isolate, "COLOR_ATTACHMENT4", v8::Uint32::New(isolate, 0x8CE4));
3718
+ tmpl->Set(isolate, "COLOR_ATTACHMENT5", v8::Uint32::New(isolate, 0x8CE5));
3719
+ tmpl->Set(isolate, "COLOR_ATTACHMENT6", v8::Uint32::New(isolate, 0x8CE6));
3720
+ tmpl->Set(isolate, "COLOR_ATTACHMENT7", v8::Uint32::New(isolate, 0x8CE7));
3721
+ tmpl->Set(isolate, "COLOR_ATTACHMENT8", v8::Uint32::New(isolate, 0x8CE8));
3722
+ tmpl->Set(isolate, "COLOR_ATTACHMENT9", v8::Uint32::New(isolate, 0x8CE9));
3723
+ tmpl->Set(isolate, "COLOR_ATTACHMENT10", v8::Uint32::New(isolate, 0x8CEA));
3724
+ tmpl->Set(isolate, "COLOR_ATTACHMENT11", v8::Uint32::New(isolate, 0x8CEB));
3725
+ tmpl->Set(isolate, "COLOR_ATTACHMENT12", v8::Uint32::New(isolate, 0x8CEC));
3726
+ tmpl->Set(isolate, "COLOR_ATTACHMENT13", v8::Uint32::New(isolate, 0x8CED));
3727
+ tmpl->Set(isolate, "COLOR_ATTACHMENT14", v8::Uint32::New(isolate, 0x8CEE));
3728
+ tmpl->Set(isolate, "COLOR_ATTACHMENT15", v8::Uint32::New(isolate, 0x8CEF));
3729
+
3730
+ tmpl->Set(isolate, "SAMPLER_3D", v8::Uint32::New(isolate, 0x8B5F));
3731
+ tmpl->Set(isolate, "SAMPLER_2D_SHADOW", v8::Uint32::New(isolate, 0x8B62));
3732
+ tmpl->Set(isolate, "SAMPLER_2D_ARRAY", v8::Uint32::New(isolate, 0x8DC1));
3733
+ tmpl->Set(isolate, "SAMPLER_2D_ARRAY_SHADOW", v8::Uint32::New(isolate, 0x8DC4));
3734
+ tmpl->Set(isolate, "SAMPLER_CUBE_SHADOW", v8::Uint32::New(isolate, 0x8DC5));
3735
+
3736
+ tmpl->Set(isolate, "INT_SAMPLER_2D", v8::Uint32::New(isolate, 0x8DCA));
3737
+ tmpl->Set(isolate, "INT_SAMPLER_3D", v8::Uint32::New(isolate, 0x8DCB));
3738
+ tmpl->Set(isolate, "INT_SAMPLER_CUBE", v8::Uint32::New(isolate, 0x8DCC));
3739
+ tmpl->Set(isolate, "INT_SAMPLER_2D_ARRAY", v8::Uint32::New(isolate, 0x8DCF));
3740
+ tmpl->Set(isolate, "UNSIGNED_INT_SAMPLER_2D", v8::Uint32::New(isolate, 0x8DD2));
3741
+
3742
+ tmpl->Set(isolate, "UNSIGNED_INT_SAMPLER_3D", v8::Uint32::New(isolate, 0x8DD3));
3743
+ tmpl->Set(isolate, "UNSIGNED_INT_SAMPLER_CUBE", v8::Uint32::New(isolate, 0x8DD4));
3744
+ tmpl->Set(isolate, "UNSIGNED_INT_SAMPLER_2D_ARRAY", v8::Uint32::New(isolate, 0x8DD7));
3745
+ tmpl->Set(isolate, "MAX_SAMPLES", v8::Uint32::New(isolate, 0x8D57));
3746
+ tmpl->Set(isolate, "SAMPLER_BINDING", v8::Uint32::New(isolate, 0x8919));
3747
+
3748
+ tmpl->Set(isolate, "PIXEL_PACK_BUFFER", v8::Uint32::New(isolate, 0x88EB));
3749
+ tmpl->Set(isolate, "PIXEL_UNPACK_BUFFER", v8::Uint32::New(isolate, 0x88EC));
3750
+ tmpl->Set(isolate, "PIXEL_PACK_BUFFER_BINDING", v8::Uint32::New(isolate, 0x88ED));
3751
+ tmpl->Set(isolate, "PIXEL_UNPACK_BUFFER_BINDING", v8::Uint32::New(isolate, 0x88EF));
3752
+ tmpl->Set(isolate, "COPY_READ_BUFFER", v8::Uint32::New(isolate, 0x8F36));
3753
+
3754
+ tmpl->Set(isolate, "COPY_WRITE_BUFFER", v8::Uint32::New(isolate, 0x8F37));
3755
+ tmpl->Set(isolate, "COPY_READ_BUFFER_BINDING", v8::Uint32::New(isolate, 0x8F36));
3756
+ tmpl->Set(isolate, "COPY_WRITE_BUFFER_BINDING", v8::Uint32::New(isolate, 0x8F37));
3757
+ tmpl->Set(isolate, "FLOAT_MAT2x3", v8::Uint32::New(isolate, 0x8B65));
3758
+ tmpl->Set(isolate, "FLOAT_MAT2x4", v8::Uint32::New(isolate, 0x8B66));
3759
+
3760
+ tmpl->Set(isolate, "FLOAT_MAT3x2", v8::Uint32::New(isolate, 0x8B67));
3761
+ tmpl->Set(isolate, "FLOAT_MAT3x4", v8::Uint32::New(isolate, 0x8B68));
3762
+ tmpl->Set(isolate, "FLOAT_MAT4x2", v8::Uint32::New(isolate, 0x8B69));
3763
+ tmpl->Set(isolate, "FLOAT_MAT4x3", v8::Uint32::New(isolate, 0x8B6A));
3764
+ tmpl->Set(isolate, "UNSIGNED_INT_VEC2", v8::Uint32::New(isolate, 0x8DC6));
3765
+
3766
+ tmpl->Set(isolate, "UNSIGNED_INT_VEC3", v8::Uint32::New(isolate, 0x8DC7));
3767
+ tmpl->Set(isolate, "UNSIGNED_INT_VEC4", v8::Uint32::New(isolate, 0x8DC8));
3768
+ tmpl->Set(isolate, "UNSIGNED_NORMALIZED", v8::Uint32::New(isolate, 0x8C17));
3769
+ tmpl->Set(isolate, "SIGNED_NORMALIZED", v8::Uint32::New(isolate, 0x8F9C));
3770
+
3771
+ /* Vertex attributes */
3772
+
3773
+ tmpl->Set(isolate, "VERTEX_ATTRIB_ARRAY_INTEGER", v8::Uint32::New(isolate, 0x88FD));
3774
+ tmpl->Set(isolate, "VERTEX_ATTRIB_ARRAY_DIVISOR", v8::Uint32::New(isolate, 0x88FE));
3775
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_BUFFER_MODE", v8::Uint32::New(isolate, 0x8C7F));
3776
+ tmpl->Set(isolate, "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",
3777
+ v8::Uint32::New(isolate, 0x8C80));
3778
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_VARYINGS", v8::Uint32::New(isolate, 0x8C83));
3779
+
3780
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_BUFFER_START", v8::Uint32::New(isolate, 0x8C84));
3781
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_BUFFER_SIZE", v8::Uint32::New(isolate, 0x8C85));
3782
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN", v8::Uint32::New(isolate, 0x8C88));
3783
+ tmpl->Set(isolate, "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",
3784
+ v8::Uint32::New(isolate, 0x8C8A));
3785
+
3786
+ /* Textures */
3787
+
3788
+ /* Pixel types */
3789
+
3790
+ tmpl->Set(isolate, "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS", v8::Uint32::New(isolate, 0x8C8B));
3791
+ tmpl->Set(isolate, "INTERLEAVED_ATTRIBS", v8::Uint32::New(isolate, 0x8C8C));
3792
+ tmpl->Set(isolate, "SEPARATE_ATTRIBS", v8::Uint32::New(isolate, 0x8C8D));
3793
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_BUFFER", v8::Uint32::New(isolate, 0x8C8E));
3794
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_BUFFER_BINDING", v8::Uint32::New(isolate, 0x8C8F));
3795
+
3796
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK", v8::Uint32::New(isolate, 0x8E22));
3797
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_PAUSED", v8::Uint32::New(isolate, 0x8E23));
3798
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_ACTIVE", v8::Uint32::New(isolate, 0x8E24));
3799
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_BINDING", v8::Uint32::New(isolate, 0x8E25));
3800
+
3801
+ /* Pixel types */
3802
+
3803
+ /* Queries */
3804
+
3805
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING", v8::Uint32::New(isolate, 0x8210));
3806
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE", v8::Uint32::New(isolate, 0x8211));
3807
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_RED_SIZE", v8::Uint32::New(isolate, 0x8212));
3808
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_GREEN_SIZE", v8::Uint32::New(isolate, 0x8213));
3809
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_BLUE_SIZE", v8::Uint32::New(isolate, 0x8214));
3810
+
3811
+ /* Queries */
3812
+
3813
+ /* Draw buffers */
3814
+
3815
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE", v8::Uint32::New(isolate, 0x8215));
3816
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE", v8::Uint32::New(isolate, 0x8216));
3817
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE", v8::Uint32::New(isolate, 0x8217));
3818
+ tmpl->Set(isolate, "FRAMEBUFFER_DEFAULT", v8::Uint32::New(isolate, 0x8218));
3819
+ tmpl->Set(isolate, "DEPTH_STENCIL_ATTACHMENT", v8::Uint32::New(isolate, 0x821A));
3820
+
3821
+ tmpl->Set(isolate, "DEPTH_STENCIL", v8::Uint32::New(isolate, 0x84F9));
3822
+ tmpl->Set(isolate, "DEPTH24_STENCIL8", v8::Uint32::New(isolate, 0x88F0));
3823
+ tmpl->Set(isolate, "DRAW_FRAMEBUFFER_BINDING", v8::Uint32::New(isolate, 0x8CA6));
3824
+ tmpl->Set(isolate, "READ_FRAMEBUFFER", v8::Uint32::New(isolate, 0x8CA8));
3825
+ tmpl->Set(isolate, "DRAW_FRAMEBUFFER", v8::Uint32::New(isolate, 0x8CA9));
3826
+
3827
+ tmpl->Set(isolate, "READ_FRAMEBUFFER_BINDING", v8::Uint32::New(isolate, 0x8CAA));
3828
+ tmpl->Set(isolate, "RENDERBUFFER_SAMPLES", v8::Uint32::New(isolate, 0x8CAB));
3829
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER", v8::Uint32::New(isolate, 0x8CD4));
3830
+ tmpl->Set(isolate, "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE", v8::Uint32::New(isolate, 0x8D56));
3831
+ tmpl->Set(isolate, "UNIFORM_BUFFER", v8::Uint32::New(isolate, 0x8A11));
3832
+
3833
+ tmpl->Set(isolate, "UNIFORM_BUFFER_BINDING", v8::Uint32::New(isolate, 0x8A28));
3834
+ tmpl->Set(isolate, "UNIFORM_BUFFER_START", v8::Uint32::New(isolate, 0x8A29));
3835
+ tmpl->Set(isolate, "UNIFORM_BUFFER_SIZE", v8::Uint32::New(isolate, 0x8A2A));
3836
+ tmpl->Set(isolate, "MAX_VERTEX_UNIFORM_BLOCKS", v8::Uint32::New(isolate, 0x8A2B));
3837
+ tmpl->Set(isolate, "MAX_FRAGMENT_UNIFORM_BLOCKS", v8::Uint32::New(isolate, 0x8A2D));
3838
+
3839
+ tmpl->Set(isolate, "MAX_COMBINED_UNIFORM_BLOCKS", v8::Uint32::New(isolate, 0x8A2E));
3840
+ tmpl->Set(isolate, "MAX_UNIFORM_BUFFER_BINDINGS", v8::Uint32::New(isolate, 0x8A2F));
3841
+ tmpl->Set(isolate, "MAX_UNIFORM_BLOCK_SIZE", v8::Uint32::New(isolate, 0x8A30));
3842
+ tmpl->Set(isolate, "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS", v8::Uint32::New(isolate, 0x8A31));
3843
+ tmpl->Set(isolate, "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",
3844
+ v8::Uint32::New(isolate, 0x8A33));
3845
+
3846
+ tmpl->Set(isolate, "UNIFORM_BUFFER_OFFSET_ALIGNMENT", v8::Uint32::New(isolate, 0x8A34));
3847
+ tmpl->Set(isolate, "ACTIVE_UNIFORM_BLOCKS", v8::Uint32::New(isolate, 0x8A36));
3848
+ tmpl->Set(isolate, "UNIFORM_TYPE", v8::Uint32::New(isolate, 0x8A37));
3849
+ tmpl->Set(isolate, "UNIFORM_SIZE", v8::Uint32::New(isolate, 0x8A38));
3850
+ tmpl->Set(isolate, "UNIFORM_BLOCK_INDEX", v8::Uint32::New(isolate, 0x8A3A));
3851
+
3852
+ tmpl->Set(isolate, "UNIFORM_OFFSET", v8::Uint32::New(isolate, 0x8A3B));
3853
+ tmpl->Set(isolate, "UNIFORM_ARRAY_STRIDE", v8::Uint32::New(isolate, 0x8A3C));
3854
+ tmpl->Set(isolate, "UNIFORM_MATRIX_STRIDE", v8::Uint32::New(isolate, 0x8A3D));
3855
+
3856
+ /* Draw buffers */
3857
+
3858
+ /* Samplers */
3859
+
3860
+ tmpl->Set(isolate, "UNIFORM_IS_ROW_MAJOR", v8::Uint32::New(isolate, 0x8A3E));
3861
+ tmpl->Set(isolate, "UNIFORM_BLOCK_BINDING", v8::Uint32::New(isolate, 0x8A3F));
3862
+ tmpl->Set(isolate, "UNIFORM_BLOCK_DATA_SIZE", v8::Uint32::New(isolate, 0x8A40));
3863
+ tmpl->Set(isolate, "UNIFORM_BLOCK_ACTIVE_UNIFORMS", v8::Uint32::New(isolate, 0x8A42));
3864
+ tmpl->Set(isolate, "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES", v8::Uint32::New(isolate, 0x8A43));
3865
+
3866
+ tmpl->Set(isolate, "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",
3867
+ v8::Uint32::New(isolate, 0x8A44));
3868
+ tmpl->Set(isolate, "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",
3869
+ v8::Uint32::New(isolate, 0x8A46));
3870
+ tmpl->Set(isolate, "OBJECT_TYPE", v8::Uint32::New(isolate, 0x9112));
3871
+ tmpl->Set(isolate, "SYNC_CONDITION", v8::Uint32::New(isolate, 0x9113));
3872
+ tmpl->Set(isolate, "SYNC_STATUS", v8::Uint32::New(isolate, 0x9114));
3873
+
3874
+ tmpl->Set(isolate, "SYNC_FLAGS", v8::Uint32::New(isolate, 0x9115));
3875
+ tmpl->Set(isolate, "SYNC_FENCE", v8::Uint32::New(isolate, 0x9116));
3876
+ tmpl->Set(isolate, "SYNC_GPU_COMMANDS_COMPLETE", v8::Uint32::New(isolate, 0x9117));
3877
+ tmpl->Set(isolate, "UNSIGNALED", v8::Uint32::New(isolate, 0x9118));
3878
+ tmpl->Set(isolate, "SIGNALED", v8::Uint32::New(isolate, 0x9119));
3879
+
3880
+ /* Samplers */
3881
+
3882
+ /* Buffers */
3883
+
3884
+ tmpl->Set(isolate, "ALREADY_SIGNALED", v8::Uint32::New(isolate, 0x911A));
3885
+ tmpl->Set(isolate, "TIMEOUT_EXPIRED", v8::Uint32::New(isolate, 0x911B));
3886
+ tmpl->Set(isolate, "CONDITION_SATISFIED", v8::Uint32::New(isolate, 0x911C));
3887
+ tmpl->Set(isolate, "WAIT_FAILED", v8::Uint32::New(isolate, 0x911D));
3888
+ tmpl->Set(isolate, "SYNC_FLUSH_COMMANDS_BIT", v8::Uint32::New(isolate, 0x00000001));
3889
+
3890
+ tmpl->Set(isolate, "COLOR", v8::Uint32::New(isolate, 0x1800));
3891
+ tmpl->Set(isolate, "DEPTH", v8::Uint32::New(isolate, 0x1801));
3892
+ tmpl->Set(isolate, "STENCIL", v8::Uint32::New(isolate, 0x1802));
3893
+
3894
+ /* Buffers */
3895
+
3896
+ /* Data types */
3897
+
3898
+ tmpl->Set(isolate, "MIN", v8::Uint32::New(isolate, 0x8007));
3899
+ tmpl->Set(isolate, "MAX", v8::Uint32::New(isolate, 0x8008));
3900
+ tmpl->Set(isolate, "DEPTH_COMPONENT24", v8::Uint32::New(isolate, 0x81A6));
3901
+ tmpl->Set(isolate, "STREAM_READ", v8::Uint32::New(isolate, 0x88E1));
3902
+ tmpl->Set(isolate, "STREAM_COPY", v8::Uint32::New(isolate, 0x88E2));
3903
+
3904
+ tmpl->Set(isolate, "STATIC_READ", v8::Uint32::New(isolate, 0x88E5));
3905
+ tmpl->Set(isolate, "STATIC_COPY", v8::Uint32::New(isolate, 0x88E6));
3906
+ tmpl->Set(isolate, "DYNAMIC_READ", v8::Uint32::New(isolate, 0x88E9));
3907
+ tmpl->Set(isolate, "DYNAMIC_COPY", v8::Uint32::New(isolate, 0x88EA));
3908
+ tmpl->Set(isolate, "DEPTH_COMPONENT32F", v8::Uint32::New(isolate, 0x8CAC));
3909
+ tmpl->Set(isolate, "DEPTH32F_STENCIL8", v8::Uint32::New(isolate, 0x8CAD));
3910
+
3911
+ /* Data types */
3912
+
3913
+ tmpl->Set(isolate, "INVALID_INDEX", v8::Number::New(isolate, (double) 0xFFFFFFFF));
3914
+ tmpl->Set(isolate, "TIMEOUT_IGNORED", v8::Int32::New(isolate, -1));
3915
+
3916
+ /* Vertex attributes */
3917
+
3918
+ /* Transform feedback */
3919
+
3920
+ tmpl->Set(isolate, "MAX_CLIENT_WAIT_TIMEOUT_WEBGL", v8::Uint32::New(isolate, 0x9247));
3921
+
3922
+ /* Transform feedback */
3923
+
3924
+ }
3925
+
3926
+
3927
+ void WebGL2RenderingContext::SetMethods(v8::Isolate *isolate,
3928
+ const v8::Local<v8::ObjectTemplate> &tmpl) {
3929
+
3930
+ tmpl->Set(
3931
+ ConvertToV8String(isolate, "beginQuery"),
3932
+ v8::FunctionTemplate::New(isolate, &BeginQuery)
3933
+ );
3934
+
3935
+ tmpl->Set(
3936
+ ConvertToV8String(isolate, "beginTransformFeedback"),
3937
+ v8::FunctionTemplate::New(isolate, &BeginTransformFeedback)
3938
+ );
3939
+
3940
+ tmpl->Set(
3941
+ ConvertToV8String(isolate, "bindBufferBase"),
3942
+ v8::FunctionTemplate::New(isolate, &BindBufferBase)
3943
+ );
3944
+
3945
+ tmpl->Set(
3946
+ ConvertToV8String(isolate, "bindBufferRange"),
3947
+ v8::FunctionTemplate::New(isolate, &BindBufferRange)
3948
+ );
3949
+
3950
+ tmpl->Set(
3951
+ ConvertToV8String(isolate, "bindSampler"),
3952
+ v8::FunctionTemplate::New(isolate, &BindSampler)
3953
+ );
3954
+
3955
+ tmpl->Set(
3956
+ ConvertToV8String(isolate, "bindTransformFeedback"),
3957
+ v8::FunctionTemplate::New(isolate, &BindTransformFeedback)
3958
+ );
3959
+
3960
+ tmpl->Set(
3961
+ ConvertToV8String(isolate, "bindVertexArray"),
3962
+ v8::FunctionTemplate::New(isolate, &BindVertexArray)
3963
+ );
3964
+
3965
+ tmpl->Set(
3966
+ ConvertToV8String(isolate, "blitFramebuffer"),
3967
+ v8::FunctionTemplate::New(isolate, &BlitFramebuffer)
3968
+ );
3969
+
3970
+ tmpl->Set(
3971
+ ConvertToV8String(isolate, "clearBufferfi"),
3972
+ v8::FunctionTemplate::New(isolate, &ClearBufferfi)
3973
+ );
3974
+
3975
+ tmpl->Set(
3976
+ ConvertToV8String(isolate, "clearBufferfv"),
3977
+ v8::FunctionTemplate::New(isolate, &ClearBufferfv)
3978
+ );
3979
+
3980
+ tmpl->Set(
3981
+ ConvertToV8String(isolate, "clearBufferiv"),
3982
+ v8::FunctionTemplate::New(isolate, &ClearBufferiv)
3983
+ );
3984
+
3985
+ tmpl->Set(
3986
+ ConvertToV8String(isolate, "clearBufferuiv"),
3987
+ v8::FunctionTemplate::New(isolate, &ClearBufferuiv)
3988
+ );
3989
+
3990
+ tmpl->Set(
3991
+ ConvertToV8String(isolate, "clientWaitSync"),
3992
+ v8::FunctionTemplate::New(isolate, &ClientWaitSync)
3993
+ );
3994
+
3995
+ tmpl->Set(
3996
+ ConvertToV8String(isolate, "compressedTexSubImage3D"),
3997
+ v8::FunctionTemplate::New(isolate, &CompressedTexSubImage3D)
3998
+ );
3999
+
4000
+ tmpl->Set(
4001
+ ConvertToV8String(isolate, "copyBufferSubData"),
4002
+ v8::FunctionTemplate::New(isolate, &CopyBufferSubData)
4003
+ );
4004
+
4005
+ tmpl->Set(
4006
+ ConvertToV8String(isolate, "copyTexSubImage3D"),
4007
+ v8::FunctionTemplate::New(isolate, &CopyTexSubImage3D)
4008
+ );
4009
+
4010
+ tmpl->Set(
4011
+ ConvertToV8String(isolate, "createQuery"),
4012
+ v8::FunctionTemplate::New(isolate, &CreateQuery)
4013
+ );
4014
+
4015
+ tmpl->Set(
4016
+ ConvertToV8String(isolate, "createSampler"),
4017
+ v8::FunctionTemplate::New(isolate, &CreateSampler)
4018
+ );
4019
+
4020
+ tmpl->Set(
4021
+ ConvertToV8String(isolate, "createTransformFeedback"),
4022
+ v8::FunctionTemplate::New(isolate, &CreateTransformFeedback)
4023
+ );
4024
+
4025
+ tmpl->Set(
4026
+ ConvertToV8String(isolate, "createVertexArray"),
4027
+ v8::FunctionTemplate::New(isolate, &CreateVertexArray)
4028
+ );
4029
+
4030
+ tmpl->Set(
4031
+ ConvertToV8String(isolate, "deleteQuery"),
4032
+ v8::FunctionTemplate::New(isolate, &DeleteQuery)
4033
+ );
4034
+
4035
+
4036
+ tmpl->Set(
4037
+ ConvertToV8String(isolate, "deleteSampler"),
4038
+ v8::FunctionTemplate::New(isolate, &DeleteSampler)
4039
+ );
4040
+
4041
+ tmpl->Set(
4042
+ ConvertToV8String(isolate, "deleteSync"),
4043
+ v8::FunctionTemplate::New(isolate, &DeleteSync)
4044
+ );
4045
+
4046
+ tmpl->Set(
4047
+ ConvertToV8String(isolate, "deleteTransformFeedback"),
4048
+ v8::FunctionTemplate::New(isolate, &DeleteTransformFeedback)
4049
+ );
4050
+
4051
+ tmpl->Set(
4052
+ ConvertToV8String(isolate, "deleteVertexArray"),
4053
+ v8::FunctionTemplate::New(isolate, &DeleteVertexArray)
4054
+ );
4055
+
4056
+ tmpl->Set(
4057
+ ConvertToV8String(isolate, "drawArraysInstanced"),
4058
+ v8::FunctionTemplate::New(isolate, &DrawArraysInstanced)
4059
+ );
4060
+
4061
+ tmpl->Set(
4062
+ ConvertToV8String(isolate, "drawBuffers"),
4063
+ v8::FunctionTemplate::New(isolate, &DrawBuffers)
4064
+ );
4065
+
4066
+ tmpl->Set(
4067
+ ConvertToV8String(isolate, "drawElementsInstanced"),
4068
+ v8::FunctionTemplate::New(isolate, &DrawElementsInstanced)
4069
+ );
4070
+
4071
+ tmpl->Set(
4072
+ ConvertToV8String(isolate, "drawRangeElements"),
4073
+ v8::FunctionTemplate::New(isolate, &DrawRangeElements)
4074
+ );
4075
+
4076
+ tmpl->Set(
4077
+ ConvertToV8String(isolate, "endQuery"),
4078
+ v8::FunctionTemplate::New(isolate, &EndQuery)
4079
+ );
4080
+
4081
+ tmpl->Set(
4082
+ ConvertToV8String(isolate, "endTransformFeedback"),
4083
+ v8::FunctionTemplate::New(isolate, &EndTransformFeedback)
4084
+ );
4085
+
4086
+ tmpl->Set(
4087
+ ConvertToV8String(isolate, "fenceSync"),
4088
+ v8::FunctionTemplate::New(isolate, &FenceSync)
4089
+ );
4090
+
4091
+ tmpl->Set(
4092
+ ConvertToV8String(isolate, "framebufferTextureLayer"),
4093
+ v8::FunctionTemplate::New(isolate, &FramebufferTextureLayer)
4094
+ );
4095
+
4096
+ tmpl->Set(
4097
+ ConvertToV8String(isolate, "uniform1ui"),
4098
+ v8::FunctionTemplate::New(isolate, &Uniform1ui)
4099
+ );
4100
+
4101
+ tmpl->Set(
4102
+ ConvertToV8String(isolate, "uniform1uiv"),
4103
+ v8::FunctionTemplate::New(isolate, &Uniform1uiv)
4104
+ );
4105
+
4106
+ tmpl->Set(
4107
+ ConvertToV8String(isolate, "uniform2ui"),
4108
+ v8::FunctionTemplate::New(isolate, &Uniform2ui)
4109
+ );
4110
+
4111
+ tmpl->Set(
4112
+ ConvertToV8String(isolate, "uniform2uiv"),
4113
+ v8::FunctionTemplate::New(isolate, &Uniform2uiv)
4114
+ );
4115
+
4116
+ tmpl->Set(
4117
+ ConvertToV8String(isolate, "uniform3ui"),
4118
+ v8::FunctionTemplate::New(isolate, &Uniform3ui)
4119
+ );
4120
+
4121
+ tmpl->Set(
4122
+ ConvertToV8String(isolate, "uniform3uiv"),
4123
+ v8::FunctionTemplate::New(isolate, &Uniform3uiv)
4124
+ );
4125
+
4126
+ tmpl->Set(
4127
+ ConvertToV8String(isolate, "uniform4ui"),
4128
+ v8::FunctionTemplate::New(isolate, &Uniform4ui)
4129
+ );
4130
+
4131
+ tmpl->Set(
4132
+ ConvertToV8String(isolate, "uniform4uiv"),
4133
+ v8::FunctionTemplate::New(isolate, &Uniform4uiv)
4134
+ );
4135
+
4136
+
4137
+ tmpl->Set(
4138
+ ConvertToV8String(isolate, "uniformBlockBinding"),
4139
+ v8::FunctionTemplate::New(isolate, &UniformBlockBinding)
4140
+ );
4141
+
4142
+
4143
+ tmpl->Set(
4144
+ ConvertToV8String(isolate, "uniformMatrix2x3fv"),
4145
+ v8::FunctionTemplate::New(isolate, &UniformMatrix2x3fv)
4146
+ );
4147
+
4148
+ tmpl->Set(
4149
+ ConvertToV8String(isolate, "uniformMatrix2x4fv"),
4150
+ v8::FunctionTemplate::New(isolate, &UniformMatrix2x4fv)
4151
+ );
4152
+
4153
+ tmpl->Set(
4154
+ ConvertToV8String(isolate, "uniformMatrix3x2fv"),
4155
+ v8::FunctionTemplate::New(isolate, &UniformMatrix3x2fv)
4156
+ );
4157
+
4158
+
4159
+ tmpl->Set(
4160
+ ConvertToV8String(isolate, "uniformMatrix3x4fv"),
4161
+ v8::FunctionTemplate::New(isolate, &UniformMatrix3x4fv)
4162
+ );
4163
+
4164
+ tmpl->Set(
4165
+ ConvertToV8String(isolate, "uniformMatrix4x2fv"),
4166
+ v8::FunctionTemplate::New(isolate, &UniformMatrix4x2fv)
4167
+ );
4168
+
4169
+ tmpl->Set(
4170
+ ConvertToV8String(isolate, "uniformMatrix4x3fv"),
4171
+ v8::FunctionTemplate::New(isolate, &UniformMatrix4x3fv)
4172
+ );
4173
+
4174
+ tmpl->Set(
4175
+ ConvertToV8String(isolate, "uniformMatrix4x3fv"),
4176
+ v8::FunctionTemplate::New(isolate, &UniformMatrix4x3fv)
4177
+ );
4178
+
4179
+ tmpl->Set(
4180
+ ConvertToV8String(isolate, "vertexAttribDivisor"),
4181
+ v8::FunctionTemplate::New(isolate, &VertexAttribDivisor)
4182
+ );
4183
+
4184
+ tmpl->Set(
4185
+ ConvertToV8String(isolate, "vertexAttribI4i"),
4186
+ v8::FunctionTemplate::New(isolate, &VertexAttribI4i)
4187
+ );
4188
+
4189
+ tmpl->Set(
4190
+ ConvertToV8String(isolate, "vertexAttribI4iv"),
4191
+ v8::FunctionTemplate::New(isolate, &VertexAttribI4iv)
4192
+ );
4193
+
4194
+ tmpl->Set(
4195
+ ConvertToV8String(isolate, "vertexAttribI4ui"),
4196
+ v8::FunctionTemplate::New(isolate, &VertexAttribI4ui)
4197
+ );
4198
+
4199
+ tmpl->Set(
4200
+ ConvertToV8String(isolate, "vertexAttribI4uiv"),
4201
+ v8::FunctionTemplate::New(isolate, &VertexAttribI4uiv)
4202
+ );
4203
+
4204
+ tmpl->Set(
4205
+ ConvertToV8String(isolate, "getActiveUniformBlockName"),
4206
+ v8::FunctionTemplate::New(isolate, &GetActiveUniformBlockName)
4207
+ );
4208
+
4209
+ tmpl->Set(
4210
+ ConvertToV8String(isolate, "getActiveUniformBlockParameter"),
4211
+ v8::FunctionTemplate::New(isolate, &GetActiveUniformBlockParameter)
4212
+ );
4213
+
4214
+ tmpl->Set(
4215
+ ConvertToV8String(isolate, "getActiveUniforms"),
4216
+ v8::FunctionTemplate::New(isolate, &GetActiveUniforms)
4217
+ );
4218
+
4219
+ tmpl->Set(
4220
+ ConvertToV8String(isolate, "getBufferSubData"),
4221
+ v8::FunctionTemplate::New(isolate, &GetBufferSubData)
4222
+ );
4223
+
4224
+
4225
+ tmpl->Set(
4226
+ ConvertToV8String(isolate, "getFragDataLocation"),
4227
+ v8::FunctionTemplate::New(isolate, &GetFragDataLocation)
4228
+ );
4229
+
4230
+
4231
+ tmpl->Set(
4232
+ ConvertToV8String(isolate, "getIndexedParameter"),
4233
+ v8::FunctionTemplate::New(isolate, &GetIndexedParameter)
4234
+ );
4235
+
4236
+ tmpl->Set(
4237
+ ConvertToV8String(isolate, "getInternalformatParameter"),
4238
+ v8::FunctionTemplate::New(isolate, &GetInternalformatParameter)
4239
+ );
4240
+
4241
+ tmpl->Set(
4242
+ ConvertToV8String(isolate, "getParameter"),
4243
+ v8::FunctionTemplate::New(isolate, &GetParameter)
4244
+ );
4245
+
4246
+ tmpl->Set(
4247
+ ConvertToV8String(isolate, "getQueryParameter"),
4248
+ v8::FunctionTemplate::New(isolate, &GetQueryParameter)
4249
+ );
4250
+
4251
+
4252
+ tmpl->Set(
4253
+ ConvertToV8String(isolate, "getQuery"),
4254
+ v8::FunctionTemplate::New(isolate, &GetQuery)
4255
+ );
4256
+
4257
+ tmpl->Set(
4258
+ ConvertToV8String(isolate, "getSamplerParameter"),
4259
+ v8::FunctionTemplate::New(isolate, &GetSamplerParameter)
4260
+ );
4261
+
4262
+ tmpl->Set(
4263
+ ConvertToV8String(isolate, "getSyncParameter"),
4264
+ v8::FunctionTemplate::New(isolate, &GetSyncParameter)
4265
+ );
4266
+
4267
+ tmpl->Set(
4268
+ ConvertToV8String(isolate, "getTransformFeedbackVarying"),
4269
+ v8::FunctionTemplate::New(isolate, &GetTransformFeedbackVarying)
4270
+ );
4271
+
4272
+ tmpl->Set(
4273
+ ConvertToV8String(isolate, "getUniformBlockIndex"),
4274
+ v8::FunctionTemplate::New(isolate, &GetUniformBlockIndex)
4275
+ );
4276
+
4277
+ tmpl->Set(
4278
+ ConvertToV8String(isolate, "getUniformIndices"),
4279
+ v8::FunctionTemplate::New(isolate, &GetUniformIndices)
4280
+ );
4281
+
4282
+ tmpl->Set(
4283
+ ConvertToV8String(isolate, "invalidateFramebuffer"),
4284
+ v8::FunctionTemplate::New(isolate, &InvalidateFramebuffer)
4285
+ );
4286
+
4287
+ tmpl->Set(
4288
+ ConvertToV8String(isolate, "invalidateSubFramebuffer"),
4289
+ v8::FunctionTemplate::New(isolate, &InvalidateSubFramebuffer)
4290
+ );
4291
+
4292
+
4293
+ tmpl->Set(
4294
+ ConvertToV8String(isolate, "isQuery"),
4295
+ v8::FunctionTemplate::New(isolate, &IsQuery)
4296
+ );
4297
+
4298
+ tmpl->Set(
4299
+ ConvertToV8String(isolate, "isSampler"),
4300
+ v8::FunctionTemplate::New(isolate, &IsSampler)
4301
+ );
4302
+
4303
+ tmpl->Set(
4304
+ ConvertToV8String(isolate, "isSync"),
4305
+ v8::FunctionTemplate::New(isolate, &IsSync)
4306
+ );
4307
+
4308
+ tmpl->Set(
4309
+ ConvertToV8String(isolate, "isTransformFeedback"),
4310
+ v8::FunctionTemplate::New(isolate, &IsTransformFeedback)
4311
+ );
4312
+
4313
+ tmpl->Set(
4314
+ ConvertToV8String(isolate, "isVertexArray"),
4315
+ v8::FunctionTemplate::New(isolate, &IsVertexArray)
4316
+ );
4317
+
4318
+
4319
+ tmpl->Set(
4320
+ ConvertToV8String(isolate, "pauseTransformFeedback"),
4321
+ v8::FunctionTemplate::New(isolate, &PauseTransformFeedback)
4322
+ );
4323
+
4324
+ tmpl->Set(
4325
+ ConvertToV8String(isolate, "readBuffer"),
4326
+ v8::FunctionTemplate::New(isolate, &ReadBuffer)
4327
+ );
4328
+
4329
+ tmpl->Set(
4330
+ ConvertToV8String(isolate, "renderbufferStorageMultisample"),
4331
+ v8::FunctionTemplate::New(isolate, &RenderbufferStorageMultisample)
4332
+ );
4333
+
4334
+
4335
+ tmpl->Set(
4336
+ ConvertToV8String(isolate, "resumeTransformFeedback"),
4337
+ v8::FunctionTemplate::New(isolate, &ResumeTransformFeedback)
4338
+ );
4339
+
4340
+ tmpl->Set(
4341
+ ConvertToV8String(isolate, "samplerParameterf"),
4342
+ v8::FunctionTemplate::New(isolate, &SamplerParameterf)
4343
+ );
4344
+
4345
+ tmpl->Set(
4346
+ ConvertToV8String(isolate, "samplerParameteri"),
4347
+ v8::FunctionTemplate::New(isolate, &SamplerParameteri)
4348
+ );
4349
+
4350
+ tmpl->Set(
4351
+ ConvertToV8String(isolate, "texImage3D"),
4352
+ v8::FunctionTemplate::New(isolate, &TexImage3D)
4353
+ );
4354
+
4355
+
4356
+ tmpl->Set(
4357
+ ConvertToV8String(isolate, "texStorage2D"),
4358
+ v8::FunctionTemplate::New(isolate, &TexStorage2D)
4359
+ );
4360
+
4361
+ tmpl->Set(
4362
+ ConvertToV8String(isolate, "texStorage3D"),
4363
+ v8::FunctionTemplate::New(isolate, &TexStorage3D)
4364
+ );
4365
+
4366
+ tmpl->Set(
4367
+ ConvertToV8String(isolate, "texSubImage3D"),
4368
+ v8::FunctionTemplate::New(isolate, &TexSubImage3D)
4369
+ );
4370
+
4371
+ tmpl->Set(
4372
+ ConvertToV8String(isolate, "transformFeedbackVaryings"),
4373
+ v8::FunctionTemplate::New(isolate, &TransformFeedbackVaryings)
4374
+ );
4375
+ }
4376
+
4377
+ void WebGL2RenderingContext::SetProps(v8::Isolate *isolate,
4378
+ const v8::Local<v8::ObjectTemplate> &webgl2RenderingContextTpl) {
4379
+
4380
+ }