@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
|
@@ -15,8 +15,8 @@ ImageAssetImpl::ImageAssetImpl(ImageAsset *asset) : asset_(asset) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
ImageAssetImpl::~ImageAssetImpl() {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
canvas_native_image_asset_destroy(this->GetImageAsset());
|
|
19
|
+
asset_ = nullptr;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
void ImageAssetImpl::Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate) {
|
|
@@ -62,6 +62,10 @@ v8::Local<v8::FunctionTemplate> ImageAssetImpl::GetCtor(v8::Isolate *isolate) {
|
|
|
62
62
|
ConvertToV8String(isolate, "error"),
|
|
63
63
|
GetError);
|
|
64
64
|
|
|
65
|
+
tmpl->SetAccessor(
|
|
66
|
+
ConvertToV8String(isolate, "__addr"),
|
|
67
|
+
GetAddr);
|
|
68
|
+
|
|
65
69
|
tmpl->Set(
|
|
66
70
|
ConvertToV8String(isolate, "scale"),
|
|
67
71
|
v8::FunctionTemplate::New(isolate, &Scale));
|
|
@@ -112,7 +116,7 @@ void ImageAssetImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
112
116
|
|
|
113
117
|
auto ret = args.This();
|
|
114
118
|
|
|
115
|
-
SetNativeType(
|
|
119
|
+
SetNativeType(ret, NativeType::ImageAsset);
|
|
116
120
|
|
|
117
121
|
auto image_asset = canvas_native_image_asset_create();
|
|
118
122
|
|
|
@@ -149,6 +153,21 @@ ImageAssetImpl::GetHeight(v8::Local<v8::String> name,
|
|
|
149
153
|
info.GetReturnValue().Set(0);
|
|
150
154
|
}
|
|
151
155
|
|
|
156
|
+
|
|
157
|
+
void
|
|
158
|
+
ImageAssetImpl::GetAddr(v8::Local<v8::String> name,
|
|
159
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
160
|
+
auto ptr = GetPointer(info.This());
|
|
161
|
+
if (ptr != nullptr) {
|
|
162
|
+
auto isolate = info.GetIsolate();
|
|
163
|
+
auto addr = static_cast<intptr_t *>(static_cast<void *>(ptr->GetImageAsset()));
|
|
164
|
+
auto ret = std::to_string(*addr);
|
|
165
|
+
info.GetReturnValue().Set(ConvertToV8String(isolate, ret.c_str()));
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
info.GetReturnValue().SetEmptyString();
|
|
169
|
+
}
|
|
170
|
+
|
|
152
171
|
void
|
|
153
172
|
ImageAssetImpl::GetError(v8::Local<v8::String> name,
|
|
154
173
|
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
|
|
17
17
|
class ImageAssetImpl: ObjectWrapperImpl{
|
|
18
18
|
public:
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
ImageAssetImpl(ImageAsset* asset);
|
|
21
21
|
|
|
22
22
|
~ImageAssetImpl();
|
|
23
23
|
|
|
24
24
|
ImageAsset* GetImageAsset();
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
27
27
|
|
|
28
28
|
static ImageAssetImpl *GetPointer(const v8::Local<v8::Object>& object);
|
|
@@ -37,6 +37,9 @@ public:
|
|
|
37
37
|
static void GetHeight(v8::Local<v8::String> name,
|
|
38
38
|
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
39
39
|
|
|
40
|
+
static void GetAddr(v8::Local<v8::String> name,
|
|
41
|
+
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
42
|
+
|
|
40
43
|
static void GetError(v8::Local<v8::String> name,
|
|
41
44
|
const v8::PropertyCallbackInfo<v8::Value> &info);
|
|
42
45
|
|
|
@@ -12,17 +12,19 @@
|
|
|
12
12
|
|
|
13
13
|
class ObjectWrapperImpl {
|
|
14
14
|
public:
|
|
15
|
-
|
|
16
|
-
v8::HandleScope scopedHandle(isolate);
|
|
17
|
-
weakHandle_.Reset(isolate, object);
|
|
18
|
-
weakHandle_.SetWeak(this, Finalizer, v8::WeakCallbackType::kParameter);
|
|
19
|
-
}
|
|
20
|
-
|
|
15
|
+
|
|
21
16
|
static void Finalizer(const v8::WeakCallbackInfo<ObjectWrapperImpl> &data) {
|
|
22
17
|
auto *pThis = data.GetParameter();
|
|
23
18
|
pThis->weakHandle_.Reset();
|
|
24
19
|
delete pThis;
|
|
25
20
|
}
|
|
21
|
+
|
|
22
|
+
void BindFinalizer(v8::Isolate *isolate, const v8::Local<v8::Object> &object) {
|
|
23
|
+
v8::HandleScope scopedHandle(isolate);
|
|
24
|
+
weakHandle_.Reset(isolate, object);
|
|
25
|
+
weakHandle_.SetWeak(this, Finalizer, v8::WeakCallbackType::kParameter);
|
|
26
|
+
}
|
|
27
|
+
|
|
26
28
|
private:
|
|
27
29
|
v8::Global<v8::Object> weakHandle_;
|
|
28
30
|
|
|
@@ -6,10 +6,19 @@
|
|
|
6
6
|
#include "Caches.h"
|
|
7
7
|
#include "OneByteStringResource.h"
|
|
8
8
|
|
|
9
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_start_raf_(
|
|
10
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::__FastStartRaf));
|
|
11
|
+
|
|
12
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_stop_raf_(
|
|
13
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::__FastStopRaf));
|
|
9
14
|
|
|
10
15
|
v8::CFunction CanvasRenderingContext2DImpl::fast_draw_point_(
|
|
11
16
|
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastDrawPoint));
|
|
12
17
|
|
|
18
|
+
//v8::CFunction CanvasRenderingContext2DImpl::fast_draw_atlas_(
|
|
19
|
+
// v8::CFunction::Make(CanvasRenderingContext2DImpl::FastDrawAtlas));
|
|
20
|
+
|
|
21
|
+
|
|
13
22
|
v8::CFunction CanvasRenderingContext2DImpl::fast_ellipse_(
|
|
14
23
|
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastEllipse));
|
|
15
24
|
|
|
@@ -81,13 +90,19 @@ v8::CFunction CanvasRenderingContext2DImpl::fast_clear_rect_(
|
|
|
81
90
|
v8::CFunction CanvasRenderingContext2DImpl::fast_fill_rect_(
|
|
82
91
|
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastFillRect));
|
|
83
92
|
|
|
93
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_fill_oval_(
|
|
94
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastFillOval));
|
|
95
|
+
|
|
96
|
+
|
|
84
97
|
v8::CFunction CanvasRenderingContext2DImpl::fast_stroke_rect_(
|
|
85
98
|
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastStrokeRect));
|
|
86
99
|
|
|
100
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_stroke_oval_(
|
|
101
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastStrokeOval));
|
|
102
|
+
|
|
87
103
|
v8::CFunction CanvasRenderingContext2DImpl::fast_rotate_(
|
|
88
104
|
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastRotate));
|
|
89
105
|
|
|
90
|
-
|
|
91
106
|
v8::CFunction CanvasRenderingContext2DImpl::fast_fill_(
|
|
92
107
|
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastFill));
|
|
93
108
|
|
|
@@ -251,6 +266,27 @@ CanvasRenderingContext2DImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
|
251
266
|
return static_cast<CanvasRenderingContext2DImpl *>(ptr);
|
|
252
267
|
}
|
|
253
268
|
|
|
269
|
+
|
|
270
|
+
void CanvasRenderingContext2DImpl::StartRaf() {
|
|
271
|
+
auto raf = this->GetRaf();
|
|
272
|
+
if (raf != nullptr) {
|
|
273
|
+
if (!canvas_native_raf_get_started(raf->GetRaf())) {
|
|
274
|
+
canvas_native_raf_start(raf->GetRaf());
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
void CanvasRenderingContext2DImpl::StopRaf() {
|
|
281
|
+
auto raf = this->GetRaf();
|
|
282
|
+
if (raf != nullptr) {
|
|
283
|
+
if (canvas_native_raf_get_started(raf->GetRaf())) {
|
|
284
|
+
canvas_native_raf_stop(raf->GetRaf());
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
|
|
254
290
|
v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolate *isolate) {
|
|
255
291
|
auto cache = Caches::Get(isolate);
|
|
256
292
|
auto ctor = cache->CanvasRenderingContext2DTmpl.get();
|
|
@@ -264,6 +300,13 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
264
300
|
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
265
301
|
tmpl->SetInternalFieldCount(2);
|
|
266
302
|
|
|
303
|
+
|
|
304
|
+
SetFastMethod(isolate, tmpl, "__startRaf", __StartRaf, &fast_start_raf_,
|
|
305
|
+
v8::Local<v8::Value>());
|
|
306
|
+
|
|
307
|
+
SetFastMethod(isolate, tmpl, "__stopRaf", __StopRaf, &fast_stop_raf_,
|
|
308
|
+
v8::Local<v8::Value>());
|
|
309
|
+
|
|
267
310
|
SetFastMethod(isolate, tmpl, "drawPoint", DrawPoint, &fast_draw_point_, v8::Local<v8::Value>());
|
|
268
311
|
|
|
269
312
|
tmpl->Set(ConvertToV8String(isolate, "drawPoints"),
|
|
@@ -278,6 +321,9 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
278
321
|
v8::FunctionTemplate::New(isolate, __GetPointer));
|
|
279
322
|
tmpl->Set(ConvertToV8String(isolate, "__resize"), v8::FunctionTemplate::New(isolate, __Resize));
|
|
280
323
|
|
|
324
|
+
tmpl->SetAccessor(ConvertToV8String(isolate, "continuousRenderMode"), GetContinuousRenderMode,
|
|
325
|
+
SetContinuousRenderMode);
|
|
326
|
+
|
|
281
327
|
tmpl->SetAccessor(ConvertToV8String(isolate, "filter"), GetFilter, SetFilter);
|
|
282
328
|
tmpl->SetAccessor(ConvertToV8String(isolate, "font"), GetFont, SetFont);
|
|
283
329
|
tmpl->SetAccessor(ConvertToV8String(isolate, "letterSpacing"), GetLetterSpacing,
|
|
@@ -319,24 +365,19 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
319
365
|
|
|
320
366
|
SetFastMethod(isolate, tmpl, "beginPath", BeginPath, &fast_begin_path_, v8::Local<v8::Value>());
|
|
321
367
|
|
|
322
|
-
|
|
323
368
|
SetFastMethod(isolate, tmpl, "bezierCurveTo", BezierCurveTo, &fast_bezier_curve_to_,
|
|
324
369
|
v8::Local<v8::Value>());
|
|
325
370
|
|
|
326
|
-
|
|
327
371
|
tmpl->Set(ConvertToV8String(isolate, "clearHitRegions"),
|
|
328
372
|
v8::FunctionTemplate::New(isolate, &ClearHitRegions));
|
|
329
373
|
|
|
330
|
-
|
|
331
374
|
SetFastMethod(isolate, tmpl, "clearRect", ClearRect, &fast_clear_rect_, v8::Local<v8::Value>());
|
|
332
375
|
|
|
333
|
-
|
|
334
376
|
SetFastMethodWithOverLoads(isolate, tmpl, "clip", Clip, fast_clip_overloads_,
|
|
335
377
|
v8::Local<v8::Value>());
|
|
336
378
|
|
|
337
379
|
SetFastMethod(isolate, tmpl, "closePath", ClosePath, &fast_close_path_, v8::Local<v8::Value>());
|
|
338
380
|
|
|
339
|
-
|
|
340
381
|
tmpl->Set(ConvertToV8String(isolate, "createImageData"),
|
|
341
382
|
v8::FunctionTemplate::New(isolate, &CreateImageData));
|
|
342
383
|
tmpl->Set(ConvertToV8String(isolate, "createPattern"),
|
|
@@ -352,6 +393,11 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
352
393
|
tmpl->Set(ConvertToV8String(isolate, "drawFocusIfNeeded"),
|
|
353
394
|
v8::FunctionTemplate::New(isolate, &DrawFocusIfNeeded));
|
|
354
395
|
|
|
396
|
+
tmpl->Set(ConvertToV8String(isolate, "drawAtlas"),
|
|
397
|
+
v8::FunctionTemplate::New(isolate, &DrawAtlas));
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
// SetFastMethod(isolate, tmpl, "drawAtlas", DrawAtlas, &fast_draw_atlas_, v8::Local<v8::Value>());
|
|
355
401
|
|
|
356
402
|
SetFastMethodWithOverLoads(isolate, tmpl, "drawImage", DrawImage, fast_draw_overloads_,
|
|
357
403
|
v8::Local<v8::Value>());
|
|
@@ -365,6 +411,10 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
365
411
|
|
|
366
412
|
tmpl->Set(ConvertToV8String(isolate, "fillText"),
|
|
367
413
|
v8::FunctionTemplate::New(isolate, &FillText));
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
SetFastMethod(isolate, tmpl, "fillOval", FillOval, &fast_fill_oval_, v8::Local<v8::Value>());
|
|
417
|
+
|
|
368
418
|
tmpl->Set(ConvertToV8String(isolate, "getImageData"),
|
|
369
419
|
v8::FunctionTemplate::New(isolate, &GetImageData));
|
|
370
420
|
tmpl->Set(ConvertToV8String(isolate, "getLineDash"),
|
|
@@ -429,6 +479,10 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
429
479
|
fast_set_transform_overloads_, v8::Local<v8::Value>());
|
|
430
480
|
|
|
431
481
|
|
|
482
|
+
tmpl->Set(ConvertToV8String(isolate, "getTransform"),
|
|
483
|
+
v8::FunctionTemplate::New(isolate, &GetTransform));
|
|
484
|
+
|
|
485
|
+
|
|
432
486
|
SetFastMethodWithOverLoads(isolate, tmpl, "stroke", Stroke, fast_stroke_overloads_,
|
|
433
487
|
v8::Local<v8::Value>());
|
|
434
488
|
|
|
@@ -440,6 +494,10 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
440
494
|
tmpl->Set(ConvertToV8String(isolate, "strokeText"),
|
|
441
495
|
v8::FunctionTemplate::New(isolate, &StrokeText));
|
|
442
496
|
|
|
497
|
+
|
|
498
|
+
SetFastMethod(isolate, tmpl, "strokeOval", StrokeOval, &fast_stroke_oval_,
|
|
499
|
+
v8::Local<v8::Value>());
|
|
500
|
+
|
|
443
501
|
SetFastMethod(isolate, tmpl, "transform", Transform, &fast_transform_, v8::Local<v8::Value>());
|
|
444
502
|
|
|
445
503
|
|
|
@@ -462,6 +520,59 @@ RafImpl *CanvasRenderingContext2DImpl::GetRaf() {
|
|
|
462
520
|
return this->raf_.get();
|
|
463
521
|
}
|
|
464
522
|
|
|
523
|
+
|
|
524
|
+
void CanvasRenderingContext2DImpl::__StartRaf(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
525
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
526
|
+
if (ptr == nullptr) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
ptr->StartRaf();
|
|
531
|
+
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
void CanvasRenderingContext2DImpl::__StopRaf(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
535
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
536
|
+
if (ptr == nullptr) {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
ptr->StopRaf();
|
|
541
|
+
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
void CanvasRenderingContext2DImpl::GetContinuousRenderMode(v8::Local<v8::String> property,
|
|
546
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
547
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
|
|
548
|
+
if (ptr == nullptr) {
|
|
549
|
+
info.GetReturnValue().Set(false);
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
info.GetReturnValue().Set(ptr->continuousRender_);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
void CanvasRenderingContext2DImpl::SetContinuousRenderMode(v8::Local<v8::String> property,
|
|
556
|
+
v8::Local<v8::Value> value,
|
|
557
|
+
const v8::PropertyCallbackInfo<void> &info) {
|
|
558
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
|
|
559
|
+
if (ptr == nullptr) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
auto isolate = info.GetIsolate();
|
|
563
|
+
auto val = value->BooleanValue(isolate);
|
|
564
|
+
if (val == ptr->continuousRender_) {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
if (val) {
|
|
568
|
+
ptr->StartRaf();
|
|
569
|
+
} else {
|
|
570
|
+
ptr->StopRaf();
|
|
571
|
+
}
|
|
572
|
+
ptr->continuousRender_ = val;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
|
|
465
576
|
/* Non Standard 2D */
|
|
466
577
|
|
|
467
578
|
void CanvasRenderingContext2DImpl::DrawPoint(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
@@ -491,26 +602,16 @@ void CanvasRenderingContext2DImpl::DrawPoints(const v8::FunctionCallbackInfo<v8:
|
|
|
491
602
|
auto context = isolate->GetCurrentContext();
|
|
492
603
|
|
|
493
604
|
|
|
494
|
-
auto mode =
|
|
605
|
+
auto mode = args[0];
|
|
495
606
|
auto points = args[1].As<v8::Array>();
|
|
496
607
|
auto size = points->Length();
|
|
497
608
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
if (mode == "points") {
|
|
502
|
-
pointMode = 0;
|
|
503
|
-
} else if (mode == "lines") {
|
|
504
|
-
pointMode = 1;
|
|
505
|
-
} else if (mode == "polygon") {
|
|
506
|
-
pointMode = 2;
|
|
507
|
-
}
|
|
508
|
-
if (pointMode == -1) {
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
609
|
+
if (size == 0) { return; }
|
|
610
|
+
uint32_t pointMode = 0;
|
|
611
|
+
if (mode->IsUint32() && mode->Uint32Value(context).To(&pointMode)) {
|
|
511
612
|
std::vector<float> store;
|
|
512
|
-
|
|
513
|
-
|
|
613
|
+
auto len = size * 2;
|
|
614
|
+
store.reserve(len);
|
|
514
615
|
for (int i = 0; i < size; i++) {
|
|
515
616
|
|
|
516
617
|
auto object = points->Get(
|
|
@@ -522,10 +623,8 @@ void CanvasRenderingContext2DImpl::DrawPoints(const v8::FunctionCallbackInfo<v8:
|
|
|
522
623
|
auto y = object->Get(context,
|
|
523
624
|
ConvertToV8String(isolate, "y")).ToLocalChecked()->NumberValue(
|
|
524
625
|
context).ToChecked();
|
|
525
|
-
store
|
|
526
|
-
store
|
|
527
|
-
|
|
528
|
-
next = i + 2;
|
|
626
|
+
store.emplace_back((float) x);
|
|
627
|
+
store.emplace_back((float) y);
|
|
529
628
|
}
|
|
530
629
|
|
|
531
630
|
canvas_native_context_draw_points(
|
|
@@ -1787,6 +1886,143 @@ CanvasRenderingContext2DImpl::DrawFocusIfNeeded(const v8::FunctionCallbackInfo<v
|
|
|
1787
1886
|
}
|
|
1788
1887
|
|
|
1789
1888
|
|
|
1889
|
+
void
|
|
1890
|
+
CanvasRenderingContext2DImpl::DrawAtlas(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
1891
|
+
|
|
1892
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
1893
|
+
if (ptr == nullptr) {
|
|
1894
|
+
return;
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
auto count = args.Length();
|
|
1898
|
+
auto value = args[0];
|
|
1899
|
+
|
|
1900
|
+
if (value->IsNullOrUndefined() || !value->IsObject()) {
|
|
1901
|
+
return;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
auto isolate = args.GetIsolate();
|
|
1905
|
+
auto context = isolate->GetCurrentContext();
|
|
1906
|
+
auto image = value.As<v8::Object>();
|
|
1907
|
+
auto imageType = GetNativeType(image);
|
|
1908
|
+
|
|
1909
|
+
|
|
1910
|
+
auto xformValue = args[1];
|
|
1911
|
+
auto texValue = args[2];
|
|
1912
|
+
auto colorsValue = args[3];
|
|
1913
|
+
auto blendValue = args[4];
|
|
1914
|
+
|
|
1915
|
+
if (xformValue->IsArray() && texValue->IsArray()) {
|
|
1916
|
+
|
|
1917
|
+
std::vector<float> xform;
|
|
1918
|
+
std::vector<float> tex;
|
|
1919
|
+
|
|
1920
|
+
v8::Local<v8::Array> xformArray = xformValue.As<v8::Array>();
|
|
1921
|
+
v8::Local<v8::Array> texArray = texValue.As<v8::Array>();
|
|
1922
|
+
|
|
1923
|
+
auto xformLen = xformArray->Length();
|
|
1924
|
+
xform.reserve(xformLen);
|
|
1925
|
+
auto texLen = texArray->Length();
|
|
1926
|
+
tex.reserve(texLen);
|
|
1927
|
+
|
|
1928
|
+
|
|
1929
|
+
for (int i = 0; i < xformLen; i++) {
|
|
1930
|
+
xform.emplace_back((float) xformArray->Get(context, i).ToLocalChecked()->NumberValue(
|
|
1931
|
+
context).ToChecked());
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
for (int i = 0; i < texLen; i++) {
|
|
1935
|
+
tex.emplace_back((float) texArray->Get(context, i).ToLocalChecked()->NumberValue(
|
|
1936
|
+
context).ToChecked());
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
std::vector<std::string> colors;
|
|
1940
|
+
std::vector<const char *> colors_ref;
|
|
1941
|
+
|
|
1942
|
+
// dst-over
|
|
1943
|
+
int32_t mode = 4;
|
|
1944
|
+
|
|
1945
|
+
if (blendValue->IsInt32()) {
|
|
1946
|
+
blendValue->Int32Value(context).To(&mode);
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
if (colorsValue->IsArray()) {
|
|
1950
|
+
auto colorsArray = colorsValue.As<v8::Array>();
|
|
1951
|
+
auto colorsLen = colorsArray->Length();
|
|
1952
|
+
colors.reserve(colorsLen);
|
|
1953
|
+
colors_ref.reserve(colorsLen);
|
|
1954
|
+
for (int i = 0; i < colorsLen; i++) {
|
|
1955
|
+
auto str = ConvertFromV8String(isolate, texArray->Get(context, i).ToLocalChecked());
|
|
1956
|
+
colors.emplace_back(str);
|
|
1957
|
+
colors_ref.emplace_back(str.c_str());
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
switch (imageType) {
|
|
1962
|
+
case NativeType::ImageAsset: {
|
|
1963
|
+
auto image_asset = ImageAssetImpl::GetPointer(image);
|
|
1964
|
+
|
|
1965
|
+
if (image_asset != nullptr) {
|
|
1966
|
+
|
|
1967
|
+
if (colors.empty()) {
|
|
1968
|
+
canvas_native_context_draw_atlas_asset(ptr->GetContext(),
|
|
1969
|
+
image_asset->GetImageAsset(),
|
|
1970
|
+
xform.data(), xform.size(),
|
|
1971
|
+
tex.data(),
|
|
1972
|
+
tex.size(), nullptr,
|
|
1973
|
+
0, mode);
|
|
1974
|
+
} else {
|
|
1975
|
+
canvas_native_context_draw_atlas_asset(ptr->GetContext(),
|
|
1976
|
+
image_asset->GetImageAsset(),
|
|
1977
|
+
xform.data(), xform.size(),
|
|
1978
|
+
tex.data(),
|
|
1979
|
+
tex.size(), colors_ref.data(),
|
|
1980
|
+
colors_ref.size(), mode);
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
|
|
1984
|
+
ptr->UpdateInvalidateState();
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
break;
|
|
1988
|
+
case NativeType::ImageBitmap: {
|
|
1989
|
+
auto image_bitmap = ImageBitmapImpl::GetPointer(image);
|
|
1990
|
+
if (image_bitmap != nullptr) {
|
|
1991
|
+
if (colors.empty()) {
|
|
1992
|
+
canvas_native_context_draw_atlas_asset(ptr->GetContext(),
|
|
1993
|
+
image_bitmap->GetImageAsset(),
|
|
1994
|
+
xform.data(), xform.size(),
|
|
1995
|
+
tex.data(),
|
|
1996
|
+
tex.size(), nullptr,
|
|
1997
|
+
0, mode);
|
|
1998
|
+
} else {
|
|
1999
|
+
canvas_native_context_draw_atlas_asset(ptr->GetContext(),
|
|
2000
|
+
image_bitmap->GetImageAsset(),
|
|
2001
|
+
xform.data(), xform.size(),
|
|
2002
|
+
tex.data(),
|
|
2003
|
+
tex.size(), colors_ref.data(),
|
|
2004
|
+
colors_ref.size(), mode);
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
break;
|
|
2009
|
+
case NativeType::CanvasRenderingContext2D: {
|
|
2010
|
+
auto image_canvas = CanvasRenderingContext2DImpl::GetPointer(image);
|
|
2011
|
+
if (image_canvas != nullptr) {
|
|
2012
|
+
|
|
2013
|
+
ptr->UpdateInvalidateState();
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
break;
|
|
2017
|
+
default:
|
|
2018
|
+
break;
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
|
|
1790
2026
|
void
|
|
1791
2027
|
CanvasRenderingContext2DImpl::DrawImage(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
1792
2028
|
|
|
@@ -2007,33 +2243,19 @@ CanvasRenderingContext2DImpl::Fill(const v8::FunctionCallbackInfo<v8::Value> &ar
|
|
|
2007
2243
|
|
|
2008
2244
|
if (object != nullptr) {
|
|
2009
2245
|
auto rule = args[1]->Uint32Value(context).ToChecked();
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
ptr->GetContext(),
|
|
2015
|
-
object->GetPath(), rule);
|
|
2016
|
-
ptr->UpdateInvalidateState();
|
|
2017
|
-
break;
|
|
2018
|
-
default:
|
|
2019
|
-
break;
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2246
|
+
canvas_native_context_fill_with_path(
|
|
2247
|
+
ptr->GetContext(),
|
|
2248
|
+
object->GetPath(), rule);
|
|
2249
|
+
ptr->UpdateInvalidateState();
|
|
2022
2250
|
}
|
|
2023
2251
|
}
|
|
2024
2252
|
} else if (count == 1) {
|
|
2025
|
-
if (value->
|
|
2026
|
-
auto rule =
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
rule);
|
|
2032
|
-
ptr->UpdateInvalidateState();
|
|
2033
|
-
break;
|
|
2034
|
-
default:
|
|
2035
|
-
break;
|
|
2036
|
-
}
|
|
2253
|
+
if (value->IsUint32()) {
|
|
2254
|
+
auto rule = value->Uint32Value(context).ToChecked();
|
|
2255
|
+
canvas_native_context_fill(
|
|
2256
|
+
ptr->GetContext(),
|
|
2257
|
+
rule);
|
|
2258
|
+
ptr->UpdateInvalidateState();
|
|
2037
2259
|
} else if (value->IsObject()) {
|
|
2038
2260
|
auto type = GetNativeType(value.As<v8::Object>());
|
|
2039
2261
|
if (type == NativeType::Path2D) {
|
|
@@ -2100,6 +2322,26 @@ CanvasRenderingContext2DImpl::FillText(const v8::FunctionCallbackInfo<v8::Value>
|
|
|
2100
2322
|
|
|
2101
2323
|
}
|
|
2102
2324
|
|
|
2325
|
+
|
|
2326
|
+
void
|
|
2327
|
+
CanvasRenderingContext2DImpl::FillOval(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
2328
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
2329
|
+
if (ptr == nullptr) {
|
|
2330
|
+
return;
|
|
2331
|
+
}
|
|
2332
|
+
auto isolate = args.GetIsolate();
|
|
2333
|
+
auto context = isolate->GetCurrentContext();
|
|
2334
|
+
|
|
2335
|
+
auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
|
|
2336
|
+
auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
|
|
2337
|
+
auto width = static_cast<float>(args[2]->NumberValue(context).ToChecked());
|
|
2338
|
+
auto height = static_cast<float>(args[3]->NumberValue(context).ToChecked());
|
|
2339
|
+
canvas_native_context_fill_oval(
|
|
2340
|
+
ptr->GetContext(), x, y, width,
|
|
2341
|
+
height);
|
|
2342
|
+
ptr->UpdateInvalidateState();
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2103
2345
|
void
|
|
2104
2346
|
CanvasRenderingContext2DImpl::GetImageData(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
2105
2347
|
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
@@ -2186,16 +2428,8 @@ CanvasRenderingContext2DImpl::IsPointInPath(const v8::FunctionCallbackInfo<v8::V
|
|
|
2186
2428
|
auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
|
|
2187
2429
|
auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
|
|
2188
2430
|
auto rule = args[2]->Uint32Value(context).ToChecked();
|
|
2189
|
-
bool ret =
|
|
2190
|
-
|
|
2191
|
-
case 0:
|
|
2192
|
-
case 1:
|
|
2193
|
-
ret = canvas_native_context_is_point_in_path(
|
|
2194
|
-
ptr->GetContext(), x, y, rule);
|
|
2195
|
-
break;
|
|
2196
|
-
default:
|
|
2197
|
-
break;
|
|
2198
|
-
}
|
|
2431
|
+
bool ret = canvas_native_context_is_point_in_path(
|
|
2432
|
+
ptr->GetContext(), x, y, rule);
|
|
2199
2433
|
args.GetReturnValue().Set(ret);
|
|
2200
2434
|
return;
|
|
2201
2435
|
} else if (count == 4 &&
|
|
@@ -2210,20 +2444,12 @@ CanvasRenderingContext2DImpl::IsPointInPath(const v8::FunctionCallbackInfo<v8::V
|
|
|
2210
2444
|
auto x = static_cast<float>(args[1]->NumberValue(context).ToChecked());
|
|
2211
2445
|
auto y = static_cast<float>(args[2]->NumberValue(context).ToChecked());
|
|
2212
2446
|
auto rule = args[3]->Uint32Value(context).ToChecked();
|
|
2213
|
-
bool ret = false;
|
|
2214
2447
|
|
|
2215
2448
|
if (path != nullptr) {
|
|
2216
2449
|
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
ret = canvas_native_context_is_point_in_path_with_path(
|
|
2221
|
-
ptr->GetContext(),
|
|
2222
|
-
path->GetPath(), x, y, rule);
|
|
2223
|
-
break;
|
|
2224
|
-
default:
|
|
2225
|
-
break;
|
|
2226
|
-
}
|
|
2450
|
+
bool ret = canvas_native_context_is_point_in_path_with_path(
|
|
2451
|
+
ptr->GetContext(),
|
|
2452
|
+
path->GetPath(), x, y, rule);
|
|
2227
2453
|
|
|
2228
2454
|
args.GetReturnValue().Set(ret);
|
|
2229
2455
|
return;
|
|
@@ -2607,6 +2833,30 @@ CanvasRenderingContext2DImpl::SetTransform(const v8::FunctionCallbackInfo<v8::Va
|
|
|
2607
2833
|
}
|
|
2608
2834
|
}
|
|
2609
2835
|
|
|
2836
|
+
|
|
2837
|
+
void
|
|
2838
|
+
CanvasRenderingContext2DImpl::GetTransform(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
2839
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
2840
|
+
|
|
2841
|
+
auto isolate = args.GetIsolate();
|
|
2842
|
+
auto context = isolate->GetCurrentContext();
|
|
2843
|
+
|
|
2844
|
+
auto matrix = canvas_native_context_get_transform(ptr->GetContext());
|
|
2845
|
+
|
|
2846
|
+
|
|
2847
|
+
auto ret = MatrixImpl::GetCtor(isolate)->GetFunction(context).ToLocalChecked()->NewInstance(
|
|
2848
|
+
context).ToLocalChecked();
|
|
2849
|
+
auto object = new MatrixImpl(matrix);
|
|
2850
|
+
|
|
2851
|
+
ret->SetAlignedPointerInInternalField(0, object);
|
|
2852
|
+
|
|
2853
|
+
SetNativeType(ret, NativeType::Matrix);
|
|
2854
|
+
|
|
2855
|
+
object->BindFinalizer(isolate, ret);
|
|
2856
|
+
|
|
2857
|
+
args.GetReturnValue().Set(ret);
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2610
2860
|
void
|
|
2611
2861
|
CanvasRenderingContext2DImpl::Stroke(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
2612
2862
|
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
@@ -2678,6 +2928,27 @@ CanvasRenderingContext2DImpl::StrokeText(const v8::FunctionCallbackInfo<v8::Valu
|
|
|
2678
2928
|
}
|
|
2679
2929
|
}
|
|
2680
2930
|
|
|
2931
|
+
void
|
|
2932
|
+
CanvasRenderingContext2DImpl::StrokeOval(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
2933
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
2934
|
+
|
|
2935
|
+
auto isolate = args.GetIsolate();
|
|
2936
|
+
auto context = isolate->GetCurrentContext();
|
|
2937
|
+
|
|
2938
|
+
if (args.Length() == 4) {
|
|
2939
|
+
auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
|
|
2940
|
+
auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
|
|
2941
|
+
auto width = static_cast<float>(args[2]->NumberValue(context).ToChecked());
|
|
2942
|
+
auto height = static_cast<float>(args[3]->NumberValue(context).ToChecked());
|
|
2943
|
+
canvas_native_context_stroke_oval(
|
|
2944
|
+
ptr->GetContext(), x, y,
|
|
2945
|
+
width,
|
|
2946
|
+
height);
|
|
2947
|
+
ptr->UpdateInvalidateState();
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2950
|
+
|
|
2951
|
+
|
|
2681
2952
|
void
|
|
2682
2953
|
CanvasRenderingContext2DImpl::Transform(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
2683
2954
|
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
@@ -2787,11 +3058,7 @@ void CanvasRenderingContext2DImpl::Flush() {
|
|
|
2787
3058
|
auto state = (int) this->GetInvalidateState() & (int) InvalidateState::InvalidateStatePending;
|
|
2788
3059
|
if (state == (int) InvalidateState::InvalidateStatePending) {
|
|
2789
3060
|
this->SetInvalidateState(InvalidateState::InvalidateStateInvalidating);
|
|
2790
|
-
// canvas_native_context_flush(ptr->GetContext());
|
|
2791
|
-
|
|
2792
3061
|
canvas_native_context_render(this->GetContext());
|
|
2793
|
-
// canvas_native_context_gl_make_current(ptr->GetContext());
|
|
2794
|
-
// canvas_native_context_gl_swap_buffers(ptr->GetContext());
|
|
2795
3062
|
this->SetInvalidateState(InvalidateState::InvalidateStateNone);
|
|
2796
3063
|
}
|
|
2797
3064
|
}
|