@nativescript/canvas 2.0.0-beta.9 → 2.0.0-webgpu.0
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 +23 -15
- package/Canvas/common.js +125 -56
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +5 -7
- package/Canvas/index.android.js +61 -133
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +4 -1
- package/Canvas/index.ios.d.ts +4 -5
- package/Canvas/index.ios.js +72 -82
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.d.ts +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.js +8 -11
- package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
- package/Canvas2D/DOMMatrix/index.d.ts +14 -0
- package/Canvas2D/DOMMatrix/index.js +62 -0
- package/Canvas2D/DOMMatrix/index.js.map +1 -1
- package/Canvas2D/ImageData/index.js +4 -6
- package/Canvas2D/ImageData/index.js.map +1 -1
- package/ImageAsset/index.d.ts +1 -0
- package/ImageAsset/index.js +49 -0
- package/ImageAsset/index.js.map +1 -1
- package/WebGL/WebGLRenderingContext/index.d.ts +1 -0
- package/WebGL/WebGLRenderingContext/index.js +86 -32
- package/WebGL/WebGLRenderingContext/index.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.d.ts +1 -0
- package/WebGL2/WebGL2RenderingContext/index.js +2 -3
- package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
- package/WebGPU/Constants.d.ts +36 -0
- package/WebGPU/Constants.js +42 -0
- package/WebGPU/Constants.js.map +1 -0
- package/WebGPU/Errors.d.ts +18 -0
- package/WebGPU/Errors.js +21 -0
- package/WebGPU/Errors.js.map +1 -0
- package/WebGPU/GPU.d.ts +13 -0
- package/WebGPU/GPU.js +35 -0
- package/WebGPU/GPU.js.map +1 -0
- package/WebGPU/GPUAdapter.d.ts +23 -0
- package/WebGPU/GPUAdapter.js +62 -0
- package/WebGPU/GPUAdapter.js.map +1 -0
- package/WebGPU/GPUAdapterInfo.d.ts +9 -0
- package/WebGPU/GPUAdapterInfo.js +24 -0
- package/WebGPU/GPUAdapterInfo.js.map +1 -0
- package/WebGPU/GPUBindGroup.d.ts +5 -0
- package/WebGPU/GPUBindGroup.js +12 -0
- package/WebGPU/GPUBindGroup.js.map +1 -0
- package/WebGPU/GPUBindGroupLayout.d.ts +5 -0
- package/WebGPU/GPUBindGroupLayout.js +12 -0
- package/WebGPU/GPUBindGroupLayout.js.map +1 -0
- package/WebGPU/GPUBuffer.d.ts +15 -0
- package/WebGPU/GPUBuffer.js +54 -0
- package/WebGPU/GPUBuffer.js.map +1 -0
- package/WebGPU/GPUCanvasContext.d.ts +33 -0
- package/WebGPU/GPUCanvasContext.js +67 -0
- package/WebGPU/GPUCanvasContext.js.map +1 -0
- package/WebGPU/GPUCommandBuffer.d.ts +5 -0
- package/WebGPU/GPUCommandBuffer.js +12 -0
- package/WebGPU/GPUCommandBuffer.js.map +1 -0
- package/WebGPU/GPUCommandEncoder.d.ts +41 -0
- package/WebGPU/GPUCommandEncoder.js +105 -0
- package/WebGPU/GPUCommandEncoder.js.map +1 -0
- package/WebGPU/GPUComputePassEncoder.d.ts +16 -0
- package/WebGPU/GPUComputePassEncoder.js +50 -0
- package/WebGPU/GPUComputePassEncoder.js.map +1 -0
- package/WebGPU/GPUComputePipeline.d.ts +7 -0
- package/WebGPU/GPUComputePipeline.js +16 -0
- package/WebGPU/GPUComputePipeline.js.map +1 -0
- package/WebGPU/GPUDevice.d.ts +173 -0
- package/WebGPU/GPUDevice.js +381 -0
- package/WebGPU/GPUDevice.js.map +1 -0
- package/WebGPU/GPUDeviceLostInfo.d.ts +1 -0
- package/WebGPU/GPUDeviceLostInfo.js +10 -0
- package/WebGPU/GPUDeviceLostInfo.js.map +1 -0
- package/WebGPU/GPUExternalTexture.d.ts +5 -0
- package/WebGPU/GPUExternalTexture.js +12 -0
- package/WebGPU/GPUExternalTexture.js.map +1 -0
- package/WebGPU/GPUPipelineLayout.d.ts +5 -0
- package/WebGPU/GPUPipelineLayout.js +12 -0
- package/WebGPU/GPUPipelineLayout.js.map +1 -0
- package/WebGPU/GPUQuerySet.d.ts +5 -0
- package/WebGPU/GPUQuerySet.js +12 -0
- package/WebGPU/GPUQuerySet.js.map +1 -0
- package/WebGPU/GPUQueue.d.ts +14 -0
- package/WebGPU/GPUQueue.js +77 -0
- package/WebGPU/GPUQueue.js.map +1 -0
- package/WebGPU/GPURenderBundle.d.ts +5 -0
- package/WebGPU/GPURenderBundle.js +12 -0
- package/WebGPU/GPURenderBundle.js.map +1 -0
- package/WebGPU/GPURenderBundleEncoder.d.ts +20 -0
- package/WebGPU/GPURenderBundleEncoder.js +61 -0
- package/WebGPU/GPURenderBundleEncoder.js.map +1 -0
- package/WebGPU/GPURenderPassEncoder.d.ts +29 -0
- package/WebGPU/GPURenderPassEncoder.js +94 -0
- package/WebGPU/GPURenderPassEncoder.js.map +1 -0
- package/WebGPU/GPURenderPipeline.d.ts +7 -0
- package/WebGPU/GPURenderPipeline.js +16 -0
- package/WebGPU/GPURenderPipeline.js.map +1 -0
- package/WebGPU/GPUSampler.d.ts +5 -0
- package/WebGPU/GPUSampler.js +12 -0
- package/WebGPU/GPUSampler.js.map +1 -0
- package/WebGPU/GPUShaderModule.d.ts +6 -0
- package/WebGPU/GPUShaderModule.js +15 -0
- package/WebGPU/GPUShaderModule.js.map +1 -0
- package/WebGPU/GPUTexture.d.ts +16 -0
- package/WebGPU/GPUTexture.js +41 -0
- package/WebGPU/GPUTexture.js.map +1 -0
- package/WebGPU/GPUTextureView.d.ts +5 -0
- package/WebGPU/GPUTextureView.js +12 -0
- package/WebGPU/GPUTextureView.js.map +1 -0
- package/WebGPU/Interfaces.d.ts +155 -0
- package/WebGPU/Interfaces.js +2 -0
- package/WebGPU/Interfaces.js.map +1 -0
- package/WebGPU/Types.d.ts +39 -0
- package/WebGPU/Types.js +2 -0
- package/WebGPU/Types.js.map +1 -0
- package/WebGPU/Utils.d.ts +1 -0
- package/WebGPU/Utils.js +75 -0
- package/WebGPU/Utils.js.map +1 -0
- package/WebGPU/index.d.ts +28 -0
- package/WebGPU/index.js +29 -0
- package/WebGPU/index.js.map +1 -0
- package/index.d.ts +1 -1
- package/index.js +22 -1
- package/index.js.map +1 -1
- package/package.json +1 -4
- 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/Headers/CanvasNative-Swift.h +23 -23
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +41 -8
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2280 -103
- 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 +1563 -3729
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +27 -34
- 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 +27 -34
- 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 +602 -663
- 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 +46 -46
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +41 -8
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2280 -103
- 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 +1563 -3729
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +27 -34
- 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 +27 -34
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +1563 -3729
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +27 -34
- 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 +27 -34
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +31 -31
- 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 +604 -662
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +638 -641
- package/platforms/ios/build.xcconfig +3 -1
- package/platforms/ios/src/cpp/Caches.h +69 -1
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +320 -395
- package/platforms/ios/src/cpp/CanvasJSIModule.h +7 -1
- package/platforms/ios/src/cpp/Helpers.h +43 -8
- package/platforms/ios/src/cpp/ImageAssetImpl.cpp +35 -37
- package/platforms/ios/src/cpp/ImageAssetImpl.h +14 -10
- package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +2 -2
- package/platforms/ios/src/cpp/ImageBitmapImpl.h +1 -1
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +0 -10
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +41 -4
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +409 -3
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +27 -0
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +131 -149
- package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +1766 -1659
- package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +302 -0
- package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +63 -0
- package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +174 -0
- package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +58 -0
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +53 -0
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +53 -0
- package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +229 -0
- package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +59 -0
- package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +317 -0
- package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +55 -0
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +54 -0
- package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +1087 -0
- package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +69 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +260 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +62 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +84 -0
- package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +49 -0
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +2741 -0
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +95 -0
- package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +186 -0
- package/platforms/ios/src/cpp/webgpu/GPUImpl.h +55 -0
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +54 -0
- package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +46 -0
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +137 -0
- package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +55 -0
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +521 -0
- package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +56 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +469 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +71 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +53 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +653 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +85 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +84 -0
- package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +49 -0
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +53 -0
- package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +56 -0
- package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +1304 -0
- package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +288 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +360 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +75 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +53 -0
- package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +45 -0
- package/platforms/ios/src/cpp/webgpu/GPUUtils.h +178 -0
- package/SVG/Circle.d.ts +0 -11
- package/SVG/Circle.js +0 -21
- package/SVG/Circle.js.map +0 -1
- package/SVG/ClipPath.d.ts +0 -4
- package/SVG/ClipPath.js +0 -9
- package/SVG/ClipPath.js.map +0 -1
- package/SVG/Defs.d.ts +0 -4
- package/SVG/Defs.js +0 -9
- package/SVG/Defs.js.map +0 -1
- package/SVG/Ellipse.d.ts +0 -13
- package/SVG/Ellipse.js +0 -26
- package/SVG/Ellipse.js.map +0 -1
- package/SVG/G.d.ts +0 -7
- package/SVG/G.js +0 -9
- package/SVG/G.js.map +0 -1
- package/SVG/Image.d.ts +0 -11
- package/SVG/Image.js +0 -40
- package/SVG/Image.js.map +0 -1
- package/SVG/Line.d.ts +0 -13
- package/SVG/Line.js +0 -26
- package/SVG/Line.js.map +0 -1
- package/SVG/LinearGradient.d.ts +0 -10
- package/SVG/LinearGradient.js +0 -13
- package/SVG/LinearGradient.js.map +0 -1
- package/SVG/Path.d.ts +0 -7
- package/SVG/Path.js +0 -14
- package/SVG/Path.js.map +0 -1
- package/SVG/Pattern.d.ts +0 -4
- package/SVG/Pattern.js +0 -9
- package/SVG/Pattern.js.map +0 -1
- package/SVG/Polygon.d.ts +0 -7
- package/SVG/Polygon.js +0 -14
- package/SVG/Polygon.js.map +0 -1
- package/SVG/Polyline.d.ts +0 -7
- package/SVG/Polyline.js +0 -14
- package/SVG/Polyline.js.map +0 -1
- package/SVG/Rect.d.ts +0 -8
- package/SVG/Rect.js +0 -13
- package/SVG/Rect.js.map +0 -1
- package/SVG/SVG.d.ts +0 -32
- package/SVG/SVG.js +0 -204
- package/SVG/SVG.js.map +0 -1
- package/SVG/SVGItem.d.ts +0 -5
- package/SVG/SVGItem.js +0 -8
- package/SVG/SVGItem.js.map +0 -1
- package/SVG/Stop.d.ts +0 -5
- package/SVG/Stop.js +0 -9
- package/SVG/Stop.js.map +0 -1
- package/SVG/Symbol.d.ts +0 -4
- package/SVG/Symbol.js +0 -9
- package/SVG/Symbol.js.map +0 -1
- package/SVG/Text.d.ts +0 -14
- package/SVG/Text.js +0 -26
- package/SVG/Text.js.map +0 -1
- package/SVG/Use.d.ts +0 -4
- package/SVG/Use.js +0 -9
- package/SVG/Use.js.map +0 -1
- package/SVG/index.d.ts +0 -18
- package/SVG/index.js +0 -19
- package/SVG/index.js.map +0 -1
- package/platforms/ios/src/cpp/PerIsolateData.cpp +0 -49
- package/platforms/ios/src/cpp/PerIsolateData.h +0 -54
- package/platforms/ios/src/cpp/URLImpl.cpp +0 -464
- package/platforms/ios/src/cpp/URLImpl.h +0 -121
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 20/06/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#include "GPUCanvasContextImpl.h"
|
|
6
|
+
#include "Caches.h"
|
|
7
|
+
#include "GPUAdapterImpl.h"
|
|
8
|
+
#include "GPUUtils.h"
|
|
9
|
+
|
|
10
|
+
GPUCanvasContextImpl::GPUCanvasContextImpl(const CanvasGPUCanvasContext *context) : context_(
|
|
11
|
+
context) {}
|
|
12
|
+
|
|
13
|
+
const CanvasGPUCanvasContext *GPUCanvasContextImpl::GetContext() {
|
|
14
|
+
return this->context_;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
void GPUCanvasContextImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
19
|
+
v8::Locker locker(isolate);
|
|
20
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
21
|
+
v8::HandleScope handle_scope(isolate);
|
|
22
|
+
|
|
23
|
+
auto ctor = GetCtor(isolate);
|
|
24
|
+
auto context = isolate->GetCurrentContext();
|
|
25
|
+
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
26
|
+
|
|
27
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUCanvasContext"), func).FromJust();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
GPUCanvasContextImpl *GPUCanvasContextImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
31
|
+
auto ptr = object->GetAlignedPointerFromInternalField(0);
|
|
32
|
+
if (ptr == nullptr) {
|
|
33
|
+
return nullptr;
|
|
34
|
+
}
|
|
35
|
+
return static_cast<GPUCanvasContextImpl *>(ptr);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
v8::Local<v8::FunctionTemplate> GPUCanvasContextImpl::GetCtor(v8::Isolate *isolate) {
|
|
39
|
+
auto cache = Caches::Get(isolate);
|
|
40
|
+
auto ctor = cache->GPUCanvasContextTmpl.get();
|
|
41
|
+
if (ctor != nullptr) {
|
|
42
|
+
return ctor->Get(isolate);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
46
|
+
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
|
|
47
|
+
ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUCanvasContext"));
|
|
48
|
+
|
|
49
|
+
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
50
|
+
tmpl->SetInternalFieldCount(2);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
tmpl->Set(
|
|
54
|
+
ConvertToV8String(isolate, "configure"),
|
|
55
|
+
v8::FunctionTemplate::New(isolate, &Configure));
|
|
56
|
+
|
|
57
|
+
tmpl->Set(
|
|
58
|
+
ConvertToV8String(isolate, "unconfigure"),
|
|
59
|
+
v8::FunctionTemplate::New(isolate, &UnConfigure));
|
|
60
|
+
|
|
61
|
+
tmpl->Set(
|
|
62
|
+
ConvertToV8String(isolate, "getCurrentTexture"),
|
|
63
|
+
v8::FunctionTemplate::New(isolate, &GetCurrentTexture));
|
|
64
|
+
|
|
65
|
+
tmpl->Set(
|
|
66
|
+
ConvertToV8String(isolate, "presentSurface"),
|
|
67
|
+
v8::FunctionTemplate::New(isolate, &PresentSurface));
|
|
68
|
+
|
|
69
|
+
tmpl->Set(
|
|
70
|
+
ConvertToV8String(isolate, "getCapabilities"),
|
|
71
|
+
v8::FunctionTemplate::New(isolate, &GetCapabilities));
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
cache->GPUCanvasContextTmpl =
|
|
75
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
76
|
+
return ctorTmpl;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
void GPUCanvasContextImpl::Configure(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
80
|
+
GPUCanvasContextImpl *ptr = GetPointer(args.This());
|
|
81
|
+
auto isolate = args.GetIsolate();
|
|
82
|
+
auto context = isolate->GetCurrentContext();
|
|
83
|
+
auto optionsValue = args[0];
|
|
84
|
+
if (ptr == nullptr) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (optionsValue->IsNullOrUndefined() || !optionsValue->IsObject()) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
auto options = optionsValue.As<v8::Object>();
|
|
93
|
+
|
|
94
|
+
v8::Local<v8::Value> deviceValue;
|
|
95
|
+
|
|
96
|
+
options->Get(context, ConvertToV8String(isolate, "device")).ToLocal(
|
|
97
|
+
&deviceValue);
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
if (deviceValue->IsNullOrUndefined() || !deviceValue->IsObject()) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
auto device = GPUDeviceImpl::GetPointer(deviceValue.As<v8::Object>());
|
|
105
|
+
|
|
106
|
+
if (device == nullptr) { return; }
|
|
107
|
+
|
|
108
|
+
CanvasGPUSurfaceConfiguration config{};
|
|
109
|
+
config.alphaMode = CanvasGPUSurfaceAlphaMode::CanvasGPUSurfaceAlphaModeOpaque;
|
|
110
|
+
config.presentMode = CanvasGPUPresentMode::CanvasGPUPresentModeFifo;
|
|
111
|
+
config.view_formats = nullptr;
|
|
112
|
+
config.view_formats_size = 0;
|
|
113
|
+
config.usage = 0x10;
|
|
114
|
+
config.format = CanvasOptionalGPUTextureFormat{
|
|
115
|
+
CanvasOptionalGPUTextureFormatNone
|
|
116
|
+
};
|
|
117
|
+
config.size = nullptr;
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
v8::Local<v8::Value> formatValue;
|
|
121
|
+
|
|
122
|
+
if (options->Get(context, ConvertToV8String(isolate, "format")).ToLocal(
|
|
123
|
+
&formatValue)) {
|
|
124
|
+
auto format = ConvertFromV8String(isolate, formatValue);
|
|
125
|
+
config.format = canvas_native_webgpu_enum_string_to_gpu_texture(format.c_str());
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
v8::Local<v8::Value> usageValue;
|
|
130
|
+
options->Get(context, ConvertToV8String(isolate, "usage")).ToLocal(
|
|
131
|
+
&usageValue);
|
|
132
|
+
|
|
133
|
+
if (!usageValue.IsEmpty() && usageValue->IsUint32()) {
|
|
134
|
+
config.usage = usageValue->Uint32Value(context).ToChecked();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
v8::Local<v8::Value> presentModeValue;
|
|
139
|
+
|
|
140
|
+
if (options->Get(context, ConvertToV8String(isolate, "presentMode")).ToLocal(
|
|
141
|
+
&presentModeValue)) {
|
|
142
|
+
if (presentModeValue->IsString()) {
|
|
143
|
+
auto presentMode = ConvertFromV8String(isolate, presentModeValue);
|
|
144
|
+
if (strcmp(presentMode.c_str(), "autoVsync") == 0) {
|
|
145
|
+
config.presentMode = CanvasGPUPresentMode::CanvasGPUPresentModeAutoVsync;
|
|
146
|
+
} else if (strcmp(presentMode.c_str(), "autoNoVsync") == 0) {
|
|
147
|
+
config.presentMode = CanvasGPUPresentMode::CanvasGPUPresentModeAutoNoVsync;
|
|
148
|
+
} else if (strcmp(presentMode.c_str(), "fifo") == 0) {
|
|
149
|
+
config.presentMode = CanvasGPUPresentMode::CanvasGPUPresentModeFifo;
|
|
150
|
+
} else if (strcmp(presentMode.c_str(), "fifoRelaxed") == 0) {
|
|
151
|
+
config.presentMode = CanvasGPUPresentMode::CanvasGPUPresentModeFifoRelaxed;
|
|
152
|
+
} else if (strcmp(presentMode.c_str(), "immediate") == 0) {
|
|
153
|
+
config.presentMode = CanvasGPUPresentMode::CanvasGPUPresentModeImmediate;
|
|
154
|
+
} else if (strcmp(presentMode.c_str(), "mailbox") == 0) {
|
|
155
|
+
config.presentMode = CanvasGPUPresentMode::CanvasGPUPresentModeMailbox;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
} else if (presentModeValue->IsInt32()) {
|
|
159
|
+
config.presentMode = (CanvasGPUPresentMode) presentModeValue->Int32Value(
|
|
160
|
+
context).ToChecked();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
v8::Local<v8::Value> alphaModeValue;
|
|
166
|
+
|
|
167
|
+
if (options->Get(context, ConvertToV8String(isolate, "alphaMode")).ToLocal(
|
|
168
|
+
&alphaModeValue)) {
|
|
169
|
+
if (alphaModeValue->IsString()) {
|
|
170
|
+
auto alphaMode = ConvertFromV8String(isolate, alphaModeValue);
|
|
171
|
+
if (strcmp(alphaMode.c_str(), "premultiplied") == 0) {
|
|
172
|
+
config.alphaMode = CanvasGPUSurfaceAlphaMode::CanvasGPUSurfaceAlphaModePreMultiplied;
|
|
173
|
+
} else if (strcmp(alphaMode.c_str(), "opaque") == 0) {
|
|
174
|
+
config.alphaMode = CanvasGPUSurfaceAlphaMode::CanvasGPUSurfaceAlphaModeOpaque;
|
|
175
|
+
} else if (strcmp(alphaMode.c_str(), "postmultiplied") == 0) {
|
|
176
|
+
config.alphaMode = CanvasGPUSurfaceAlphaMode::CanvasGPUSurfaceAlphaModePostMultiplied;
|
|
177
|
+
} else if (strcmp(alphaMode.c_str(), "inherit") == 0) {
|
|
178
|
+
config.alphaMode = CanvasGPUSurfaceAlphaMode::CanvasGPUSurfaceAlphaModeInherit;
|
|
179
|
+
} else if (strcmp(alphaMode.c_str(), "auto") == 0) {
|
|
180
|
+
config.alphaMode = CanvasGPUSurfaceAlphaMode::CanvasGPUSurfaceAlphaModeAuto;
|
|
181
|
+
}
|
|
182
|
+
} else if (alphaModeValue->IsInt32()) {
|
|
183
|
+
config.alphaMode = (CanvasGPUSurfaceAlphaMode) alphaModeValue->Int32Value(
|
|
184
|
+
context).ToChecked();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
v8::Local<v8::Value> sizeValue;
|
|
191
|
+
options->Get(context, ConvertToV8String(isolate, "size")).ToLocal(
|
|
192
|
+
&usageValue);
|
|
193
|
+
|
|
194
|
+
CanvasExtent3d size = ParseExtent3d(isolate, sizeValue);
|
|
195
|
+
|
|
196
|
+
if (size.width > 0) {
|
|
197
|
+
config.size = &size;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
canvas_native_webgpu_context_configure(ptr->GetContext(), device->GetGPUDevice(), &config);
|
|
201
|
+
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
void GPUCanvasContextImpl::UnConfigure(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
205
|
+
GPUCanvasContextImpl *ptr = GetPointer(args.This());
|
|
206
|
+
if (ptr == nullptr) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// canvas_native_webgpu_context_unconfigure(ptr->GetContext());
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
void GPUCanvasContextImpl::GetCurrentTexture(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
215
|
+
GPUCanvasContextImpl *ptr = GetPointer(args.This());
|
|
216
|
+
auto isolate = args.GetIsolate();
|
|
217
|
+
if (ptr == nullptr) {
|
|
218
|
+
args.GetReturnValue().SetUndefined();
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
auto ctx = ptr->GetContext();
|
|
223
|
+
|
|
224
|
+
auto texture = canvas_native_webgpu_context_get_current_texture(ctx);
|
|
225
|
+
|
|
226
|
+
if (texture != nullptr) {
|
|
227
|
+
auto textureImpl = new GPUTextureImpl(texture);
|
|
228
|
+
auto ret = GPUTextureImpl::NewInstance(isolate, textureImpl);
|
|
229
|
+
args.GetReturnValue().Set(ret);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
args.GetReturnValue().SetUndefined();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
void GPUCanvasContextImpl::PresentSurface(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
237
|
+
GPUCanvasContextImpl *ptr = GetPointer(args.This());
|
|
238
|
+
if (ptr == nullptr) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
auto textureVal = args[0];
|
|
242
|
+
if (!textureVal.IsEmpty() && textureVal->IsObject()) {
|
|
243
|
+
auto texture = GPUTextureImpl::GetPointer(textureVal.As<v8::Object>());
|
|
244
|
+
if (texture != nullptr) {
|
|
245
|
+
auto ctx = ptr->GetContext();
|
|
246
|
+
|
|
247
|
+
canvas_native_webgpu_context_present_surface(ctx, texture->GetTexture());
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
void GPUCanvasContextImpl::GetCapabilities(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
254
|
+
GPUCanvasContextImpl *ptr = GetPointer(args.This());
|
|
255
|
+
if (ptr == nullptr) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
auto isolate = args.GetIsolate();
|
|
259
|
+
auto context = isolate->GetCurrentContext();
|
|
260
|
+
auto adapterVal = args[0];
|
|
261
|
+
auto ret = v8::Object::New(isolate);
|
|
262
|
+
|
|
263
|
+
if (!adapterVal.IsEmpty() && adapterVal->IsObject()) {
|
|
264
|
+
auto adapter = GPUAdapterImpl::GetPointer(adapterVal.As<v8::Object>());
|
|
265
|
+
auto ctx = ptr->GetContext();
|
|
266
|
+
|
|
267
|
+
if (adapter != nullptr) {
|
|
268
|
+
auto cap = canvas_native_webgpu_context_get_capabilities(ctx, adapter->GetGPUAdapter());
|
|
269
|
+
auto formats_len = canvas_native_string_buffer_get_length(cap->formats);
|
|
270
|
+
auto formats = v8::Array::New(isolate, (int) formats_len);
|
|
271
|
+
for (int i = 0; i < formats_len; i++) {
|
|
272
|
+
auto format = canvas_native_string_buffer_get_value_at(cap->formats, i);
|
|
273
|
+
formats->Set(context, i, ConvertToV8String(isolate, format));
|
|
274
|
+
canvas_native_string_destroy(format);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
auto present_modes_len = canvas_native_string_buffer_get_length(cap->present_modes);
|
|
278
|
+
auto present_modes = v8::Array::New(isolate, (int) present_modes_len);
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
for (int i = 0; i < present_modes_len; i++) {
|
|
282
|
+
auto mode = canvas_native_string_buffer_get_value_at(cap->present_modes, i);
|
|
283
|
+
present_modes->Set(context, i, ConvertToV8String(isolate, mode));
|
|
284
|
+
canvas_native_string_destroy(mode);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
auto alpha_modes_len = canvas_native_string_buffer_get_length(cap->alpha_modes);
|
|
288
|
+
auto alpha_modes = v8::Array::New(isolate, (int) alpha_modes_len);
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
for (int i = 0; i < alpha_modes_len; i++) {
|
|
292
|
+
auto mode = canvas_native_string_buffer_get_value_at(cap->alpha_modes, i);
|
|
293
|
+
alpha_modes->Set(context, i, ConvertToV8String(isolate, mode));
|
|
294
|
+
canvas_native_string_destroy(mode);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
ret->Set(context, ConvertToV8String(isolate, "format"), formats);
|
|
298
|
+
ret->Set(context, ConvertToV8String(isolate, "presentModes"), present_modes);
|
|
299
|
+
ret->Set(context, ConvertToV8String(isolate, "alphaModes"), alpha_modes);
|
|
300
|
+
ret->Set(context, ConvertToV8String(isolate, "usages"),
|
|
301
|
+
v8::Uint32::NewFromUnsigned(isolate, cap->usages));
|
|
302
|
+
|
|
303
|
+
canvas_native_webgpu_struct_surface_capabilities_release(cap);
|
|
304
|
+
|
|
305
|
+
args.GetReturnValue().Set(ret);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
ret->Set(context, ConvertToV8String(isolate, "format"), v8::Array::New(isolate));
|
|
313
|
+
ret->Set(context, ConvertToV8String(isolate, "presentModes"), v8::Array::New(isolate));
|
|
314
|
+
ret->Set(context, ConvertToV8String(isolate, "alphaModes"), v8::Array::New(isolate));
|
|
315
|
+
ret->Set(context, ConvertToV8String(isolate, "usages"), v8::Uint32::New(isolate, 0));
|
|
316
|
+
args.GetReturnValue().Set(ret);
|
|
317
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 20/06/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#ifndef CANVAS_ANDROID_GPUCANVASCONTEXTIMPL_H
|
|
6
|
+
#define CANVAS_ANDROID_GPUCANVASCONTEXTIMPL_H
|
|
7
|
+
|
|
8
|
+
#include "Helpers.h"
|
|
9
|
+
#include "ObjectWrapperImpl.h"
|
|
10
|
+
#include "GPUDeviceImpl.h"
|
|
11
|
+
#include "GPUTextureImpl.h"
|
|
12
|
+
|
|
13
|
+
class GPUCanvasContextImpl : ObjectWrapperImpl {
|
|
14
|
+
public:
|
|
15
|
+
explicit GPUCanvasContextImpl(const CanvasGPUCanvasContext *context);
|
|
16
|
+
|
|
17
|
+
~GPUCanvasContextImpl() {
|
|
18
|
+
canvas_native_webgpu_context_release(this->context_);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const CanvasGPUCanvasContext *GetContext();
|
|
22
|
+
|
|
23
|
+
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
24
|
+
|
|
25
|
+
static GPUCanvasContextImpl *GetPointer(const v8::Local<v8::Object> &object);
|
|
26
|
+
|
|
27
|
+
static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
|
|
28
|
+
|
|
29
|
+
static v8::Local<v8::Object> NewInstance(v8::Isolate *isolate, GPUCanvasContextImpl *ctx) {
|
|
30
|
+
auto context = isolate->GetCurrentContext();
|
|
31
|
+
v8::EscapableHandleScope scope(isolate);
|
|
32
|
+
auto object = GPUCanvasContextImpl::GetCtor(isolate)->GetFunction(
|
|
33
|
+
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
34
|
+
SetNativeType(object, NativeType::GPUCanvasContext);
|
|
35
|
+
object->SetAlignedPointerInInternalField(0, ctx);
|
|
36
|
+
ctx->BindFinalizer(isolate, object);
|
|
37
|
+
return scope.Escape(object);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static void Configure(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
41
|
+
|
|
42
|
+
static void UnConfigure(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
43
|
+
|
|
44
|
+
static void GetCurrentTexture(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
45
|
+
|
|
46
|
+
static void PresentSurface(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
47
|
+
|
|
48
|
+
static void GetCapabilities(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
49
|
+
|
|
50
|
+
private:
|
|
51
|
+
const CanvasGPUCanvasContext *context_;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
#endif //CANVAS_ANDROID_GPUCANVASCONTEXTIMPL_H
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 01/07/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#include "GPUCommandBufferImpl.h"
|
|
6
|
+
#include "Caches.h"
|
|
7
|
+
|
|
8
|
+
GPUCommandBufferImpl::GPUCommandBufferImpl(const CanvasGPUCommandBuffer *commandBuffer) : commandBuffer_(
|
|
9
|
+
commandBuffer) {}
|
|
10
|
+
|
|
11
|
+
const CanvasGPUCommandBuffer *GPUCommandBufferImpl::GetGPUCommandBuffer() {
|
|
12
|
+
return this->commandBuffer_;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
void GPUCommandBufferImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
17
|
+
v8::Locker locker(isolate);
|
|
18
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
19
|
+
v8::HandleScope handle_scope(isolate);
|
|
20
|
+
|
|
21
|
+
auto ctor = GetCtor(isolate);
|
|
22
|
+
auto context = isolate->GetCurrentContext();
|
|
23
|
+
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
24
|
+
|
|
25
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "GPUCommandBuffer"), func).FromJust();;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
GPUCommandBufferImpl *GPUCommandBufferImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
29
|
+
auto ptr = object->GetAlignedPointerFromInternalField(0);
|
|
30
|
+
if (ptr == nullptr) {
|
|
31
|
+
return nullptr;
|
|
32
|
+
}
|
|
33
|
+
return static_cast<GPUCommandBufferImpl *>(ptr);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
v8::Local<v8::FunctionTemplate> GPUCommandBufferImpl::GetCtor(v8::Isolate *isolate) {
|
|
37
|
+
auto cache = Caches::Get(isolate);
|
|
38
|
+
auto ctor = cache->GPUCommandBufferTmpl.get();
|
|
39
|
+
if (ctor != nullptr) {
|
|
40
|
+
return ctor->Get(isolate);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
44
|
+
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(2);
|
|
45
|
+
ctorTmpl->SetClassName(ConvertToV8String(isolate, "GPUCommandBuffer"));
|
|
46
|
+
|
|
47
|
+
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
48
|
+
tmpl->SetInternalFieldCount(2);
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
cache->GPUCommandBufferTmpl =
|
|
52
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
53
|
+
return ctorTmpl;
|
|
54
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 01/07/2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#ifndef CANVAS_ANDROID_GPUCOMMANDBUFFERIMPL_H
|
|
6
|
+
#define CANVAS_ANDROID_GPUCOMMANDBUFFERIMPL_H
|
|
7
|
+
|
|
8
|
+
#include "Common.h"
|
|
9
|
+
#include "Helpers.h"
|
|
10
|
+
#include "ObjectWrapperImpl.h"
|
|
11
|
+
|
|
12
|
+
class GPUCommandBufferImpl : ObjectWrapperImpl {
|
|
13
|
+
public:
|
|
14
|
+
explicit GPUCommandBufferImpl(const CanvasGPUCommandBuffer *commandBuffer);
|
|
15
|
+
|
|
16
|
+
~GPUCommandBufferImpl() {
|
|
17
|
+
canvas_native_webgpu_command_buffer_release(this->commandBuffer_);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const CanvasGPUCommandBuffer *GetGPUCommandBuffer();
|
|
21
|
+
|
|
22
|
+
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
23
|
+
|
|
24
|
+
static GPUCommandBufferImpl *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, GPUCommandBufferImpl *commandBuffer) {
|
|
30
|
+
auto context = isolate->GetCurrentContext();
|
|
31
|
+
v8::EscapableHandleScope scope(isolate);
|
|
32
|
+
auto object = GPUCommandBufferImpl::GetCtor(isolate)->GetFunction(
|
|
33
|
+
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
34
|
+
SetNativeType(object, NativeType::GPUCommandBuffer);
|
|
35
|
+
object->SetAlignedPointerInInternalField(0, commandBuffer);
|
|
36
|
+
commandBuffer->BindFinalizer(isolate, object);
|
|
37
|
+
return scope.Escape(object);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private:
|
|
41
|
+
const CanvasGPUCommandBuffer *commandBuffer_;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
#endif //CANVAS_ANDROID_GPUCOMMANDBUFFERIMPL_H
|