@nativescript/canvas 2.0.0-alpha.44 → 2.0.0-alpha.46
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 +113 -20
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +243 -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,66 @@
|
|
|
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_rect_(
|
|
38
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastFillRect));
|
|
39
|
+
|
|
40
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_stroke_rect_(
|
|
41
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastStrokeRect));
|
|
42
|
+
|
|
43
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_rotate_(
|
|
44
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastRotate));
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_fill_(
|
|
48
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastFill));
|
|
49
|
+
|
|
50
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_fill_one_path_(
|
|
51
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastFillOnePath));
|
|
52
|
+
|
|
53
|
+
const v8::CFunction fast_fill_overloads_[] = {
|
|
54
|
+
CanvasRenderingContext2DImpl::fast_fill_,
|
|
55
|
+
CanvasRenderingContext2DImpl::fast_fill_one_path_
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_stroke_(
|
|
61
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastStroke));
|
|
62
|
+
|
|
63
|
+
v8::CFunction CanvasRenderingContext2DImpl::fast_stroke_path_(
|
|
64
|
+
v8::CFunction::Make(CanvasRenderingContext2DImpl::FastStrokePath));
|
|
65
|
+
|
|
66
|
+
const v8::CFunction fast_stroke_overloads_[] = {
|
|
67
|
+
CanvasRenderingContext2DImpl::fast_stroke_,
|
|
68
|
+
CanvasRenderingContext2DImpl::fast_stroke_path_
|
|
69
|
+
};
|
|
17
70
|
|
|
18
71
|
|
|
19
72
|
CanvasRenderingContext2DImpl::CanvasRenderingContext2DImpl(
|
|
@@ -64,7 +117,6 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
64
117
|
}
|
|
65
118
|
|
|
66
119
|
v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
|
|
67
|
-
ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
68
120
|
ctorTmpl->SetClassName(ConvertToV8String(isolate, "CanvasRenderingContext2D"));
|
|
69
121
|
|
|
70
122
|
auto tmpl = ctorTmpl->InstanceTemplate();
|
|
@@ -124,10 +176,13 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
124
176
|
|
|
125
177
|
SetFastMethod(isolate, tmpl, "arc", Arc, &fast_arc_, v8::Local<v8::Value>());
|
|
126
178
|
|
|
127
|
-
|
|
179
|
+
SetFastMethod(isolate, tmpl, "arcTo", ArcTo, &fast_arc_to_, v8::Local<v8::Value>());
|
|
180
|
+
|
|
181
|
+
// tmpl->Set(ConvertToV8String(isolate, "arcTo"), v8::FunctionTemplate::New(isolate, &ArcTo));
|
|
128
182
|
// tmpl->Set(ConvertToV8String(isolate, "beginPath"),
|
|
129
183
|
// v8::FunctionTemplate::New(isolate, &BeginPath));
|
|
130
184
|
|
|
185
|
+
|
|
131
186
|
SetFastMethod(isolate, tmpl, "beginPath", BeginPath, &fast_begin_path_, v8::Local<v8::Value>());
|
|
132
187
|
|
|
133
188
|
|
|
@@ -135,8 +190,12 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
135
190
|
v8::FunctionTemplate::New(isolate, &BezierCurveTo));
|
|
136
191
|
tmpl->Set(ConvertToV8String(isolate, "clearHitRegions"),
|
|
137
192
|
v8::FunctionTemplate::New(isolate, &ClearHitRegions));
|
|
138
|
-
tmpl->Set(ConvertToV8String(isolate, "clearRect"),
|
|
139
|
-
v8::FunctionTemplate::New(isolate, &ClearRect));
|
|
193
|
+
// tmpl->Set(ConvertToV8String(isolate, "clearRect"),
|
|
194
|
+
// v8::FunctionTemplate::New(isolate, &ClearRect));
|
|
195
|
+
|
|
196
|
+
SetFastMethod(isolate, tmpl, "clearRect", ClearRect, &fast_clear_rect_, v8::Local<v8::Value>());
|
|
197
|
+
|
|
198
|
+
|
|
140
199
|
tmpl->Set(ConvertToV8String(isolate, "clip"), v8::FunctionTemplate::New(isolate, &Clip));
|
|
141
200
|
// tmpl->Set(ConvertToV8String(isolate, "closePath"),
|
|
142
201
|
// v8::FunctionTemplate::New(isolate, &ClosePath));
|
|
@@ -162,12 +221,21 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
162
221
|
tmpl->Set(ConvertToV8String(isolate, "drawImage"),
|
|
163
222
|
v8::FunctionTemplate::New(isolate, &DrawImage));
|
|
164
223
|
tmpl->Set(ConvertToV8String(isolate, "ellipse"), v8::FunctionTemplate::New(isolate, &Ellipse));
|
|
165
|
-
tmpl->Set(ConvertToV8String(isolate, "fill"), v8::FunctionTemplate::New(isolate, &Fill));
|
|
224
|
+
// tmpl->Set(ConvertToV8String(isolate, "fill"), v8::FunctionTemplate::New(isolate, &Fill));
|
|
225
|
+
|
|
226
|
+
SetFastMethodWithOverLoads(isolate, tmpl, "fill", Fill, fast_fill_overloads_,
|
|
227
|
+
v8::Local<v8::Value>());
|
|
166
228
|
|
|
167
|
-
// SetFastMethod(isolate, tmpl, "fill", Fill, &fast_fill_, v8::Local<v8::Value>());
|
|
168
229
|
|
|
169
|
-
|
|
170
|
-
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
SetFastMethod(isolate, tmpl, "fillRect", FillRect, &fast_fill_rect_, v8::Local<v8::Value>());
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
//
|
|
237
|
+
// tmpl->Set(ConvertToV8String(isolate, "fillRect"),
|
|
238
|
+
// v8::FunctionTemplate::New(isolate, &FillRect));
|
|
171
239
|
tmpl->Set(ConvertToV8String(isolate, "fillText"),
|
|
172
240
|
v8::FunctionTemplate::New(isolate, &FillText));
|
|
173
241
|
tmpl->Set(ConvertToV8String(isolate, "getImageData"),
|
|
@@ -193,9 +261,21 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
193
261
|
v8::FunctionTemplate::New(isolate, &RemoveHitRegion));
|
|
194
262
|
tmpl->Set(ConvertToV8String(isolate, "resetTransform"),
|
|
195
263
|
v8::FunctionTemplate::New(isolate, &ResetTransform));
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
264
|
+
|
|
265
|
+
SetFastMethod(isolate, tmpl, "restore", Restore, &fast_restore_, v8::Local<v8::Value>());
|
|
266
|
+
|
|
267
|
+
// tmpl->Set(ConvertToV8String(isolate, "restore"), v8::FunctionTemplate::New(isolate, &Restore));
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
SetFastMethod(isolate, tmpl, "rotate", Rotate, &fast_rotate_, v8::Local<v8::Value>());
|
|
271
|
+
|
|
272
|
+
// tmpl->Set(ConvertToV8String(isolate, "rotate"), v8::FunctionTemplate::New(isolate, &Rotate));
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
SetFastMethod(isolate, tmpl, "save", Save, &fast_save_, v8::Local<v8::Value>());
|
|
276
|
+
//tmpl->Set(ConvertToV8String(isolate, "save"), v8::FunctionTemplate::New(isolate, &Save));
|
|
277
|
+
|
|
278
|
+
|
|
199
279
|
tmpl->Set(ConvertToV8String(isolate, "scale"), v8::FunctionTemplate::New(isolate, &Scale));
|
|
200
280
|
tmpl->Set(ConvertToV8String(isolate, "scrollPathIntoView"),
|
|
201
281
|
v8::FunctionTemplate::New(isolate, &ScrollPathIntoView));
|
|
@@ -203,15 +283,28 @@ v8::Local<v8::FunctionTemplate> CanvasRenderingContext2DImpl::GetCtor(v8::Isolat
|
|
|
203
283
|
v8::FunctionTemplate::New(isolate, &SetLineDash));
|
|
204
284
|
tmpl->Set(ConvertToV8String(isolate, "setTransform"),
|
|
205
285
|
v8::FunctionTemplate::New(isolate, &SetTransform));
|
|
206
|
-
tmpl->Set(ConvertToV8String(isolate, "stroke"), v8::FunctionTemplate::New(isolate, &Stroke));
|
|
207
|
-
|
|
208
|
-
|
|
286
|
+
// tmpl->Set(ConvertToV8String(isolate, "stroke"), v8::FunctionTemplate::New(isolate, &Stroke));
|
|
287
|
+
|
|
288
|
+
SetFastMethodWithOverLoads(isolate, tmpl, "stroke", Stroke, fast_stroke_overloads_,
|
|
289
|
+
v8::Local<v8::Value>());
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
// tmpl->Set(ConvertToV8String(isolate, "strokeRect"),
|
|
293
|
+
// v8::FunctionTemplate::New(isolate, &StrokeRect));
|
|
294
|
+
|
|
295
|
+
SetFastMethod(isolate, tmpl, "strokeRect", StrokeRect, &fast_stroke_rect_, v8::Local<v8::Value>());
|
|
296
|
+
|
|
297
|
+
|
|
209
298
|
tmpl->Set(ConvertToV8String(isolate, "strokeText"),
|
|
210
299
|
v8::FunctionTemplate::New(isolate, &StrokeText));
|
|
211
300
|
tmpl->Set(ConvertToV8String(isolate, "transform"),
|
|
212
301
|
v8::FunctionTemplate::New(isolate, &Transform));
|
|
213
|
-
|
|
214
|
-
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
SetFastMethod(isolate, tmpl, "translate", Translate, &fast_translate_, v8::Local<v8::Value>());
|
|
305
|
+
|
|
306
|
+
// tmpl->Set(ConvertToV8String(isolate, "translate"),
|
|
307
|
+
// v8::FunctionTemplate::New(isolate, &Translate));
|
|
215
308
|
tmpl->Set(ConvertToV8String(isolate, "__toDataURL"),
|
|
216
309
|
v8::FunctionTemplate::New(isolate, &__ToDataURL));
|
|
217
310
|
|
|
@@ -220,7 +220,26 @@ 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_fill_rect_;
|
|
230
|
+
|
|
231
|
+
static v8::CFunction fast_stroke_;
|
|
232
|
+
static v8::CFunction fast_stroke_path_;
|
|
233
|
+
|
|
234
|
+
static v8::CFunction fast_stroke_rect_;
|
|
235
|
+
|
|
236
|
+
static v8::CFunction fast_rotate_;
|
|
237
|
+
|
|
238
|
+
static v8::CFunction fast_restore_;
|
|
239
|
+
|
|
240
|
+
static v8::CFunction fast_save_;
|
|
241
|
+
|
|
242
|
+
static v8::CFunction fast_translate_;
|
|
224
243
|
|
|
225
244
|
|
|
226
245
|
static void AddHitRegion(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -268,6 +287,25 @@ public:
|
|
|
268
287
|
|
|
269
288
|
static void ArcTo(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
270
289
|
|
|
290
|
+
static void FastArcTo(v8::Local<v8::Object> receiver_obj, double x1,
|
|
291
|
+
double y1,
|
|
292
|
+
double x2,
|
|
293
|
+
double y2,
|
|
294
|
+
double radius) {
|
|
295
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
296
|
+
if (ptr == nullptr) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
canvas_native_context_arc_to(
|
|
301
|
+
ptr->GetContext(), static_cast<float>(x1),
|
|
302
|
+
static_cast<float>(y1),
|
|
303
|
+
static_cast<float>(x2),
|
|
304
|
+
static_cast<float>(y2),
|
|
305
|
+
static_cast<float>(radius)
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
271
309
|
static void BeginPath(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
272
310
|
|
|
273
311
|
static void BeginPathImpl(CanvasRenderingContext2D *receiver_obj) {
|
|
@@ -289,6 +327,24 @@ public:
|
|
|
289
327
|
|
|
290
328
|
static void ClearRect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
291
329
|
|
|
330
|
+
|
|
331
|
+
static void FastClearRect(v8::Local<v8::Object> receiver_obj, double x, double y, double width,
|
|
332
|
+
double height) {
|
|
333
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
334
|
+
if (ptr == nullptr) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
canvas_native_context_clear_rect(
|
|
339
|
+
ptr->GetContext(),
|
|
340
|
+
static_cast<float>(x),
|
|
341
|
+
static_cast<float>(y),
|
|
342
|
+
static_cast<float>(width),
|
|
343
|
+
static_cast<float>(height)
|
|
344
|
+
);
|
|
345
|
+
ptr->UpdateInvalidateState();
|
|
346
|
+
}
|
|
347
|
+
|
|
292
348
|
static void Clip(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
293
349
|
|
|
294
350
|
static void ClosePath(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -330,8 +386,126 @@ public:
|
|
|
330
386
|
|
|
331
387
|
static void Fill(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
332
388
|
|
|
389
|
+
/* todo when fast string is supported
|
|
390
|
+
static void FastFillTwo(v8::Local<v8::Object> receiver_obj, v8::Local<v8::Object> path, string) {
|
|
391
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
392
|
+
if (ptr == nullptr) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
auto object = Path2D::GetPointer(path);
|
|
397
|
+
|
|
398
|
+
if (object != nullptr) {
|
|
399
|
+
auto data = ConvertFromV8String(isolate, args[1]);
|
|
400
|
+
canvas_native_context_fill_with_path(
|
|
401
|
+
ptr->GetContext(),
|
|
402
|
+
object->GetPath(),
|
|
403
|
+
data.c_str());
|
|
404
|
+
ptr->UpdateInvalidateState();
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
*/
|
|
409
|
+
|
|
410
|
+
static void FastFillOnePath(v8::Local<v8::Object> receiver_obj, v8::Local<v8::Object> path) {
|
|
411
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
412
|
+
if (ptr == nullptr) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
auto object = Path2D::GetPointer(path);
|
|
417
|
+
|
|
418
|
+
std::string rule("nonzero");
|
|
419
|
+
canvas_native_context_fill_with_path(
|
|
420
|
+
ptr->GetContext(),
|
|
421
|
+
object->GetPath(), rule.c_str());
|
|
422
|
+
ptr->UpdateInvalidateState();
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// todo when fast string is supported
|
|
426
|
+
/*
|
|
427
|
+
static void FastFillOneString(v8::Local<v8::Object> receiver_obj) {
|
|
428
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(args.This());
|
|
429
|
+
if (ptr == nullptr) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
auto isolate = args.GetIsolate();
|
|
433
|
+
|
|
434
|
+
auto count = args.Length();
|
|
435
|
+
auto value = args[0];
|
|
436
|
+
if (count == 2) {
|
|
437
|
+
auto type = GetNativeType(isolate, value.As<v8::Object>());
|
|
438
|
+
if (type == NativeType::Path2D) {
|
|
439
|
+
auto object = Path2D::GetPointer(value.As<v8::Object>());
|
|
440
|
+
|
|
441
|
+
if (object != nullptr) {
|
|
442
|
+
auto data = ConvertFromV8String(isolate, args[1]);
|
|
443
|
+
canvas_native_context_fill_with_path(
|
|
444
|
+
ptr->GetContext(),
|
|
445
|
+
object->GetPath(),
|
|
446
|
+
data.c_str());
|
|
447
|
+
ptr->UpdateInvalidateState();
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
} else if (count == 1) {
|
|
452
|
+
if (value->IsString()) {
|
|
453
|
+
auto rule = ConvertFromV8String(isolate, value);
|
|
454
|
+
canvas_native_context_fill(
|
|
455
|
+
ptr->GetContext(), rule.c_str());
|
|
456
|
+
ptr->UpdateInvalidateState();
|
|
457
|
+
} else if (value->IsObject()) {
|
|
458
|
+
auto type = GetNativeType(isolate, value.As<v8::Object>());
|
|
459
|
+
if (type == NativeType::Path2D) {
|
|
460
|
+
auto object = Path2D::GetPointer(value.As<v8::Object>());
|
|
461
|
+
|
|
462
|
+
std::string rule("nonzero");
|
|
463
|
+
canvas_native_context_fill_with_path(
|
|
464
|
+
ptr->GetContext(),
|
|
465
|
+
object->GetPath(), rule.c_str());
|
|
466
|
+
ptr->UpdateInvalidateState();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
} else {
|
|
470
|
+
std::string rule("nonzero");
|
|
471
|
+
canvas_native_context_fill(
|
|
472
|
+
ptr->GetContext(), rule.c_str());
|
|
473
|
+
ptr->UpdateInvalidateState();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
*/
|
|
477
|
+
static void FastFill(v8::Local<v8::Object> receiver_obj) {
|
|
478
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
479
|
+
if (ptr == nullptr) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
std::string rule("nonzero");
|
|
484
|
+
canvas_native_context_fill(
|
|
485
|
+
ptr->GetContext(), rule.c_str());
|
|
486
|
+
ptr->UpdateInvalidateState();
|
|
487
|
+
}
|
|
488
|
+
|
|
333
489
|
static void FillRect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
334
490
|
|
|
491
|
+
|
|
492
|
+
static void FastFillRect(v8::Local<v8::Object> receiver_obj, double x, double y, double width,
|
|
493
|
+
double height) {
|
|
494
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
495
|
+
if (ptr == nullptr) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
canvas_native_context_fill_rect(
|
|
500
|
+
ptr->GetContext(),
|
|
501
|
+
static_cast<float>(x),
|
|
502
|
+
static_cast<float>(y),
|
|
503
|
+
static_cast<float>(width),
|
|
504
|
+
static_cast<float>(height)
|
|
505
|
+
);
|
|
506
|
+
ptr->UpdateInvalidateState();
|
|
507
|
+
}
|
|
508
|
+
|
|
335
509
|
static void FillText(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
336
510
|
|
|
337
511
|
static void GetImageData(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -362,10 +536,37 @@ public:
|
|
|
362
536
|
|
|
363
537
|
static void Restore(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
364
538
|
|
|
539
|
+
static void FastRestore(v8::Local<v8::Object> receiver_obj) {
|
|
540
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
541
|
+
if (ptr == nullptr) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
canvas_native_context_restore(
|
|
546
|
+
ptr->GetContext());
|
|
547
|
+
}
|
|
548
|
+
|
|
365
549
|
static void Rotate(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
366
550
|
|
|
551
|
+
static void FastRotate(v8::Local<v8::Object> receiver_obj, double angle) {
|
|
552
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
553
|
+
canvas_native_context_rotate(
|
|
554
|
+
ptr->GetContext(), angle);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
|
|
367
558
|
static void Save(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
368
559
|
|
|
560
|
+
static void FastSave(v8::Local<v8::Object> receiver_obj) {
|
|
561
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
562
|
+
if (ptr == nullptr) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
canvas_native_context_save(
|
|
567
|
+
ptr->GetContext());
|
|
568
|
+
}
|
|
569
|
+
|
|
369
570
|
static void Scale(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
370
571
|
|
|
371
572
|
static void ScrollPathIntoView(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
@@ -376,14 +577,55 @@ public:
|
|
|
376
577
|
|
|
377
578
|
static void Stroke(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
378
579
|
|
|
580
|
+
static void FastStroke(v8::Local<v8::Object> receiver_obj) {
|
|
581
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
582
|
+
|
|
583
|
+
canvas_native_context_stroke(
|
|
584
|
+
ptr->GetContext());
|
|
585
|
+
ptr->UpdateInvalidateState();
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
static void FastStrokePath(v8::Local<v8::Object> receiver_obj, v8::Local<v8::Object> path_obj) {
|
|
589
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
590
|
+
|
|
591
|
+
auto path = Path2D::GetPointer(path_obj);
|
|
592
|
+
if (path != nullptr) {
|
|
593
|
+
canvas_native_context_stroke_with_path(
|
|
594
|
+
ptr->GetContext(),
|
|
595
|
+
path->GetPath());
|
|
596
|
+
ptr->UpdateInvalidateState();
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
379
600
|
static void StrokeRect(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
380
601
|
|
|
602
|
+
|
|
603
|
+
static void FastStrokeRect(v8::Local<v8::Object> receiver_obj, double x, double y, double width,
|
|
604
|
+
double height) {
|
|
605
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
606
|
+
|
|
607
|
+
canvas_native_context_stroke_rect(
|
|
608
|
+
ptr->GetContext(), static_cast<float>(x),
|
|
609
|
+
static_cast<float>(y),
|
|
610
|
+
static_cast<float>(width),
|
|
611
|
+
static_cast<float>(height));
|
|
612
|
+
ptr->UpdateInvalidateState();
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
|
|
381
616
|
static void StrokeText(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
382
617
|
|
|
383
618
|
static void Transform(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
384
619
|
|
|
385
620
|
static void Translate(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
386
621
|
|
|
622
|
+
static void FastTranslate(v8::Local<v8::Object> receiver_obj, double x, double y) {
|
|
623
|
+
CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj);
|
|
624
|
+
canvas_native_context_translate(
|
|
625
|
+
ptr->GetContext(), x, y);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
|
|
387
629
|
static void __ToDataURL(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
388
630
|
|
|
389
631
|
~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
|