@nativescript/canvas 2.0.0-webgpu.2 → 2.0.0-webgpu.3
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/angular/package.json +20 -0
- package/package.json +1 -3
- package/platforms/android/canvas-release.aar +0 -0
- package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
- 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 +6577 -5995
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/NSCCanvas.nib +0 -0
- 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 +132 -132
- 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/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 +6577 -5995
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +6577 -5995
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/NSCCanvas.nib +0 -0
- 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 +646 -646
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +684 -684
- package/platforms/ios/src/NSOperationQueueWrapper.h +2 -0
- package/platforms/ios/src/cpp/AsyncCallback.h +206 -0
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +1 -1
- package/platforms/ios/src/cpp/Helpers.h +2 -164
- package/platforms/ios/src/cpp/ImageAssetImpl.cpp +2 -2
- package/platforms/ios/src/cpp/ImageBitmapImpl.h +2 -1
- package/platforms/ios/src/cpp/NativeType.h +87 -0
- package/platforms/ios/src/cpp/ObjectWrapperImpl.h +50 -0
- package/platforms/ios/src/cpp/PromiseCallback.h +198 -0
- package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +7 -6
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +1 -1
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +1 -1
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +5 -5
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +15 -10
- package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +2 -2
- package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +1 -1
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +10 -10
- package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +6 -3
- package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +1 -1
- package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +1 -1
- package/platforms/ios/src/cpp/webgl/WebGLProgram.h +3 -3
- package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +3 -3
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +1 -1
- package/platforms/ios/src/cpp/webgl/WebGLShader.h +1 -1
- package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +5 -5
- package/platforms/ios/src/cpp/webgl/WebGLTexture.h +3 -2
- package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +2 -2
- package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +2 -2
- package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +5 -5
- package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +2 -2
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +1 -1
- package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +1 -1
- package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +1 -1
- package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +1 -1
- package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +1 -1
- package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +2 -2
- package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +123 -57
- package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +44 -30
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +4 -4
- package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +30 -31
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +93 -66
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +52 -39
- package/platforms/ios/src/cpp/webgpu/GPUImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +5 -4
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +38 -23
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +2 -2
- package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +2 -2
- package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +2 -2
- package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +4 -4
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +2 -2
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 05/08/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "Common.h"
|
|
8
|
+
|
|
9
|
+
#ifdef __ANDROID__
|
|
10
|
+
|
|
11
|
+
#include <android/looper.h>
|
|
12
|
+
#include <cassert>
|
|
13
|
+
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
#ifdef __APPLE__
|
|
17
|
+
#include "NSOperationQueueWrapper.h"
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
#include <unistd.h>
|
|
21
|
+
#include <fcntl.h>
|
|
22
|
+
|
|
23
|
+
typedef void(*CompleteCallback)(bool success, void *data);
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
#ifdef __APPLE__
|
|
27
|
+
struct AsyncCallback {
|
|
28
|
+
|
|
29
|
+
struct Inner {
|
|
30
|
+
NSOperationQueueWrapper* current_queue = nullptr;
|
|
31
|
+
v8::Isolate *isolate_;
|
|
32
|
+
v8::Persistent<v8::Function> callback_;
|
|
33
|
+
CompleteCallback completeCallback_;
|
|
34
|
+
CompleteCallback completeCallbackWrapper_;
|
|
35
|
+
bool isPrepared_ = false;
|
|
36
|
+
void* data = nullptr;
|
|
37
|
+
|
|
38
|
+
Inner(v8::Isolate *isolate, v8::Local<v8::Function> callback,
|
|
39
|
+
CompleteCallback completeCallback) : isolate_(isolate),
|
|
40
|
+
callback_(v8::Persistent<v8::Function>(
|
|
41
|
+
isolate,
|
|
42
|
+
callback)) {
|
|
43
|
+
this->completeCallback_ = completeCallback;
|
|
44
|
+
|
|
45
|
+
this->completeCallbackWrapper_ = [](bool success, void *data){
|
|
46
|
+
if(data != nullptr){
|
|
47
|
+
auto* callback = static_cast<AsyncCallback*>(data);
|
|
48
|
+
auto inner = callback->inner_.get();
|
|
49
|
+
if(inner == nullptr || inner->current_queue == nullptr){
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
inner->current_queue->addOperation([success, data, inner, callback](){
|
|
53
|
+
inner->completeCallback_(success, data);
|
|
54
|
+
// delete callback;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
void prepare(){
|
|
61
|
+
current_queue = new NSOperationQueueWrapper(true);
|
|
62
|
+
isPrepared_ = true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
void execute(bool complete, AsyncCallback* callback){
|
|
66
|
+
completeCallbackWrapper_(complete, callback);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
~Inner() {
|
|
70
|
+
callback_.Reset();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
std::shared_ptr<Inner> inner_;
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
void prepare(){
|
|
78
|
+
auto inner = this->inner_.get();
|
|
79
|
+
if(inner == nullptr){return;}
|
|
80
|
+
inner->prepare();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
void execute(bool complete) {
|
|
84
|
+
auto inner = this->inner_.get();
|
|
85
|
+
if (inner == nullptr) { return; }
|
|
86
|
+
inner->execute(complete, this);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
explicit AsyncCallback(std::shared_ptr<Inner> inner) : inner_(std::move(inner)) {}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
AsyncCallback(v8::Isolate *isolate, v8::Local<v8::Function> callback,
|
|
94
|
+
CompleteCallback completeCallback) : inner_(
|
|
95
|
+
std::make_shared<Inner>(isolate, callback, completeCallback)) {
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
};
|
|
100
|
+
#endif
|
|
101
|
+
|
|
102
|
+
#ifdef __ANDROID__
|
|
103
|
+
|
|
104
|
+
struct AsyncCallback {
|
|
105
|
+
|
|
106
|
+
struct Inner {
|
|
107
|
+
int fd_[2];
|
|
108
|
+
ALooper *looper_;
|
|
109
|
+
v8::Isolate *isolate_;
|
|
110
|
+
v8::Persistent<v8::Function> callback_;
|
|
111
|
+
CompleteCallback completeCallback_;
|
|
112
|
+
bool isPrepared_ = false;
|
|
113
|
+
void* data;
|
|
114
|
+
|
|
115
|
+
Inner(v8::Isolate *isolate, v8::Local<v8::Function> callback,
|
|
116
|
+
CompleteCallback completeCallback) : isolate_(isolate),
|
|
117
|
+
callback_(v8::Persistent<v8::Function>(
|
|
118
|
+
isolate,
|
|
119
|
+
callback)) {
|
|
120
|
+
this->completeCallback_ = completeCallback;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
void prepare() {
|
|
124
|
+
// release previous looper
|
|
125
|
+
if (isPrepared_) {
|
|
126
|
+
ALooper_removeFd(looper_, fd_[0]);
|
|
127
|
+
close(fd_[0]);
|
|
128
|
+
fd_[0] = -1;
|
|
129
|
+
fd_[1] = -1;
|
|
130
|
+
ALooper_release(looper_);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
auto res = pipe(fd_);
|
|
134
|
+
assert(res != -1);
|
|
135
|
+
res = fcntl(fd_[1], F_SETFL, O_NONBLOCK);
|
|
136
|
+
assert(res != -1);
|
|
137
|
+
looper_ = ALooper_prepare(0);
|
|
138
|
+
ALooper_acquire(looper_);
|
|
139
|
+
|
|
140
|
+
isPrepared_ = true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
void execute(bool complete) const {
|
|
144
|
+
if (!isPrepared_) { return; }
|
|
145
|
+
write(fd_[1],
|
|
146
|
+
&complete,
|
|
147
|
+
sizeof(bool));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
~Inner() {
|
|
151
|
+
if(!isPrepared_){
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
ALooper_removeFd(looper_, fd_[0]);
|
|
155
|
+
close(fd_[0]);
|
|
156
|
+
ALooper_release(looper_);
|
|
157
|
+
callback_.Reset();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
std::shared_ptr<Inner> inner_;
|
|
162
|
+
|
|
163
|
+
void prepare() const {
|
|
164
|
+
auto inner = this->inner_.get();
|
|
165
|
+
if (inner == nullptr) { return; }
|
|
166
|
+
inner->prepare();
|
|
167
|
+
auto looper = inner->looper_;
|
|
168
|
+
auto fd = inner->fd_[0];
|
|
169
|
+
|
|
170
|
+
auto data = new AsyncCallback(this->inner_);
|
|
171
|
+
ALooper_addFd(looper,
|
|
172
|
+
fd,
|
|
173
|
+
ALOOPER_POLL_CALLBACK,
|
|
174
|
+
ALOOPER_EVENT_INPUT,
|
|
175
|
+
[](int fd, int events,
|
|
176
|
+
void *data) {
|
|
177
|
+
auto cb = static_cast<AsyncCallback *>(data);
|
|
178
|
+
bool done = false;
|
|
179
|
+
read(fd, &done,
|
|
180
|
+
sizeof(bool));
|
|
181
|
+
cb->inner_->completeCallback_(done, data);
|
|
182
|
+
return 0;
|
|
183
|
+
}, (void *) data);
|
|
184
|
+
|
|
185
|
+
ALooper_wake(looper);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
void execute(bool complete) const {
|
|
189
|
+
auto inner = this->inner_.get();
|
|
190
|
+
if (inner == nullptr) { return; }
|
|
191
|
+
inner->execute(complete);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
explicit AsyncCallback(std::shared_ptr<Inner> inner) : inner_(std::move(inner)) {}
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
AsyncCallback(v8::Isolate *isolate, v8::Local<v8::Function> callback,
|
|
199
|
+
CompleteCallback completeCallback) : inner_(
|
|
200
|
+
std::make_shared<Inner>(isolate, callback, completeCallback)) {
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
#endif
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
#include "Common.h"
|
|
9
9
|
#include "OneByteStringResource.h"
|
|
10
10
|
#include "v8-fast-api-calls.h"
|
|
11
|
+
#include "AsyncCallback.h"
|
|
12
|
+
#include "PromiseCallback.h"
|
|
11
13
|
//#ifdef __APPLE__
|
|
12
14
|
//#ifdef __OBJC__
|
|
13
15
|
//#include <Foundation/Foundation.h>
|
|
@@ -17,19 +19,6 @@
|
|
|
17
19
|
//#endif
|
|
18
20
|
//#endif
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
struct AsyncCallback {
|
|
22
|
-
v8::Isolate *isolate;
|
|
23
|
-
v8::Global<v8::Function> callback;
|
|
24
|
-
void *data;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
struct PromiseCallback {
|
|
28
|
-
v8::Isolate *isolate;
|
|
29
|
-
v8::Global<v8::Promise::Resolver> callback;
|
|
30
|
-
void *data;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
22
|
static const char *LOG_TAG = "JS";
|
|
34
23
|
static int m_maxLogcatObjectSize = 4096;
|
|
35
24
|
|
|
@@ -81,89 +70,6 @@ static void LogToConsole(const std::string &message) {
|
|
|
81
70
|
#endif
|
|
82
71
|
}
|
|
83
72
|
|
|
84
|
-
enum class NativeMask {
|
|
85
|
-
Type = 1
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
enum class NativeType {
|
|
89
|
-
None,
|
|
90
|
-
CanvasGradient,
|
|
91
|
-
CanvasPattern,
|
|
92
|
-
ImageData,
|
|
93
|
-
ImageAsset,
|
|
94
|
-
CanvasRenderingContext2D,
|
|
95
|
-
WebGLRenderingContextBase,
|
|
96
|
-
Path2D,
|
|
97
|
-
Matrix,
|
|
98
|
-
ImageBitmap,
|
|
99
|
-
TextMetrics,
|
|
100
|
-
|
|
101
|
-
WebGLQuery,
|
|
102
|
-
WebGLProgram,
|
|
103
|
-
WebGLShader,
|
|
104
|
-
WebGLBuffer,
|
|
105
|
-
WebGLFramebuffer,
|
|
106
|
-
WebGLRenderbuffer,
|
|
107
|
-
WebGLTexture,
|
|
108
|
-
WebGLActiveInfo,
|
|
109
|
-
OES_fbo_render_mipmap,
|
|
110
|
-
EXT_blend_minmax,
|
|
111
|
-
EXT_color_buffer_half_float,
|
|
112
|
-
EXT_disjoint_timer_query,
|
|
113
|
-
EXT_sRGB,
|
|
114
|
-
EXT_shader_texture_lod,
|
|
115
|
-
EXT_texture_filter_anisotropic,
|
|
116
|
-
OES_element_index_uint,
|
|
117
|
-
OES_standard_derivatives,
|
|
118
|
-
OES_texture_float,
|
|
119
|
-
OES_texture_float_linear,
|
|
120
|
-
OES_texture_half_float_linear,
|
|
121
|
-
OES_texture_half_float,
|
|
122
|
-
WEBGL_color_buffer_float,
|
|
123
|
-
OES_vertex_array_object,
|
|
124
|
-
WebGLVertexArrayObject,
|
|
125
|
-
WEBGL_compressed_texture_atc,
|
|
126
|
-
WEBGL_compressed_texture_etc1,
|
|
127
|
-
WEBGL_compressed_texture_s3tc,
|
|
128
|
-
WEBGL_compressed_texture_s3tc_srgb,
|
|
129
|
-
WEBGL_compressed_texture_etc,
|
|
130
|
-
WEBGL_compressed_texture_pvrtc,
|
|
131
|
-
WEBGL_lose_context,
|
|
132
|
-
ANGLE_instanced_arrays,
|
|
133
|
-
WEBGL_depth_texture,
|
|
134
|
-
WEBGL_draw_buffers,
|
|
135
|
-
WebGLShaderPrecisionFormat,
|
|
136
|
-
WebGLUniformLocation,
|
|
137
|
-
WebGLSampler,
|
|
138
|
-
WebGLTransformFeedback,
|
|
139
|
-
WebGLSync,
|
|
140
|
-
|
|
141
|
-
GPUAdapter,
|
|
142
|
-
GPUSupportedLimits,
|
|
143
|
-
GPUDevice,
|
|
144
|
-
GPUQueue,
|
|
145
|
-
GPUBuffer,
|
|
146
|
-
GPUInstance,
|
|
147
|
-
GPUCanvasContext,
|
|
148
|
-
GPUTexture,
|
|
149
|
-
GPUAdapterInfo,
|
|
150
|
-
GPUCommandEncoder,
|
|
151
|
-
GPUComputePass,
|
|
152
|
-
GPUQuerySet,
|
|
153
|
-
GPUShaderModule,
|
|
154
|
-
GPUPipelineLayout,
|
|
155
|
-
GPURenderPipeline,
|
|
156
|
-
GPUBindGroupLayout,
|
|
157
|
-
GPUTextureView,
|
|
158
|
-
GPURenderPassEncoder,
|
|
159
|
-
GPUCommandBuffer,
|
|
160
|
-
GPUBindGroup,
|
|
161
|
-
GPUComputePipeline,
|
|
162
|
-
GPUSampler,
|
|
163
|
-
GPURenderBundleEncoder,
|
|
164
|
-
GPURenderBundle
|
|
165
|
-
};
|
|
166
|
-
|
|
167
73
|
inline static v8::Local<v8::String>
|
|
168
74
|
ConvertToV8OneByteString(v8::Isolate *isolate, std::string string) {
|
|
169
75
|
auto value = new OneByteStringResource(std::move(string));
|
|
@@ -207,74 +113,6 @@ ConvertFromV8String(v8::Isolate *isolate, const v8::Local<v8::Value> &value) {
|
|
|
207
113
|
}
|
|
208
114
|
|
|
209
115
|
|
|
210
|
-
static void SetPrivateValue(v8::Isolate *isolate, const v8::Local<v8::Object> &obj,
|
|
211
|
-
const v8::Local<v8::String> &propName,
|
|
212
|
-
const v8::Local<v8::Value> &value) {
|
|
213
|
-
v8::Local<v8::Context> context;
|
|
214
|
-
auto succcess = obj->GetCreationContext().ToLocal(&context);
|
|
215
|
-
v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, propName);
|
|
216
|
-
obj->SetPrivate(context, privateKey, value);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
static v8::Local<v8::Value>
|
|
220
|
-
GetPrivateValue(v8::Isolate *isolate, const v8::Local<v8::Object> &obj,
|
|
221
|
-
const v8::Local<v8::String> &propName) {
|
|
222
|
-
v8::Local<v8::Context> context;
|
|
223
|
-
auto succcess = obj->GetCreationContext().ToLocal(&context);
|
|
224
|
-
v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, propName);
|
|
225
|
-
|
|
226
|
-
v8::Maybe<bool> hasPrivate = obj->HasPrivate(context, privateKey);
|
|
227
|
-
|
|
228
|
-
if (!hasPrivate.FromMaybe(false)) {
|
|
229
|
-
return {};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
v8::Local<v8::Value> result;
|
|
233
|
-
|
|
234
|
-
succcess = obj->GetPrivate(context, privateKey).ToLocal(&result);
|
|
235
|
-
|
|
236
|
-
return result;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
static void SetNativeType(const v8::Local<v8::Object> &obj, NativeType type) {
|
|
240
|
-
auto value = (int32_t) type;
|
|
241
|
-
obj->SetAlignedPointerInInternalField(1, new int32_t(value));
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
inline static NativeType GetNativeType(const v8::Local<v8::Value> &obj) {
|
|
245
|
-
if (!obj.IsEmpty() && !obj->IsNullOrUndefined() && obj->IsObject() &&
|
|
246
|
-
obj.As<v8::Object>()->InternalFieldCount() > 1) {
|
|
247
|
-
auto info = obj.As<v8::Object>()->GetAlignedPointerFromInternalField(1);
|
|
248
|
-
|
|
249
|
-
if (info != nullptr) {
|
|
250
|
-
auto value = *static_cast<int32_t *>(info);
|
|
251
|
-
auto ret = value;
|
|
252
|
-
if (ret >= (int) NativeType::CanvasGradient &&
|
|
253
|
-
ret <= (int) NativeType::GPURenderBundle) {
|
|
254
|
-
return (NativeType) ret;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
return NativeType::None;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
//template<class T>
|
|
264
|
-
//static inline void Finalizer(const v8::WeakCallbackInfo<T> &data) {
|
|
265
|
-
// auto *pThis = data.GetParameter();
|
|
266
|
-
// pThis->weakHandle_.Reset();
|
|
267
|
-
// delete pThis;
|
|
268
|
-
//}
|
|
269
|
-
|
|
270
|
-
//static inline void BindFinalizer(v8::Isolate *isolate, v8::Global<v8::Object> &weakHandle, const v8::Local<v8::Object> &object) {
|
|
271
|
-
// v8::HandleScope scopedHandle(isolate);
|
|
272
|
-
// weakHandle.Reset(isolate, object);
|
|
273
|
-
// weakHandle.SetWeak(this, Finalizer, v8::WeakCallbackType::kParameter);
|
|
274
|
-
//}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
116
|
static void SetFastMethod(v8::Isolate *isolate,
|
|
279
117
|
v8::Local<v8::Template> that,
|
|
280
118
|
const char *name,
|
|
@@ -122,12 +122,12 @@ void ImageAssetImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
122
122
|
|
|
123
123
|
auto ret = args.This();
|
|
124
124
|
|
|
125
|
-
SetNativeType(ret, NativeType::ImageAsset);
|
|
126
|
-
|
|
127
125
|
auto image_asset = canvas_native_image_asset_create();
|
|
128
126
|
|
|
129
127
|
auto object = new ImageAssetImpl(image_asset);
|
|
130
128
|
|
|
129
|
+
SetNativeType(object, NativeType::ImageAsset);
|
|
130
|
+
|
|
131
131
|
ret->SetAlignedPointerInInternalField(0, object);
|
|
132
132
|
|
|
133
133
|
object->BindFinalizer(isolate, ret);
|
|
@@ -30,11 +30,12 @@ public:
|
|
|
30
30
|
v8::EscapableHandleScope scope(isolate);
|
|
31
31
|
auto object = ImageBitmapImpl::GetCtor(isolate)->GetFunction(
|
|
32
32
|
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
33
|
-
SetNativeType(object, NativeType::ImageBitmap);
|
|
34
33
|
|
|
35
34
|
auto ptr = asset->Value();
|
|
36
35
|
auto impl = static_cast<ObjectWrapperImpl *>(ptr);
|
|
37
36
|
|
|
37
|
+
SetNativeType(impl, NativeType::ImageBitmap);
|
|
38
|
+
|
|
38
39
|
|
|
39
40
|
object->SetAlignedPointerInInternalField(0, ptr);
|
|
40
41
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 06/08/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#ifndef CANVAS_ANDROID_NATIVETYPE_H
|
|
6
|
+
#define CANVAS_ANDROID_NATIVETYPE_H
|
|
7
|
+
|
|
8
|
+
enum class NativeType {
|
|
9
|
+
None,
|
|
10
|
+
CanvasGradient,
|
|
11
|
+
CanvasPattern,
|
|
12
|
+
ImageData,
|
|
13
|
+
ImageAsset,
|
|
14
|
+
CanvasRenderingContext2D,
|
|
15
|
+
WebGLRenderingContextBase,
|
|
16
|
+
Path2D,
|
|
17
|
+
Matrix,
|
|
18
|
+
ImageBitmap,
|
|
19
|
+
TextMetrics,
|
|
20
|
+
|
|
21
|
+
WebGLQuery,
|
|
22
|
+
WebGLProgram,
|
|
23
|
+
WebGLShader,
|
|
24
|
+
WebGLBuffer,
|
|
25
|
+
WebGLFramebuffer,
|
|
26
|
+
WebGLRenderbuffer,
|
|
27
|
+
WebGLTexture,
|
|
28
|
+
WebGLActiveInfo,
|
|
29
|
+
OES_fbo_render_mipmap,
|
|
30
|
+
EXT_blend_minmax,
|
|
31
|
+
EXT_color_buffer_half_float,
|
|
32
|
+
EXT_disjoint_timer_query,
|
|
33
|
+
EXT_sRGB,
|
|
34
|
+
EXT_shader_texture_lod,
|
|
35
|
+
EXT_texture_filter_anisotropic,
|
|
36
|
+
OES_element_index_uint,
|
|
37
|
+
OES_standard_derivatives,
|
|
38
|
+
OES_texture_float,
|
|
39
|
+
OES_texture_float_linear,
|
|
40
|
+
OES_texture_half_float_linear,
|
|
41
|
+
OES_texture_half_float,
|
|
42
|
+
WEBGL_color_buffer_float,
|
|
43
|
+
OES_vertex_array_object,
|
|
44
|
+
WebGLVertexArrayObject,
|
|
45
|
+
WEBGL_compressed_texture_atc,
|
|
46
|
+
WEBGL_compressed_texture_etc1,
|
|
47
|
+
WEBGL_compressed_texture_s3tc,
|
|
48
|
+
WEBGL_compressed_texture_s3tc_srgb,
|
|
49
|
+
WEBGL_compressed_texture_etc,
|
|
50
|
+
WEBGL_compressed_texture_pvrtc,
|
|
51
|
+
WEBGL_lose_context,
|
|
52
|
+
ANGLE_instanced_arrays,
|
|
53
|
+
WEBGL_depth_texture,
|
|
54
|
+
WEBGL_draw_buffers,
|
|
55
|
+
WebGLShaderPrecisionFormat,
|
|
56
|
+
WebGLUniformLocation,
|
|
57
|
+
WebGLSampler,
|
|
58
|
+
WebGLTransformFeedback,
|
|
59
|
+
WebGLSync,
|
|
60
|
+
|
|
61
|
+
GPUAdapter,
|
|
62
|
+
GPUSupportedLimits,
|
|
63
|
+
GPUDevice,
|
|
64
|
+
GPUQueue,
|
|
65
|
+
GPUBuffer,
|
|
66
|
+
GPUInstance,
|
|
67
|
+
GPUCanvasContext,
|
|
68
|
+
GPUTexture,
|
|
69
|
+
GPUAdapterInfo,
|
|
70
|
+
GPUCommandEncoder,
|
|
71
|
+
GPUComputePass,
|
|
72
|
+
GPUQuerySet,
|
|
73
|
+
GPUShaderModule,
|
|
74
|
+
GPUPipelineLayout,
|
|
75
|
+
GPURenderPipeline,
|
|
76
|
+
GPUBindGroupLayout,
|
|
77
|
+
GPUTextureView,
|
|
78
|
+
GPURenderPassEncoder,
|
|
79
|
+
GPUCommandBuffer,
|
|
80
|
+
GPUBindGroup,
|
|
81
|
+
GPUComputePipeline,
|
|
82
|
+
GPUSampler,
|
|
83
|
+
GPURenderBundleEncoder,
|
|
84
|
+
GPURenderBundle
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
#endif //CANVAS_ANDROID_NATIVETYPE_H
|
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
#define ObjectWrapperImpl_h
|
|
10
10
|
|
|
11
11
|
#include "Common.h"
|
|
12
|
+
#include "NativeType.h"
|
|
12
13
|
|
|
13
14
|
class ObjectWrapperImpl {
|
|
14
15
|
public:
|
|
16
|
+
NativeType type_ = NativeType::None;
|
|
15
17
|
|
|
16
18
|
static void Finalizer(const v8::WeakCallbackInfo<ObjectWrapperImpl> &data) {
|
|
17
19
|
auto *pThis = data.GetParameter();
|
|
@@ -25,6 +27,54 @@ public:
|
|
|
25
27
|
weakHandle_.SetWeak(this, Finalizer, v8::WeakCallbackType::kParameter);
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
static void SetNativeType(const v8::Local<v8::Object> &obj, NativeType type) {
|
|
33
|
+
if (!obj.IsEmpty() && !obj->IsNullOrUndefined() && obj->IsObject() &&
|
|
34
|
+
obj.As<v8::Object>()->InternalFieldCount() > 1) {
|
|
35
|
+
auto wrapper = obj.As<v8::Object>()->GetAlignedPointerFromInternalField(0);
|
|
36
|
+
if (wrapper != nullptr) {
|
|
37
|
+
((ObjectWrapperImpl *) wrapper)->type_ = type;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
inline static NativeType GetNativeType(const v8::Local<v8::Value> &obj) {
|
|
44
|
+
if (!obj.IsEmpty() && !obj->IsNullOrUndefined() && obj->IsObject() &&
|
|
45
|
+
obj.As<v8::Object>()->InternalFieldCount() > 1) {
|
|
46
|
+
auto info = obj.As<v8::Object>()->GetAlignedPointerFromInternalField(0);
|
|
47
|
+
|
|
48
|
+
if (info != nullptr) {
|
|
49
|
+
auto value = static_cast<ObjectWrapperImpl *>(info);
|
|
50
|
+
return value->type_;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return NativeType::None;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static void SetNativeType(ObjectWrapperImpl *obj, NativeType type) {
|
|
58
|
+
if (obj != nullptr) {
|
|
59
|
+
obj->type_ = type;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static NativeType GetNativeType(const ObjectWrapperImpl *obj) {
|
|
64
|
+
if (obj != nullptr) {
|
|
65
|
+
return obj->type_;
|
|
66
|
+
}
|
|
67
|
+
return NativeType::None;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static void SetNativeType(ObjectWrapperImpl &obj, NativeType type) {
|
|
71
|
+
obj.type_ = type;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static NativeType GetNativeType(const ObjectWrapperImpl &obj) {
|
|
75
|
+
return obj.type_;
|
|
76
|
+
}
|
|
77
|
+
|
|
28
78
|
private:
|
|
29
79
|
v8::Global<v8::Object> weakHandle_;
|
|
30
80
|
|