@nativescript/canvas 2.0.0-alpha.44 → 2.0.0-alpha.45
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/package.json +1 -1
- package/platforms/android/canvas-release.aar +0 -0
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +81 -15
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +199 -1
- package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +27 -13
- package/platforms/ios/src/cpp/canvas2d/Path2D.h +30 -94
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +8 -22
package/package.json
CHANGED
|
Binary file
|
|
@@ -7,13 +7,55 @@
|
|
|
7
7
|
#include "OneByteStringResource.h"
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
v8::CFunction CanvasRenderingContext2DImpl::fast_close_path_(
|
|
10
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_close_path_(
|
|
11
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastClosePath));
|
|
11
12
|
|
|
12
|
-
v8::CFunction CanvasRenderingContext2DImpl::fast_begin_path_(
|
|
13
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_begin_path_(
|
|
14
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastBeginPath));
|
|
13
15
|
|
|
14
|
-
v8::CFunction CanvasRenderingContext2DImpl::fast_arc_(
|
|
16
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_arc_(
|
|
17
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastArc));
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_arc_to_(
|
|
20
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastArcTo));
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_save_(
|
|
24
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastSave));
|
|
25
|
+
|
|
26
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_restore_(
|
|
27
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastRestore));
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_translate_(
|
|
31
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastTranslate));
|
|
32
|
+
|
|
33
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_clear_rect_(
|
|
34
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastClearRect));
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_fill_(
|
|
38
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastFill));
|
|
39
|
+
|
|
40
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_fill_one_path_(
|
|
41
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastFillOnePath));
|
|
42
|
+
|
|
43
|
+
const v8::CFunction fast_fill_overloads_[] = {
|
|
44
|
+
CanvasRenderingContext2DImpl::fast_fill_,
|
|
45
|
+
CanvasRenderingContext2DImpl::fast_fill_one_path_
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_stroke_(
|
|
50
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastStroke));
|
|
51
|
+
|
|
52
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_stroke_path_(
|
|
53
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastStrokePath));
|
|
54
|
+
|
|
55
|
+
const v8::CFunction fast_stroke_overloads_[] = {
|
|
56
|
+
CanvasRenderingContext2DImpl::fast_stroke_,
|
|
57
|
+
CanvasRenderingContext2DImpl::fast_stroke_path_
|
|
58
|
+
};
|
|
17
59
|
|
|
18
60
|
|
|
19
61
|
CanvasRenderingContext2DImpl::CanvasRenderingContext2DImpl(
|
|
@@ -64,7 +106,6 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
64
106
|
}
|
|
65
107
|
|
|
66
108
|
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
67
|
-
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
68
109
|
ctorTmpl->SetClassName(ConvertToV8String(isolate, "CanvasRenderingContext2D"));
|
|
69
110
|
|
|
70
111
|
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
@@ -124,10 +165,13 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
124
165
|
|
|
125
166
|
SetFastMethod(isolate, tmpl, "arc", Arc, &fast_arc_, v8::Local<v8::Value>());
|
|
126
167
|
|
|
127
|
-
|
|
168
|
+
SetFastMethod(isolate, tmpl, "arcTo", ArcTo, &fast_arc_to_, v8::Local<v8::Value>());
|
|
169
|
+
|
|
170
|
+
// tmpl->Set(ConvertToV8String(isolate, "arcTo"), v8::FunctionTemplate::New(isolate, &ArcTo));
|
|
128
171
|
// tmpl->Set(ConvertToV8String(isolate, "beginPath"),
|
|
129
172
|
// v8::FunctionTemplate::New(isolate, &BeginPath));
|
|
130
173
|
|
|
174
|
+
|
|
131
175
|
SetFastMethod(isolate, tmpl, "beginPath", BeginPath, &fast_begin_path_, v8::Local<v8::Value>());
|
|
132
176
|
|
|
133
177
|
|
|
@@ -135,8 +179,12 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
135
179
|
v8::FunctionTemplate::New(isolate, &BezierCurveTo));
|
|
136
180
|
tmpl->Set(ConvertToV8String(isolate, "clearHitRegions"),
|
|
137
181
|
v8::FunctionTemplate::New(isolate, &ClearHitRegions));
|
|
138
|
-
tmpl->Set(ConvertToV8String(isolate, "clearRect"),
|
|
139
|
-
v8::FunctionTemplate::New(isolate, &ClearRect));
|
|
182
|
+
// tmpl->Set(ConvertToV8String(isolate, "clearRect"),
|
|
183
|
+
// v8::FunctionTemplate::New(isolate, &ClearRect));
|
|
184
|
+
|
|
185
|
+
SetFastMethod(isolate, tmpl, "clearRect", ClearRect, &fast_clear_rect_, v8::Local<v8::Value>());
|
|
186
|
+
|
|
187
|
+
|
|
140
188
|
tmpl->Set(ConvertToV8String(isolate, "clip"), v8::FunctionTemplate::New(isolate, &Clip));
|
|
141
189
|
// tmpl->Set(ConvertToV8String(isolate, "closePath"),
|
|
142
190
|
// v8::FunctionTemplate::New(isolate, &ClosePath));
|
|
@@ -162,9 +210,10 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
162
210
|
tmpl->Set(ConvertToV8String(isolate, "drawImage"),
|
|
163
211
|
v8::FunctionTemplate::New(isolate, &DrawImage));
|
|
164
212
|
tmpl->Set(ConvertToV8String(isolate, "ellipse"), v8::FunctionTemplate::New(isolate, &Ellipse));
|
|
165
|
-
tmpl->Set(ConvertToV8String(isolate, "fill"), v8::FunctionTemplate::New(isolate, &Fill));
|
|
213
|
+
// tmpl->Set(ConvertToV8String(isolate, "fill"), v8::FunctionTemplate::New(isolate, &Fill));
|
|
166
214
|
|
|
167
|
-
|
|
215
|
+
SetFastMethodWithOverLoads(isolate, tmpl, "fill", Fill, fast_fill_overloads_,
|
|
216
|
+
v8::Local<v8::Value>());
|
|
168
217
|
|
|
169
218
|
tmpl->Set(ConvertToV8String(isolate, "fillRect"),
|
|
170
219
|
v8::FunctionTemplate::New(isolate, &FillRect));
|
|
@@ -193,9 +242,17 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
193
242
|
v8::FunctionTemplate::New(isolate, &RemoveHitRegion));
|
|
194
243
|
tmpl->Set(ConvertToV8String(isolate, "resetTransform"),
|
|
195
244
|
v8::FunctionTemplate::New(isolate, &ResetTransform));
|
|
196
|
-
|
|
245
|
+
|
|
246
|
+
SetFastMethod(isolate, tmpl, "restore", Restore, &fast_restore_, v8::Local<v8::Value>());
|
|
247
|
+
|
|
248
|
+
// tmpl->Set(ConvertToV8String(isolate, "restore"), v8::FunctionTemplate::New(isolate, &Restore));
|
|
197
249
|
tmpl->Set(ConvertToV8String(isolate, "rotate"), v8::FunctionTemplate::New(isolate, &Rotate));
|
|
198
|
-
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
SetFastMethod(isolate, tmpl, "save", Save, &fast_save_, v8::Local<v8::Value>());
|
|
253
|
+
//tmpl->Set(ConvertToV8String(isolate, "save"), v8::FunctionTemplate::New(isolate, &Save));
|
|
254
|
+
|
|
255
|
+
|
|
199
256
|
tmpl->Set(ConvertToV8String(isolate, "scale"), v8::FunctionTemplate::New(isolate, &Scale));
|
|
200
257
|
tmpl->Set(ConvertToV8String(isolate, "scrollPathIntoView"),
|
|
201
258
|
v8::FunctionTemplate::New(isolate, &ScrollPathIntoView));
|
|
@@ -203,15 +260,24 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
203
260
|
v8::FunctionTemplate::New(isolate, &SetLineDash));
|
|
204
261
|
tmpl->Set(ConvertToV8String(isolate, "setTransform"),
|
|
205
262
|
v8::FunctionTemplate::New(isolate, &SetTransform));
|
|
206
|
-
tmpl->Set(ConvertToV8String(isolate, "stroke"), v8::FunctionTemplate::New(isolate, &Stroke));
|
|
263
|
+
// tmpl->Set(ConvertToV8String(isolate, "stroke"), v8::FunctionTemplate::New(isolate, &Stroke));
|
|
264
|
+
|
|
265
|
+
SetFastMethodWithOverLoads(isolate, tmpl, "stroke", Stroke, fast_stroke_overloads_,
|
|
266
|
+
v8::Local<v8::Value>());
|
|
267
|
+
|
|
268
|
+
|
|
207
269
|
tmpl->Set(ConvertToV8String(isolate, "strokeRect"),
|
|
208
270
|
v8::FunctionTemplate::New(isolate, &StrokeRect));
|
|
209
271
|
tmpl->Set(ConvertToV8String(isolate, "strokeText"),
|
|
210
272
|
v8::FunctionTemplate::New(isolate, &StrokeText));
|
|
211
273
|
tmpl->Set(ConvertToV8String(isolate, "transform"),
|
|
212
274
|
v8::FunctionTemplate::New(isolate, &Transform));
|
|
213
|
-
|
|
214
|
-
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
SetFastMethod(isolate, tmpl, "translate", Translate, &fast_translate_, v8::Local<v8::Value>());
|
|
278
|
+
|
|
279
|
+
// tmpl->Set(ConvertToV8String(isolate, "translate"),
|
|
280
|
+
// v8::FunctionTemplate::New(isolate, &Translate));
|
|
215
281
|
tmpl->Set(ConvertToV8String(isolate, "__toDataURL"),
|
|
216
282
|
v8::FunctionTemplate::New(isolate, &__ToDataURL));
|
|
217
283
|
|
|
@@ -220,7 +220,21 @@ public:
|
|
|
220
220
|
static v8::CFunction fast_begin_path_;
|
|
221
221
|
|
|
222
222
|
static v8::CFunction fast_arc_;
|
|
223
|
-
|
|
223
|
+
static v8::CFunction fast_arc_to_;
|
|
224
|
+
static v8::CFunction fast_clear_rect_;
|
|
225
|
+
|
|
226
|
+
static v8::CFunction fast_fill_;
|
|
227
|
+
static v8::CFunction fast_fill_one_path_;
|
|
228
|
+
|
|
229
|
+
static v8::CFunction fast_stroke_;
|
|
230
|
+
static v8::CFunction fast_stroke_path_;
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
static v8::CFunction fast_restore_;
|
|
234
|
+
|
|
235
|
+
static v8::CFunction fast_save_;
|
|
236
|
+
|
|
237
|
+
static v8::CFunction fast_translate_;
|
|
224
238
|
|
|
225
239
|
|
|
226
240
|
static void AddHitRegion(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -268,6 +282,25 @@ public:
|
|
|
268
282
|
|
|
269
283
|
static void ArcTo(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
270
284
|
|
|
285
|
+
static void FastArcTo(v8::Local<v8::Object> receiver_obj, double x1,
|
|
286
|
+
double y1,
|
|
287
|
+
double x2,
|
|
288
|
+
double y2,
|
|
289
|
+
double radius) {
|
|
290
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
291
|
+
if (ptr == nullptr) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
canvas_native_context_arc_to(
|
|
296
|
+
ptr->GetContext(), static_cast<float>(x1),
|
|
297
|
+
static_cast<float>(y1),
|
|
298
|
+
static_cast<float>(x2),
|
|
299
|
+
static_cast<float>(y2),
|
|
300
|
+
static_cast<float>(radius)
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
271
304
|
static void BeginPath(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
272
305
|
|
|
273
306
|
static void BeginPathImpl(CanvasRenderingContext2D *receiver_obj) {
|
|
@@ -289,6 +322,24 @@ public:
|
|
|
289
322
|
|
|
290
323
|
static void ClearRect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
291
324
|
|
|
325
|
+
|
|
326
|
+
static void FastClearRect(v8::Local<v8::Object> receiver_obj, double x, double y, double width,
|
|
327
|
+
double height) {
|
|
328
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
329
|
+
if (ptr == nullptr) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
canvas_native_context_clear_rect(
|
|
334
|
+
ptr->GetContext(),
|
|
335
|
+
static_cast<float>(x),
|
|
336
|
+
static_cast<float>(y),
|
|
337
|
+
static_cast<float>(width),
|
|
338
|
+
static_cast<float>(height)
|
|
339
|
+
);
|
|
340
|
+
ptr->UpdateInvalidateState();
|
|
341
|
+
}
|
|
342
|
+
|
|
292
343
|
static void Clip(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
293
344
|
|
|
294
345
|
static void ClosePath(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -330,6 +381,106 @@ public:
|
|
|
330
381
|
|
|
331
382
|
static void Fill(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
332
383
|
|
|
384
|
+
/* todo when fast string is supported
|
|
385
|
+
static void FastFillTwo(v8::Local<v8::Object> receiver_obj, v8::Local<v8::Object> path, string) {
|
|
386
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
387
|
+
if (ptr == nullptr) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
auto object = Path2D::GetPointer(path);
|
|
392
|
+
|
|
393
|
+
if (object != nullptr) {
|
|
394
|
+
auto data = ConvertFromV8String(isolate, args[1]);
|
|
395
|
+
canvas_native_context_fill_with_path(
|
|
396
|
+
ptr->GetContext(),
|
|
397
|
+
object->GetPath(),
|
|
398
|
+
data.c_str());
|
|
399
|
+
ptr->UpdateInvalidateState();
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
*/
|
|
404
|
+
|
|
405
|
+
static void FastFillOnePath(v8::Local<v8::Object> receiver_obj, v8::Local<v8::Object> path) {
|
|
406
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
407
|
+
if (ptr == nullptr) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
auto object = Path2D::GetPointer(path);
|
|
412
|
+
|
|
413
|
+
std::string rule("nonzero");
|
|
414
|
+
canvas_native_context_fill_with_path(
|
|
415
|
+
ptr->GetContext(),
|
|
416
|
+
object->GetPath(), rule.c_str());
|
|
417
|
+
ptr->UpdateInvalidateState();
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// todo when fast string is supported
|
|
421
|
+
/*
|
|
422
|
+
static void FastFillOneString(v8::Local<v8::Object> receiver_obj) {
|
|
423
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
424
|
+
if (ptr == nullptr) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
auto isolate = args.GetIsolate();
|
|
428
|
+
|
|
429
|
+
auto count = args.Length();
|
|
430
|
+
auto value = args[0];
|
|
431
|
+
if (count == 2) {
|
|
432
|
+
auto type = GetNativeType(isolate, value.As<v8::Object>());
|
|
433
|
+
if (type == NativeType::Path2D) {
|
|
434
|
+
auto object = Path2D::GetPointer(value.As<v8::Object>());
|
|
435
|
+
|
|
436
|
+
if (object != nullptr) {
|
|
437
|
+
auto data = ConvertFromV8String(isolate, args[1]);
|
|
438
|
+
canvas_native_context_fill_with_path(
|
|
439
|
+
ptr->GetContext(),
|
|
440
|
+
object->GetPath(),
|
|
441
|
+
data.c_str());
|
|
442
|
+
ptr->UpdateInvalidateState();
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
} else if (count == 1) {
|
|
447
|
+
if (value->IsString()) {
|
|
448
|
+
auto rule = ConvertFromV8String(isolate, value);
|
|
449
|
+
canvas_native_context_fill(
|
|
450
|
+
ptr->GetContext(), rule.c_str());
|
|
451
|
+
ptr->UpdateInvalidateState();
|
|
452
|
+
} else if (value->IsObject()) {
|
|
453
|
+
auto type = GetNativeType(isolate, value.As<v8::Object>());
|
|
454
|
+
if (type == NativeType::Path2D) {
|
|
455
|
+
auto object = Path2D::GetPointer(value.As<v8::Object>());
|
|
456
|
+
|
|
457
|
+
std::string rule("nonzero");
|
|
458
|
+
canvas_native_context_fill_with_path(
|
|
459
|
+
ptr->GetContext(),
|
|
460
|
+
object->GetPath(), rule.c_str());
|
|
461
|
+
ptr->UpdateInvalidateState();
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
} else {
|
|
465
|
+
std::string rule("nonzero");
|
|
466
|
+
canvas_native_context_fill(
|
|
467
|
+
ptr->GetContext(), rule.c_str());
|
|
468
|
+
ptr->UpdateInvalidateState();
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
*/
|
|
472
|
+
static void FastFill(v8::Local<v8::Object> receiver_obj) {
|
|
473
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
474
|
+
if (ptr == nullptr) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
std::string rule("nonzero");
|
|
479
|
+
canvas_native_context_fill(
|
|
480
|
+
ptr->GetContext(), rule.c_str());
|
|
481
|
+
ptr->UpdateInvalidateState();
|
|
482
|
+
}
|
|
483
|
+
|
|
333
484
|
static void FillRect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
334
485
|
|
|
335
486
|
static void FillText(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -362,10 +513,30 @@ public:
|
|
|
362
513
|
|
|
363
514
|
static void Restore(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
364
515
|
|
|
516
|
+
static void FastRestore(v8::Local<v8::Object> receiver_obj) {
|
|
517
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
518
|
+
if (ptr == nullptr) {
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
canvas_native_context_restore(
|
|
523
|
+
ptr->GetContext());
|
|
524
|
+
}
|
|
525
|
+
|
|
365
526
|
static void Rotate(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
366
527
|
|
|
367
528
|
static void Save(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
368
529
|
|
|
530
|
+
static void FastSave(v8::Local<v8::Object> receiver_obj) {
|
|
531
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
532
|
+
if (ptr == nullptr) {
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
canvas_native_context_save(
|
|
537
|
+
ptr->GetContext());
|
|
538
|
+
}
|
|
539
|
+
|
|
369
540
|
static void Scale(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
370
541
|
|
|
371
542
|
static void ScrollPathIntoView(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -376,6 +547,26 @@ public:
|
|
|
376
547
|
|
|
377
548
|
static void Stroke(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
378
549
|
|
|
550
|
+
static void FastStroke(v8::Local<v8::Object> receiver_obj) {
|
|
551
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
552
|
+
|
|
553
|
+
canvas_native_context_stroke(
|
|
554
|
+
ptr->GetContext());
|
|
555
|
+
ptr->UpdateInvalidateState();
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
static void FastStrokePath(v8::Local<v8::Object> receiver_obj, v8::Local<v8::Object> path_obj) {
|
|
559
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
560
|
+
|
|
561
|
+
auto path = Path2D::GetPointer(path_obj);
|
|
562
|
+
if (path != nullptr) {
|
|
563
|
+
canvas_native_context_stroke_with_path(
|
|
564
|
+
ptr->GetContext(),
|
|
565
|
+
path->GetPath());
|
|
566
|
+
ptr->UpdateInvalidateState();
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
379
570
|
static void StrokeRect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
380
571
|
|
|
381
572
|
static void StrokeText(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -384,6 +575,13 @@ public:
|
|
|
384
575
|
|
|
385
576
|
static void Translate(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
386
577
|
|
|
578
|
+
static void FastTranslate(v8::Local<v8::Object> receiver_obj, double x, double y) {
|
|
579
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
580
|
+
canvas_native_context_translate(
|
|
581
|
+
ptr->GetContext(), x, y);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
|
|
387
585
|
static void __ToDataURL(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
388
586
|
|
|
389
587
|
~CanvasRenderingContext2DImpl();
|
|
@@ -53,6 +53,20 @@ v8::CFunction Path2D::fast_rect_(v8::CFunction::Make(Path2D::FastRect));
|
|
|
53
53
|
|
|
54
54
|
//v8::CFunction Path2D::fast_round_rect_(v8::CFunction::Make(Path2D::FastRoundRect));
|
|
55
55
|
|
|
56
|
+
|
|
57
|
+
v8::CFunction Path2D::fast_round_rect_(
|
|
58
|
+
v8::CFunction::Make(Path2D::FastRoundRect));
|
|
59
|
+
|
|
60
|
+
v8::CFunction Path2D::fast_round_rect_array_(
|
|
61
|
+
v8::CFunction::Make(Path2D::FastRoundRectArray));
|
|
62
|
+
|
|
63
|
+
const v8::CFunction fast_round_rect_overloads_[] = {
|
|
64
|
+
Path2D::fast_round_rect_,
|
|
65
|
+
Path2D::fast_round_rect_array_
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
56
70
|
//v8::CFunction Path2D::fast_to_svg_(v8::CFunction::Make(Path2D::FastToSVG));
|
|
57
71
|
|
|
58
72
|
void Path2D::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
@@ -410,14 +424,6 @@ v8::Local<v8::FunctionTemplate> Path2D::GetCtor(v8::Isolate *isolate) {
|
|
|
410
424
|
|
|
411
425
|
tmpl->SetInternalFieldCount(1);
|
|
412
426
|
|
|
413
|
-
// tmpl->Set(
|
|
414
|
-
// ConvertToV8String(isolate, "addPath"),
|
|
415
|
-
// v8::FunctionTemplate::New(isolate, &AddPath));
|
|
416
|
-
|
|
417
|
-
// tmpl->Set(
|
|
418
|
-
// ConvertToV8String(isolate, "arc"),
|
|
419
|
-
// v8::FunctionTemplate::New(isolate, &Arc));
|
|
420
|
-
|
|
421
427
|
tmpl->Set(
|
|
422
428
|
ConvertToV8String(isolate, "arcTo"),
|
|
423
429
|
v8::FunctionTemplate::New(isolate, &ArcTo));
|
|
@@ -434,8 +440,16 @@ v8::Local<v8::FunctionTemplate> Path2D::GetCtor(v8::Isolate *isolate) {
|
|
|
434
440
|
SetFastMethod(isolate, tmpl, "quadraticCurveTo", QuadraticCurveTo, &fast_quadratic_curve_to_,
|
|
435
441
|
v8::Local<v8::Value>());
|
|
436
442
|
SetFastMethod(isolate, tmpl, "rect", Rect, &fast_rect_, v8::Local<v8::Value>());
|
|
437
|
-
|
|
438
|
-
|
|
443
|
+
SetFastMethodWithOverLoads(isolate, tmpl, "roundRect", RoundRect,
|
|
444
|
+
fast_round_rect_overloads_, v8::Local<v8::Value>());
|
|
445
|
+
|
|
446
|
+
// tmpl->Set(
|
|
447
|
+
// ConvertToV8String(isolate, "addPath"),
|
|
448
|
+
// v8::FunctionTemplate::New(isolate, &AddPath));
|
|
449
|
+
|
|
450
|
+
// tmpl->Set(
|
|
451
|
+
// ConvertToV8String(isolate, "arc"),
|
|
452
|
+
// v8::FunctionTemplate::New(isolate, &Arc));
|
|
439
453
|
|
|
440
454
|
|
|
441
455
|
// tmpl->Set(
|
|
@@ -470,9 +484,9 @@ v8::Local<v8::FunctionTemplate> Path2D::GetCtor(v8::Isolate *isolate) {
|
|
|
470
484
|
// ConvertToV8String(isolate, "rect"),
|
|
471
485
|
// v8::FunctionTemplate::New(isolate, &Rect));
|
|
472
486
|
|
|
473
|
-
tmpl->Set(
|
|
474
|
-
ConvertToV8String(isolate, "roundRect"),
|
|
475
|
-
v8::FunctionTemplate::New(isolate, &RoundRect));
|
|
487
|
+
// tmpl->Set(
|
|
488
|
+
// ConvertToV8String(isolate, "roundRect"),
|
|
489
|
+
// v8::FunctionTemplate::New(isolate, &RoundRect));
|
|
476
490
|
|
|
477
491
|
tmpl->Set(
|
|
478
492
|
ConvertToV8String(isolate, "__toSVG"),
|
|
@@ -61,6 +61,7 @@ public:
|
|
|
61
61
|
static v8::CFunction fast_quadratic_curve_to_;
|
|
62
62
|
static v8::CFunction fast_rect_;
|
|
63
63
|
static v8::CFunction fast_round_rect_;
|
|
64
|
+
static v8::CFunction fast_round_rect_array_;
|
|
64
65
|
// static v8::CFunction fast_to_svg_; // todo after v8 upgrade
|
|
65
66
|
|
|
66
67
|
|
|
@@ -307,7 +308,8 @@ public:
|
|
|
307
308
|
);
|
|
308
309
|
}
|
|
309
310
|
|
|
310
|
-
static void
|
|
311
|
+
static void
|
|
312
|
+
FastRect(v8::Local<v8::Object> receiver_obj, double x, double y, double width, double height) {
|
|
311
313
|
Path2D *ptr = GetPointer(receiver_obj);
|
|
312
314
|
if (ptr == nullptr) {
|
|
313
315
|
return;
|
|
@@ -323,115 +325,49 @@ public:
|
|
|
323
325
|
}
|
|
324
326
|
|
|
325
327
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
Path2D *ptr = GetPointer(
|
|
328
|
+
static void FastRoundRect(v8::Local<v8::Object> receiver_obj, double x, double y, double width,
|
|
329
|
+
double height, double radii) {
|
|
330
|
+
Path2D *ptr = GetPointer(receiver_obj);
|
|
329
331
|
if (ptr == nullptr) {
|
|
330
332
|
return;
|
|
331
333
|
}
|
|
332
334
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
auto x = static_cast<float>(args[0]->NumberValue(context).ToChecked());
|
|
339
|
-
auto y = static_cast<float>(args[1]->NumberValue(context).ToChecked());
|
|
340
|
-
auto width = static_cast<float>(args[2]->NumberValue(context).ToChecked());
|
|
341
|
-
auto height = static_cast<float>(args[3]->NumberValue(context).ToChecked());
|
|
342
|
-
auto objectOrNumber = args[4];
|
|
343
|
-
if (objectOrNumber->IsObject()) {
|
|
344
|
-
auto radii = objectOrNumber.As<v8::Object>();
|
|
345
|
-
if (radii->IsArray()) {
|
|
346
|
-
auto array = radii.As<v8::Array>();
|
|
347
|
-
auto size = array->Length();
|
|
348
|
-
|
|
349
|
-
if (size > 1) {
|
|
350
|
-
std::vector<float> store;
|
|
351
|
-
store.reserve(size);
|
|
352
|
-
for (int i = 0;
|
|
353
|
-
i < size; i++) {
|
|
354
|
-
store[i] = (float) array->Get(context, i).ToLocalChecked()->NumberValue(
|
|
355
|
-
context).ToChecked();
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
canvas_native_path_round_rect(
|
|
359
|
-
ptr->GetPath(),
|
|
360
|
-
x, y,
|
|
361
|
-
width,
|
|
362
|
-
height, store.data(),
|
|
363
|
-
store.size());
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
} else {
|
|
368
|
-
auto radii = (float) objectOrNumber->NumberValue(context).ToChecked();
|
|
369
|
-
canvas_native_path_round_rect_tl_tr_br_bl(
|
|
370
|
-
ptr->GetPath(), x, y,
|
|
371
|
-
width,
|
|
372
|
-
height, radii, radii,
|
|
373
|
-
radii, radii);
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
}
|
|
335
|
+
canvas_native_path_round_rect_tl_tr_br_bl(
|
|
336
|
+
ptr->GetPath(), static_cast<float>(x), static_cast<float>(y),
|
|
337
|
+
static_cast<float>(width),
|
|
338
|
+
static_cast<float>(height), static_cast<float>(radii), static_cast<float>(radii),
|
|
339
|
+
static_cast<float>(radii), static_cast<float>(radii));
|
|
377
340
|
|
|
378
|
-
args.GetReturnValue().SetUndefined();
|
|
379
341
|
}
|
|
380
342
|
|
|
381
|
-
static void
|
|
382
|
-
|
|
343
|
+
static void
|
|
344
|
+
FastRoundRectArray(v8::Local<v8::Object> receiver_obj, double x, double y, double width,
|
|
345
|
+
double height, v8::Local<v8::Array> value) {
|
|
346
|
+
Path2D *ptr = GetPointer(receiver_obj);
|
|
383
347
|
if (ptr == nullptr) {
|
|
384
348
|
return;
|
|
385
349
|
}
|
|
386
350
|
|
|
387
|
-
auto
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
auto array = radii.As<v8::Array>();
|
|
401
|
-
auto size = array->Length();
|
|
402
|
-
|
|
403
|
-
if (size > 1) {
|
|
404
|
-
std::vector<float> store;
|
|
405
|
-
store.reserve(size);
|
|
406
|
-
for (int i = 0;
|
|
407
|
-
i < size; i++) {
|
|
408
|
-
store[i] = (float) array->Get(context, i).ToLocalChecked()->NumberValue(
|
|
409
|
-
context).ToChecked();
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
canvas_native_path_round_rect(
|
|
413
|
-
ptr->GetPath(),
|
|
414
|
-
x, y,
|
|
415
|
-
width,
|
|
416
|
-
height, store.data(),
|
|
417
|
-
store.size());
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
} else {
|
|
422
|
-
auto radii = (float) objectOrNumber->NumberValue(context).ToChecked();
|
|
423
|
-
canvas_native_path_round_rect_tl_tr_br_bl(
|
|
424
|
-
ptr->GetPath(), x, y,
|
|
351
|
+
auto len = value->Length();
|
|
352
|
+
std::vector<float> buf;
|
|
353
|
+
buf.reserve(len);
|
|
354
|
+
|
|
355
|
+
auto copied = v8::TryToCopyAndConvertArrayToCppBuffer<v8::CTypeInfoBuilder<float>::Build().GetId(), float>(
|
|
356
|
+
value, nullptr, len);
|
|
357
|
+
|
|
358
|
+
if (copied) {
|
|
359
|
+
if (len > 1) {
|
|
360
|
+
|
|
361
|
+
canvas_native_path_round_rect(
|
|
362
|
+
ptr->GetPath(),
|
|
363
|
+
x, y,
|
|
425
364
|
width,
|
|
426
|
-
height,
|
|
427
|
-
|
|
365
|
+
height, buf.data(),
|
|
366
|
+
buf.size());
|
|
428
367
|
|
|
429
368
|
}
|
|
430
369
|
}
|
|
431
|
-
|
|
432
|
-
args.GetReturnValue().SetUndefined();
|
|
433
370
|
}
|
|
434
|
-
*/
|
|
435
371
|
|
|
436
372
|
|
|
437
373
|
/*
|
|
@@ -110,7 +110,6 @@ public:
|
|
|
110
110
|
static v8::CFunction fast_uniform_4fv_array_;
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
|
|
114
113
|
static v8::Local<v8::Object>
|
|
115
114
|
NewInstance(v8::Isolate *isolate, WebGLRenderingContext *renderingContext) {
|
|
116
115
|
auto context = isolate->GetCurrentContext();
|
|
@@ -492,7 +491,6 @@ public:
|
|
|
492
491
|
static void Uniform1fv(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
493
492
|
|
|
494
493
|
|
|
495
|
-
|
|
496
494
|
static void
|
|
497
495
|
FastUniform1fv(v8::Local<v8::Object> receiver_obj, v8::Local<v8::Object> location_obj,
|
|
498
496
|
const v8::FastApiTypedArray<float> &value) {
|
|
@@ -543,8 +541,6 @@ public:
|
|
|
543
541
|
}
|
|
544
542
|
|
|
545
543
|
|
|
546
|
-
|
|
547
|
-
|
|
548
544
|
static void Uniform1i(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
549
545
|
|
|
550
546
|
|
|
@@ -690,10 +686,6 @@ public:
|
|
|
690
686
|
}
|
|
691
687
|
|
|
692
688
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
689
|
static void Uniform3i(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
698
690
|
|
|
699
691
|
static void Uniform4f(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -742,11 +734,14 @@ public:
|
|
|
742
734
|
auto copied = v8::TryToCopyAndConvertArrayToCppBuffer<v8::CTypeInfoBuilder<float>::Build().GetId(), float>(
|
|
743
735
|
value, nullptr, len);
|
|
744
736
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
737
|
+
if (copied) {
|
|
738
|
+
canvas_native_webgl_uniform4fv(
|
|
739
|
+
location->GetUniformLocation(),
|
|
740
|
+
buf.data(),
|
|
741
|
+
buf.size(),
|
|
742
|
+
ptr->GetState());
|
|
743
|
+
}
|
|
744
|
+
|
|
750
745
|
|
|
751
746
|
}
|
|
752
747
|
}
|
|
@@ -813,10 +808,6 @@ public:
|
|
|
813
808
|
}
|
|
814
809
|
|
|
815
810
|
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
811
|
static void UniformMatrix3fv(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
821
812
|
|
|
822
813
|
|
|
@@ -877,11 +868,6 @@ public:
|
|
|
877
868
|
}
|
|
878
869
|
|
|
879
870
|
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
871
|
static void UniformMatrix4fv(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
886
872
|
|
|
887
873
|
static void
|