@nativescript/canvas 2.0.0-alpha.24 → 2.0.0-alpha.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/package.json +1 -1
  2. package/platforms/android/canvas-release.aar +0 -0
  3. package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
  4. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  5. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +19 -0
  6. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  7. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  8. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +19 -0
  9. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +2 -2
  10. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  11. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +13 -62
  12. package/platforms/ios/src/cpp/ImageBitmapImpl.h +15 -3
  13. package/platforms/ios/src/cpp/OneByteStringResource.cpp +26 -2
  14. package/platforms/ios/src/cpp/OneByteStringResource.h +14 -3
  15. package/platforms/ios/src/cpp/TextDecoderImpl.cpp +8 -9
  16. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +257 -268
  17. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +8 -2
  18. package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +1 -1
  19. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +72 -94
  20. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.cpp +2 -2
  21. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +4 -3
  22. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.cpp +1 -5
  23. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +5 -5
  24. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +103 -113
@@ -6,7 +6,7 @@
6
6
  #include "MatrixImpl.h"
7
7
  #include "Caches.h"
8
8
 
9
- MatrixImpl::MatrixImpl(Matrix* matrix) : matrix_(matrix) {}
9
+ MatrixImpl::MatrixImpl(Matrix *matrix) : matrix_(matrix) {}
10
10
 
11
11
  void MatrixImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
12
12
  v8::Locker locker(isolate);
@@ -218,6 +218,8 @@ void MatrixImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
218
218
 
219
219
  ret->SetInternalField(0, ext);
220
220
 
221
+ SetNativeType(isolate, ret, NativeType::Matrix);
222
+
221
223
  args.GetReturnValue().Set(ret);
222
224
 
223
225
  return;
@@ -241,6 +243,8 @@ void MatrixImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
241
243
 
242
244
  ret->SetInternalField(0, ext);
243
245
 
246
+ SetNativeType(isolate, ret, NativeType::Matrix);
247
+
244
248
  args.GetReturnValue().Set(ret);
245
249
  return;
246
250
  }
@@ -254,6 +258,8 @@ void MatrixImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
254
258
 
255
259
  ret->SetInternalField(0, ext);
256
260
 
261
+ SetNativeType(isolate, ret, NativeType::Matrix);
262
+
257
263
  args.GetReturnValue().Set(ret);
258
264
  return;
259
265
  }
@@ -795,6 +801,6 @@ void MatrixImpl::SetM44(v8::Local<v8::String> property,
795
801
  canvas_native_matrix_set_m44(ptr->GetMatrix(), (float) value->NumberValue(context).ToChecked());
796
802
  }
797
803
 
798
- Matrix* MatrixImpl::GetMatrix() {
804
+ Matrix *MatrixImpl::GetMatrix() {
799
805
  return this->matrix_;
800
806
  }
@@ -118,7 +118,7 @@ void Path2D::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
118
118
  if (value->IsString()) {
119
119
  auto d = ConvertFromV8String(isolate, value);
120
120
  auto path = canvas_native_path_create_with_string(d.c_str());
121
- auto object = new Path2D(std::move(path));
121
+ auto object = new Path2D(path);
122
122
 
123
123
  auto ext = v8::External::New(isolate, object);
124
124
 
@@ -336,11 +336,7 @@ void WebGLRenderingContext::AttachShader(const v8::FunctionCallbackInfo<v8::Valu
336
336
  shader = WebGLShader::GetPointer(shaderValue.As<v8::Object>());
337
337
  }
338
338
 
339
- if (program == nullptr) {
340
- return;
341
- }
342
-
343
- if (shader == nullptr) {
339
+ if (program == nullptr || shader == nullptr) {
344
340
  return;
345
341
  }
346
342
 
@@ -389,7 +385,7 @@ void WebGLRenderingContext::BindBuffer(const v8::FunctionCallbackInfo<v8::Value>
389
385
  auto target = args[0]->Uint32Value(context).ToChecked();
390
386
  if (!args[1]->IsNull() &&
391
387
  args[1]->IsObject()) {
392
- auto type = GetNativeType(isolate, args[1].As<v8::Object>());
388
+ auto type = GetNativeType(isolate, args[1]);
393
389
  if (type == NativeType::WebGLBuffer) {
394
390
  auto buffer = WebGLBuffer::GetPointer(args[1].As<v8::Object>());
395
391
  if (buffer ==
@@ -421,27 +417,25 @@ void WebGLRenderingContext::BindFramebuffer(const v8::FunctionCallbackInfo<v8::V
421
417
  auto isolate = args.GetIsolate();
422
418
  auto context = isolate->GetCurrentContext();
423
419
 
424
- if (args[0]->IsNumber()) {
425
- auto target = args[0]->Uint32Value(context).ToChecked();
426
- if (args[1]->IsObject()) {
427
- auto type = GetNativeType(isolate, args[1]);
428
- if (type == NativeType::WebGLFramebuffer) {
429
- auto framebuffer = WebGLFramebuffer::GetPointer(args[1].As<v8::Object>());
430
- canvas_native_webgl_bind_frame_buffer(
431
- target,
432
- framebuffer->GetFrameBuffer(),
433
- ptr->GetState()
434
- );
435
- }
436
- } else {
437
- // null value
438
- // unbind
420
+ auto target = args[0]->Uint32Value(context).ToChecked();
421
+ if (args[1]->IsObject()) {
422
+ auto type = GetNativeType(isolate, args[1]);
423
+ if (type == NativeType::WebGLFramebuffer) {
424
+ auto framebuffer = WebGLFramebuffer::GetPointer(args[1].As<v8::Object>());
439
425
  canvas_native_webgl_bind_frame_buffer(
440
426
  target,
441
- 0,
427
+ framebuffer->GetFrameBuffer(),
442
428
  ptr->GetState()
443
429
  );
444
430
  }
431
+ } else {
432
+ // null value
433
+ // unbind
434
+ canvas_native_webgl_bind_frame_buffer(
435
+ target,
436
+ 0,
437
+ ptr->GetState()
438
+ );
445
439
  }
446
440
  }
447
441
 
@@ -456,7 +450,7 @@ void WebGLRenderingContext::BindRenderbuffer(const v8::FunctionCallbackInfo<v8::
456
450
 
457
451
  auto target = args[0]->Uint32Value(context).ToChecked();
458
452
  if (args[1]->IsObject()) {
459
- auto type = GetNativeType(isolate, args[1].As<v8::Object>());
453
+ auto type = GetNativeType(isolate, args[1]);
460
454
  if (type == NativeType::WebGLRenderbuffer) {
461
455
  auto renderbuffer = WebGLRenderbuffer::GetPointer(args[1].As<v8::Object>());
462
456
 
@@ -784,21 +778,15 @@ WebGLRenderingContext::CheckFramebufferStatus(const v8::FunctionCallbackInfo<v8:
784
778
  auto isolate = args.GetIsolate();
785
779
  auto context = isolate->GetCurrentContext();
786
780
 
787
- auto count = args.Length();
788
-
789
- if (args[0]->IsNumber()) {
790
- auto target = args[0]->Uint32Value(context).ToChecked();
791
781
 
792
- auto ret = canvas_native_webgl_check_frame_buffer_status(
793
- target,
794
- ptr->GetState()
795
- );
782
+ auto target = args[0]->Uint32Value(context).ToChecked();
796
783
 
797
- args.GetReturnValue().Set(ret);
798
- return;
799
- }
784
+ auto ret = canvas_native_webgl_check_frame_buffer_status(
785
+ target,
786
+ ptr->GetState()
787
+ );
800
788
 
801
- args.GetReturnValue().Set(0);
789
+ args.GetReturnValue().Set(ret);
802
790
  }
803
791
 
804
792
  void WebGLRenderingContext::ClearColor(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -1016,44 +1004,42 @@ WebGLRenderingContext::CompressedTexSubImage2D(const v8::FunctionCallbackInfo<v8
1016
1004
  auto width = args[4]->Int32Value(context).ToChecked();
1017
1005
  auto height = args[5]->Int32Value(context).ToChecked();
1018
1006
  auto format = args[6]->Uint32Value(context).ToChecked();
1019
- if (args[7]->IsObject()) {
1020
- auto pixels = args[7];
1021
- if (pixels->IsArrayBufferView()) {
1022
- auto buf = pixels.As<v8::ArrayBufferView>();
1023
- auto array = buf->Buffer();
1024
- auto offset = buf->ByteOffset();
1025
- auto size = array->ByteLength();
1026
- auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
1027
- auto data = static_cast<uint8_t *>((void *) data_ptr);
1007
+ auto pixels = args[7];
1008
+ if (pixels->IsArrayBufferView()) {
1009
+ auto buf = pixels.As<v8::ArrayBufferView>();
1010
+ auto array = buf->Buffer();
1011
+ auto offset = buf->ByteOffset();
1012
+ auto size = array->ByteLength();
1013
+ auto data_ptr = static_cast<uint8_t *>(array->GetBackingStore()->Data()) + offset;
1014
+ auto data = static_cast<uint8_t *>((void *) data_ptr);
1028
1015
 
1029
- canvas_native_webgl_compressed_tex_sub_image2d(
1030
- target,
1031
- level,
1032
- xoffset,
1033
- yoffset,
1034
- width,
1035
- height,
1036
- format,
1037
- data, size,
1038
- ptr->GetState()
1039
- );
1040
- } else if (pixels->IsArrayBuffer()) {
1041
- auto array = pixels.As<v8::ArrayBuffer>();
1042
- auto size = array->ByteLength();
1043
- auto data = (uint8_t *) array->GetBackingStore()->Data();
1016
+ canvas_native_webgl_compressed_tex_sub_image2d(
1017
+ target,
1018
+ level,
1019
+ xoffset,
1020
+ yoffset,
1021
+ width,
1022
+ height,
1023
+ format,
1024
+ data, size,
1025
+ ptr->GetState()
1026
+ );
1027
+ } else if (pixels->IsArrayBuffer()) {
1028
+ auto array = pixels.As<v8::ArrayBuffer>();
1029
+ auto size = array->ByteLength();
1030
+ auto data = (uint8_t *) array->GetBackingStore()->Data();
1044
1031
 
1045
- canvas_native_webgl_compressed_tex_sub_image2d(
1046
- target,
1047
- level,
1048
- xoffset,
1049
- yoffset,
1050
- width,
1051
- height,
1052
- format,
1053
- data, size,
1054
- ptr->GetState()
1055
- );
1056
- }
1032
+ canvas_native_webgl_compressed_tex_sub_image2d(
1033
+ target,
1034
+ level,
1035
+ xoffset,
1036
+ yoffset,
1037
+ width,
1038
+ height,
1039
+ format,
1040
+ data, size,
1041
+ ptr->GetState()
1042
+ );
1057
1043
  }
1058
1044
 
1059
1045
  }
@@ -1303,7 +1289,7 @@ void WebGLRenderingContext::DeleteBuffer(const v8::FunctionCallbackInfo<v8::Valu
1303
1289
 
1304
1290
 
1305
1291
  auto value = args[0];
1306
- auto type = GetNativeType(isolate, value.As<v8::Object>());
1292
+ auto type = GetNativeType(isolate, value);
1307
1293
  if (type == NativeType::WebGLBuffer) {
1308
1294
  auto buffer = WebGLBuffer::GetPointer(value.As<v8::Object>());
1309
1295
  if (buffer != nullptr) {
@@ -1324,7 +1310,6 @@ void WebGLRenderingContext::DeleteFramebuffer(const v8::FunctionCallbackInfo<v8:
1324
1310
 
1325
1311
  auto isolate = args.GetIsolate();
1326
1312
 
1327
-
1328
1313
  auto value = args[0];
1329
1314
  auto type = GetNativeType(isolate, value);
1330
1315
  if (type == NativeType::WebGLFramebuffer) {
@@ -1377,7 +1362,7 @@ void WebGLRenderingContext::DeleteRenderbuffer(const v8::FunctionCallbackInfo<v8
1377
1362
  auto value = args[0];
1378
1363
  auto type = GetNativeType(isolate, value);
1379
1364
 
1380
- if (type == NativeType::WebGLProgram) {
1365
+ if (type == NativeType::WebGLRenderbuffer) {
1381
1366
  auto buffer = WebGLRenderbuffer::GetPointer(value.As<v8::Object>());
1382
1367
  if (buffer != nullptr) {
1383
1368
  canvas_native_webgl_delete_renderbuffer(
@@ -1402,7 +1387,7 @@ void WebGLRenderingContext::DeleteShader(const v8::FunctionCallbackInfo<v8::Valu
1402
1387
  auto value = args[0];
1403
1388
  auto type = GetNativeType(isolate, value);
1404
1389
 
1405
- if (type == NativeType::WebGLProgram) {
1390
+ if (type == NativeType::WebGLShader) {
1406
1391
  auto shader = WebGLShader::GetPointer(value.As<v8::Object>());
1407
1392
  if (shader != nullptr) {
1408
1393
  canvas_native_webgl_delete_shader(
@@ -1425,7 +1410,7 @@ void WebGLRenderingContext::DeleteTexture(const v8::FunctionCallbackInfo<v8::Val
1425
1410
  auto value = args[0];
1426
1411
  auto type = GetNativeType(isolate, value);
1427
1412
 
1428
- if (type == NativeType::WebGLProgram) {
1413
+ if (type == NativeType::WebGLTexture) {
1429
1414
  auto texture = WebGLTexture::GetPointer(value.As<v8::Object>());
1430
1415
  if (texture != nullptr) {
1431
1416
  canvas_native_webgl_delete_texture(
@@ -2430,22 +2415,16 @@ WebGLRenderingContext::GetRenderbufferParameter(const v8::FunctionCallbackInfo<v
2430
2415
  auto isolate = args.GetIsolate();
2431
2416
  auto context = isolate->GetCurrentContext();
2432
2417
 
2433
- if (args.Length() > 1) {
2434
- auto target = args[0]->Uint32Value(
2435
- context).ToChecked();
2436
- auto pname = args[1]->Uint32Value(
2437
- context).ToChecked();
2438
- auto ret = canvas_native_webgl_get_renderbuffer_parameter(
2439
- target,
2440
- pname,
2441
- ptr->GetState()
2442
- );
2443
- args.GetReturnValue().Set(ret);
2444
- return;
2445
- }
2446
-
2447
- // todo check return
2448
- args.GetReturnValue().SetNull();
2418
+ auto target = args[0]->Uint32Value(
2419
+ context).ToChecked();
2420
+ auto pname = args[1]->Uint32Value(
2421
+ context).ToChecked();
2422
+ auto ret = canvas_native_webgl_get_renderbuffer_parameter(
2423
+ target,
2424
+ pname,
2425
+ ptr->GetState()
2426
+ );
2427
+ args.GetReturnValue().Set(ret);
2449
2428
  }
2450
2429
 
2451
2430
  void WebGLRenderingContext::GetShaderInfoLog(const v8::FunctionCallbackInfo<v8::Value> &args) {
@@ -2685,7 +2664,7 @@ WebGLRenderingContext::GetUniformLocation(const v8::FunctionCallbackInfo<v8::Val
2685
2664
  if (type == NativeType::WebGLProgram && nameValue->IsString()) {
2686
2665
  auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2687
2666
  if (program != nullptr) {
2688
- auto name = ConvertFromV8String(isolate, args[1]);
2667
+ auto name = ConvertFromV8String(isolate, nameValue);
2689
2668
 
2690
2669
  auto ret = canvas_native_webgl_get_uniform_location(
2691
2670
  program->GetProgram(),
@@ -2726,7 +2705,6 @@ WebGLRenderingContext::GetUniform(const v8::FunctionCallbackInfo<v8::Value> &arg
2726
2705
  auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2727
2706
  auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2728
2707
 
2729
-
2730
2708
  if (program != nullptr &&
2731
2709
  location != nullptr) {
2732
2710
 
@@ -50,13 +50,13 @@ void ANGLE_instanced_arraysImpl::DrawElementsInstancedANGLE(
50
50
  auto context = isolate->GetCurrentContext();
51
51
 
52
52
  auto mode = args[0]->Uint32Value(context).ToChecked();
53
- auto count_ = args[1]->Int32Value(context).ToChecked();
53
+ auto count = args[1]->Int32Value(context).ToChecked();
54
54
  auto type = args[2]->Uint32Value(context).ToChecked();
55
55
  auto offset = args[3]->Int32Value(context).ToChecked();
56
56
  auto primcount = args[4]->Int32Value(context).ToChecked();
57
57
  canvas_native_webgl_angle_instanced_arrays_draw_elements_instanced_angle(
58
58
  mode,
59
- count_,
59
+ count,
60
60
  type,
61
61
  offset,
62
62
  primcount,
@@ -3,15 +3,16 @@
3
3
  //
4
4
 
5
5
  #pragma once
6
+
6
7
  #include "Helpers.h"
7
8
  #include <vector>
8
9
 
9
10
 
10
11
  class ANGLE_instanced_arraysImpl {
11
12
  public:
12
- ANGLE_instanced_arraysImpl(ANGLE_instanced_arrays* arrays);
13
+ ANGLE_instanced_arraysImpl(ANGLE_instanced_arrays *arrays);
13
14
 
14
- ANGLE_instanced_arrays* GetArrays();
15
+ ANGLE_instanced_arrays *GetArrays();
15
16
 
16
17
  static ANGLE_instanced_arraysImpl *GetPointer(const v8::Local<v8::Object> &object);
17
18
 
@@ -36,6 +37,6 @@ public:
36
37
  static void VertexAttribDivisorANGLE(const v8::FunctionCallbackInfo<v8::Value> &args);
37
38
 
38
39
  private:
39
- ANGLE_instanced_arrays* arrays_;
40
+ ANGLE_instanced_arrays *arrays_;
40
41
  };
41
42
 
@@ -88,7 +88,6 @@ void EXT_disjoint_timer_queryImpl::CreateQueryExt(
88
88
  return;
89
89
  }
90
90
  auto isolate = args.GetIsolate();
91
- auto context = isolate->GetCurrentContext();
92
91
 
93
92
  auto ret = canvas_native_webgl_ext_disjoint_timer_query_create_query_ext(
94
93
  ptr->GetQuery());
@@ -96,10 +95,7 @@ void EXT_disjoint_timer_queryImpl::CreateQueryExt(
96
95
  auto object = new WebGLQuery(
97
96
  ret);
98
97
 
99
- auto value = WebGLQuery::GetCtor(isolate)->GetFunction(context).ToLocalChecked()->NewInstance(
100
- context).ToLocalChecked();
101
- value->SetInternalField(0, v8::External::New(isolate, object));
102
- SetNativeType(isolate, value, NativeType::WebGLQuery);
98
+ auto value = WebGLQuery::NewInstance(isolate, object);
103
99
  args.GetReturnValue().Set(value);
104
100
  }
105
101
 
@@ -11,14 +11,14 @@
11
11
 
12
12
  class EXT_disjoint_timer_queryImpl {
13
13
  public:
14
- EXT_disjoint_timer_queryImpl(EXT_disjoint_timer_query* query);
15
-
16
- ~EXT_disjoint_timer_queryImpl(){
14
+ EXT_disjoint_timer_queryImpl(EXT_disjoint_timer_query *query);
15
+
16
+ ~EXT_disjoint_timer_queryImpl() {
17
17
  canvas_native_webgl_EXT_disjoint_timer_query_destroy(this->GetQuery());
18
18
  this->query_ = nullptr;
19
19
  }
20
20
 
21
- EXT_disjoint_timer_query* GetQuery();
21
+ EXT_disjoint_timer_query *GetQuery();
22
22
 
23
23
  static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
24
24
 
@@ -58,5 +58,5 @@ public:
58
58
 
59
59
 
60
60
  private:
61
- EXT_disjoint_timer_query* query_;
61
+ EXT_disjoint_timer_query *query_;
62
62
  };