@nativescript/canvas 2.0.0-webgpu.31 → 2.0.0-webgpu.34
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.
- package/Canvas/index.android.d.ts +6 -4
- package/Canvas/index.android.js +21 -7
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +2 -0
- package/Canvas/index.ios.d.ts +2 -0
- package/Canvas/index.ios.js +22 -20
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas/utils.js +2 -2
- package/Canvas/utils.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
- package/WebGPU/GPUDevice.js +17 -18
- package/WebGPU/GPUDevice.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/platforms/android/canvas-release.aar +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +21 -19
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative.h +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/NSCMTLView.h +32 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +143 -182
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +30 -10
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +380 -519
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +20 -20
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +20 -20
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +675 -650
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +42 -38
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative.h +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/NSCMTLView.h +32 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +143 -182
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +30 -10
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +380 -519
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +20 -20
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +20 -20
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +380 -519
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +20 -20
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +20 -20
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +39 -28
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +677 -652
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +730 -704
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +17 -55
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +6 -10
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.cpp +5 -5
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +33 -33
- package/utils.d.ts +1 -1
|
@@ -232,19 +232,8 @@ void CanvasJSIModule::Create2DContext(const v8::FunctionCallbackInfo<v8::Value>
|
|
|
232
232
|
auto isolate = args.GetIsolate();
|
|
233
233
|
auto context = isolate->GetCurrentContext();
|
|
234
234
|
auto ptr = args[0].As<v8::BigInt>()->Int64Value();
|
|
235
|
-
|
|
236
|
-
auto
|
|
237
|
-
auto density = (float) args[3]->NumberValue(context).ToChecked();
|
|
238
|
-
auto samples = (int) args[4]->NumberValue(context).ToChecked();
|
|
239
|
-
auto alpha = (bool) args[5]->BooleanValue(isolate);
|
|
240
|
-
auto font_color = (int) args[6]->NumberValue(context).ToChecked();
|
|
241
|
-
auto ppi = (float) args[7]->NumberValue(context).ToChecked();
|
|
242
|
-
auto direction = (int) args[8]->NumberValue(context).ToChecked();
|
|
243
|
-
|
|
244
|
-
auto context_2d = canvas_native_context_create_gl(width, height, density,
|
|
245
|
-
ptr,
|
|
246
|
-
samples, alpha,
|
|
247
|
-
font_color, ppi, direction);
|
|
235
|
+
|
|
236
|
+
auto context_2d = static_cast<CanvasRenderingContext2D *>((void *)ptr);
|
|
248
237
|
|
|
249
238
|
auto ret = CanvasRenderingContext2DImpl::NewInstance(isolate, new CanvasRenderingContext2DImpl(
|
|
250
239
|
context_2d));
|
|
@@ -397,7 +386,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
397
386
|
callback->Call(context, context->Global(),
|
|
398
387
|
2,
|
|
399
388
|
args); // ignore JS return value
|
|
400
|
-
|
|
389
|
+
|
|
401
390
|
delete asset_data;
|
|
402
391
|
|
|
403
392
|
} else {
|
|
@@ -610,7 +599,7 @@ void CanvasJSIModule::Create2DContextWithPointer(const v8::FunctionCallbackInfo<
|
|
|
610
599
|
struct FileData {
|
|
611
600
|
char *error_;
|
|
612
601
|
U8Buffer* data;
|
|
613
|
-
|
|
602
|
+
|
|
614
603
|
~FileData() {
|
|
615
604
|
if (error_ != nullptr) {
|
|
616
605
|
canvas_native_string_destroy(error_);
|
|
@@ -623,8 +612,8 @@ void CanvasJSIModule::ReadFile(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
623
612
|
auto isolate = args.GetIsolate();
|
|
624
613
|
auto file = ConvertFromV8String(isolate, args[0]);
|
|
625
614
|
auto cbFunc = args[1].As<v8::Function>();
|
|
626
|
-
|
|
627
|
-
|
|
615
|
+
|
|
616
|
+
|
|
628
617
|
auto callback = new AsyncCallback(isolate, cbFunc, [](bool done, void *data) {
|
|
629
618
|
if(data == nullptr){return;}
|
|
630
619
|
auto async_data = static_cast<AsyncCallback *>(data);
|
|
@@ -638,10 +627,10 @@ void CanvasJSIModule::ReadFile(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
638
627
|
isolate);
|
|
639
628
|
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
640
629
|
v8::Context::Scope context_scope(context);
|
|
641
|
-
|
|
630
|
+
|
|
642
631
|
if (func->data != nullptr) {
|
|
643
632
|
auto file_data = static_cast<FileData*>(func->data);
|
|
644
|
-
|
|
633
|
+
|
|
645
634
|
v8::Local<v8::Value> args[2];
|
|
646
635
|
|
|
647
636
|
if (done) {
|
|
@@ -657,7 +646,7 @@ void CanvasJSIModule::ReadFile(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
657
646
|
if (deleter_data !=
|
|
658
647
|
nullptr) {
|
|
659
648
|
delete static_cast<FileData *>(deleter_data);
|
|
660
|
-
|
|
649
|
+
|
|
661
650
|
}
|
|
662
651
|
},
|
|
663
652
|
func->data);
|
|
@@ -698,13 +687,13 @@ void CanvasJSIModule::ReadFile(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
698
687
|
}
|
|
699
688
|
|
|
700
689
|
delete async_data;
|
|
701
|
-
|
|
690
|
+
|
|
702
691
|
}
|
|
703
692
|
}
|
|
704
693
|
});
|
|
705
|
-
|
|
694
|
+
|
|
706
695
|
callback->prepare();
|
|
707
|
-
|
|
696
|
+
|
|
708
697
|
std::thread thread(
|
|
709
698
|
[callback, file]() {
|
|
710
699
|
bool done = false;
|
|
@@ -723,8 +712,8 @@ void CanvasJSIModule::ReadFile(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
723
712
|
});
|
|
724
713
|
|
|
725
714
|
thread.detach();
|
|
726
|
-
|
|
727
|
-
|
|
715
|
+
|
|
716
|
+
|
|
728
717
|
|
|
729
718
|
}
|
|
730
719
|
|
|
@@ -745,20 +734,7 @@ void CanvasJSIModule::CreateWebGLContext(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
745
734
|
auto count = args.Length();
|
|
746
735
|
if (count == 6) {
|
|
747
736
|
auto ctx = args[1].As<v8::BigInt>()->Int64Value();
|
|
748
|
-
auto webgl =
|
|
749
|
-
ctx,
|
|
750
|
-
options.version,
|
|
751
|
-
options.alpha,
|
|
752
|
-
options.antialias,
|
|
753
|
-
options.depth,
|
|
754
|
-
options.failIfMajorPerformanceCaveat,
|
|
755
|
-
options.powerPreference,
|
|
756
|
-
options.premultipliedAlpha,
|
|
757
|
-
options.preserveDrawingBuffer,
|
|
758
|
-
options.stencil,
|
|
759
|
-
options.desynchronized,
|
|
760
|
-
options.xrCompatible
|
|
761
|
-
);
|
|
737
|
+
auto webgl = static_cast<WebGLState*>((void *)ctx);
|
|
762
738
|
|
|
763
739
|
auto renderingContext = WebGLRenderingContext::NewInstance(isolate,
|
|
764
740
|
new WebGLRenderingContext(
|
|
@@ -841,22 +817,8 @@ void CanvasJSIModule::CreateWebGL2Context(const v8::FunctionCallbackInfo<v8::Val
|
|
|
841
817
|
|
|
842
818
|
auto count = args.Length();
|
|
843
819
|
if (count == 6) {
|
|
844
|
-
auto ctx = args[
|
|
845
|
-
auto webgl =
|
|
846
|
-
ctx,
|
|
847
|
-
options.version,
|
|
848
|
-
options.alpha,
|
|
849
|
-
options.antialias,
|
|
850
|
-
options.depth,
|
|
851
|
-
options.failIfMajorPerformanceCaveat,
|
|
852
|
-
options.powerPreference,
|
|
853
|
-
options.premultipliedAlpha,
|
|
854
|
-
options.preserveDrawingBuffer,
|
|
855
|
-
options.stencil,
|
|
856
|
-
options.desynchronized,
|
|
857
|
-
options.xrCompatible
|
|
858
|
-
);
|
|
859
|
-
|
|
820
|
+
auto ctx = args[0].As<v8::BigInt>()->Int64Value();
|
|
821
|
+
auto webgl = static_cast<WebGLState*>((void *)ctx);
|
|
860
822
|
auto renderingContext = WebGL2RenderingContext::NewInstance(isolate,
|
|
861
823
|
new WebGL2RenderingContext(
|
|
862
824
|
webgl,
|
|
@@ -1110,7 +1110,6 @@ void CanvasRenderingContext2DImpl::SetTextAlign(v8::Local<v8::String> property,
|
|
|
1110
1110
|
void CanvasRenderingContext2DImpl::GetTextBaseline(v8::Local<v8::String> property,
|
|
1111
1111
|
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
1112
1112
|
CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
|
|
1113
|
-
auto isolate = info.GetIsolate();
|
|
1114
1113
|
if (ptr == nullptr) {
|
|
1115
1114
|
info.GetReturnValue().Set(0);
|
|
1116
1115
|
return;
|
|
@@ -1963,7 +1962,6 @@ CanvasRenderingContext2DImpl::DrawAtlas(const v8::FunctionCallbackInfo<v8::Value
|
|
|
1963
1962
|
return;
|
|
1964
1963
|
}
|
|
1965
1964
|
|
|
1966
|
-
auto count = args.Length();
|
|
1967
1965
|
auto value = args[0];
|
|
1968
1966
|
|
|
1969
1967
|
if (value->IsNullOrUndefined() || !value->IsObject()) {
|
|
@@ -2968,8 +2966,6 @@ void
|
|
|
2968
2966
|
CanvasRenderingContext2DImpl::Stroke(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
2969
2967
|
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
2970
2968
|
|
|
2971
|
-
auto isolate = args.GetIsolate();
|
|
2972
|
-
|
|
2973
2969
|
auto value = args[0];
|
|
2974
2970
|
auto type = GetNativeType(value);
|
|
2975
2971
|
if (type == NativeType::Path2D) {
|
|
@@ -3136,12 +3132,12 @@ CanvasRenderingContext2DImpl::~CanvasRenderingContext2DImpl() {
|
|
|
3136
3132
|
}
|
|
3137
3133
|
|
|
3138
3134
|
void CanvasRenderingContext2DImpl::UpdateInvalidateState() {
|
|
3139
|
-
auto raf = this->GetRaf();
|
|
3140
|
-
if (raf != nullptr) {
|
|
3141
|
-
if (!canvas_native_raf_get_started(raf->GetRaf())) {
|
|
3142
|
-
canvas_native_raf_start(raf->GetRaf());
|
|
3143
|
-
}
|
|
3144
|
-
}
|
|
3135
|
+
// auto raf = this->GetRaf();
|
|
3136
|
+
// if (raf != nullptr) {
|
|
3137
|
+
// if (!canvas_native_raf_get_started(raf->GetRaf())) {
|
|
3138
|
+
// canvas_native_raf_start(raf->GetRaf());
|
|
3139
|
+
// }
|
|
3140
|
+
// }
|
|
3145
3141
|
|
|
3146
3142
|
auto state = this->GetInvalidateState();
|
|
3147
3143
|
this->SetInvalidateState((int) state | (int) InvalidateState::InvalidateStatePending);
|
|
@@ -82,11 +82,11 @@ void WebGLRenderingContextBase::StopRaf() {
|
|
|
82
82
|
|
|
83
83
|
void WebGLRenderingContextBase::UpdateInvalidateState() {
|
|
84
84
|
auto raf = this->GetRaf();
|
|
85
|
-
if (raf != nullptr) {
|
|
86
|
-
if (!canvas_native_raf_get_started(raf->GetRaf())) {
|
|
87
|
-
canvas_native_raf_start(raf->GetRaf());
|
|
88
|
-
}
|
|
89
|
-
}
|
|
85
|
+
// if (raf != nullptr) {
|
|
86
|
+
// if (!canvas_native_raf_get_started(raf->GetRaf())) {
|
|
87
|
+
// canvas_native_raf_start(raf->GetRaf());
|
|
88
|
+
// }
|
|
89
|
+
// }
|
|
90
90
|
auto state = this->GetInvalidateState();
|
|
91
91
|
this->SetInvalidateState(state | (int) InvalidateState::InvalidateStatePending);
|
|
92
92
|
}
|
|
@@ -1295,12 +1295,12 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1295
1295
|
auto options = optionsVal.As<v8::Object>();
|
|
1296
1296
|
|
|
1297
1297
|
v8::Local<v8::Value> stencilValue;
|
|
1298
|
-
options->Get(context, ConvertToV8String(isolate, "depthStencil")).ToLocal(
|
|
1298
|
+
auto hasDepthStencil = options->Get(context, ConvertToV8String(isolate, "depthStencil")).ToLocal(
|
|
1299
1299
|
&stencilValue);
|
|
1300
1300
|
|
|
1301
1301
|
CanvasDepthStencilState *stencil = nullptr;
|
|
1302
1302
|
|
|
1303
|
-
if (
|
|
1303
|
+
if (hasDepthStencil && stencilValue->IsObject()) {
|
|
1304
1304
|
auto stencilObj = stencilValue.As<v8::Object>();
|
|
1305
1305
|
stencil = new CanvasDepthStencilState{};
|
|
1306
1306
|
stencil->depth_bias = 0;
|
|
@@ -1491,14 +1491,14 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1491
1491
|
|
|
1492
1492
|
|
|
1493
1493
|
v8::Local<v8::Value> fragmentValue;
|
|
1494
|
-
options->Get(context, ConvertToV8String(isolate, "fragment")).ToLocal(
|
|
1494
|
+
auto hasFragment = options->Get(context, ConvertToV8String(isolate, "fragment")).ToLocal(
|
|
1495
1495
|
&fragmentValue);
|
|
1496
1496
|
|
|
1497
1497
|
CanvasFragmentState *fragment = nullptr;
|
|
1498
1498
|
|
|
1499
1499
|
std::vector<CanvasColorTargetState> targets;
|
|
1500
1500
|
|
|
1501
|
-
if (
|
|
1501
|
+
if (hasFragment && fragmentValue->IsObject()) {
|
|
1502
1502
|
auto fragmentValueObj = fragmentValue.As<v8::Object>();
|
|
1503
1503
|
fragment = new CanvasFragmentState{};
|
|
1504
1504
|
|
|
@@ -1532,9 +1532,9 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1532
1532
|
|
|
1533
1533
|
v8::Local<v8::Value> writeMaskVal;
|
|
1534
1534
|
|
|
1535
|
-
state->Get(context, ConvertToV8String(isolate, "writeMask")).ToLocal(&writeMaskVal);
|
|
1535
|
+
auto hasWriteMask = state->Get(context, ConvertToV8String(isolate, "writeMask")).ToLocal(&writeMaskVal);
|
|
1536
1536
|
|
|
1537
|
-
if (
|
|
1537
|
+
if (hasWriteMask && writeMaskVal->IsUint32()) {
|
|
1538
1538
|
writeMask = writeMaskVal->Uint32Value(context).FromJust();
|
|
1539
1539
|
}
|
|
1540
1540
|
|
|
@@ -1544,9 +1544,9 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1544
1544
|
|
|
1545
1545
|
v8::Local<v8::Value> blendVal;
|
|
1546
1546
|
|
|
1547
|
-
state->Get(context, ConvertToV8String(isolate, "blend")).ToLocal(&blendVal);
|
|
1547
|
+
auto hasBlend = state->Get(context, ConvertToV8String(isolate, "blend")).ToLocal(&blendVal);
|
|
1548
1548
|
|
|
1549
|
-
if (
|
|
1549
|
+
if (hasBlend && blendVal->IsObject()) {
|
|
1550
1550
|
auto blendObj = blendVal.As<v8::Object>();
|
|
1551
1551
|
auto alpha = blendObj->Get(context, ConvertToV8String(isolate,
|
|
1552
1552
|
"alpha")).ToLocalChecked().As<v8::Object>();
|
|
@@ -1638,10 +1638,10 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1638
1638
|
}
|
|
1639
1639
|
|
|
1640
1640
|
v8::Local<v8::Value> constantsVal;
|
|
1641
|
-
fragmentValueObj->Get(context, ConvertToV8String(isolate, "constants")).ToLocal(
|
|
1641
|
+
auto hasConstants = fragmentValueObj->Get(context, ConvertToV8String(isolate, "constants")).ToLocal(
|
|
1642
1642
|
&constantsVal);
|
|
1643
1643
|
|
|
1644
|
-
if (
|
|
1644
|
+
if (hasConstants && constantsVal->IsMap()) {
|
|
1645
1645
|
auto constants = constantsVal.As<v8::Map>();
|
|
1646
1646
|
auto keyValues = constants->AsArray();
|
|
1647
1647
|
auto length = keyValues->Length();
|
|
@@ -1675,11 +1675,11 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1675
1675
|
|
|
1676
1676
|
|
|
1677
1677
|
v8::Local<v8::Value> entryPoint;
|
|
1678
|
-
fragmentValueObj->Get(context, ConvertToV8String(isolate, "entryPoint")).ToLocal(
|
|
1678
|
+
auto hasEntryPoint = fragmentValueObj->Get(context, ConvertToV8String(isolate, "entryPoint")).ToLocal(
|
|
1679
1679
|
&entryPoint);
|
|
1680
1680
|
|
|
1681
1681
|
|
|
1682
|
-
if (
|
|
1682
|
+
if (hasEntryPoint && entryPoint->IsString()) {
|
|
1683
1683
|
auto ep = v8::String::Utf8Value(isolate, entryPoint);
|
|
1684
1684
|
char *entry_point = (char *) malloc(ep.length());
|
|
1685
1685
|
std::strcpy(entry_point, *ep);
|
|
@@ -1707,7 +1707,6 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1707
1707
|
|
|
1708
1708
|
auto label = GPULabel(isolate, labelVal);
|
|
1709
1709
|
|
|
1710
|
-
|
|
1711
1710
|
descriptor.label = *label;
|
|
1712
1711
|
|
|
1713
1712
|
|
|
@@ -1738,13 +1737,13 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1738
1737
|
|
|
1739
1738
|
|
|
1740
1739
|
v8::Local<v8::Value> multisampleValue;
|
|
1741
|
-
options->Get(context, ConvertToV8String(isolate, "multisample")).ToLocal(
|
|
1740
|
+
auto hasMultisample = options->Get(context, ConvertToV8String(isolate, "multisample")).ToLocal(
|
|
1742
1741
|
&multisampleValue);
|
|
1743
1742
|
|
|
1744
1743
|
|
|
1745
1744
|
CanvasMultisampleState *multisample = nullptr;
|
|
1746
1745
|
|
|
1747
|
-
if (
|
|
1746
|
+
if (hasMultisample && multisampleValue->IsObject()) {
|
|
1748
1747
|
auto multisampleObj = multisampleValue.As<v8::Object>();
|
|
1749
1748
|
multisample = new CanvasMultisampleState{};
|
|
1750
1749
|
multisample->alpha_to_coverage_enabled = false;
|
|
@@ -1755,25 +1754,25 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1755
1754
|
v8::Local<v8::Value> count;
|
|
1756
1755
|
v8::Local<v8::Value> mask;
|
|
1757
1756
|
|
|
1758
|
-
multisampleObj->Get(context, ConvertToV8String(isolate, "alphaToCoverageEnabled")).
|
|
1757
|
+
auto hasAlphaToCoverageEnabled = multisampleObj->Get(context, ConvertToV8String(isolate, "alphaToCoverageEnabled")).
|
|
1759
1758
|
ToLocal(&alphaToCoverageEnabled);
|
|
1760
1759
|
|
|
1761
|
-
if (
|
|
1760
|
+
if (hasAlphaToCoverageEnabled && alphaToCoverageEnabled->IsBoolean()) {
|
|
1762
1761
|
multisample->alpha_to_coverage_enabled = alphaToCoverageEnabled->BooleanValue(
|
|
1763
1762
|
isolate);
|
|
1764
1763
|
}
|
|
1765
1764
|
|
|
1766
|
-
multisampleObj->Get(context, ConvertToV8String(isolate, "count")).
|
|
1765
|
+
auto hasCount = multisampleObj->Get(context, ConvertToV8String(isolate, "count")).
|
|
1767
1766
|
ToLocal(&count);
|
|
1768
1767
|
|
|
1769
|
-
if (
|
|
1768
|
+
if (hasCount && count->IsUint32()) {
|
|
1770
1769
|
multisample->count = count.As<v8::Uint32>()->Value();
|
|
1771
1770
|
}
|
|
1772
1771
|
|
|
1773
|
-
multisampleObj->Get(context, ConvertToV8String(isolate, "mask")).
|
|
1772
|
+
auto hasMask = multisampleObj->Get(context, ConvertToV8String(isolate, "mask")).
|
|
1774
1773
|
ToLocal(&mask);
|
|
1775
1774
|
|
|
1776
|
-
if (
|
|
1775
|
+
if (hasMask && mask->IsNumber()) {
|
|
1777
1776
|
// todo verify mask
|
|
1778
1777
|
auto maskValue = mask.As<v8::Number>()->Value();
|
|
1779
1778
|
multisample->mask = (uint64_t) maskValue;
|
|
@@ -1786,13 +1785,13 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1786
1785
|
|
|
1787
1786
|
|
|
1788
1787
|
v8::Local<v8::Value> primitiveValue;
|
|
1789
|
-
options->Get(context, ConvertToV8String(isolate, "primitive")).ToLocal(
|
|
1788
|
+
auto hasPrimitive = options->Get(context, ConvertToV8String(isolate, "primitive")).ToLocal(
|
|
1790
1789
|
&primitiveValue);
|
|
1791
1790
|
|
|
1792
1791
|
|
|
1793
1792
|
CanvasPrimitiveState *primitive = nullptr;
|
|
1794
1793
|
|
|
1795
|
-
if (
|
|
1794
|
+
if (hasPrimitive && primitiveValue->IsObject()) {
|
|
1796
1795
|
auto primitiveObj = primitiveValue.As<v8::Object>();
|
|
1797
1796
|
primitive = new CanvasPrimitiveState{};
|
|
1798
1797
|
|
|
@@ -1968,7 +1967,7 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1968
1967
|
|
|
1969
1968
|
|
|
1970
1969
|
v8::Local<v8::Value> vertexValue;
|
|
1971
|
-
|
|
1970
|
+
auto hasVertex = options->Get(context, ConvertToV8String(isolate, "vertex")).ToLocal(
|
|
1972
1971
|
&vertexValue);
|
|
1973
1972
|
|
|
1974
1973
|
|
|
@@ -1978,7 +1977,7 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1978
1977
|
|
|
1979
1978
|
std::vector<std::vector<CanvasVertexAttribute>> attributes;
|
|
1980
1979
|
|
|
1981
|
-
if (
|
|
1980
|
+
if (hasVertex && vertexValue->IsObject()) {
|
|
1982
1981
|
auto vertexObj = vertexValue.As<v8::Object>();
|
|
1983
1982
|
vertex = new CanvasVertexState{};
|
|
1984
1983
|
|
|
@@ -1990,9 +1989,9 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
1990
1989
|
vertex->module = module->GetShaderModule();
|
|
1991
1990
|
|
|
1992
1991
|
v8::Local<v8::Value> constantsVal;
|
|
1993
|
-
vertexObj->Get(context, ConvertToV8String(isolate, "constants")).ToLocal(&constantsVal);
|
|
1992
|
+
auto hasConstants = vertexObj->Get(context, ConvertToV8String(isolate, "constants")).ToLocal(&constantsVal);
|
|
1994
1993
|
|
|
1995
|
-
if (
|
|
1994
|
+
if (hasConstants && constantsVal->IsMap()) {
|
|
1996
1995
|
auto constants = constantsVal.As<v8::Map>();
|
|
1997
1996
|
auto keyValues = constants->AsArray();
|
|
1998
1997
|
auto len = keyValues->Length();
|
|
@@ -2027,10 +2026,10 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
2027
2026
|
}
|
|
2028
2027
|
|
|
2029
2028
|
v8::Local<v8::Value> buffersVal;
|
|
2030
|
-
vertexObj->Get(context, ConvertToV8String(isolate, "buffers")).ToLocal(&buffersVal);
|
|
2029
|
+
auto hasBuffers = vertexObj->Get(context, ConvertToV8String(isolate, "buffers")).ToLocal(&buffersVal);
|
|
2031
2030
|
|
|
2032
2031
|
uint64_t stride = 0;
|
|
2033
|
-
if (
|
|
2032
|
+
if (hasBuffers && buffersVal->IsArray()) {
|
|
2034
2033
|
auto buffers = buffersVal.As<v8::Array>();
|
|
2035
2034
|
auto len = buffers->Length();
|
|
2036
2035
|
|
|
@@ -2039,10 +2038,10 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
2039
2038
|
|
|
2040
2039
|
v8::Local<v8::Value> arrayStride;
|
|
2041
2040
|
|
|
2042
|
-
buffer->Get(context, ConvertToV8String(isolate, "arrayStride")).ToLocal(
|
|
2041
|
+
auto hasArrayStride = buffer->Get(context, ConvertToV8String(isolate, "arrayStride")).ToLocal(
|
|
2043
2042
|
&arrayStride);
|
|
2044
2043
|
|
|
2045
|
-
if (
|
|
2044
|
+
if (hasArrayStride && arrayStride->IsNumber()) {
|
|
2046
2045
|
stride = (uint64_t) arrayStride.As<v8::Number>()->Value();
|
|
2047
2046
|
}
|
|
2048
2047
|
|
|
@@ -2050,10 +2049,10 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
2050
2049
|
|
|
2051
2050
|
v8::Local<v8::Value> attributesValue;
|
|
2052
2051
|
|
|
2053
|
-
buffer->Get(context, ConvertToV8String(isolate, "attributes")).ToLocal(
|
|
2052
|
+
auto hasAttributes = buffer->Get(context, ConvertToV8String(isolate, "attributes")).ToLocal(
|
|
2054
2053
|
&attributesValue);
|
|
2055
2054
|
|
|
2056
|
-
if (
|
|
2055
|
+
if (hasAttributes && attributesValue->IsArray()) {
|
|
2057
2056
|
auto attributes_array = attributesValue.As<v8::Array>();
|
|
2058
2057
|
auto attributes_len = attributes_array->Length();
|
|
2059
2058
|
|
|
@@ -2144,6 +2143,7 @@ void GPUDeviceImpl::CreateRenderPipeline(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
2144
2143
|
}
|
|
2145
2144
|
|
|
2146
2145
|
|
|
2146
|
+
|
|
2147
2147
|
auto pipeline = canvas_native_webgpu_device_create_render_pipeline(ptr->GetGPUDevice(),
|
|
2148
2148
|
&descriptor);
|
|
2149
2149
|
|
package/utils.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export declare class Utils {
|
|
|
4
4
|
static _CHECKED_FOR_SUPPORT: boolean;
|
|
5
5
|
static toJSArray(array: any): any[];
|
|
6
6
|
static get IS_SUPPORTED_TYPED_ARRAYS_VERSION(): boolean;
|
|
7
|
-
static isTypedArray(value: any): value is Uint32Array | Uint8Array | Uint8ClampedArray |
|
|
7
|
+
static isTypedArray(value: any): value is Uint32Array | Uint8Array | Uint8ClampedArray | Int8Array | Uint16Array | Int16Array | Int32Array | Float32Array;
|
|
8
8
|
}
|
|
9
9
|
export default function lazy<T>(action: () => T): () => T;
|