@nativescript/canvas 2.0.0-rc.11 → 2.0.0-rc.12
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.js +6 -0
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.ios.js +7 -1
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas2D/Path2D/index.js.map +1 -1
- package/Fonts/FontFace.android.js +7 -3
- package/Fonts/FontFace.android.js.map +1 -1
- package/Fonts/FontFace.ios.d.ts +1 -0
- package/Fonts/FontFace.ios.js +10 -3
- package/Fonts/FontFace.ios.js.map +1 -1
- package/WebGPU/GPUCompilationInfo.d.ts +10 -0
- package/WebGPU/GPUCompilationInfo.js +20 -0
- package/WebGPU/GPUCompilationInfo.js.map +1 -0
- package/WebGPU/GPUCompilationMessage.d.ts +11 -0
- package/WebGPU/GPUCompilationMessage.js +30 -0
- package/WebGPU/GPUCompilationMessage.js.map +1 -0
- package/WebGPU/GPUQueue.js.map +1 -1
- package/WebGPU/GPUShaderModule.d.ts +2 -0
- package/WebGPU/GPUShaderModule.js +10 -0
- package/WebGPU/GPUShaderModule.js.map +1 -1
- package/WebGPU/index.d.ts +2 -0
- package/WebGPU/index.js +2 -0
- package/WebGPU/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/canvas_native.h +35 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +11317 -12361
- 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 +954 -954
- 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/canvas_native.h +35 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +11317 -12361
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +11317 -12361
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +2 -2
- 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 +955 -955
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +824 -824
- package/platforms/ios/src/cpp/Caches.h +6 -0
- package/platforms/ios/src/cpp/NativeType.h +3 -1
- package/platforms/ios/src/cpp/webgpu/GPUCompilationInfoImpl.cpp +88 -0
- package/platforms/ios/src/cpp/webgpu/GPUCompilationInfoImpl.h +49 -0
- package/platforms/ios/src/cpp/webgpu/GPUCompilationMessageImpl.cpp +193 -0
- package/platforms/ios/src/cpp/webgpu/GPUCompilationMessageImpl.h +64 -0
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +23 -0
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +2 -0
|
@@ -249,6 +249,12 @@ public:
|
|
|
249
249
|
std::unique_ptr<v8::Persistent<v8::FunctionTemplate>> GPURenderBundleTmpl = std::unique_ptr<v8::Persistent<v8::FunctionTemplate>>(
|
|
250
250
|
nullptr);
|
|
251
251
|
|
|
252
|
+
std::unique_ptr<v8::Persistent<v8::FunctionTemplate>> GPUCompilationInfoTmpl = std::unique_ptr<v8::Persistent<v8::FunctionTemplate>>(
|
|
253
|
+
nullptr);
|
|
254
|
+
|
|
255
|
+
std::unique_ptr<v8::Persistent<v8::FunctionTemplate>> GPUCompilationMessageTmpl = std::unique_ptr<v8::Persistent<v8::FunctionTemplate>>(
|
|
256
|
+
nullptr);
|
|
257
|
+
|
|
252
258
|
private:
|
|
253
259
|
static std::shared_ptr<ConcurrentMap<v8::Isolate *,
|
|
254
260
|
std::shared_ptr<Caches>>>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 14/06/2025.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#include "GPUCompilationInfoImpl.h"
|
|
6
|
+
#include "Caches.h"
|
|
7
|
+
#include "GPUCompilationMessageImpl.h"
|
|
8
|
+
|
|
9
|
+
GPUCompilationInfoImpl::GPUCompilationInfoImpl(CanvasGPUCompilationInfo *info) : info_(
|
|
10
|
+
info) {}
|
|
11
|
+
|
|
12
|
+
CanvasGPUCompilationInfo *GPUCompilationInfoImpl::GetCompilationInfo() {
|
|
13
|
+
return this->info_;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
void GPUCompilationInfoImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
18
|
+
v8::Locker locker(isolate);
|
|
19
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
20
|
+
v8::HandleScope handle_scope(isolate);
|
|
21
|
+
|
|
22
|
+
auto ctor = GetCtor(isolate);
|
|
23
|
+
auto context = isolate->GetCurrentContext();
|
|
24
|
+
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
25
|
+
|
|
26
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUCompilationInfo"), func).FromJust();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
GPUCompilationInfoImpl *GPUCompilationInfoImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
30
|
+
auto ptr = object->GetAlignedPointerFromInternalField(0);
|
|
31
|
+
if (ptr == nullptr) {
|
|
32
|
+
return nullptr;
|
|
33
|
+
}
|
|
34
|
+
return static_cast<GPUCompilationInfoImpl *>(ptr);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
v8::Local<v8::FunctionTemplate> GPUCompilationInfoImpl::GetCtor(v8::Isolate *isolate) {
|
|
38
|
+
auto cache = Caches::Get(isolate);
|
|
39
|
+
auto ctor = cache->GPUCompilationInfoTmpl.get();
|
|
40
|
+
if (ctor != nullptr) {
|
|
41
|
+
return ctor->Get(isolate);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
45
|
+
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
|
|
46
|
+
ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUCompilationInfo"));
|
|
47
|
+
|
|
48
|
+
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
49
|
+
tmpl->SetInternalFieldCount(2);
|
|
50
|
+
|
|
51
|
+
tmpl->SetLazyDataProperty(
|
|
52
|
+
ConvertToV8String(isolate, "messages"),
|
|
53
|
+
GetMessages
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
cache->GPUCompilationInfoTmpl =
|
|
58
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
59
|
+
return ctorTmpl;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
void
|
|
64
|
+
GPUCompilationInfoImpl::GetMessages(v8::Local<v8::Name> name,
|
|
65
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
66
|
+
auto isolate = info.GetIsolate();
|
|
67
|
+
auto context = isolate->GetCurrentContext();
|
|
68
|
+
auto ptr = GetPointer(info.This());
|
|
69
|
+
if (ptr != nullptr) {
|
|
70
|
+
auto count = canvas_native_webgpu_compilation_info_get_messages_count(
|
|
71
|
+
ptr->GetCompilationInfo());
|
|
72
|
+
auto array = v8::Array::New(isolate, (int) count);
|
|
73
|
+
for (int i = 0; i < count; i++) {
|
|
74
|
+
auto msg = canvas_native_webgpu_compilation_info_get_message_at(
|
|
75
|
+
ptr->GetCompilationInfo(), i);
|
|
76
|
+
if (msg != nullptr) {
|
|
77
|
+
auto ret = new GPUCompilationMessageImpl(msg);
|
|
78
|
+
array->Set(context, i, GPUCompilationMessageImpl::NewInstance(isolate, ret));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
info.GetReturnValue().Set(array);
|
|
83
|
+
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
info.GetReturnValue().Set(v8::Array::New(isolate));
|
|
88
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 14/06/2025.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#ifndef CANVAS_ANDROID_GPUCOMPILATIONINFOIMPL_H
|
|
6
|
+
#define CANVAS_ANDROID_GPUCOMPILATIONINFOIMPL_H
|
|
7
|
+
|
|
8
|
+
#include "Common.h"
|
|
9
|
+
#include "Helpers.h"
|
|
10
|
+
#include "ObjectWrapperImpl.h"
|
|
11
|
+
|
|
12
|
+
class GPUCompilationInfoImpl : ObjectWrapperImpl {
|
|
13
|
+
public:
|
|
14
|
+
explicit GPUCompilationInfoImpl(CanvasGPUCompilationInfo *info);
|
|
15
|
+
|
|
16
|
+
~GPUCompilationInfoImpl() {
|
|
17
|
+
canvas_native_webgpu_compilation_info_release(this->GetCompilationInfo());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
CanvasGPUCompilationInfo* GetCompilationInfo();
|
|
21
|
+
|
|
22
|
+
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
23
|
+
|
|
24
|
+
static GPUCompilationInfoImpl *GetPointer(const v8::Local<v8::Object> &object);
|
|
25
|
+
|
|
26
|
+
static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
|
|
27
|
+
|
|
28
|
+
static v8::Local<v8::Object>
|
|
29
|
+
NewInstance(v8::Isolate *isolate, GPUCompilationInfoImpl *info) {
|
|
30
|
+
auto context = isolate->GetCurrentContext();
|
|
31
|
+
v8::EscapableHandleScope scope(isolate);
|
|
32
|
+
auto object = GPUCompilationInfoImpl::GetCtor(isolate)->GetFunction(
|
|
33
|
+
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
34
|
+
SetNativeType(info, NativeType::GPUCompilationInfo);
|
|
35
|
+
object->SetAlignedPointerInInternalField(0, info);
|
|
36
|
+
info->BindFinalizer(isolate, object);
|
|
37
|
+
return scope.Escape(object);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static void GetMessages(v8::Local<v8::Name> name,
|
|
41
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
private:
|
|
45
|
+
CanvasGPUCompilationInfo *info_;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
#endif //CANVAS_ANDROID_GPUCOMPILATIONINFOIMPL_H
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 14/06/2025.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#include "GPUCompilationMessageImpl.h"
|
|
6
|
+
#include "Caches.h"
|
|
7
|
+
|
|
8
|
+
GPUCompilationMessageImpl::GPUCompilationMessageImpl(CanvasGPUCompilationMessage *message)
|
|
9
|
+
: message_(
|
|
10
|
+
message) {}
|
|
11
|
+
|
|
12
|
+
CanvasGPUCompilationMessage *GPUCompilationMessageImpl::GetMessage() {
|
|
13
|
+
return this->message_;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
void GPUCompilationMessageImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
18
|
+
v8::Locker locker(isolate);
|
|
19
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
20
|
+
v8::HandleScope handle_scope(isolate);
|
|
21
|
+
|
|
22
|
+
auto ctor = GetCtor(isolate);
|
|
23
|
+
auto context = isolate->GetCurrentContext();
|
|
24
|
+
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
25
|
+
|
|
26
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUCompilationMessage"),
|
|
27
|
+
func).FromJust();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
GPUCompilationMessageImpl *
|
|
31
|
+
GPUCompilationMessageImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
32
|
+
auto ptr = object->GetAlignedPointerFromInternalField(0);
|
|
33
|
+
if (ptr == nullptr) {
|
|
34
|
+
return nullptr;
|
|
35
|
+
}
|
|
36
|
+
return static_cast<GPUCompilationMessageImpl *>(ptr);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
v8::Local<v8::FunctionTemplate> GPUCompilationMessageImpl::GetCtor(v8::Isolate *isolate) {
|
|
40
|
+
auto cache = Caches::Get(isolate);
|
|
41
|
+
auto ctor = cache->GPUCompilationMessageTmpl.get();
|
|
42
|
+
if (ctor != nullptr) {
|
|
43
|
+
return ctor->Get(isolate);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
47
|
+
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
|
|
48
|
+
ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUCompilationMessage"));
|
|
49
|
+
|
|
50
|
+
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
51
|
+
tmpl->SetInternalFieldCount(2);
|
|
52
|
+
|
|
53
|
+
tmpl->SetLazyDataProperty(
|
|
54
|
+
ConvertToV8String(isolate, "length"),
|
|
55
|
+
GetLength
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
tmpl->SetLazyDataProperty(
|
|
59
|
+
ConvertToV8String(isolate, "lineNum"),
|
|
60
|
+
GetLineNum
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
tmpl->SetLazyDataProperty(
|
|
64
|
+
ConvertToV8String(isolate, "linePos"),
|
|
65
|
+
GetLinePos
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
tmpl->SetLazyDataProperty(
|
|
69
|
+
ConvertToV8String(isolate, "message"),
|
|
70
|
+
GetMessage
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
tmpl->SetLazyDataProperty(
|
|
74
|
+
ConvertToV8String(isolate, "offset"),
|
|
75
|
+
GetOffset
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
tmpl->SetLazyDataProperty(
|
|
79
|
+
ConvertToV8String(isolate, "type"),
|
|
80
|
+
GetType
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
cache->GPUCompilationMessageTmpl =
|
|
84
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
85
|
+
return ctorTmpl;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
void
|
|
89
|
+
GPUCompilationMessageImpl::GetLength(v8::Local<v8::Name> name,
|
|
90
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
91
|
+
auto ptr = GetPointer(info.This());
|
|
92
|
+
if (ptr != nullptr) {
|
|
93
|
+
auto len = canvas_native_webgpu_compilation_message_get_length(ptr->GetMessage());
|
|
94
|
+
|
|
95
|
+
info.GetReturnValue().Set((double) len);
|
|
96
|
+
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
info.GetReturnValue().Set(0);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
void
|
|
105
|
+
GPUCompilationMessageImpl::GetLineNum(v8::Local<v8::Name> name,
|
|
106
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
107
|
+
auto ptr = GetPointer(info.This());
|
|
108
|
+
if (ptr != nullptr) {
|
|
109
|
+
auto num = canvas_native_webgpu_compilation_message_get_line_num(ptr->GetMessage());
|
|
110
|
+
|
|
111
|
+
info.GetReturnValue().Set((double) num);
|
|
112
|
+
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
info.GetReturnValue().Set(0);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
void
|
|
121
|
+
GPUCompilationMessageImpl::GetLinePos(v8::Local<v8::Name> name,
|
|
122
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
123
|
+
auto ptr = GetPointer(info.This());
|
|
124
|
+
if (ptr != nullptr) {
|
|
125
|
+
auto pos = canvas_native_webgpu_compilation_message_get_line_pos(ptr->GetMessage());
|
|
126
|
+
|
|
127
|
+
info.GetReturnValue().Set((double) pos);
|
|
128
|
+
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
info.GetReturnValue().Set(0);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
void
|
|
136
|
+
GPUCompilationMessageImpl::GetMessage(v8::Local<v8::Name> name,
|
|
137
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
138
|
+
auto ptr = GetPointer(info.This());
|
|
139
|
+
if (ptr != nullptr) {
|
|
140
|
+
auto isolate = info.GetIsolate();
|
|
141
|
+
auto len = canvas_native_webgpu_compilation_message_get_message(ptr->GetMessage());
|
|
142
|
+
|
|
143
|
+
info.GetReturnValue().Set(ConvertToV8String(isolate, len));
|
|
144
|
+
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
info.GetReturnValue().SetEmptyString();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
void
|
|
153
|
+
GPUCompilationMessageImpl::GetOffset(v8::Local<v8::Name> name,
|
|
154
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
155
|
+
auto ptr = GetPointer(info.This());
|
|
156
|
+
if (ptr != nullptr) {
|
|
157
|
+
auto offset = canvas_native_webgpu_compilation_message_get_offset(ptr->GetMessage());
|
|
158
|
+
|
|
159
|
+
info.GetReturnValue().Set((double) offset);
|
|
160
|
+
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
info.GetReturnValue().Set(0);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
void
|
|
169
|
+
GPUCompilationMessageImpl::GetType(v8::Local<v8::Name> name,
|
|
170
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
171
|
+
auto ptr = GetPointer(info.This());
|
|
172
|
+
auto isolate = info.GetIsolate();
|
|
173
|
+
if (ptr != nullptr) {
|
|
174
|
+
auto message_type = canvas_native_webgpu_compilation_message_get_type(ptr->GetMessage());
|
|
175
|
+
|
|
176
|
+
switch (message_type) {
|
|
177
|
+
case CanvasGPUCompilationMessageType::CanvasGPUCompilationMessageTypeInfo:
|
|
178
|
+
info.GetReturnValue().Set(ConvertToV8String(isolate, "info"));
|
|
179
|
+
break;
|
|
180
|
+
case CanvasGPUCompilationMessageType::CanvasGPUCompilationMessageTypeWarning:
|
|
181
|
+
info.GetReturnValue().Set(ConvertToV8String(isolate, "warning"));
|
|
182
|
+
break;
|
|
183
|
+
case CanvasGPUCompilationMessageType::CanvasGPUCompilationMessageTypeError:
|
|
184
|
+
info.GetReturnValue().Set(ConvertToV8String(isolate, "error"));
|
|
185
|
+
break;
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
info.GetReturnValue().Set(ConvertToV8String(isolate, "error"));
|
|
193
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 14/06/2025.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#ifndef CANVAS_ANDROID_GPUCOMPILATIONMESSAGEIMPL_H
|
|
6
|
+
#define CANVAS_ANDROID_GPUCOMPILATIONMESSAGEIMPL_H
|
|
7
|
+
|
|
8
|
+
#include "Common.h"
|
|
9
|
+
#include "Helpers.h"
|
|
10
|
+
#include "ObjectWrapperImpl.h"
|
|
11
|
+
|
|
12
|
+
class GPUCompilationMessageImpl : ObjectWrapperImpl {
|
|
13
|
+
public:
|
|
14
|
+
explicit GPUCompilationMessageImpl(CanvasGPUCompilationMessage *message);
|
|
15
|
+
|
|
16
|
+
~GPUCompilationMessageImpl() {
|
|
17
|
+
canvas_native_webgpu_compilation_message_release(this->GetMessage());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
CanvasGPUCompilationMessage *GetMessage();
|
|
21
|
+
|
|
22
|
+
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
23
|
+
|
|
24
|
+
static GPUCompilationMessageImpl *GetPointer(const v8::Local<v8::Object> &object);
|
|
25
|
+
|
|
26
|
+
static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
|
|
27
|
+
|
|
28
|
+
static v8::Local<v8::Object>
|
|
29
|
+
NewInstance(v8::Isolate *isolate, GPUCompilationMessageImpl *message) {
|
|
30
|
+
auto context = isolate->GetCurrentContext();
|
|
31
|
+
v8::EscapableHandleScope scope(isolate);
|
|
32
|
+
auto object = GPUCompilationMessageImpl::GetCtor(isolate)->GetFunction(
|
|
33
|
+
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
34
|
+
SetNativeType(message, NativeType::GPUCompilationMessage);
|
|
35
|
+
object->SetAlignedPointerInInternalField(0, message);
|
|
36
|
+
message->BindFinalizer(isolate, object);
|
|
37
|
+
return scope.Escape(object);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static void GetLength(v8::Local<v8::Name> name,
|
|
41
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
42
|
+
|
|
43
|
+
static void GetLineNum(v8::Local<v8::Name> name,
|
|
44
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
45
|
+
|
|
46
|
+
static void GetLinePos(v8::Local<v8::Name> name,
|
|
47
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
48
|
+
|
|
49
|
+
static void GetMessage(v8::Local<v8::Name> name,
|
|
50
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
51
|
+
|
|
52
|
+
static void GetOffset(v8::Local<v8::Name> name,
|
|
53
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
54
|
+
|
|
55
|
+
static void GetType(v8::Local<v8::Name> name,
|
|
56
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
private:
|
|
60
|
+
CanvasGPUCompilationMessage *message_;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
#endif //CANVAS_ANDROID_GPUCOMPILATIONMESSAGEIMPL_H
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
#include "GPUShaderModuleImpl.h"
|
|
6
6
|
#include "Caches.h"
|
|
7
|
+
#include "GPUCompilationInfoImpl.h"
|
|
7
8
|
|
|
8
9
|
GPUShaderModuleImpl::GPUShaderModuleImpl(const CanvasGPUShaderModule *shaderModule) : shaderModule_(
|
|
9
10
|
shaderModule) {}
|
|
@@ -52,6 +53,10 @@ v8::Local<v8::FunctionTemplate> GPUShaderModuleImpl::GetCtor(v8::Isolate *isolat
|
|
|
52
53
|
GetLabel
|
|
53
54
|
);
|
|
54
55
|
|
|
56
|
+
tmpl->Set(
|
|
57
|
+
ConvertToV8String(isolate, "getCompilationInfo"),
|
|
58
|
+
v8::FunctionTemplate::New(isolate, &GetCompilationInfo));
|
|
59
|
+
|
|
55
60
|
cache->GPUShaderModuleTmpl =
|
|
56
61
|
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
57
62
|
return ctorTmpl;
|
|
@@ -77,4 +82,22 @@ GPUShaderModuleImpl::GetLabel(v8::Local<v8::Name> name,
|
|
|
77
82
|
info.GetReturnValue().SetEmptyString();
|
|
78
83
|
}
|
|
79
84
|
|
|
85
|
+
void
|
|
86
|
+
GPUShaderModuleImpl::GetCompilationInfo(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
87
|
+
auto isolate = args.GetIsolate();
|
|
88
|
+
auto context = isolate->GetCurrentContext();
|
|
89
|
+
GPUShaderModuleImpl *ptr = GetPointer(args.This());
|
|
90
|
+
auto resolver = v8::Promise::Resolver::New(isolate->GetCurrentContext()).ToLocalChecked();
|
|
91
|
+
args.GetReturnValue().Set(resolver->GetPromise());
|
|
92
|
+
if (ptr == nullptr) {
|
|
93
|
+
resolver->Reject(context, v8::Null(isolate));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
auto info = new GPUCompilationInfoImpl(
|
|
98
|
+
canvas_native_webgpu_device_create_shader_module_get_compilation_info(
|
|
99
|
+
ptr->GetShaderModule()));
|
|
100
|
+
|
|
101
|
+
resolver->Resolve(context, GPUCompilationInfoImpl::NewInstance(isolate, info));
|
|
102
|
+
}
|
|
80
103
|
|
|
@@ -40,6 +40,8 @@ public:
|
|
|
40
40
|
static void GetLabel(v8::Local<v8::Name> name,
|
|
41
41
|
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
42
42
|
|
|
43
|
+
static void GetCompilationInfo(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
44
|
+
|
|
43
45
|
private:
|
|
44
46
|
const CanvasGPUShaderModule *shaderModule_;
|
|
45
47
|
};
|