@antv/g-webgpu 1.7.20 → 1.7.21

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.
@@ -1 +1 @@
1
- {"version":3,"file":"WebGPUContextService.d.ts","sourceRoot":"","sources":["../src/WebGPUContextService.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EACL,YAAY,EACZ,cAAc,EAKf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,KAAK,cAAc,MAAM,gCAAgC,CAAC;AAItE,qBACa,oBAAqB,YAAW,cAAc,CAAC,gBAAgB,CAAC;IAOzE,OAAO,CAAC,YAAY;IAGpB,OAAO,CAAC,oBAAoB;IAT9B,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,GAAG,CAAS;gBAIV,YAAY,EAAE,YAAY,EAG1B,oBAAoB,EAAE,cAAc,CAAC,MAAM;IAG/C,IAAI;IAgCV,aAAa;IAIb,UAAU;IAKV,qBAAqB;IAMrB,OAAO;IAQP,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAapC,MAAM;IAIN,gBAAgB,CAAC,MAAM,EAAE,MAAM;IAMzB,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC;CAGjD"}
1
+ {"version":3,"file":"WebGPUContextService.d.ts","sourceRoot":"","sources":["../src/WebGPUContextService.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EACL,YAAY,EACZ,cAAc,EAKf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,KAAK,cAAc,MAAM,gCAAgC,CAAC;AAItE,qBACa,oBAAqB,YAAW,cAAc,CAAC,gBAAgB,CAAC;IAOzE,OAAO,CAAC,YAAY;IAGpB,OAAO,CAAC,oBAAoB;IAT9B,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,GAAG,CAAS;gBAIV,YAAY,EAAE,YAAY,EAG1B,oBAAoB,EAAE,cAAc,CAAC,MAAM;IAG/C,IAAI;IA6BV,aAAa;IAIb,UAAU;IAKV,qBAAqB;IAMrB,OAAO;IAQP,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAmBpC,MAAM;IAIN,gBAAgB,CAAC,MAAM,EAAE,MAAM;IAMzB,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC;CAGjD"}
package/dist/index.esm.js CHANGED
@@ -453,13 +453,13 @@ var WebGPUContextService = /*#__PURE__*/function () {
453
453
 
454
454
  _proto.init = /*#__PURE__*/function () {
455
455
  var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
456
- var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
456
+ var _this$canvasConfig, container, canvas, $canvas;
457
457
 
458
458
  return _regeneratorRuntime().wrap(function _callee$(_context) {
459
459
  while (1) {
460
460
  switch (_context.prev = _context.next) {
461
461
  case 0:
462
- _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
462
+ _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
463
463
 
464
464
  if (canvas) {
465
465
  this.$canvas = canvas;
@@ -485,14 +485,11 @@ var WebGPUContextService = /*#__PURE__*/function () {
485
485
 
486
486
  this.$canvas = $canvas;
487
487
  }
488
- } // use user-defined dpr first
488
+ }
489
489
 
490
+ this.resize(this.canvasConfig.width, this.canvasConfig.height);
490
491
 
491
- dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
492
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
493
- this.dpr = dpr;
494
-
495
- case 5:
492
+ case 3:
496
493
  case "end":
497
494
  return _context.stop();
498
495
  }
@@ -531,11 +528,18 @@ var WebGPUContextService = /*#__PURE__*/function () {
531
528
  };
532
529
 
533
530
  _proto.resize = function resize(width, height) {
531
+ // use user-defined dpr first
532
+ var devicePixelRatio = this.canvasConfig.devicePixelRatio;
533
+ var dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
534
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
535
+ this.dpr = dpr;
536
+
534
537
  if (this.$canvas) {
535
- var dpr = this.getDPR(); // set canvas width & height
538
+ var _dpr = this.getDPR(); // set canvas width & height
539
+
536
540
 
537
- this.$canvas.width = dpr * width;
538
- this.$canvas.height = dpr * height; // set CSS style width & height
541
+ this.$canvas.width = _dpr * width;
542
+ this.$canvas.height = _dpr * height; // set CSS style width & height
539
543
 
540
544
  setDOMSize(this.$canvas, width, height);
541
545
  }
package/dist/index.js CHANGED
@@ -474,13 +474,13 @@ var WebGPUContextService = /*#__PURE__*/function () {
474
474
 
475
475
  _proto.init = /*#__PURE__*/function () {
476
476
  var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
477
- var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
477
+ var _this$canvasConfig, container, canvas, $canvas;
478
478
 
479
479
  return _regeneratorRuntime().wrap(function _callee$(_context) {
480
480
  while (1) {
481
481
  switch (_context.prev = _context.next) {
482
482
  case 0:
483
- _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
483
+ _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
484
484
 
485
485
  if (canvas) {
486
486
  this.$canvas = canvas;
@@ -506,14 +506,11 @@ var WebGPUContextService = /*#__PURE__*/function () {
506
506
 
507
507
  this.$canvas = $canvas;
508
508
  }
509
- } // use user-defined dpr first
509
+ }
510
510
 
511
+ this.resize(this.canvasConfig.width, this.canvasConfig.height);
511
512
 
512
- dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
513
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
514
- this.dpr = dpr;
515
-
516
- case 5:
513
+ case 3:
517
514
  case "end":
518
515
  return _context.stop();
519
516
  }
@@ -552,11 +549,18 @@ var WebGPUContextService = /*#__PURE__*/function () {
552
549
  };
553
550
 
554
551
  _proto.resize = function resize(width, height) {
552
+ // use user-defined dpr first
553
+ var devicePixelRatio = this.canvasConfig.devicePixelRatio;
554
+ var dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
555
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
556
+ this.dpr = dpr;
557
+
555
558
  if (this.$canvas) {
556
- var dpr = this.getDPR(); // set canvas width & height
559
+ var _dpr = this.getDPR(); // set canvas width & height
560
+
557
561
 
558
- this.$canvas.width = dpr * width;
559
- this.$canvas.height = dpr * height; // set CSS style width & height
562
+ this.$canvas.width = _dpr * width;
563
+ this.$canvas.height = _dpr * height; // set CSS style width & height
560
564
 
561
565
  gLite.setDOMSize(this.$canvas, width, height);
562
566
  }
package/dist/index.umd.js CHANGED
@@ -2058,15 +2058,15 @@
2058
2058
  };
2059
2059
 
2060
2060
  _proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
2061
- var key = this.generateGradientKey(params); // @ts-ignore
2062
-
2061
+ var key = this.generateGradientKey(params);
2063
2062
  var type = params.type,
2064
2063
  steps = params.steps,
2065
2064
  width = params.width,
2066
2065
  height = params.height,
2067
2066
  angle = params.angle,
2068
2067
  cx = params.cx,
2069
- cy = params.cy;
2068
+ cy = params.cy,
2069
+ size = params.size;
2070
2070
 
2071
2071
  if (this.gradientCache[key]) {
2072
2072
  return this.gradientCache[key];
@@ -2084,7 +2084,7 @@
2084
2084
 
2085
2085
  gradient = context.createLinearGradient(x1, y1, x2, y2);
2086
2086
  } else if (type === gLite.GradientType.RadialGradient) {
2087
- var _computeRadialGradien = gLite.computeRadialGradient(width, height, cx, cy),
2087
+ var _computeRadialGradien = gLite.computeRadialGradient(width, height, cx, cy, size),
2088
2088
  x = _computeRadialGradien.x,
2089
2089
  y = _computeRadialGradien.y,
2090
2090
  r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
@@ -2095,11 +2095,14 @@
2095
2095
 
2096
2096
  if (gradient) {
2097
2097
  steps.forEach(function (_ref) {
2098
- var _gradient;
2098
+ var offset = _ref.offset,
2099
+ color = _ref.color;
2100
+
2101
+ if (offset.unit === gLite.UnitType.kPercentage) {
2102
+ var _gradient;
2099
2103
 
2100
- var offset = _ref[0],
2101
- color = _ref[1];
2102
- (_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset, color);
2104
+ (_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset.value / 100, color.toString());
2105
+ }
2103
2106
  });
2104
2107
  this.gradientCache[key] = gradient;
2105
2108
  }
@@ -2108,16 +2111,18 @@
2108
2111
  };
2109
2112
 
2110
2113
  _proto.generateGradientKey = function generateGradientKey(params) {
2111
- // @ts-ignore
2112
2114
  var type = params.type,
2113
2115
  width = params.width,
2114
2116
  height = params.height,
2115
2117
  steps = params.steps,
2116
2118
  angle = params.angle,
2117
2119
  cx = params.cx,
2118
- cy = params.cy;
2119
- return "gradient-" + type + "-" + (angle || 0) + "-" + (cx || 0) + "-" + (cy || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
2120
- return step.join('');
2120
+ cy = params.cy,
2121
+ size = params.size;
2122
+ return "gradient-" + type + "-" + ((angle === null || angle === void 0 ? void 0 : angle.toString()) || 0) + "-" + ((cx === null || cx === void 0 ? void 0 : cx.toString()) || 0) + "-" + ((cy === null || cy === void 0 ? void 0 : cy.toString()) || 0) + "-" + ((size === null || size === void 0 ? void 0 : size.toString()) || 0) + "-" + width + "-" + height + "-" + steps.map(function (_ref2) {
2123
+ var offset = _ref2.offset,
2124
+ color = _ref2.color;
2125
+ return "" + offset + color;
2121
2126
  }).join('-');
2122
2127
  };
2123
2128
 
@@ -19856,13 +19861,13 @@
19856
19861
 
19857
19862
  _proto.init = /*#__PURE__*/function () {
19858
19863
  var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
19859
- var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
19864
+ var _this$canvasConfig, container, canvas, $canvas;
19860
19865
 
19861
19866
  return _regeneratorRuntime().wrap(function _callee$(_context) {
19862
19867
  while (1) {
19863
19868
  switch (_context.prev = _context.next) {
19864
19869
  case 0:
19865
- _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
19870
+ _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
19866
19871
 
19867
19872
  if (canvas) {
19868
19873
  this.$canvas = canvas;
@@ -19888,14 +19893,11 @@
19888
19893
 
19889
19894
  this.$canvas = $canvas;
19890
19895
  }
19891
- } // use user-defined dpr first
19892
-
19896
+ }
19893
19897
 
19894
- dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
19895
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
19896
- this.dpr = dpr;
19898
+ this.resize(this.canvasConfig.width, this.canvasConfig.height);
19897
19899
 
19898
- case 5:
19900
+ case 3:
19899
19901
  case "end":
19900
19902
  return _context.stop();
19901
19903
  }
@@ -19934,11 +19936,18 @@
19934
19936
  };
19935
19937
 
19936
19938
  _proto.resize = function resize(width, height) {
19939
+ // use user-defined dpr first
19940
+ var devicePixelRatio = this.canvasConfig.devicePixelRatio;
19941
+ var dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
19942
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
19943
+ this.dpr = dpr;
19944
+
19937
19945
  if (this.$canvas) {
19938
- var dpr = this.getDPR(); // set canvas width & height
19946
+ var _dpr = this.getDPR(); // set canvas width & height
19947
+
19939
19948
 
19940
- this.$canvas.width = dpr * width;
19941
- this.$canvas.height = dpr * height; // set CSS style width & height
19949
+ this.$canvas.width = _dpr * width;
19950
+ this.$canvas.height = _dpr * height; // set CSS style width & height
19942
19951
 
19943
19952
  gLite.setDOMSize(this.$canvas, width, height);
19944
19953
  }