@nativescript/canvas 2.0.0-beta.2 → 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/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 +111 -44
- 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
package/Dom/shapes/Line.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Property } from '@nativescript/core';
|
|
2
2
|
import { Paint } from '../Paint';
|
|
3
|
+
import { Path2D } from '../../Canvas2D';
|
|
3
4
|
export const p1Property = new Property({
|
|
4
5
|
name: 'p1',
|
|
5
6
|
valueConverter(value) {
|
|
@@ -21,13 +22,14 @@ export class Line extends Paint {
|
|
|
21
22
|
const context = this._canvas.getContext('2d');
|
|
22
23
|
const line = new Path2D();
|
|
23
24
|
line.lineTo(this.p1, this.p2);
|
|
24
|
-
const
|
|
25
|
+
const color = this._getColor();
|
|
26
|
+
const style = this._getPaintStyle();
|
|
25
27
|
if (style === 'fill') {
|
|
26
|
-
context.fillStyle =
|
|
28
|
+
context.fillStyle = color;
|
|
27
29
|
context.fill(line);
|
|
28
30
|
}
|
|
29
31
|
else if (style === 'stroke') {
|
|
30
|
-
context.strokeStyle =
|
|
32
|
+
context.strokeStyle = color;
|
|
31
33
|
context.stroke(line);
|
|
32
34
|
}
|
|
33
35
|
}
|
package/Dom/shapes/Line.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Line.js","sourceRoot":"","sources":["../../../../../packages/canvas/Dom/shapes/Line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAoB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"Line.js","sourceRoot":"","sources":["../../../../../packages/canvas/Dom/shapes/Line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAoB,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,QAAQ,CAAe;IACpD,IAAI,EAAE,IAAI;IACV,cAAc,CAAC,KAAK;QACnB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,QAAQ,CAAe;IACpD,IAAI,EAAE,IAAI;IACV,cAAc,CAAC,KAAK;QACnB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACD,CAAC,CAAC;AAEH,MAAM,OAAO,IAAK,SAAQ,KAAK;IAI9B,IAAI;QACH,IAAI,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI,IAAI,CAAC,EAAE,KAAK,SAAS,EAAE;YACnD,OAAO;SACP;QACD,MAAM,cAAc,GAAI,IAAI,CAAC,MAAc,CAAC,cAAc,CAAC;QAC3D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAoC,CAAC;QACjF,MAAM,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAEpC,IAAI,KAAK,KAAK,MAAM,EAAE;YACrB,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACnB;aAAM,IAAI,KAAK,KAAK,QAAQ,EAAE;YAC9B,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC;YAC5B,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SACrB;IACF,CAAC;CACD;AAED,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC1B,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC"}
|
package/Dom/shapes/Rect.js
CHANGED
|
@@ -34,14 +34,16 @@ export class Rect extends Paint {
|
|
|
34
34
|
context.rect(this.x, this.y, this.width, this.height);
|
|
35
35
|
if (this._children.length > 0) {
|
|
36
36
|
for (const child of this._children) {
|
|
37
|
-
|
|
37
|
+
const color = child._getColor();
|
|
38
|
+
const style = child._getPaintStyle();
|
|
39
|
+
switch (style) {
|
|
38
40
|
case 'fill':
|
|
39
|
-
context.fillStyle =
|
|
41
|
+
context.fillStyle = color;
|
|
40
42
|
context.fill();
|
|
41
43
|
break;
|
|
42
44
|
case 'stroke':
|
|
43
|
-
context.strokeStyle =
|
|
44
|
-
context.lineWidth = child.
|
|
45
|
+
context.strokeStyle = color;
|
|
46
|
+
context.lineWidth = child._getStrokeWidth();
|
|
45
47
|
context.stroke();
|
|
46
48
|
break;
|
|
47
49
|
}
|
|
@@ -52,7 +54,12 @@ export class Rect extends Paint {
|
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
_addViewToNativeVisualTree(view, atIndex) {
|
|
55
|
-
if (view
|
|
57
|
+
if (view === this._canvas) {
|
|
58
|
+
this.nativeView.addView(this._canvas.nativeView);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
else if (view instanceof Paint) {
|
|
62
|
+
view._canvas = this._canvas;
|
|
56
63
|
this._children.push(view);
|
|
57
64
|
}
|
|
58
65
|
return false;
|
package/Dom/shapes/Rect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rect.js","sourceRoot":"","sources":["../../../../../packages/canvas/Dom/shapes/Rect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAA8B,MAAM,oBAAoB,CAAC;AAEzF,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,QAAQ,CAAe;IACnD,IAAI,EAAE,GAAG;IACT,cAAc,CAAC,KAAK;QACnB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,QAAQ,CAAe;IACnD,IAAI,EAAE,GAAG;IACT,cAAc,CAAC,KAAK;QACnB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,QAAQ,CAAe;IACvD,IAAI,EAAE,OAAO;IACb,cAAc,CAAC,KAAK;QACnB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,QAAQ,CAAe;IACxD,IAAI,EAAE,QAAQ;IACd,cAAc,CAAC,KAAK;QACnB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACD,CAAC,CAAC;AAEH,MAAM,OAAO,IAAK,SAAQ,KAAK;IAA/B;;QAMC,cAAS,GAAY,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"Rect.js","sourceRoot":"","sources":["../../../../../packages/canvas/Dom/shapes/Rect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAA8B,MAAM,oBAAoB,CAAC;AAEzF,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,QAAQ,CAAe;IACnD,IAAI,EAAE,GAAG;IACT,cAAc,CAAC,KAAK;QACnB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,QAAQ,CAAe;IACnD,IAAI,EAAE,GAAG;IACT,cAAc,CAAC,KAAK;QACnB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,QAAQ,CAAe;IACvD,IAAI,EAAE,OAAO;IACb,cAAc,CAAC,KAAK;QACnB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,QAAQ,CAAe;IACxD,IAAI,EAAE,QAAQ;IACd,cAAc,CAAC,KAAK;QACnB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACD,CAAC,CAAC;AAEH,MAAM,OAAO,IAAK,SAAQ,KAAK;IAA/B;;QAMC,cAAS,GAAY,EAAE,CAAC;IAoCzB,CAAC;IAlCA,IAAI;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAoC,CAAC;QACjF,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,SAAS,EAAE;gBACnC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;gBAChC,MAAM,KAAK,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC;gBACrC,QAAQ,KAAK,EAAE;oBACd,KAAK,MAAM;wBACV,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;wBAC1B,OAAO,CAAC,IAAI,EAAE,CAAC;wBACf,MAAM;oBACP,KAAK,QAAQ;wBACZ,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC;wBAC5B,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC,eAAe,EAAE,CAAC;wBAC5C,OAAO,CAAC,MAAM,EAAE,CAAC;wBACjB,MAAM;iBACP;aACD;SACD;aAAM;YACN,KAAK,CAAC,IAAI,EAAE,CAAC;SACb;IACF,CAAC;IAED,0BAA0B,CAAC,IAAc,EAAE,OAAgB;QAC1D,IAAI,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE;YAC1B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACjD,OAAO,IAAI,CAAC;SACZ;aAAM,IAAI,IAAI,YAAY,KAAK,EAAE;YACjC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC1B;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AAED,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACzB,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC"}
|
package/package.json
CHANGED
|
Binary file
|
package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative
CHANGED
|
Binary file
|
|
@@ -1213,6 +1213,8 @@ bool canvas_native_webgl_make_current(struct WebGLState *state);
|
|
|
1213
1213
|
|
|
1214
1214
|
bool canvas_native_webgl_swap_buffers(struct WebGLState *state);
|
|
1215
1215
|
|
|
1216
|
+
bool canvas_native_webgl_make_current_and_swap_buffers(struct WebGLState *state);
|
|
1217
|
+
|
|
1216
1218
|
void canvas_native_webgl_resized(struct WebGLState *_state);
|
|
1217
1219
|
|
|
1218
1220
|
const char *canvas_native_webgl_to_data_url(struct WebGLState *state,
|
|
Binary file
|
|
Binary file
|
|
@@ -1213,6 +1213,8 @@ bool canvas_native_webgl_make_current(struct WebGLState *state);
|
|
|
1213
1213
|
|
|
1214
1214
|
bool canvas_native_webgl_swap_buffers(struct WebGLState *state);
|
|
1215
1215
|
|
|
1216
|
+
bool canvas_native_webgl_make_current_and_swap_buffers(struct WebGLState *state);
|
|
1217
|
+
|
|
1216
1218
|
void canvas_native_webgl_resized(struct WebGLState *_state);
|
|
1217
1219
|
|
|
1218
1220
|
const char *canvas_native_webgl_to_data_url(struct WebGLState *state,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
</data>
|
|
19
19
|
<key>Headers/canvas_native.h</key>
|
|
20
20
|
<data>
|
|
21
|
-
|
|
21
|
+
fHjKG7aDZ9ZVi79Vu9g8z8IS9lo=
|
|
22
22
|
</data>
|
|
23
23
|
<key>Info.plist</key>
|
|
24
24
|
<data>
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
<dict>
|
|
109
109
|
<key>hash2</key>
|
|
110
110
|
<data>
|
|
111
|
-
|
|
111
|
+
aufqGvTGgpXa9ipXAyNSFoJPEdAdB2J5O3Cf8sPHYMM=
|
|
112
112
|
</data>
|
|
113
113
|
</dict>
|
|
114
114
|
<key>Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo</key>
|
|
Binary file
|
|
@@ -6,6 +6,11 @@
|
|
|
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));
|
|
@@ -251,6 +256,27 @@ CanvasRenderingContext2DImpl::GetPointer(const v8::Local<v8::Object> &object) {
|
|
|
251
256
|
return static_cast<CanvasRenderingContext2DImpl *>(ptr);
|
|
252
257
|
}
|
|
253
258
|
|
|
259
|
+
|
|
260
|
+
void CanvasRenderingContext2DImpl::StartRaf() {
|
|
261
|
+
auto raf = this->GetRaf();
|
|
262
|
+
if (raf != nullptr) {
|
|
263
|
+
if (!canvas_native_raf_get_started(raf->GetRaf())) {
|
|
264
|
+
canvas_native_raf_start(raf->GetRaf());
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
void CanvasRenderingContext2DImpl::StopRaf() {
|
|
271
|
+
auto raf = this->GetRaf();
|
|
272
|
+
if (raf != nullptr) {
|
|
273
|
+
if (canvas_native_raf_get_started(raf->GetRaf())) {
|
|
274
|
+
canvas_native_raf_stop(raf->GetRaf());
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
|
|
254
280
|
v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolate *isolate) {
|
|
255
281
|
auto cache = Caches::Get(isolate);
|
|
256
282
|
auto ctor = cache->CanvasRenderingContext2DTmpl.get();
|
|
@@ -264,6 +290,13 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
264
290
|
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
265
291
|
tmpl->SetInternalFieldCount(2);
|
|
266
292
|
|
|
293
|
+
|
|
294
|
+
SetFastMethod(isolate, tmpl, "__startRaf", __StartRaf, &fast_start_raf_,
|
|
295
|
+
v8::Local<v8::Value>());
|
|
296
|
+
|
|
297
|
+
SetFastMethod(isolate, tmpl, "__stopRaf", __StopRaf, &fast_stop_raf_,
|
|
298
|
+
v8::Local<v8::Value>());
|
|
299
|
+
|
|
267
300
|
SetFastMethod(isolate, tmpl, "drawPoint", DrawPoint, &fast_draw_point_, v8::Local<v8::Value>());
|
|
268
301
|
|
|
269
302
|
tmpl->Set(ConvertToV8String(isolate, "drawPoints"),
|
|
@@ -278,6 +311,9 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
278
311
|
v8::FunctionTemplate::New(isolate, __GetPointer));
|
|
279
312
|
tmpl->Set(ConvertToV8String(isolate, "__resize"), v8::FunctionTemplate::New(isolate, __Resize));
|
|
280
313
|
|
|
314
|
+
tmpl->SetAccessor(ConvertToV8String(isolate, "continuousRenderMode"), GetContinuousRenderMode,
|
|
315
|
+
SetContinuousRenderMode);
|
|
316
|
+
|
|
281
317
|
tmpl->SetAccessor(ConvertToV8String(isolate, "filter"), GetFilter, SetFilter);
|
|
282
318
|
tmpl->SetAccessor(ConvertToV8String(isolate, "font"), GetFont, SetFont);
|
|
283
319
|
tmpl->SetAccessor(ConvertToV8String(isolate, "letterSpacing"), GetLetterSpacing,
|
|
@@ -319,24 +355,19 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
319
355
|
|
|
320
356
|
SetFastMethod(isolate, tmpl, "beginPath", BeginPath, &fast_begin_path_, v8::Local<v8::Value>());
|
|
321
357
|
|
|
322
|
-
|
|
323
358
|
SetFastMethod(isolate, tmpl, "bezierCurveTo", BezierCurveTo, &fast_bezier_curve_to_,
|
|
324
359
|
v8::Local<v8::Value>());
|
|
325
360
|
|
|
326
|
-
|
|
327
361
|
tmpl->Set(ConvertToV8String(isolate, "clearHitRegions"),
|
|
328
362
|
v8::FunctionTemplate::New(isolate, &ClearHitRegions));
|
|
329
363
|
|
|
330
|
-
|
|
331
364
|
SetFastMethod(isolate, tmpl, "clearRect", ClearRect, &fast_clear_rect_, v8::Local<v8::Value>());
|
|
332
365
|
|
|
333
|
-
|
|
334
366
|
SetFastMethodWithOverLoads(isolate, tmpl, "clip", Clip, fast_clip_overloads_,
|
|
335
367
|
v8::Local<v8::Value>());
|
|
336
368
|
|
|
337
369
|
SetFastMethod(isolate, tmpl, "closePath", ClosePath, &fast_close_path_, v8::Local<v8::Value>());
|
|
338
370
|
|
|
339
|
-
|
|
340
371
|
tmpl->Set(ConvertToV8String(isolate, "createImageData"),
|
|
341
372
|
v8::FunctionTemplate::New(isolate, &CreateImageData));
|
|
342
373
|
tmpl->Set(ConvertToV8String(isolate, "createPattern"),
|
|
@@ -352,7 +383,6 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
352
383
|
tmpl->Set(ConvertToV8String(isolate, "drawFocusIfNeeded"),
|
|
353
384
|
v8::FunctionTemplate::New(isolate, &DrawFocusIfNeeded));
|
|
354
385
|
|
|
355
|
-
|
|
356
386
|
SetFastMethodWithOverLoads(isolate, tmpl, "drawImage", DrawImage, fast_draw_overloads_,
|
|
357
387
|
v8::Local<v8::Value>());
|
|
358
388
|
|
|
@@ -466,6 +496,59 @@ RafImpl *CanvasRenderingContext2DImpl::GetRaf() {
|
|
|
466
496
|
return this->raf_.get();
|
|
467
497
|
}
|
|
468
498
|
|
|
499
|
+
|
|
500
|
+
void CanvasRenderingContext2DImpl::__StartRaf(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
501
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
502
|
+
if (ptr == nullptr) {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
ptr->StartRaf();
|
|
507
|
+
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
void CanvasRenderingContext2DImpl::__StopRaf(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
511
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
512
|
+
if (ptr == nullptr) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
ptr->StopRaf();
|
|
517
|
+
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
void CanvasRenderingContext2DImpl::GetContinuousRenderMode(v8::Local<v8::String> property,
|
|
522
|
+
const v8::PropertyCallbackInfo<v8::Value> &info) {
|
|
523
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
|
|
524
|
+
if (ptr == nullptr) {
|
|
525
|
+
info.GetReturnValue().Set(false);
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
info.GetReturnValue().Set(ptr->continuousRender_);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
void CanvasRenderingContext2DImpl::SetContinuousRenderMode(v8::Local<v8::String> property,
|
|
532
|
+
v8::Local<v8::Value> value,
|
|
533
|
+
const v8::PropertyCallbackInfo<void> &info) {
|
|
534
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(info.This());
|
|
535
|
+
if (ptr == nullptr) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
auto isolate = info.GetIsolate();
|
|
539
|
+
auto val = value->BooleanValue(isolate);
|
|
540
|
+
if (val == ptr->continuousRender_) {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
if (val) {
|
|
544
|
+
ptr->StartRaf();
|
|
545
|
+
} else {
|
|
546
|
+
ptr->StopRaf();
|
|
547
|
+
}
|
|
548
|
+
ptr->continuousRender_ = val;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
|
|
469
552
|
/* Non Standard 2D */
|
|
470
553
|
|
|
471
554
|
void CanvasRenderingContext2DImpl::DrawPoint(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
@@ -490,53 +573,41 @@ void CanvasRenderingContext2DImpl::DrawPoints(const v8::FunctionCallbackInfo<v8:
|
|
|
490
573
|
if (ptr == nullptr) {
|
|
491
574
|
return;
|
|
492
575
|
}
|
|
493
|
-
|
|
576
|
+
|
|
494
577
|
auto isolate = args.GetIsolate();
|
|
495
578
|
auto context = isolate->GetCurrentContext();
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
auto mode =
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
auto mode = args[0];
|
|
499
582
|
auto points = args[1].As<v8::Array>();
|
|
500
583
|
auto size = points->Length();
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
if (mode == "points") {
|
|
506
|
-
pointMode = 0;
|
|
507
|
-
} else if (mode == "lines") {
|
|
508
|
-
pointMode = 1;
|
|
509
|
-
} else if (mode == "polygon") {
|
|
510
|
-
pointMode = 2;
|
|
511
|
-
}
|
|
512
|
-
if (pointMode == -1) {
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
584
|
+
|
|
585
|
+
if (size == 0){return;}
|
|
586
|
+
uint32_t pointMode = 0;
|
|
587
|
+
if(mode->IsUint32() && mode->Uint32Value(context).To(&pointMode)){
|
|
515
588
|
std::vector<float> store;
|
|
516
|
-
|
|
517
|
-
|
|
589
|
+
auto len = size * 2;
|
|
590
|
+
store.reserve(len);
|
|
518
591
|
for (int i = 0; i < size; i++) {
|
|
519
|
-
|
|
592
|
+
|
|
520
593
|
auto object = points->Get(
|
|
521
|
-
|
|
522
|
-
|
|
594
|
+
context, i).ToLocalChecked().As<v8::Object>();
|
|
595
|
+
|
|
523
596
|
auto x = object->Get(context,
|
|
524
597
|
ConvertToV8String(isolate, "x")).ToLocalChecked()->NumberValue(
|
|
525
|
-
|
|
598
|
+
context).ToChecked();
|
|
526
599
|
auto y = object->Get(context,
|
|
527
600
|
ConvertToV8String(isolate, "y")).ToLocalChecked()->NumberValue(
|
|
528
|
-
|
|
529
|
-
store
|
|
530
|
-
store
|
|
531
|
-
|
|
532
|
-
next = i + 2;
|
|
601
|
+
context).ToChecked();
|
|
602
|
+
store.emplace_back((float) x);
|
|
603
|
+
store.emplace_back((float) y);
|
|
533
604
|
}
|
|
534
|
-
|
|
605
|
+
|
|
535
606
|
canvas_native_context_draw_points(
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
607
|
+
ptr->GetContext(), pointMode,
|
|
608
|
+
store.data(), store.size());
|
|
609
|
+
|
|
610
|
+
|
|
540
611
|
ptr->UpdateInvalidateState();
|
|
541
612
|
}
|
|
542
613
|
}
|
|
@@ -2785,11 +2856,7 @@ void CanvasRenderingContext2DImpl::Flush() {
|
|
|
2785
2856
|
auto state = (int) this->GetInvalidateState() & (int) InvalidateState::InvalidateStatePending;
|
|
2786
2857
|
if (state == (int) InvalidateState::InvalidateStatePending) {
|
|
2787
2858
|
this->SetInvalidateState(InvalidateState::InvalidateStateInvalidating);
|
|
2788
|
-
// canvas_native_context_flush(ptr->GetContext());
|
|
2789
|
-
|
|
2790
2859
|
canvas_native_context_render(this->GetContext());
|
|
2791
|
-
// canvas_native_context_gl_make_current(ptr->GetContext());
|
|
2792
|
-
// canvas_native_context_gl_swap_buffers(ptr->GetContext());
|
|
2793
2860
|
this->SetInvalidateState(InvalidateState::InvalidateStateNone);
|
|
2794
2861
|
}
|
|
2795
2862
|
}
|
|
@@ -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"
|