@nativescript/canvas 2.0.0-alpha.21 → 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.
@@ -748,7 +748,7 @@ void WebGL2RenderingContext::DeleteSampler(const v8::FunctionCallbackInfo<v8::Va
748
748
  }
749
749
 
750
750
  auto isolate = args.GetIsolate();
751
-
751
+
752
752
 
753
753
  auto samplerValue = args[0];
754
754
  auto type = GetNativeType(isolate, samplerValue);
@@ -772,7 +772,7 @@ void WebGL2RenderingContext::DeleteSync(const v8::FunctionCallbackInfo<v8::Value
772
772
  }
773
773
 
774
774
  auto isolate = args.GetIsolate();
775
-
775
+
776
776
 
777
777
  auto syncValue = args[0];
778
778
  auto type = GetNativeType(isolate, syncValue);
@@ -796,7 +796,7 @@ WebGL2RenderingContext::DeleteTransformFeedback(const v8::FunctionCallbackInfo<v
796
796
  }
797
797
 
798
798
  auto isolate = args.GetIsolate();
799
-
799
+
800
800
 
801
801
  auto transformFeedbackValue = args[0];
802
802
  auto type = GetNativeType(isolate, transformFeedbackValue);
@@ -820,7 +820,7 @@ void WebGL2RenderingContext::DeleteVertexArray(const v8::FunctionCallbackInfo<v8
820
820
  }
821
821
 
822
822
  auto isolate = args.GetIsolate();
823
-
823
+
824
824
 
825
825
  auto vertexArrayValue = args[0];
826
826
  auto type = GetNativeType(isolate, vertexArrayValue);
@@ -845,21 +845,19 @@ void WebGL2RenderingContext::DrawArraysInstanced(const v8::FunctionCallbackInfo<
845
845
  auto isolate = args.GetIsolate();
846
846
  auto context = isolate->GetCurrentContext();
847
847
 
848
- if (args.Length() > 3) {
849
- auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
850
- auto first = (int32_t) args[1]->NumberValue(context).ToChecked();
851
- auto count_ = (int32_t) args[2]->NumberValue(context).ToChecked();
852
- auto instanceCount = (int32_t) args[3]->NumberValue(context).ToChecked();
853
- canvas_native_webgl2_draw_arrays_instanced(
854
- mode,
855
- first,
856
- count_,
857
- instanceCount,
858
- ptr->GetState()
859
- );
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
+ );
860
859
 
861
- ptr->UpdateInvalidateState();
862
- }
860
+ ptr->UpdateInvalidateState();
863
861
  }
864
862
 
865
863
  void WebGL2RenderingContext::DrawBuffers(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -900,23 +898,21 @@ WebGL2RenderingContext::DrawElementsInstanced(const v8::FunctionCallbackInfo<v8:
900
898
  auto isolate = args.GetIsolate();
901
899
  auto context = isolate->GetCurrentContext();
902
900
 
903
- if (args.Length() > 4) {
904
- auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
905
- auto count_ = (int32_t) args[1]->NumberValue(context).ToChecked();
906
- auto type = (uint32_t) args[2]->NumberValue(context).ToChecked();
907
- auto offset = args[3]->NumberValue(context).ToChecked();
908
- auto instanceCount = (int32_t) args[4]->NumberValue(context).ToChecked();
909
- canvas_native_webgl2_draw_elements_instanced(
910
- mode,
911
- count_,
912
- type,
913
- static_cast<ssize_t>(offset),
914
- instanceCount,
915
- ptr->GetState()
916
- );
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
+ );
917
914
 
918
- ptr->UpdateInvalidateState();
919
- }
915
+ ptr->UpdateInvalidateState();
920
916
  }
921
917
 
922
918
  void WebGL2RenderingContext::DrawRangeElements(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -928,25 +924,23 @@ void WebGL2RenderingContext::DrawRangeElements(const v8::FunctionCallbackInfo<v8
928
924
  auto isolate = args.GetIsolate();
929
925
  auto context = isolate->GetCurrentContext();
930
926
 
931
- if (args.Length() > 5) {
932
- auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
933
- auto start = (uint32_t) args[1]->NumberValue(context).ToChecked();
934
- auto end = (uint32_t) args[2]->NumberValue(context).ToChecked();
935
- auto count_ = (int32_t) args[3]->NumberValue(context).ToChecked();
936
- auto type = (uint32_t) args[4]->NumberValue(context).ToChecked();
937
- auto offset = args[5]->NumberValue(context).ToChecked();
938
- canvas_native_webgl2_draw_range_elements(
939
- mode,
940
- start,
941
- end,
942
- count_,
943
- type,
944
- static_cast<ssize_t>(offset),
945
- ptr->GetState()
946
- );
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
+ );
947
942
 
948
- ptr->UpdateInvalidateState();
949
- }
943
+ ptr->UpdateInvalidateState();
950
944
  }
951
945
 
952
946
  void WebGL2RenderingContext::EndQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -972,7 +966,7 @@ void WebGL2RenderingContext::EndTransformFeedback(const v8::FunctionCallbackInfo
972
966
  }
973
967
 
974
968
  auto isolate = args.GetIsolate();
975
-
969
+
976
970
 
977
971
  canvas_native_webgl2_end_transform_feedback(
978
972
  ptr->GetState());
@@ -988,18 +982,16 @@ void WebGL2RenderingContext::FenceSync(const v8::FunctionCallbackInfo<v8::Value>
988
982
  auto isolate = args.GetIsolate();
989
983
  auto context = isolate->GetCurrentContext();
990
984
 
991
- if (args.Length() > 1) {
992
- auto condition = (uint32_t) args[0]->NumberValue(context).ToChecked();
993
- auto flags = (uint32_t) args[1]->NumberValue(context).ToChecked();
994
- auto sync = canvas_native_webgl2_fence_sync(
995
- condition,
996
- flags,
997
- ptr->GetState()
998
- );
999
- auto ret = WebGLSyncImpl::NewInstance(isolate, new WebGLSyncImpl(std::move(sync)));
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));
1000
993
 
1001
- args.GetReturnValue().Set(ret);
1002
- }
994
+ args.GetReturnValue().Set(ret);
1003
995
  }
1004
996
 
1005
997
  void
@@ -1016,7 +1008,7 @@ WebGL2RenderingContext::FramebufferTextureLayer(const v8::FunctionCallbackInfo<v
1016
1008
 
1017
1009
  auto textureValue = args[2];
1018
1010
  auto type = GetNativeType(isolate, textureValue);
1019
- if (args.Length() > 4 && type == NativeType::WebGLTexture) {
1011
+ if (type == NativeType::WebGLTexture) {
1020
1012
  auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1021
1013
  auto attachment = (uint32_t) args[1]->NumberValue(context).ToChecked();
1022
1014
  auto texture = WebGLTexture::GetPointer(textureValue.As<v8::Object>());
@@ -1081,7 +1073,7 @@ void WebGL2RenderingContext::GetActiveUniformBlockParameter(
1081
1073
  auto programValue = args[0];
1082
1074
  auto type = GetNativeType(isolate, programValue);
1083
1075
 
1084
- if (args.Length() > 2 && type == NativeType::WebGLProgram) {
1076
+ if (type == NativeType::WebGLProgram) {
1085
1077
  auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1086
1078
 
1087
1079
  if (program != nullptr) {
@@ -1154,7 +1146,7 @@ void WebGL2RenderingContext::GetActiveUniforms(const v8::FunctionCallbackInfo<v8
1154
1146
 
1155
1147
  auto programValue = args[0];
1156
1148
  auto type = GetNativeType(isolate, programValue);
1157
- if (args.Length() > 2 && type == NativeType::WebGLProgram) {
1149
+ if (type == NativeType::WebGLProgram) {
1158
1150
 
1159
1151
  auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1160
1152
  auto uniformIndicesObject = args[1];
@@ -1184,14 +1176,14 @@ void WebGL2RenderingContext::GetActiveUniforms(const v8::FunctionCallbackInfo<v8
1184
1176
  auto value = canvas_native_webgl_result_get_u32_array(
1185
1177
  ret);
1186
1178
  auto len = canvas_native_u32_buffer_get_length(value);
1187
- auto buf = canvas_native_u32_buffer_get_bytes(value);
1179
+ auto buffer = canvas_native_u32_buffer_get_bytes(value);
1188
1180
 
1189
1181
  auto array = v8::Array::New(
1190
1182
  isolate, (int) len);
1191
1183
 
1192
1184
  for (int j = 0;
1193
1185
  j < len; ++j) {
1194
- auto item = buf[j];
1186
+ auto item = buffer[j];
1195
1187
  array->Set(
1196
1188
  context, j,
1197
1189
  v8::Number::New(isolate, (double) item));
@@ -1208,12 +1200,12 @@ void WebGL2RenderingContext::GetActiveUniforms(const v8::FunctionCallbackInfo<v8
1208
1200
  auto value = canvas_native_webgl_result_get_i32_array(
1209
1201
  ret);
1210
1202
  auto len = canvas_native_i32_buffer_get_length(value);
1211
- auto buf = canvas_native_i32_buffer_get_bytes(value);
1203
+ auto buffer = canvas_native_i32_buffer_get_bytes(value);
1212
1204
  auto array = v8::Array::New(
1213
1205
  isolate, (int) len);
1214
1206
  for (int j = 0;
1215
1207
  j < len; ++j) {
1216
- auto item = buf[j];
1208
+ auto item = buffer[j];
1217
1209
  array->Set(
1218
1210
  context, j,
1219
1211
  v8::Number::New(isolate,
@@ -1228,14 +1220,14 @@ void WebGL2RenderingContext::GetActiveUniforms(const v8::FunctionCallbackInfo<v8
1228
1220
  auto value = canvas_native_webgl_result_get_bool_array(
1229
1221
  ret);
1230
1222
  auto len = canvas_native_u8_buffer_get_length(value);
1231
- auto buf = canvas_native_u8_buffer_get_bytes(value);
1223
+ auto buffer = canvas_native_u8_buffer_get_bytes(value);
1232
1224
  auto array = v8::Array::New(
1233
1225
  isolate,
1234
1226
  (int) len);
1235
1227
  for (int j = 0;
1236
1228
  j < len; ++j) {
1237
1229
  bool item =
1238
- buf[j] == 1;
1230
+ buffer[j] == 1;
1239
1231
  array->Set(
1240
1232
  context, j,
1241
1233
  v8::Boolean::New(isolate, item));
@@ -1267,50 +1259,46 @@ void WebGL2RenderingContext::GetBufferSubData(const v8::FunctionCallbackInfo<v8:
1267
1259
  auto context = isolate->GetCurrentContext();
1268
1260
 
1269
1261
  auto dstDataObject = args[2];
1270
- if (args.Length() >= 3 &&
1271
- dstDataObject->IsObject()) {
1262
+ if (dstDataObject->IsArrayBufferView()) {
1272
1263
  auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1273
1264
  auto srcByteOffset = args[1]->NumberValue(context).ToChecked();
1274
1265
 
1275
- if (dstDataObject->IsArrayBufferView()) {
1276
-
1277
- auto array = dstDataObject.As<v8::ArrayBufferView>();
1278
-
1279
- auto buf = array->Buffer();
1280
- auto offset = array->ByteOffset();
1281
- auto size = buf->ByteLength();
1282
- auto data = reinterpret_cast<uint8_t *>(buf->GetBackingStore()->Data()) + offset;
1266
+ auto array = dstDataObject.As<v8::ArrayBufferView>();
1283
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;
1284
1272
 
1285
1273
 
1286
- auto BYTES_PER_ELEMENT = (ssize_t) array->Get(
1287
- context,
1288
- ConvertToV8String(isolate, "BYTES_PER_ELEMENT")).ToLocalChecked()->NumberValue(
1289
- context).ToChecked();
1290
1274
 
1291
- ssize_t dstOffsetValue = 0;
1292
- if (args[3]->IsNumber()) {
1293
- dstOffsetValue =
1294
- static_cast<ssize_t>(args[3]->NumberValue(context).ToChecked()) *
1295
- BYTES_PER_ELEMENT;
1296
- }
1275
+ auto BYTES_PER_ELEMENT = (ssize_t) array->Get(
1276
+ context,
1277
+ ConvertToV8String(isolate, "BYTES_PER_ELEMENT")).ToLocalChecked()->NumberValue(
1278
+ context).ToChecked();
1297
1279
 
1298
- ssize_t lengthValue = 0;
1299
- if (args[4]->IsNumber()) {
1300
- lengthValue =
1301
- static_cast<ssize_t>(args[4]->NumberValue(context).ToChecked()) *
1302
- BYTES_PER_ELEMENT;
1303
- }
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
+ }
1304
1286
 
1305
- canvas_native_webgl2_get_buffer_sub_data(
1306
- target,
1307
- static_cast<ssize_t>(srcByteOffset),
1308
- data, size,
1309
- dstOffsetValue,
1310
- lengthValue,
1311
- ptr->GetState()
1312
- );
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;
1313
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
+ );
1314
1302
  }
1315
1303
  }
1316
1304
 
@@ -1357,41 +1345,38 @@ void WebGL2RenderingContext::GetIndexedParameter(const v8::FunctionCallbackInfo<
1357
1345
  auto isolate = args.GetIsolate();
1358
1346
  auto context = isolate->GetCurrentContext();
1359
1347
 
1360
- if (args.Length() > 1) {
1361
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1362
- auto index = (uint32_t) args[1]->NumberValue(context).ToChecked();
1363
- auto ret = canvas_native_webgl2_get_indexed_parameter(
1364
- target,
1365
- index,
1366
- ptr->GetState()
1367
- );
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
+ );
1368
1355
 
1369
- switch (target) {
1370
- case GL_UNIFORM_BUFFER_BINDING:
1371
- case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: {
1372
- auto buffer = canvas_native_webgl2_indexed_parameter_get_buffer_value(
1373
- ret);
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);
1374
1361
 
1375
- args.GetReturnValue().Set(
1376
- WebGLBuffer::NewInstance(isolate, new WebGLBuffer(buffer)));
1377
- }
1378
- return;
1379
- case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
1380
- case GL_TRANSFORM_FEEDBACK_BUFFER_START:
1381
- case GL_UNIFORM_BUFFER_SIZE:
1382
- case GL_UNIFORM_BUFFER_START: {
1383
- auto value = canvas_native_webgl2_indexed_parameter_get_value(
1384
- ret);
1385
- args.GetReturnValue().Set(static_cast<double>(value));
1386
- return;
1387
- }
1388
- break;
1389
- default:
1390
- args.GetReturnValue().SetNull();
1391
- return;
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;
1392
1374
  }
1375
+ break;
1376
+ default:
1377
+ args.GetReturnValue().SetNull();
1378
+ return;
1393
1379
  }
1394
- args.GetReturnValue().SetNull();
1395
1380
  }
1396
1381
 
1397
1382
  void WebGL2RenderingContext::GetInternalformatParameter(
@@ -1405,102 +1390,99 @@ void WebGL2RenderingContext::GetInternalformatParameter(
1405
1390
  auto isolate = args.GetIsolate();
1406
1391
  auto context = isolate->GetCurrentContext();
1407
1392
 
1408
- if (args.Length() > 2) {
1409
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1410
- auto internalformat = (uint32_t) args[1]->NumberValue(context).ToChecked();
1411
- auto pname = (uint32_t) args[2]->NumberValue(context).ToChecked();
1412
- switch (internalformat) {
1413
- case GL_RGB:
1414
- case GL_RGBA:
1415
- case GL_R8UI:
1416
- case GL_R8I:
1417
- case GL_R16UI:
1418
- case GL_R16I:
1419
- case GL_R32UI:
1420
- case GL_R32I:
1421
- case GL_RG8UI:
1422
- case GL_RG8I:
1423
- case GL_RG16UI:
1424
- case GL_RG16I:
1425
- case GL_RG32UI:
1426
- case GL_RG32I:
1427
- case GL_RGBA8UI:
1428
- case GL_RGBA8I:
1429
- case GL_RGB10_A2UI:
1430
- case GL_RGBA16UI:
1431
- case GL_RGBA16I:
1432
- case GL_RGBA32UI:
1433
- case GL_RGBA32I: {
1434
- // empty
1435
- auto arraybuffer = v8::ArrayBuffer::New(isolate, 0);
1436
-
1437
- args.GetReturnValue().Set(v8::Int32Array::New(arraybuffer, 0, 0));
1438
- return;
1439
- }
1440
- case GL_R8:
1441
- case GL_RG8:
1442
- case GL_RGB565:
1443
- case GL_RGBA8:
1444
- case GL_SRGB8_ALPHA8:
1445
- case GL_RGB5_A1:
1446
- case GL_RGBA4:
1447
- case GL_RGB10_A2:
1448
- case GL_DEPTH_COMPONENT16:
1449
- case GL_DEPTH_COMPONENT24:
1450
- case GL_DEPTH_COMPONENT32F:
1451
- case GL_DEPTH24_STENCIL8:
1452
- case GL_DEPTH32F_STENCIL8:
1453
- case GL_STENCIL_INDEX8:
1454
- // noop
1455
- break;
1456
- case GL_R16F:
1457
- case GL_RG16F:
1458
- case GL_R32F:
1459
- case GL_RG32F:
1460
- case GL_RGBA32F:
1461
- case GL_R11F_G11F_B10F:
1462
- // noop
1463
- break;
1464
- default:
1465
- args.GetReturnValue().SetNull();
1466
- return;
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;
1467
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
+ }
1468
1452
 
1469
1453
 
1470
- auto ret = canvas_native_webgl2_get_internalformat_parameter(
1471
- target,
1472
- internalformat,
1473
- pname,
1474
- ptr->GetState()
1475
- );
1454
+ auto ret = canvas_native_webgl2_get_internalformat_parameter(
1455
+ target,
1456
+ internalformat,
1457
+ pname,
1458
+ ptr->GetState()
1459
+ );
1476
1460
 
1477
- if (pname == GL_SAMPLES) {
1478
- auto value = canvas_native_webgl_result_get_i32_array(ret);
1461
+ if (pname == GL_SAMPLES) {
1462
+ auto value = canvas_native_webgl_result_get_i32_array(ret);
1479
1463
 
1480
- auto buf = (uint8_t*)canvas_native_i32_buffer_get_bytes(value);
1481
- auto size = canvas_native_i32_buffer_get_length(value);
1482
- auto bytes_size = size * sizeof(int32_t);
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);
1483
1467
 
1484
- auto store = v8::ArrayBuffer::NewBackingStore(buf, bytes_size,
1485
- [](void *data, size_t length,
1486
- void *deleter_data) {
1487
- if (deleter_data != nullptr) {
1488
- canvas_native_i32_buffer_destroy((I32Buffer *) deleter_data);
1489
- }
1490
- },
1491
- value);
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);
1492
1476
 
1493
- auto arraybuffer = v8::ArrayBuffer::New(isolate, std::move(store));
1494
- args.GetReturnValue().Set(v8::Int32Array::New(arraybuffer, 0, size));
1495
- canvas_native_webgl_WebGLResult_destroy(ret);
1496
- return;
1497
- } else {
1498
- args.GetReturnValue().SetNull();
1499
- canvas_native_webgl_WebGLResult_destroy(ret);
1500
- return;
1501
- }
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;
1502
1485
  }
1503
- args.GetReturnValue().SetNull();
1504
1486
  }
1505
1487
 
1506
1488
  void WebGL2RenderingContext::GetParameter(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -1513,33 +1495,29 @@ void WebGL2RenderingContext::GetParameter(const v8::FunctionCallbackInfo<v8::Val
1513
1495
  auto isolate = args.GetIsolate();
1514
1496
  auto context = isolate->GetCurrentContext();
1515
1497
 
1516
- if (args.Length() > 0) {
1517
- auto pname = (uint32_t) args[0]->NumberValue(context).ToChecked();
1518
- auto result = canvas_native_webgl2_get_parameter(
1519
- pname,
1520
- ptr->GetState());
1521
- switch (pname) {
1522
- case GL_COPY_READ_BUFFER_BINDING:
1523
- case GL_COPY_WRITE_BUFFER_BINDING:
1524
- case GL_DRAW_FRAMEBUFFER_BINDING:
1525
- args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1526
- result));
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));
1527
1508
 
1528
- canvas_native_webgl_WebGLResult_destroy(result);
1529
- return;
1530
- default: {
1531
- auto ret = ptr->GetParameterInternal(
1532
- isolate, pname,result);
1509
+ canvas_native_webgl_WebGLResult_destroy(result);
1510
+ return;
1511
+ default: {
1512
+ auto ret = ptr->GetParameterInternal(
1513
+ isolate, pname,result);
1533
1514
 
1534
- canvas_native_webgl_WebGLResult_destroy(result);
1515
+ canvas_native_webgl_WebGLResult_destroy(result);
1535
1516
 
1536
- args.GetReturnValue().Set(ret);
1537
- return;
1538
- }
1517
+ args.GetReturnValue().Set(ret);
1518
+ return;
1539
1519
  }
1540
1520
  }
1541
-
1542
- args.GetReturnValue().SetNull();
1543
1521
  }
1544
1522
 
1545
1523
  void WebGL2RenderingContext::GetQueryParameter(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -1552,37 +1530,34 @@ void WebGL2RenderingContext::GetQueryParameter(const v8::FunctionCallbackInfo<v8
1552
1530
  auto isolate = args.GetIsolate();
1553
1531
  auto context = isolate->GetCurrentContext();
1554
1532
 
1555
- if (args.Length() > 1) {
1556
- auto queryValue = args[0];
1557
- auto type = GetNativeType(isolate, queryValue);
1558
- if (type == NativeType::WebGLQuery) {
1559
- auto query = WebGLQuery::GetPointer(queryValue.As<v8::Object>());
1560
- if (query != nullptr) {
1561
- auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
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();
1562
1539
 
1563
1540
 
1564
- auto ret = canvas_native_webgl2_get_query_parameter(
1565
- query->GetQuery(),
1566
- pname,
1567
- ptr->GetState());
1568
- if (pname == GL_QUERY_RESULT) {
1569
- args.GetReturnValue().Set(canvas_native_webgl_result_get_bool(
1570
- ret));
1571
- canvas_native_webgl_WebGLResult_destroy(ret);
1572
- return;
1573
- } else if (pname ==
1574
- GL_QUERY_RESULT_AVAILABLE) {
1575
- args.GetReturnValue().Set((int32_t) canvas_native_webgl_result_get_u32(
1576
- ret));
1577
- canvas_native_webgl_WebGLResult_destroy(ret);
1578
- return;
1579
- }
1580
- //clean up
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));
1581
1548
  canvas_native_webgl_WebGLResult_destroy(ret);
1582
-
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;
1583
1556
  }
1584
- }
1557
+ //clean up
1558
+ canvas_native_webgl_WebGLResult_destroy(ret);
1585
1559
 
1560
+ }
1586
1561
  }
1587
1562
 
1588
1563
  args.GetReturnValue().SetNull();
@@ -1598,24 +1573,20 @@ void WebGL2RenderingContext::GetQuery(const v8::FunctionCallbackInfo<v8::Value>
1598
1573
  auto isolate = args.GetIsolate();
1599
1574
  auto context = isolate->GetCurrentContext();
1600
1575
 
1601
- if (args.Length() > 1) {
1602
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1603
- auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
1604
- auto ret = canvas_native_webgl2_get_query(
1605
- target,
1606
- pname,
1607
- ptr->GetState());
1608
- if (pname == GL_CURRENT_QUERY) {
1609
- args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1610
- ret));
1611
- canvas_native_webgl_WebGLResult_destroy(ret);
1612
- return;
1613
- }
1614
- // clean up
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));
1615
1585
  canvas_native_webgl_WebGLResult_destroy(ret);
1586
+ return;
1616
1587
  }
1617
-
1618
- args.GetReturnValue().SetNull();
1588
+ // clean up
1589
+ canvas_native_webgl_WebGLResult_destroy(ret);
1619
1590
  }
1620
1591
 
1621
1592
  void WebGL2RenderingContext::GetSamplerParameter(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -1628,45 +1599,42 @@ void WebGL2RenderingContext::GetSamplerParameter(const v8::FunctionCallbackInfo<
1628
1599
  auto isolate = args.GetIsolate();
1629
1600
  auto context = isolate->GetCurrentContext();
1630
1601
 
1631
- if (args.Length() > 1) {
1632
- auto samplerValue = args[0];
1633
- auto type = GetNativeType(isolate, samplerValue);
1634
- if (type == NativeType::WebGLSampler) {
1635
- auto sampler = WebGLSampler::GetPointer(samplerValue.As<v8::Object>());
1636
- if (sampler != nullptr) {
1637
- auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
1638
- auto ret = canvas_native_webgl2_get_sampler_parameter(
1639
- sampler->GetSampler(),
1640
- pname,
1641
- ptr->GetState());
1642
-
1643
- switch (pname) {
1644
- case GL_TEXTURE_MAX_LOD:
1645
- case GL_TEXTURE_MIN_LOD:
1646
- args.GetReturnValue().Set(
1647
- static_cast<double>(canvas_native_webgl_result_get_f32(
1648
- ret)));
1649
- canvas_native_webgl_WebGLResult_destroy(ret);
1650
- return;
1651
- case GL_TEXTURE_COMPARE_FUNC:
1652
- case GL_TEXTURE_COMPARE_MODE:
1653
- case GL_TEXTURE_MAG_FILTER:
1654
- case GL_TEXTURE_MIN_FILTER:
1655
- case GL_TEXTURE_WRAP_R:
1656
- case GL_TEXTURE_WRAP_S:
1657
- case GL_TEXTURE_WRAP_T:
1658
- args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1659
- ret));
1660
- canvas_native_webgl_WebGLResult_destroy(ret);
1661
- return;
1662
- default:
1663
- args.GetReturnValue().SetNull();
1664
- canvas_native_webgl_WebGLResult_destroy(ret);
1665
- return;
1666
- }
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;
1667
1636
  }
1668
1637
  }
1669
-
1670
1638
  }
1671
1639
 
1672
1640
  args.GetReturnValue().SetNull();
@@ -1682,34 +1650,31 @@ void WebGL2RenderingContext::GetSyncParameter(const v8::FunctionCallbackInfo<v8:
1682
1650
  auto isolate = args.GetIsolate();
1683
1651
  auto context = isolate->GetCurrentContext();
1684
1652
 
1685
- if (args.Length() > 1) {
1686
- auto syncValue = args[0];
1687
- auto sync = WebGLSyncImpl::GetPointer(syncValue.As<v8::Object>());
1688
- if (sync != nullptr) {
1689
- auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
1690
- auto ret = canvas_native_webgl2_get_sync_parameter(
1691
- sync->GetSync(),
1692
- pname,
1693
- ptr->GetState());
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());
1694
1661
 
1695
- switch (pname) {
1696
- case GL_OBJECT_TYPE:
1697
- case GL_SYNC_STATUS:
1698
- case GL_SYNC_CONDITION:
1699
- case GL_SYNC_FLAGS:
1700
- args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1701
- ret));
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));
1702
1669
 
1703
- canvas_native_webgl_WebGLResult_destroy(ret);
1704
- return;
1705
- default:
1706
- args.GetReturnValue().SetNull();
1707
- canvas_native_webgl_WebGLResult_destroy(ret);
1708
- return;
1709
- }
1670
+ canvas_native_webgl_WebGLResult_destroy(ret);
1671
+ return;
1672
+ default:
1673
+ args.GetReturnValue().SetNull();
1674
+ canvas_native_webgl_WebGLResult_destroy(ret);
1675
+ return;
1710
1676
  }
1711
1677
  }
1712
-
1713
1678
  args.GetReturnValue().SetNull();
1714
1679
  }
1715
1680
 
@@ -1724,30 +1689,28 @@ void WebGL2RenderingContext::GetTransformFeedbackVarying(
1724
1689
  auto isolate = args.GetIsolate();
1725
1690
  auto context = isolate->GetCurrentContext();
1726
1691
 
1727
- if (args.Length() > 1) {
1728
- auto programValue = args[0];
1729
- auto type = GetNativeType(isolate, programValue);
1730
- if (type == NativeType::WebGLProgram) {
1731
- auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1732
- auto index = (uint32_t) args[1]->NumberValue(context).ToChecked();
1733
- if (program != nullptr) {
1734
- auto ret = canvas_native_webgl2_get_transform_feedback_varying(
1735
- program->GetProgram(),
1736
- index,
1737
- ptr->GetState()
1738
- );
1739
-
1740
- if (canvas_native_webgl_active_info_get_is_empty(
1741
- ret)) {
1742
- canvas_native_webgl_active_info_destroy(ret);
1743
- args.GetReturnValue().SetNull();
1744
- return;
1745
- }
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
+ );
1746
1703
 
1747
- auto info = WebGLActiveInfoImpl::NewInstance(isolate, new WebGLActiveInfoImpl(ret));
1748
- args.GetReturnValue().Set(info);
1704
+ if (canvas_native_webgl_active_info_get_is_empty(
1705
+ ret)) {
1706
+ canvas_native_webgl_active_info_destroy(ret);
1707
+ args.GetReturnValue().SetNull();
1749
1708
  return;
1750
1709
  }
1710
+
1711
+ auto info = WebGLActiveInfoImpl::NewInstance(isolate, new WebGLActiveInfoImpl(ret));
1712
+ args.GetReturnValue().Set(info);
1713
+ return;
1751
1714
  }
1752
1715
  }
1753
1716
 
@@ -1764,22 +1727,19 @@ void WebGL2RenderingContext::GetUniformBlockIndex(const v8::FunctionCallbackInfo
1764
1727
  auto isolate = args.GetIsolate();
1765
1728
  auto context = isolate->GetCurrentContext();
1766
1729
 
1767
- if (args.Length() > 1) {
1768
- auto programValue = args[0];
1769
- auto type = GetNativeType(isolate, programValue);
1770
- if (type == NativeType::WebGLProgram) {
1771
- auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1772
- auto index = ConvertFromV8String(isolate, args[1]);
1773
- if (program != nullptr) {
1774
- auto ret = canvas_native_webgl2_get_uniform_block_index(
1775
- program->GetProgram(),
1776
- index.c_str(),
1777
- ptr->GetState());
1778
- args.GetReturnValue().Set((int) ret);
1779
- return;
1780
- }
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;
1781
1742
  }
1782
-
1783
1743
  }
1784
1744
 
1785
1745
  args.GetReturnValue().SetNull();
@@ -1795,58 +1755,55 @@ void WebGL2RenderingContext::GetUniformIndices(const v8::FunctionCallbackInfo<v8
1795
1755
  auto isolate = args.GetIsolate();
1796
1756
  auto context = isolate->GetCurrentContext();
1797
1757
 
1798
- if (args.Length() > 1 && args[1]->IsObject()) {
1799
- auto programValue = args[0];
1800
- auto type = GetNativeType(isolate, programValue);
1801
- if (type == NativeType::WebGLProgram) {
1802
- auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1803
- auto uniformNamesObject = args[1];
1804
- if (program != nullptr &&
1805
- uniformNamesObject->IsArray()) {
1806
- auto uniformNames = uniformNamesObject.As<v8::Array>();
1807
- auto len = uniformNames->Length();
1808
-
1809
- std::vector<std::string> store;
1810
- store.reserve(len);
1811
-
1812
- for (int j = 0; j < len; ++j) {
1813
- auto name = ConvertFromV8String(isolate, uniformNames->Get(
1814
- context, j).ToLocalChecked());
1815
-
1816
- store.push_back(name);
1817
- }
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();
1818
1767
 
1768
+ std::vector<std::string> store;
1769
+ store.reserve(len);
1819
1770
 
1820
- const char* cStrings[store.size()];
1821
- for (size_t i = 0; i < store.size(); ++i) {
1822
- cStrings[i] = store[i].c_str();
1823
- }
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
+ }
1824
1777
 
1825
1778
 
1826
- auto ret = canvas_native_webgl2_get_uniform_indices(
1827
- program->GetProgram(),
1828
- cStrings,
1829
- store.size(),
1830
- ptr->GetState());
1779
+ const char* cStrings[store.size()];
1780
+ for (size_t i = 0; i < store.size(); ++i) {
1781
+ cStrings[i] = store[i].c_str();
1782
+ }
1831
1783
 
1832
1784
 
1833
- auto retSize = canvas_native_u32_buffer_get_length(ret);
1834
- auto buf = canvas_native_u32_buffer_get_bytes(ret);
1835
- auto result = v8::Array::New(isolate, (int) retSize);
1836
- for (int j = 0; j < retSize; ++j) {
1837
- auto item = buf[j];
1838
- result->Set(context,
1839
- j,
1840
- v8::Number::New(isolate,
1841
- (int32_t) item));
1842
- }
1785
+ auto ret = canvas_native_webgl2_get_uniform_indices(
1786
+ program->GetProgram(),
1787
+ cStrings,
1788
+ store.size(),
1789
+ ptr->GetState());
1843
1790
 
1844
- args.GetReturnValue().Set(result);
1845
- canvas_native_u32_buffer_destroy(ret);
1846
- return;
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));
1847
1801
  }
1848
- }
1849
1802
 
1803
+ args.GetReturnValue().Set(result);
1804
+ canvas_native_u32_buffer_destroy(ret);
1805
+ return;
1806
+ }
1850
1807
  }
1851
1808
 
1852
1809
  args.GetReturnValue().SetNull();
@@ -1863,24 +1820,22 @@ WebGL2RenderingContext::InvalidateFramebuffer(const v8::FunctionCallbackInfo<v8:
1863
1820
  auto context = isolate->GetCurrentContext();
1864
1821
 
1865
1822
  auto attachments = args[1];
1866
- if (args.Length() > 1 && attachments->IsObject()) {
1867
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1823
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1868
1824
 
1869
- if (attachments->IsArray()) {
1870
- auto array = attachments.As<v8::Array>();
1871
- auto len = array->Length();
1872
- std::vector<uint32_t> buf;
1873
- buf.reserve(len);
1874
- for (int j = 0; j < len; ++j) {
1875
- auto item = (uint32_t) array->Get(
1876
- context, j).ToLocalChecked()->NumberValue(context).ToChecked();
1877
- buf.push_back(item);
1878
- }
1879
-
1880
- canvas_native_webgl2_invalidate_framebuffer(
1881
- target, buf.data(), buf.size(),
1882
- ptr->GetState());
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);
1883
1834
  }
1835
+
1836
+ canvas_native_webgl2_invalidate_framebuffer(
1837
+ target, buf.data(), buf.size(),
1838
+ ptr->GetState());
1884
1839
  }
1885
1840
  }
1886
1841
 
@@ -1894,36 +1849,32 @@ WebGL2RenderingContext::InvalidateSubFramebuffer(const v8::FunctionCallbackInfo<
1894
1849
  auto isolate = args.GetIsolate();
1895
1850
  auto context = isolate->GetCurrentContext();
1896
1851
 
1897
- if (args.Length() > 5 && args[1]->IsObject()) {
1898
- auto attachments = args[1];
1899
- if (attachments->IsArray()) {
1900
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1901
- auto x = (int32_t) args[2]->NumberValue(context).ToChecked();
1902
- auto y = (int32_t) args[3]->NumberValue(context).ToChecked();
1903
- auto width = (int32_t) args[4]->NumberValue(context).ToChecked();
1904
- auto height = (int32_t) args[5]->NumberValue(context).ToChecked();
1905
-
1906
- auto array = attachments.As<v8::Array>();
1907
- auto len = array->Length();
1908
- std::vector<uint32_t> buf;
1909
- buf.reserve(len);
1910
- for (int j = 0; j < len; ++j) {
1911
- auto item = (uint32_t) array->Get(
1912
- context, j).ToLocalChecked()->NumberValue(context).ToChecked();
1913
- buf.push_back(item);
1914
- }
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();
1915
1859
 
1916
- canvas_native_webgl2_invalidate_sub_framebuffer(
1917
- target,
1918
- buf.data(), buf.size(),
1919
- x,
1920
- y,
1921
- width,
1922
- height,
1923
- ptr->GetState());
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);
1924
1868
  }
1925
1869
 
1926
-
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());
1927
1878
  }
1928
1879
  }
1929
1880
 
@@ -2071,13 +2022,11 @@ void WebGL2RenderingContext::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value
2071
2022
  auto isolate = args.GetIsolate();
2072
2023
  auto context = isolate->GetCurrentContext();
2073
2024
 
2074
- if (args.Length() > 0) {
2075
- auto src = (uint32_t) args[0]->NumberValue(context).ToChecked();
2076
- canvas_native_webgl2_read_buffer(
2077
- src,
2078
- ptr->GetState()
2079
- );
2080
- }
2025
+ auto src = (uint32_t) args[0]->NumberValue(context).ToChecked();
2026
+ canvas_native_webgl2_read_buffer(
2027
+ src,
2028
+ ptr->GetState()
2029
+ );
2081
2030
  }
2082
2031
 
2083
2032
  void WebGL2RenderingContext::RenderbufferStorageMultisample(
@@ -2090,21 +2039,19 @@ void WebGL2RenderingContext::RenderbufferStorageMultisample(
2090
2039
  auto isolate = args.GetIsolate();
2091
2040
  auto context = isolate->GetCurrentContext();
2092
2041
 
2093
- if (args.Length() > 4) {
2094
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
2095
- auto samples = (int32_t) args[1]->NumberValue(context).ToChecked();
2096
- auto internalFormat = (uint32_t) args[2]->NumberValue(context).ToChecked();
2097
- auto width = (int32_t) args[3]->NumberValue(context).ToChecked();
2098
- auto height = (int32_t) args[4]->NumberValue(context).ToChecked();
2099
- canvas_native_webgl2_renderbuffer_storage_multisample(
2100
- target,
2101
- samples,
2102
- internalFormat,
2103
- width,
2104
- height,
2105
- ptr->GetState()
2106
- );
2107
- }
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
+ );
2108
2055
  }
2109
2056
 
2110
2057
  void
@@ -2127,22 +2074,19 @@ void WebGL2RenderingContext::SamplerParameterf(const v8::FunctionCallbackInfo<v8
2127
2074
  auto isolate = args.GetIsolate();
2128
2075
  auto context = isolate->GetCurrentContext();
2129
2076
 
2130
- if (args.Length() > 2) {
2131
- auto samplerValue = args[0];
2132
- auto type = GetNativeType(isolate, samplerValue);
2133
- if (type == NativeType::WebGLSampler) {
2134
- auto sampler = WebGLSampler::GetPointer(samplerValue.As<v8::Object>());
2135
- auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
2136
- auto param = args[2]->NumberValue(context).ToChecked();
2137
- if (sampler != nullptr) {
2138
- canvas_native_webgl2_sampler_parameterf(
2139
- sampler->GetSampler(),
2140
- pname,
2141
- static_cast<float>(param),
2142
- ptr->GetState());
2143
- }
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());
2144
2089
  }
2145
-
2146
2090
  }
2147
2091
 
2148
2092
  }
@@ -2156,22 +2100,19 @@ void WebGL2RenderingContext::SamplerParameteri(const v8::FunctionCallbackInfo<v8
2156
2100
  auto isolate = args.GetIsolate();
2157
2101
  auto context = isolate->GetCurrentContext();
2158
2102
 
2159
- if (args.Length() > 2) {
2160
- auto samplerValue = args[0];
2161
- auto type = GetNativeType(isolate, samplerValue);
2162
- if (type == NativeType::WebGLSampler) {
2163
- auto sampler = WebGLSampler::GetPointer(samplerValue.As<v8::Object>());
2164
- auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
2165
- auto param = (int32_t) args[2]->NumberValue(context).ToChecked();
2166
- if (sampler != nullptr) {
2167
- canvas_native_webgl2_sampler_parameteri(
2168
- sampler->GetSampler(),
2169
- pname,
2170
- param,
2171
- ptr->GetState());
2172
- }
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());
2173
2115
  }
2174
-
2175
2116
  }
2176
2117
 
2177
2118
  }
@@ -2381,26 +2322,24 @@ void WebGL2RenderingContext::TexStorage2D(const v8::FunctionCallbackInfo<v8::Val
2381
2322
  auto isolate = args.GetIsolate();
2382
2323
  auto context = isolate->GetCurrentContext();
2383
2324
 
2384
- if (args.Length() > 4) {
2385
- auto target = (uint32_t) args[0]->NumberValue(
2386
- context).ToChecked();
2387
- auto levels = (int32_t) args[1]->NumberValue(
2388
- context).ToChecked();
2389
- auto internalFormat = (uint32_t) args[2]->NumberValue(
2390
- context).ToChecked();
2391
- auto width = (int32_t) args[3]->NumberValue(
2392
- context).ToChecked();
2393
- auto height = (int32_t) args[4]->NumberValue(
2394
- context).ToChecked();
2395
- canvas_native_webgl2_tex_storage2d(
2396
- target,
2397
- levels,
2398
- internalFormat,
2399
- width,
2400
- height,
2401
- ptr->GetState()
2402
- );
2403
- }
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
+ );
2404
2343
  }
2405
2344
 
2406
2345
  void WebGL2RenderingContext::TexStorage3D(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -2412,29 +2351,27 @@ void WebGL2RenderingContext::TexStorage3D(const v8::FunctionCallbackInfo<v8::Val
2412
2351
  auto isolate = args.GetIsolate();
2413
2352
  auto context = isolate->GetCurrentContext();
2414
2353
 
2415
- if (args.Length() > 5) {
2416
- auto target = (uint32_t) args[0]->NumberValue(
2417
- context).ToChecked();
2418
- auto levels = (int32_t) args[1]->NumberValue(
2419
- context).ToChecked();
2420
- auto internalFormat = (uint32_t) args[2]->NumberValue(
2421
- context).ToChecked();
2422
- auto width = (int32_t) args[3]->NumberValue(
2423
- context).ToChecked();
2424
- auto height = (int32_t) args[4]->NumberValue(
2425
- context).ToChecked();
2426
- auto depth = (int32_t) args[5]->NumberValue(
2427
- context).ToChecked();
2428
- canvas_native_webgl2_tex_storage3d(
2429
- target,
2430
- levels,
2431
- internalFormat,
2432
- width,
2433
- height,
2434
- depth,
2435
- ptr->GetState()
2436
- );
2437
- }
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
+ );
2438
2375
  }
2439
2376
 
2440
2377
  void WebGL2RenderingContext::TexSubImage3D(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -2624,7 +2561,7 @@ WebGL2RenderingContext::TransformFeedbackVaryings(const v8::FunctionCallbackInfo
2624
2561
 
2625
2562
  auto programValue = args[0];
2626
2563
  auto type = GetNativeType(isolate, programValue);
2627
- if (args.Length() > 2 && type == NativeType::WebGLProgram) {
2564
+ if (type == NativeType::WebGLProgram) {
2628
2565
  auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2629
2566
  auto varyingsObject = args[1];
2630
2567
  auto bufferMode = (uint32_t) args[2]->NumberValue(
@@ -2675,11 +2612,11 @@ void WebGL2RenderingContext::Uniform1ui(const v8::FunctionCallbackInfo<v8::Value
2675
2612
  auto locationValue = args[0];
2676
2613
  auto type = GetNativeType(isolate, locationValue);
2677
2614
 
2678
- if (args.Length() > 1 &&
2679
- args[1]->IsNumber() && type == NativeType::WebGLUniformLocation) {
2615
+ auto v0Value = args[1];
2616
+ if (type == NativeType::WebGLUniformLocation) {
2680
2617
 
2681
2618
  auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2682
- auto v0 = (uint32_t) args[1]->NumberValue(
2619
+ auto v0 = (uint32_t) v0Value->NumberValue(
2683
2620
  context).ToChecked();
2684
2621
 
2685
2622
  if (location != nullptr) {
@@ -2705,8 +2642,7 @@ void WebGL2RenderingContext::Uniform2ui(const v8::FunctionCallbackInfo<v8::Value
2705
2642
  auto locationValue = args[0];
2706
2643
  auto type = GetNativeType(isolate, locationValue);
2707
2644
 
2708
- if (args.Length() > 2 &&
2709
- args[1]->IsNumber() && type == NativeType::WebGLUniformLocation) {
2645
+ if (type == NativeType::WebGLUniformLocation) {
2710
2646
 
2711
2647
  auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2712
2648
  auto v0 = (uint32_t) args[1]->NumberValue(
@@ -2738,8 +2674,7 @@ void WebGL2RenderingContext::Uniform3ui(const v8::FunctionCallbackInfo<v8::Value
2738
2674
  auto locationValue = args[0];
2739
2675
  auto type = GetNativeType(isolate, locationValue);
2740
2676
 
2741
- if (args.Length() > 3 &&
2742
- args[1]->IsNumber() && type == NativeType::WebGLUniformLocation) {
2677
+ if (type == NativeType::WebGLUniformLocation) {
2743
2678
 
2744
2679
  auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2745
2680
  auto v0 = (uint32_t) args[1]->NumberValue(
@@ -2776,8 +2711,7 @@ void WebGL2RenderingContext::Uniform4ui(const v8::FunctionCallbackInfo<v8::Value
2776
2711
  auto locationValue = args[0];
2777
2712
  auto type = GetNativeType(isolate, locationValue);
2778
2713
 
2779
- if (args.Length() > 1 &&
2780
- args[1]->IsNumber() && type == NativeType::WebGLUniformLocation) {
2714
+ if (type == NativeType::WebGLUniformLocation) {
2781
2715
 
2782
2716
  auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2783
2717
  auto v0 = (uint32_t) args[1]->NumberValue(
@@ -2820,13 +2754,12 @@ void WebGL2RenderingContext::Uniform1uiv(const v8::FunctionCallbackInfo<v8::Valu
2820
2754
  auto type = GetNativeType(isolate, locationValue);
2821
2755
 
2822
2756
 
2823
- if (args.Length() > 1 &&
2824
- args[1]->IsObject() && type == NativeType::WebGLUniformLocation) {
2757
+ if (type == NativeType::WebGLUniformLocation) {
2825
2758
  auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2826
- auto data = args[1];
2759
+ auto dataValue = args[1];
2827
2760
  if (location != nullptr &&
2828
- data->IsUint32Array()) {
2829
- auto buf = data.As<v8::Uint32Array>();
2761
+ dataValue->IsUint32Array()) {
2762
+ auto buf = dataValue.As<v8::Uint32Array>();
2830
2763
  auto array = buf->Buffer();
2831
2764
  auto offset = buf->ByteOffset();
2832
2765
  auto size = buf->Length();
@@ -2841,7 +2774,7 @@ void WebGL2RenderingContext::Uniform1uiv(const v8::FunctionCallbackInfo<v8::Valu
2841
2774
  );
2842
2775
  } else {
2843
2776
  std::vector<uint32_t> buf;
2844
- auto array = data.As<v8::Array>();
2777
+ auto array = dataValue.As<v8::Array>();
2845
2778
  auto len = array->Length();
2846
2779
  buf.reserve(len);
2847
2780
  for (int i = 0; i < len; i++) {
@@ -2878,13 +2811,12 @@ void WebGL2RenderingContext::Uniform2uiv(const v8::FunctionCallbackInfo<v8::Valu
2878
2811
  auto type = GetNativeType(isolate, locationValue);
2879
2812
 
2880
2813
 
2881
- if (args.Length() > 1 &&
2882
- args[1]->IsObject() && type == NativeType::WebGLUniformLocation) {
2814
+ if (type == NativeType::WebGLUniformLocation) {
2883
2815
  auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2884
- auto data = args[1];
2816
+ auto dataValue = args[1];
2885
2817
  if (location != nullptr &&
2886
- data->IsUint32Array()) {
2887
- auto buf = data.As<v8::Uint32Array>();
2818
+ dataValue->IsUint32Array()) {
2819
+ auto buf = dataValue.As<v8::Uint32Array>();
2888
2820
  auto array = buf->Buffer();
2889
2821
  auto offset = buf->ByteOffset();
2890
2822
  auto size = buf->Length();
@@ -2900,7 +2832,7 @@ void WebGL2RenderingContext::Uniform2uiv(const v8::FunctionCallbackInfo<v8::Valu
2900
2832
  );
2901
2833
  } else {
2902
2834
  std::vector<uint32_t> buf;
2903
- auto array = data.As<v8::Array>();
2835
+ auto array = dataValue.As<v8::Array>();
2904
2836
  auto len = array->Length();
2905
2837
  buf.reserve(len);
2906
2838
  for (int i = 0; i < len; i++) {
@@ -2936,13 +2868,12 @@ void WebGL2RenderingContext::Uniform3uiv(const v8::FunctionCallbackInfo<v8::Valu
2936
2868
  auto type = GetNativeType(isolate, locationValue);
2937
2869
 
2938
2870
 
2939
- if (args.Length() > 1 &&
2940
- args[1]->IsObject() && type == NativeType::WebGLUniformLocation) {
2871
+ if (type == NativeType::WebGLUniformLocation) {
2941
2872
  auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2942
- auto data = args[1];
2873
+ auto dataValue = args[1];
2943
2874
  if (location != nullptr &&
2944
- data->IsUint32Array()) {
2945
- auto buf = data.As<v8::Uint32Array>();
2875
+ dataValue->IsUint32Array()) {
2876
+ auto buf = dataValue.As<v8::Uint32Array>();
2946
2877
 
2947
2878
  auto array = buf->Buffer();
2948
2879
  auto offset = buf->ByteOffset();
@@ -2958,7 +2889,7 @@ void WebGL2RenderingContext::Uniform3uiv(const v8::FunctionCallbackInfo<v8::Valu
2958
2889
  );
2959
2890
  } else {
2960
2891
  std::vector<uint32_t> buf;
2961
- auto array = data.As<v8::Array>();
2892
+ auto array = dataValue.As<v8::Array>();
2962
2893
  auto len = array->Length();
2963
2894
  buf.reserve(len);
2964
2895
  for (int i = 0; i < len; i++) {
@@ -2994,13 +2925,12 @@ void WebGL2RenderingContext::Uniform4uiv(const v8::FunctionCallbackInfo<v8::Valu
2994
2925
  auto type = GetNativeType(isolate, locationValue);
2995
2926
 
2996
2927
 
2997
- if (args.Length() > 1 &&
2998
- args[1]->IsObject() && type == NativeType::WebGLUniformLocation) {
2928
+ if (type == NativeType::WebGLUniformLocation) {
2999
2929
  auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3000
- auto data = args[1];
2930
+ auto dataValue = args[1];
3001
2931
  if (location != nullptr &&
3002
- data->IsUint32Array()) {
3003
- auto buf = data.As<v8::Uint32Array>();
2932
+ dataValue->IsUint32Array()) {
2933
+ auto buf = dataValue.As<v8::Uint32Array>();
3004
2934
 
3005
2935
  auto array = buf->Buffer();
3006
2936
  auto offset = buf->ByteOffset();
@@ -3016,7 +2946,7 @@ void WebGL2RenderingContext::Uniform4uiv(const v8::FunctionCallbackInfo<v8::Valu
3016
2946
  );
3017
2947
  } else {
3018
2948
  std::vector<uint32_t> buf;
3019
- auto array = data.As<v8::Array>();
2949
+ auto array = dataValue.As<v8::Array>();
3020
2950
  auto len = array->Length();
3021
2951
  buf.reserve(len);
3022
2952
  for (int i = 0; i < len; i++) {
@@ -3050,7 +2980,7 @@ void WebGL2RenderingContext::UniformBlockBinding(const v8::FunctionCallbackInfo<
3050
2980
 
3051
2981
  auto programValue = args[0];
3052
2982
  auto type = GetNativeType(isolate, programValue);
3053
- if (args.Length() > 2 && type == NativeType::WebGLProgram) {
2983
+ if (type == NativeType::WebGLProgram) {
3054
2984
 
3055
2985
  auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
3056
2986
  auto uniformBlockIndex = args[1]->NumberValue(
@@ -3081,57 +3011,48 @@ void WebGL2RenderingContext::UniformMatrix2x3fv(const v8::FunctionCallbackInfo<v
3081
3011
  auto context = isolate->GetCurrentContext();
3082
3012
 
3083
3013
 
3084
- if (args.Length() > 2 &&
3085
- args[2]->IsObject()) {
3086
- auto locationValue = args[0];
3087
- auto type = GetNativeType(isolate, locationValue);
3088
- if (type == NativeType::WebGLUniformLocation) {
3089
- auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3090
- auto transpose = args[1]->BooleanValue(isolate);
3091
- auto data = args[2];
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];
3092
3020
 
3093
- if (data->IsFloat32Array()) {
3094
- auto buf = data.As<v8::Float32Array>();
3095
- auto array = buf->Buffer();
3096
- auto offset = buf->ByteOffset();
3097
- auto size = buf->Length();
3098
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3099
- auto data = static_cast<float *>((void*) data_ptr);
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);
3100
3028
 
3101
3029
 
3102
- canvas_native_webgl2_uniform_matrix2x3fv(
3103
- location->GetUniformLocation(),
3104
- transpose,
3105
- data, size,
3106
- ptr->GetState()
3107
- );
3108
- } else if (data->IsArray()) {
3109
- std::vector<float> buf;
3110
- auto array = data.As<v8::Array>();
3111
- auto len = array->Length();
3112
- for (int i = 0; i < len; i++) {
3113
- auto item = array->Get(
3114
- context, i).ToLocalChecked();
3115
- if (item->IsNumber()) {
3116
- buf.push_back(
3117
- static_cast<float>(item->NumberValue(
3118
- context).ToChecked()));
3119
- } else {
3120
- buf.push_back(
3121
- std::nanf(""));
3122
- }
3123
- }
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
+ }
3124
3047
 
3125
3048
 
3126
- canvas_native_webgl2_uniform_matrix2x3fv(
3127
- location->GetUniformLocation(),
3128
- transpose,
3129
- buf.data(), buf.size(),
3130
- ptr->GetState()
3131
- );
3132
- }
3049
+ canvas_native_webgl2_uniform_matrix2x3fv(
3050
+ location->GetUniformLocation(),
3051
+ transpose,
3052
+ buf.data(), buf.size(),
3053
+ ptr->GetState()
3054
+ );
3133
3055
  }
3134
-
3135
3056
  }
3136
3057
 
3137
3058
  }
@@ -3146,59 +3067,50 @@ void WebGL2RenderingContext::UniformMatrix2x4fv(const v8::FunctionCallbackInfo<v
3146
3067
  auto context = isolate->GetCurrentContext();
3147
3068
 
3148
3069
 
3149
- if (args.Length() > 2 &&
3150
- args[2]->IsObject()) {
3151
- auto locationValue = args[0];
3152
- auto type = GetNativeType(isolate, locationValue);
3153
- if (type == NativeType::WebGLUniformLocation) {
3154
- auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3155
- auto transpose = args[1]->BooleanValue(isolate);
3156
- auto data = args[2];
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];
3157
3076
 
3158
- if (data->IsFloat32Array()) {
3159
- auto buf = data.As<v8::Float32Array>();
3077
+ if (dataValue->IsFloat32Array()) {
3078
+ auto buf = dataValue.As<v8::Float32Array>();
3160
3079
 
3161
- auto array = buf->Buffer();
3162
- auto offset = buf->ByteOffset();
3163
- auto size = buf->Length();
3164
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3165
- auto data = static_cast<float *>((void*) data_ptr);
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);
3166
3085
 
3167
3086
 
3168
- canvas_native_webgl2_uniform_matrix2x4fv(
3169
- location->GetUniformLocation(),
3170
- transpose,
3171
- data, size,
3172
- ptr->GetState()
3173
- );
3174
- } else if (data->IsArray()) {
3175
- std::vector<float> buf;
3176
- auto array = data.As<v8::Array>();
3177
- auto len = array->Length();
3178
- for (int i = 0; i < len; i++) {
3179
- auto item = array->Get(
3180
- context, i).ToLocalChecked();
3181
- if (item->IsNumber()) {
3182
- buf.push_back(
3183
- static_cast<float>(item->NumberValue(
3184
- context).ToChecked()));
3185
- } else {
3186
- buf.push_back(
3187
- std::nanf(""));
3188
- }
3189
- }
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
+ }
3190
3104
 
3191
3105
 
3192
3106
 
3193
- canvas_native_webgl2_uniform_matrix2x4fv(
3194
- location->GetUniformLocation(),
3195
- transpose,
3196
- buf.data(), buf.size(),
3197
- ptr->GetState()
3198
- );
3199
- }
3107
+ canvas_native_webgl2_uniform_matrix2x4fv(
3108
+ location->GetUniformLocation(),
3109
+ transpose,
3110
+ buf.data(), buf.size(),
3111
+ ptr->GetState()
3112
+ );
3200
3113
  }
3201
-
3202
3114
  }
3203
3115
 
3204
3116
  }
@@ -3213,60 +3125,51 @@ void WebGL2RenderingContext::UniformMatrix3x2fv(const v8::FunctionCallbackInfo<v
3213
3125
  auto context = isolate->GetCurrentContext();
3214
3126
 
3215
3127
 
3216
- if (args.Length() > 2 &&
3217
- args[2]->IsObject()) {
3218
- auto locationValue = args[0];
3219
- auto type = GetNativeType(isolate, locationValue);
3220
- if (type == NativeType::WebGLUniformLocation) {
3221
- auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3222
- auto transpose = args[1]->BooleanValue(isolate);
3223
- auto data = args[2];
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];
3224
3134
 
3225
- if (data->IsFloat32Array()) {
3226
- auto buf = data.As<v8::Float32Array>();
3135
+ if (dataValue->IsFloat32Array()) {
3136
+ auto buf = dataValue.As<v8::Float32Array>();
3227
3137
 
3228
3138
 
3229
- auto array = buf->Buffer();
3230
- auto offset = buf->ByteOffset();
3231
- auto size = buf->Length();
3232
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3233
- auto data = static_cast<float *>((void*) data_ptr);
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);
3234
3144
 
3235
3145
 
3236
- canvas_native_webgl2_uniform_matrix3x2fv(
3237
- location->GetUniformLocation(),
3238
- transpose,
3239
- data, size,
3240
- ptr->GetState()
3241
- );
3242
- } else if (data->IsArray()) {
3243
- std::vector<float> buf;
3244
- auto array = data.As<v8::Array>();
3245
- auto len = array->Length();
3246
- for (int i = 0; i < len; i++) {
3247
- auto item = array->Get(
3248
- context, i).ToLocalChecked();
3249
- if (item->IsNumber()) {
3250
- buf.push_back(
3251
- static_cast<float>(item->NumberValue(
3252
- context).ToChecked()));
3253
- } else {
3254
- buf.push_back(
3255
- std::nanf(""));
3256
- }
3257
- }
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
+ }
3258
3163
 
3259
3164
 
3260
3165
 
3261
- canvas_native_webgl2_uniform_matrix3x2fv(
3262
- location->GetUniformLocation(),
3263
- transpose,
3264
- buf.data(), buf.size(),
3265
- ptr->GetState()
3266
- );
3267
- }
3166
+ canvas_native_webgl2_uniform_matrix3x2fv(
3167
+ location->GetUniformLocation(),
3168
+ transpose,
3169
+ buf.data(), buf.size(),
3170
+ ptr->GetState()
3171
+ );
3268
3172
  }
3269
-
3270
3173
  }
3271
3174
 
3272
3175
  }
@@ -3281,58 +3184,49 @@ void WebGL2RenderingContext::UniformMatrix3x4fv(const v8::FunctionCallbackInfo<v
3281
3184
  auto context = isolate->GetCurrentContext();
3282
3185
 
3283
3186
 
3284
- if (args.Length() > 2 &&
3285
- args[2]->IsObject()) {
3286
- auto locationValue = args[0];
3287
- auto type = GetNativeType(isolate, locationValue);
3288
- if (type == NativeType::WebGLUniformLocation) {
3289
- auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3290
- auto transpose = args[1]->BooleanValue(isolate);
3291
- auto data = args[2];
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];
3292
3193
 
3293
- if (data->IsFloat32Array()) {
3294
- auto buf = data.As<v8::Float32Array>();
3295
- auto array = buf->Buffer();
3296
- auto offset = buf->ByteOffset();
3297
- auto size = buf->Length();
3298
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3299
- auto data = static_cast<float *>((void*) data_ptr);
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);
3300
3201
 
3301
3202
 
3302
- canvas_native_webgl2_uniform_matrix3x4fv(
3303
- location->GetUniformLocation(),
3304
- transpose,
3305
- data, size,
3306
- ptr->GetState()
3307
- );
3308
- } else if (data->IsArray()) {
3309
- std::vector<float> buf;
3310
- auto array = data.As<v8::Array>();
3311
- auto len = array->Length();
3312
- for (int i = 0; i < len; i++) {
3313
- auto item = array->Get(
3314
- context, i).ToLocalChecked();
3315
- if (item->IsNumber()) {
3316
- buf.push_back(
3317
- static_cast<float>(item->NumberValue(
3318
- context).ToChecked()));
3319
- } else {
3320
- buf.push_back(
3321
- std::nanf(""));
3322
- }
3323
- }
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
+ }
3324
3220
 
3325
3221
 
3326
3222
 
3327
- canvas_native_webgl2_uniform_matrix3x4fv(
3328
- location->GetUniformLocation(),
3329
- transpose,
3330
- buf.data(), buf.size(),
3331
- ptr->GetState()
3332
- );
3333
- }
3223
+ canvas_native_webgl2_uniform_matrix3x4fv(
3224
+ location->GetUniformLocation(),
3225
+ transpose,
3226
+ buf.data(), buf.size(),
3227
+ ptr->GetState()
3228
+ );
3334
3229
  }
3335
-
3336
3230
  }
3337
3231
 
3338
3232
  }
@@ -3347,58 +3241,49 @@ void WebGL2RenderingContext::UniformMatrix4x2fv(const v8::FunctionCallbackInfo<v
3347
3241
  auto context = isolate->GetCurrentContext();
3348
3242
 
3349
3243
 
3350
- if (args.Length() > 2 &&
3351
- args[2]->IsObject()) {
3352
- auto locationValue = args[0];
3353
- auto type = GetNativeType(isolate, locationValue);
3354
- if (type == NativeType::WebGLUniformLocation) {
3355
- auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3356
- auto transpose = args[1]->BooleanValue(isolate);
3357
- auto data = args[2];
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];
3358
3250
 
3359
- if (data->IsFloat32Array()) {
3360
- auto buf = data.As<v8::Float32Array>();
3251
+ if (dataValue->IsFloat32Array()) {
3252
+ auto buf = dataValue.As<v8::Float32Array>();
3361
3253
 
3362
- auto array = buf->Buffer();
3363
- auto offset = buf->ByteOffset();
3364
- auto size = buf->Length();
3365
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3366
- auto data = static_cast<float *>((void*) data_ptr);
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);
3367
3259
 
3368
- canvas_native_webgl2_uniform_matrix4x2fv(
3369
- location->GetUniformLocation(),
3370
- transpose,
3371
- data, size,
3372
- ptr->GetState()
3373
- );
3374
- } else if (data->IsArray()) {
3375
- std::vector<float> buf;
3376
- auto array = data.As<v8::Array>();
3377
- auto len = array->Length();
3378
- for (int i = 0; i < len; i++) {
3379
- auto item = array->Get(
3380
- context, i).ToLocalChecked();
3381
- if (item->IsNumber()) {
3382
- buf.push_back(
3383
- static_cast<float>(item->NumberValue(
3384
- context).ToChecked()));
3385
- } else {
3386
- buf.push_back(
3387
- std::nanf(""));
3388
- }
3389
- }
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
+ }
3390
3277
 
3391
3278
 
3392
3279
 
3393
- canvas_native_webgl2_uniform_matrix4x2fv(
3394
- location->GetUniformLocation(),
3395
- transpose,
3396
- buf.data(), buf.size(),
3397
- ptr->GetState()
3398
- );
3399
- }
3280
+ canvas_native_webgl2_uniform_matrix4x2fv(
3281
+ location->GetUniformLocation(),
3282
+ transpose,
3283
+ buf.data(), buf.size(),
3284
+ ptr->GetState()
3285
+ );
3400
3286
  }
3401
-
3402
3287
  }
3403
3288
 
3404
3289
  }
@@ -3413,56 +3298,47 @@ void WebGL2RenderingContext::UniformMatrix4x3fv(const v8::FunctionCallbackInfo<v
3413
3298
  auto context = isolate->GetCurrentContext();
3414
3299
 
3415
3300
 
3416
- if (args.Length() > 2 &&
3417
- args[2]->IsObject()) {
3418
- auto locationValue = args[0];
3419
- auto type = GetNativeType(isolate, locationValue);
3420
- if (type == NativeType::WebGLUniformLocation) {
3421
- auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3422
- auto transpose = args[1]->BooleanValue(isolate);
3423
- auto data = args[2];
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];
3424
3307
 
3425
- if (data->IsFloat32Array()) {
3426
- auto buf = data.As<v8::Float32Array>();
3427
- auto array = buf->Buffer();
3428
- auto offset = buf->ByteOffset();
3429
- auto size = buf->Length();
3430
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3431
- auto data = static_cast<float *>((void*) data_ptr);
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);
3432
3315
 
3433
- canvas_native_webgl2_uniform_matrix4x3fv(
3434
- location->GetUniformLocation(),
3435
- transpose,
3436
- data, size,
3437
- ptr->GetState()
3438
- );
3439
- } else if (data->IsArray()) {
3440
- std::vector<float> buf;
3441
- auto array = data.As<v8::Array>();
3442
- auto len = array->Length();
3443
- for (int i = 0; i < len; i++) {
3444
- auto item = array->Get(
3445
- context, i).ToLocalChecked();
3446
- if (item->IsNumber()) {
3447
- buf.push_back(
3448
- static_cast<float>(item->NumberValue(
3449
- context).ToChecked()));
3450
- } else {
3451
- buf.push_back(
3452
- std::nanf(""));
3453
- }
3454
- }
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
+ }
3455
3333
 
3456
3334
 
3457
- canvas_native_webgl2_uniform_matrix4x3fv(
3458
- location->GetUniformLocation(),
3459
- transpose,
3460
- buf.data(), buf.size(),
3461
- ptr->GetState()
3462
- );
3463
- }
3335
+ canvas_native_webgl2_uniform_matrix4x3fv(
3336
+ location->GetUniformLocation(),
3337
+ transpose,
3338
+ buf.data(), buf.size(),
3339
+ ptr->GetState()
3340
+ );
3464
3341
  }
3465
-
3466
3342
  }
3467
3343
 
3468
3344
  }
@@ -3477,17 +3353,15 @@ void WebGL2RenderingContext::VertexAttribDivisor(const v8::FunctionCallbackInfo<
3477
3353
  auto context = isolate->GetCurrentContext();
3478
3354
 
3479
3355
 
3480
- if (args.Length() > 1) {
3481
- auto index = args[0]->NumberValue(
3482
- context).ToChecked();
3483
- auto divisor = args[1]->NumberValue(
3484
- context).ToChecked();
3485
- canvas_native_webgl2_vertex_attrib_divisor(
3486
- (uint32_t) index,
3487
- (uint32_t) divisor,
3488
- ptr->GetState()
3489
- );
3490
- }
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
+ );
3491
3365
 
3492
3366
  }
3493
3367
 
@@ -3501,26 +3375,24 @@ void WebGL2RenderingContext::VertexAttribI4i(const v8::FunctionCallbackInfo<v8::
3501
3375
  auto context = isolate->GetCurrentContext();
3502
3376
 
3503
3377
 
3504
- if (args.Length() > 4) {
3505
- auto index = args[0]->NumberValue(
3506
- context).ToChecked();
3507
- auto v0 = args[1]->NumberValue(
3508
- context).ToChecked();
3509
- auto v1 = args[2]->NumberValue(
3510
- context).ToChecked();
3511
- auto v2 = args[3]->NumberValue(
3512
- context).ToChecked();
3513
- auto v3 = args[4]->NumberValue(
3514
- context).ToChecked();
3515
- canvas_native_webgl2_vertex_attrib_i4i(
3516
- (uint32_t) index,
3517
- (int32_t) v0,
3518
- (int32_t) v1,
3519
- (int32_t) v2,
3520
- (int32_t) v3,
3521
- ptr->GetState()
3522
- );
3523
- }
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
+ );
3524
3396
 
3525
3397
  }
3526
3398
 
@@ -3534,46 +3406,43 @@ void WebGL2RenderingContext::VertexAttribI4iv(const v8::FunctionCallbackInfo<v8:
3534
3406
  auto context = isolate->GetCurrentContext();
3535
3407
 
3536
3408
 
3537
- if (args.Length() > 1 &&
3538
- args[1]->IsObject()) {
3539
- auto index = (uint32_t) args[0]->NumberValue(
3540
- context).ToChecked();
3541
- auto value = args[1];
3542
- if (value->IsInt32Array()) {
3543
- auto buf = value.As<v8::Int32Array>();
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>();
3544
3414
 
3545
- auto array = buf->Buffer();
3546
- auto offset = buf->ByteOffset();
3547
- auto size = buf->Length();
3548
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3549
- auto data = static_cast<int32_t *>((void*) data_ptr);
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);
3550
3420
 
3551
3421
 
3552
- canvas_native_webgl2_vertex_attrib_i4iv(
3553
- index,
3554
- data, size,
3555
- ptr->GetState()
3556
- );
3557
- } else if (value->IsArray()) {
3558
- auto array = value.As<v8::Array>();
3559
- auto len = array->Length();
3560
- std::vector<int32_t> buf;
3561
- buf.reserve(len);
3562
- for (int i = 0; i < len; i++) {
3563
- auto item = (int32_t) array->Get(
3564
- context,
3565
- i).ToLocalChecked()->NumberValue(
3566
- context).ToChecked();
3567
- buf.push_back(item);
3568
- }
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
+ }
3569
3439
 
3570
3440
 
3571
- canvas_native_webgl2_vertex_attrib_i4iv(
3572
- index,
3573
- buf.data(), buf.size(),
3574
- ptr->GetState()
3575
- );
3576
- }
3441
+ canvas_native_webgl2_vertex_attrib_i4iv(
3442
+ index,
3443
+ buf.data(), buf.size(),
3444
+ ptr->GetState()
3445
+ );
3577
3446
  }
3578
3447
 
3579
3448
  }
@@ -3588,27 +3457,25 @@ void WebGL2RenderingContext::VertexAttribI4ui(const v8::FunctionCallbackInfo<v8:
3588
3457
  auto context = isolate->GetCurrentContext();
3589
3458
 
3590
3459
 
3591
- if (args.Length() > 4) {
3592
- auto index = (uint32_t) args[0]->NumberValue(
3593
- context).ToChecked();
3594
- auto v0 = (uint32_t) args[1]->NumberValue(
3595
- context).ToChecked();
3596
- auto v1 = (uint32_t) args[2]->NumberValue(
3597
- context).ToChecked();
3598
- auto v2 = (uint32_t) args[3]->NumberValue(
3599
- context).ToChecked();
3600
- auto v3 = (uint32_t) args[4]->NumberValue(
3601
- context).ToChecked();
3602
-
3603
- canvas_native_webgl2_vertex_attrib_i4ui(
3604
- index,
3605
- v0,
3606
- v1,
3607
- v2,
3608
- v3,
3609
- ptr->GetState()
3610
- );
3611
- }
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
+ );
3612
3479
 
3613
3480
  }
3614
3481
 
@@ -3621,46 +3488,42 @@ void WebGL2RenderingContext::VertexAttribI4uiv(const v8::FunctionCallbackInfo<v8
3621
3488
  auto isolate = args.GetIsolate();
3622
3489
  auto context = isolate->GetCurrentContext();
3623
3490
 
3624
-
3625
- if (args.Length() > 1 &&
3626
- args[1]->IsObject()) {
3627
- auto index = (uint32_t) args[0]->NumberValue(
3628
- context).ToChecked();
3629
- auto value = args[1];
3630
- if (value->IsUint32Array()) {
3631
- auto buf = value.As<v8::Uint32Array>();
3632
- auto array = buf->Buffer();
3633
- auto offset = buf->ByteOffset();
3634
- auto size = buf->Length();
3635
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3636
- auto data = static_cast<uint32_t *>((void*) data_ptr);
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);
3637
3501
 
3638
3502
 
3639
- canvas_native_webgl2_vertex_attrib_i4uiv(
3640
- index,
3641
- data, size,
3642
- ptr->GetState()
3643
- );
3644
- } else if (value->IsArray()) {
3645
- auto array = value.As<v8::Array>();
3646
- auto len = array->Length();
3647
- std::vector<uint32_t> buf;
3648
- buf.reserve(len);
3649
- for (int i = 0; i < len; i++) {
3650
- auto item = (uint32_t) array->Get(
3651
- context,
3652
- i).ToLocalChecked()->NumberValue(
3653
- context).ToChecked();
3654
- buf.push_back(item);
3655
- }
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
+ }
3656
3520
 
3657
3521
 
3658
- canvas_native_webgl2_vertex_attrib_i4uiv(
3659
- index,
3660
- buf.data(), buf.size(),
3661
- ptr->GetState()
3662
- );
3663
- }
3522
+ canvas_native_webgl2_vertex_attrib_i4uiv(
3523
+ index,
3524
+ buf.data(), buf.size(),
3525
+ ptr->GetState()
3526
+ );
3664
3527
  }
3665
3528
 
3666
3529
  }