@antv/g-canvas 1.5.3 → 1.6.1

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/dist/index.umd.js CHANGED
@@ -1,7 +1,7 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@antv/g')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', '@antv/g'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.ImageExporter = {}), global.window.G));
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.Canvas2D = {}), global.window.G));
5
5
  }(this, (function (exports, g) { 'use strict';
6
6
 
7
7
  function _regeneratorRuntime() {
@@ -400,6 +400,21 @@
400
400
  return _setPrototypeOf(o, p);
401
401
  }
402
402
 
403
+ function _inheritsLoose$1(subClass, superClass) {
404
+ subClass.prototype = Object.create(superClass.prototype);
405
+ subClass.prototype.constructor = subClass;
406
+
407
+ _setPrototypeOf$1(subClass, superClass);
408
+ }
409
+
410
+ function _setPrototypeOf$1(o, p) {
411
+ _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
412
+ o.__proto__ = p;
413
+ return o;
414
+ };
415
+ return _setPrototypeOf$1(o, p);
416
+ }
417
+
403
418
  var PathGeneratorFactory = g.Syringe.defineToken('PathGeneratorFactory');
404
419
  var PathGenerator = g.Syringe.defineToken('PathGenerator');
405
420
 
@@ -637,23 +652,33 @@
637
652
  });
638
653
  });
639
654
 
640
- var Plugin = /*#__PURE__*/function () {
655
+ var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
656
+ _inheritsLoose$1(Plugin, _AbstractRendererPlug);
657
+
641
658
  function Plugin() {
642
- this.name = 'canvas-path-generator';
659
+ var _this;
660
+
661
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
662
+ args[_key] = arguments[_key];
663
+ }
664
+
665
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
666
+ _this.name = 'canvas-path-generator';
667
+ return _this;
643
668
  }
644
669
 
645
670
  var _proto = Plugin.prototype;
646
671
 
647
- _proto.init = function init(container) {
648
- container.load(containerModule, true);
672
+ _proto.init = function init() {
673
+ this.container.load(containerModule, true);
649
674
  };
650
675
 
651
- _proto.destroy = function destroy(container) {
652
- container.unload(containerModule);
676
+ _proto.destroy = function destroy() {
677
+ this.container.unload(containerModule);
653
678
  };
654
679
 
655
680
  return Plugin;
656
- }();
681
+ }(g.AbstractRendererPlugin);
657
682
 
658
683
  var index_esm = /*#__PURE__*/Object.freeze({
659
684
  __proto__: null,
@@ -1073,6 +1098,21 @@
1073
1098
  });
1074
1099
  };
1075
1100
  }
1101
+
1102
+ function _inheritsLoose$2(subClass, superClass) {
1103
+ subClass.prototype = Object.create(superClass.prototype);
1104
+ subClass.prototype.constructor = subClass;
1105
+
1106
+ _setPrototypeOf$2(subClass, superClass);
1107
+ }
1108
+
1109
+ function _setPrototypeOf$2(o, p) {
1110
+ _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
1111
+ o.__proto__ = p;
1112
+ return o;
1113
+ };
1114
+ return _setPrototypeOf$2(o, p);
1115
+ }
1076
1116
  /**
1077
1117
  * Common utilities
1078
1118
  * @module glMatrix
@@ -2524,192 +2564,39 @@
2524
2564
  register(CanvasPickerPlugin);
2525
2565
  });
2526
2566
 
2527
- var Plugin$1 = /*#__PURE__*/function () {
2567
+ var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
2568
+ _inheritsLoose$2(Plugin, _AbstractRendererPlug);
2569
+
2528
2570
  function Plugin() {
2529
- this.name = 'canvas-picker';
2571
+ var _this;
2572
+
2573
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2574
+ args[_key] = arguments[_key];
2575
+ }
2576
+
2577
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
2578
+ _this.name = 'canvas-picker';
2579
+ return _this;
2530
2580
  }
2531
2581
 
2532
2582
  var _proto = Plugin.prototype;
2533
2583
 
2534
- _proto.init = function init(container) {
2535
- container.load(containerModule$1, true);
2584
+ _proto.init = function init() {
2585
+ this.container.load(containerModule$1, true);
2536
2586
  };
2537
2587
 
2538
- _proto.destroy = function destroy(container) {
2539
- container.unload(containerModule$1);
2588
+ _proto.destroy = function destroy() {
2589
+ this.container.unload(containerModule$1);
2540
2590
  };
2541
2591
 
2542
2592
  return Plugin;
2543
- }();
2593
+ }(g.AbstractRendererPlugin);
2544
2594
 
2545
2595
  var index_esm$1 = /*#__PURE__*/Object.freeze({
2546
2596
  __proto__: null,
2547
2597
  Plugin: Plugin$1
2548
2598
  });
2549
2599
 
2550
- var ImagePool = /*#__PURE__*/function () {
2551
- function ImagePool() {
2552
- this.imageCache = {};
2553
- this.gradientCache = {};
2554
- this.patternCache = {};
2555
- this.canvasConfig = void 0;
2556
- }
2557
-
2558
- var _proto = ImagePool.prototype;
2559
-
2560
- _proto.getImageSync = function getImageSync(src, callback) {
2561
- if (!this.imageCache[src]) {
2562
- this.getOrCreateImage(src).then(function () {
2563
- if (callback) {
2564
- callback();
2565
- }
2566
- });
2567
- }
2568
-
2569
- return this.imageCache[src];
2570
- };
2571
-
2572
- _proto.getOrCreateImage = function getOrCreateImage(src) {
2573
- var _this = this;
2574
-
2575
- if (this.imageCache[src]) {
2576
- return Promise.resolve(this.imageCache[src]);
2577
- } // @see https://github.com/antvis/g/issues/938
2578
-
2579
-
2580
- var createImage = this.canvasConfig.createImage;
2581
- return new Promise(function (resolve, reject) {
2582
- var image;
2583
-
2584
- if (createImage) {
2585
- image = createImage(src);
2586
- } else if (g.isBrowser) {
2587
- image = new window.Image();
2588
- }
2589
-
2590
- if (image) {
2591
- image.onload = function () {
2592
- resolve(image);
2593
- };
2594
-
2595
- image.onerror = function (ev) {
2596
- reject(ev);
2597
- };
2598
-
2599
- image.crossOrigin = 'Anonymous';
2600
- image.src = src;
2601
- _this.imageCache[src] = image;
2602
- }
2603
- });
2604
- };
2605
-
2606
- _proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, callback) {
2607
- var patternKey = this.generatePatternKey(pattern);
2608
-
2609
- if (patternKey && this.patternCache[patternKey]) {
2610
- return this.patternCache[patternKey];
2611
- }
2612
-
2613
- var image = pattern.image,
2614
- repetition = pattern.repetition;
2615
- var src; // Image URL
2616
-
2617
- if (g.isString(image)) {
2618
- src = this.getImageSync(image, callback);
2619
- } else {
2620
- src = image;
2621
- } // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
2622
-
2623
-
2624
- var canvasPattern = src && context.createPattern(src, repetition);
2625
-
2626
- if (patternKey && canvasPattern) {
2627
- this.patternCache[patternKey] = canvasPattern;
2628
- }
2629
-
2630
- return canvasPattern;
2631
- };
2632
-
2633
- _proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
2634
- var key = this.generateGradientKey(params); // @ts-ignore
2635
-
2636
- var type = params.type,
2637
- steps = params.steps,
2638
- width = params.width,
2639
- height = params.height,
2640
- angle = params.angle,
2641
- cx = params.cx,
2642
- cy = params.cy;
2643
-
2644
- if (this.gradientCache[key]) {
2645
- return this.gradientCache[key];
2646
- }
2647
-
2648
- var gradient = null;
2649
-
2650
- if (type === g.GradientType.LinearGradient) {
2651
- var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
2652
- x1 = _computeLinearGradien.x1,
2653
- y1 = _computeLinearGradien.y1,
2654
- x2 = _computeLinearGradien.x2,
2655
- y2 = _computeLinearGradien.y2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
2656
-
2657
-
2658
- gradient = context.createLinearGradient(x1, y1, x2, y2);
2659
- } else if (type === g.GradientType.RadialGradient) {
2660
- var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
2661
- x = _computeRadialGradien.x,
2662
- y = _computeRadialGradien.y,
2663
- r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
2664
-
2665
-
2666
- gradient = context.createRadialGradient(x, y, 0, x, y, r);
2667
- }
2668
-
2669
- if (gradient) {
2670
- steps.forEach(function (_ref) {
2671
- var _gradient;
2672
-
2673
- var offset = _ref[0],
2674
- color = _ref[1];
2675
- (_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset, color);
2676
- });
2677
- this.gradientCache[key] = gradient;
2678
- }
2679
-
2680
- return this.gradientCache[key];
2681
- };
2682
-
2683
- _proto.generateGradientKey = function generateGradientKey(params) {
2684
- // @ts-ignore
2685
- var type = params.type,
2686
- width = params.width,
2687
- height = params.height,
2688
- steps = params.steps,
2689
- angle = params.angle,
2690
- cx = params.cx,
2691
- cy = params.cy;
2692
- return "gradient-" + type + "-" + (angle || 0) + "-" + (cx || 0) + "-" + (cy || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
2693
- return step.join('');
2694
- }).join('-');
2695
- };
2696
-
2697
- _proto.generatePatternKey = function generatePatternKey(pattern) {
2698
- var image = pattern.image,
2699
- repetition = pattern.repetition; // only generate cache for Image
2700
-
2701
- if (g.isString(image)) {
2702
- return "pattern-" + image + "-" + repetition;
2703
- }
2704
- };
2705
-
2706
- return ImagePool;
2707
- }();
2708
-
2709
- __decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
2710
-
2711
- ImagePool = __decorate([g.singleton()], ImagePool);
2712
-
2713
2600
  function _regeneratorRuntime$2() {
2714
2601
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
2715
2602
  _regeneratorRuntime$2 = function _regeneratorRuntime() {
@@ -3044,57 +2931,235 @@
3044
2931
  resetTryEntry(entry);
3045
2932
  }
3046
2933
 
3047
- return thrown;
3048
- }
3049
- }
2934
+ return thrown;
2935
+ }
2936
+ }
2937
+
2938
+ throw new Error("illegal catch attempt");
2939
+ },
2940
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
2941
+ return this.delegate = {
2942
+ iterator: values(iterable),
2943
+ resultName: resultName,
2944
+ nextLoc: nextLoc
2945
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
2946
+ }
2947
+ }, exports;
2948
+ }
2949
+
2950
+ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
2951
+ try {
2952
+ var info = gen[key](arg);
2953
+ var value = info.value;
2954
+ } catch (error) {
2955
+ reject(error);
2956
+ return;
2957
+ }
2958
+
2959
+ if (info.done) {
2960
+ resolve(value);
2961
+ } else {
2962
+ Promise.resolve(value).then(_next, _throw);
2963
+ }
2964
+ }
2965
+
2966
+ function _asyncToGenerator$2(fn) {
2967
+ return function () {
2968
+ var self = this,
2969
+ args = arguments;
2970
+ return new Promise(function (resolve, reject) {
2971
+ var gen = fn.apply(self, args);
2972
+
2973
+ function _next(value) {
2974
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
2975
+ }
2976
+
2977
+ function _throw(err) {
2978
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
2979
+ }
2980
+
2981
+ _next(undefined);
2982
+ });
2983
+ };
2984
+ }
2985
+
2986
+ function _inheritsLoose$3(subClass, superClass) {
2987
+ subClass.prototype = Object.create(superClass.prototype);
2988
+ subClass.prototype.constructor = subClass;
2989
+
2990
+ _setPrototypeOf$3(subClass, superClass);
2991
+ }
2992
+
2993
+ function _setPrototypeOf$3(o, p) {
2994
+ _setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
2995
+ o.__proto__ = p;
2996
+ return o;
2997
+ };
2998
+ return _setPrototypeOf$3(o, p);
2999
+ }
3000
+
3001
+ var ImagePool = /*#__PURE__*/function () {
3002
+ function ImagePool() {
3003
+ this.imageCache = {};
3004
+ this.gradientCache = {};
3005
+ this.patternCache = {};
3006
+ this.canvasConfig = void 0;
3007
+ }
3008
+
3009
+ var _proto = ImagePool.prototype;
3010
+
3011
+ _proto.getImageSync = function getImageSync(src, callback) {
3012
+ if (!this.imageCache[src]) {
3013
+ this.getOrCreateImage(src).then(function () {
3014
+ if (callback) {
3015
+ callback();
3016
+ }
3017
+ });
3018
+ }
3019
+
3020
+ return this.imageCache[src];
3021
+ };
3022
+
3023
+ _proto.getOrCreateImage = function getOrCreateImage(src) {
3024
+ var _this = this;
3025
+
3026
+ if (this.imageCache[src]) {
3027
+ return Promise.resolve(this.imageCache[src]);
3028
+ } // @see https://github.com/antvis/g/issues/938
3029
+
3030
+
3031
+ var createImage = this.canvasConfig.createImage;
3032
+ return new Promise(function (resolve, reject) {
3033
+ var image;
3034
+
3035
+ if (createImage) {
3036
+ image = createImage(src);
3037
+ } else if (g.isBrowser) {
3038
+ image = new window.Image();
3039
+ }
3040
+
3041
+ if (image) {
3042
+ image.onload = function () {
3043
+ resolve(image);
3044
+ };
3045
+
3046
+ image.onerror = function (ev) {
3047
+ reject(ev);
3048
+ };
3049
+
3050
+ image.crossOrigin = 'Anonymous';
3051
+ image.src = src;
3052
+ _this.imageCache[src] = image;
3053
+ }
3054
+ });
3055
+ };
3056
+
3057
+ _proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, callback) {
3058
+ var patternKey = this.generatePatternKey(pattern);
3059
+
3060
+ if (patternKey && this.patternCache[patternKey]) {
3061
+ return this.patternCache[patternKey];
3062
+ }
3063
+
3064
+ var image = pattern.image,
3065
+ repetition = pattern.repetition;
3066
+ var src; // Image URL
3067
+
3068
+ if (g.isString(image)) {
3069
+ src = this.getImageSync(image, callback);
3070
+ } else {
3071
+ src = image;
3072
+ } // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
3073
+
3074
+
3075
+ var canvasPattern = src && context.createPattern(src, repetition);
3076
+
3077
+ if (patternKey && canvasPattern) {
3078
+ this.patternCache[patternKey] = canvasPattern;
3079
+ }
3080
+
3081
+ return canvasPattern;
3082
+ };
3083
+
3084
+ _proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
3085
+ var key = this.generateGradientKey(params); // @ts-ignore
3086
+
3087
+ var type = params.type,
3088
+ steps = params.steps,
3089
+ width = params.width,
3090
+ height = params.height,
3091
+ angle = params.angle,
3092
+ cx = params.cx,
3093
+ cy = params.cy;
3094
+
3095
+ if (this.gradientCache[key]) {
3096
+ return this.gradientCache[key];
3097
+ }
3098
+
3099
+ var gradient = null;
3100
+
3101
+ if (type === g.GradientType.LinearGradient) {
3102
+ var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
3103
+ x1 = _computeLinearGradien.x1,
3104
+ y1 = _computeLinearGradien.y1,
3105
+ x2 = _computeLinearGradien.x2,
3106
+ y2 = _computeLinearGradien.y2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
3107
+
3108
+
3109
+ gradient = context.createLinearGradient(x1, y1, x2, y2);
3110
+ } else if (type === g.GradientType.RadialGradient) {
3111
+ var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
3112
+ x = _computeRadialGradien.x,
3113
+ y = _computeRadialGradien.y,
3114
+ r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
3115
+
3050
3116
 
3051
- throw new Error("illegal catch attempt");
3052
- },
3053
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
3054
- return this.delegate = {
3055
- iterator: values(iterable),
3056
- resultName: resultName,
3057
- nextLoc: nextLoc
3058
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
3117
+ gradient = context.createRadialGradient(x, y, 0, x, y, r);
3059
3118
  }
3060
- }, exports;
3061
- }
3062
3119
 
3063
- function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
3064
- try {
3065
- var info = gen[key](arg);
3066
- var value = info.value;
3067
- } catch (error) {
3068
- reject(error);
3069
- return;
3070
- }
3120
+ if (gradient) {
3121
+ steps.forEach(function (_ref) {
3122
+ var _gradient;
3071
3123
 
3072
- if (info.done) {
3073
- resolve(value);
3074
- } else {
3075
- Promise.resolve(value).then(_next, _throw);
3076
- }
3077
- }
3124
+ var offset = _ref[0],
3125
+ color = _ref[1];
3126
+ (_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset, color);
3127
+ });
3128
+ this.gradientCache[key] = gradient;
3129
+ }
3078
3130
 
3079
- function _asyncToGenerator$2(fn) {
3080
- return function () {
3081
- var self = this,
3082
- args = arguments;
3083
- return new Promise(function (resolve, reject) {
3084
- var gen = fn.apply(self, args);
3131
+ return this.gradientCache[key];
3132
+ };
3085
3133
 
3086
- function _next(value) {
3087
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
3088
- }
3134
+ _proto.generateGradientKey = function generateGradientKey(params) {
3135
+ // @ts-ignore
3136
+ var type = params.type,
3137
+ width = params.width,
3138
+ height = params.height,
3139
+ steps = params.steps,
3140
+ angle = params.angle,
3141
+ cx = params.cx,
3142
+ cy = params.cy;
3143
+ return "gradient-" + type + "-" + (angle || 0) + "-" + (cx || 0) + "-" + (cy || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
3144
+ return step.join('');
3145
+ }).join('-');
3146
+ };
3089
3147
 
3090
- function _throw(err) {
3091
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
3092
- }
3148
+ _proto.generatePatternKey = function generatePatternKey(pattern) {
3149
+ var image = pattern.image,
3150
+ repetition = pattern.repetition; // only generate cache for Image
3093
3151
 
3094
- _next(undefined);
3095
- });
3152
+ if (g.isString(image)) {
3153
+ return "pattern-" + image + "-" + repetition;
3154
+ }
3096
3155
  };
3097
- }
3156
+
3157
+ return ImagePool;
3158
+ }();
3159
+
3160
+ __decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
3161
+
3162
+ ImagePool = __decorate([g.singleton()], ImagePool);
3098
3163
 
3099
3164
  var _class$1;
3100
3165
 
@@ -3184,23 +3249,33 @@
3184
3249
  register(LoadImagePlugin);
3185
3250
  });
3186
3251
 
3187
- var Plugin$2 = /*#__PURE__*/function () {
3252
+ var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
3253
+ _inheritsLoose$3(Plugin, _AbstractRendererPlug);
3254
+
3188
3255
  function Plugin() {
3189
- this.name = 'image-loader';
3256
+ var _this;
3257
+
3258
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3259
+ args[_key] = arguments[_key];
3260
+ }
3261
+
3262
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
3263
+ _this.name = 'image-loader';
3264
+ return _this;
3190
3265
  }
3191
3266
 
3192
3267
  var _proto = Plugin.prototype;
3193
3268
 
3194
- _proto.init = function init(container) {
3195
- container.load(containerModule$2, true);
3269
+ _proto.init = function init() {
3270
+ this.container.load(containerModule$2, true);
3196
3271
  };
3197
3272
 
3198
- _proto.destroy = function destroy(container) {
3199
- container.unload(containerModule$2);
3273
+ _proto.destroy = function destroy() {
3274
+ this.container.unload(containerModule$2);
3200
3275
  };
3201
3276
 
3202
3277
  return Plugin;
3203
- }();
3278
+ }(g.AbstractRendererPlugin);
3204
3279
 
3205
3280
  var index_esm$2 = /*#__PURE__*/Object.freeze({
3206
3281
  __proto__: null,
@@ -3611,19 +3686,19 @@
3611
3686
  return _extends.apply(this, arguments);
3612
3687
  }
3613
3688
 
3614
- function _inheritsLoose$1(subClass, superClass) {
3689
+ function _inheritsLoose$4(subClass, superClass) {
3615
3690
  subClass.prototype = Object.create(superClass.prototype);
3616
3691
  subClass.prototype.constructor = subClass;
3617
3692
 
3618
- _setPrototypeOf$1(subClass, superClass);
3693
+ _setPrototypeOf$4(subClass, superClass);
3619
3694
  }
3620
3695
 
3621
- function _setPrototypeOf$1(o, p) {
3622
- _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
3696
+ function _setPrototypeOf$4(o, p) {
3697
+ _setPrototypeOf$4 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
3623
3698
  o.__proto__ = p;
3624
3699
  return o;
3625
3700
  };
3626
- return _setPrototypeOf$1(o, p);
3701
+ return _setPrototypeOf$4(o, p);
3627
3702
  }
3628
3703
  /**
3629
3704
  * Common utilities
@@ -3895,6 +3970,28 @@
3895
3970
  out[2] = z;
3896
3971
  return out;
3897
3972
  }
3973
+ /**
3974
+ * Transforms the vec3 with a mat4.
3975
+ * 4th vector component is implicitly '1'
3976
+ *
3977
+ * @param {vec3} out the receiving vector
3978
+ * @param {ReadonlyVec3} a the vector to transform
3979
+ * @param {ReadonlyMat4} m matrix to transform with
3980
+ * @returns {vec3} out
3981
+ */
3982
+
3983
+
3984
+ function transformMat4$1(out, a, m) {
3985
+ var x = a[0],
3986
+ y = a[1],
3987
+ z = a[2];
3988
+ var w = m[3] * x + m[7] * y + m[11] * z + m[15];
3989
+ w = w || 1.0;
3990
+ out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
3991
+ out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
3992
+ out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
3993
+ return out;
3994
+ }
3898
3995
  /**
3899
3996
  * Perform some operation over an array of vec3s.
3900
3997
  *
@@ -4023,10 +4120,8 @@
4023
4120
  textAlign = parsedStyle.textAlign,
4024
4121
  textBaseline = parsedStyle.textBaseline,
4025
4122
  lineJoin = parsedStyle.lineJoin,
4026
- _parsedStyle$miterLim = parsedStyle.miterLimit,
4027
- miterLimit = _parsedStyle$miterLim === void 0 ? 0 : _parsedStyle$miterLim,
4028
- _parsedStyle$letterSp = parsedStyle.letterSpacing,
4029
- letterSpacing = _parsedStyle$letterSp === void 0 ? 0 : _parsedStyle$letterSp,
4123
+ miterLimit = parsedStyle.miterLimit,
4124
+ letterSpacing = parsedStyle.letterSpacing,
4030
4125
  stroke = parsedStyle.stroke,
4031
4126
  fill = parsedStyle.fill,
4032
4127
  fillOpacity = parsedStyle.fillOpacity,
@@ -4045,7 +4140,11 @@
4045
4140
  context.textAlign = textAlign.value;
4046
4141
  context.textBaseline = textBaseline.value;
4047
4142
  context.lineJoin = lineJoin.value;
4048
- context.miterLimit = miterLimit;
4143
+
4144
+ if (!g.isNil(miterLimit)) {
4145
+ context.miterLimit = miterLimit.value;
4146
+ }
4147
+
4049
4148
  var linePositionY = 0; // handle vertical text baseline
4050
4149
 
4051
4150
  if (textBaseline.value === 'middle') {
@@ -4074,11 +4173,11 @@
4074
4173
  // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
4075
4174
 
4076
4175
  if (!g.isNil(stroke) && !stroke.isNone && lineWidth && lineWidth.value) {
4077
- this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value, true);
4176
+ this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing.value, fillOpacity.value, strokeOpacity.value, opacity.value, true);
4078
4177
  }
4079
4178
 
4080
4179
  if (!g.isNil(fill)) {
4081
- this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value);
4180
+ this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing.value, fillOpacity.value, strokeOpacity.value, opacity.value);
4082
4181
  }
4083
4182
  }
4084
4183
  };
@@ -4186,93 +4285,106 @@
4186
4285
  lineWidth = parsedStyle.lineWidth,
4187
4286
  lineCap = parsedStyle.lineCap,
4188
4287
  lineJoin = parsedStyle.lineJoin,
4288
+ shadowType = parsedStyle.shadowType,
4189
4289
  shadowColor = parsedStyle.shadowColor,
4290
+ shadowBlur = parsedStyle.shadowBlur,
4190
4291
  filter = parsedStyle.filter,
4191
4292
  miterLimit = parsedStyle.miterLimit;
4192
4293
  var hasFill = !g.isNil(fill) && !fill.isNone;
4193
- var hasStroke = !g.isNil(stroke) && !stroke.isNone;
4294
+ var hasStroke = !g.isNil(stroke) && !stroke.isNone && lineWidth && lineWidth.value > 0;
4194
4295
  var isFillTransparent = fill.alpha === 0;
4296
+ var hasFilter = !g.isNil(filter);
4297
+ var hasShadow = !g.isNil(shadowColor) && (shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) > 0;
4298
+ var nodeName = object.nodeName;
4299
+ var isInnerShadow = (shadowType === null || shadowType === void 0 ? void 0 : shadowType.value) === 'inner';
4300
+ var shouldDrawShadowWithStroke = hasStroke && hasShadow && (nodeName === g.Shape.PATH || nodeName === g.Shape.LINE || nodeName === g.Shape.POLYLINE || isFillTransparent || isInnerShadow);
4195
4301
 
4196
4302
  if (hasFill) {
4197
- if (!g.isNil(fillOpacity) && fillOpacity.value !== 1) {
4198
- context.globalAlpha = fillOpacity.value;
4199
- this.fill(context, object, fill, renderingService);
4200
- context.globalAlpha = opacity.value;
4201
- } else {
4202
- this.fill(context, object, fill, renderingService);
4303
+ context.globalAlpha = opacity.value * fillOpacity.value;
4304
+
4305
+ if (!shouldDrawShadowWithStroke) {
4306
+ this.setShadowAndFilter(object, context, hasShadow);
4203
4307
  }
4204
- }
4205
4308
 
4206
- if (hasStroke) {
4207
- if (lineWidth && lineWidth.value > 0) {
4208
- var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity.value !== 1;
4309
+ this.fill(context, object, fill, renderingService);
4209
4310
 
4210
- if (applyOpacity) {
4211
- context.globalAlpha = strokeOpacity.value;
4212
- }
4311
+ if (!shouldDrawShadowWithStroke) {
4312
+ this.clearShadowAndFilter(context, hasFilter, hasShadow);
4313
+ }
4314
+ }
4213
4315
 
4214
- context.lineWidth = lineWidth.value;
4316
+ if (hasStroke) {
4317
+ context.globalAlpha = opacity.value * strokeOpacity.value;
4318
+ context.lineWidth = lineWidth.value;
4215
4319
 
4216
- if (!g.isNil(miterLimit)) {
4217
- context.miterLimit = miterLimit;
4218
- }
4320
+ if (!g.isNil(miterLimit)) {
4321
+ context.miterLimit = miterLimit.value;
4322
+ }
4219
4323
 
4220
- if (!g.isNil(lineCap)) {
4221
- context.lineCap = lineCap.value;
4222
- }
4324
+ if (!g.isNil(lineCap)) {
4325
+ context.lineCap = lineCap.value;
4326
+ }
4223
4327
 
4224
- if (!g.isNil(lineJoin)) {
4225
- context.lineJoin = lineJoin.value;
4226
- }
4328
+ if (!g.isNil(lineJoin)) {
4329
+ context.lineJoin = lineJoin.value;
4330
+ }
4227
4331
 
4228
- var oldShadowBlur;
4229
- var oldShadowColor;
4230
- var oldFilter;
4231
- var hasShadowColor = !g.isNil(shadowColor);
4232
- var hasFilter = !g.isNil(filter);
4233
-
4234
- if (hasShadowColor) {
4235
- // prevent inner shadow when drawing stroke, toggle shadowBlur & filter(drop-shadow)
4236
- // save shadow blur
4237
- oldShadowBlur = context.shadowBlur;
4238
- oldShadowColor = context.shadowColor;
4239
-
4240
- if (!g.isNil(oldShadowBlur)) {
4241
- context.shadowColor = 'transparent';
4242
- context.shadowBlur = 0;
4243
- }
4332
+ if (shouldDrawShadowWithStroke) {
4333
+ if (isInnerShadow) {
4334
+ context.globalCompositeOperation = 'source-atop';
4244
4335
  }
4245
4336
 
4246
- if (hasFilter) {
4247
- // save drop-shadow filter
4248
- oldFilter = context.filter;
4337
+ this.setShadowAndFilter(object, context, true);
4249
4338
 
4250
- if (!g.isNil(oldFilter) && oldFilter.indexOf('drop-shadow') > -1) {
4251
- context.filter = oldFilter.replace(/drop-shadow\([^)]*\)/, '').trim() || 'none';
4252
- }
4339
+ if (isInnerShadow) {
4340
+ this.stroke(context, object, stroke, renderingService);
4341
+ context.globalCompositeOperation = 'source-over';
4342
+ this.clearShadowAndFilter(context, hasFilter, true);
4253
4343
  }
4344
+ }
4254
4345
 
4255
- var drawStroke = hasFill && !isFillTransparent;
4346
+ this.stroke(context, object, stroke, renderingService);
4347
+ }
4348
+ };
4256
4349
 
4257
- if (drawStroke) {
4258
- this.stroke(context, object, stroke, renderingService);
4259
- } // restore shadow blur
4350
+ _proto.clearShadowAndFilter = function clearShadowAndFilter(context, hasFilter, hasShadow) {
4351
+ if (hasShadow) {
4352
+ context.shadowColor = 'transparent';
4353
+ context.shadowBlur = 0;
4354
+ }
4260
4355
 
4356
+ if (hasFilter) {
4357
+ // save drop-shadow filter
4358
+ var oldFilter = context.filter;
4261
4359
 
4262
- if (hasShadowColor) {
4263
- context.shadowColor = oldShadowColor;
4264
- context.shadowBlur = oldShadowBlur;
4265
- } // restore filters
4360
+ if (!g.isNil(oldFilter) && oldFilter.indexOf('drop-shadow') > -1) {
4361
+ context.filter = oldFilter.replace(/drop-shadow\([^)]*\)/, '').trim() || 'none';
4362
+ }
4363
+ }
4364
+ }
4365
+ /**
4366
+ * apply before fill and stroke but only once
4367
+ */
4368
+ ;
4266
4369
 
4370
+ _proto.setShadowAndFilter = function setShadowAndFilter(object, context, hasShadow) {
4371
+ var _object$parsedStyle = object.parsedStyle,
4372
+ filter = _object$parsedStyle.filter,
4373
+ shadowColor = _object$parsedStyle.shadowColor,
4374
+ shadowBlur = _object$parsedStyle.shadowBlur,
4375
+ shadowOffsetX = _object$parsedStyle.shadowOffsetX,
4376
+ shadowOffsetY = _object$parsedStyle.shadowOffsetY;
4267
4377
 
4268
- if (hasFilter) {
4269
- context.filter = oldFilter;
4270
- }
4378
+ if (!g.isNil(filter)) {
4379
+ // use raw filter string
4380
+ context.filter = object.style.filter;
4381
+ }
4271
4382
 
4272
- if (!drawStroke) {
4273
- this.stroke(context, object, stroke, renderingService);
4274
- }
4275
- }
4383
+ if (hasShadow) {
4384
+ context.shadowColor = shadowColor.toString();
4385
+ context.shadowBlur = shadowBlur && shadowBlur.value || 0;
4386
+ context.shadowOffsetX = shadowOffsetX && shadowOffsetX.value || 0;
4387
+ context.shadowOffsetY = shadowOffsetY && shadowOffsetY.value || 0;
4276
4388
  }
4277
4389
  };
4278
4390
 
@@ -4345,7 +4457,7 @@
4345
4457
  DefaultRenderer = __decorate([g.singleton()], DefaultRenderer);
4346
4458
 
4347
4459
  var RectRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4348
- _inheritsLoose$1(RectRenderer, _DefaultRenderer);
4460
+ _inheritsLoose$4(RectRenderer, _DefaultRenderer);
4349
4461
 
4350
4462
  function RectRenderer() {
4351
4463
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4359,7 +4471,7 @@
4359
4471
  })], RectRenderer);
4360
4472
 
4361
4473
  var CircleRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4362
- _inheritsLoose$1(CircleRenderer, _DefaultRenderer);
4474
+ _inheritsLoose$4(CircleRenderer, _DefaultRenderer);
4363
4475
 
4364
4476
  function CircleRenderer() {
4365
4477
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4373,7 +4485,7 @@
4373
4485
  })], CircleRenderer);
4374
4486
 
4375
4487
  var EllipseRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4376
- _inheritsLoose$1(EllipseRenderer, _DefaultRenderer);
4488
+ _inheritsLoose$4(EllipseRenderer, _DefaultRenderer);
4377
4489
 
4378
4490
  function EllipseRenderer() {
4379
4491
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4387,7 +4499,7 @@
4387
4499
  })], EllipseRenderer);
4388
4500
 
4389
4501
  var LineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4390
- _inheritsLoose$1(LineRenderer, _DefaultRenderer);
4502
+ _inheritsLoose$4(LineRenderer, _DefaultRenderer);
4391
4503
 
4392
4504
  function LineRenderer() {
4393
4505
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4401,7 +4513,7 @@
4401
4513
  })], LineRenderer);
4402
4514
 
4403
4515
  var PolylineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4404
- _inheritsLoose$1(PolylineRenderer, _DefaultRenderer);
4516
+ _inheritsLoose$4(PolylineRenderer, _DefaultRenderer);
4405
4517
 
4406
4518
  function PolylineRenderer() {
4407
4519
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4415,7 +4527,7 @@
4415
4527
  })], PolylineRenderer);
4416
4528
 
4417
4529
  var PolygonRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4418
- _inheritsLoose$1(PolygonRenderer, _DefaultRenderer);
4530
+ _inheritsLoose$4(PolygonRenderer, _DefaultRenderer);
4419
4531
 
4420
4532
  function PolygonRenderer() {
4421
4533
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4429,7 +4541,7 @@
4429
4541
  })], PolygonRenderer);
4430
4542
 
4431
4543
  var PathRenderer = /*#__PURE__*/function (_DefaultRenderer) {
4432
- _inheritsLoose$1(PathRenderer, _DefaultRenderer);
4544
+ _inheritsLoose$4(PathRenderer, _DefaultRenderer);
4433
4545
 
4434
4546
  function PathRenderer() {
4435
4547
  return _DefaultRenderer.apply(this, arguments) || this;
@@ -4441,6 +4553,7 @@
4441
4553
  PathRenderer = __decorate([g.singleton({
4442
4554
  token: PathRendererContribution
4443
4555
  })], PathRenderer);
4556
+ var CanvasRendererPluginOptions = g.Syringe.defineToken('CanvasRendererPluginOptions');
4444
4557
 
4445
4558
  var _class$2;
4446
4559
 
@@ -4462,6 +4575,7 @@
4462
4575
  this.styleRendererFactory = void 0;
4463
4576
  this.styleRendererFactoryCache = {};
4464
4577
  this.displayObjectPool = void 0;
4578
+ this.canvasRendererPluginOptions = void 0;
4465
4579
  this.rBush = void 0;
4466
4580
  this.removedRBushNodeAABBs = [];
4467
4581
  this.renderQueue = [];
@@ -4478,6 +4592,8 @@
4478
4592
  _proto.apply = function apply(renderingService) {
4479
4593
  var _this = this;
4480
4594
 
4595
+ var canvas = this.renderingContext.root.ownerDocument.defaultView;
4596
+
4481
4597
  var handleUnmounted = function handleUnmounted(e) {
4482
4598
  var object = e.target; // remove r-bush node
4483
4599
  // @ts-ignore
@@ -4540,19 +4656,22 @@
4540
4656
 
4541
4657
  var _this$canvasConfig2 = _this.canvasConfig,
4542
4658
  width = _this$canvasConfig2.width,
4543
- height = _this$canvasConfig2.height; // some heuristic conditions such as 80% object changed
4659
+ height = _this$canvasConfig2.height;
4660
+ var _this$canvasRendererP = _this.canvasRendererPluginOptions,
4661
+ dirtyObjectNumThreshold = _this$canvasRendererP.dirtyObjectNumThreshold,
4662
+ dirtyObjectRatioThreshold = _this$canvasRendererP.dirtyObjectRatioThreshold; // some heuristic conditions such as 80% object changed
4544
4663
 
4545
4664
  var _renderingService$get = renderingService.getStats(),
4546
4665
  total = _renderingService$get.total,
4547
4666
  rendered = _renderingService$get.rendered;
4548
4667
 
4549
4668
  var ratio = rendered / total;
4550
- _this.clearFullScreen = renderingService.disableDirtyRectangleRendering() || rendered > 100 && ratio > 0.8;
4669
+ _this.clearFullScreen = renderingService.disableDirtyRectangleRendering() || rendered > dirtyObjectNumThreshold && ratio > dirtyObjectRatioThreshold;
4551
4670
 
4552
4671
  if (context) {
4553
- if (_this.clearFullScreen) {
4554
- context.resetTransform();
4672
+ context.resetTransform();
4555
4673
 
4674
+ if (_this.clearFullScreen) {
4556
4675
  _this.clearRect(context, 0, 0, width * dpr, height * dpr);
4557
4676
  }
4558
4677
  }
@@ -4567,7 +4686,10 @@
4567
4686
  if (_this.clearFullScreen) {
4568
4687
  _this.renderingContext.root.forEach(function (object) {
4569
4688
  if (object.isVisible() && !object.isCulled()) {
4570
- _this.renderDisplayObject(object, renderingService);
4689
+ _this.renderDisplayObject(object, renderingService); // if we did a full screen rendering last frame
4690
+
4691
+
4692
+ _this.saveDirtyAABB(object);
4571
4693
  }
4572
4694
  });
4573
4695
  } else {
@@ -4589,29 +4711,37 @@
4589
4711
  return;
4590
4712
  }
4591
4713
 
4592
- var _this$convertAABB2Rec = _this.convertAABB2Rect(dirtyRenderBounds),
4593
- x = _this$convertAABB2Rec.x,
4594
- y = _this$convertAABB2Rec.y,
4595
- width = _this$convertAABB2Rec.width,
4596
- height = _this$convertAABB2Rec.height; // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
4597
-
4598
-
4599
- context.setTransform(_this.vpMatrix[0], _this.vpMatrix[1], _this.vpMatrix[4], _this.vpMatrix[5], _this.vpMatrix[12], _this.vpMatrix[13]);
4714
+ var dirtyRect = _this.convertAABB2Rect(dirtyRenderBounds);
4715
+
4716
+ var x = dirtyRect.x,
4717
+ y = dirtyRect.y,
4718
+ width = dirtyRect.width,
4719
+ height = dirtyRect.height;
4720
+ var tl = transformMat4$1(_this.tmpVec3, fromValues$1(x, y, 0), _this.vpMatrix);
4721
+ var br = transformMat4$1(create$1$1(), fromValues$1(x + width, y + height, 0), _this.vpMatrix);
4722
+ var ix = Math.floor(tl[0]);
4723
+ var iy = Math.floor(tl[1]);
4724
+ var iwidth = Math.ceil(br[0] - tl[0]);
4725
+ var iheight = Math.ceil(br[1] - tl[1]);
4600
4726
  context.save();
4601
4727
 
4602
- _this.clearRect(context, x, y, width, height);
4728
+ _this.clearRect(context, ix, iy, iwidth, iheight);
4603
4729
 
4604
4730
  context.beginPath();
4605
- context.rect(x, y, width, height);
4606
- context.clip(); // draw dirty rectangle
4607
- // if (enableDirtyRectangleRenderingDebug) {
4608
- // context.lineWidth = 4;
4609
- // context.strokeStyle = `rgba(${Math.random() * 255}, ${Math.random() * 255}, ${
4610
- // Math.random() * 255
4611
- // }, 1)`;
4612
- // context.strokeRect(x, y, width, height);
4613
- // }
4614
- // search objects intersect with dirty rectangle
4731
+ context.rect(ix, iy, iwidth, iheight);
4732
+ context.clip(); // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
4733
+
4734
+ context.setTransform(_this.vpMatrix[0], _this.vpMatrix[1], _this.vpMatrix[4], _this.vpMatrix[5], _this.vpMatrix[12], _this.vpMatrix[13]); // draw dirty rectangle
4735
+
4736
+ var _this$canvasConfig$re = _this.canvasConfig.renderer.getConfig(),
4737
+ enableDirtyRectangleRenderingDebug = _this$canvasConfig$re.enableDirtyRectangleRenderingDebug;
4738
+
4739
+ if (enableDirtyRectangleRenderingDebug) {
4740
+ canvas.dispatchEvent(new g.CustomEvent(g.CanvasEvent.DIRTY_RECTANGLE, {
4741
+ dirtyRect: dirtyRect
4742
+ }));
4743
+ } // search objects intersect with dirty rectangle
4744
+
4615
4745
 
4616
4746
  var dirtyObjects = _this.searchDirtyObjects(dirtyRenderBounds); // do rendering
4617
4747
 
@@ -4642,7 +4772,6 @@
4642
4772
 
4643
4773
 
4644
4774
  _this.restoreStack = [];
4645
- _this.clearFullScreen = false;
4646
4775
  });
4647
4776
  renderingService.hooks.render.tap(CanvasRendererPlugin_1.tag, function (object) {
4648
4777
  if (!_this.clearFullScreen) {
@@ -4653,6 +4782,7 @@
4653
4782
  };
4654
4783
 
4655
4784
  _proto.clearRect = function clearRect(context, x, y, width, height) {
4785
+ // clearRect is faster than fillRect @see https://stackoverflow.com/a/30830253
4656
4786
  context.clearRect(x, y, width, height);
4657
4787
  var background = this.canvasConfig.background;
4658
4788
 
@@ -4766,6 +4896,7 @@
4766
4896
 
4767
4897
  _proto.mergeDirtyAABBs = function mergeDirtyAABBs(dirtyObjects) {
4768
4898
  // merge into a big AABB
4899
+ // TODO: skip descendant if ancestor is caculated, but compareNodePosition is really slow
4769
4900
  var aabb = new g.AABB();
4770
4901
  dirtyObjects.forEach(function (object) {
4771
4902
  var renderBounds = object.getRenderBounds();
@@ -4828,12 +4959,7 @@
4828
4959
  fill = _object$parsedStyle.fill,
4829
4960
  opacity = _object$parsedStyle.opacity,
4830
4961
  lineDash = _object$parsedStyle.lineDash,
4831
- lineDashOffset = _object$parsedStyle.lineDashOffset,
4832
- filter = _object$parsedStyle.filter,
4833
- shadowColor = _object$parsedStyle.shadowColor,
4834
- shadowBlur = _object$parsedStyle.shadowBlur,
4835
- shadowOffsetX = _object$parsedStyle.shadowOffsetX,
4836
- shadowOffsetY = _object$parsedStyle.shadowOffsetY; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
4962
+ lineDashOffset = _object$parsedStyle.lineDashOffset; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
4837
4963
 
4838
4964
  if (lineDash && Array.isArray(lineDash)) {
4839
4965
  context.setLineDash(lineDash.map(function (segment) {
@@ -4857,20 +4983,6 @@
4857
4983
  if (!g.isNil(fill) && !Array.isArray(fill) && !fill.isNone) {
4858
4984
  context.fillStyle = object.attributes.fill;
4859
4985
  }
4860
-
4861
- if (!g.isNil(filter)) {
4862
- // use raw filter string
4863
- context.filter = object.style.filter;
4864
- }
4865
-
4866
- var hasShadow = !g.isNil(shadowColor) && (shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) > 0;
4867
-
4868
- if (hasShadow) {
4869
- context.shadowColor = shadowColor.toString();
4870
- context.shadowBlur = shadowBlur && shadowBlur.value || 0;
4871
- context.shadowOffsetX = shadowOffsetX && shadowOffsetX.value || 0;
4872
- context.shadowOffsetY = shadowOffsetY && shadowOffsetY.value || 0;
4873
- }
4874
4986
  };
4875
4987
 
4876
4988
  _proto.applyWorldTransform = function applyWorldTransform(context, object, matrix) {
@@ -4944,6 +5056,8 @@
4944
5056
 
4945
5057
  __decorate([g.inject(g.DisplayObjectPool), __metadata("design:type", g.DisplayObjectPool)], CanvasRendererPlugin.prototype, "displayObjectPool", void 0);
4946
5058
 
5059
+ __decorate([g.inject(CanvasRendererPluginOptions), __metadata("design:type", Object)], CanvasRendererPlugin.prototype, "canvasRendererPluginOptions", void 0);
5060
+
4947
5061
  __decorate([g.inject(g.RBushRoot), __metadata("design:type", g.RBush)], CanvasRendererPlugin.prototype, "rBush", void 0);
4948
5062
 
4949
5063
  CanvasRendererPlugin = CanvasRendererPlugin_1 = __decorate([g.singleton({
@@ -4979,23 +5093,42 @@
4979
5093
  register(CanvasRendererPlugin);
4980
5094
  });
4981
5095
 
4982
- var Plugin$3 = /*#__PURE__*/function () {
4983
- function Plugin() {
4984
- this.name = 'canvas-renderer';
5096
+ var Plugin$3 = /*#__PURE__*/function (_AbstractRendererPlug) {
5097
+ _inheritsLoose$4(Plugin, _AbstractRendererPlug);
5098
+
5099
+ function Plugin(options) {
5100
+ var _this;
5101
+
5102
+ if (options === void 0) {
5103
+ options = {};
5104
+ }
5105
+
5106
+ _this = _AbstractRendererPlug.call(this) || this;
5107
+ _this.options = void 0;
5108
+ _this.name = 'canvas-renderer';
5109
+ _this.options = options;
5110
+ return _this;
4985
5111
  }
4986
5112
 
4987
5113
  var _proto = Plugin.prototype;
4988
5114
 
4989
- _proto.init = function init(container) {
4990
- container.load(containerModule$3, true);
5115
+ _proto.init = function init() {
5116
+ this.container.register(CanvasRendererPluginOptions, {
5117
+ useValue: _extends({
5118
+ dirtyObjectNumThreshold: 500,
5119
+ dirtyObjectRatioThreshold: 0.8
5120
+ }, this.options)
5121
+ });
5122
+ this.container.load(containerModule$3, true);
4991
5123
  };
4992
5124
 
4993
- _proto.destroy = function destroy(container) {
4994
- container.unload(containerModule$3);
5125
+ _proto.destroy = function destroy() {
5126
+ this.container.unload(containerModule$3);
5127
+ this.container.remove(CanvasRendererPluginOptions);
4995
5128
  };
4996
5129
 
4997
5130
  return Plugin;
4998
- }();
5131
+ }(g.AbstractRendererPlugin);
4999
5132
 
5000
5133
  var index_esm$3 = /*#__PURE__*/Object.freeze({
5001
5134
  __proto__: null,
@@ -5407,6 +5540,21 @@
5407
5540
  };
5408
5541
  }
5409
5542
 
5543
+ function _inheritsLoose$5(subClass, superClass) {
5544
+ subClass.prototype = Object.create(superClass.prototype);
5545
+ subClass.prototype.constructor = subClass;
5546
+
5547
+ _setPrototypeOf$5(subClass, superClass);
5548
+ }
5549
+
5550
+ function _setPrototypeOf$5(o, p) {
5551
+ _setPrototypeOf$5 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
5552
+ o.__proto__ = p;
5553
+ return o;
5554
+ };
5555
+ return _setPrototypeOf$5(o, p);
5556
+ }
5557
+
5410
5558
  var _class$3;
5411
5559
 
5412
5560
  var DOMInteractionPlugin_1;
@@ -5573,23 +5721,33 @@
5573
5721
  register(DOMInteractionPlugin);
5574
5722
  });
5575
5723
 
5576
- var Plugin$4 = /*#__PURE__*/function () {
5724
+ var Plugin$4 = /*#__PURE__*/function (_AbstractRendererPlug) {
5725
+ _inheritsLoose$5(Plugin, _AbstractRendererPlug);
5726
+
5577
5727
  function Plugin() {
5578
- this.name = 'dom-interaction';
5728
+ var _this;
5729
+
5730
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5731
+ args[_key] = arguments[_key];
5732
+ }
5733
+
5734
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
5735
+ _this.name = 'dom-interaction';
5736
+ return _this;
5579
5737
  }
5580
5738
 
5581
5739
  var _proto = Plugin.prototype;
5582
5740
 
5583
- _proto.init = function init(container) {
5584
- container.load(containerModule$4, true);
5741
+ _proto.init = function init() {
5742
+ this.container.load(containerModule$4, true);
5585
5743
  };
5586
5744
 
5587
- _proto.destroy = function destroy(container) {
5588
- container.unload(containerModule$4);
5745
+ _proto.destroy = function destroy() {
5746
+ this.container.unload(containerModule$4);
5589
5747
  };
5590
5748
 
5591
5749
  return Plugin;
5592
- }();
5750
+ }(g.AbstractRendererPlugin);
5593
5751
 
5594
5752
  var index_esm$4 = /*#__PURE__*/Object.freeze({
5595
5753
  __proto__: null,
@@ -5982,6 +6140,21 @@
5982
6140
  };
5983
6141
  }
5984
6142
 
6143
+ function _inheritsLoose$6(subClass, superClass) {
6144
+ subClass.prototype = Object.create(superClass.prototype);
6145
+ subClass.prototype.constructor = subClass;
6146
+
6147
+ _setPrototypeOf$6(subClass, superClass);
6148
+ }
6149
+
6150
+ function _setPrototypeOf$6(o, p) {
6151
+ _setPrototypeOf$6 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
6152
+ o.__proto__ = p;
6153
+ return o;
6154
+ };
6155
+ return _setPrototypeOf$6(o, p);
6156
+ }
6157
+
5985
6158
  var _class$4;
5986
6159
 
5987
6160
  var HTMLRenderingPlugin_1;
@@ -6250,23 +6423,33 @@
6250
6423
  register(HTMLRenderingPlugin);
6251
6424
  });
6252
6425
 
6253
- var Plugin$5 = /*#__PURE__*/function () {
6426
+ var Plugin$5 = /*#__PURE__*/function (_AbstractRendererPlug) {
6427
+ _inheritsLoose$6(Plugin, _AbstractRendererPlug);
6428
+
6254
6429
  function Plugin() {
6255
- this.name = 'html-renderer';
6430
+ var _this;
6431
+
6432
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6433
+ args[_key] = arguments[_key];
6434
+ }
6435
+
6436
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
6437
+ _this.name = 'html-renderer';
6438
+ return _this;
6256
6439
  }
6257
6440
 
6258
6441
  var _proto = Plugin.prototype;
6259
6442
 
6260
- _proto.init = function init(container) {
6261
- container.load(containerModule$5, true);
6443
+ _proto.init = function init() {
6444
+ this.container.load(containerModule$5, true);
6262
6445
  };
6263
6446
 
6264
- _proto.destroy = function destroy(container) {
6265
- container.unload(containerModule$5);
6447
+ _proto.destroy = function destroy() {
6448
+ this.container.unload(containerModule$5);
6266
6449
  };
6267
6450
 
6268
6451
  return Plugin;
6269
- }();
6452
+ }(g.AbstractRendererPlugin);
6270
6453
 
6271
6454
  var index_esm$5 = /*#__PURE__*/Object.freeze({
6272
6455
  __proto__: null,
@@ -6433,23 +6616,33 @@
6433
6616
  */
6434
6617
  register(Canvas2DContextService);
6435
6618
  });
6436
- var ContextRegisterPlugin = /*#__PURE__*/function () {
6619
+ var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
6620
+ _inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
6621
+
6437
6622
  function ContextRegisterPlugin() {
6438
- this.name = 'canvas-context-register';
6623
+ var _this;
6624
+
6625
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6626
+ args[_key] = arguments[_key];
6627
+ }
6628
+
6629
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
6630
+ _this.name = 'canvas-context-register';
6631
+ return _this;
6439
6632
  }
6440
6633
 
6441
6634
  var _proto = ContextRegisterPlugin.prototype;
6442
6635
 
6443
- _proto.init = function init(container) {
6444
- container.load(containerModule$6, true);
6636
+ _proto.init = function init() {
6637
+ this.container.load(containerModule$6, true);
6445
6638
  };
6446
6639
 
6447
- _proto.destroy = function destroy(container) {
6448
- container.unload(containerModule$6);
6640
+ _proto.destroy = function destroy() {
6641
+ this.container.unload(containerModule$6);
6449
6642
  };
6450
6643
 
6451
6644
  return ContextRegisterPlugin;
6452
- }();
6645
+ }(g.AbstractRendererPlugin);
6453
6646
 
6454
6647
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
6455
6648
  _inheritsLoose(Renderer, _AbstractRenderer);