@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.
@@ -359,23 +359,21 @@ void WebGLRenderingContext::BindAttribLocation(const v8::FunctionCallbackInfo<v8
359
359
  auto isolate = args.GetIsolate();
360
360
  auto context = isolate->GetCurrentContext();
361
361
 
362
- if (args.Length() > 2) {
363
- auto programValue = args[0];
364
- auto type = GetNativeType(isolate, programValue);
365
- if (type == NativeType::WebGLProgram && args[1]->IsNumber() &&
366
- args[2]->IsString()) {
367
- auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
368
-
369
- auto index = (uint32_t) args[1]->NumberValue(context).ToChecked();
370
- auto name = ConvertFromV8String(isolate, args[2]);
371
- canvas_native_webgl_bind_attrib_location(
372
- program->GetProgram(),
373
- index,
374
- name.c_str(),
375
- ptr->GetState()
376
- );
362
+ auto programValue = args[0];
363
+ auto type = GetNativeType(isolate, programValue);
364
+ if (type == NativeType::WebGLProgram && args[1]->IsNumber() &&
365
+ args[2]->IsString()) {
366
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
367
+
368
+ auto index = (uint32_t) args[1]->NumberValue(context).ToChecked();
369
+ auto name = ConvertFromV8String(isolate, args[2]);
370
+ canvas_native_webgl_bind_attrib_location(
371
+ program->GetProgram(),
372
+ index,
373
+ name.c_str(),
374
+ ptr->GetState()
375
+ );
377
376
 
378
- }
379
377
  }
380
378
  }
381
379
 
@@ -388,32 +386,30 @@ void WebGLRenderingContext::BindBuffer(const v8::FunctionCallbackInfo<v8::Value>
388
386
  auto isolate = args.GetIsolate();
389
387
  auto context = isolate->GetCurrentContext();
390
388
 
391
- if (args.Length() > 1) {
392
- if (args[0]->IsNumber()) {
393
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
394
- if (!args[1]->IsNull() &&
395
- args[1]->IsObject()) {
396
- auto type = GetNativeType(isolate, args[1].As<v8::Object>());
397
- if (type == NativeType::WebGLBuffer) {
398
- auto buffer = WebGLBuffer::GetPointer(args[1].As<v8::Object>());
399
- if (buffer ==
400
- nullptr) { return; }
401
- canvas_native_webgl_bind_buffer(
402
- target,
403
- buffer->GetBuffer(),
404
- ptr->GetState()
405
- );
406
- }
407
-
408
- } else {
409
- // unbind
410
- // check for null or undefined ?
389
+ if (args[0]->IsNumber()) {
390
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
391
+ if (!args[1]->IsNull() &&
392
+ args[1]->IsObject()) {
393
+ auto type = GetNativeType(isolate, args[1].As<v8::Object>());
394
+ if (type == NativeType::WebGLBuffer) {
395
+ auto buffer = WebGLBuffer::GetPointer(args[1].As<v8::Object>());
396
+ if (buffer ==
397
+ nullptr) { return; }
411
398
  canvas_native_webgl_bind_buffer(
412
399
  target,
413
- 0,
400
+ buffer->GetBuffer(),
414
401
  ptr->GetState()
415
402
  );
416
403
  }
404
+
405
+ } else {
406
+ // unbind
407
+ // check for null or undefined ?
408
+ canvas_native_webgl_bind_buffer(
409
+ target,
410
+ 0,
411
+ ptr->GetState()
412
+ );
417
413
  }
418
414
  }
419
415
  }
@@ -427,28 +423,26 @@ void WebGLRenderingContext::BindFramebuffer(const v8::FunctionCallbackInfo<v8::V
427
423
  auto isolate = args.GetIsolate();
428
424
  auto context = isolate->GetCurrentContext();
429
425
 
430
- if (args.Length() > 1) {
431
- if (args[0]->IsNumber()) {
432
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
433
- if (args[1]->IsObject()) {
434
- auto type = GetNativeType(isolate, args[1].As<v8::Object>());
435
- if (type == NativeType::WebGLFramebuffer) {
436
- auto framebuffer = WebGLFramebuffer::GetPointer(args[1].As<v8::Object>());
437
- canvas_native_webgl_bind_frame_buffer(
438
- target,
439
- framebuffer->GetFrameBuffer(),
440
- ptr->GetState()
441
- );
442
- }
443
- } else {
444
- // null value
445
- // unbind
426
+ if (args[0]->IsNumber()) {
427
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
428
+ if (args[1]->IsObject()) {
429
+ auto type = GetNativeType(isolate, args[1].As<v8::Object>());
430
+ if (type == NativeType::WebGLFramebuffer) {
431
+ auto framebuffer = WebGLFramebuffer::GetPointer(args[1].As<v8::Object>());
446
432
  canvas_native_webgl_bind_frame_buffer(
447
433
  target,
448
- 0,
434
+ framebuffer->GetFrameBuffer(),
449
435
  ptr->GetState()
450
436
  );
451
437
  }
438
+ } else {
439
+ // null value
440
+ // unbind
441
+ canvas_native_webgl_bind_frame_buffer(
442
+ target,
443
+ 0,
444
+ ptr->GetState()
445
+ );
452
446
  }
453
447
  }
454
448
  }
@@ -462,29 +456,27 @@ void WebGLRenderingContext::BindRenderbuffer(const v8::FunctionCallbackInfo<v8::
462
456
  auto isolate = args.GetIsolate();
463
457
  auto context = isolate->GetCurrentContext();
464
458
 
465
- if (args.Length() > 1) {
466
- if (args[0]->IsNumber()) {
467
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
468
- if (args[1]->IsObject()) {
469
- auto type = GetNativeType(isolate, args[1].As<v8::Object>());
470
- if (type == NativeType::WebGLRenderbuffer) {
471
- auto renderbuffer = WebGLRenderbuffer::GetPointer(args[1].As<v8::Object>());
472
-
473
- if (renderbuffer ==
474
- nullptr) { return; }
475
- canvas_native_webgl_bind_render_buffer(
476
- target,
477
- renderbuffer->GetRenderBuffer(),
478
- ptr->GetState()
479
- );
480
- }
481
- } else {
459
+ if (args[0]->IsNumber()) {
460
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
461
+ if (args[1]->IsObject()) {
462
+ auto type = GetNativeType(isolate, args[1].As<v8::Object>());
463
+ if (type == NativeType::WebGLRenderbuffer) {
464
+ auto renderbuffer = WebGLRenderbuffer::GetPointer(args[1].As<v8::Object>());
465
+
466
+ if (renderbuffer ==
467
+ nullptr) { return; }
482
468
  canvas_native_webgl_bind_render_buffer(
483
469
  target,
484
- 0,
470
+ renderbuffer->GetRenderBuffer(),
485
471
  ptr->GetState()
486
472
  );
487
473
  }
474
+ } else {
475
+ canvas_native_webgl_bind_render_buffer(
476
+ target,
477
+ 0,
478
+ ptr->GetState()
479
+ );
488
480
  }
489
481
  }
490
482
  }
@@ -498,26 +490,24 @@ void WebGLRenderingContext::BindTexture(const v8::FunctionCallbackInfo<v8::Value
498
490
  auto isolate = args.GetIsolate();
499
491
  auto context = isolate->GetCurrentContext();
500
492
 
501
- if (args.Length() > 1) {
502
- if (args[0]->IsNumber()) {
503
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
504
- if (args[1]->IsObject()) {
505
- auto type = GetNativeType(isolate, args[1].As<v8::Object>());
506
- if (type == NativeType::WebGLTexture) {
507
- auto texture = WebGLTexture::GetPointer(args[1].As<v8::Object>());
508
- canvas_native_webgl_bind_texture(
509
- target,
510
- texture->GetTexture(),
511
- ptr->GetState()
512
- );
513
- }
514
- } else {
493
+ if (args[0]->IsNumber()) {
494
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
495
+ if (args[1]->IsObject()) {
496
+ auto type = GetNativeType(isolate, args[1].As<v8::Object>());
497
+ if (type == NativeType::WebGLTexture) {
498
+ auto texture = WebGLTexture::GetPointer(args[1].As<v8::Object>());
515
499
  canvas_native_webgl_bind_texture(
516
500
  target,
517
- 0,
501
+ texture->GetTexture(),
518
502
  ptr->GetState()
519
503
  );
520
504
  }
505
+ } else {
506
+ canvas_native_webgl_bind_texture(
507
+ target,
508
+ 0,
509
+ ptr->GetState()
510
+ );
521
511
  }
522
512
  }
523
513
  }
@@ -531,20 +521,18 @@ void WebGLRenderingContext::BlendColor(const v8::FunctionCallbackInfo<v8::Value>
531
521
  auto isolate = args.GetIsolate();
532
522
  auto context = isolate->GetCurrentContext();
533
523
 
534
- if (args.Length() > 3) {
535
- auto red = args[0]->NumberValue(context).ToChecked();
536
- auto green = args[1]->NumberValue(context).ToChecked();
537
- auto blue = args[2]->NumberValue(context).ToChecked();
538
- auto alpha = args[3]->NumberValue(context).ToChecked();
539
-
540
- canvas_native_webgl_blend_color(
541
- static_cast<float>(red),
542
- static_cast<float>(green),
543
- static_cast<float>(blue),
544
- static_cast<float>(alpha),
545
- ptr->GetState()
546
- );
547
- }
524
+ auto red = args[0]->NumberValue(context).ToChecked();
525
+ auto green = args[1]->NumberValue(context).ToChecked();
526
+ auto blue = args[2]->NumberValue(context).ToChecked();
527
+ auto alpha = args[3]->NumberValue(context).ToChecked();
528
+
529
+ canvas_native_webgl_blend_color(
530
+ static_cast<float>(red),
531
+ static_cast<float>(green),
532
+ static_cast<float>(blue),
533
+ static_cast<float>(alpha),
534
+ ptr->GetState()
535
+ );
548
536
  }
549
537
 
550
538
  void WebGLRenderingContext::BlendEquationSeparate(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -556,16 +544,14 @@ void WebGLRenderingContext::BlendEquationSeparate(const v8::FunctionCallbackInfo
556
544
  auto isolate = args.GetIsolate();
557
545
  auto context = isolate->GetCurrentContext();
558
546
 
559
- if (args.Length() > 1) {
560
- auto modeRGB = (uint32_t) args[0]->NumberValue(context).ToChecked();
561
- auto modeAlpha = (uint32_t) args[1]->NumberValue(context).ToChecked();
547
+ auto modeRGB = (uint32_t) args[0]->NumberValue(context).ToChecked();
548
+ auto modeAlpha = (uint32_t) args[1]->NumberValue(context).ToChecked();
562
549
 
563
- canvas_native_webgl_blend_equation_separate(
564
- modeRGB,
565
- modeAlpha,
566
- ptr->GetState()
567
- );
568
- }
550
+ canvas_native_webgl_blend_equation_separate(
551
+ modeRGB,
552
+ modeAlpha,
553
+ ptr->GetState()
554
+ );
569
555
  }
570
556
 
571
557
  void WebGLRenderingContext::BlendEquation(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -577,13 +563,11 @@ void WebGLRenderingContext::BlendEquation(const v8::FunctionCallbackInfo<v8::Val
577
563
  auto isolate = args.GetIsolate();
578
564
  auto context = isolate->GetCurrentContext();
579
565
 
580
- if (args.Length() > 0) {
581
- auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
582
- canvas_native_webgl_blend_equation(
583
- mode,
584
- ptr->GetState()
585
- );
586
- }
566
+ auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
567
+ canvas_native_webgl_blend_equation(
568
+ mode,
569
+ ptr->GetState()
570
+ );
587
571
  }
588
572
 
589
573
  void WebGLRenderingContext::BlendFuncSeparate(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -595,20 +579,18 @@ void WebGLRenderingContext::BlendFuncSeparate(const v8::FunctionCallbackInfo<v8:
595
579
  auto isolate = args.GetIsolate();
596
580
  auto context = isolate->GetCurrentContext();
597
581
 
598
- if (args.Length() > 3) {
599
- auto srcRGB = (uint32_t) args[0]->NumberValue(context).ToChecked();
600
- auto dstRGB = (uint32_t) args[1]->NumberValue(context).ToChecked();
601
- auto srcAlpha = (uint32_t) args[2]->NumberValue(context).ToChecked();
602
- auto dstAlpha = (uint32_t) args[3]->NumberValue(context).ToChecked();
603
-
604
- canvas_native_webgl_blend_func_separate(
605
- srcRGB,
606
- dstRGB,
607
- srcAlpha,
608
- dstAlpha,
609
- ptr->GetState()
610
- );
611
- }
582
+ auto srcRGB = (uint32_t) args[0]->NumberValue(context).ToChecked();
583
+ auto dstRGB = (uint32_t) args[1]->NumberValue(context).ToChecked();
584
+ auto srcAlpha = (uint32_t) args[2]->NumberValue(context).ToChecked();
585
+ auto dstAlpha = (uint32_t) args[3]->NumberValue(context).ToChecked();
586
+
587
+ canvas_native_webgl_blend_func_separate(
588
+ srcRGB,
589
+ dstRGB,
590
+ srcAlpha,
591
+ dstAlpha,
592
+ ptr->GetState()
593
+ );
612
594
  }
613
595
 
614
596
  void WebGLRenderingContext::BlendFunc(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -620,16 +602,14 @@ void WebGLRenderingContext::BlendFunc(const v8::FunctionCallbackInfo<v8::Value>
620
602
  auto isolate = args.GetIsolate();
621
603
  auto context = isolate->GetCurrentContext();
622
604
 
623
- if (args.Length() > 1) {
624
- auto sfactor = (uint32_t) args[0]->NumberValue(context).ToChecked();
625
- auto dfactor = (uint32_t) args[1]->NumberValue(context).ToChecked();
605
+ auto sfactor = (uint32_t) args[0]->NumberValue(context).ToChecked();
606
+ auto dfactor = (uint32_t) args[1]->NumberValue(context).ToChecked();
626
607
 
627
- canvas_native_webgl_blend_func(
628
- sfactor,
629
- dfactor,
630
- ptr->GetState()
631
- );
632
- }
608
+ canvas_native_webgl_blend_func(
609
+ sfactor,
610
+ dfactor,
611
+ ptr->GetState()
612
+ );
633
613
  }
634
614
 
635
615
  void WebGLRenderingContext::BufferData(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -668,7 +648,8 @@ void WebGLRenderingContext::BufferData(const v8::FunctionCallbackInfo<v8::Value>
668
648
  auto array = buf->Buffer();
669
649
  auto offset = buf->ByteOffset();
670
650
  auto size = buf->Length();
671
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
651
+ auto data_ptr =
652
+ static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
672
653
  auto data = static_cast<uint16_t *>((void *) data_ptr);
673
654
 
674
655
  canvas_native_webgl_buffer_data_u16(
@@ -683,7 +664,8 @@ void WebGLRenderingContext::BufferData(const v8::FunctionCallbackInfo<v8::Value>
683
664
  auto array = buf->Buffer();
684
665
  auto offset = buf->ByteOffset();
685
666
  auto size = buf->Length();
686
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
667
+ auto data_ptr =
668
+ static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
687
669
  auto data = static_cast<float *>((void *) data_ptr);
688
670
 
689
671
  canvas_native_webgl_buffer_data_f32(
@@ -698,7 +680,8 @@ void WebGLRenderingContext::BufferData(const v8::FunctionCallbackInfo<v8::Value>
698
680
  auto array = buf->Buffer();
699
681
  auto offset = buf->ByteOffset();
700
682
  auto size = buf->ByteLength();
701
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
683
+ auto data_ptr =
684
+ static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
702
685
  auto data = static_cast<uint8_t *>((void *) data_ptr);
703
686
 
704
687
 
@@ -809,19 +792,16 @@ WebGLRenderingContext::CheckFramebufferStatus(const v8::FunctionCallbackInfo<v8:
809
792
 
810
793
  auto count = args.Length();
811
794
 
812
- if (count > 0) {
813
-
814
- if (args[0]->IsNumber()) {
815
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
795
+ if (args[0]->IsNumber()) {
796
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
816
797
 
817
- auto ret = canvas_native_webgl_check_frame_buffer_status(
818
- target,
819
- ptr->GetState()
820
- );
798
+ auto ret = canvas_native_webgl_check_frame_buffer_status(
799
+ target,
800
+ ptr->GetState()
801
+ );
821
802
 
822
- args.GetReturnValue().Set((int32_t) ret);
823
- return;
824
- }
803
+ args.GetReturnValue().Set((int32_t) ret);
804
+ return;
825
805
  }
826
806
 
827
807
  args.GetReturnValue().Set(0);
@@ -836,20 +816,18 @@ void WebGLRenderingContext::ClearColor(const v8::FunctionCallbackInfo<v8::Value>
836
816
  auto isolate = args.GetIsolate();
837
817
  auto context = isolate->GetCurrentContext();
838
818
 
839
- if (args.Length() > 3) {
840
- auto red = args[0]->NumberValue(context).ToChecked();
841
- auto green = args[1]->NumberValue(context).ToChecked();
842
- auto blue = args[2]->NumberValue(context).ToChecked();
843
- auto alpha = args[3]->NumberValue(context).ToChecked();
844
-
845
- canvas_native_webgl_clear_color(
846
- static_cast<float>(red),
847
- static_cast<float>(green),
848
- static_cast<float>(blue),
849
- static_cast<float>(alpha),
850
- ptr->GetState()
851
- );
852
- }
819
+ auto red = args[0]->NumberValue(context).ToChecked();
820
+ auto green = args[1]->NumberValue(context).ToChecked();
821
+ auto blue = args[2]->NumberValue(context).ToChecked();
822
+ auto alpha = args[3]->NumberValue(context).ToChecked();
823
+
824
+ canvas_native_webgl_clear_color(
825
+ static_cast<float>(red),
826
+ static_cast<float>(green),
827
+ static_cast<float>(blue),
828
+ static_cast<float>(alpha),
829
+ ptr->GetState()
830
+ );
853
831
  }
854
832
 
855
833
  void WebGLRenderingContext::ClearDepth(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -861,14 +839,12 @@ void WebGLRenderingContext::ClearDepth(const v8::FunctionCallbackInfo<v8::Value>
861
839
  auto isolate = args.GetIsolate();
862
840
  auto context = isolate->GetCurrentContext();
863
841
 
864
- if (args.Length() > 0) {
865
- auto depth = args[0]->NumberValue(context).ToChecked();
842
+ auto depth = args[0]->NumberValue(context).ToChecked();
866
843
 
867
- canvas_native_webgl_clear_depth(
868
- static_cast<float>(depth),
869
- ptr->GetState()
870
- );
871
- }
844
+ canvas_native_webgl_clear_depth(
845
+ static_cast<float>(depth),
846
+ ptr->GetState()
847
+ );
872
848
  }
873
849
 
874
850
  void WebGLRenderingContext::ClearStencil(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -880,13 +856,11 @@ void WebGLRenderingContext::ClearStencil(const v8::FunctionCallbackInfo<v8::Valu
880
856
  auto isolate = args.GetIsolate();
881
857
  auto context = isolate->GetCurrentContext();
882
858
 
883
- if (args.Length() > 0) {
884
- auto stencil = (int32_t) args[0]->NumberValue(context).ToChecked();
885
- canvas_native_webgl_clear_stencil(
886
- stencil,
887
- ptr->GetState()
888
- );
889
- }
859
+ auto stencil = (int32_t) args[0]->NumberValue(context).ToChecked();
860
+ canvas_native_webgl_clear_stencil(
861
+ stencil,
862
+ ptr->GetState()
863
+ );
890
864
  }
891
865
 
892
866
  void WebGLRenderingContext::Clear(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -898,7 +872,6 @@ void WebGLRenderingContext::Clear(const v8::FunctionCallbackInfo<v8::Value> &arg
898
872
  auto isolate = args.GetIsolate();
899
873
  auto context = isolate->GetCurrentContext();
900
874
 
901
- //if (count > 0) {
902
875
  auto mask = (uint32_t) args[0]->NumberValue(context).ToChecked();
903
876
 
904
877
  canvas_native_webgl_clear(
@@ -907,7 +880,6 @@ void WebGLRenderingContext::Clear(const v8::FunctionCallbackInfo<v8::Value> &arg
907
880
  );
908
881
 
909
882
  ptr->UpdateInvalidateState();
910
- // }
911
883
  }
912
884
 
913
885
  void WebGLRenderingContext::ColorMask(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -918,20 +890,18 @@ void WebGLRenderingContext::ColorMask(const v8::FunctionCallbackInfo<v8::Value>
918
890
 
919
891
  auto isolate = args.GetIsolate();
920
892
 
921
- if (args.Length() > 3) {
922
- auto red = args[0]->BooleanValue(isolate);
923
- auto green = args[1]->BooleanValue(isolate);
924
- auto blue = args[2]->BooleanValue(isolate);
925
- auto alpha = args[3]->BooleanValue(isolate);
893
+ auto red = args[0]->BooleanValue(isolate);
894
+ auto green = args[1]->BooleanValue(isolate);
895
+ auto blue = args[2]->BooleanValue(isolate);
896
+ auto alpha = args[3]->BooleanValue(isolate);
926
897
 
927
- canvas_native_webgl_color_mask(
928
- red,
929
- green,
930
- blue,
931
- alpha,
932
- ptr->GetState()
933
- );
934
- }
898
+ canvas_native_webgl_color_mask(
899
+ red,
900
+ green,
901
+ blue,
902
+ alpha,
903
+ ptr->GetState()
904
+ );
935
905
  }
936
906
 
937
907
  void WebGLRenderingContext::Commit(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -947,14 +917,12 @@ void WebGLRenderingContext::CompileShader(const v8::FunctionCallbackInfo<v8::Val
947
917
  return;
948
918
  }
949
919
 
950
- if (args.Length() > 0) {
951
- auto shader = WebGLShader::GetPointer(args[0].As<v8::Object>());
952
- if (shader != nullptr) {
953
- canvas_native_webgl_compile_shader(
954
- shader->GetShader(),
955
- ptr->GetState()
956
- );
957
- }
920
+ auto shader = WebGLShader::GetPointer(args[0].As<v8::Object>());
921
+ if (shader != nullptr) {
922
+ canvas_native_webgl_compile_shader(
923
+ shader->GetShader(),
924
+ ptr->GetState()
925
+ );
958
926
  }
959
927
  }
960
928
 
@@ -1001,7 +969,7 @@ void WebGLRenderingContext::CompressedTexImage2D(const v8::FunctionCallbackInfo<
1001
969
  auto array = buf->Buffer();
1002
970
  auto offset = buf->ByteOffset();
1003
971
  auto size = buf->ByteLength();
1004
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
972
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
1005
973
  auto data = static_cast<uint8_t *>((void *) data_ptr);
1006
974
 
1007
975
 
@@ -1047,55 +1015,50 @@ WebGLRenderingContext::CompressedTexSubImage2D(const v8::FunctionCallbackInfo<v8
1047
1015
  auto isolate = args.GetIsolate();
1048
1016
  auto context = isolate->GetCurrentContext();
1049
1017
 
1050
- auto count = args.Length();
1051
-
1052
-
1053
- if (count > 7) {
1054
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1055
- auto level = (int32_t) args[1]->NumberValue(context).ToChecked();
1056
- auto xoffset = (int32_t) args[2]->NumberValue(context).ToChecked();
1057
- auto yoffset = (int32_t) args[3]->NumberValue(context).ToChecked();
1058
- auto width = (int32_t) args[4]->NumberValue(context).ToChecked();
1059
- auto height = (int32_t) args[5]->NumberValue(context).ToChecked();
1060
- auto format = (uint32_t) args[6]->NumberValue(context).ToChecked();
1061
- if (args[7]->IsObject()) {
1062
- auto pixels = args[7];
1063
- if (pixels->IsArrayBufferView()) {
1064
- auto buf = pixels.As<v8::ArrayBufferView>();
1065
- auto array = buf->Buffer();
1066
- auto offset = buf->ByteOffset();
1067
- auto size = array->ByteLength();
1068
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
1069
- auto data = static_cast<uint8_t *>((void *) data_ptr);
1018
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1019
+ auto level = (int32_t) args[1]->NumberValue(context).ToChecked();
1020
+ auto xoffset = (int32_t) args[2]->NumberValue(context).ToChecked();
1021
+ auto yoffset = (int32_t) args[3]->NumberValue(context).ToChecked();
1022
+ auto width = (int32_t) args[4]->NumberValue(context).ToChecked();
1023
+ auto height = (int32_t) args[5]->NumberValue(context).ToChecked();
1024
+ auto format = (uint32_t) args[6]->NumberValue(context).ToChecked();
1025
+ if (args[7]->IsObject()) {
1026
+ auto pixels = args[7];
1027
+ if (pixels->IsArrayBufferView()) {
1028
+ auto buf = pixels.As<v8::ArrayBufferView>();
1029
+ auto array = buf->Buffer();
1030
+ auto offset = buf->ByteOffset();
1031
+ auto size = array->ByteLength();
1032
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
1033
+ auto data = static_cast<uint8_t *>((void *) data_ptr);
1070
1034
 
1071
- canvas_native_webgl_compressed_tex_sub_image2d(
1072
- target,
1073
- level,
1074
- xoffset,
1075
- yoffset,
1076
- width,
1077
- height,
1078
- format,
1079
- data, size,
1080
- ptr->GetState()
1081
- );
1082
- } else if (pixels->IsArrayBuffer()) {
1083
- auto array = pixels.As<v8::ArrayBuffer>();
1084
- auto size = array->ByteLength();
1085
- auto data = (uint8_t *) array->GetBackingStore()->Data();
1035
+ canvas_native_webgl_compressed_tex_sub_image2d(
1036
+ target,
1037
+ level,
1038
+ xoffset,
1039
+ yoffset,
1040
+ width,
1041
+ height,
1042
+ format,
1043
+ data, size,
1044
+ ptr->GetState()
1045
+ );
1046
+ } else if (pixels->IsArrayBuffer()) {
1047
+ auto array = pixels.As<v8::ArrayBuffer>();
1048
+ auto size = array->ByteLength();
1049
+ auto data = (uint8_t *) array->GetBackingStore()->Data();
1086
1050
 
1087
- canvas_native_webgl_compressed_tex_sub_image2d(
1088
- target,
1089
- level,
1090
- xoffset,
1091
- yoffset,
1092
- width,
1093
- height,
1094
- format,
1095
- data, size,
1096
- ptr->GetState()
1097
- );
1098
- }
1051
+ canvas_native_webgl_compressed_tex_sub_image2d(
1052
+ target,
1053
+ level,
1054
+ xoffset,
1055
+ yoffset,
1056
+ width,
1057
+ height,
1058
+ format,
1059
+ data, size,
1060
+ ptr->GetState()
1061
+ );
1099
1062
  }
1100
1063
  }
1101
1064
 
@@ -1113,28 +1076,26 @@ void WebGLRenderingContext::CopyTexImage2D(const v8::FunctionCallbackInfo<v8::Va
1113
1076
  auto count = args.Length();
1114
1077
 
1115
1078
 
1116
- if (count > 7) {
1117
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1118
- auto level = (int32_t) args[1]->NumberValue(context).ToChecked();
1119
- auto internalformat = (uint32_t) args[2]->NumberValue(context).ToChecked();
1120
- auto x = (int32_t) args[3]->NumberValue(context).ToChecked();
1121
- auto y = (int32_t) args[4]->NumberValue(context).ToChecked();
1122
- auto width = (int32_t) args[5]->NumberValue(context).ToChecked();
1123
- auto height = (int32_t) args[6]->NumberValue(context).ToChecked();
1124
- auto border = (int32_t) args[7]->NumberValue(context).ToChecked();
1125
-
1126
- canvas_native_webgl_copy_tex_image2d(
1127
- target,
1128
- level,
1129
- internalformat,
1130
- x,
1131
- y,
1132
- width,
1133
- height,
1134
- border,
1135
- ptr->GetState()
1136
- );
1137
- }
1079
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1080
+ auto level = (int32_t) args[1]->NumberValue(context).ToChecked();
1081
+ auto internalformat = (uint32_t) args[2]->NumberValue(context).ToChecked();
1082
+ auto x = (int32_t) args[3]->NumberValue(context).ToChecked();
1083
+ auto y = (int32_t) args[4]->NumberValue(context).ToChecked();
1084
+ auto width = (int32_t) args[5]->NumberValue(context).ToChecked();
1085
+ auto height = (int32_t) args[6]->NumberValue(context).ToChecked();
1086
+ auto border = (int32_t) args[7]->NumberValue(context).ToChecked();
1087
+
1088
+ canvas_native_webgl_copy_tex_image2d(
1089
+ target,
1090
+ level,
1091
+ internalformat,
1092
+ x,
1093
+ y,
1094
+ width,
1095
+ height,
1096
+ border,
1097
+ ptr->GetState()
1098
+ );
1138
1099
 
1139
1100
  }
1140
1101
 
@@ -1150,28 +1111,26 @@ void WebGLRenderingContext::CopyTexSubImage2D(const v8::FunctionCallbackInfo<v8:
1150
1111
  auto count = args.Length();
1151
1112
 
1152
1113
 
1153
- if (count > 7) {
1154
- auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1155
- auto level = (int32_t) args[1]->NumberValue(context).ToChecked();
1156
- auto xoffset = (int32_t) args[2]->NumberValue(context).ToChecked();
1157
- auto yoffset = (int32_t) args[3]->NumberValue(context).ToChecked();
1158
- auto x = (int32_t) args[4]->NumberValue(context).ToChecked();
1159
- auto y = (int32_t) args[5]->NumberValue(context).ToChecked();
1160
- auto width = (int32_t) args[6]->NumberValue(context).ToChecked();
1161
- auto height = (int32_t) args[7]->NumberValue(context).ToChecked();
1162
-
1163
- canvas_native_webgl_copy_tex_sub_image2d(
1164
- target,
1165
- level,
1166
- xoffset,
1167
- yoffset,
1168
- x,
1169
- y,
1170
- width,
1171
- height,
1172
- ptr->GetState()
1173
- );
1174
- }
1114
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1115
+ auto level = (int32_t) args[1]->NumberValue(context).ToChecked();
1116
+ auto xoffset = (int32_t) args[2]->NumberValue(context).ToChecked();
1117
+ auto yoffset = (int32_t) args[3]->NumberValue(context).ToChecked();
1118
+ auto x = (int32_t) args[4]->NumberValue(context).ToChecked();
1119
+ auto y = (int32_t) args[5]->NumberValue(context).ToChecked();
1120
+ auto width = (int32_t) args[6]->NumberValue(context).ToChecked();
1121
+ auto height = (int32_t) args[7]->NumberValue(context).ToChecked();
1122
+
1123
+ canvas_native_webgl_copy_tex_sub_image2d(
1124
+ target,
1125
+ level,
1126
+ xoffset,
1127
+ yoffset,
1128
+ x,
1129
+ y,
1130
+ width,
1131
+ height,
1132
+ ptr->GetState()
1133
+ );
1175
1134
 
1176
1135
  }
1177
1136
 
@@ -1331,14 +1290,12 @@ void WebGLRenderingContext::CullFace(const v8::FunctionCallbackInfo<v8::Value> &
1331
1290
  auto context = isolate->GetCurrentContext();
1332
1291
 
1333
1292
 
1334
- if (args.Length() > 0) {
1335
- auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
1293
+ auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
1336
1294
 
1337
- canvas_native_webgl_cull_face(
1338
- mode,
1339
- ptr->GetState()
1340
- );
1341
- }
1295
+ canvas_native_webgl_cull_face(
1296
+ mode,
1297
+ ptr->GetState()
1298
+ );
1342
1299
 
1343
1300
  }
1344
1301
 
@@ -1351,19 +1308,15 @@ void WebGLRenderingContext::DeleteBuffer(const v8::FunctionCallbackInfo<v8::Valu
1351
1308
  auto isolate = args.GetIsolate();
1352
1309
 
1353
1310
 
1354
- if (args.Length() > 0) {
1355
- auto value = args[0];
1356
- if (value->IsObject()) {
1357
- auto type = GetNativeType(isolate, value.As<v8::Object>());
1358
- if (type == NativeType::WebGLBuffer) {
1359
- auto buffer = WebGLBuffer::GetPointer(value.As<v8::Object>());
1360
- if (buffer != nullptr) {
1361
- canvas_native_webgl_delete_buffer(
1362
- buffer->GetBuffer(),
1363
- ptr->GetState()
1364
- );
1365
- }
1366
- }
1311
+ auto value = args[0];
1312
+ auto type = GetNativeType(isolate, value.As<v8::Object>());
1313
+ if (type == NativeType::WebGLBuffer) {
1314
+ auto buffer = WebGLBuffer::GetPointer(value.As<v8::Object>());
1315
+ if (buffer != nullptr) {
1316
+ canvas_native_webgl_delete_buffer(
1317
+ buffer->GetBuffer(),
1318
+ ptr->GetState()
1319
+ );
1367
1320
  }
1368
1321
  }
1369
1322
 
@@ -1501,14 +1454,12 @@ void WebGLRenderingContext::DepthFunc(const v8::FunctionCallbackInfo<v8::Value>
1501
1454
 
1502
1455
  auto value = args[0];
1503
1456
 
1504
- if (args.Length() > 0) {
1505
- auto func = (uint32_t) value->NumberValue(context).ToChecked();
1457
+ auto func = (uint32_t) value->NumberValue(context).ToChecked();
1506
1458
 
1507
- canvas_native_webgl_depth_func(
1508
- func,
1509
- ptr->GetState()
1510
- );
1511
- }
1459
+ canvas_native_webgl_depth_func(
1460
+ func,
1461
+ ptr->GetState()
1462
+ );
1512
1463
  }
1513
1464
 
1514
1465
  void WebGLRenderingContext::DepthMask(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -1521,15 +1472,13 @@ void WebGLRenderingContext::DepthMask(const v8::FunctionCallbackInfo<v8::Value>
1521
1472
 
1522
1473
  auto value = args[0];
1523
1474
 
1524
- if (args.Length() > 0) {
1525
- auto mask = value->BooleanValue(isolate);
1526
-
1527
- canvas_native_webgl_depth_mask(
1528
- mask,
1529
- ptr->GetState()
1530
- );
1531
- }
1532
- }
1475
+ auto mask = value->BooleanValue(isolate);
1476
+
1477
+ canvas_native_webgl_depth_mask(
1478
+ mask,
1479
+ ptr->GetState()
1480
+ );
1481
+ }
1533
1482
 
1534
1483
  void WebGLRenderingContext::DepthRange(const v8::FunctionCallbackInfo<v8::Value> &args) {
1535
1484
  WebGLRenderingContext *ptr = GetPointer(args.This());
@@ -1543,14 +1492,11 @@ void WebGLRenderingContext::DepthRange(const v8::FunctionCallbackInfo<v8::Value>
1543
1492
  auto zNear = args[0];
1544
1493
  auto zFar = args[1];
1545
1494
 
1546
- if (args.Length() > 1) {
1547
-
1548
- canvas_native_webgl_depth_range(
1549
- static_cast<float>(zNear->NumberValue(context).ToChecked()),
1550
- static_cast<float>(zFar->NumberValue(context).ToChecked()),
1551
- ptr->GetState()
1552
- );
1553
- }
1495
+ canvas_native_webgl_depth_range(
1496
+ static_cast<float>(zNear->NumberValue(context).ToChecked()),
1497
+ static_cast<float>(zFar->NumberValue(context).ToChecked()),
1498
+ ptr->GetState()
1499
+ );
1554
1500
  }
1555
1501
 
1556
1502
  void WebGLRenderingContext::DetachShader(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -1565,27 +1511,24 @@ void WebGLRenderingContext::DetachShader(const v8::FunctionCallbackInfo<v8::Valu
1565
1511
  auto programValue = args[0];
1566
1512
  auto shaderValue = args[1];
1567
1513
 
1568
- if (programValue->IsObject() &&
1569
- shaderValue->IsObject()) {
1570
- auto programType = GetNativeType(isolate, programValue);
1571
- auto shaderType = GetNativeType(isolate, shaderValue);
1572
- WebGLProgram *program = nullptr;
1573
- WebGLShader *shader = nullptr;
1574
- if (programType == NativeType::WebGLProgram) {
1575
- program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1576
- }
1577
- if (shaderType == NativeType::WebGLShader) {
1578
- shader = WebGLShader::GetPointer(shaderValue.As<v8::Object>());
1579
- }
1514
+ auto programType = GetNativeType(isolate, programValue);
1515
+ auto shaderType = GetNativeType(isolate, shaderValue);
1516
+ WebGLProgram *program = nullptr;
1517
+ WebGLShader *shader = nullptr;
1518
+ if (programType == NativeType::WebGLProgram) {
1519
+ program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1520
+ }
1521
+ if (shaderType == NativeType::WebGLShader) {
1522
+ shader = WebGLShader::GetPointer(shaderValue.As<v8::Object>());
1523
+ }
1580
1524
 
1581
- if (program != nullptr &&
1582
- shader != nullptr) {
1583
- canvas_native_webgl_detach_shader(
1584
- program->GetProgram(),
1585
- shader->GetShader(),
1586
- ptr->GetState()
1587
- );
1588
- }
1525
+ if (program != nullptr &&
1526
+ shader != nullptr) {
1527
+ canvas_native_webgl_detach_shader(
1528
+ program->GetProgram(),
1529
+ shader->GetShader(),
1530
+ ptr->GetState()
1531
+ );
1589
1532
  }
1590
1533
  }
1591
1534
 
@@ -1963,23 +1906,18 @@ void WebGLRenderingContext::GetBufferParameter(const v8::FunctionCallbackInfo<v8
1963
1906
  auto isolate = args.GetIsolate();
1964
1907
  auto context = isolate->GetCurrentContext();
1965
1908
 
1966
- if (args.Length() > 1) {
1967
- auto target = (uint32_t) args[0]->NumberValue(
1968
- context).ToChecked();
1969
- auto pname = (uint32_t) args[1]->NumberValue(
1970
- context).ToChecked();
1971
-
1972
- auto param = canvas_native_webgl_get_buffer_parameter(
1973
- target,
1974
- pname,
1975
- ptr->GetState()
1976
- );
1909
+ auto target = (uint32_t) args[0]->NumberValue(
1910
+ context).ToChecked();
1911
+ auto pname = (uint32_t) args[1]->NumberValue(
1912
+ context).ToChecked();
1977
1913
 
1978
- args.GetReturnValue().Set(param);
1979
- return;
1980
- }
1914
+ auto param = canvas_native_webgl_get_buffer_parameter(
1915
+ target,
1916
+ pname,
1917
+ ptr->GetState()
1918
+ );
1981
1919
 
1982
- args.GetReturnValue().SetUndefined();
1920
+ args.GetReturnValue().Set(param);
1983
1921
 
1984
1922
  }
1985
1923
 
@@ -2389,22 +2327,17 @@ void WebGLRenderingContext::GetParameter(const v8::FunctionCallbackInfo<v8::Valu
2389
2327
  auto isolate = args.GetIsolate();
2390
2328
  auto context = isolate->GetCurrentContext();
2391
2329
 
2392
- // TODO remove extra allocations
2393
- if (args.Length() > 0) {
2394
- auto pname = (uint32_t) args[0]->NumberValue(
2395
- context).ToChecked();
2396
- auto result = canvas_native_webgl_get_parameter(
2397
- pname,
2398
- ptr->GetState());
2330
+ auto pname = (uint32_t) args[0]->NumberValue(
2331
+ context).ToChecked();
2332
+ auto result = canvas_native_webgl_get_parameter(
2333
+ pname,
2334
+ ptr->GetState());
2399
2335
 
2400
- auto ret = ptr->GetParameterInternal(isolate, pname, result);
2336
+ auto ret = ptr->GetParameterInternal(isolate, pname, result);
2401
2337
 
2402
- canvas_native_webgl_WebGLResult_destroy(result);
2338
+ canvas_native_webgl_WebGLResult_destroy(result);
2403
2339
 
2404
- args.GetReturnValue().Set(ret);
2405
- return;
2406
- }
2407
- args.GetReturnValue().SetNull();
2340
+ args.GetReturnValue().Set(ret);
2408
2341
  }
2409
2342
 
2410
2343
  void WebGLRenderingContext::GetProgramInfoLog(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -2416,31 +2349,28 @@ void WebGLRenderingContext::GetProgramInfoLog(const v8::FunctionCallbackInfo<v8:
2416
2349
 
2417
2350
  auto isolate = args.GetIsolate();
2418
2351
 
2419
- if (args.Length() > 0) {
2420
- auto programValue = args[0];
2421
- auto type = GetNativeType(isolate, programValue);
2422
- if (type == NativeType::WebGLProgram) {
2423
- auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2424
- if (program != nullptr) {
2425
- auto log = canvas_native_webgl_get_program_info_log(
2426
- program->GetProgram(),
2427
- ptr->GetState()
2428
- );
2352
+ auto programValue = args[0];
2353
+ auto type = GetNativeType(isolate, programValue);
2354
+ if (type == NativeType::WebGLProgram) {
2355
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2356
+ if (program != nullptr) {
2357
+ auto log = canvas_native_webgl_get_program_info_log(
2358
+ program->GetProgram(),
2359
+ ptr->GetState()
2360
+ );
2429
2361
 
2430
2362
 
2431
- if (strlen(log) == 0) {
2432
- args.GetReturnValue().SetEmptyString();
2433
- canvas_native_string_destroy((char *) log);
2434
- return;
2435
- }
2436
-
2437
- args.GetReturnValue().Set(ConvertToV8OneByteString(isolate, (char *) log));
2363
+ if (strlen(log) == 0) {
2364
+ args.GetReturnValue().SetEmptyString();
2365
+ canvas_native_string_destroy((char *) log);
2438
2366
  return;
2439
2367
  }
2368
+
2369
+ args.GetReturnValue().Set(ConvertToV8OneByteString(isolate, (char *) log));
2370
+ return;
2440
2371
  }
2441
2372
  }
2442
2373
 
2443
- // todo check return
2444
2374
  args.GetReturnValue().SetEmptyString();
2445
2375
  }
2446
2376
 
@@ -2454,48 +2384,46 @@ void WebGLRenderingContext::GetProgramParameter(const v8::FunctionCallbackInfo<v
2454
2384
  auto isolate = args.GetIsolate();
2455
2385
  auto context = isolate->GetCurrentContext();
2456
2386
 
2457
- if (args.Length() > 1) {
2458
- auto programValue = args[0];
2459
- auto type = GetNativeType(isolate, programValue);
2460
- auto pname = (uint32_t) args[1]->NumberValue(
2461
- context).ToChecked();
2462
- if (type == NativeType::WebGLProgram) {
2463
- auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2464
- if (program != nullptr) {
2465
- auto ret = canvas_native_webgl_get_program_parameter(
2466
- program->GetProgram(),
2467
- pname,
2468
- ptr->GetState()
2469
- );
2387
+ auto programValue = args[0];
2388
+ auto type = GetNativeType(isolate, programValue);
2389
+ auto pname = (uint32_t) args[1]->NumberValue(
2390
+ context).ToChecked();
2391
+ if (type == NativeType::WebGLProgram) {
2392
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2393
+ if (program != nullptr) {
2394
+ auto ret = canvas_native_webgl_get_program_parameter(
2395
+ program->GetProgram(),
2396
+ pname,
2397
+ ptr->GetState()
2398
+ );
2470
2399
 
2471
2400
 
2472
- if (canvas_native_webgl_result_get_is_none(
2473
- ret)) {
2474
- args.GetReturnValue().SetNull();
2401
+ if (canvas_native_webgl_result_get_is_none(
2402
+ ret)) {
2403
+ args.GetReturnValue().SetNull();
2404
+
2405
+ canvas_native_webgl_WebGLResult_destroy(ret);
2406
+ return;
2407
+ }
2408
+ switch (pname) {
2409
+ case GL_DELETE_STATUS:
2410
+ case GL_LINK_STATUS:
2411
+ case GL_VALIDATE_STATUS:
2412
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_bool(
2413
+ ret));
2414
+ canvas_native_webgl_WebGLResult_destroy(ret);
2415
+ return;
2416
+ default:
2417
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
2418
+ ret));
2475
2419
 
2476
2420
  canvas_native_webgl_WebGLResult_destroy(ret);
2477
2421
  return;
2478
- }
2479
- switch (pname) {
2480
- case GL_DELETE_STATUS:
2481
- case GL_LINK_STATUS:
2482
- case GL_VALIDATE_STATUS:
2483
- args.GetReturnValue().Set(canvas_native_webgl_result_get_bool(
2484
- ret));
2485
- canvas_native_webgl_WebGLResult_destroy(ret);
2486
- return;
2487
- default:
2488
- args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
2489
- ret));
2490
-
2491
- canvas_native_webgl_WebGLResult_destroy(ret);
2492
- return;
2493
- }
2494
2422
  }
2495
2423
  }
2496
2424
  }
2497
2425
 
2498
- // todo check return
2426
+
2499
2427
  args.GetReturnValue().SetNull();
2500
2428
  }
2501
2429
 
@@ -2537,31 +2465,28 @@ void WebGLRenderingContext::GetShaderInfoLog(const v8::FunctionCallbackInfo<v8::
2537
2465
 
2538
2466
  auto isolate = args.GetIsolate();
2539
2467
 
2540
- if (args.Length() > 0) {
2541
- auto value = args[0];
2542
- auto type = GetNativeType(isolate, value);
2543
- if (type == NativeType::WebGLShader) {
2544
- auto shader = WebGLShader::GetPointer(value.As<v8::Object>());
2545
- if (shader != nullptr) {
2546
- auto log = canvas_native_webgl_get_shader_info_log(
2547
- shader->GetShader(),
2548
- ptr->GetState()
2549
- );
2550
-
2551
- if (strlen(log) == 0) {
2552
- args.GetReturnValue().SetEmptyString();
2553
- canvas_native_string_destroy((char *) log);
2554
- return;
2555
- }
2556
-
2557
- args.GetReturnValue().Set(ConvertToV8OneByteString(isolate, (char *) log));
2468
+ auto value = args[0];
2469
+ auto type = GetNativeType(isolate, value);
2470
+ if (type == NativeType::WebGLShader) {
2471
+ auto shader = WebGLShader::GetPointer(value.As<v8::Object>());
2472
+ if (shader != nullptr) {
2473
+ auto log = canvas_native_webgl_get_shader_info_log(
2474
+ shader->GetShader(),
2475
+ ptr->GetState()
2476
+ );
2558
2477
 
2478
+ if (strlen(log) == 0) {
2479
+ args.GetReturnValue().SetEmptyString();
2480
+ canvas_native_string_destroy((char *) log);
2559
2481
  return;
2560
2482
  }
2483
+
2484
+ args.GetReturnValue().Set(ConvertToV8OneByteString(isolate, (char *) log));
2485
+
2486
+ return;
2561
2487
  }
2562
2488
  }
2563
2489
 
2564
- // todo check return
2565
2490
  args.GetReturnValue().SetEmptyString();
2566
2491
  }
2567
2492
 
@@ -2575,50 +2500,48 @@ void WebGLRenderingContext::GetShaderParameter(const v8::FunctionCallbackInfo<v8
2575
2500
  auto isolate = args.GetIsolate();
2576
2501
  auto context = isolate->GetCurrentContext();
2577
2502
 
2578
- if (args.Length() > 1) {
2579
- auto value = args[0];
2580
- auto type = GetNativeType(isolate, value);
2581
- auto pname = (uint32_t) args[1]->NumberValue(
2582
- context).ToChecked();
2583
- if (type == NativeType::WebGLShader) {
2584
- auto shader = WebGLShader::GetPointer(value.As<v8::Object>());
2585
- if (shader != nullptr) {
2586
- auto ret = canvas_native_webgl_get_shader_parameter(
2587
- shader->GetShader(),
2588
- pname,
2589
- ptr->GetState()
2590
- );
2591
-
2592
- if (canvas_native_webgl_result_get_is_none(
2593
- ret)) {
2594
- args.GetReturnValue().SetNull();
2595
-
2596
- canvas_native_webgl_WebGLResult_destroy(ret);
2597
- return;
2598
- }
2503
+ auto value = args[0];
2504
+ auto type = GetNativeType(isolate, value);
2505
+ auto pname = (uint32_t) args[1]->NumberValue(
2506
+ context).ToChecked();
2507
+ if (type == NativeType::WebGLShader) {
2508
+ auto shader = WebGLShader::GetPointer(value.As<v8::Object>());
2509
+ if (shader != nullptr) {
2510
+ auto ret = canvas_native_webgl_get_shader_parameter(
2511
+ shader->GetShader(),
2512
+ pname,
2513
+ ptr->GetState()
2514
+ );
2599
2515
 
2600
- if (pname ==
2601
- GL_DELETE_STATUS ||
2602
- pname ==
2603
- GL_COMPILE_STATUS) {
2604
- args.GetReturnValue().Set(canvas_native_webgl_result_get_bool(
2605
- ret));
2516
+ if (canvas_native_webgl_result_get_is_none(
2517
+ ret)) {
2518
+ args.GetReturnValue().SetNull();
2606
2519
 
2607
- canvas_native_webgl_WebGLResult_destroy(ret);
2608
- return;
2609
- }
2520
+ canvas_native_webgl_WebGLResult_destroy(ret);
2521
+ return;
2522
+ }
2610
2523
 
2611
- args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
2524
+ if (pname ==
2525
+ GL_DELETE_STATUS ||
2526
+ pname ==
2527
+ GL_COMPILE_STATUS) {
2528
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_bool(
2612
2529
  ret));
2613
2530
 
2614
2531
  canvas_native_webgl_WebGLResult_destroy(ret);
2615
-
2616
2532
  return;
2617
2533
  }
2534
+
2535
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
2536
+ ret));
2537
+
2538
+ canvas_native_webgl_WebGLResult_destroy(ret);
2539
+
2540
+ return;
2618
2541
  }
2619
2542
  }
2620
2543
 
2621
- // todo check return
2544
+
2622
2545
  args.GetReturnValue().SetNull();
2623
2546
  }
2624
2547
 
@@ -2633,25 +2556,19 @@ WebGLRenderingContext::GetShaderPrecisionFormat(const v8::FunctionCallbackInfo<v
2633
2556
  auto isolate = args.GetIsolate();
2634
2557
  auto context = isolate->GetCurrentContext();
2635
2558
 
2636
- if (args.Length() > 1) {
2637
- auto shaderType = (uint32_t) args[0]->NumberValue(
2638
- context).ToChecked();
2639
- auto precisionType = (uint32_t) args[1]->NumberValue(
2640
- context).ToChecked();
2641
- auto ret = canvas_native_webgl_get_shader_precision_format(
2642
- shaderType,
2643
- precisionType,
2644
- ptr->GetState()
2645
- );
2646
- auto shader = WebGLShaderPrecisionFormatImpl::NewInstance(isolate,
2647
- new WebGLShaderPrecisionFormatImpl(
2648
- ret));
2649
- args.GetReturnValue().Set(shader);
2650
- return;
2651
- }
2652
-
2653
- // todo check return
2654
- args.GetReturnValue().SetNull();
2559
+ auto shaderType = (uint32_t) args[0]->NumberValue(
2560
+ context).ToChecked();
2561
+ auto precisionType = (uint32_t) args[1]->NumberValue(
2562
+ context).ToChecked();
2563
+ auto ret = canvas_native_webgl_get_shader_precision_format(
2564
+ shaderType,
2565
+ precisionType,
2566
+ ptr->GetState()
2567
+ );
2568
+ auto shader = WebGLShaderPrecisionFormatImpl::NewInstance(isolate,
2569
+ new WebGLShaderPrecisionFormatImpl(
2570
+ ret));
2571
+ args.GetReturnValue().Set(shader);
2655
2572
  }
2656
2573
 
2657
2574
  void WebGLRenderingContext::GetShaderSource(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -2663,30 +2580,27 @@ void WebGLRenderingContext::GetShaderSource(const v8::FunctionCallbackInfo<v8::V
2663
2580
 
2664
2581
  auto isolate = args.GetIsolate();
2665
2582
 
2666
- if (args.Length() > 0) {
2667
- auto value = args[0];
2668
- auto type = GetNativeType(isolate, value);
2669
- if (type == NativeType::WebGLShader) {
2670
- auto shader = WebGLShader::GetPointer(value.As<v8::Object>());
2671
-
2672
- if (shader != nullptr) {
2673
- auto source = canvas_native_webgl_get_shader_source(
2674
- shader->GetShader(),
2675
- ptr->GetState()
2676
- );
2583
+ auto value = args[0];
2584
+ auto type = GetNativeType(isolate, value);
2585
+ if (type == NativeType::WebGLShader) {
2586
+ auto shader = WebGLShader::GetPointer(value.As<v8::Object>());
2677
2587
 
2678
- if (strlen(source) == 0) {
2679
- args.GetReturnValue().SetEmptyString();
2680
- canvas_native_string_destroy((char *) source);
2681
- return;
2682
- }
2588
+ if (shader != nullptr) {
2589
+ auto source = canvas_native_webgl_get_shader_source(
2590
+ shader->GetShader(),
2591
+ ptr->GetState()
2592
+ );
2683
2593
 
2684
- args.GetReturnValue().Set(ConvertToV8OneByteString(isolate, (char *) source));
2594
+ if (strlen(source) == 0) {
2595
+ args.GetReturnValue().SetEmptyString();
2596
+ canvas_native_string_destroy((char *) source);
2685
2597
  return;
2686
2598
  }
2599
+
2600
+ args.GetReturnValue().Set(ConvertToV8OneByteString(isolate, (char *) source));
2601
+ return;
2687
2602
  }
2688
2603
  }
2689
-
2690
2604
  // todo check return
2691
2605
  args.GetReturnValue().SetEmptyString();
2692
2606
  }
@@ -2751,22 +2665,16 @@ WebGLRenderingContext::GetTexParameter(const v8::FunctionCallbackInfo<v8::Value>
2751
2665
  auto isolate = args.GetIsolate();
2752
2666
  auto context = isolate->GetCurrentContext();
2753
2667
 
2754
- if (args.Length() > 1) {
2755
- auto target = (uint32_t) args[0]->NumberValue(
2756
- context).ToChecked();
2757
- auto pname = (uint32_t) args[1]->NumberValue(
2758
- context).ToChecked();
2759
- auto ret = canvas_native_webgl_get_tex_parameter(
2760
- target,
2761
- pname,
2762
- ptr->GetState()
2763
- );
2764
- args.GetReturnValue().Set(ret);
2765
- return;
2766
- }
2767
-
2768
- // todo check return
2769
- args.GetReturnValue().SetNull();
2668
+ auto target = (uint32_t) args[0]->NumberValue(
2669
+ context).ToChecked();
2670
+ auto pname = (uint32_t) args[1]->NumberValue(
2671
+ context).ToChecked();
2672
+ auto ret = canvas_native_webgl_get_tex_parameter(
2673
+ target,
2674
+ pname,
2675
+ ptr->GetState()
2676
+ );
2677
+ args.GetReturnValue().Set(ret);
2770
2678
  }
2771
2679
 
2772
2680
  void
@@ -2779,27 +2687,25 @@ WebGLRenderingContext::GetUniformLocation(const v8::FunctionCallbackInfo<v8::Val
2779
2687
 
2780
2688
  auto isolate = args.GetIsolate();
2781
2689
 
2782
- if (args.Length() > 1) {
2783
- auto programValue = args[0];
2784
- auto type = GetNativeType(isolate, programValue);
2785
- auto nameValue = args[1];
2786
- if (type == NativeType::WebGLProgram && nameValue->IsString()) {
2787
- auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2788
- if (program != nullptr) {
2789
- auto name = ConvertFromV8String(isolate, args[1]);
2790
-
2791
- auto ret = canvas_native_webgl_get_uniform_location(
2792
- program->GetProgram(),
2793
- name.c_str(),
2794
- ptr->GetState()
2795
- );
2690
+ auto programValue = args[0];
2691
+ auto type = GetNativeType(isolate, programValue);
2692
+ auto nameValue = args[1];
2693
+ if (type == NativeType::WebGLProgram && nameValue->IsString()) {
2694
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2695
+ if (program != nullptr) {
2696
+ auto name = ConvertFromV8String(isolate, args[1]);
2796
2697
 
2797
- auto location = WebGLUniformLocation::NewInstance(isolate, new WebGLUniformLocation(
2798
- ret));
2698
+ auto ret = canvas_native_webgl_get_uniform_location(
2699
+ program->GetProgram(),
2700
+ name.c_str(),
2701
+ ptr->GetState()
2702
+ );
2799
2703
 
2800
- args.GetReturnValue().Set(location);
2801
- return;
2802
- }
2704
+ auto location = WebGLUniformLocation::NewInstance(isolate, new WebGLUniformLocation(
2705
+ ret));
2706
+
2707
+ args.GetReturnValue().Set(location);
2708
+ return;
2803
2709
  }
2804
2710
  }
2805
2711
 
@@ -2818,183 +2724,181 @@ WebGLRenderingContext::GetUniform(const v8::FunctionCallbackInfo<v8::Value> &arg
2818
2724
  auto isolate = args.GetIsolate();
2819
2725
  auto context = isolate->GetCurrentContext();
2820
2726
 
2821
- if (args.Length() > 1) {
2822
- auto programValue = args[0];
2823
- auto programType = GetNativeType(isolate, programValue);
2824
- auto locationValue = args[1];
2825
- auto locationType = GetNativeType(isolate, locationValue);
2826
- if (programType == NativeType::WebGLProgram &&
2827
- locationType == NativeType::WebGLUniformLocation) {
2727
+ auto programValue = args[0];
2728
+ auto programType = GetNativeType(isolate, programValue);
2729
+ auto locationValue = args[1];
2730
+ auto locationType = GetNativeType(isolate, locationValue);
2731
+ if (programType == NativeType::WebGLProgram &&
2732
+ locationType == NativeType::WebGLUniformLocation) {
2828
2733
 
2829
- auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2830
- auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2734
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2735
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2831
2736
 
2832
2737
 
2833
- if (program != nullptr &&
2834
- location != nullptr) {
2738
+ if (program != nullptr &&
2739
+ location != nullptr) {
2835
2740
 
2836
- auto val = canvas_native_webgl_get_uniform(
2837
- program->GetProgram(),
2838
- location->GetUniformLocation(),
2839
- ptr->GetState());
2741
+ auto val = canvas_native_webgl_get_uniform(
2742
+ program->GetProgram(),
2743
+ location->GetUniformLocation(),
2744
+ ptr->GetState());
2840
2745
 
2841
- switch (canvas_native_webgl_result_get_type(
2842
- val)) {
2843
- case WebGLResultType::WebGLResultTypeBoolean:
2844
- args.GetReturnValue().Set(canvas_native_webgl_result_get_bool(
2845
- val));
2846
- canvas_native_webgl_WebGLResult_destroy(val);
2847
- return;
2848
- case WebGLResultType::WebGLResultTypeNone:
2849
- args.GetReturnValue().SetNull();
2850
- canvas_native_webgl_WebGLResult_destroy(val);
2851
- return;
2852
- case WebGLResultType::WebGLResultTypeString: {
2853
- auto str = canvas_native_webgl_result_get_string(
2854
- val);
2855
-
2856
- args.GetReturnValue().Set(
2857
- ConvertToV8OneByteString(isolate, (char *) str));
2858
- canvas_native_webgl_WebGLResult_destroy(val);
2859
- return;
2860
- }
2861
- case WebGLResultType::WebGLResultTypeBooleanArray: {
2862
- auto ret = canvas_native_webgl_result_get_bool_array(
2863
- val);
2864
- auto len = canvas_native_u8_buffer_get_length(ret);
2865
- auto buf = canvas_native_u8_buffer_get_bytes(ret);
2866
- auto array = v8::Array::New(
2867
- isolate, (int) len);
2868
- for (int i = 0;
2869
- i < len; ++i) {
2870
- auto item = buf[i];
2871
- array->Set(
2872
- context, i,
2873
- v8::Boolean::New(isolate,
2874
- item ==
2875
- 1));
2876
- }
2877
- args.GetReturnValue().Set(array);
2878
- canvas_native_webgl_WebGLResult_destroy(val);
2879
- return;
2746
+ switch (canvas_native_webgl_result_get_type(
2747
+ val)) {
2748
+ case WebGLResultType::WebGLResultTypeBoolean:
2749
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_bool(
2750
+ val));
2751
+ canvas_native_webgl_WebGLResult_destroy(val);
2752
+ return;
2753
+ case WebGLResultType::WebGLResultTypeNone:
2754
+ args.GetReturnValue().SetNull();
2755
+ canvas_native_webgl_WebGLResult_destroy(val);
2756
+ return;
2757
+ case WebGLResultType::WebGLResultTypeString: {
2758
+ auto str = canvas_native_webgl_result_get_string(
2759
+ val);
2760
+
2761
+ args.GetReturnValue().Set(
2762
+ ConvertToV8OneByteString(isolate, (char *) str));
2763
+ canvas_native_webgl_WebGLResult_destroy(val);
2764
+ return;
2765
+ }
2766
+ case WebGLResultType::WebGLResultTypeBooleanArray: {
2767
+ auto ret = canvas_native_webgl_result_get_bool_array(
2768
+ val);
2769
+ auto len = canvas_native_u8_buffer_get_length(ret);
2770
+ auto buf = canvas_native_u8_buffer_get_bytes(ret);
2771
+ auto array = v8::Array::New(
2772
+ isolate, (int) len);
2773
+ for (int i = 0;
2774
+ i < len; ++i) {
2775
+ auto item = buf[i];
2776
+ array->Set(
2777
+ context, i,
2778
+ v8::Boolean::New(isolate,
2779
+ item ==
2780
+ 1));
2880
2781
  }
2881
- case WebGLResultType::WebGLResultTypeF32Array: {
2882
- auto ret = canvas_native_webgl_result_get_f32_array(
2883
- val);
2782
+ args.GetReturnValue().Set(array);
2783
+ canvas_native_webgl_WebGLResult_destroy(val);
2784
+ return;
2785
+ }
2786
+ case WebGLResultType::WebGLResultTypeF32Array: {
2787
+ auto ret = canvas_native_webgl_result_get_f32_array(
2788
+ val);
2884
2789
 
2885
2790
 
2886
- auto buf = (uint8_t *) canvas_native_f32_buffer_get_bytes_mut(ret);
2887
- auto size = canvas_native_f32_buffer_get_length(ret);
2888
- auto bytes_size = size * sizeof(float);
2791
+ auto buf = (uint8_t *) canvas_native_f32_buffer_get_bytes_mut(ret);
2792
+ auto size = canvas_native_f32_buffer_get_length(ret);
2793
+ auto bytes_size = size * sizeof(float);
2889
2794
 
2890
2795
 
2891
- auto store = v8::ArrayBuffer::NewBackingStore(buf,
2892
- bytes_size,
2893
- [](void *data, size_t length,
2894
- void *deleter_data) {
2895
- if (deleter_data !=
2896
- nullptr) {
2897
- canvas_native_f32_buffer_destroy(
2898
- (F32Buffer *) deleter_data);
2899
- }
2900
- },
2901
- ret);
2796
+ auto store = v8::ArrayBuffer::NewBackingStore(buf,
2797
+ bytes_size,
2798
+ [](void *data, size_t length,
2799
+ void *deleter_data) {
2800
+ if (deleter_data !=
2801
+ nullptr) {
2802
+ canvas_native_f32_buffer_destroy(
2803
+ (F32Buffer *) deleter_data);
2804
+ }
2805
+ },
2806
+ ret);
2902
2807
 
2903
- auto arraybuffer = v8::ArrayBuffer::New(isolate, std::move(store));
2808
+ auto arraybuffer = v8::ArrayBuffer::New(isolate, std::move(store));
2904
2809
 
2905
- args.GetReturnValue().Set(
2906
- v8::Float32Array::New(arraybuffer, 0, size)
2907
- );
2810
+ args.GetReturnValue().Set(
2811
+ v8::Float32Array::New(arraybuffer, 0, size)
2812
+ );
2908
2813
 
2909
- canvas_native_webgl_WebGLResult_destroy(val);
2814
+ canvas_native_webgl_WebGLResult_destroy(val);
2910
2815
 
2911
- return;
2912
- }
2913
- case WebGLResultType::WebGLResultTypeI32Array: {
2914
- auto ret = canvas_native_webgl_result_get_i32_array(
2915
- val);
2816
+ return;
2817
+ }
2818
+ case WebGLResultType::WebGLResultTypeI32Array: {
2819
+ auto ret = canvas_native_webgl_result_get_i32_array(
2820
+ val);
2916
2821
 
2917
2822
 
2918
- auto buf = (uint8_t *) canvas_native_i32_buffer_get_bytes_mut(ret);
2919
- auto size = canvas_native_i32_buffer_get_length(ret);
2920
- auto bytes_size = size * sizeof(int32_t);
2823
+ auto buf = (uint8_t *) canvas_native_i32_buffer_get_bytes_mut(ret);
2824
+ auto size = canvas_native_i32_buffer_get_length(ret);
2825
+ auto bytes_size = size * sizeof(int32_t);
2921
2826
 
2922
2827
 
2923
- auto store = v8::ArrayBuffer::NewBackingStore(buf, bytes_size,
2924
- [](void *data, size_t length,
2925
- void *deleter_data) {
2926
- if (deleter_data !=
2927
- nullptr) {
2928
- canvas_native_i32_buffer_destroy(
2929
- (I32Buffer *) deleter_data);
2930
- }
2931
- },
2932
- ret);
2828
+ auto store = v8::ArrayBuffer::NewBackingStore(buf, bytes_size,
2829
+ [](void *data, size_t length,
2830
+ void *deleter_data) {
2831
+ if (deleter_data !=
2832
+ nullptr) {
2833
+ canvas_native_i32_buffer_destroy(
2834
+ (I32Buffer *) deleter_data);
2835
+ }
2836
+ },
2837
+ ret);
2933
2838
 
2934
- auto arraybuffer = v8::ArrayBuffer::New(isolate, std::move(store));
2839
+ auto arraybuffer = v8::ArrayBuffer::New(isolate, std::move(store));
2935
2840
 
2936
2841
 
2937
- args.GetReturnValue().Set(
2938
- v8::Int32Array::New(arraybuffer, 0, size)
2939
- );
2842
+ args.GetReturnValue().Set(
2843
+ v8::Int32Array::New(arraybuffer, 0, size)
2844
+ );
2940
2845
 
2941
- canvas_native_webgl_WebGLResult_destroy(val);
2846
+ canvas_native_webgl_WebGLResult_destroy(val);
2942
2847
 
2943
- return;
2944
- }
2945
- case WebGLResultType::WebGLResultTypeU32Array: {
2946
- auto ret = canvas_native_webgl_result_get_u32_array(
2947
- val);
2848
+ return;
2849
+ }
2850
+ case WebGLResultType::WebGLResultTypeU32Array: {
2851
+ auto ret = canvas_native_webgl_result_get_u32_array(
2852
+ val);
2948
2853
 
2949
- auto buf = (uint8_t *) canvas_native_u32_buffer_get_bytes_mut(ret);
2950
- auto size = canvas_native_u32_buffer_get_length(ret);
2951
- auto bytes_size = size * sizeof(uint32_t);
2854
+ auto buf = (uint8_t *) canvas_native_u32_buffer_get_bytes_mut(ret);
2855
+ auto size = canvas_native_u32_buffer_get_length(ret);
2856
+ auto bytes_size = size * sizeof(uint32_t);
2952
2857
 
2953
2858
 
2954
- auto store = v8::ArrayBuffer::NewBackingStore(buf, bytes_size,
2955
- [](void *data, size_t length,
2956
- void *deleter_data) {
2957
- if (deleter_data !=
2958
- nullptr) {
2959
- canvas_native_u32_buffer_destroy(
2960
- (U32Buffer *) deleter_data);
2961
- }
2962
- },
2963
- ret);
2859
+ auto store = v8::ArrayBuffer::NewBackingStore(buf, bytes_size,
2860
+ [](void *data, size_t length,
2861
+ void *deleter_data) {
2862
+ if (deleter_data !=
2863
+ nullptr) {
2864
+ canvas_native_u32_buffer_destroy(
2865
+ (U32Buffer *) deleter_data);
2866
+ }
2867
+ },
2868
+ ret);
2964
2869
 
2965
- auto arraybuffer = v8::ArrayBuffer::New(isolate, std::move(store));
2870
+ auto arraybuffer = v8::ArrayBuffer::New(isolate, std::move(store));
2966
2871
 
2967
2872
 
2968
- args.GetReturnValue().Set(
2969
- v8::Uint32Array::New(arraybuffer, 0, size)
2970
- );
2873
+ args.GetReturnValue().Set(
2874
+ v8::Uint32Array::New(arraybuffer, 0, size)
2875
+ );
2971
2876
 
2972
2877
 
2973
- canvas_native_webgl_WebGLResult_destroy(val);
2878
+ canvas_native_webgl_WebGLResult_destroy(val);
2974
2879
 
2975
- return;
2880
+ return;
2976
2881
 
2977
2882
 
2978
- }
2979
- case WebGLResultType::WebGLResultTypeF32:
2980
- args.GetReturnValue().Set((double) canvas_native_webgl_result_get_f32(
2981
- val));
2982
-
2983
- canvas_native_webgl_WebGLResult_destroy(val);
2984
- return;
2985
- case WebGLResultType::WebGLResultTypeI32:
2986
- args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
2987
- val));
2988
-
2989
- canvas_native_webgl_WebGLResult_destroy(val);
2990
- return;
2991
- case WebGLResultType::WebGLResultTypeU32:
2992
- args.GetReturnValue().Set(canvas_native_webgl_result_get_u32(
2993
- val));
2994
-
2995
- canvas_native_webgl_WebGLResult_destroy(val);
2996
- return;
2997
2883
  }
2884
+ case WebGLResultType::WebGLResultTypeF32:
2885
+ args.GetReturnValue().Set((double) canvas_native_webgl_result_get_f32(
2886
+ val));
2887
+
2888
+ canvas_native_webgl_WebGLResult_destroy(val);
2889
+ return;
2890
+ case WebGLResultType::WebGLResultTypeI32:
2891
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
2892
+ val));
2893
+
2894
+ canvas_native_webgl_WebGLResult_destroy(val);
2895
+ return;
2896
+ case WebGLResultType::WebGLResultTypeU32:
2897
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_u32(
2898
+ val));
2899
+
2900
+ canvas_native_webgl_WebGLResult_destroy(val);
2901
+ return;
2998
2902
  }
2999
2903
  }
3000
2904
  }
@@ -3014,21 +2918,15 @@ WebGLRenderingContext::GetVertexAttribOffset(const v8::FunctionCallbackInfo<v8::
3014
2918
  auto isolate = args.GetIsolate();
3015
2919
  auto context = isolate->GetCurrentContext();
3016
2920
 
3017
- if (args.Length() > 1) {
3018
- auto index = (uint32_t) args[0]->NumberValue(
3019
- context).ToChecked();
3020
- auto pname = (uint32_t) args[1]->NumberValue(
3021
- context).ToChecked();
3022
- auto ret = canvas_native_webgl_get_vertex_attrib_offset(
3023
- index,
3024
- pname,
3025
- ptr->GetState());
3026
- args.GetReturnValue().Set(static_cast<double>(ret));
3027
- return;
3028
- }
3029
-
3030
- // todo check return
3031
- args.GetReturnValue().SetNull();
2921
+ auto index = (uint32_t) args[0]->NumberValue(
2922
+ context).ToChecked();
2923
+ auto pname = (uint32_t) args[1]->NumberValue(
2924
+ context).ToChecked();
2925
+ auto ret = canvas_native_webgl_get_vertex_attrib_offset(
2926
+ index,
2927
+ pname,
2928
+ ptr->GetState());
2929
+ args.GetReturnValue().Set(static_cast<double>(ret));
3032
2930
  }
3033
2931
 
3034
2932
  void
@@ -3043,63 +2941,58 @@ WebGLRenderingContext::GetVertexAttrib(const v8::FunctionCallbackInfo<v8::Value>
3043
2941
  auto context = isolate->GetCurrentContext();
3044
2942
 
3045
2943
 
3046
- if (args.Length() > 1) {
3047
- auto index = (uint32_t) args[0]->NumberValue(
3048
- context).ToChecked();
3049
- auto pname = (uint32_t) args[1]->NumberValue(
3050
- context).ToChecked();
3051
- auto ret = canvas_native_webgl_get_vertex_attrib(
3052
- index,
3053
- pname,
3054
- ptr->GetState());
2944
+ auto index = (uint32_t) args[0]->NumberValue(
2945
+ context).ToChecked();
2946
+ auto pname = (uint32_t) args[1]->NumberValue(
2947
+ context).ToChecked();
2948
+ auto ret = canvas_native_webgl_get_vertex_attrib(
2949
+ index,
2950
+ pname,
2951
+ ptr->GetState());
3055
2952
 
3056
- if (pname ==
3057
- GL_CURRENT_VERTEX_ATTRIB) {
3058
- auto val = canvas_native_webgl_result_get_f32_array(
3059
- ret);
2953
+ if (pname ==
2954
+ GL_CURRENT_VERTEX_ATTRIB) {
2955
+ auto val = canvas_native_webgl_result_get_f32_array(
2956
+ ret);
3060
2957
 
3061
2958
 
3062
- auto buf = (uint8_t *) canvas_native_f32_buffer_get_bytes_mut(val);
3063
- auto size = canvas_native_f32_buffer_get_length(val);
3064
- auto bytes_size = size * sizeof(float);
2959
+ auto buf = (uint8_t *) canvas_native_f32_buffer_get_bytes_mut(val);
2960
+ auto size = canvas_native_f32_buffer_get_length(val);
2961
+ auto bytes_size = size * sizeof(float);
3065
2962
 
3066
- auto store = v8::ArrayBuffer::NewBackingStore(buf, bytes_size,
3067
- [](void *data, size_t length,
3068
- void *deleter_data) {
3069
- if (deleter_data != nullptr) {
3070
- canvas_native_f32_buffer_destroy(
3071
- (F32Buffer *) deleter_data);
3072
- }
3073
- },
3074
- val);
2963
+ auto store = v8::ArrayBuffer::NewBackingStore(buf, bytes_size,
2964
+ [](void *data, size_t length,
2965
+ void *deleter_data) {
2966
+ if (deleter_data != nullptr) {
2967
+ canvas_native_f32_buffer_destroy(
2968
+ (F32Buffer *) deleter_data);
2969
+ }
2970
+ },
2971
+ val);
3075
2972
 
3076
- auto arraybuffer = v8::ArrayBuffer::New(isolate, std::move(store));
2973
+ auto arraybuffer = v8::ArrayBuffer::New(isolate, std::move(store));
3077
2974
 
3078
2975
 
3079
- args.GetReturnValue().Set(
3080
- v8::Float32Array::New(arraybuffer, 0, size)
3081
- );
2976
+ args.GetReturnValue().Set(
2977
+ v8::Float32Array::New(arraybuffer, 0, size)
2978
+ );
3082
2979
 
3083
- canvas_native_webgl_WebGLResult_destroy(ret);
3084
- return;
3085
- } else if (pname ==
3086
- GL_VERTEX_ATTRIB_ARRAY_ENABLED ||
3087
- pname ==
3088
- GL_VERTEX_ATTRIB_ARRAY_NORMALIZED) {
3089
- args.GetReturnValue().Set(canvas_native_webgl_result_get_bool(
3090
- ret));
3091
- canvas_native_webgl_WebGLResult_destroy(ret);
3092
- return;
3093
- } else {
3094
- args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
3095
- ret));
3096
- canvas_native_webgl_WebGLResult_destroy(ret);
3097
- return;
3098
- }
2980
+ canvas_native_webgl_WebGLResult_destroy(ret);
2981
+ return;
2982
+ } else if (pname ==
2983
+ GL_VERTEX_ATTRIB_ARRAY_ENABLED ||
2984
+ pname ==
2985
+ GL_VERTEX_ATTRIB_ARRAY_NORMALIZED) {
2986
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_bool(
2987
+ ret));
2988
+ canvas_native_webgl_WebGLResult_destroy(ret);
2989
+ return;
2990
+ } else {
2991
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
2992
+ ret));
2993
+ canvas_native_webgl_WebGLResult_destroy(ret);
2994
+ return;
3099
2995
  }
3100
-
3101
- // todo check return
3102
- args.GetReturnValue().SetNull();
3103
2996
  }
3104
2997
 
3105
2998
  void
@@ -3113,15 +3006,13 @@ WebGLRenderingContext::Hint(const v8::FunctionCallbackInfo<v8::Value> &args) {
3113
3006
  auto isolate = args.GetIsolate();
3114
3007
  auto context = isolate->GetCurrentContext();
3115
3008
 
3116
- if (args.Length() > 1) {
3117
- auto target = (uint32_t) args[0]->NumberValue(
3118
- context).ToChecked();
3119
- auto mode = (uint32_t) args[1]->NumberValue(
3120
- context).ToChecked();
3121
- canvas_native_webgl_hint(target,
3122
- mode,
3123
- ptr->GetState());
3124
- }
3009
+ auto target = (uint32_t) args[0]->NumberValue(
3010
+ context).ToChecked();
3011
+ auto mode = (uint32_t) args[1]->NumberValue(
3012
+ context).ToChecked();
3013
+ canvas_native_webgl_hint(target,
3014
+ mode,
3015
+ ptr->GetState());
3125
3016
  }
3126
3017
 
3127
3018
  void
@@ -3176,15 +3067,11 @@ WebGLRenderingContext::IsEnabled(const v8::FunctionCallbackInfo<v8::Value> &args
3176
3067
  auto isolate = args.GetIsolate();
3177
3068
  auto context = isolate->GetCurrentContext();
3178
3069
 
3179
- if (args.Length() > 0) {
3180
- auto cap = (uint32_t) args[0]->NumberValue(
3181
- context).ToChecked();
3182
- auto ret = canvas_native_webgl_is_enabled(
3183
- cap, ptr->GetState());
3184
- args.GetReturnValue().Set(ret);
3185
- return;
3186
- }
3187
- args.GetReturnValue().Set(false);
3070
+ auto cap = (uint32_t) args[0]->NumberValue(
3071
+ context).ToChecked();
3072
+ auto ret = canvas_native_webgl_is_enabled(
3073
+ cap, ptr->GetState());
3074
+ args.GetReturnValue().Set(ret);
3188
3075
  }
3189
3076
 
3190
3077
  void
@@ -3334,13 +3221,11 @@ WebGLRenderingContext::LineWidth(const v8::FunctionCallbackInfo<v8::Value> &args
3334
3221
  auto isolate = args.GetIsolate();
3335
3222
  auto context = isolate->GetCurrentContext();
3336
3223
 
3337
- if (args.Length() > 0) {
3338
- auto width = args[0]->NumberValue(
3339
- context).ToChecked();
3340
- canvas_native_webgl_line_width(
3341
- static_cast<float>(width),
3342
- ptr->GetState());
3343
- }
3224
+ auto width = args[0]->NumberValue(
3225
+ context).ToChecked();
3226
+ canvas_native_webgl_line_width(
3227
+ static_cast<float>(width),
3228
+ ptr->GetState());
3344
3229
 
3345
3230
  }
3346
3231
 
@@ -3374,26 +3259,23 @@ WebGLRenderingContext::PixelStorei(const v8::FunctionCallbackInfo<v8::Value> &ar
3374
3259
  auto isolate = args.GetIsolate();
3375
3260
  auto context = isolate->GetCurrentContext();
3376
3261
 
3377
- if (args.Length() > 1) {
3378
- auto pname = (uint32_t) args[0]->NumberValue(
3262
+ auto pname = (uint32_t) args[0]->NumberValue(
3263
+ context).ToChecked();
3264
+ if (args[1]->IsBoolean()) {
3265
+ auto param = args[1]->BooleanValue(isolate);
3266
+ canvas_native_webgl_pixel_storei(
3267
+ pname,
3268
+ param ? 1 : 0,
3269
+ ptr->GetState()
3270
+ );
3271
+ } else {
3272
+ auto param = (int32_t) args[1]->NumberValue(
3379
3273
  context).ToChecked();
3380
- if (args[1]->IsBoolean()) {
3381
- auto param = args[1]->BooleanValue(isolate);
3382
- canvas_native_webgl_pixel_storei(
3383
- pname,
3384
- param ? 1 : 0,
3385
- ptr->GetState()
3386
- );
3387
- } else {
3388
- auto param = (int32_t) args[1]->NumberValue(
3389
- context).ToChecked();
3390
- canvas_native_webgl_pixel_storei(
3391
- pname,
3392
- param,
3393
- ptr->GetState()
3394
- );
3395
- }
3396
-
3274
+ canvas_native_webgl_pixel_storei(
3275
+ pname,
3276
+ param,
3277
+ ptr->GetState()
3278
+ );
3397
3279
  }
3398
3280
  }
3399
3281
 
@@ -3407,17 +3289,15 @@ WebGLRenderingContext::PolygonOffset(const v8::FunctionCallbackInfo<v8::Value> &
3407
3289
  auto isolate = args.GetIsolate();
3408
3290
  auto context = isolate->GetCurrentContext();
3409
3291
 
3410
- if (args.Length() > 1) {
3411
- auto factor = args[0]->NumberValue(
3412
- context).ToChecked();
3413
- auto units = args[1]->NumberValue(
3414
- context).ToChecked();
3415
- canvas_native_webgl_polygon_offset(
3416
- static_cast<float>(factor),
3417
- static_cast<float>(units),
3418
- ptr->GetState()
3419
- );
3420
- }
3292
+ auto factor = args[0]->NumberValue(
3293
+ context).ToChecked();
3294
+ auto units = args[1]->NumberValue(
3295
+ context).ToChecked();
3296
+ canvas_native_webgl_polygon_offset(
3297
+ static_cast<float>(factor),
3298
+ static_cast<float>(units),
3299
+ ptr->GetState()
3300
+ );
3421
3301
 
3422
3302
  }
3423
3303
 
@@ -3432,62 +3312,60 @@ WebGLRenderingContext::ReadPixels(const v8::FunctionCallbackInfo<v8::Value> &arg
3432
3312
  auto context = isolate->GetCurrentContext();
3433
3313
 
3434
3314
 
3435
- if (args.Length() > 6) {
3436
- auto x = (int32_t) args[0]->NumberValue(
3437
- context).ToChecked();
3438
- auto y = (int32_t) args[1]->NumberValue(
3439
- context).ToChecked();
3440
- auto width = (int32_t) args[2]->NumberValue(
3441
- context).ToChecked();
3442
- auto height = (int32_t) args[3]->NumberValue(
3443
- context).ToChecked();
3444
- auto format = (uint32_t) args[4]->NumberValue(
3445
- context).ToChecked();
3446
- auto type = (uint32_t) args[5]->NumberValue(
3447
- context).ToChecked();
3315
+ auto x = (int32_t) args[0]->NumberValue(
3316
+ context).ToChecked();
3317
+ auto y = (int32_t) args[1]->NumberValue(
3318
+ context).ToChecked();
3319
+ auto width = (int32_t) args[2]->NumberValue(
3320
+ context).ToChecked();
3321
+ auto height = (int32_t) args[3]->NumberValue(
3322
+ context).ToChecked();
3323
+ auto format = (uint32_t) args[4]->NumberValue(
3324
+ context).ToChecked();
3325
+ auto type = (uint32_t) args[5]->NumberValue(
3326
+ context).ToChecked();
3448
3327
 
3449
- auto pixels = args[6];
3450
- if (pixels->IsArrayBufferView()) {
3451
- auto buf = pixels.As<v8::ArrayBufferView>();
3328
+ auto pixels = args[6];
3329
+ if (pixels->IsArrayBufferView()) {
3330
+ auto buf = pixels.As<v8::ArrayBufferView>();
3452
3331
 
3453
- auto array = buf->Buffer();
3454
- auto offset = buf->ByteOffset();
3455
- auto size = array->ByteLength();
3456
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3457
- auto data = static_cast<uint8_t *>((void *) data_ptr);
3332
+ auto array = buf->Buffer();
3333
+ auto offset = buf->ByteOffset();
3334
+ auto size = array->ByteLength();
3335
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
3336
+ auto data = static_cast<uint8_t *>((void *) data_ptr);
3458
3337
 
3459
3338
 
3460
- canvas_native_webgl_read_pixels_u8(
3461
- x,
3462
- y,
3463
- width,
3464
- height,
3465
- format,
3466
- type,
3467
- data, size,
3468
- ptr->GetState()
3469
- );
3470
- return;
3471
- }
3339
+ canvas_native_webgl_read_pixels_u8(
3340
+ x,
3341
+ y,
3342
+ width,
3343
+ height,
3344
+ format,
3345
+ type,
3346
+ data, size,
3347
+ ptr->GetState()
3348
+ );
3349
+ return;
3350
+ }
3472
3351
 
3473
3352
 
3474
- if (pixels->IsArrayBuffer()) {
3475
- auto array = pixels.As<v8::ArrayBuffer>();
3353
+ if (pixels->IsArrayBuffer()) {
3354
+ auto array = pixels.As<v8::ArrayBuffer>();
3476
3355
 
3477
- auto size = array->ByteLength();
3478
- auto data = (uint8_t *) array->GetBackingStore()->Data();
3356
+ auto size = array->ByteLength();
3357
+ auto data = (uint8_t *) array->GetBackingStore()->Data();
3479
3358
 
3480
- canvas_native_webgl_read_pixels_u8(
3481
- x,
3482
- y,
3483
- width,
3484
- height,
3485
- format,
3486
- type,
3487
- data, size,
3488
- ptr->GetState()
3489
- );
3490
- }
3359
+ canvas_native_webgl_read_pixels_u8(
3360
+ x,
3361
+ y,
3362
+ width,
3363
+ height,
3364
+ format,
3365
+ type,
3366
+ data, size,
3367
+ ptr->GetState()
3368
+ );
3491
3369
  }
3492
3370
 
3493
3371
  }
@@ -3495,31 +3373,29 @@ WebGLRenderingContext::ReadPixels(const v8::FunctionCallbackInfo<v8::Value> &arg
3495
3373
  void
3496
3374
  WebGLRenderingContext::RenderbufferStorage(const v8::FunctionCallbackInfo<v8::Value> &args) {
3497
3375
  WebGLRenderingContext *ptr = GetPointer(args.This());
3498
- if (ptr == nullptr) {
3499
- return;
3500
- }
3501
-
3502
- auto isolate = args.GetIsolate();
3503
- auto context = isolate->GetCurrentContext();
3504
-
3505
- if (args.Length() > 3) {
3506
- auto target = (uint32_t) args[0]->NumberValue(
3507
- context).ToChecked();
3508
- auto internalFormat = (uint32_t) args[1]->NumberValue(
3509
- context).ToChecked();
3510
- auto width = (int32_t) args[2]->NumberValue(
3511
- context).ToChecked();
3512
- auto height = (int32_t) args[3]->NumberValue(
3513
- context).ToChecked();
3514
- canvas_native_webgl_renderbuffer_storage(
3515
- target,
3516
- internalFormat,
3517
- width,
3518
- height,
3519
- ptr->GetState()
3520
- );
3376
+ if (ptr == nullptr) {
3377
+ return;
3521
3378
  }
3522
3379
 
3380
+ auto isolate = args.GetIsolate();
3381
+ auto context = isolate->GetCurrentContext();
3382
+
3383
+ auto target = (uint32_t) args[0]->NumberValue(
3384
+ context).ToChecked();
3385
+ auto internalFormat = (uint32_t) args[1]->NumberValue(
3386
+ context).ToChecked();
3387
+ auto width = (int32_t) args[2]->NumberValue(
3388
+ context).ToChecked();
3389
+ auto height = (int32_t) args[3]->NumberValue(
3390
+ context).ToChecked();
3391
+ canvas_native_webgl_renderbuffer_storage(
3392
+ target,
3393
+ internalFormat,
3394
+ width,
3395
+ height,
3396
+ ptr->GetState()
3397
+ );
3398
+
3523
3399
  }
3524
3400
 
3525
3401
  void
@@ -3532,16 +3408,14 @@ WebGLRenderingContext::SampleCoverage(const v8::FunctionCallbackInfo<v8::Value>
3532
3408
  auto isolate = args.GetIsolate();
3533
3409
  auto context = isolate->GetCurrentContext();
3534
3410
 
3535
- if (args.Length() > 1) {
3536
- auto value = args[0]->NumberValue(
3537
- context).ToChecked();
3538
- auto invert = args[1]->BooleanValue(isolate);
3539
- canvas_native_webgl_sample_coverage(
3540
- static_cast<float>(value),
3541
- invert,
3542
- ptr->GetState()
3543
- );
3544
- }
3411
+ auto value = args[0]->NumberValue(
3412
+ context).ToChecked();
3413
+ auto invert = args[1]->BooleanValue(isolate);
3414
+ canvas_native_webgl_sample_coverage(
3415
+ static_cast<float>(value),
3416
+ invert,
3417
+ ptr->GetState()
3418
+ );
3545
3419
 
3546
3420
  }
3547
3421
 
@@ -3555,23 +3429,21 @@ WebGLRenderingContext::Scissor(const v8::FunctionCallbackInfo<v8::Value> &args)
3555
3429
  auto isolate = args.GetIsolate();
3556
3430
  auto context = isolate->GetCurrentContext();
3557
3431
 
3558
- if (args.Length() > 3) {
3559
- auto x = (int32_t) args[0]->NumberValue(
3560
- context).ToChecked();
3561
- auto y = (int32_t) args[1]->NumberValue(
3562
- context).ToChecked();
3563
- auto width = (int32_t) args[2]->NumberValue(
3564
- context).ToChecked();
3565
- auto height = (int32_t) args[3]->NumberValue(
3566
- context).ToChecked();
3567
- canvas_native_webgl_scissor(
3568
- x,
3569
- y,
3570
- width,
3571
- height,
3572
- ptr->GetState()
3573
- );
3574
- }
3432
+ auto x = (int32_t) args[0]->NumberValue(
3433
+ context).ToChecked();
3434
+ auto y = (int32_t) args[1]->NumberValue(
3435
+ context).ToChecked();
3436
+ auto width = (int32_t) args[2]->NumberValue(
3437
+ context).ToChecked();
3438
+ auto height = (int32_t) args[3]->NumberValue(
3439
+ context).ToChecked();
3440
+ canvas_native_webgl_scissor(
3441
+ x,
3442
+ y,
3443
+ width,
3444
+ height,
3445
+ ptr->GetState()
3446
+ );
3575
3447
 
3576
3448
  }
3577
3449
 
@@ -3610,23 +3482,21 @@ WebGLRenderingContext::StencilFuncSeparate(const v8::FunctionCallbackInfo<v8::Va
3610
3482
  auto isolate = args.GetIsolate();
3611
3483
  auto context = isolate->GetCurrentContext();
3612
3484
 
3613
- if (args.Length() > 3) {
3614
- auto face = (uint32_t) args[0]->NumberValue(
3615
- context).ToChecked();
3616
- auto func = (uint32_t) args[1]->NumberValue(
3617
- context).ToChecked();
3618
- auto ref = (int32_t) args[2]->NumberValue(
3619
- context).ToChecked();
3620
- auto mask = (uint32_t) args[3]->NumberValue(
3621
- context).ToChecked();
3622
- canvas_native_webgl_stencil_func_separate(
3623
- face,
3624
- func,
3625
- ref,
3626
- mask,
3627
- ptr->GetState()
3628
- );
3629
- }
3485
+ auto face = (uint32_t) args[0]->NumberValue(
3486
+ context).ToChecked();
3487
+ auto func = (uint32_t) args[1]->NumberValue(
3488
+ context).ToChecked();
3489
+ auto ref = (int32_t) args[2]->NumberValue(
3490
+ context).ToChecked();
3491
+ auto mask = (uint32_t) args[3]->NumberValue(
3492
+ context).ToChecked();
3493
+ canvas_native_webgl_stencil_func_separate(
3494
+ face,
3495
+ func,
3496
+ ref,
3497
+ mask,
3498
+ ptr->GetState()
3499
+ );
3630
3500
 
3631
3501
  }
3632
3502
 
@@ -3640,20 +3510,18 @@ WebGLRenderingContext::StencilFunc(const v8::FunctionCallbackInfo<v8::Value> &ar
3640
3510
  auto isolate = args.GetIsolate();
3641
3511
  auto context = isolate->GetCurrentContext();
3642
3512
 
3643
- if (args.Length() > 2) {
3644
- auto func = (uint32_t) args[0]->NumberValue(
3645
- context).ToChecked();
3646
- auto ref = (int32_t) args[1]->NumberValue(
3647
- context).ToChecked();
3648
- auto mask = (uint32_t) args[2]->NumberValue(
3649
- context).ToChecked();
3650
- canvas_native_webgl_stencil_func(
3651
- func,
3652
- ref,
3653
- mask,
3654
- ptr->GetState()
3655
- );
3656
- }
3513
+ auto func = (uint32_t) args[0]->NumberValue(
3514
+ context).ToChecked();
3515
+ auto ref = (int32_t) args[1]->NumberValue(
3516
+ context).ToChecked();
3517
+ auto mask = (uint32_t) args[2]->NumberValue(
3518
+ context).ToChecked();
3519
+ canvas_native_webgl_stencil_func(
3520
+ func,
3521
+ ref,
3522
+ mask,
3523
+ ptr->GetState()
3524
+ );
3657
3525
 
3658
3526
  }
3659
3527
 
@@ -3667,17 +3535,15 @@ WebGLRenderingContext::StencilMaskSeparate(const v8::FunctionCallbackInfo<v8::Va
3667
3535
  auto isolate = args.GetIsolate();
3668
3536
  auto context = isolate->GetCurrentContext();
3669
3537
 
3670
- if (args.Length() > 1) {
3671
- auto face = (uint32_t) args[0]->NumberValue(
3672
- context).ToChecked();
3673
- auto mask = (uint32_t) args[1]->NumberValue(
3674
- context).ToChecked();
3675
- canvas_native_webgl_stencil_mask_separate(
3676
- face,
3677
- mask,
3678
- ptr->GetState()
3679
- );
3680
- }
3538
+ auto face = (uint32_t) args[0]->NumberValue(
3539
+ context).ToChecked();
3540
+ auto mask = (uint32_t) args[1]->NumberValue(
3541
+ context).ToChecked();
3542
+ canvas_native_webgl_stencil_mask_separate(
3543
+ face,
3544
+ mask,
3545
+ ptr->GetState()
3546
+ );
3681
3547
 
3682
3548
  }
3683
3549
 
@@ -3691,14 +3557,12 @@ WebGLRenderingContext::StencilMask(const v8::FunctionCallbackInfo<v8::Value> &ar
3691
3557
  auto isolate = args.GetIsolate();
3692
3558
  auto context = isolate->GetCurrentContext();
3693
3559
 
3694
- if (args.Length() > 0) {
3695
- auto mask = (uint32_t) args[0]->NumberValue(
3696
- context).ToChecked();
3697
- canvas_native_webgl_stencil_mask(
3698
- mask,
3699
- ptr->GetState()
3700
- );
3701
- }
3560
+ auto mask = (uint32_t) args[0]->NumberValue(
3561
+ context).ToChecked();
3562
+ canvas_native_webgl_stencil_mask(
3563
+ mask,
3564
+ ptr->GetState()
3565
+ );
3702
3566
 
3703
3567
  }
3704
3568
 
@@ -3713,23 +3577,21 @@ WebGLRenderingContext::StencilOpSeparate(const v8::FunctionCallbackInfo<v8::Valu
3713
3577
  auto context = isolate->GetCurrentContext();
3714
3578
 
3715
3579
 
3716
- if (args.Length() > 3) {
3717
- auto face = (uint32_t) args[0]->NumberValue(
3718
- context).ToChecked();
3719
- auto fail = (uint32_t) args[1]->NumberValue(
3720
- context).ToChecked();
3721
- auto zfail = (uint32_t) args[2]->NumberValue(
3722
- context).ToChecked();
3723
- auto zpass = (uint32_t) args[3]->NumberValue(
3724
- context).ToChecked();
3725
- canvas_native_webgl_stencil_op_separate(
3726
- face,
3727
- fail,
3728
- zfail,
3729
- zpass,
3730
- ptr->GetState()
3731
- );
3732
- }
3580
+ auto face = (uint32_t) args[0]->NumberValue(
3581
+ context).ToChecked();
3582
+ auto fail = (uint32_t) args[1]->NumberValue(
3583
+ context).ToChecked();
3584
+ auto zfail = (uint32_t) args[2]->NumberValue(
3585
+ context).ToChecked();
3586
+ auto zpass = (uint32_t) args[3]->NumberValue(
3587
+ context).ToChecked();
3588
+ canvas_native_webgl_stencil_op_separate(
3589
+ face,
3590
+ fail,
3591
+ zfail,
3592
+ zpass,
3593
+ ptr->GetState()
3594
+ );
3733
3595
 
3734
3596
  }
3735
3597
 
@@ -3743,20 +3605,18 @@ WebGLRenderingContext::StencilOp(const v8::FunctionCallbackInfo<v8::Value> &args
3743
3605
  auto isolate = args.GetIsolate();
3744
3606
  auto context = isolate->GetCurrentContext();
3745
3607
 
3746
- if (args.Length() > 2) {
3747
- auto fail = (uint32_t) args[0]->NumberValue(
3748
- context).ToChecked();
3749
- auto zfail = (uint32_t) args[1]->NumberValue(
3750
- context).ToChecked();
3751
- auto zpass = (uint32_t) args[2]->NumberValue(
3752
- context).ToChecked();
3753
- canvas_native_webgl_stencil_op(
3754
- fail,
3755
- zfail,
3756
- zpass,
3757
- ptr->GetState()
3758
- );
3759
- }
3608
+ auto fail = (uint32_t) args[0]->NumberValue(
3609
+ context).ToChecked();
3610
+ auto zfail = (uint32_t) args[1]->NumberValue(
3611
+ context).ToChecked();
3612
+ auto zpass = (uint32_t) args[2]->NumberValue(
3613
+ context).ToChecked();
3614
+ canvas_native_webgl_stencil_op(
3615
+ fail,
3616
+ zfail,
3617
+ zpass,
3618
+ ptr->GetState()
3619
+ );
3760
3620
 
3761
3621
  }
3762
3622
 
@@ -3951,7 +3811,7 @@ WebGLRenderingContext::TexImage2D(const v8::FunctionCallbackInfo<v8::Value> &arg
3951
3811
  auto array = buf->Buffer();
3952
3812
  auto offset = buf->ByteOffset();
3953
3813
  auto size = array->ByteLength();
3954
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3814
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
3955
3815
  auto data = static_cast<uint8_t *>((void *) data_ptr);
3956
3816
 
3957
3817
 
@@ -4003,20 +3863,18 @@ WebGLRenderingContext::TexParameterf(const v8::FunctionCallbackInfo<v8::Value> &
4003
3863
  auto isolate = args.GetIsolate();
4004
3864
  auto context = isolate->GetCurrentContext();
4005
3865
 
4006
- if (args.Length() > 2) {
4007
- auto target = (uint32_t) args[0]->NumberValue(
4008
- context).ToChecked();
4009
- auto pname = (uint32_t) args[1]->NumberValue(
4010
- context).ToChecked();
4011
- auto param = args[2]->NumberValue(
4012
- context).ToChecked();
4013
- canvas_native_webgl_tex_parameterf(
4014
- target,
4015
- pname,
4016
- static_cast<float>(param),
4017
- ptr->GetState()
4018
- );
4019
- }
3866
+ auto target = (uint32_t) args[0]->NumberValue(
3867
+ context).ToChecked();
3868
+ auto pname = (uint32_t) args[1]->NumberValue(
3869
+ context).ToChecked();
3870
+ auto param = args[2]->NumberValue(
3871
+ context).ToChecked();
3872
+ canvas_native_webgl_tex_parameterf(
3873
+ target,
3874
+ pname,
3875
+ static_cast<float>(param),
3876
+ ptr->GetState()
3877
+ );
4020
3878
 
4021
3879
  }
4022
3880
 
@@ -4030,20 +3888,18 @@ WebGLRenderingContext::TexParameteri(const v8::FunctionCallbackInfo<v8::Value> &
4030
3888
  auto isolate = args.GetIsolate();
4031
3889
  auto context = isolate->GetCurrentContext();
4032
3890
 
4033
- if (args.Length() > 2) {
4034
- auto target = (uint32_t) args[0]->NumberValue(
4035
- context).ToChecked();
4036
- auto pname = (uint32_t) args[1]->NumberValue(
4037
- context).ToChecked();
4038
- auto param = (int32_t) args[2]->NumberValue(
4039
- context).ToChecked();
4040
- canvas_native_webgl_tex_parameteri(
4041
- target,
4042
- pname,
4043
- param,
4044
- ptr->GetState()
4045
- );
4046
- }
3891
+ auto target = (uint32_t) args[0]->NumberValue(
3892
+ context).ToChecked();
3893
+ auto pname = (uint32_t) args[1]->NumberValue(
3894
+ context).ToChecked();
3895
+ auto param = (int32_t) args[2]->NumberValue(
3896
+ context).ToChecked();
3897
+ canvas_native_webgl_tex_parameteri(
3898
+ target,
3899
+ pname,
3900
+ param,
3901
+ ptr->GetState()
3902
+ );
4047
3903
 
4048
3904
  }
4049
3905
 
@@ -4176,7 +4032,7 @@ WebGLRenderingContext::TexSubImage2D(const v8::FunctionCallbackInfo<v8::Value> &
4176
4032
  auto array = buf->Buffer();
4177
4033
  auto offset = buf->ByteOffset();
4178
4034
  auto size = array->ByteLength();
4179
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
4035
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
4180
4036
  auto data = static_cast<uint8_t *>((void *) data_ptr);
4181
4037
 
4182
4038
 
@@ -4227,14 +4083,12 @@ WebGLRenderingContext::VertexAttrib1f(const v8::FunctionCallbackInfo<v8::Value>
4227
4083
  auto isolate = args.GetIsolate();
4228
4084
  auto context = isolate->GetCurrentContext();
4229
4085
 
4230
- if (args.Length() > 1) {
4231
- auto index = (uint32_t) args[0]->NumberValue(
4232
- context).ToChecked();
4233
- auto v0 = static_cast<float>(args[1]->NumberValue(
4234
- context).ToChecked());
4235
- canvas_native_webgl_vertex_attrib1f(
4236
- index, v0, ptr->GetState());
4237
- }
4086
+ auto index = (uint32_t) args[0]->NumberValue(
4087
+ context).ToChecked();
4088
+ auto v0 = static_cast<float>(args[1]->NumberValue(
4089
+ context).ToChecked());
4090
+ canvas_native_webgl_vertex_attrib1f(
4091
+ index, v0, ptr->GetState());
4238
4092
 
4239
4093
  }
4240
4094
 
@@ -4248,17 +4102,15 @@ WebGLRenderingContext::VertexAttrib2f(const v8::FunctionCallbackInfo<v8::Value>
4248
4102
  auto isolate = args.GetIsolate();
4249
4103
  auto context = isolate->GetCurrentContext();
4250
4104
 
4251
- if (args.Length() > 2) {
4252
- auto index = (uint32_t) args[0]->NumberValue(
4253
- context).ToChecked();
4254
- auto v0 = static_cast<float>(args[1]->NumberValue(
4255
- context).ToChecked());
4256
- auto v1 = static_cast<float>(args[2]->NumberValue(
4257
- context).ToChecked());
4258
- canvas_native_webgl_vertex_attrib2f(
4259
- index, v0, v1,
4260
- ptr->GetState());
4261
- }
4105
+ auto index = (uint32_t) args[0]->NumberValue(
4106
+ context).ToChecked();
4107
+ auto v0 = static_cast<float>(args[1]->NumberValue(
4108
+ context).ToChecked());
4109
+ auto v1 = static_cast<float>(args[2]->NumberValue(
4110
+ context).ToChecked());
4111
+ canvas_native_webgl_vertex_attrib2f(
4112
+ index, v0, v1,
4113
+ ptr->GetState());
4262
4114
 
4263
4115
  }
4264
4116
 
@@ -4272,19 +4124,17 @@ WebGLRenderingContext::VertexAttrib3f(const v8::FunctionCallbackInfo<v8::Value>
4272
4124
  auto isolate = args.GetIsolate();
4273
4125
  auto context = isolate->GetCurrentContext();
4274
4126
 
4275
- if (args.Length() > 3) {
4276
- auto index = (uint32_t) args[0]->NumberValue(
4277
- context).ToChecked();
4278
- auto v0 = static_cast<float>(args[1]->NumberValue(
4279
- context).ToChecked());
4280
- auto v1 = static_cast<float>(args[2]->NumberValue(
4281
- context).ToChecked());
4282
- auto v2 = static_cast<float>(args[3]->NumberValue(
4283
- context).ToChecked());
4284
- canvas_native_webgl_vertex_attrib3f(
4285
- index, v0, v1, v2,
4286
- ptr->GetState());
4287
- }
4127
+ auto index = (uint32_t) args[0]->NumberValue(
4128
+ context).ToChecked();
4129
+ auto v0 = static_cast<float>(args[1]->NumberValue(
4130
+ context).ToChecked());
4131
+ auto v1 = static_cast<float>(args[2]->NumberValue(
4132
+ context).ToChecked());
4133
+ auto v2 = static_cast<float>(args[3]->NumberValue(
4134
+ context).ToChecked());
4135
+ canvas_native_webgl_vertex_attrib3f(
4136
+ index, v0, v1, v2,
4137
+ ptr->GetState());
4288
4138
 
4289
4139
  }
4290
4140
 
@@ -4298,21 +4148,19 @@ WebGLRenderingContext::VertexAttrib4f(const v8::FunctionCallbackInfo<v8::Value>
4298
4148
  auto isolate = args.GetIsolate();
4299
4149
  auto context = isolate->GetCurrentContext();
4300
4150
 
4301
- if (args.Length() > 4) {
4302
- auto index = (uint32_t) args[0]->NumberValue(
4303
- context).ToChecked();
4304
- auto v0 = static_cast<float>(args[1]->NumberValue(
4305
- context).ToChecked());
4306
- auto v1 = static_cast<float>(args[2]->NumberValue(
4307
- context).ToChecked());
4308
- auto v2 = static_cast<float>(args[3]->NumberValue(
4309
- context).ToChecked());
4310
- auto v3 = static_cast<float>(args[4]->NumberValue(
4311
- context).ToChecked());
4312
- canvas_native_webgl_vertex_attrib4f(
4313
- index, v0, v1, v2, v3,
4314
- ptr->GetState());
4315
- }
4151
+ auto index = (uint32_t) args[0]->NumberValue(
4152
+ context).ToChecked();
4153
+ auto v0 = static_cast<float>(args[1]->NumberValue(
4154
+ context).ToChecked());
4155
+ auto v1 = static_cast<float>(args[2]->NumberValue(
4156
+ context).ToChecked());
4157
+ auto v2 = static_cast<float>(args[3]->NumberValue(
4158
+ context).ToChecked());
4159
+ auto v3 = static_cast<float>(args[4]->NumberValue(
4160
+ context).ToChecked());
4161
+ canvas_native_webgl_vertex_attrib4f(
4162
+ index, v0, v1, v2, v3,
4163
+ ptr->GetState());
4316
4164
 
4317
4165
  }
4318
4166
 
@@ -4326,25 +4174,23 @@ WebGLRenderingContext::VertexAttrib1fv(const v8::FunctionCallbackInfo<v8::Value>
4326
4174
  auto isolate = args.GetIsolate();
4327
4175
  auto context = isolate->GetCurrentContext();
4328
4176
 
4329
- if (args.Length() > 1) {
4330
- auto index = (uint32_t) args[0]->NumberValue(
4331
- context).ToChecked();
4177
+ auto index = (uint32_t) args[0]->NumberValue(
4178
+ context).ToChecked();
4332
4179
 
4333
- auto value = args[1];
4334
- if (value->IsFloat32Array()) {
4335
- auto buf = value.As<v8::Float32Array>();
4180
+ auto value = args[1];
4181
+ if (value->IsFloat32Array()) {
4182
+ auto buf = value.As<v8::Float32Array>();
4336
4183
 
4337
- auto array = buf->Buffer();
4338
- auto offset = buf->ByteOffset();
4339
- auto size = buf->Length();
4340
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
4341
- auto data = static_cast<float *>((void *) data_ptr);
4184
+ auto array = buf->Buffer();
4185
+ auto offset = buf->ByteOffset();
4186
+ auto size = buf->Length();
4187
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
4188
+ auto data = static_cast<float *>((void *) data_ptr);
4342
4189
 
4343
4190
 
4344
- canvas_native_webgl_vertex_attrib1fv(
4345
- index, data, size,
4346
- ptr->GetState());
4347
- }
4191
+ canvas_native_webgl_vertex_attrib1fv(
4192
+ index, data, size,
4193
+ ptr->GetState());
4348
4194
  }
4349
4195
  }
4350
4196
 
@@ -4358,25 +4204,23 @@ WebGLRenderingContext::VertexAttrib2fv(const v8::FunctionCallbackInfo<v8::Value>
4358
4204
  auto isolate = args.GetIsolate();
4359
4205
  auto context = isolate->GetCurrentContext();
4360
4206
 
4361
- if (args.Length() > 1) {
4362
- auto index = (uint32_t) args[0]->NumberValue(
4363
- context).ToChecked();
4207
+ auto index = (uint32_t) args[0]->NumberValue(
4208
+ context).ToChecked();
4364
4209
 
4365
- auto value = args[1];
4366
- if (value->IsFloat32Array()) {
4367
- auto buf = value.As<v8::Float32Array>();
4210
+ auto value = args[1];
4211
+ if (value->IsFloat32Array()) {
4212
+ auto buf = value.As<v8::Float32Array>();
4368
4213
 
4369
- auto array = buf->Buffer();
4370
- auto offset = buf->ByteOffset();
4371
- auto size = buf->Length();
4372
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
4373
- auto data = static_cast<float *>((void *) data_ptr);
4214
+ auto array = buf->Buffer();
4215
+ auto offset = buf->ByteOffset();
4216
+ auto size = buf->Length();
4217
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
4218
+ auto data = static_cast<float *>((void *) data_ptr);
4374
4219
 
4375
4220
 
4376
- canvas_native_webgl_vertex_attrib2fv(
4377
- index, data, size,
4378
- ptr->GetState());
4379
- }
4221
+ canvas_native_webgl_vertex_attrib2fv(
4222
+ index, data, size,
4223
+ ptr->GetState());
4380
4224
  }
4381
4225
  }
4382
4226
 
@@ -4390,25 +4234,23 @@ WebGLRenderingContext::VertexAttrib3fv(const v8::FunctionCallbackInfo<v8::Value>
4390
4234
  auto isolate = args.GetIsolate();
4391
4235
  auto context = isolate->GetCurrentContext();
4392
4236
 
4393
- if (args.Length() > 1) {
4394
- auto index = (uint32_t) args[0]->NumberValue(
4395
- context).ToChecked();
4237
+ auto index = (uint32_t) args[0]->NumberValue(
4238
+ context).ToChecked();
4396
4239
 
4397
- auto value = args[1];
4398
- if (value->IsFloat32Array()) {
4399
- auto buf = value.As<v8::Float32Array>();
4240
+ auto value = args[1];
4241
+ if (value->IsFloat32Array()) {
4242
+ auto buf = value.As<v8::Float32Array>();
4400
4243
 
4401
- auto array = buf->Buffer();
4402
- auto offset = buf->ByteOffset();
4403
- auto size = buf->Length();
4404
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
4405
- auto data = static_cast<float *>((void *) data_ptr);
4244
+ auto array = buf->Buffer();
4245
+ auto offset = buf->ByteOffset();
4246
+ auto size = buf->Length();
4247
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
4248
+ auto data = static_cast<float *>((void *) data_ptr);
4406
4249
 
4407
4250
 
4408
- canvas_native_webgl_vertex_attrib3fv(
4409
- index, data, size,
4410
- ptr->GetState());
4411
- }
4251
+ canvas_native_webgl_vertex_attrib3fv(
4252
+ index, data, size,
4253
+ ptr->GetState());
4412
4254
  }
4413
4255
  }
4414
4256
 
@@ -4422,25 +4264,23 @@ WebGLRenderingContext::VertexAttrib4fv(const v8::FunctionCallbackInfo<v8::Value>
4422
4264
  auto isolate = args.GetIsolate();
4423
4265
  auto context = isolate->GetCurrentContext();
4424
4266
 
4425
- if (args.Length() > 1) {
4426
- auto index = (uint32_t) args[0]->NumberValue(
4427
- context).ToChecked();
4267
+ auto index = (uint32_t) args[0]->NumberValue(
4268
+ context).ToChecked();
4428
4269
 
4429
- auto value = args[1];
4430
- if (value->IsFloat32Array()) {
4431
- auto buf = value.As<v8::Float32Array>();
4270
+ auto value = args[1];
4271
+ if (value->IsFloat32Array()) {
4272
+ auto buf = value.As<v8::Float32Array>();
4432
4273
 
4433
- auto array = buf->Buffer();
4434
- auto offset = buf->ByteOffset();
4435
- auto size = buf->Length();
4436
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
4437
- auto data = static_cast<float *>((void *) data_ptr);
4274
+ auto array = buf->Buffer();
4275
+ auto offset = buf->ByteOffset();
4276
+ auto size = buf->Length();
4277
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
4278
+ auto data = static_cast<float *>((void *) data_ptr);
4438
4279
 
4439
4280
 
4440
- canvas_native_webgl_vertex_attrib4fv(
4441
- index, data, size,
4442
- ptr->GetState());
4443
- }
4281
+ canvas_native_webgl_vertex_attrib4fv(
4282
+ index, data, size,
4283
+ ptr->GetState());
4444
4284
  }
4445
4285
  }
4446
4286
 
@@ -4454,23 +4294,21 @@ WebGLRenderingContext::VertexAttribPointer(const v8::FunctionCallbackInfo<v8::Va
4454
4294
  auto isolate = args.GetIsolate();
4455
4295
  auto context = isolate->GetCurrentContext();
4456
4296
 
4457
- if (args.Length() > 5) {
4458
- auto index = (uint32_t) args[0]->NumberValue(
4459
- context).ToChecked();
4460
- auto size = (int32_t) args[1]->NumberValue(
4461
- context).ToChecked();
4462
- auto type = (uint32_t) args[2]->NumberValue(
4463
- context).ToChecked();
4464
- auto normalized = args[3]->BooleanValue(isolate);
4465
- auto stride = (int32_t) args[4]->NumberValue(
4466
- context).ToChecked();
4467
- auto offset = static_cast<ssize_t>(args[5]->NumberValue(
4468
- context).ToChecked());
4469
- canvas_native_webgl_vertex_attrib_pointer(
4470
- index, size, type, normalized,
4471
- stride, offset,
4472
- ptr->GetState());
4473
- }
4297
+ auto index = (uint32_t) args[0]->NumberValue(
4298
+ context).ToChecked();
4299
+ auto size = (int32_t) args[1]->NumberValue(
4300
+ context).ToChecked();
4301
+ auto type = (uint32_t) args[2]->NumberValue(
4302
+ context).ToChecked();
4303
+ auto normalized = args[3]->BooleanValue(isolate);
4304
+ auto stride = (int32_t) args[4]->NumberValue(
4305
+ context).ToChecked();
4306
+ auto offset = static_cast<ssize_t>(args[5]->NumberValue(
4307
+ context).ToChecked());
4308
+ canvas_native_webgl_vertex_attrib_pointer(
4309
+ index, size, type, normalized,
4310
+ stride, offset,
4311
+ ptr->GetState());
4474
4312
  }
4475
4313
 
4476
4314
  void
@@ -4484,8 +4322,7 @@ WebGLRenderingContext::Uniform1f(const v8::FunctionCallbackInfo<v8::Value> &args
4484
4322
  auto context = isolate->GetCurrentContext();
4485
4323
 
4486
4324
  auto value = args[0];
4487
- //if (count > 1) {
4488
- // if (args[0].isObject()) {
4325
+
4489
4326
  auto location = WebGLUniformLocation::GetPointer(value.As<v8::Object>());
4490
4327
  auto v0 = args[1]->NumberValue(
4491
4328
  context).ToChecked();
@@ -4496,8 +4333,6 @@ WebGLRenderingContext::Uniform1f(const v8::FunctionCallbackInfo<v8::Value> &args
4496
4333
  ptr->GetState()
4497
4334
  );
4498
4335
  }
4499
- // }
4500
- // }
4501
4336
  }
4502
4337
 
4503
4338
  void
@@ -4511,8 +4346,7 @@ WebGLRenderingContext::Uniform2f(const v8::FunctionCallbackInfo<v8::Value> &args
4511
4346
  auto context = isolate->GetCurrentContext();
4512
4347
 
4513
4348
  auto value = args[0];
4514
- //if (count > 1) {
4515
- // if (args[0].isObject()) {
4349
+
4516
4350
  auto location = WebGLUniformLocation::GetPointer(value.As<v8::Object>());
4517
4351
  auto v0 = args[1]->NumberValue(
4518
4352
  context).ToChecked();
@@ -4526,8 +4360,6 @@ WebGLRenderingContext::Uniform2f(const v8::FunctionCallbackInfo<v8::Value> &args
4526
4360
  ptr->GetState()
4527
4361
  );
4528
4362
  }
4529
- // }
4530
- // }
4531
4363
  }
4532
4364
 
4533
4365
  void
@@ -4541,8 +4373,6 @@ WebGLRenderingContext::Uniform3f(const v8::FunctionCallbackInfo<v8::Value> &args
4541
4373
  auto context = isolate->GetCurrentContext();
4542
4374
 
4543
4375
  auto value = args[0];
4544
- //if (count > 1) {
4545
- // if (args[0].isObject()) {
4546
4376
  auto location = WebGLUniformLocation::GetPointer(value.As<v8::Object>());
4547
4377
  auto v0 = args[1]->NumberValue(
4548
4378
  context).ToChecked();
@@ -4559,8 +4389,6 @@ WebGLRenderingContext::Uniform3f(const v8::FunctionCallbackInfo<v8::Value> &args
4559
4389
  ptr->GetState()
4560
4390
  );
4561
4391
  }
4562
- // }
4563
- // }
4564
4392
  }
4565
4393
 
4566
4394
  void
@@ -4574,8 +4402,6 @@ WebGLRenderingContext::Uniform4f(const v8::FunctionCallbackInfo<v8::Value> &args
4574
4402
  auto context = isolate->GetCurrentContext();
4575
4403
 
4576
4404
  auto value = args[0];
4577
- //if (count > 1) {
4578
- // if (args[0].isObject()) {
4579
4405
  auto location = WebGLUniformLocation::GetPointer(value.As<v8::Object>());
4580
4406
  auto v0 = args[1]->NumberValue(
4581
4407
  context).ToChecked();
@@ -4595,8 +4421,6 @@ WebGLRenderingContext::Uniform4f(const v8::FunctionCallbackInfo<v8::Value> &args
4595
4421
  ptr->GetState()
4596
4422
  );
4597
4423
  }
4598
- // }
4599
- // }
4600
4424
  }
4601
4425
 
4602
4426
  void
@@ -4624,7 +4448,7 @@ WebGLRenderingContext::Uniform1fv(const v8::FunctionCallbackInfo<v8::Value> &arg
4624
4448
  auto array = buf->Buffer();
4625
4449
  auto offset = buf->ByteOffset();
4626
4450
  auto size = buf->Length();
4627
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
4451
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
4628
4452
  auto data = static_cast<float *>((void *) data_ptr);
4629
4453
 
4630
4454
 
@@ -4641,15 +4465,10 @@ WebGLRenderingContext::Uniform1fv(const v8::FunctionCallbackInfo<v8::Value> &arg
4641
4465
  i < len; ++i) {
4642
4466
  auto item = array->Get(
4643
4467
  context, i).ToLocalChecked();
4644
- if (!item->IsNumber()) {
4645
- buf.push_back(
4646
- nanf(""));
4647
- } else {
4648
- auto value = item->NumberValue(
4649
- context).ToChecked();
4650
- buf.push_back(
4651
- static_cast<float>(value));
4652
- }
4468
+ auto value = item->NumberValue(
4469
+ context).ToChecked();
4470
+ buf.push_back(
4471
+ static_cast<float>(value));
4653
4472
  }
4654
4473
 
4655
4474
  canvas_native_webgl_uniform1fv(
@@ -4686,7 +4505,7 @@ WebGLRenderingContext::Uniform2fv(const v8::FunctionCallbackInfo<v8::Value> &arg
4686
4505
  auto array = buf->Buffer();
4687
4506
  auto offset = buf->ByteOffset();
4688
4507
  auto size = buf->Length();
4689
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
4508
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
4690
4509
  auto data = static_cast<float *>((void *) data_ptr);
4691
4510
 
4692
4511
 
@@ -4703,15 +4522,10 @@ WebGLRenderingContext::Uniform2fv(const v8::FunctionCallbackInfo<v8::Value> &arg
4703
4522
  i < len; ++i) {
4704
4523
  auto item = array->Get(
4705
4524
  context, i).ToLocalChecked();
4706
- if (!item->IsNumber()) {
4707
- buf.push_back(
4708
- nanf(""));
4709
- } else {
4710
- auto value = item->NumberValue(
4711
- context).ToChecked();
4712
- buf.push_back(
4713
- static_cast<float>(value));
4714
- }
4525
+ auto value = item->NumberValue(
4526
+ context).ToChecked();
4527
+ buf.push_back(
4528
+ static_cast<float>(value));
4715
4529
  }
4716
4530
 
4717
4531
  canvas_native_webgl_uniform2fv(
@@ -4748,7 +4562,7 @@ WebGLRenderingContext::Uniform3fv(const v8::FunctionCallbackInfo<v8::Value> &arg
4748
4562
  auto array = buf->Buffer();
4749
4563
  auto offset = buf->ByteOffset();
4750
4564
  auto size = buf->Length();
4751
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
4565
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
4752
4566
  auto data = static_cast<float *>((void *) data_ptr);
4753
4567
 
4754
4568
 
@@ -4765,15 +4579,10 @@ WebGLRenderingContext::Uniform3fv(const v8::FunctionCallbackInfo<v8::Value> &arg
4765
4579
  i < len; ++i) {
4766
4580
  auto item = array->Get(
4767
4581
  context, i).ToLocalChecked();
4768
- if (!item->IsNumber()) {
4769
- buf.push_back(
4770
- nanf(""));
4771
- } else {
4772
- auto value = item->NumberValue(
4773
- context).ToChecked();
4774
- buf.push_back(
4775
- static_cast<float>(value));
4776
- }
4582
+ auto value = item->NumberValue(
4583
+ context).ToChecked();
4584
+ buf.push_back(
4585
+ static_cast<float>(value));
4777
4586
  }
4778
4587
  canvas_native_webgl_uniform3fv(
4779
4588
  location->GetUniformLocation(),
@@ -4809,7 +4618,7 @@ WebGLRenderingContext::Uniform4fv(const v8::FunctionCallbackInfo<v8::Value> &arg
4809
4618
  auto array = buf->Buffer();
4810
4619
  auto offset = buf->ByteOffset();
4811
4620
  auto size = buf->Length();
4812
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
4621
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
4813
4622
  auto data = static_cast<float *>((void *) data_ptr);
4814
4623
 
4815
4624
 
@@ -4826,15 +4635,10 @@ WebGLRenderingContext::Uniform4fv(const v8::FunctionCallbackInfo<v8::Value> &arg
4826
4635
  i < len; ++i) {
4827
4636
  auto item = array->Get(
4828
4637
  context, i).ToLocalChecked();
4829
- if (!item->IsNumber()) {
4830
- buf.push_back(
4831
- nanf(""));
4832
- } else {
4833
- auto value = item->NumberValue(
4834
- context).ToChecked();
4835
- buf.push_back(
4836
- static_cast<float>(value));
4837
- }
4638
+ auto value = item->NumberValue(
4639
+ context).ToChecked();
4640
+ buf.push_back(
4641
+ static_cast<float>(value));
4838
4642
  }
4839
4643
  canvas_native_webgl_uniform4fv(
4840
4644
  location->GetUniformLocation(),
@@ -4857,8 +4661,6 @@ WebGLRenderingContext::Uniform1i(const v8::FunctionCallbackInfo<v8::Value> &args
4857
4661
  auto context = isolate->GetCurrentContext();
4858
4662
 
4859
4663
  auto value = args[0];
4860
- //if (count > 1) {
4861
- // if (args[0].isObject()) {
4862
4664
  auto location = WebGLUniformLocation::GetPointer(value.As<v8::Object>());
4863
4665
  auto v0 = args[1]->NumberValue(
4864
4666
  context).ToChecked();
@@ -4869,8 +4671,6 @@ WebGLRenderingContext::Uniform1i(const v8::FunctionCallbackInfo<v8::Value> &args
4869
4671
  ptr->GetState()
4870
4672
  );
4871
4673
  }
4872
- // }
4873
- // }
4874
4674
  }
4875
4675
 
4876
4676
  void
@@ -4884,8 +4684,6 @@ WebGLRenderingContext::Uniform2i(const v8::FunctionCallbackInfo<v8::Value> &args
4884
4684
  auto context = isolate->GetCurrentContext();
4885
4685
 
4886
4686
  auto value = args[0];
4887
- //if (count > 1) {
4888
- // if (args[0].isObject()) {
4889
4687
  auto location = WebGLUniformLocation::GetPointer(value.As<v8::Object>());
4890
4688
  auto v0 = args[1]->NumberValue(
4891
4689
  context).ToChecked();
@@ -4899,8 +4697,6 @@ WebGLRenderingContext::Uniform2i(const v8::FunctionCallbackInfo<v8::Value> &args
4899
4697
  ptr->GetState()
4900
4698
  );
4901
4699
  }
4902
- // }
4903
- // }
4904
4700
  }
4905
4701
 
4906
4702
  void
@@ -4914,8 +4710,6 @@ WebGLRenderingContext::Uniform3i(const v8::FunctionCallbackInfo<v8::Value> &args
4914
4710
  auto context = isolate->GetCurrentContext();
4915
4711
 
4916
4712
  auto value = args[0];
4917
- //if (count > 1) {
4918
- // if (args[0].isObject()) {
4919
4713
  auto location = WebGLUniformLocation::GetPointer(value.As<v8::Object>());
4920
4714
  auto v0 = args[1]->NumberValue(
4921
4715
  context).ToChecked();
@@ -4932,8 +4726,6 @@ WebGLRenderingContext::Uniform3i(const v8::FunctionCallbackInfo<v8::Value> &args
4932
4726
  ptr->GetState()
4933
4727
  );
4934
4728
  }
4935
- // }
4936
- // }
4937
4729
  }
4938
4730
 
4939
4731
  void
@@ -4947,8 +4739,6 @@ WebGLRenderingContext::Uniform4i(const v8::FunctionCallbackInfo<v8::Value> &args
4947
4739
  auto context = isolate->GetCurrentContext();
4948
4740
 
4949
4741
  auto value = args[0];
4950
- //if (count > 1) {
4951
- // if (args[0].isObject()) {
4952
4742
  auto location = WebGLUniformLocation::GetPointer(value.As<v8::Object>());
4953
4743
  auto v0 = args[1]->NumberValue(
4954
4744
  context).ToChecked();
@@ -4968,8 +4758,6 @@ WebGLRenderingContext::Uniform4i(const v8::FunctionCallbackInfo<v8::Value> &args
4968
4758
  ptr->GetState()
4969
4759
  );
4970
4760
  }
4971
- // }
4972
- // }
4973
4761
  }
4974
4762
 
4975
4763
  void
@@ -4997,7 +4785,7 @@ WebGLRenderingContext::Uniform1iv(const v8::FunctionCallbackInfo<v8::Value> &arg
4997
4785
  auto array = buf->Buffer();
4998
4786
  auto offset = buf->ByteOffset();
4999
4787
  auto size = buf->Length();
5000
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
4788
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
5001
4789
  auto data = static_cast<int32_t *>((void *) data_ptr);
5002
4790
 
5003
4791
 
@@ -5055,7 +4843,7 @@ WebGLRenderingContext::Uniform2iv(const v8::FunctionCallbackInfo<v8::Value> &arg
5055
4843
  auto array = buf->Buffer();
5056
4844
  auto offset = buf->ByteOffset();
5057
4845
  auto size = buf->Length();
5058
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
4846
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
5059
4847
  auto data = static_cast<int32_t *>((void *) data_ptr);
5060
4848
 
5061
4849
  canvas_native_webgl_uniform2iv(
@@ -5111,7 +4899,7 @@ WebGLRenderingContext::Uniform3iv(const v8::FunctionCallbackInfo<v8::Value> &arg
5111
4899
  auto array = buf->Buffer();
5112
4900
  auto offset = buf->ByteOffset();
5113
4901
  auto size = buf->Length();
5114
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
4902
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
5115
4903
  auto data = static_cast<int32_t *>((void *) data_ptr);
5116
4904
 
5117
4905
 
@@ -5169,7 +4957,7 @@ WebGLRenderingContext::Uniform4iv(const v8::FunctionCallbackInfo<v8::Value> &arg
5169
4957
  auto array = buf->Buffer();
5170
4958
  auto offset = buf->ByteOffset();
5171
4959
  auto size = buf->Length();
5172
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
4960
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
5173
4961
  auto data = static_cast<int32_t *>((void *) data_ptr);
5174
4962
 
5175
4963
 
@@ -5226,7 +5014,7 @@ WebGLRenderingContext::UniformMatrix2fv(const v8::FunctionCallbackInfo<v8::Value
5226
5014
  auto array = buf->Buffer();
5227
5015
  auto offset = buf->ByteOffset();
5228
5016
  auto size = buf->Length();
5229
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
5017
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
5230
5018
  auto data = static_cast<float *>((void *) data_ptr);
5231
5019
 
5232
5020
  canvas_native_webgl_uniform_matrix2fv(
@@ -5242,15 +5030,9 @@ WebGLRenderingContext::UniformMatrix2fv(const v8::FunctionCallbackInfo<v8::Value
5242
5030
  for (int i = 0;
5243
5031
  i < len; i++) {
5244
5032
  auto item = array->Get(context, i).ToLocalChecked();
5245
- if (item->IsNumber()) {
5246
- buf.push_back(
5247
- static_cast<float>(item->NumberValue(
5248
- context).ToChecked()));
5249
- } else {
5250
- buf.push_back(
5251
- std::nanf(
5252
- ""));
5253
- }
5033
+ buf.push_back(
5034
+ static_cast<float>(item->NumberValue(
5035
+ context).ToChecked()));
5254
5036
  }
5255
5037
 
5256
5038
  canvas_native_webgl_uniform_matrix2fv(
@@ -5288,7 +5070,7 @@ WebGLRenderingContext::UniformMatrix3fv(const v8::FunctionCallbackInfo<v8::Value
5288
5070
  auto array = buf->Buffer();
5289
5071
  auto offset = buf->ByteOffset();
5290
5072
  auto size = buf->Length();
5291
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
5073
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
5292
5074
  auto data = static_cast<float *>((void *) data_ptr);
5293
5075
 
5294
5076
  canvas_native_webgl_uniform_matrix3fv(
@@ -5304,15 +5086,9 @@ WebGLRenderingContext::UniformMatrix3fv(const v8::FunctionCallbackInfo<v8::Value
5304
5086
  for (int i = 0;
5305
5087
  i < len; i++) {
5306
5088
  auto item = array->Get(context, i).ToLocalChecked();
5307
- if (item->IsNumber()) {
5308
- buf.push_back(
5309
- static_cast<float>(item->NumberValue(
5310
- context).ToChecked()));
5311
- } else {
5312
- buf.push_back(
5313
- std::nanf(
5314
- ""));
5315
- }
5089
+ buf.push_back(
5090
+ static_cast<float>(item->NumberValue(
5091
+ context).ToChecked()));
5316
5092
  }
5317
5093
 
5318
5094
 
@@ -5351,7 +5127,7 @@ WebGLRenderingContext::UniformMatrix4fv(const v8::FunctionCallbackInfo<v8::Value
5351
5127
  auto array = buf->Buffer();
5352
5128
  auto offset = buf->ByteOffset();
5353
5129
  auto size = buf->Length();
5354
- auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
5130
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
5355
5131
  auto data = static_cast<float *>((void *) data_ptr);
5356
5132
 
5357
5133
 
@@ -5368,15 +5144,9 @@ WebGLRenderingContext::UniformMatrix4fv(const v8::FunctionCallbackInfo<v8::Value
5368
5144
  for (int i = 0;
5369
5145
  i < len; i++) {
5370
5146
  auto item = array->Get(context, i).ToLocalChecked();
5371
- if (item->IsNumber()) {
5372
- buf.push_back(
5373
- static_cast<float>(item->NumberValue(
5374
- context).ToChecked()));
5375
- } else {
5376
- buf.push_back(
5377
- std::nanf(
5378
- ""));
5379
- }
5147
+ buf.push_back(
5148
+ static_cast<float>(item->NumberValue(
5149
+ context).ToChecked()));
5380
5150
  }
5381
5151
 
5382
5152
 
@@ -5399,24 +5169,22 @@ WebGLRenderingContext::UseProgram(const v8::FunctionCallbackInfo<v8::Value> &arg
5399
5169
 
5400
5170
  auto isolate = args.GetIsolate();
5401
5171
 
5402
- if (args.Length() > 0) {
5403
- auto value = args[0];
5404
- if (value->IsNull()) {
5405
- canvas_native_webgl_use_program(0,
5406
- ptr->GetState());
5172
+ auto value = args[0];
5173
+ if (value->IsNull()) {
5174
+ canvas_native_webgl_use_program(0,
5175
+ ptr->GetState());
5407
5176
 
5408
- return;
5409
- }
5177
+ return;
5178
+ }
5410
5179
 
5411
- auto type = GetNativeType(isolate, value);
5412
- if (type == NativeType::WebGLProgram) {
5413
- auto program = WebGLProgram::GetPointer(value.As<v8::Object>());
5414
- if (program != nullptr) {
5415
- canvas_native_webgl_use_program(
5416
- program->GetProgram(),
5417
- ptr->GetState()
5418
- );
5419
- }
5180
+ auto type = GetNativeType(isolate, value);
5181
+ if (type == NativeType::WebGLProgram) {
5182
+ auto program = WebGLProgram::GetPointer(value.As<v8::Object>());
5183
+ if (program != nullptr) {
5184
+ canvas_native_webgl_use_program(
5185
+ program->GetProgram(),
5186
+ ptr->GetState()
5187
+ );
5420
5188
  }
5421
5189
  }
5422
5190
 
@@ -5455,20 +5223,18 @@ WebGLRenderingContext::Viewport(const v8::FunctionCallbackInfo<v8::Value> &args)
5455
5223
  auto isolate = args.GetIsolate();
5456
5224
  auto context = isolate->GetCurrentContext();
5457
5225
 
5458
- if (args.Length() > 3) {
5459
- auto x = (int32_t) args[0]->NumberValue(
5460
- context).ToChecked();
5461
- auto y = (int32_t) args[1]->NumberValue(
5462
- context).ToChecked();
5463
- auto width = (int32_t) args[2]->NumberValue(
5464
- context).ToChecked();
5465
- auto height = (int32_t) args[3]->NumberValue(
5466
- context).ToChecked();
5467
- canvas_native_webgl_viewport(x, y,
5468
- width,
5469
- height,
5470
- ptr->GetState());
5471
- }
5226
+ auto x = (int32_t) args[0]->NumberValue(
5227
+ context).ToChecked();
5228
+ auto y = (int32_t) args[1]->NumberValue(
5229
+ context).ToChecked();
5230
+ auto width = (int32_t) args[2]->NumberValue(
5231
+ context).ToChecked();
5232
+ auto height = (int32_t) args[3]->NumberValue(
5233
+ context).ToChecked();
5234
+ canvas_native_webgl_viewport(x, y,
5235
+ width,
5236
+ height,
5237
+ ptr->GetState());
5472
5238
 
5473
5239
  }
5474
5240