@antv/g-webgpu 1.7.19 → 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.
package/dist/index.umd.js CHANGED
@@ -1194,15 +1194,6 @@
1194
1194
 
1195
1195
  function __param(paramIndex, decorator) {
1196
1196
  return function (target, key) { decorator(target, key, paramIndex); }
1197
- }
1198
-
1199
- /** @deprecated */
1200
- function __spreadArrays() {
1201
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
1202
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
1203
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
1204
- r[k] = a[j];
1205
- return r;
1206
1197
  }
1207
1198
 
1208
1199
  var eventemitter3 = createCommonjsModule(function (module) {
@@ -1978,148 +1969,6 @@
1978
1969
  return _setPrototypeOf$1(o, p);
1979
1970
  }
1980
1971
 
1981
- var toString$1 = {}.toString;
1982
-
1983
- var isType$1 = function isType(value, type) {
1984
- return toString$1.call(value) === '[object ' + type + ']';
1985
- };
1986
- /**
1987
- * 是否为函数
1988
- * @param {*} fn 对象
1989
- * @return {Boolean} 是否函数
1990
- */
1991
-
1992
-
1993
- var isFunction = function isFunction(value) {
1994
- return isType$1(value, 'Function');
1995
- };
1996
-
1997
- var isArray = function isArray(value) {
1998
- return Array.isArray ? Array.isArray(value) : isType$1(value, 'Array');
1999
- };
2000
-
2001
- var isObject = function isObject(value) {
2002
- /**
2003
- * isObject({}) => true
2004
- * isObject([1, 2, 3]) => true
2005
- * isObject(Function) => true
2006
- * isObject(null) => false
2007
- */
2008
- var type = typeof value;
2009
- return value !== null && type === 'object' || type === 'function';
2010
- };
2011
-
2012
- function each(elements, func) {
2013
- if (!elements) {
2014
- return;
2015
- }
2016
-
2017
- var rst;
2018
-
2019
- if (isArray(elements)) {
2020
- for (var i = 0, len = elements.length; i < len; i++) {
2021
- rst = func(elements[i], i);
2022
-
2023
- if (rst === false) {
2024
- break;
2025
- }
2026
- }
2027
- } else if (isObject(elements)) {
2028
- for (var k in elements) {
2029
- if (elements.hasOwnProperty(k)) {
2030
- rst = func(elements[k], k);
2031
-
2032
- if (rst === false) {
2033
- break;
2034
- }
2035
- }
2036
- }
2037
- }
2038
- }
2039
-
2040
- var isString$1 = function isString(str) {
2041
- return isType$1(str, 'String');
2042
- }; // @ts-ignore
2043
-
2044
-
2045
- var values = Object.values ? function (obj) {
2046
- return Object.values(obj);
2047
- } : function (obj) {
2048
- var result = [];
2049
- each(obj, function (value, key) {
2050
- if (!(isFunction(obj) && key === 'prototype')) {
2051
- result.push(value);
2052
- }
2053
- });
2054
- return result;
2055
- };
2056
- /**
2057
- * _.memoize(calColor);
2058
- * _.memoize(calColor, (...args) => args[0]);
2059
- * @param f
2060
- * @param resolver
2061
- */
2062
-
2063
- var memoize = function memoize(f, resolver) {
2064
- if (!isFunction(f)) {
2065
- throw new TypeError('Expected a function');
2066
- }
2067
-
2068
- var memoized = function memoized() {
2069
- var args = [];
2070
-
2071
- for (var _i = 0; _i < arguments.length; _i++) {
2072
- args[_i] = arguments[_i];
2073
- } // 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
2074
-
2075
-
2076
- var key = resolver ? resolver.apply(this, args) : args[0];
2077
- var cache = memoized.cache;
2078
-
2079
- if (cache.has(key)) {
2080
- return cache.get(key);
2081
- }
2082
-
2083
- var result = f.apply(this, args); // 缓存起来
2084
-
2085
- cache.set(key, result);
2086
- return result;
2087
- };
2088
-
2089
- memoized.cache = new Map();
2090
- return memoized;
2091
- };
2092
-
2093
- var ctx;
2094
- /**
2095
- * 计算文本的宽度
2096
- */
2097
-
2098
- memoize(function (text, font) {
2099
- if (font === void 0) {
2100
- font = {};
2101
- }
2102
-
2103
- var fontSize = font.fontSize,
2104
- fontFamily = font.fontFamily,
2105
- fontWeight = font.fontWeight,
2106
- fontStyle = font.fontStyle,
2107
- fontVariant = font.fontVariant;
2108
-
2109
- if (!ctx) {
2110
- ctx = document.createElement('canvas').getContext('2d');
2111
- }
2112
-
2113
- ctx.font = [fontStyle, fontVariant, fontWeight, fontSize + "px", fontFamily].join(' ');
2114
- return ctx.measureText(isString$1(text) ? text : '').width;
2115
- }, function (text, font) {
2116
- if (font === void 0) {
2117
- font = {};
2118
- }
2119
-
2120
- return __spreadArrays([text], values(font)).join('');
2121
- });
2122
-
2123
1972
  var ImagePool = /*#__PURE__*/function () {
2124
1973
  function ImagePool(canvasConfig) {
2125
1974
  this.canvasConfig = void 0;
@@ -2192,7 +2041,7 @@
2192
2041
  repetition = pattern.repetition;
2193
2042
  var src; // Image URL
2194
2043
 
2195
- if (isString$1(image)) {
2044
+ if (isString(image)) {
2196
2045
  src = this.getImageSync(image, callback);
2197
2046
  } else {
2198
2047
  src = image;
@@ -2209,15 +2058,15 @@
2209
2058
  };
2210
2059
 
2211
2060
  _proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
2212
- var key = this.generateGradientKey(params); // @ts-ignore
2213
-
2061
+ var key = this.generateGradientKey(params);
2214
2062
  var type = params.type,
2215
2063
  steps = params.steps,
2216
2064
  width = params.width,
2217
2065
  height = params.height,
2218
2066
  angle = params.angle,
2219
2067
  cx = params.cx,
2220
- cy = params.cy;
2068
+ cy = params.cy,
2069
+ size = params.size;
2221
2070
 
2222
2071
  if (this.gradientCache[key]) {
2223
2072
  return this.gradientCache[key];
@@ -2235,7 +2084,7 @@
2235
2084
 
2236
2085
  gradient = context.createLinearGradient(x1, y1, x2, y2);
2237
2086
  } else if (type === gLite.GradientType.RadialGradient) {
2238
- var _computeRadialGradien = gLite.computeRadialGradient(width, height, cx, cy),
2087
+ var _computeRadialGradien = gLite.computeRadialGradient(width, height, cx, cy, size),
2239
2088
  x = _computeRadialGradien.x,
2240
2089
  y = _computeRadialGradien.y,
2241
2090
  r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
@@ -2246,11 +2095,14 @@
2246
2095
 
2247
2096
  if (gradient) {
2248
2097
  steps.forEach(function (_ref) {
2249
- var _gradient;
2098
+ var offset = _ref.offset,
2099
+ color = _ref.color;
2100
+
2101
+ if (offset.unit === gLite.UnitType.kPercentage) {
2102
+ var _gradient;
2250
2103
 
2251
- var offset = _ref[0],
2252
- color = _ref[1];
2253
- (_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
+ }
2254
2106
  });
2255
2107
  this.gradientCache[key] = gradient;
2256
2108
  }
@@ -2259,16 +2111,18 @@
2259
2111
  };
2260
2112
 
2261
2113
  _proto.generateGradientKey = function generateGradientKey(params) {
2262
- // @ts-ignore
2263
2114
  var type = params.type,
2264
2115
  width = params.width,
2265
2116
  height = params.height,
2266
2117
  steps = params.steps,
2267
2118
  angle = params.angle,
2268
2119
  cx = params.cx,
2269
- cy = params.cy;
2270
- return "gradient-" + type + "-" + (angle || 0) + "-" + (cx || 0) + "-" + (cy || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
2271
- 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;
2272
2126
  }).join('-');
2273
2127
  };
2274
2128
 
@@ -2276,7 +2130,7 @@
2276
2130
  var image = pattern.image,
2277
2131
  repetition = pattern.repetition; // only generate cache for Image
2278
2132
 
2279
- if (isString$1(image)) {
2133
+ if (isString(image)) {
2280
2134
  return "pattern-" + image + "-" + repetition;
2281
2135
  }
2282
2136
  };
@@ -2310,7 +2164,7 @@
2310
2164
  if (nodeName === gLite.Shape.IMAGE) {
2311
2165
  var img = attributes.img;
2312
2166
 
2313
- if (isString$1(img)) {
2167
+ if (isString(img)) {
2314
2168
  _this.imagePool.getImageSync(img, function () {
2315
2169
  // set dirty rectangle flag
2316
2170
  object.renderable.dirty = true;
@@ -2327,7 +2181,7 @@
2327
2181
 
2328
2182
  if (object.nodeName === gLite.Shape.IMAGE) {
2329
2183
  if (attrName === 'img') {
2330
- if (isString$1(newValue)) {
2184
+ if (isString(newValue)) {
2331
2185
  _this.imagePool.getOrCreateImage(newValue).then(function () {
2332
2186
  // set dirty rectangle flag
2333
2187
  object.renderable.dirty = true;
@@ -16622,148 +16476,6 @@
16622
16476
  return _setPrototypeOf$4(o, p);
16623
16477
  }
16624
16478
 
16625
- var toString$2 = {}.toString;
16626
-
16627
- var isType$2 = function isType(value, type) {
16628
- return toString$2.call(value) === '[object ' + type + ']';
16629
- };
16630
- /**
16631
- * 是否为函数
16632
- * @param {*} fn 对象
16633
- * @return {Boolean} 是否函数
16634
- */
16635
-
16636
-
16637
- var isFunction$1 = function isFunction(value) {
16638
- return isType$2(value, 'Function');
16639
- };
16640
-
16641
- var isArray$1 = function isArray(value) {
16642
- return Array.isArray ? Array.isArray(value) : isType$2(value, 'Array');
16643
- };
16644
-
16645
- var isObject$1 = function isObject(value) {
16646
- /**
16647
- * isObject({}) => true
16648
- * isObject([1, 2, 3]) => true
16649
- * isObject(Function) => true
16650
- * isObject(null) => false
16651
- */
16652
- var type = typeof value;
16653
- return value !== null && type === 'object' || type === 'function';
16654
- };
16655
-
16656
- function each$1(elements, func) {
16657
- if (!elements) {
16658
- return;
16659
- }
16660
-
16661
- var rst;
16662
-
16663
- if (isArray$1(elements)) {
16664
- for (var i = 0, len = elements.length; i < len; i++) {
16665
- rst = func(elements[i], i);
16666
-
16667
- if (rst === false) {
16668
- break;
16669
- }
16670
- }
16671
- } else if (isObject$1(elements)) {
16672
- for (var k in elements) {
16673
- if (elements.hasOwnProperty(k)) {
16674
- rst = func(elements[k], k);
16675
-
16676
- if (rst === false) {
16677
- break;
16678
- }
16679
- }
16680
- }
16681
- }
16682
- }
16683
-
16684
- var isString$2 = function isString(str) {
16685
- return isType$2(str, 'String');
16686
- }; // @ts-ignore
16687
-
16688
-
16689
- var values$1 = Object.values ? function (obj) {
16690
- return Object.values(obj);
16691
- } : function (obj) {
16692
- var result = [];
16693
- each$1(obj, function (value, key) {
16694
- if (!(isFunction$1(obj) && key === 'prototype')) {
16695
- result.push(value);
16696
- }
16697
- });
16698
- return result;
16699
- };
16700
- /**
16701
- * _.memoize(calColor);
16702
- * _.memoize(calColor, (...args) => args[0]);
16703
- * @param f
16704
- * @param resolver
16705
- */
16706
-
16707
- var memoize$1 = function memoize(f, resolver) {
16708
- if (!isFunction$1(f)) {
16709
- throw new TypeError('Expected a function');
16710
- }
16711
-
16712
- var memoized = function memoized() {
16713
- var args = [];
16714
-
16715
- for (var _i = 0; _i < arguments.length; _i++) {
16716
- args[_i] = arguments[_i];
16717
- } // 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
16718
-
16719
-
16720
- var key = resolver ? resolver.apply(this, args) : args[0];
16721
- var cache = memoized.cache;
16722
-
16723
- if (cache.has(key)) {
16724
- return cache.get(key);
16725
- }
16726
-
16727
- var result = f.apply(this, args); // 缓存起来
16728
-
16729
- cache.set(key, result);
16730
- return result;
16731
- };
16732
-
16733
- memoized.cache = new Map();
16734
- return memoized;
16735
- };
16736
-
16737
- var ctx$1;
16738
- /**
16739
- * 计算文本的宽度
16740
- */
16741
-
16742
- memoize$1(function (text, font) {
16743
- if (font === void 0) {
16744
- font = {};
16745
- }
16746
-
16747
- var fontSize = font.fontSize,
16748
- fontFamily = font.fontFamily,
16749
- fontWeight = font.fontWeight,
16750
- fontStyle = font.fontStyle,
16751
- fontVariant = font.fontVariant;
16752
-
16753
- if (!ctx$1) {
16754
- ctx$1 = document.createElement('canvas').getContext('2d');
16755
- }
16756
-
16757
- ctx$1.font = [fontStyle, fontVariant, fontWeight, fontSize + "px", fontFamily].join(' ');
16758
- return ctx$1.measureText(isString$2(text) ? text : '').width;
16759
- }, function (text, font) {
16760
- if (font === void 0) {
16761
- font = {};
16762
- }
16763
-
16764
- return __spreadArrays([text], values$1(font)).join('');
16765
- });
16766
-
16767
16479
  var _class$3;
16768
16480
 
16769
16481
  var HTMLRenderingPlugin_1;
@@ -16926,7 +16638,7 @@
16926
16638
  case 'innerHTML':
16927
16639
  var innerHTML = object.parsedStyle.innerHTML;
16928
16640
 
16929
- if (isString$2(innerHTML)) {
16641
+ if (isString(innerHTML)) {
16930
16642
  $el.innerHTML = innerHTML;
16931
16643
  } else {
16932
16644
  $el.innerHTML = '';
@@ -18460,157 +18172,6 @@
18460
18172
  return ComputePipeline_WebGPU;
18461
18173
  }(ResourceBase_WebGPU);
18462
18174
 
18463
- var toString$3 = {}.toString;
18464
-
18465
- var isType$3 = function isType(value, type) {
18466
- return toString$3.call(value) === '[object ' + type + ']';
18467
- };
18468
- /**
18469
- * 是否为函数
18470
- * @param {*} fn 对象
18471
- * @return {Boolean} 是否函数
18472
- */
18473
-
18474
-
18475
- var isFunction$2 = function isFunction(value) {
18476
- return isType$3(value, 'Function');
18477
- }; // isFinite,
18478
-
18479
-
18480
- var isNil$1 = function isNil(value) {
18481
- /**
18482
- * isNil(null) => true
18483
- * isNil() => true
18484
- */
18485
- return value === null || value === undefined;
18486
- };
18487
-
18488
- var isArray$2 = function isArray(value) {
18489
- return Array.isArray ? Array.isArray(value) : isType$3(value, 'Array');
18490
- };
18491
-
18492
- var isObject$2 = function isObject(value) {
18493
- /**
18494
- * isObject({}) => true
18495
- * isObject([1, 2, 3]) => true
18496
- * isObject(Function) => true
18497
- * isObject(null) => false
18498
- */
18499
- var type = typeof value;
18500
- return value !== null && type === 'object' || type === 'function';
18501
- };
18502
-
18503
- function each$2(elements, func) {
18504
- if (!elements) {
18505
- return;
18506
- }
18507
-
18508
- var rst;
18509
-
18510
- if (isArray$2(elements)) {
18511
- for (var i = 0, len = elements.length; i < len; i++) {
18512
- rst = func(elements[i], i);
18513
-
18514
- if (rst === false) {
18515
- break;
18516
- }
18517
- }
18518
- } else if (isObject$2(elements)) {
18519
- for (var k in elements) {
18520
- if (elements.hasOwnProperty(k)) {
18521
- rst = func(elements[k], k);
18522
-
18523
- if (rst === false) {
18524
- break;
18525
- }
18526
- }
18527
- }
18528
- }
18529
- }
18530
-
18531
- var isString$3 = function isString(str) {
18532
- return isType$3(str, 'String');
18533
- }; // @ts-ignore
18534
-
18535
-
18536
- var values$2 = Object.values ? function (obj) {
18537
- return Object.values(obj);
18538
- } : function (obj) {
18539
- var result = [];
18540
- each$2(obj, function (value, key) {
18541
- if (!(isFunction$2(obj) && key === 'prototype')) {
18542
- result.push(value);
18543
- }
18544
- });
18545
- return result;
18546
- };
18547
- /**
18548
- * _.memoize(calColor);
18549
- * _.memoize(calColor, (...args) => args[0]);
18550
- * @param f
18551
- * @param resolver
18552
- */
18553
-
18554
- var memoize$2 = function memoize(f, resolver) {
18555
- if (!isFunction$2(f)) {
18556
- throw new TypeError('Expected a function');
18557
- }
18558
-
18559
- var memoized = function memoized() {
18560
- var args = [];
18561
-
18562
- for (var _i = 0; _i < arguments.length; _i++) {
18563
- args[_i] = arguments[_i];
18564
- } // 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
18565
-
18566
-
18567
- var key = resolver ? resolver.apply(this, args) : args[0];
18568
- var cache = memoized.cache;
18569
-
18570
- if (cache.has(key)) {
18571
- return cache.get(key);
18572
- }
18573
-
18574
- var result = f.apply(this, args); // 缓存起来
18575
-
18576
- cache.set(key, result);
18577
- return result;
18578
- };
18579
-
18580
- memoized.cache = new Map();
18581
- return memoized;
18582
- };
18583
-
18584
- var ctx$2;
18585
- /**
18586
- * 计算文本的宽度
18587
- */
18588
-
18589
- memoize$2(function (text, font) {
18590
- if (font === void 0) {
18591
- font = {};
18592
- }
18593
-
18594
- var fontSize = font.fontSize,
18595
- fontFamily = font.fontFamily,
18596
- fontWeight = font.fontWeight,
18597
- fontStyle = font.fontStyle,
18598
- fontVariant = font.fontVariant;
18599
-
18600
- if (!ctx$2) {
18601
- ctx$2 = document.createElement('canvas').getContext('2d');
18602
- }
18603
-
18604
- ctx$2.font = [fontStyle, fontVariant, fontWeight, fontSize + "px", fontFamily].join(' ');
18605
- return ctx$2.measureText(isString$3(text) ? text : '').width;
18606
- }, function (text, font) {
18607
- if (font === void 0) {
18608
- font = {};
18609
- }
18610
-
18611
- return __spreadArrays([text], values$2(font)).join('');
18612
- });
18613
-
18614
18175
  var InputLayout_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
18615
18176
  _inheritsLoose$5(InputLayout_WebGPU, _ResourceBase_WebGPU);
18616
18177
 
@@ -18631,7 +18192,7 @@
18631
18192
 
18632
18193
  for (var i = 0; i < descriptor.vertexBufferDescriptors.length; i++) {
18633
18194
  var b = descriptor.vertexBufferDescriptors[i];
18634
- if (isNil$1(b)) continue;
18195
+ if (isNil(b)) continue;
18635
18196
  var arrayStride = b.byteStride;
18636
18197
  var stepMode = translateVertexBufferFrequency(b.frequency);
18637
18198
  var attributes = [];
@@ -19319,7 +18880,7 @@
19319
18880
 
19320
18881
  for (var i = 0; i < inputState.vertexBuffers.length; i++) {
19321
18882
  var b = inputState.vertexBuffers[i];
19322
- if (isNil$1(b)) continue;
18883
+ if (isNil(b)) continue;
19323
18884
  this.gpuRenderPassEncoder.setVertexBuffer(i, getPlatformBuffer(b.buffer), b.byteOffset);
19324
18885
  }
19325
18886
  };
@@ -20285,122 +19846,6 @@
20285
19846
 
20286
19847
  var DeviceRendererPlugin = gLite.Syringe.defineToken('');
20287
19848
 
20288
- var toString$4 = {}.toString;
20289
- var isType$4 = function (value, type) { return toString$4.call(value) === '[object ' + type + ']'; };
20290
-
20291
- /**
20292
- * 是否为函数
20293
- * @param {*} fn 对象
20294
- * @return {Boolean} 是否函数
20295
- */
20296
- var isFunction$3 = (function (value) {
20297
- return isType$4(value, 'Function');
20298
- });
20299
-
20300
- var isArray$3 = (function (value) {
20301
- return Array.isArray ?
20302
- Array.isArray(value) :
20303
- isType$4(value, 'Array');
20304
- });
20305
-
20306
- var isObject$3 = (function (value) {
20307
- /**
20308
- * isObject({}) => true
20309
- * isObject([1, 2, 3]) => true
20310
- * isObject(Function) => true
20311
- * isObject(null) => false
20312
- */
20313
- var type = typeof value;
20314
- return value !== null && type === 'object' || type === 'function';
20315
- });
20316
-
20317
- function each$3(elements, func) {
20318
- if (!elements) {
20319
- return;
20320
- }
20321
- var rst;
20322
- if (isArray$3(elements)) {
20323
- for (var i = 0, len = elements.length; i < len; i++) {
20324
- rst = func(elements[i], i);
20325
- if (rst === false) {
20326
- break;
20327
- }
20328
- }
20329
- }
20330
- else if (isObject$3(elements)) {
20331
- for (var k in elements) {
20332
- if (elements.hasOwnProperty(k)) {
20333
- rst = func(elements[k], k);
20334
- if (rst === false) {
20335
- break;
20336
- }
20337
- }
20338
- }
20339
- }
20340
- }
20341
-
20342
- var isString$4 = (function (str) {
20343
- return isType$4(str, 'String');
20344
- });
20345
-
20346
- // @ts-ignore
20347
- var values$3 = Object.values ? function (obj) { return Object.values(obj); } : function (obj) {
20348
- var result = [];
20349
- each$3(obj, function (value, key) {
20350
- if (!(isFunction$3(obj) && key === 'prototype')) {
20351
- result.push(value);
20352
- }
20353
- });
20354
- return result;
20355
- };
20356
-
20357
- /**
20358
- * _.memoize(calColor);
20359
- * _.memoize(calColor, (...args) => args[0]);
20360
- * @param f
20361
- * @param resolver
20362
- */
20363
- var memoize$3 = (function (f, resolver) {
20364
- if (!isFunction$3(f)) {
20365
- throw new TypeError('Expected a function');
20366
- }
20367
- var memoized = function () {
20368
- var args = [];
20369
- for (var _i = 0; _i < arguments.length; _i++) {
20370
- args[_i] = arguments[_i];
20371
- }
20372
- // 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
20373
- var key = resolver ? resolver.apply(this, args) : args[0];
20374
- var cache = memoized.cache;
20375
- if (cache.has(key)) {
20376
- return cache.get(key);
20377
- }
20378
- var result = f.apply(this, args);
20379
- // 缓存起来
20380
- cache.set(key, result);
20381
- return result;
20382
- };
20383
- memoized.cache = new Map();
20384
- return memoized;
20385
- });
20386
-
20387
- var ctx$3;
20388
- /**
20389
- * 计算文本的宽度
20390
- */
20391
- memoize$3(function (text, font) {
20392
- if (font === void 0) { font = {}; }
20393
- var fontSize = font.fontSize, fontFamily = font.fontFamily, fontWeight = font.fontWeight, fontStyle = font.fontStyle, fontVariant = font.fontVariant;
20394
- if (!ctx$3) {
20395
- ctx$3 = document.createElement('canvas').getContext('2d');
20396
- }
20397
- ctx$3.font = [fontStyle, fontVariant, fontWeight, fontSize + "px", fontFamily].join(' ');
20398
- return ctx$3.measureText(isString$4(text) ? text : '').width;
20399
- }, function (text, font) {
20400
- if (font === void 0) { font = {}; }
20401
- return __spreadArrays([text], values$3(font)).join('');
20402
- });
20403
-
20404
19849
  var WebGPUContextService = /*#__PURE__*/function () {
20405
19850
  function WebGPUContextService(canvasConfig, deviceRendererPlugin) {
20406
19851
  this.canvasConfig = void 0;
@@ -20416,13 +19861,13 @@
20416
19861
 
20417
19862
  _proto.init = /*#__PURE__*/function () {
20418
19863
  var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
20419
- var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
19864
+ var _this$canvasConfig, container, canvas, $canvas;
20420
19865
 
20421
19866
  return _regeneratorRuntime().wrap(function _callee$(_context) {
20422
19867
  while (1) {
20423
19868
  switch (_context.prev = _context.next) {
20424
19869
  case 0:
20425
- _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;
20426
19871
 
20427
19872
  if (canvas) {
20428
19873
  this.$canvas = canvas;
@@ -20435,7 +19880,7 @@
20435
19880
  this.canvasConfig.container = this.$container;
20436
19881
  } else if (container) {
20437
19882
  // create container
20438
- this.$container = isString$4(container) ? document.getElementById(container) : container;
19883
+ this.$container = isString(container) ? document.getElementById(container) : container;
20439
19884
 
20440
19885
  if (this.$container) {
20441
19886
  // create canvas
@@ -20448,14 +19893,11 @@
20448
19893
 
20449
19894
  this.$canvas = $canvas;
20450
19895
  }
20451
- } // use user-defined dpr first
20452
-
19896
+ }
20453
19897
 
20454
- dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
20455
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
20456
- this.dpr = dpr;
19898
+ this.resize(this.canvasConfig.width, this.canvasConfig.height);
20457
19899
 
20458
- case 5:
19900
+ case 3:
20459
19901
  case "end":
20460
19902
  return _context.stop();
20461
19903
  }
@@ -20494,11 +19936,18 @@
20494
19936
  };
20495
19937
 
20496
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
+
20497
19945
  if (this.$canvas) {
20498
- var dpr = this.getDPR(); // set canvas width & height
19946
+ var _dpr = this.getDPR(); // set canvas width & height
19947
+
20499
19948
 
20500
- this.$canvas.width = dpr * width;
20501
- 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
20502
19951
 
20503
19952
  gLite.setDOMSize(this.$canvas, width, height);
20504
19953
  }