@nativescript/canvas 2.0.0-beta.1 → 2.0.0-beta.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/index.android.js +1 -1
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.ios.d.ts +1 -0
- package/Canvas/index.ios.js +9 -1
- package/Canvas/index.ios.js.map +1 -1
- package/Canvas2D/CanvasRenderingContext2D/index.js +23 -8
- package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
- package/Dom/Dom.d.ts +4 -1
- package/Dom/Dom.js +27 -8
- package/Dom/Dom.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 +35 -0
- package/Dom/shaders/LinearGradient.js.map +1 -0
- package/Dom/shaders/TwoPointConicalGradient.d.ts +16 -0
- package/Dom/shaders/TwoPointConicalGradient.js +45 -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/Circle.js +1 -0
- package/Dom/shapes/Circle.js.map +1 -1
- package/Dom/shapes/Line.js +5 -3
- package/Dom/shapes/Line.js.map +1 -1
- package/Dom/shapes/Rect.js +12 -5
- package/Dom/shapes/Rect.js.map +1 -1
- package/package.json +1 -1
- 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/canvas_native.h +2 -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_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +2 -2
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +126 -89
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +57 -55
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +5 -0
- 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_;
|
|
@@ -121,6 +125,34 @@ public:
|
|
|
121
125
|
|
|
122
126
|
CanvasRenderingContext2DImpl(CanvasRenderingContext2D *context);
|
|
123
127
|
|
|
128
|
+
void StartRaf();
|
|
129
|
+
|
|
130
|
+
void StopRaf();
|
|
131
|
+
|
|
132
|
+
static void __StartRaf(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
133
|
+
|
|
134
|
+
static void __FastStartRaf(v8::Local<v8::Object> receiver_obj) {
|
|
135
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
136
|
+
if (ptr == nullptr) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
ptr->StartRaf();
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
static void __StopRaf(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
145
|
+
|
|
146
|
+
static void __FastStopRaf(v8::Local<v8::Object> receiver_obj) {
|
|
147
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
148
|
+
if (ptr == nullptr) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
ptr->StopRaf();
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
124
156
|
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
125
157
|
|
|
126
158
|
static CanvasRenderingContext2DImpl *GetPointer(const v8::Local<v8::Object> &object);
|
|
@@ -163,6 +195,15 @@ public:
|
|
|
163
195
|
|
|
164
196
|
static void __Resize(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
165
197
|
|
|
198
|
+
|
|
199
|
+
static void SetContinuousRenderMode(v8::Local<v8::String> property,
|
|
200
|
+
v8::Local<v8::Value> value,
|
|
201
|
+
const v8::PropertyCallbackInfo<void> &info);
|
|
202
|
+
|
|
203
|
+
static void GetContinuousRenderMode(v8::Local<v8::String> property,
|
|
204
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
205
|
+
|
|
206
|
+
|
|
166
207
|
static void GetFilter(v8::Local<v8::String> property,
|
|
167
208
|
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
168
209
|
|
|
@@ -489,18 +530,10 @@ public:
|
|
|
489
530
|
|
|
490
531
|
if (GetNativeType(path_obj) == NativeType::Path2D) {
|
|
491
532
|
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
|
-
}
|
|
533
|
+
canvas_native_context_clip(
|
|
534
|
+
ptr->GetContext(), path->GetPath(), rule);
|
|
501
535
|
}
|
|
502
536
|
|
|
503
|
-
|
|
504
537
|
}
|
|
505
538
|
|
|
506
539
|
static void ClosePath(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -800,18 +833,10 @@ public:
|
|
|
800
833
|
auto object = Path2D::GetPointer(path);
|
|
801
834
|
|
|
802
835
|
if (object != nullptr) {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
ptr->GetContext(),
|
|
808
|
-
object->GetPath(),
|
|
809
|
-
rule);
|
|
810
|
-
break;
|
|
811
|
-
default:
|
|
812
|
-
break;
|
|
813
|
-
}
|
|
814
|
-
|
|
836
|
+
canvas_native_context_fill_with_path(
|
|
837
|
+
ptr->GetContext(),
|
|
838
|
+
object->GetPath(),
|
|
839
|
+
rule);
|
|
815
840
|
ptr->UpdateInvalidateState();
|
|
816
841
|
}
|
|
817
842
|
}
|
|
@@ -837,16 +862,9 @@ public:
|
|
|
837
862
|
return;
|
|
838
863
|
}
|
|
839
864
|
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
canvas_native_context_fill(
|
|
844
|
-
ptr->GetContext(), rule);
|
|
845
|
-
ptr->UpdateInvalidateState();
|
|
846
|
-
break;
|
|
847
|
-
default:
|
|
848
|
-
break;
|
|
849
|
-
}
|
|
865
|
+
canvas_native_context_fill(
|
|
866
|
+
ptr->GetContext(), rule);
|
|
867
|
+
ptr->UpdateInvalidateState();
|
|
850
868
|
}
|
|
851
869
|
|
|
852
870
|
static void FastFill(v8::Local<v8::Object> receiver_obj) {
|
|
@@ -907,18 +925,8 @@ public:
|
|
|
907
925
|
return false;
|
|
908
926
|
}
|
|
909
927
|
|
|
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;
|
|
928
|
+
return canvas_native_context_is_point_in_path(
|
|
929
|
+
ptr->GetContext(), static_cast<float>(x), static_cast<float>(y), rule);
|
|
922
930
|
}
|
|
923
931
|
|
|
924
932
|
static bool
|
|
@@ -939,17 +947,9 @@ public:
|
|
|
939
947
|
auto path = Path2D::GetPointer(path_obj);
|
|
940
948
|
|
|
941
949
|
|
|
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
|
-
}
|
|
950
|
+
ret = canvas_native_context_is_point_in_path_with_path(
|
|
951
|
+
ptr->GetContext(),
|
|
952
|
+
path->GetPath(), x, y, rule);
|
|
953
953
|
|
|
954
954
|
}
|
|
955
955
|
return ret;
|
|
@@ -1385,4 +1385,6 @@ private:
|
|
|
1385
1385
|
|
|
1386
1386
|
std::shared_ptr<RafImpl> raf_;
|
|
1387
1387
|
|
|
1388
|
+
bool continuousRender_ = true;
|
|
1389
|
+
|
|
1388
1390
|
};
|
|
@@ -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));
|
|
@@ -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"
|