@nativescript/canvas 2.0.0-alpha.20 → 2.0.0-alpha.21
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 -0
- package/Canvas/common.js +6 -0
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +0 -2
- package/Canvas/index.android.js +8 -22
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +7 -0
- package/Canvas/index.ios.d.ts +0 -2
- package/Canvas/index.ios.js +7 -26
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas2D/CanvasGradient/index.d.ts +1 -3
- package/Canvas2D/CanvasGradient/index.js +1 -10
- package/Canvas2D/CanvasGradient/index.js.map +1 -1
- package/Canvas2D/CanvasPattern/index.d.ts +1 -3
- package/Canvas2D/CanvasPattern/index.js +1 -10
- package/Canvas2D/CanvasPattern/index.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.d.ts +0 -2
- package/Canvas2D/CanvasRenderingContext2D/index.js +120 -138
- package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
- package/Canvas2D/DOMMatrix/index.js +3 -3
- package/Canvas2D/DOMMatrix/index.js.map +1 -1
- package/Canvas2D/ImageData/index.js +5 -5
- package/Canvas2D/ImageData/index.js.map +1 -1
- package/Canvas2D/Path2D/index.d.ts +0 -2
- package/Canvas2D/Path2D/index.js +34 -39
- package/Canvas2D/Path2D/index.js.map +1 -1
- package/ImageAsset/index.d.ts +2 -2
- package/ImageAsset/index.js +33 -37
- package/ImageAsset/index.js.map +1 -1
- package/ImageBitmap/index.d.ts +0 -2
- package/ImageBitmap/index.js +23 -29
- package/ImageBitmap/index.js.map +1 -1
- package/SVG/SVG.js +1 -1
- package/TextDecoder/index.d.ts +0 -2
- package/TextDecoder/index.js +3 -12
- package/TextDecoder/index.js.map +1 -1
- package/TextEncoder/index.d.ts +0 -2
- package/TextEncoder/index.js +4 -13
- package/TextEncoder/index.js.map +1 -1
- package/WebGL/WebGLExtensions/index.d.ts +0 -9
- package/WebGL/WebGLExtensions/index.js +17 -74
- package/WebGL/WebGLExtensions/index.js.map +1 -1
- package/WebGL/WebGLRenderingContext/common.d.ts +0 -2
- package/WebGL/WebGLRenderingContext/common.js +0 -10
- package/WebGL/WebGLRenderingContext/common.js.map +1 -1
- package/WebGL/WebGLRenderingContext/index.js +159 -298
- package/WebGL/WebGLRenderingContext/index.js.map +1 -1
- package/WebGL2/WebGL2RenderingContext/index.js +107 -195
- package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
- package/angular/esm2020/index.mjs +5 -5
- package/angular/fesm2015/nativescript-canvas-angular.mjs +4 -4
- package/angular/fesm2015/nativescript-canvas-angular.mjs.map +1 -1
- package/angular/fesm2020/nativescript-canvas-angular.mjs +4 -4
- package/angular/fesm2020/nativescript-canvas-angular.mjs.map +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/platforms/android/canvas-release.aar +0 -0
- package/platforms/android/include.gradle +15 -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 +87 -57
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative.h +10 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +142 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2589 -110
- 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 +1174 -89
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +2 -2
- 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 +2 -2
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- 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 +174 -114
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative.h +10 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +142 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2589 -110
- 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 +1174 -89
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +2 -2
- 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 +2 -2
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +1174 -89
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +2 -2
- 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 +2 -2
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +42 -31
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/Podfile +3 -0
- package/platforms/ios/build.xcconfig +3 -3
- package/platforms/ios/src/CanvasModule.h +0 -2
- package/platforms/ios/src/CanvasModule.mm +4 -4
- package/platforms/ios/src/NSOperationQueueWrapper.h +11 -0
- package/platforms/ios/src/NSOperationQueueWrapper.mm +74 -0
- package/platforms/ios/src/cpp/Caches.cpp +35 -0
- package/platforms/ios/src/cpp/Caches.h +186 -0
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +1582 -0
- package/platforms/ios/src/cpp/CanvasJSIModule.h +7 -34
- package/platforms/ios/src/cpp/Common.h +30 -0
- package/platforms/ios/src/cpp/ConcurrentMap.h +54 -0
- package/platforms/ios/src/cpp/Helpers.h +304 -38
- package/platforms/ios/src/cpp/ImageAssetImpl.cpp +802 -0
- package/platforms/ios/src/cpp/ImageAssetImpl.h +44 -12
- package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +189 -0
- package/platforms/ios/src/cpp/ImageBitmapImpl.h +22 -16
- package/platforms/ios/src/cpp/JSICallback.h +61 -5
- package/platforms/ios/src/cpp/JSIReadFileCallback.h +86 -6
- package/platforms/ios/src/cpp/JSIRuntime.cpp +21 -0
- package/platforms/ios/src/cpp/JSIRuntime.h +7 -0
- package/platforms/ios/src/cpp/OneByteStringResource.cpp +25 -0
- package/platforms/ios/src/cpp/OneByteStringResource.h +21 -0
- package/platforms/ios/src/cpp/RafImpl.cpp +8 -0
- package/platforms/ios/src/cpp/RafImpl.h +11 -8
- package/platforms/ios/src/cpp/TextDecoderImpl.cpp +188 -0
- package/platforms/ios/src/cpp/TextDecoderImpl.h +20 -14
- package/platforms/ios/src/cpp/TextEncoderImpl.cpp +139 -0
- package/platforms/ios/src/cpp/TextEncoderImpl.h +20 -11
- package/platforms/ios/src/cpp/canvas2d/CanvasGradient.cpp +71 -0
- package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +27 -13
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +89 -0
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +26 -13
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +2402 -0
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +264 -21
- package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +203 -0
- package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +26 -12
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +800 -0
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +172 -13
- package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +449 -0
- package/platforms/ios/src/cpp/canvas2d/Path2D.h +41 -12
- package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.cpp +253 -0
- package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.h +50 -12
- package/platforms/ios/src/cpp/gl.h +57 -7
- package/platforms/ios/src/cpp/gl3stub.c +425 -0
- package/platforms/ios/src/cpp/gl3stub.h +665 -0
- package/platforms/ios/src/cpp/gles3jni.h +37 -0
- package/platforms/ios/src/cpp/include/robin_hood.h +2544 -0
- package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.cpp +93 -0
- package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +33 -13
- package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +41 -6
- package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +46 -10
- package/platforms/ios/src/cpp/webgl/WebGLProgram.h +40 -5
- package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +40 -6
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +6691 -0
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +261 -390
- package/platforms/ios/src/cpp/webgl/{WebGLRenderingContextBase.mm → WebGLRenderingContextBase.cpp} +17 -16
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.h +15 -36
- package/platforms/ios/src/cpp/webgl/WebGLShader.h +40 -6
- package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.cpp +50 -0
- package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +66 -11
- package/platforms/ios/src/cpp/webgl/WebGLTexture.h +40 -6
- package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +44 -8
- package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.cpp +126 -0
- package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +25 -12
- package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.cpp +35 -0
- package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +25 -5
- package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.cpp +41 -0
- package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +25 -5
- package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.cpp +323 -0
- package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +47 -13
- package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +49 -6
- package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +37 -15
- package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +47 -6
- package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +49 -6
- package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +36 -15
- package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +44 -6
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +38 -15
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +37 -16
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +41 -6
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +40 -16
- package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.cpp +102 -0
- package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +69 -14
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +51 -8
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +49 -6
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +49 -8
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +76 -6
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +57 -6
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +53 -6
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +59 -6
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +46 -6
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.cpp +43 -0
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +126 -14
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.cpp +32 -0
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +61 -12
- package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +4517 -0
- package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +139 -343
- package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +40 -4
- package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +42 -3
- package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +44 -11
- package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +42 -4
- package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +43 -4
- package/platforms/ios/src/module.modulemap +1 -0
- package/platforms/ios/src/cpp/CanvasJSIModule.mm +0 -1105
- package/platforms/ios/src/cpp/ImageAssetImpl.mm +0 -417
- package/platforms/ios/src/cpp/ImageBitmapImpl.mm +0 -126
- package/platforms/ios/src/cpp/RafImpl.mm +0 -10
- package/platforms/ios/src/cpp/TextDecoderImpl.mm +0 -97
- package/platforms/ios/src/cpp/TextEncoderImpl.mm +0 -60
- package/platforms/ios/src/cpp/VecMutableBuffer.h +0 -46
- package/platforms/ios/src/cpp/canvas-cxx/src/lib.rs.cc +0 -6156
- package/platforms/ios/src/cpp/canvas-cxx/src/lib.rs.h +0 -2867
- package/platforms/ios/src/cpp/canvas2d/CanvasGradient.mm +0 -42
- package/platforms/ios/src/cpp/canvas2d/CanvasPattern.mm +0 -49
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.mm +0 -1972
- package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.mm +0 -68
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.mm +0 -149
- package/platforms/ios/src/cpp/canvas2d/Path2D.mm +0 -335
- package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.mm +0 -68
- package/platforms/ios/src/cpp/rust/cxx.cc +0 -793
- package/platforms/ios/src/cpp/rust/cxx.h +0 -1111
- package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.mm +0 -39
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.mm +0 -5958
- package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.mm +0 -40
- package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.mm +0 -108
- package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.mm +0 -28
- package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.mm +0 -42
- package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.mm +0 -295
- package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.mm +0 -40
- package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.mm +0 -37
- package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.mm +0 -28
- package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.mm +0 -31
- package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.mm +0 -28
- package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.mm +0 -127
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.mm +0 -45
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.mm +0 -45
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.mm +0 -31
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.mm +0 -70
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.mm +0 -47
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.mm +0 -46
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.mm +0 -49
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.mm +0 -30
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.mm +0 -177
- package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.mm +0 -64
- package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.mm +0 -4551
- /package/platforms/ios/src/cpp/{OnRafCallback.mm → OnRafCallback.cpp} +0 -0
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
#pragma once
|
|
6
6
|
#pragma process_pending_includes
|
|
7
7
|
|
|
8
|
-
#import <NativeScript/JSIRuntime.h>
|
|
9
|
-
#include "rust/cxx.h"
|
|
10
8
|
#include <vector>
|
|
11
9
|
#include <cstdint>
|
|
12
10
|
#include <memory>
|
|
@@ -14,7 +12,6 @@
|
|
|
14
12
|
#include "RafImpl.h"
|
|
15
13
|
#include "OnRafCallback.h"
|
|
16
14
|
|
|
17
|
-
#include "canvas-cxx/src/lib.rs.h"
|
|
18
15
|
#include "Helpers.h"
|
|
19
16
|
|
|
20
17
|
#include "CanvasGradient.h"
|
|
@@ -24,23 +21,274 @@
|
|
|
24
21
|
#include "ImageAssetImpl.h"
|
|
25
22
|
#include "ImageBitmapImpl.h"
|
|
26
23
|
#include "Path2D.h"
|
|
27
|
-
#include "
|
|
24
|
+
#include "WebGLRenderingContextBase.h"
|
|
25
|
+
#include "Helpers.h"
|
|
28
26
|
|
|
27
|
+
class CanvasRenderingContext2DImpl {
|
|
28
|
+
public:
|
|
29
|
+
CanvasRenderingContext2DImpl(CanvasRenderingContext2D* context);
|
|
30
|
+
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
using namespace org::nativescript::canvas;
|
|
32
|
+
static CanvasRenderingContext2DImpl *GetPointer(const v8::Local<v8::Object> &object);
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
public:
|
|
35
|
-
CanvasRenderingContext2DImpl(rust::Box<CanvasRenderingContext2D> context);
|
|
34
|
+
static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
static v8::Local<v8::Object>
|
|
37
|
+
NewInstance(v8::Isolate *isolate, CanvasRenderingContext2DImpl *renderingContext) {
|
|
38
|
+
auto context = isolate->GetCurrentContext();
|
|
39
|
+
v8::EscapableHandleScope scope(isolate);
|
|
40
|
+
auto object = CanvasRenderingContext2DImpl::GetCtor(isolate)->GetFunction(
|
|
41
|
+
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
42
|
+
SetNativeType(isolate, object, NativeType::CanvasRenderingContext2D);
|
|
43
|
+
auto ext = v8::External::New(isolate, renderingContext);
|
|
44
|
+
object->SetInternalField(0, ext);
|
|
45
|
+
return scope.Escape(object);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static void DrawPoint(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
49
|
+
|
|
50
|
+
static void DrawPoints(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
51
|
+
|
|
52
|
+
static void DrawPaint(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
static void __MakeDirty(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
56
|
+
|
|
57
|
+
static void __GetPointer(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
58
|
+
|
|
59
|
+
static void __Resize(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
60
|
+
|
|
61
|
+
static void GetFilter(v8::Local<v8::String> property,
|
|
62
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
63
|
+
|
|
64
|
+
static void SetFilter(v8::Local<v8::String> property,
|
|
65
|
+
v8::Local<v8::Value> value,
|
|
66
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
67
|
+
|
|
68
|
+
static void GetFont(v8::Local<v8::String> property,
|
|
69
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
70
|
+
|
|
71
|
+
static void SetFont(v8::Local<v8::String> property,
|
|
72
|
+
v8::Local<v8::Value> value,
|
|
73
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
74
|
+
|
|
75
|
+
static void SetGlobalAlpha(v8::Local<v8::String> property,
|
|
76
|
+
v8::Local<v8::Value> value,
|
|
77
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
78
|
+
|
|
79
|
+
static void GetGlobalAlpha(v8::Local<v8::String> property,
|
|
80
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
static void SetImageSmoothingEnabled(v8::Local<v8::String> property,
|
|
84
|
+
v8::Local<v8::Value> value,
|
|
85
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
86
|
+
|
|
87
|
+
static void GetImageSmoothingEnabled(v8::Local<v8::String> property,
|
|
88
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
89
|
+
|
|
90
|
+
static void SetImageSmoothingQuality(v8::Local<v8::String> property,
|
|
91
|
+
v8::Local<v8::Value> value,
|
|
92
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
93
|
+
|
|
94
|
+
static void GetImageSmoothingQuality(v8::Local<v8::String> property,
|
|
95
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
96
|
+
|
|
97
|
+
static void SetLineDashOffset(v8::Local<v8::String> property,
|
|
98
|
+
v8::Local<v8::Value> value,
|
|
99
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
100
|
+
|
|
101
|
+
static void GetLineDashOffset(v8::Local<v8::String> property,
|
|
102
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
103
|
+
|
|
104
|
+
static void GetLineJoin(v8::Local<v8::String> property,
|
|
105
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
106
|
+
|
|
107
|
+
static void SetLineJoin(v8::Local<v8::String> property,
|
|
108
|
+
v8::Local<v8::Value> value,
|
|
109
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
110
|
+
|
|
111
|
+
static void GetLineCap(v8::Local<v8::String> property,
|
|
112
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
113
|
+
|
|
114
|
+
static void SetLineCap(v8::Local<v8::String> property,
|
|
115
|
+
v8::Local<v8::Value> value,
|
|
116
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
117
|
+
|
|
118
|
+
static void GetMiterLimit(v8::Local<v8::String> property,
|
|
119
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
120
|
+
|
|
121
|
+
static void SetMiterLimit(v8::Local<v8::String> property,
|
|
122
|
+
v8::Local<v8::Value> value,
|
|
123
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
124
|
+
|
|
125
|
+
static void GetShadowColor(v8::Local<v8::String> property,
|
|
126
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
127
|
+
|
|
128
|
+
static void SetShadowColor(v8::Local<v8::String> property,
|
|
129
|
+
v8::Local<v8::Value> value,
|
|
130
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
131
|
+
|
|
132
|
+
static void GetShadowBlur(v8::Local<v8::String> property,
|
|
133
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
134
|
+
|
|
135
|
+
static void SetShadowBlur(v8::Local<v8::String> property,
|
|
136
|
+
v8::Local<v8::Value> value,
|
|
137
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
138
|
+
|
|
139
|
+
static void GetShadowOffsetX(v8::Local<v8::String> property,
|
|
140
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
141
|
+
|
|
142
|
+
static void SetShadowOffsetX(v8::Local<v8::String> property,
|
|
143
|
+
v8::Local<v8::Value> value,
|
|
144
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
145
|
+
|
|
146
|
+
static void GetShadowOffsetY(v8::Local<v8::String> property,
|
|
147
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
148
|
+
|
|
149
|
+
static void SetShadowOffsetY(v8::Local<v8::String> property,
|
|
150
|
+
v8::Local<v8::Value> value,
|
|
151
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
152
|
+
|
|
153
|
+
static void GetTextAlign(v8::Local<v8::String> property,
|
|
154
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
155
|
+
|
|
156
|
+
static void SetTextAlign(v8::Local<v8::String> property,
|
|
157
|
+
v8::Local<v8::Value> value,
|
|
158
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
159
|
+
|
|
160
|
+
static void GetGlobalCompositeOperation(v8::Local<v8::String> property,
|
|
161
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
162
|
+
|
|
163
|
+
static void SetGlobalCompositeOperation(v8::Local<v8::String> property,
|
|
164
|
+
v8::Local<v8::Value> value,
|
|
165
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
166
|
+
|
|
167
|
+
static void GetFillStyle(v8::Local<v8::String> property,
|
|
168
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
169
|
+
|
|
170
|
+
static void SetFillStyle(v8::Local<v8::String> property,
|
|
171
|
+
v8::Local<v8::Value> value,
|
|
172
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
173
|
+
|
|
174
|
+
static void GetStrokeStyle(v8::Local<v8::String> property,
|
|
175
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
176
|
+
|
|
177
|
+
static void SetStrokeStyle(v8::Local<v8::String> property,
|
|
178
|
+
v8::Local<v8::Value> value,
|
|
179
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
180
|
+
|
|
181
|
+
static void GetLineWidth(v8::Local<v8::String> property,
|
|
182
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
183
|
+
|
|
184
|
+
static void SetLineWidth(v8::Local<v8::String> property,
|
|
185
|
+
v8::Local<v8::Value> value,
|
|
186
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
38
187
|
|
|
39
|
-
|
|
188
|
+
static void GetLineDash(v8::Local<v8::String> property,
|
|
189
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
40
190
|
|
|
41
|
-
void
|
|
191
|
+
static void SetLineDash(v8::Local<v8::String> property,
|
|
192
|
+
v8::Local<v8::Value> value,
|
|
193
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
42
194
|
|
|
43
|
-
|
|
195
|
+
|
|
196
|
+
static void AddHitRegion(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
197
|
+
|
|
198
|
+
static void Arc(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
199
|
+
|
|
200
|
+
static void ArcTo(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
201
|
+
|
|
202
|
+
static void BeginPath(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
203
|
+
|
|
204
|
+
static void BezierCurveTo(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
205
|
+
|
|
206
|
+
static void ClearHitRegions(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
207
|
+
|
|
208
|
+
static void ClearRect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
209
|
+
|
|
210
|
+
static void Clip(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
211
|
+
|
|
212
|
+
static void ClosePath(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
213
|
+
|
|
214
|
+
static void CreateImageData(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
215
|
+
|
|
216
|
+
static void CreatePattern(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
217
|
+
|
|
218
|
+
static void CreateLinearGradient(
|
|
219
|
+
const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
220
|
+
|
|
221
|
+
static void __CreatePatternWithNative(
|
|
222
|
+
const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
223
|
+
|
|
224
|
+
static void CreateRadialGradient(
|
|
225
|
+
const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
226
|
+
|
|
227
|
+
static void DrawFocusIfNeeded(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
228
|
+
|
|
229
|
+
static void DrawImage(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
230
|
+
|
|
231
|
+
static void Ellipse(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
232
|
+
|
|
233
|
+
static void Fill(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
234
|
+
|
|
235
|
+
static void FillRect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
236
|
+
|
|
237
|
+
static void FillText(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
238
|
+
|
|
239
|
+
static void GetImageData(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
240
|
+
|
|
241
|
+
static void GetLineDash(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
242
|
+
|
|
243
|
+
static void IsPointInPath(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
244
|
+
|
|
245
|
+
static void IsPointInStroke(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
246
|
+
|
|
247
|
+
static void LineTo(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
248
|
+
|
|
249
|
+
static void MeasureText(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
250
|
+
|
|
251
|
+
static void MoveTo(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
252
|
+
|
|
253
|
+
static void PutImageData(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
254
|
+
|
|
255
|
+
static void QuadraticCurveTo(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
256
|
+
|
|
257
|
+
static void RoundRect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
258
|
+
|
|
259
|
+
static void Rect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
260
|
+
|
|
261
|
+
static void RemoveHitRegion(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
262
|
+
|
|
263
|
+
static void ResetTransform(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
264
|
+
|
|
265
|
+
static void Restore(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
266
|
+
|
|
267
|
+
static void Rotate(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
268
|
+
|
|
269
|
+
static void Save(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
270
|
+
|
|
271
|
+
static void Scale(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
272
|
+
|
|
273
|
+
static void ScrollPathIntoView(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
274
|
+
|
|
275
|
+
static void SetLineDash(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
276
|
+
|
|
277
|
+
static void SetTransform(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
278
|
+
|
|
279
|
+
static void Stroke(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
280
|
+
|
|
281
|
+
static void StrokeRect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
282
|
+
|
|
283
|
+
static void StrokeText(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
284
|
+
|
|
285
|
+
static void Transform(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
286
|
+
|
|
287
|
+
static void Translate(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
288
|
+
|
|
289
|
+
static void __ToDataURL(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
290
|
+
|
|
291
|
+
~CanvasRenderingContext2DImpl();
|
|
44
292
|
|
|
45
293
|
void UpdateInvalidateState();
|
|
46
294
|
|
|
@@ -58,17 +306,12 @@ public:
|
|
|
58
306
|
|
|
59
307
|
RafImpl *GetRaf();
|
|
60
308
|
|
|
61
|
-
CanvasRenderingContext2D
|
|
62
|
-
|
|
63
|
-
void StartRaf();
|
|
64
|
-
|
|
65
|
-
void StopRaf();
|
|
66
|
-
|
|
309
|
+
CanvasRenderingContext2D* GetContext();
|
|
67
310
|
|
|
68
311
|
private:
|
|
69
|
-
|
|
312
|
+
CanvasRenderingContext2D* context_;
|
|
70
313
|
|
|
71
|
-
int invalidateState_ = static_cast<int>(InvalidateState::
|
|
314
|
+
int invalidateState_ = static_cast<int>(InvalidateState::InvalidateStateNone);
|
|
72
315
|
|
|
73
316
|
std::shared_ptr<RafImpl> raf_;
|
|
74
317
|
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Osei Fortune on 27/03/2022.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#include "ImageDataImpl.h"
|
|
6
|
+
#include "Helpers.h"
|
|
7
|
+
#include "Caches.h"
|
|
8
|
+
|
|
9
|
+
struct ImageDataBuffer {
|
|
10
|
+
public:
|
|
11
|
+
explicit ImageDataBuffer(ImageData* imageData) : imageData_(imageData) {
|
|
12
|
+
this->slice_ = canvas_native_image_data_get_data(imageData_);
|
|
13
|
+
this->buf_ = canvas_native_u8_buffer_get_bytes_mut(slice_);
|
|
14
|
+
this->size_ = canvas_native_u8_buffer_get_length(slice_);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
size_t size() const {
|
|
18
|
+
return this->size_;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
uint8_t *data() {
|
|
22
|
+
return this->buf_;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
~ImageDataBuffer() {
|
|
26
|
+
canvas_native_u8_buffer_destroy(slice_);
|
|
27
|
+
slice_ = nullptr;
|
|
28
|
+
canvas_native_image_data_destroy(imageData_);
|
|
29
|
+
imageData_ = nullptr;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private:
|
|
33
|
+
uint8_t *buf_;
|
|
34
|
+
size_t size_;
|
|
35
|
+
ImageData* imageData_;
|
|
36
|
+
U8Buffer* slice_;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
ImageDataImpl::ImageDataImpl(ImageData* imageData) : imageData_(imageData) {}
|
|
40
|
+
|
|
41
|
+
void ImageDataImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
42
|
+
v8::Locker locker(isolate);
|
|
43
|
+
v8::Isolate::Scope isolate_scope(isolate);
|
|
44
|
+
v8::HandleScope handle_scope(isolate);
|
|
45
|
+
|
|
46
|
+
auto ctor = GetCtor(isolate);
|
|
47
|
+
auto context = isolate->GetCurrentContext();
|
|
48
|
+
auto func = ctor->GetFunction(context).ToLocalChecked();
|
|
49
|
+
|
|
50
|
+
canvasModule->Set(context, ConvertToV8String(isolate, "ImageData"), func);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
ImageDataImpl *ImageDataImpl::GetPointer(const v8::Local<v8::Object>& object) {
|
|
55
|
+
auto ptr = object->GetInternalField(0).As<v8::External>()->Value();
|
|
56
|
+
if (ptr == nullptr) {
|
|
57
|
+
return nullptr;
|
|
58
|
+
}
|
|
59
|
+
return static_cast<ImageDataImpl *>(ptr);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
v8::Local<v8::FunctionTemplate> ImageDataImpl::GetCtor(v8::Isolate *isolate) {
|
|
64
|
+
auto cache = Caches::Get(isolate);
|
|
65
|
+
auto ctor = cache->ImageDataTmpl.get();
|
|
66
|
+
if (ctor != nullptr) {
|
|
67
|
+
return ctor->Get(isolate);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate, Ctor);
|
|
71
|
+
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
72
|
+
ctorTmpl->SetClassName(ConvertToV8String(isolate, "ImageData"));
|
|
73
|
+
|
|
74
|
+
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
75
|
+
tmpl->SetInternalFieldCount(1);
|
|
76
|
+
tmpl->SetAccessor(
|
|
77
|
+
ConvertToV8String(isolate, "width"),
|
|
78
|
+
GetWidth);
|
|
79
|
+
tmpl->SetAccessor(
|
|
80
|
+
ConvertToV8String(isolate, "height"),
|
|
81
|
+
GetHeight);
|
|
82
|
+
tmpl->SetAccessor(
|
|
83
|
+
ConvertToV8String(isolate, "data"),
|
|
84
|
+
GetData);
|
|
85
|
+
cache->ImageDataTmpl =
|
|
86
|
+
std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
|
|
87
|
+
return ctorTmpl;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
void ImageDataImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
92
|
+
auto count = args.Length();
|
|
93
|
+
auto value = args[0];
|
|
94
|
+
auto isolate = args.GetIsolate();
|
|
95
|
+
auto context = isolate->GetCurrentContext();
|
|
96
|
+
if (count == 1 && !value->IsString()) {
|
|
97
|
+
auto label = value->ToString(isolate->GetCurrentContext()).ToLocalChecked();
|
|
98
|
+
auto arg = ConvertFromV8String(isolate, label);
|
|
99
|
+
auto error = "Failed to construct 'TextEncoder': The encoding label provided (" +
|
|
100
|
+
arg + "') is invalid";
|
|
101
|
+
isolate->ThrowError(ConvertToV8String(isolate, error));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
auto ret = args.This();
|
|
106
|
+
|
|
107
|
+
if (value->IsNumber()) {
|
|
108
|
+
auto image_data = canvas_native_context_create_image_data(
|
|
109
|
+
(int32_t) value->NumberValue(context).ToChecked(),
|
|
110
|
+
(int32_t) args[1]->NumberValue(context).ToChecked());
|
|
111
|
+
|
|
112
|
+
auto object = new ImageDataImpl(image_data);
|
|
113
|
+
|
|
114
|
+
auto ext = v8::External::New(isolate, object);
|
|
115
|
+
|
|
116
|
+
ret->SetInternalField(0, ext);
|
|
117
|
+
|
|
118
|
+
args.GetReturnValue().Set(ret);
|
|
119
|
+
return;
|
|
120
|
+
|
|
121
|
+
} else if (value->IsUint8ClampedArray()) {
|
|
122
|
+
auto arrayObject = value.As<v8::Uint8ClampedArray>();
|
|
123
|
+
auto array = arrayObject->Buffer();
|
|
124
|
+
auto store = array->GetBackingStore();
|
|
125
|
+
auto buffer_data = static_cast<u_int8_t *>(store->Data()) + arrayObject->ByteOffset();
|
|
126
|
+
auto len = arrayObject->Length();
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
auto image_data = canvas_native_context_create_image_data_with_data(
|
|
130
|
+
(int32_t) args[1]->NumberValue(context).ToChecked(),
|
|
131
|
+
(int32_t) args[2]->NumberValue(context).ToChecked(), buffer_data, len);
|
|
132
|
+
|
|
133
|
+
auto object = new ImageDataImpl(image_data);
|
|
134
|
+
|
|
135
|
+
auto ext = v8::External::New(isolate, object);
|
|
136
|
+
|
|
137
|
+
ret->SetInternalField(0, ext);
|
|
138
|
+
|
|
139
|
+
args.GetReturnValue().Set(ret);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// TODO throw ?
|
|
144
|
+
args.GetReturnValue().SetUndefined();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
void
|
|
149
|
+
ImageDataImpl::GetWidth(v8::Local<v8::String> name,
|
|
150
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
151
|
+
auto ptr = GetPointer(info.This());
|
|
152
|
+
if (ptr != nullptr) {
|
|
153
|
+
auto ret = canvas_native_image_data_get_width(ptr->GetImageData());
|
|
154
|
+
info.GetReturnValue().Set(ret);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
info.GetReturnValue().Set(0);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
void
|
|
161
|
+
ImageDataImpl::GetHeight(v8::Local<v8::String> name,
|
|
162
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
163
|
+
auto ptr = GetPointer(info.This());
|
|
164
|
+
if (ptr != nullptr) {
|
|
165
|
+
auto ret = canvas_native_image_data_get_height(ptr->GetImageData());
|
|
166
|
+
info.GetReturnValue().Set(ret);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
info.GetReturnValue().Set(0);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
void
|
|
174
|
+
ImageDataImpl::GetData(v8::Local<v8::String> name,
|
|
175
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
176
|
+
auto ptr = GetPointer(info.This());
|
|
177
|
+
if (ptr != nullptr) {
|
|
178
|
+
auto isolate = info.GetIsolate();
|
|
179
|
+
|
|
180
|
+
auto data = new ImageDataBuffer(
|
|
181
|
+
canvas_native_image_data_get_shared_instance(ptr->GetImageData()));
|
|
182
|
+
|
|
183
|
+
auto length = data->size();
|
|
184
|
+
auto store = v8::ArrayBuffer::NewBackingStore(data->data(), length,
|
|
185
|
+
[](void *data, size_t length,
|
|
186
|
+
void *deleter_data) {
|
|
187
|
+
if (deleter_data != nullptr) {
|
|
188
|
+
delete (ImageDataBuffer *) deleter_data;
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
data);
|
|
192
|
+
|
|
193
|
+
auto buf = v8::ArrayBuffer::New(isolate, std::move(store));
|
|
194
|
+
|
|
195
|
+
auto ret = v8::Uint8ClampedArray::New(buf, 0, length);
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
info.GetReturnValue().Set(ret);
|
|
199
|
+
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
info.GetReturnValue().SetUndefined();
|
|
203
|
+
}
|
|
@@ -4,26 +4,40 @@
|
|
|
4
4
|
|
|
5
5
|
#pragma once
|
|
6
6
|
|
|
7
|
-
#include "rust/cxx.h"
|
|
8
|
-
#include "canvas-cxx/src/lib.rs.h"
|
|
9
|
-
#import <NativeScript/JSIRuntime.h>
|
|
10
7
|
#include <vector>
|
|
8
|
+
#include "Common.h"
|
|
11
9
|
|
|
12
|
-
using namespace facebook;
|
|
13
|
-
using namespace org::nativescript::canvas;
|
|
14
10
|
|
|
15
|
-
class
|
|
11
|
+
class ImageDataImpl {
|
|
16
12
|
public:
|
|
17
|
-
ImageDataImpl(
|
|
13
|
+
ImageDataImpl(ImageData* imageData);
|
|
14
|
+
|
|
15
|
+
~ImageDataImpl(){
|
|
16
|
+
canvas_native_image_data_destroy(this->GetImageData());
|
|
17
|
+
this->imageData_ = nullptr;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
21
|
+
|
|
22
|
+
static ImageDataImpl *GetPointer(const v8::Local<v8::Object>& object);
|
|
23
|
+
|
|
24
|
+
static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
|
|
25
|
+
|
|
26
|
+
static void Ctor(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
27
|
+
|
|
28
|
+
static void GetWidth(v8::Local<v8::String> name,
|
|
29
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
18
30
|
|
|
19
|
-
|
|
31
|
+
static void GetHeight(v8::Local<v8::String> name,
|
|
32
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
20
33
|
|
|
21
|
-
|
|
34
|
+
static void GetData(v8::Local<v8::String> name,
|
|
35
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
22
36
|
|
|
23
|
-
ImageData
|
|
24
|
-
return
|
|
37
|
+
ImageData* GetImageData() {
|
|
38
|
+
return this->imageData_;
|
|
25
39
|
}
|
|
26
40
|
|
|
27
41
|
private:
|
|
28
|
-
|
|
42
|
+
ImageData* imageData_;
|
|
29
43
|
};
|