@nativescript/canvas 2.0.0-beta.0 → 2.0.0-beta.10
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.js +3 -0
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +1 -0
- package/Canvas/index.android.js +8 -2
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.d.ts +2 -0
- package/Canvas/index.ios.d.ts +4 -1
- package/Canvas/index.ios.js +14 -6
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.d.ts +16 -0
- package/Canvas2D/CanvasRenderingContext2D/index.js +209 -10
- package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
- package/Canvas2D/DOMMatrix/index.js +5 -3
- package/Canvas2D/DOMMatrix/index.js.map +1 -1
- package/Canvas2D/Path2D/index.d.ts +2 -1
- package/Canvas2D/Path2D/index.js +3 -12
- package/Canvas2D/Path2D/index.js.map +1 -1
- package/Dom/Dom.d.ts +20 -1
- package/Dom/Dom.js +79 -6
- package/Dom/Dom.js.map +1 -1
- package/Dom/Group.d.ts +12 -7
- package/Dom/Group.js +62 -21
- package/Dom/Group.js.map +1 -1
- package/Dom/Image.d.ts +1 -0
- package/Dom/Image.js +22 -3
- package/Dom/Image.js.map +1 -1
- package/Dom/Paint.d.ts +5 -0
- package/Dom/Paint.js +25 -7
- package/Dom/Paint.js.map +1 -1
- package/Dom/Shadow.js +9 -0
- package/Dom/Shadow.js.map +1 -1
- package/Dom/Text.js +14 -5
- package/Dom/Text.js.map +1 -1
- package/Dom/index.d.ts +1 -0
- package/Dom/index.js +1 -0
- package/Dom/index.js.map +1 -1
- package/Dom/shaders/Gradients.d.ts +3 -0
- package/Dom/shaders/Gradients.js +4 -0
- package/Dom/shaders/Gradients.js.map +1 -0
- package/Dom/shaders/LinearGradient.d.ts +14 -0
- package/Dom/shaders/LinearGradient.js +44 -0
- package/Dom/shaders/LinearGradient.js.map +1 -0
- package/Dom/shaders/TwoPointConicalGradient.d.ts +16 -0
- package/Dom/shaders/TwoPointConicalGradient.js +60 -0
- package/Dom/shaders/TwoPointConicalGradient.js.map +1 -0
- package/Dom/shaders/index.d.ts +2 -0
- package/Dom/shaders/index.js +3 -0
- package/Dom/shaders/index.js.map +1 -0
- package/Dom/shapes/Atlas.d.ts +22 -0
- package/Dom/shapes/Atlas.js +60 -0
- package/Dom/shapes/Atlas.js.map +1 -0
- package/Dom/shapes/Circle.js +12 -1
- package/Dom/shapes/Circle.js.map +1 -1
- package/Dom/shapes/Line.d.ts +16 -4
- package/Dom/shapes/Line.js +13 -8
- package/Dom/shapes/Line.js.map +1 -1
- package/Dom/shapes/Oval.d.ts +12 -0
- package/Dom/shapes/Oval.js +87 -0
- package/Dom/shapes/Oval.js.map +1 -0
- package/Dom/shapes/Path.d.ts +19 -2
- package/Dom/shapes/Path.js +68 -3
- package/Dom/shapes/Path.js.map +1 -1
- package/Dom/shapes/Points.js +9 -1
- package/Dom/shapes/Points.js.map +1 -1
- package/Dom/shapes/Rect.js +29 -7
- package/Dom/shapes/Rect.js.map +1 -1
- package/Dom/shapes/RoundedRect.d.ts +2 -1
- package/Dom/shapes/RoundedRect.js +21 -11
- package/Dom/shapes/RoundedRect.js.map +1 -1
- package/Dom/shapes/index.d.ts +17 -0
- package/Dom/shapes/index.js +31 -0
- package/Dom/shapes/index.js.map +1 -1
- package/SVG/SVG.d.ts +2 -1
- package/SVG/SVG.js +15 -1
- package/SVG/SVG.js.map +1 -1
- package/WebGL/WebGLRenderingContext/index.js +37 -1
- package/WebGL/WebGLRenderingContext/index.js.map +1 -1
- package/package.json +1 -1
- package/platforms/android/canvas-release.aar +0 -0
- package/platforms/ios/CanvasNative.xcframework/Info.plist +4 -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 +21 -4
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +25 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +50 -0
- 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 +306 -208
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +2 -1
- 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 -1
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/module.modulemap +1 -1
- 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 +668 -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 +42 -8
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +25 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +50 -0
- 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 +306 -208
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +2 -1
- 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 -1
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +306 -208
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +2 -1
- 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 -1
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/module.modulemap +1 -1
- 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 +35 -35
- 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 +667 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +646 -0
- package/platforms/ios/src/cpp/ImageAssetImpl.cpp +22 -3
- package/platforms/ios/src/cpp/ImageAssetImpl.h +5 -2
- package/platforms/ios/src/cpp/ObjectWrapperImpl.h +8 -6
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +342 -75
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +153 -55
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +1 -1
- package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +19 -48
- package/platforms/ios/src/cpp/canvas2d/Path2D.h +19 -0
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +5 -0
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +4 -4
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.cpp +37 -7
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.h +10 -0
- package/src-native/ios/NativeScript.podspec +1 -1
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
class CanvasRenderingContext2DImpl : ObjectWrapperImpl {
|
|
29
29
|
public:
|
|
30
30
|
|
|
31
|
+
static v8::CFunction fast_start_raf_;
|
|
32
|
+
|
|
33
|
+
static v8::CFunction fast_stop_raf_;
|
|
34
|
+
|
|
31
35
|
static v8::CFunction fast_draw_point_;
|
|
32
36
|
|
|
33
37
|
static v8::CFunction fast_arc_;
|
|
@@ -102,12 +106,16 @@ public:
|
|
|
102
106
|
|
|
103
107
|
static v8::CFunction fast_fill_rect_;
|
|
104
108
|
|
|
109
|
+
static v8::CFunction fast_fill_oval_;
|
|
110
|
+
|
|
105
111
|
static v8::CFunction fast_stroke_;
|
|
106
112
|
|
|
107
113
|
static v8::CFunction fast_stroke_path_;
|
|
108
114
|
|
|
109
115
|
static v8::CFunction fast_stroke_rect_;
|
|
110
116
|
|
|
117
|
+
static v8::CFunction fast_stroke_oval_;
|
|
118
|
+
|
|
111
119
|
static v8::CFunction fast_rotate_;
|
|
112
120
|
|
|
113
121
|
static v8::CFunction fast_reset_transform_;
|
|
@@ -118,9 +126,39 @@ public:
|
|
|
118
126
|
|
|
119
127
|
static v8::CFunction fast_translate_;
|
|
120
128
|
|
|
129
|
+
static v8::CFunction fast_draw_atlas_;
|
|
130
|
+
|
|
121
131
|
|
|
122
132
|
CanvasRenderingContext2DImpl(CanvasRenderingContext2D *context);
|
|
123
133
|
|
|
134
|
+
void StartRaf();
|
|
135
|
+
|
|
136
|
+
void StopRaf();
|
|
137
|
+
|
|
138
|
+
static void __StartRaf(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
139
|
+
|
|
140
|
+
static void __FastStartRaf(v8::Local<v8::Object> receiver_obj) {
|
|
141
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
142
|
+
if (ptr == nullptr) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
ptr->StartRaf();
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
static void __StopRaf(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
151
|
+
|
|
152
|
+
static void __FastStopRaf(v8::Local<v8::Object> receiver_obj) {
|
|
153
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
154
|
+
if (ptr == nullptr) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
ptr->StopRaf();
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
124
162
|
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
125
163
|
|
|
126
164
|
static CanvasRenderingContext2DImpl *GetPointer(const v8::Local<v8::Object> &object);
|
|
@@ -163,6 +201,15 @@ public:
|
|
|
163
201
|
|
|
164
202
|
static void __Resize(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
165
203
|
|
|
204
|
+
|
|
205
|
+
static void SetContinuousRenderMode(v8::Local<v8::String> property,
|
|
206
|
+
v8::Local<v8::Value> value,
|
|
207
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
208
|
+
|
|
209
|
+
static void GetContinuousRenderMode(v8::Local<v8::String> property,
|
|
210
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
211
|
+
|
|
212
|
+
|
|
166
213
|
static void GetFilter(v8::Local<v8::String> property,
|
|
167
214
|
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
168
215
|
|
|
@@ -489,18 +536,10 @@ public:
|
|
|
489
536
|
|
|
490
537
|
if (GetNativeType(path_obj) == NativeType::Path2D) {
|
|
491
538
|
auto path = Path2D::GetPointer(path_obj);
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
case 1:
|
|
495
|
-
canvas_native_context_clip(
|
|
496
|
-
ptr->GetContext(), path->GetPath(), rule);
|
|
497
|
-
break;
|
|
498
|
-
default:
|
|
499
|
-
break;
|
|
500
|
-
}
|
|
539
|
+
canvas_native_context_clip(
|
|
540
|
+
ptr->GetContext(), path->GetPath(), rule);
|
|
501
541
|
}
|
|
502
542
|
|
|
503
|
-
|
|
504
543
|
}
|
|
505
544
|
|
|
506
545
|
static void ClosePath(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -536,6 +575,51 @@ public:
|
|
|
536
575
|
|
|
537
576
|
static void DrawFocusIfNeeded(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
538
577
|
|
|
578
|
+
|
|
579
|
+
static void DrawAtlas(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
580
|
+
|
|
581
|
+
/*
|
|
582
|
+
static void FastDrawAtlas(v8::Local<v8::Object> receiver_obj, v8::Local<v8::Object> image_obj, v8::Local<v8::Array> xform, v8::Local<v8::Array> tex, v8::Local<v8::Array> xform) {
|
|
583
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
584
|
+
if (ptr == nullptr) {
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
auto len = array->Length();
|
|
590
|
+
std::vector<float> buf;
|
|
591
|
+
buf.reserve(len);
|
|
592
|
+
|
|
593
|
+
auto copied = v8::TryToCopyAndConvertArrayToCppBuffer<v8::CTypeInfoBuilder<float>::Build().GetId(), float>(
|
|
594
|
+
array, buf.data(), len);
|
|
595
|
+
|
|
596
|
+
if (copied) {
|
|
597
|
+
|
|
598
|
+
auto imageType = GetNativeType(image_obj);
|
|
599
|
+
switch (imageType) {
|
|
600
|
+
case NativeType::ImageAsset: {
|
|
601
|
+
auto asset = ImageAssetImpl::GetPointer(image_obj);
|
|
602
|
+
|
|
603
|
+
}
|
|
604
|
+
break;
|
|
605
|
+
case NativeType::ImageBitmap: {
|
|
606
|
+
auto asset = ImageBitmapImpl::GetPointer(image_obj);
|
|
607
|
+
}
|
|
608
|
+
break;
|
|
609
|
+
case NativeType::CanvasRenderingContext2D: {
|
|
610
|
+
auto context = CanvasRenderingContext2DImpl::GetPointer(image_obj);
|
|
611
|
+
|
|
612
|
+
}
|
|
613
|
+
break;
|
|
614
|
+
default:
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
ptr->UpdateInvalidateState();
|
|
620
|
+
}
|
|
621
|
+
*/
|
|
622
|
+
|
|
539
623
|
static void DrawImage(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
540
624
|
|
|
541
625
|
static void
|
|
@@ -800,18 +884,10 @@ public:
|
|
|
800
884
|
auto object = Path2D::GetPointer(path);
|
|
801
885
|
|
|
802
886
|
if (object != nullptr) {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
ptr->GetContext(),
|
|
808
|
-
object->GetPath(),
|
|
809
|
-
rule);
|
|
810
|
-
break;
|
|
811
|
-
default:
|
|
812
|
-
break;
|
|
813
|
-
}
|
|
814
|
-
|
|
887
|
+
canvas_native_context_fill_with_path(
|
|
888
|
+
ptr->GetContext(),
|
|
889
|
+
object->GetPath(),
|
|
890
|
+
rule);
|
|
815
891
|
ptr->UpdateInvalidateState();
|
|
816
892
|
}
|
|
817
893
|
}
|
|
@@ -837,16 +913,9 @@ public:
|
|
|
837
913
|
return;
|
|
838
914
|
}
|
|
839
915
|
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
canvas_native_context_fill(
|
|
844
|
-
ptr->GetContext(), rule);
|
|
845
|
-
ptr->UpdateInvalidateState();
|
|
846
|
-
break;
|
|
847
|
-
default:
|
|
848
|
-
break;
|
|
849
|
-
}
|
|
916
|
+
canvas_native_context_fill(
|
|
917
|
+
ptr->GetContext(), rule);
|
|
918
|
+
ptr->UpdateInvalidateState();
|
|
850
919
|
}
|
|
851
920
|
|
|
852
921
|
static void FastFill(v8::Local<v8::Object> receiver_obj) {
|
|
@@ -882,6 +951,27 @@ public:
|
|
|
882
951
|
|
|
883
952
|
static void FillText(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
884
953
|
|
|
954
|
+
|
|
955
|
+
static void FillOval(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
static void FastFillOval(v8::Local<v8::Object> receiver_obj, double x, double y, double width,
|
|
959
|
+
double height) {
|
|
960
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
961
|
+
if (ptr == nullptr) {
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
canvas_native_context_fill_oval(
|
|
966
|
+
ptr->GetContext(),
|
|
967
|
+
static_cast<float>(x),
|
|
968
|
+
static_cast<float>(y),
|
|
969
|
+
static_cast<float>(width),
|
|
970
|
+
static_cast<float>(height)
|
|
971
|
+
);
|
|
972
|
+
ptr->UpdateInvalidateState();
|
|
973
|
+
}
|
|
974
|
+
|
|
885
975
|
static void GetImageData(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
886
976
|
|
|
887
977
|
static void GetLineDash(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -907,18 +997,8 @@ public:
|
|
|
907
997
|
return false;
|
|
908
998
|
}
|
|
909
999
|
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
case 0:
|
|
913
|
-
case 1:
|
|
914
|
-
ret = canvas_native_context_is_point_in_path(
|
|
915
|
-
ptr->GetContext(), static_cast<float>(x), static_cast<float>(y), rule);
|
|
916
|
-
break;
|
|
917
|
-
default:
|
|
918
|
-
break;
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
return ret;
|
|
1000
|
+
return canvas_native_context_is_point_in_path(
|
|
1001
|
+
ptr->GetContext(), static_cast<float>(x), static_cast<float>(y), rule);
|
|
922
1002
|
}
|
|
923
1003
|
|
|
924
1004
|
static bool
|
|
@@ -939,17 +1019,9 @@ public:
|
|
|
939
1019
|
auto path = Path2D::GetPointer(path_obj);
|
|
940
1020
|
|
|
941
1021
|
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
ret = canvas_native_context_is_point_in_path_with_path(
|
|
946
|
-
ptr->GetContext(),
|
|
947
|
-
path->GetPath(), x, y, rule);
|
|
948
|
-
break;
|
|
949
|
-
break;
|
|
950
|
-
default:
|
|
951
|
-
break;
|
|
952
|
-
}
|
|
1022
|
+
ret = canvas_native_context_is_point_in_path_with_path(
|
|
1023
|
+
ptr->GetContext(),
|
|
1024
|
+
path->GetPath(), x, y, rule);
|
|
953
1025
|
|
|
954
1026
|
}
|
|
955
1027
|
return ret;
|
|
@@ -1279,6 +1351,9 @@ public:
|
|
|
1279
1351
|
f);
|
|
1280
1352
|
}
|
|
1281
1353
|
|
|
1354
|
+
|
|
1355
|
+
static void GetTransform(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
1356
|
+
|
|
1282
1357
|
static void Stroke(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
1283
1358
|
|
|
1284
1359
|
static void FastStroke(v8::Local<v8::Object> receiver_obj) {
|
|
@@ -1322,6 +1397,27 @@ public:
|
|
|
1322
1397
|
|
|
1323
1398
|
static void StrokeText(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
1324
1399
|
|
|
1400
|
+
|
|
1401
|
+
|
|
1402
|
+
static void StrokeOval(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
1403
|
+
|
|
1404
|
+
|
|
1405
|
+
static void FastStrokeOval(v8::Local<v8::Object> receiver_obj, double x, double y, double width,
|
|
1406
|
+
double height) {
|
|
1407
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
1408
|
+
if (ptr == nullptr) {
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
canvas_native_context_stroke_oval(
|
|
1413
|
+
ptr->GetContext(), static_cast<float>(x),
|
|
1414
|
+
static_cast<float>(y),
|
|
1415
|
+
static_cast<float>(width),
|
|
1416
|
+
static_cast<float>(height));
|
|
1417
|
+
ptr->UpdateInvalidateState();
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
|
|
1325
1421
|
static void Transform(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
1326
1422
|
|
|
1327
1423
|
static void
|
|
@@ -1382,4 +1478,6 @@ private:
|
|
|
1382
1478
|
|
|
1383
1479
|
std::shared_ptr<RafImpl> raf_;
|
|
1384
1480
|
|
|
1481
|
+
bool continuousRender_ = true;
|
|
1482
|
+
|
|
1385
1483
|
};
|
|
@@ -51,9 +51,6 @@ v8::CFunction Path2D::fast_quadratic_curve_to_(v8::CFunction::Make(Path2D::FastQ
|
|
|
51
51
|
|
|
52
52
|
v8::CFunction Path2D::fast_rect_(v8::CFunction::Make(Path2D::FastRect));
|
|
53
53
|
|
|
54
|
-
//v8::CFunction Path2D::fast_round_rect_(v8::CFunction::Make(Path2D::FastRoundRect));
|
|
55
|
-
|
|
56
|
-
|
|
57
54
|
v8::CFunction Path2D::fast_round_rect_(
|
|
58
55
|
v8::CFunction::Make(Path2D::FastRoundRect));
|
|
59
56
|
|
|
@@ -65,6 +62,8 @@ const v8::CFunction fast_round_rect_overloads_[] = {
|
|
|
65
62
|
Path2D::fast_round_rect_array_
|
|
66
63
|
};
|
|
67
64
|
|
|
65
|
+
v8::CFunction Path2D::fast_trim_(v8::CFunction::Make(Path2D::FastTrim));
|
|
66
|
+
|
|
68
67
|
|
|
69
68
|
|
|
70
69
|
//v8::CFunction Path2D::fast_to_svg_(v8::CFunction::Make(Path2D::FastToSVG));
|
|
@@ -76,7 +75,7 @@ void Path2D::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
76
75
|
|
|
77
76
|
auto ret = args.This();
|
|
78
77
|
|
|
79
|
-
SetNativeType(
|
|
78
|
+
SetNativeType(ret, NativeType::Path2D);
|
|
80
79
|
|
|
81
80
|
if (count > 0) {
|
|
82
81
|
if (value->IsString()) {
|
|
@@ -385,6 +384,21 @@ void Path2D::RoundRect(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
385
384
|
args.GetReturnValue().SetUndefined();
|
|
386
385
|
}
|
|
387
386
|
|
|
387
|
+
void Path2D::Trim(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
388
|
+
Path2D *ptr = GetPointer(args.This());
|
|
389
|
+
if (ptr == nullptr) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
auto isolate = args.GetIsolate();
|
|
394
|
+
auto context = isolate->GetCurrentContext();
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
canvas_native_path_trim(ptr->GetPath(),
|
|
398
|
+
static_cast<float>(args[0]->NumberValue(context).ToChecked()),
|
|
399
|
+
static_cast<float>(args[1]->NumberValue(context).ToChecked()));
|
|
400
|
+
}
|
|
401
|
+
|
|
388
402
|
void Path2D::__toSVG(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
389
403
|
Path2D *ptr = GetPointer(args.This());
|
|
390
404
|
if (ptr == nullptr) {
|
|
@@ -443,50 +457,7 @@ v8::Local<v8::FunctionTemplate> Path2D::GetCtor(v8::Isolate *isolate) {
|
|
|
443
457
|
SetFastMethodWithOverLoads(isolate, tmpl, "roundRect", RoundRect,
|
|
444
458
|
fast_round_rect_overloads_, v8::Local<v8::Value>());
|
|
445
459
|
|
|
446
|
-
|
|
447
|
-
// ConvertToV8String(isolate, "addPath"),
|
|
448
|
-
// v8::FunctionTemplate::New(isolate, &AddPath));
|
|
449
|
-
|
|
450
|
-
// tmpl->Set(
|
|
451
|
-
// ConvertToV8String(isolate, "arc"),
|
|
452
|
-
// v8::FunctionTemplate::New(isolate, &Arc));
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
// tmpl->Set(
|
|
456
|
-
// ConvertToV8String(isolate, "bezierCurveTo"),
|
|
457
|
-
// v8::FunctionTemplate::New(isolate, &BezierCurveTo));
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
// tmpl->Set(
|
|
461
|
-
// ConvertToV8String(isolate, "closePath"),
|
|
462
|
-
// v8::FunctionTemplate::New(isolate, &ClosePath));
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
// tmpl->Set(
|
|
466
|
-
// ConvertToV8String(isolate, "ellipse"),
|
|
467
|
-
// v8::FunctionTemplate::New(isolate, &Ellipse));
|
|
468
|
-
|
|
469
|
-
// tmpl->Set(
|
|
470
|
-
// ConvertToV8String(isolate, "lineTo"),
|
|
471
|
-
// v8::FunctionTemplate::New(isolate, &LineTo));
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
// tmpl->Set(
|
|
475
|
-
// ConvertToV8String(isolate, "moveTo"),
|
|
476
|
-
// v8::FunctionTemplate::New(isolate, &MoveTo));
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
// tmpl->Set(
|
|
480
|
-
// ConvertToV8String(isolate, "quadraticCurveTo"),
|
|
481
|
-
// v8::FunctionTemplate::New(isolate, &QuadraticCurveTo));
|
|
482
|
-
|
|
483
|
-
// tmpl->Set(
|
|
484
|
-
// ConvertToV8String(isolate, "rect"),
|
|
485
|
-
// v8::FunctionTemplate::New(isolate, &Rect));
|
|
486
|
-
|
|
487
|
-
// tmpl->Set(
|
|
488
|
-
// ConvertToV8String(isolate, "roundRect"),
|
|
489
|
-
// v8::FunctionTemplate::New(isolate, &RoundRect));
|
|
460
|
+
SetFastMethod(isolate, tmpl, "trim", Trim, &fast_trim_, v8::Local<v8::Value>());
|
|
490
461
|
|
|
491
462
|
tmpl->Set(
|
|
492
463
|
ConvertToV8String(isolate, "__toSVG"),
|
|
@@ -64,6 +64,8 @@ public:
|
|
|
64
64
|
static v8::CFunction fast_round_rect_array_;
|
|
65
65
|
// static v8::CFunction fast_to_svg_; // todo after v8 upgrade
|
|
66
66
|
|
|
67
|
+
static v8::CFunction fast_trim_;
|
|
68
|
+
|
|
67
69
|
|
|
68
70
|
static void Arc(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
69
71
|
|
|
@@ -429,6 +431,23 @@ public:
|
|
|
429
431
|
|
|
430
432
|
static void RoundRect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
431
433
|
|
|
434
|
+
static void Trim(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
435
|
+
|
|
436
|
+
static void
|
|
437
|
+
FastTrim(v8::Local<v8::Object> receiver_obj, double start, double end) {
|
|
438
|
+
|
|
439
|
+
Path2D *ptr = GetPointer(receiver_obj);
|
|
440
|
+
if (ptr == nullptr) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
canvas_native_path_trim(
|
|
445
|
+
ptr->GetPath(),
|
|
446
|
+
static_cast<float>(start),
|
|
447
|
+
static_cast<float>(end)
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
|
|
432
451
|
static void __toSVG(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
433
452
|
|
|
434
453
|
|
|
@@ -6302,6 +6302,11 @@ WebGLRenderingContext::SetMethods(v8::Isolate *isolate, const v8::Local<v8::Obje
|
|
|
6302
6302
|
v8::Local<v8::Value>());
|
|
6303
6303
|
|
|
6304
6304
|
|
|
6305
|
+
|
|
6306
|
+
tmpl->SetAccessor(ConvertToV8String(isolate, "continuousRenderMode"), GetContinuousRenderMode,
|
|
6307
|
+
SetContinuousRenderMode);
|
|
6308
|
+
|
|
6309
|
+
|
|
6305
6310
|
// todo
|
|
6306
6311
|
tmpl->Set(ConvertToV8String(isolate, "__toDataURL"),
|
|
6307
6312
|
v8::FunctionTemplate::New(isolate, &__ToDataURL));
|
|
@@ -1557,13 +1557,13 @@ public:
|
|
|
1557
1557
|
return;
|
|
1558
1558
|
}
|
|
1559
1559
|
|
|
1560
|
-
|
|
1561
|
-
DrawArraysImpl(
|
|
1562
|
-
ptr,
|
|
1560
|
+
canvas_native_webgl_draw_arrays(
|
|
1563
1561
|
mode,
|
|
1564
1562
|
first,
|
|
1565
|
-
count
|
|
1563
|
+
count,
|
|
1564
|
+
ptr->GetState()
|
|
1566
1565
|
);
|
|
1566
|
+
ptr->UpdateInvalidateState();
|
|
1567
1567
|
}
|
|
1568
1568
|
|
|
1569
1569
|
static void DrawElements(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
WebGLRenderingContextBase::WebGLRenderingContextBase(WebGLState* state,
|
|
8
8
|
WebGLRenderingVersion version)
|
|
9
9
|
: state_(state), version_(version) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
|
|
12
12
|
auto ctx_ptr = reinterpret_cast<intptr_t>(reinterpret_cast<intptr_t *>(this));
|
|
13
13
|
auto raf_callback = new OnRafCallback(
|
|
14
14
|
ctx_ptr,
|
|
@@ -19,13 +19,44 @@ WebGLRenderingContextBase::WebGLRenderingContextBase(WebGLState* state,
|
|
|
19
19
|
std::make_shared<RafImpl>(
|
|
20
20
|
raf_callback,
|
|
21
21
|
raf_callback_ptr, raf));
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
auto _raf = this->GetRaf();
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
if (_raf != nullptr) {
|
|
26
26
|
canvas_native_raf_start(_raf->GetRaf());
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
void WebGLRenderingContextBase::GetContinuousRenderMode(v8::Local<v8::String> property,
|
|
33
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
34
|
+
WebGLRenderingContextBase *ptr = GetPointer(info.This());
|
|
35
|
+
if (ptr == nullptr) {
|
|
36
|
+
info.GetReturnValue().Set(false);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
info.GetReturnValue().Set(ptr->continuousRender_);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void WebGLRenderingContextBase::SetContinuousRenderMode(v8::Local<v8::String> property,
|
|
43
|
+
v8::Local<v8::Value> value,
|
|
44
|
+
const v8::PropertyCallbackInfo<void> &info) {
|
|
45
|
+
WebGLRenderingContextBase *ptr = GetPointer(info.This());
|
|
46
|
+
if (ptr == nullptr) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
auto isolate = info.GetIsolate();
|
|
50
|
+
auto val = value->BooleanValue(isolate);
|
|
51
|
+
if (val == ptr->continuousRender_) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (val) {
|
|
55
|
+
ptr->StartRaf();
|
|
56
|
+
} else {
|
|
57
|
+
ptr->StopRaf();
|
|
58
|
+
}
|
|
59
|
+
ptr->continuousRender_ = val;
|
|
29
60
|
}
|
|
30
61
|
|
|
31
62
|
|
|
@@ -64,8 +95,7 @@ void WebGLRenderingContextBase::Flush() {
|
|
|
64
95
|
auto state = this->GetInvalidateState() & (int) InvalidateState::InvalidateStatePending;
|
|
65
96
|
if (state == (int) InvalidateState::InvalidateStatePending) {
|
|
66
97
|
this->SetInvalidateState((int) InvalidateState::InvalidateStateInvalidating);
|
|
67
|
-
|
|
68
|
-
canvas_native_webgl_swap_buffers(this->GetState());
|
|
98
|
+
canvas_native_webgl_make_current_and_swap_buffers(this->GetState());
|
|
69
99
|
this->SetInvalidateState((int) InvalidateState::InvalidateStateNone);
|
|
70
100
|
}
|
|
71
101
|
}
|
|
@@ -32,6 +32,14 @@ public:
|
|
|
32
32
|
return static_cast<WebGLRenderingContextBase *>(ptr);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
|
|
36
|
+
static void GetContinuousRenderMode(v8::Local<v8::String> property,
|
|
37
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
38
|
+
|
|
39
|
+
static void SetContinuousRenderMode(v8::Local<v8::String> property,
|
|
40
|
+
v8::Local<v8::Value> value,
|
|
41
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
42
|
+
|
|
35
43
|
~WebGLRenderingContextBase();
|
|
36
44
|
|
|
37
45
|
void UpdateInvalidateState();
|
|
@@ -66,5 +74,7 @@ private:
|
|
|
66
74
|
int invalidateState_ = static_cast<int>(InvalidateState::InvalidateStateNone);
|
|
67
75
|
|
|
68
76
|
std::shared_ptr<RafImpl> raf_;
|
|
77
|
+
|
|
78
|
+
bool continuousRender_ = true;
|
|
69
79
|
};
|
|
70
80
|
|
|
@@ -6,7 +6,7 @@ Pod::Spec.new do |s|
|
|
|
6
6
|
|
|
7
7
|
s.authors = "Ammar Ahmed"
|
|
8
8
|
s.homepage = "https://github.com/ammarahm-ed/nativescript-v8-module"
|
|
9
|
-
s.platforms = { :ios => "12.
|
|
9
|
+
s.platforms = { :ios => "12.0" }
|
|
10
10
|
s.source = { :git => "https://github.com/ammarahm-ed/nativescript-v8-module.git", :tag => "v1.0.0" }
|
|
11
11
|
s.cocoapods_version = ">= 1.10.1"
|
|
12
12
|
s.vendored_frameworks = "NativeScript.xcframework"
|