@nativescript/canvas 2.0.0-webgpu.1 → 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/Canvas/common.d.ts +2 -16
- package/Canvas/common.js +1 -62
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +6 -7
- package/Canvas/index.android.js +87 -42
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +7 -8
- package/Canvas/index.ios.d.ts +3 -2
- package/Canvas/index.ios.js +87 -46
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.js +71 -72
- package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
- package/Canvas2D/DOMMatrix/index.js +1 -1
- package/Canvas2D/DOMMatrix/index.js.map +1 -1
- package/Canvas2D/ImageData/index.js.map +1 -1
- package/Canvas2D/Path2D/index.js.map +1 -1
- package/Dom/Dom.js +8 -1
- package/Dom/Dom.js.map +1 -1
- package/Dom/Group.js.map +1 -1
- package/Dom/Image.d.ts +4 -1
- package/Dom/Image.js +16 -2
- package/Dom/Image.js.map +1 -1
- package/Dom/Paint.js.map +1 -1
- package/Dom/Text.js.map +1 -1
- package/Dom/shaders/LinearGradient.js.map +1 -1
- package/Dom/shaders/TwoPointConicalGradient.js.map +1 -1
- package/Dom/shapes/Atlas.js.map +1 -1
- package/Dom/shapes/Circle.js.map +1 -1
- package/Dom/shapes/Line.js.map +1 -1
- package/Dom/shapes/Oval.js.map +1 -1
- package/Dom/shapes/Path.js.map +1 -1
- package/Dom/shapes/Rect.js.map +1 -1
- package/Dom/shapes/RoundedRect.js.map +1 -1
- package/Dom/shapes/index.js.map +1 -1
- package/ImageAsset/index.d.ts +3 -1
- package/ImageAsset/index.js +38 -6
- package/ImageAsset/index.js.map +1 -1
- package/ImageBitmap/index.js +3 -3
- package/ImageBitmap/index.js.map +1 -1
- package/README.md +64 -3
- package/TextDecoder/index.js +3 -3
- package/TextDecoder/index.js.map +1 -1
- package/TextEncoder/index.js +3 -3
- package/TextEncoder/index.js.map +1 -1
- package/WebGL/WebGLExtensions/index.js +5 -5
- package/WebGL/WebGLExtensions/index.js.map +1 -1
- package/WebGL/WebGLRenderingContext/common.js.map +1 -1
- package/WebGL/WebGLRenderingContext/index.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
- package/WebGPU/Constants.js.map +1 -1
- package/WebGPU/GPU.js.map +1 -1
- package/WebGPU/GPUAdapter.js.map +1 -1
- package/WebGPU/GPUAdapterInfo.js.map +1 -1
- package/WebGPU/GPUBindGroup.js.map +1 -1
- package/WebGPU/GPUBindGroupLayout.js.map +1 -1
- package/WebGPU/GPUBuffer.js +5 -1
- package/WebGPU/GPUBuffer.js.map +1 -1
- package/WebGPU/GPUCanvasContext.js.map +1 -1
- package/WebGPU/GPUCommandBuffer.js.map +1 -1
- package/WebGPU/GPUCommandEncoder.js.map +1 -1
- package/WebGPU/GPUComputePassEncoder.js.map +1 -1
- package/WebGPU/GPUComputePipeline.js.map +1 -1
- package/WebGPU/GPUDevice.d.ts +2 -2
- package/WebGPU/GPUDevice.js +4 -3
- package/WebGPU/GPUDevice.js.map +1 -1
- package/WebGPU/GPUExternalTexture.js.map +1 -1
- package/WebGPU/GPUPipelineLayout.js.map +1 -1
- package/WebGPU/GPUQuerySet.js.map +1 -1
- package/WebGPU/GPUQueue.js.map +1 -1
- package/WebGPU/GPURenderBundle.js.map +1 -1
- package/WebGPU/GPURenderBundleEncoder.js.map +1 -1
- package/WebGPU/GPURenderPassEncoder.js +2 -2
- package/WebGPU/GPURenderPassEncoder.js.map +1 -1
- package/WebGPU/GPURenderPipeline.js.map +1 -1
- package/WebGPU/GPUSampler.js.map +1 -1
- package/WebGPU/GPUShaderModule.js.map +1 -1
- package/WebGPU/GPUTexture.js.map +1 -1
- package/WebGPU/GPUTextureView.js.map +1 -1
- package/WebGPU/Types.d.ts +27 -27
- package/WebGPU/Utils.d.ts +1 -1
- package/WebGPU/Utils.js.map +1 -1
- package/angular/{esm2020 → esm2022}/index.mjs +5 -5
- package/angular/{fesm2015 → fesm2022}/nativescript-canvas-angular.mjs +4 -4
- package/angular/{fesm2020 → fesm2022}/nativescript-canvas-angular.mjs.map +1 -1
- package/angular/package.json +4 -10
- package/helpers.js.map +1 -1
- package/package.json +2 -2
- 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 +21 -9
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2049 -2061
- 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 +752 -108
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +35 -9
- 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 +35 -9
- 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 +644 -602
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +42 -18
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2049 -2061
- 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 +752 -108
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +35 -9
- 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 +35 -9
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +752 -108
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +35 -9
- 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 +35 -9
- 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 +24 -24
- 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 -604
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +684 -638
- package/platforms/ios/src/NSOperationQueueWrapper.h +2 -0
- package/platforms/ios/src/cpp/AsyncCallback.h +206 -0
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +13 -13
- package/platforms/ios/src/cpp/Helpers.h +2 -164
- package/platforms/ios/src/cpp/ImageAssetImpl.cpp +13 -13
- package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +1 -1
- package/platforms/ios/src/cpp/ImageBitmapImpl.h +2 -1
- package/platforms/ios/src/cpp/JSIReadFileCallback.h +4 -4
- package/platforms/ios/src/cpp/NativeType.h +87 -0
- package/platforms/ios/src/cpp/ObjectWrapperImpl.h +50 -0
- package/platforms/ios/src/cpp/OneByteStringResource.cpp +2 -2
- package/platforms/ios/src/cpp/PromiseCallback.h +198 -0
- package/platforms/ios/src/cpp/RafImpl.h +2 -2
- package/platforms/ios/src/cpp/TextDecoderImpl.cpp +0 -6
- package/platforms/ios/src/cpp/TextDecoderImpl.h +3 -3
- package/platforms/ios/src/cpp/TextEncoderImpl.cpp +1 -1
- package/platforms/ios/src/cpp/TextEncoderImpl.h +3 -3
- package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +8 -7
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +1 -1
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +3 -3
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +145 -75
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +74 -20
- package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +5 -6
- package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +4 -4
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +10 -10
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +2 -2
- package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +6 -3
- package/platforms/ios/src/cpp/canvas2d/Path2D.h +2 -2
- package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.h +3 -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.cpp +8 -8
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +1 -1
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.cpp +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.cpp +722 -722
- 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 +124 -58
- 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.cpp +11 -11
- 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 +99 -73
- package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +2 -2
- package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +54 -41
- 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 +4 -3
- 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
- package/react/index.d.ts +1 -1
- package/utils.js.map +1 -1
- package/angular/fesm2015/nativescript-canvas-angular.mjs.map +0 -1
- package/angular/fesm2020/nativescript-canvas-angular.mjs +0 -24
- package/typings/objc!CanvasNative.d.ts +0 -2038
- package/typings/objc!CanvasNative.js +0 -1
- package/typings/objc!CanvasNative.js.map +0 -1
- /package/angular/{esm2020 → esm2022}/nativescript-canvas-angular.mjs +0 -0
|
@@ -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
|
|
@@ -324,7 +324,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
324
324
|
|
|
325
325
|
auto asset = canvas_native_image_asset_create();
|
|
326
326
|
|
|
327
|
-
auto shared_asset =
|
|
327
|
+
auto shared_asset = canvas_native_image_asset_reference(asset);
|
|
328
328
|
|
|
329
329
|
auto ret = new ImageBitmapImpl(asset);
|
|
330
330
|
|
|
@@ -401,7 +401,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
401
401
|
options.resizeHeight,
|
|
402
402
|
shared_asset);
|
|
403
403
|
|
|
404
|
-
|
|
404
|
+
canvas_native_image_asset_release(shared_asset);
|
|
405
405
|
|
|
406
406
|
write(jsi_callback->fd_[1],
|
|
407
407
|
&done,
|
|
@@ -440,7 +440,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
440
440
|
options.resizeHeight,
|
|
441
441
|
shared_asset);
|
|
442
442
|
|
|
443
|
-
|
|
443
|
+
canvas_native_image_asset_release(shared_asset);
|
|
444
444
|
|
|
445
445
|
write(jsi_callback->fd_[1],
|
|
446
446
|
&done,
|
|
@@ -479,7 +479,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
479
479
|
options.resizeHeight,
|
|
480
480
|
shared_asset);
|
|
481
481
|
|
|
482
|
-
|
|
482
|
+
canvas_native_image_asset_release(shared_asset);
|
|
483
483
|
|
|
484
484
|
|
|
485
485
|
auto main_task = [jsi_callback, current_queue, done]() {
|
|
@@ -553,7 +553,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
553
553
|
options.resizeHeight,
|
|
554
554
|
shared_asset);
|
|
555
555
|
|
|
556
|
-
|
|
556
|
+
canvas_native_image_asset_release(shared_asset);
|
|
557
557
|
|
|
558
558
|
auto main_task = [jsi_callback, current_queue, done]() {
|
|
559
559
|
|
|
@@ -601,7 +601,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
601
601
|
} else if (len == 5 || len == 6) {
|
|
602
602
|
auto asset = canvas_native_image_asset_create();
|
|
603
603
|
|
|
604
|
-
auto shared_asset =
|
|
604
|
+
auto shared_asset = canvas_native_image_asset_reference(asset);
|
|
605
605
|
|
|
606
606
|
auto ret = new ImageBitmapImpl(asset);
|
|
607
607
|
|
|
@@ -686,7 +686,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
686
686
|
options.resizeWidth,
|
|
687
687
|
options.resizeHeight, shared_asset);
|
|
688
688
|
|
|
689
|
-
|
|
689
|
+
canvas_native_image_asset_release(shared_asset);
|
|
690
690
|
|
|
691
691
|
|
|
692
692
|
write(jsi_callback->fd_[1],
|
|
@@ -736,7 +736,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
736
736
|
options.resizeWidth,
|
|
737
737
|
options.resizeHeight, shared_asset);
|
|
738
738
|
|
|
739
|
-
|
|
739
|
+
canvas_native_image_asset_release(shared_asset);
|
|
740
740
|
|
|
741
741
|
|
|
742
742
|
write(jsi_callback->fd_[1],
|
|
@@ -786,7 +786,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
786
786
|
options.resizeWidth,
|
|
787
787
|
options.resizeHeight, shared_asset);
|
|
788
788
|
|
|
789
|
-
|
|
789
|
+
canvas_native_image_asset_release(shared_asset);
|
|
790
790
|
|
|
791
791
|
|
|
792
792
|
auto main_task = [jsi_callback, current_queue, done]() {
|
|
@@ -871,7 +871,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
871
871
|
options.resizeWidth,
|
|
872
872
|
options.resizeHeight, shared_asset);
|
|
873
873
|
|
|
874
|
-
|
|
874
|
+
canvas_native_image_asset_release(shared_asset);
|
|
875
875
|
|
|
876
876
|
auto main_task = [jsi_callback, current_queue, done]() {
|
|
877
877
|
|
|
@@ -927,7 +927,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
927
927
|
}
|
|
928
928
|
}
|
|
929
929
|
|
|
930
|
-
auto type = GetNativeType(image);
|
|
930
|
+
auto type = ObjectWrapperImpl::GetNativeType(image);
|
|
931
931
|
|
|
932
932
|
if (len == 1 || len == 2) {
|
|
933
933
|
if (len == 2) {
|
|
@@ -1183,7 +1183,7 @@ void CanvasJSIModule::ReadFile(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
1183
1183
|
|
|
1184
1184
|
jsi_callback->SetError(const_cast<char *>(error));
|
|
1185
1185
|
}
|
|
1186
|
-
|
|
1186
|
+
canvas_native_helper_release(ret);
|
|
1187
1187
|
|
|
1188
1188
|
write(jsi_callback->fd_[1],
|
|
1189
1189
|
&done,
|
|
@@ -1221,7 +1221,7 @@ void CanvasJSIModule::ReadFile(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
1221
1221
|
jsi_callback->SetError((char*)error);
|
|
1222
1222
|
}
|
|
1223
1223
|
|
|
1224
|
-
|
|
1224
|
+
canvas_native_helper_release(ret);
|
|
1225
1225
|
|
|
1226
1226
|
auto main_task = [jsi_callback, current_queue, queue, done]() {
|
|
1227
1227
|
|
|
@@ -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,
|
|
@@ -15,7 +15,7 @@ ImageAssetImpl::ImageAssetImpl(ImageAsset *asset) : asset_(asset) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
ImageAssetImpl::~ImageAssetImpl() {
|
|
18
|
-
|
|
18
|
+
canvas_native_image_asset_release(this->GetImageAsset());
|
|
19
19
|
asset_ = nullptr;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -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);
|
|
@@ -179,7 +179,7 @@ ImageAssetImpl::GetReference(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
179
179
|
auto ptr = GetPointer(args.This());
|
|
180
180
|
if (ptr != nullptr) {
|
|
181
181
|
auto isolate = args.GetIsolate();
|
|
182
|
-
auto reference =
|
|
182
|
+
auto reference = canvas_native_image_asset_reference(ptr->GetImageAsset());
|
|
183
183
|
auto ret = std::to_string(canvas_native_image_asset_get_addr(reference));
|
|
184
184
|
args.GetReturnValue().Set(ConvertToV8String(isolate, ret));
|
|
185
185
|
return;
|
|
@@ -230,7 +230,7 @@ void ImageAssetImpl::FromUrlCb(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
230
230
|
|
|
231
231
|
auto url = ConvertFromV8String(isolate, args[0]);
|
|
232
232
|
|
|
233
|
-
auto asset =
|
|
233
|
+
auto asset = canvas_native_image_asset_reference(ptr->asset_);
|
|
234
234
|
|
|
235
235
|
auto callback = args[1].As<v8::Function>();
|
|
236
236
|
|
|
@@ -277,7 +277,7 @@ void ImageAssetImpl::FromUrlCb(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
277
277
|
const std::string &url) {
|
|
278
278
|
auto done = canvas_native_image_asset_load_from_url(asset, url.c_str());
|
|
279
279
|
|
|
280
|
-
|
|
280
|
+
canvas_native_image_asset_release(asset);
|
|
281
281
|
|
|
282
282
|
write(jsi_callback->fd_[1],
|
|
283
283
|
&done,
|
|
@@ -346,7 +346,7 @@ void ImageAssetImpl::FromUrlCb(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
346
346
|
auto task = [jsi_callback, current_queue, queue, asset, url]() {
|
|
347
347
|
|
|
348
348
|
auto done = canvas_native_image_asset_load_from_url(asset, url.c_str());
|
|
349
|
-
|
|
349
|
+
canvas_native_image_asset_release(asset);
|
|
350
350
|
|
|
351
351
|
auto main_task = [jsi_callback, current_queue, queue, url, done]() {
|
|
352
352
|
|
|
@@ -412,7 +412,7 @@ void ImageAssetImpl::FromFileCb(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
412
412
|
|
|
413
413
|
auto path = ConvertFromV8String(isolate, args[0]);
|
|
414
414
|
|
|
415
|
-
auto asset =
|
|
415
|
+
auto asset = canvas_native_image_asset_reference(
|
|
416
416
|
ptr->GetImageAsset());
|
|
417
417
|
|
|
418
418
|
auto callback = args[1].As<v8::Function>();
|
|
@@ -461,7 +461,7 @@ void ImageAssetImpl::FromFileCb(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
461
461
|
|
|
462
462
|
auto done = canvas_native_image_asset_load_from_path(asset, path.c_str());
|
|
463
463
|
|
|
464
|
-
|
|
464
|
+
canvas_native_image_asset_release(asset);
|
|
465
465
|
|
|
466
466
|
write(jsi_callback->fd_[1],
|
|
467
467
|
&done,
|
|
@@ -482,7 +482,7 @@ void ImageAssetImpl::FromFileCb(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
482
482
|
|
|
483
483
|
auto done = canvas_native_image_asset_load_from_path(asset, path.c_str());
|
|
484
484
|
|
|
485
|
-
|
|
485
|
+
canvas_native_image_asset_release(asset);
|
|
486
486
|
|
|
487
487
|
auto main_task = [jsi_callback, current_queue, queue, done]() {
|
|
488
488
|
|
|
@@ -562,7 +562,7 @@ void ImageAssetImpl::FromBytesCb(const v8::FunctionCallbackInfo<v8::Value> &args
|
|
|
562
562
|
|
|
563
563
|
auto data = (uint8_t *) bytes->GetBackingStore()->Data();
|
|
564
564
|
|
|
565
|
-
auto asset =
|
|
565
|
+
auto asset = canvas_native_image_asset_reference(ptr->GetImageAsset());
|
|
566
566
|
|
|
567
567
|
auto callback = args[1].As<v8::Function>();
|
|
568
568
|
|
|
@@ -608,7 +608,7 @@ void ImageAssetImpl::FromBytesCb(const v8::FunctionCallbackInfo<v8::Value> &args
|
|
|
608
608
|
|
|
609
609
|
auto done = canvas_native_image_asset_load_from_raw(asset, data, size);
|
|
610
610
|
|
|
611
|
-
|
|
611
|
+
canvas_native_image_asset_release(asset);
|
|
612
612
|
|
|
613
613
|
write(jsi_callback->fd_[1],
|
|
614
614
|
&done,
|
|
@@ -631,7 +631,7 @@ void ImageAssetImpl::FromBytesCb(const v8::FunctionCallbackInfo<v8::Value> &args
|
|
|
631
631
|
|
|
632
632
|
auto done = canvas_native_image_asset_load_from_raw(asset, data, size);
|
|
633
633
|
|
|
634
|
-
|
|
634
|
+
canvas_native_image_asset_release(asset);
|
|
635
635
|
|
|
636
636
|
auto main_task = [jsi_callback, current_queue, queue, done]() {
|
|
637
637
|
|
|
@@ -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
|
|
|
@@ -38,9 +38,9 @@ struct JSIReadFileCallback {
|
|
|
38
38
|
|
|
39
39
|
~JSIReadFileCallback() {
|
|
40
40
|
callback_.Reset();
|
|
41
|
-
|
|
41
|
+
canvas_native_u8_buffer_release(data_);
|
|
42
42
|
data_ = nullptr;
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
canvas_native_string_destroy(error_);
|
|
45
45
|
error_ = nullptr;
|
|
46
46
|
}
|
|
@@ -86,9 +86,9 @@ struct JSIReadFileCallback {
|
|
|
86
86
|
close(fd_[0]);
|
|
87
87
|
ALooper_release(looper_);
|
|
88
88
|
callback_.Reset();
|
|
89
|
-
|
|
89
|
+
canvas_native_u8_buffer_release(data_);
|
|
90
90
|
data_ = nullptr;
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
canvas_native_string_destroy(error_);
|
|
93
93
|
error_ = nullptr;
|
|
94
94
|
}
|