@nativescript/canvas 2.0.0-webgpu.4 → 2.0.0-webgpu.41
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/common.d.ts +5 -10
- package/Canvas/common.js +61 -144
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +6 -5
- package/Canvas/index.android.js +63 -42
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +13 -3
- package/Canvas/index.ios.d.ts +9 -1
- package/Canvas/index.ios.js +117 -66
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas/utils.d.ts +3 -0
- package/Canvas/utils.js +85 -0
- package/Canvas/utils.js.map +1 -0
- package/Canvas2D/CanvasRenderingContext2D/index.d.ts +3 -1
- package/Canvas2D/CanvasRenderingContext2D/index.js +2 -4
- package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
- package/Dom/Group.d.ts +1 -2
- package/Dom/Group.js.map +1 -1
- package/Dom/Image.js +0 -1
- package/Dom/Image.js.map +1 -1
- package/Dom/Paint.d.ts +1 -1
- package/Dom/shapes/Path.d.ts +1 -1
- package/ImageAsset/index.d.ts +4 -2
- package/ImageAsset/index.js +151 -37
- package/ImageAsset/index.js.map +1 -1
- package/ImageBitmap/index.js +107 -20
- package/ImageBitmap/index.js.map +1 -1
- package/README.md +2 -4
- package/WebGL/WebGLRenderingContext/common.d.ts +1 -1
- package/WebGL/WebGLRenderingContext/index.js +76 -32
- package/WebGL/WebGLRenderingContext/index.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.js +5 -5
- package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
- package/WebGPU/GPU.js +4 -3
- package/WebGPU/GPU.js.map +1 -1
- package/WebGPU/GPUAdapter.d.ts +6 -3
- package/WebGPU/GPUAdapter.js +31 -0
- package/WebGPU/GPUAdapter.js.map +1 -1
- package/WebGPU/GPUBindGroup.d.ts +1 -0
- package/WebGPU/GPUBindGroup.js +3 -0
- package/WebGPU/GPUBindGroup.js.map +1 -1
- package/WebGPU/GPUBindGroupLayout.d.ts +1 -0
- package/WebGPU/GPUBindGroupLayout.js +3 -0
- package/WebGPU/GPUBindGroupLayout.js.map +1 -1
- package/WebGPU/GPUBuffer.js +10 -2
- package/WebGPU/GPUBuffer.js.map +1 -1
- package/WebGPU/GPUCanvasContext.d.ts +5 -3
- package/WebGPU/GPUCanvasContext.js +52 -10
- package/WebGPU/GPUCanvasContext.js.map +1 -1
- package/WebGPU/GPUCommandBuffer.d.ts +1 -0
- package/WebGPU/GPUCommandBuffer.js +3 -0
- package/WebGPU/GPUCommandBuffer.js.map +1 -1
- package/WebGPU/GPUCommandEncoder.d.ts +3 -9
- package/WebGPU/GPUCommandEncoder.js +94 -41
- package/WebGPU/GPUCommandEncoder.js.map +1 -1
- package/WebGPU/GPUComputePassEncoder.d.ts +1 -0
- package/WebGPU/GPUComputePassEncoder.js +3 -0
- package/WebGPU/GPUComputePassEncoder.js.map +1 -1
- package/WebGPU/GPUComputePipeline.d.ts +1 -0
- package/WebGPU/GPUComputePipeline.js +3 -0
- package/WebGPU/GPUComputePipeline.js.map +1 -1
- package/WebGPU/GPUDevice.d.ts +17 -79
- package/WebGPU/GPUDevice.js +75 -91
- package/WebGPU/GPUDevice.js.map +1 -1
- package/WebGPU/GPUExternalTexture.d.ts +1 -0
- package/WebGPU/GPUExternalTexture.js +3 -0
- package/WebGPU/GPUExternalTexture.js.map +1 -1
- package/WebGPU/GPUPipelineLayout.d.ts +1 -0
- package/WebGPU/GPUPipelineLayout.js +3 -0
- package/WebGPU/GPUPipelineLayout.js.map +1 -1
- package/WebGPU/GPUQuerySet.d.ts +1 -0
- package/WebGPU/GPUQuerySet.js +3 -0
- package/WebGPU/GPUQuerySet.js.map +1 -1
- package/WebGPU/GPUQueue.d.ts +1 -0
- package/WebGPU/GPUQueue.js +65 -14
- package/WebGPU/GPUQueue.js.map +1 -1
- package/WebGPU/GPURenderBundle.d.ts +1 -0
- package/WebGPU/GPURenderBundle.js +3 -0
- package/WebGPU/GPURenderBundle.js.map +1 -1
- package/WebGPU/GPURenderBundleEncoder.d.ts +4 -2
- package/WebGPU/GPURenderBundleEncoder.js +7 -3
- package/WebGPU/GPURenderBundleEncoder.js.map +1 -1
- package/WebGPU/GPURenderPassEncoder.d.ts +5 -1
- package/WebGPU/GPURenderPassEncoder.js +14 -2
- package/WebGPU/GPURenderPassEncoder.js.map +1 -1
- package/WebGPU/GPURenderPipeline.d.ts +1 -0
- package/WebGPU/GPURenderPipeline.js +3 -0
- package/WebGPU/GPURenderPipeline.js.map +1 -1
- package/WebGPU/GPUSampler.d.ts +1 -0
- package/WebGPU/GPUSampler.js +3 -0
- package/WebGPU/GPUSampler.js.map +1 -1
- package/WebGPU/GPUShaderModule.d.ts +1 -1
- package/WebGPU/GPUShaderModule.js +2 -2
- package/WebGPU/GPUShaderModule.js.map +1 -1
- package/WebGPU/GPUTexture.d.ts +1 -0
- package/WebGPU/GPUTexture.js +3 -0
- package/WebGPU/GPUTexture.js.map +1 -1
- package/WebGPU/GPUTextureView.d.ts +1 -0
- package/WebGPU/GPUTextureView.js +3 -0
- package/WebGPU/GPUTextureView.js.map +1 -1
- package/WebGPU/Interfaces.d.ts +95 -4
- package/WebGPU/Types.d.ts +9 -1
- package/WebGPU/Utils.d.ts +6 -0
- package/WebGPU/Utils.js +226 -0
- package/WebGPU/Utils.js.map +1 -1
- package/angular/esm2022/index.mjs +4 -4
- package/angular/fesm2022/nativescript-canvas-angular.mjs +4 -4
- package/angular/fesm2022/nativescript-canvas-angular.mjs.map +1 -1
- package/common.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.js +3 -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 +61 -30
- 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 +144 -176
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +342 -72
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +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 +1928 -630
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +85 -23
- 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/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +85 -23
- 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 +681 -644
- 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 +122 -60
- 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 +144 -176
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +342 -72
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +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 +1928 -630
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +85 -23
- 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/arm64-apple-ios-simulator.swiftinterface +85 -23
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +1928 -630
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +85 -23
- 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/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +85 -23
- 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/CanvasNative.framework/_CodeSignature/CodeResources +40 -29
- 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 +683 -646
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +736 -684
- package/platforms/ios/src/NSOperationQueueWrapper.h +1 -1
- package/platforms/ios/src/NSOperationQueueWrapper.mm +41 -9
- package/platforms/ios/src/cpp/AsyncCallback.h +16 -8
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +310 -801
- package/platforms/ios/src/cpp/CanvasJSIModule.h +2 -0
- package/platforms/ios/src/cpp/ImageAssetImpl.cpp +578 -413
- package/platforms/ios/src/cpp/ImageAssetImpl.h +7 -3
- package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +60 -3
- package/platforms/ios/src/cpp/ImageBitmapImpl.h +10 -3
- package/platforms/ios/src/cpp/PromiseCallback.h +1 -2
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +7 -11
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +3 -3
- package/platforms/ios/src/cpp/canvas2d/Path2D.h +5 -5
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +106 -1
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.cpp +6 -6
- package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +26 -23
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +31 -5
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +26 -0
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +41 -7
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +4 -0
- package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +11 -5
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +28 -1
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +75 -79
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +4 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +56 -23
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +25 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +2 -0
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +1606 -681
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +2 -0
- package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +2 -1
- package/platforms/ios/src/cpp/webgpu/GPUImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPULabel.h +33 -0
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +26 -0
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +3 -1
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +1 -2
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +1 -1
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +83 -14
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +66 -34
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +25 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +151 -52
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +7 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +25 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +26 -0
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +4 -1
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +24 -0
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +34 -8
- package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +2 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +26 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +3 -0
- package/platforms/ios/src/cpp/webgpu/GPUUtils.h +511 -0
- package/utils.d.ts +1 -1
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
class ImageAssetImpl : ObjectWrapperImpl {
|
|
20
20
|
public:
|
|
21
21
|
|
|
22
|
-
explicit ImageAssetImpl(ImageAsset *asset);
|
|
22
|
+
explicit ImageAssetImpl(const ImageAsset *asset);
|
|
23
23
|
|
|
24
24
|
~ImageAssetImpl();
|
|
25
25
|
|
|
26
|
-
ImageAsset *GetImageAsset();
|
|
26
|
+
const ImageAsset *GetImageAsset();
|
|
27
27
|
|
|
28
28
|
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
29
29
|
|
|
@@ -61,11 +61,15 @@ public:
|
|
|
61
61
|
|
|
62
62
|
static void FromBytesCb(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
63
63
|
|
|
64
|
+
static void FromEncodedBytesSync(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
65
|
+
|
|
66
|
+
static void FromEncodedBytesCb(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
67
|
+
|
|
64
68
|
/* static void SaveSync(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
65
69
|
|
|
66
70
|
static void SaveCb(const v8::FunctionCallbackInfo<v8::Value> &args);*/
|
|
67
71
|
|
|
68
72
|
|
|
69
73
|
private:
|
|
70
|
-
ImageAsset *asset_;
|
|
74
|
+
const ImageAsset *asset_;
|
|
71
75
|
};
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
#include "ImageBitmapImpl.h"
|
|
6
6
|
#include "Caches.h"
|
|
7
7
|
|
|
8
|
-
ImageBitmapImpl::ImageBitmapImpl(ImageAsset*
|
|
8
|
+
ImageBitmapImpl::ImageBitmapImpl(const ImageAsset *asset)
|
|
9
9
|
: bitmap_(asset) {}
|
|
10
10
|
|
|
11
|
-
ImageBitmapImpl::~ImageBitmapImpl(){
|
|
11
|
+
ImageBitmapImpl::~ImageBitmapImpl() {
|
|
12
12
|
canvas_native_image_asset_release(bitmap_);
|
|
13
13
|
this->bitmap_ = nullptr;
|
|
14
14
|
}
|
|
@@ -26,6 +26,23 @@ void ImageBitmapImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isol
|
|
|
26
26
|
canvasModule->Set(context, ConvertToV8String(isolate, "ImageBitmap"), func);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
|
|
30
|
+
void ImageBitmapImpl::FromAsset(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
31
|
+
auto asset = args[0];
|
|
32
|
+
auto type = GetNativeType(asset);
|
|
33
|
+
auto isolate = args.GetIsolate();
|
|
34
|
+
if (type == NativeType::ImageAsset){
|
|
35
|
+
auto ptr = ImageAssetImpl::GetPointer(asset.As<v8::Object>());
|
|
36
|
+
auto ret = canvas_native_image_asset_reference(ptr->GetImageAsset());
|
|
37
|
+
auto bitmap = new ImageBitmapImpl(ret);
|
|
38
|
+
auto data = v8::External::New(isolate, bitmap);
|
|
39
|
+
auto object = ImageBitmapImpl::NewInstance(isolate, data);
|
|
40
|
+
args.GetReturnValue().Set(object);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
args.GetReturnValue().SetNull();
|
|
44
|
+
}
|
|
45
|
+
|
|
29
46
|
ImageBitmapImpl *ImageBitmapImpl::GetPointer(v8::Local<v8::Object> object) {
|
|
30
47
|
auto ptr = object->GetAlignedPointerFromInternalField(0);
|
|
31
48
|
if (ptr == nullptr) {
|
|
@@ -45,7 +62,10 @@ v8::Local<v8::FunctionTemplate> ImageBitmapImpl::GetCtor(v8::Isolate *isolate) {
|
|
|
45
62
|
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
|
|
46
63
|
ctorTmpl->SetClassName(ConvertToV8String(isolate, "ImageBitmap"));
|
|
47
64
|
|
|
65
|
+
ctorTmpl->Set(ConvertToV8String(isolate, "fromAsset"), v8::FunctionTemplate::New(isolate, FromAsset));
|
|
66
|
+
|
|
48
67
|
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
68
|
+
|
|
49
69
|
tmpl->SetInternalFieldCount(2);
|
|
50
70
|
tmpl->SetAccessor(
|
|
51
71
|
ConvertToV8String(isolate, "width"), GetWidth);
|
|
@@ -56,6 +76,13 @@ v8::Local<v8::FunctionTemplate> ImageBitmapImpl::GetCtor(v8::Isolate *isolate) {
|
|
|
56
76
|
tmpl->Set(
|
|
57
77
|
ConvertToV8String(isolate, "close"), v8::FunctionTemplate::New(isolate, Close));
|
|
58
78
|
|
|
79
|
+
tmpl->SetAccessor(
|
|
80
|
+
ConvertToV8String(isolate, "__addr"),
|
|
81
|
+
GetAddr);
|
|
82
|
+
|
|
83
|
+
tmpl->Set(
|
|
84
|
+
ConvertToV8String(isolate, "__getRef"),
|
|
85
|
+
v8::FunctionTemplate::New(isolate, GetReference));
|
|
59
86
|
|
|
60
87
|
cache->ImageBitmapTmpl =
|
|
61
88
|
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
@@ -93,6 +120,8 @@ void ImageBitmapImpl::Close(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
93
120
|
return;
|
|
94
121
|
}
|
|
95
122
|
|
|
123
|
+
canvas_native_image_asset_close(ptr->GetImageAsset());
|
|
124
|
+
|
|
96
125
|
ptr->closed_ = true;
|
|
97
126
|
}
|
|
98
127
|
|
|
@@ -184,6 +213,34 @@ ImageBitmapImpl::HandleOptions(v8::Isolate *isolate, const v8::Local<v8::Value>
|
|
|
184
213
|
return ret;
|
|
185
214
|
}
|
|
186
215
|
|
|
187
|
-
|
|
216
|
+
|
|
217
|
+
void
|
|
218
|
+
ImageBitmapImpl::GetAddr(v8::Local<v8::String> name,
|
|
219
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
220
|
+
auto ptr = GetPointer(info.This());
|
|
221
|
+
if (ptr != nullptr) {
|
|
222
|
+
auto isolate = info.GetIsolate();
|
|
223
|
+
auto ret = std::to_string(canvas_native_image_asset_get_addr(ptr->GetImageAsset()));
|
|
224
|
+
info.GetReturnValue().Set(ConvertToV8String(isolate, ret));
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
info.GetReturnValue().SetEmptyString();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
void
|
|
231
|
+
ImageBitmapImpl::GetReference(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
232
|
+
auto ptr = GetPointer(args.This());
|
|
233
|
+
if (ptr != nullptr) {
|
|
234
|
+
auto isolate = args.GetIsolate();
|
|
235
|
+
auto reference = canvas_native_image_asset_reference(ptr->GetImageAsset());
|
|
236
|
+
auto ret = std::to_string(canvas_native_image_asset_get_addr(reference));
|
|
237
|
+
args.GetReturnValue().Set(ConvertToV8String(isolate, ret));
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
args.GetReturnValue().SetEmptyString();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const ImageAsset *ImageBitmapImpl::GetImageAsset() {
|
|
188
245
|
return this->bitmap_;
|
|
189
246
|
}
|
|
@@ -21,7 +21,7 @@ struct Options {
|
|
|
21
21
|
|
|
22
22
|
class ImageBitmapImpl : public ObjectWrapperImpl {
|
|
23
23
|
public:
|
|
24
|
-
explicit ImageBitmapImpl(ImageAsset *asset);
|
|
24
|
+
explicit ImageBitmapImpl(const ImageAsset *asset);
|
|
25
25
|
|
|
26
26
|
~ImageBitmapImpl();
|
|
27
27
|
|
|
@@ -46,7 +46,7 @@ public:
|
|
|
46
46
|
|
|
47
47
|
static Options HandleOptions(v8::Isolate *isolate, const v8::Local<v8::Value> &options);
|
|
48
48
|
|
|
49
|
-
ImageAsset *GetImageAsset();
|
|
49
|
+
const ImageAsset *GetImageAsset();
|
|
50
50
|
|
|
51
51
|
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
52
52
|
|
|
@@ -60,9 +60,16 @@ public:
|
|
|
60
60
|
static void GetHeight(v8::Local<v8::String> name,
|
|
61
61
|
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
62
62
|
|
|
63
|
+
static void GetReference(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
64
|
+
|
|
65
|
+
static void GetAddr(v8::Local<v8::String> name,
|
|
66
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
67
|
+
|
|
63
68
|
static void Close(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
64
69
|
|
|
70
|
+
static void FromAsset(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
71
|
+
|
|
65
72
|
private:
|
|
66
|
-
ImageAsset *bitmap_;
|
|
73
|
+
const ImageAsset *bitmap_;
|
|
67
74
|
bool closed_ = false;
|
|
68
75
|
};
|
|
@@ -163,7 +163,7 @@ struct PromiseCallback {
|
|
|
163
163
|
auto data = new PromiseCallback(this->inner_);
|
|
164
164
|
ALooper_addFd(looper,
|
|
165
165
|
fd,
|
|
166
|
-
|
|
166
|
+
0,
|
|
167
167
|
ALOOPER_EVENT_INPUT,
|
|
168
168
|
[](int fd, int events,
|
|
169
169
|
void *data) {
|
|
@@ -175,7 +175,6 @@ struct PromiseCallback {
|
|
|
175
175
|
return 0;
|
|
176
176
|
}, (void *) data);
|
|
177
177
|
|
|
178
|
-
ALooper_wake(looper);
|
|
179
178
|
inner->isPrepared_ = true;
|
|
180
179
|
}
|
|
181
180
|
|
|
@@ -630,7 +630,7 @@ void CanvasRenderingContext2DImpl::DrawPoints(const v8::FunctionCallbackInfo<v8:
|
|
|
630
630
|
}
|
|
631
631
|
|
|
632
632
|
canvas_native_context_draw_points(
|
|
633
|
-
ptr->GetContext(), pointMode,
|
|
633
|
+
ptr->GetContext(), (int32_t)pointMode,
|
|
634
634
|
store.data(), store.size());
|
|
635
635
|
|
|
636
636
|
|
|
@@ -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);
|
|
@@ -636,7 +636,7 @@ public:
|
|
|
636
636
|
static void DrawImage(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
637
637
|
|
|
638
638
|
static void
|
|
639
|
-
DrawImageDxDyAssetImpl(CanvasRenderingContext2DImpl *ptr, ImageAsset *asset, double dx,
|
|
639
|
+
DrawImageDxDyAssetImpl(CanvasRenderingContext2DImpl *ptr, const ImageAsset *asset, double dx,
|
|
640
640
|
double dy) {
|
|
641
641
|
if (asset != nullptr) {
|
|
642
642
|
canvas_native_context_draw_image_dx_dy_asset(
|
|
@@ -690,7 +690,7 @@ public:
|
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
692
|
|
|
693
|
-
static void DrawImageDxDyDwDhAssetImpl(CanvasRenderingContext2DImpl *ptr, ImageAsset *asset,
|
|
693
|
+
static void DrawImageDxDyDwDhAssetImpl(CanvasRenderingContext2DImpl *ptr, const ImageAsset *asset,
|
|
694
694
|
double dx, double dy, double dw, double dh) {
|
|
695
695
|
|
|
696
696
|
|
|
@@ -783,7 +783,7 @@ public:
|
|
|
783
783
|
|
|
784
784
|
static void
|
|
785
785
|
DrawImageAssetImpl(CanvasRenderingContext2DImpl *ptr,
|
|
786
|
-
ImageAsset *asset, double sx,
|
|
786
|
+
const ImageAsset *asset, double sx,
|
|
787
787
|
double sy, double sw, double sh, double dx, double dy, double dw,
|
|
788
788
|
double dh) {
|
|
789
789
|
|
|
@@ -199,7 +199,7 @@ public:
|
|
|
199
199
|
double rotation,
|
|
200
200
|
double start_angle,
|
|
201
201
|
double end_angle,
|
|
202
|
-
|
|
202
|
+
bool anticlockwise) {
|
|
203
203
|
|
|
204
204
|
canvas_native_path_ellipse(
|
|
205
205
|
receiver_obj,
|
|
@@ -222,7 +222,7 @@ public:
|
|
|
222
222
|
double rotation,
|
|
223
223
|
double start_angle,
|
|
224
224
|
double end_angle,
|
|
225
|
-
|
|
225
|
+
bool anticlockwise) {
|
|
226
226
|
Path2D *ptr = GetPointer(receiver_obj);
|
|
227
227
|
if (ptr == nullptr) {
|
|
228
228
|
return;
|
|
@@ -362,9 +362,9 @@ public:
|
|
|
362
362
|
|
|
363
363
|
canvas_native_path_round_rect(
|
|
364
364
|
ptr->GetPath(),
|
|
365
|
-
x, y,
|
|
366
|
-
width,
|
|
367
|
-
height, buf.data(),
|
|
365
|
+
(float)x, (float)y,
|
|
366
|
+
(float)width,
|
|
367
|
+
(float)height, buf.data(),
|
|
368
368
|
buf.size());
|
|
369
369
|
|
|
370
370
|
}
|
|
@@ -4350,8 +4350,113 @@ WebGLRenderingContext::TexImage2D(const v8::FunctionCallbackInfo<v8::Value> &arg
|
|
|
4350
4350
|
ptr->GetState()
|
|
4351
4351
|
);
|
|
4352
4352
|
return;
|
|
4353
|
-
}
|
|
4353
|
+
} else {
|
|
4354
|
+
auto objectType = GetNativeType(value);
|
|
4355
|
+
|
|
4356
|
+
switch (objectType) {
|
|
4357
|
+
case NativeType::ImageAsset: {
|
|
4358
|
+
auto image_asset = ImageAssetImpl::GetPointer(value.As<v8::Object>());
|
|
4359
|
+
|
|
4360
|
+
if (image_asset !=
|
|
4361
|
+
nullptr) {
|
|
4362
|
+
|
|
4363
|
+
canvas_native_webgl2_tex_image2d_image_asset(
|
|
4364
|
+
target,
|
|
4365
|
+
level,
|
|
4366
|
+
internalformat,
|
|
4367
|
+
width,
|
|
4368
|
+
height,
|
|
4369
|
+
border,
|
|
4370
|
+
format,
|
|
4371
|
+
type,
|
|
4372
|
+
image_asset->GetImageAsset(),
|
|
4373
|
+
ptr->GetState()
|
|
4374
|
+
);
|
|
4375
|
+
}
|
|
4376
|
+
return;
|
|
4377
|
+
}
|
|
4378
|
+
case NativeType::ImageBitmap: {
|
|
4379
|
+
auto image_bitmap = ImageBitmapImpl::GetPointer(value.As<v8::Object>());
|
|
4380
|
+
|
|
4381
|
+
if (image_bitmap !=
|
|
4382
|
+
nullptr) {
|
|
4383
|
+
canvas_native_webgl2_tex_image2d_image_asset(
|
|
4384
|
+
target,
|
|
4385
|
+
level,
|
|
4386
|
+
internalformat,
|
|
4387
|
+
width,
|
|
4388
|
+
height,
|
|
4389
|
+
border,
|
|
4390
|
+
format,
|
|
4391
|
+
type,
|
|
4392
|
+
image_bitmap->GetImageAsset(),
|
|
4393
|
+
ptr->GetState()
|
|
4394
|
+
);
|
|
4395
|
+
}
|
|
4396
|
+
return;
|
|
4397
|
+
}
|
|
4398
|
+
case NativeType::CanvasRenderingContext2D: {
|
|
4399
|
+
auto canvas_2d = CanvasRenderingContext2DImpl::GetPointer(
|
|
4400
|
+
value.As<v8::Object>());
|
|
4401
|
+
|
|
4402
|
+
if (canvas_2d != nullptr) {
|
|
4403
|
+
canvas_native_webgl2_tex_image2d_canvas2d(
|
|
4404
|
+
target,
|
|
4405
|
+
level,
|
|
4406
|
+
internalformat,
|
|
4407
|
+
width,
|
|
4408
|
+
height,
|
|
4409
|
+
border,
|
|
4410
|
+
format,
|
|
4411
|
+
type,
|
|
4412
|
+
canvas_2d->GetContext(),
|
|
4413
|
+
ptr->GetState()
|
|
4414
|
+
);
|
|
4415
|
+
}
|
|
4416
|
+
|
|
4417
|
+
return;
|
|
4418
|
+
}
|
|
4419
|
+
case NativeType::WebGLRenderingContextBase: {
|
|
4420
|
+
auto gl = WebGLRenderingContext::GetPointer(value.As<v8::Object>());
|
|
4421
|
+
|
|
4422
|
+
if (gl != nullptr) {
|
|
4423
|
+
canvas_native_webgl2_tex_image2d_webgl(
|
|
4424
|
+
target,
|
|
4425
|
+
level,
|
|
4426
|
+
internalformat,
|
|
4427
|
+
width,
|
|
4428
|
+
height,
|
|
4429
|
+
border,
|
|
4430
|
+
format,
|
|
4431
|
+
type,
|
|
4432
|
+
gl->GetState(),
|
|
4433
|
+
ptr->GetState()
|
|
4434
|
+
);
|
|
4435
|
+
}
|
|
4436
|
+
return;
|
|
4437
|
+
}
|
|
4438
|
+
case NativeType::ImageData: {
|
|
4439
|
+
auto image_data = ImageDataImpl::GetPointer(value.As<v8::Object>());
|
|
4440
|
+
if (image_data != nullptr) {
|
|
4441
|
+
canvas_native_webgl2_tex_image2d_image_data(
|
|
4442
|
+
target,
|
|
4443
|
+
level,
|
|
4444
|
+
internalformat,
|
|
4445
|
+
width,
|
|
4446
|
+
height,
|
|
4447
|
+
border,
|
|
4448
|
+
format,
|
|
4449
|
+
type,
|
|
4450
|
+
image_data->GetImageData(),
|
|
4451
|
+
ptr->GetState()
|
|
4452
|
+
);
|
|
4453
|
+
}
|
|
4354
4454
|
|
|
4455
|
+
}
|
|
4456
|
+
default:
|
|
4457
|
+
break;
|
|
4458
|
+
}
|
|
4459
|
+
}
|
|
4355
4460
|
}
|
|
4356
4461
|
}
|
|
4357
4462
|
|
|
@@ -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
|
}
|
|
@@ -141,8 +141,8 @@ WebGLRenderingContextBase::~WebGLRenderingContextBase() {
|
|
|
141
141
|
if (_raf != nullptr) {
|
|
142
142
|
canvas_native_raf_stop(
|
|
143
143
|
_raf->GetRaf());
|
|
144
|
+
canvas_native_raf_release(_raf->GetRaf());
|
|
144
145
|
}
|
|
145
|
-
canvas_native_raf_release(_raf->GetRaf());
|
|
146
146
|
this->raf_ = nullptr;
|
|
147
147
|
canvas_native_webgl_state_destroy(this->GetState());
|
|
148
148
|
this->state_ = nullptr;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
#include "GPUAdapterImpl.h"
|
|
6
6
|
#include "Caches.h"
|
|
7
|
-
|
|
7
|
+
#include "GPULabel.h"
|
|
8
8
|
GPUAdapterImpl::GPUAdapterImpl(const CanvasGPUAdapter *adapter) : adapter_(adapter) {}
|
|
9
9
|
|
|
10
10
|
const CanvasGPUAdapter *GPUAdapterImpl::GetGPUAdapter() {
|
|
@@ -61,7 +61,6 @@ v8::Local<v8::FunctionTemplate> GPUAdapterImpl::GetCtor(v8::Isolate *isolate) {
|
|
|
61
61
|
GetLimits
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
-
|
|
65
64
|
tmpl->Set(
|
|
66
65
|
ConvertToV8String(isolate, "requestAdapterInfo"),
|
|
67
66
|
v8::FunctionTemplate::New(isolate, &RequestAdapterInfo));
|
|
@@ -90,19 +89,19 @@ GPUAdapterImpl::GetFeatures(v8::Local<v8::Name> name,
|
|
|
90
89
|
|
|
91
90
|
auto len = canvas_native_string_buffer_get_length(features);
|
|
92
91
|
|
|
93
|
-
auto
|
|
92
|
+
auto set = v8::Set::New(isolate);
|
|
94
93
|
for (int i = 0; i < len; ++i) {
|
|
95
94
|
auto item = canvas_native_string_buffer_get_value_at(features, i);
|
|
96
95
|
if (item != nullptr) {
|
|
97
|
-
auto keyValue =
|
|
98
|
-
|
|
96
|
+
auto keyValue = ConvertToV8String(isolate, (char *) item);
|
|
97
|
+
set->Add(context, keyValue);
|
|
99
98
|
canvas_native_string_destroy(item);
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
}
|
|
103
102
|
canvas_native_string_buffer_release(features);
|
|
104
103
|
|
|
105
|
-
info.GetReturnValue().Set(
|
|
104
|
+
info.GetReturnValue().Set(set);
|
|
106
105
|
|
|
107
106
|
return;
|
|
108
107
|
}
|
|
@@ -162,11 +161,14 @@ struct RequestData {
|
|
|
162
161
|
char *error_;
|
|
163
162
|
const CanvasGPUDevice *device_;
|
|
164
163
|
char **required_features_data_;
|
|
164
|
+
size_t required_features_data_size;
|
|
165
165
|
|
|
166
166
|
~RequestData() {
|
|
167
167
|
if (required_features_data_ != nullptr) {
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
for (size_t i = 0; i < required_features_data_size; ++i) {
|
|
169
|
+
delete[] required_features_data_[i];
|
|
170
|
+
}
|
|
171
|
+
delete[] required_features_data_;
|
|
170
172
|
}
|
|
171
173
|
|
|
172
174
|
if (error_ != nullptr) {
|
|
@@ -190,7 +192,7 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
190
192
|
|
|
191
193
|
auto func = cb.As<v8::Function>();
|
|
192
194
|
|
|
193
|
-
|
|
195
|
+
GPULabel label;
|
|
194
196
|
|
|
195
197
|
std::vector<std::string> required_features_buf;
|
|
196
198
|
|
|
@@ -201,10 +203,9 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
201
203
|
v8::Local<v8::Value> labelValue;
|
|
202
204
|
options->Get(context, ConvertToV8String(isolate, "label")).ToLocal(
|
|
203
205
|
&labelValue);
|
|
206
|
+
|
|
207
|
+
label = GPULabel(isolate, labelValue);
|
|
204
208
|
|
|
205
|
-
if (!labelValue.IsEmpty() && labelValue->IsString()) {
|
|
206
|
-
label = ConvertFromV8String(isolate, labelValue);
|
|
207
|
-
}
|
|
208
209
|
|
|
209
210
|
v8::Local<v8::Value> requiredFeaturesValue;
|
|
210
211
|
|
|
@@ -212,11 +213,9 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
212
213
|
&requiredFeaturesValue);
|
|
213
214
|
|
|
214
215
|
|
|
215
|
-
if (!requiredFeaturesValue.IsEmpty() && requiredFeaturesValue->
|
|
216
|
-
v8::Local<v8::
|
|
217
|
-
v8::Local<v8::Array> requiredFeatures = requiredFeaturesSet->AsArray();
|
|
216
|
+
if (!requiredFeaturesValue.IsEmpty() && requiredFeaturesValue->IsArray()) {
|
|
217
|
+
v8::Local<v8::Array> requiredFeatures = requiredFeaturesValue.As<v8::Array>();
|
|
218
218
|
auto len = requiredFeatures->Length();
|
|
219
|
-
|
|
220
219
|
for (int i = 0; i < len; i++) {
|
|
221
220
|
auto item = requiredFeatures->Get(context, i);
|
|
222
221
|
if (!item.IsEmpty()) {
|
|
@@ -245,10 +244,12 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
245
244
|
size_t required_features_data_length = required_features_buf.size();
|
|
246
245
|
|
|
247
246
|
if (required_features_data_length > 0) {
|
|
248
|
-
required_features_data = new char *[required_features_data_length
|
|
247
|
+
required_features_data = new char *[required_features_data_length];
|
|
249
248
|
|
|
250
249
|
for (size_t i = 0; i < required_features_data_length; ++i) {
|
|
251
|
-
|
|
250
|
+
required_features_data[i] = new char[required_features_buf[i].size() + 1];
|
|
251
|
+
auto src = required_features_buf[i].c_str();
|
|
252
|
+
std::strcpy(required_features_data[i], src);
|
|
252
253
|
}
|
|
253
254
|
}
|
|
254
255
|
|
|
@@ -297,7 +298,8 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
297
298
|
callback->Call(context, context->Global(),
|
|
298
299
|
1,
|
|
299
300
|
args); // ignore JS return value
|
|
300
|
-
|
|
301
|
+
|
|
302
|
+
|
|
301
303
|
} else {
|
|
302
304
|
|
|
303
305
|
auto impl = new GPUDeviceImpl(requestData->device_);
|
|
@@ -311,14 +313,14 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
311
313
|
callback->Call(context, context->Global(),
|
|
312
314
|
2,
|
|
313
315
|
args); // ignore JS return value
|
|
314
|
-
|
|
315
|
-
delete static_cast<AsyncCallback *>(data);
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
if (requestData != nullptr) {
|
|
319
319
|
delete requestData;
|
|
320
320
|
requestData = nullptr;
|
|
321
321
|
}
|
|
322
|
+
|
|
323
|
+
delete static_cast<AsyncCallback *>(data);
|
|
322
324
|
}
|
|
323
325
|
}
|
|
324
326
|
}
|
|
@@ -330,14 +332,15 @@ void GPUAdapterImpl::RequestDevice(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
330
332
|
inner->data = new RequestData{
|
|
331
333
|
nullptr,
|
|
332
334
|
nullptr,
|
|
333
|
-
required_features_data
|
|
335
|
+
required_features_data,
|
|
336
|
+
required_features_data_length
|
|
334
337
|
};
|
|
335
338
|
}
|
|
336
339
|
|
|
337
340
|
callback->prepare();
|
|
338
341
|
|
|
339
342
|
canvas_native_webgpu_adapter_request_device(ptr->GetGPUAdapter(),
|
|
340
|
-
label
|
|
343
|
+
*label,
|
|
341
344
|
required_features_data,
|
|
342
345
|
required_features_data_length,
|
|
343
346
|
limits,
|
|
@@ -13,7 +13,7 @@ const CanvasGPUBindGroup *GPUBindGroupImpl::GetBindGroup() {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
void GPUBindGroupImpl::Init(v8::Local
|
|
16
|
+
void GPUBindGroupImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
17
17
|
v8::Locker locker(isolate);
|
|
18
18
|
v8::Isolate::Scope isolate_scope(isolate);
|
|
19
19
|
v8::HandleScope handle_scope(isolate);
|
|
@@ -25,7 +25,7 @@ void GPUBindGroupImpl::Init(v8::Local <v8::Object> canvasModule, v8::Isolate *is
|
|
|
25
25
|
canvasModule->Set(context, ConvertToV8String(isolate, "GPUBindGroup"), func).FromJust();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
GPUBindGroupImpl *GPUBindGroupImpl::GetPointer(const v8::Local
|
|
28
|
+
GPUBindGroupImpl *GPUBindGroupImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
29
29
|
auto ptr = object->GetAlignedPointerFromInternalField(0);
|
|
30
30
|
if (ptr == nullptr) {
|
|
31
31
|
return nullptr;
|
|
@@ -33,21 +33,47 @@ GPUBindGroupImpl *GPUBindGroupImpl::GetPointer(const v8::Local <v8::Object> &obj
|
|
|
33
33
|
return static_cast<GPUBindGroupImpl *>(ptr);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
v8::Local
|
|
36
|
+
v8::Local<v8::FunctionTemplate> GPUBindGroupImpl::GetCtor(v8::Isolate *isolate) {
|
|
37
37
|
auto cache = Caches::Get(isolate);
|
|
38
38
|
auto ctor = cache->GPUBindGroupTmpl.get();
|
|
39
39
|
if (ctor != nullptr) {
|
|
40
40
|
return ctor->Get(isolate);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
v8::Local
|
|
43
|
+
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
44
44
|
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
|
|
45
45
|
ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUBindGroup"));
|
|
46
46
|
|
|
47
47
|
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
48
48
|
tmpl->SetInternalFieldCount(2);
|
|
49
49
|
|
|
50
|
+
tmpl->SetLazyDataProperty(
|
|
51
|
+
ConvertToV8String(isolate, "label"),
|
|
52
|
+
GetLabel
|
|
53
|
+
);
|
|
54
|
+
|
|
50
55
|
cache->GPUBindGroupTmpl =
|
|
51
|
-
std::make_unique
|
|
56
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate >>(isolate, ctorTmpl);
|
|
52
57
|
return ctorTmpl;
|
|
53
58
|
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
void
|
|
62
|
+
GPUBindGroupImpl::GetLabel(v8::Local<v8::Name> name,
|
|
63
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
64
|
+
auto ptr = GetPointer(info.This());
|
|
65
|
+
if (ptr != nullptr) {
|
|
66
|
+
auto label = canvas_native_webgpu_bind_group_get_label(ptr->group_);
|
|
67
|
+
if (label == nullptr) {
|
|
68
|
+
info.GetReturnValue().SetEmptyString();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
info.GetReturnValue().Set(
|
|
72
|
+
ConvertToV8String(info.GetIsolate(), label)
|
|
73
|
+
);
|
|
74
|
+
canvas_native_string_destroy(label);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
info.GetReturnValue().SetEmptyString();
|
|
79
|
+
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
class GPUBindGroupImpl : ObjectWrapperImpl {
|
|
13
13
|
public:
|
|
14
|
-
GPUBindGroupImpl(const CanvasGPUBindGroup *group);
|
|
14
|
+
explicit GPUBindGroupImpl(const CanvasGPUBindGroup *group);
|
|
15
15
|
|
|
16
16
|
~GPUBindGroupImpl() {
|
|
17
17
|
canvas_native_webgpu_bind_group_release(this->GetBindGroup());
|
|
@@ -37,6 +37,9 @@ public:
|
|
|
37
37
|
return scope.Escape(object);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
static void GetLabel(v8::Local<v8::Name> name,
|
|
41
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
42
|
+
|
|
40
43
|
private:
|
|
41
44
|
const CanvasGPUBindGroup *group_;
|
|
42
45
|
};
|