@antv/g-webgpu 1.7.32 → 1.7.33

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
@@ -14869,6 +14869,111 @@
14869
14869
  };
14870
14870
  return _setPrototypeOf$4(o, p);
14871
14871
  }
14872
+
14873
+ /**
14874
+ * Common utilities
14875
+ * @module glMatrix
14876
+ */
14877
+ var ARRAY_TYPE$1 = typeof Float32Array !== 'undefined' ? Float32Array : Array;
14878
+ if (!Math.hypot) Math.hypot = function () {
14879
+ var y = 0,
14880
+ i = arguments.length;
14881
+ while (i--) {
14882
+ y += arguments[i] * arguments[i];
14883
+ }
14884
+ return Math.sqrt(y);
14885
+ };
14886
+
14887
+ /**
14888
+ * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
14889
+ * @module mat4
14890
+ */
14891
+
14892
+ /**
14893
+ * Creates a new identity mat4
14894
+ *
14895
+ * @returns {mat4} a new 4x4 matrix
14896
+ */
14897
+
14898
+ function create$3() {
14899
+ var out = new ARRAY_TYPE$1(16);
14900
+ if (ARRAY_TYPE$1 != Float32Array) {
14901
+ out[1] = 0;
14902
+ out[2] = 0;
14903
+ out[3] = 0;
14904
+ out[4] = 0;
14905
+ out[6] = 0;
14906
+ out[7] = 0;
14907
+ out[8] = 0;
14908
+ out[9] = 0;
14909
+ out[11] = 0;
14910
+ out[12] = 0;
14911
+ out[13] = 0;
14912
+ out[14] = 0;
14913
+ }
14914
+ out[0] = 1;
14915
+ out[5] = 1;
14916
+ out[10] = 1;
14917
+ out[15] = 1;
14918
+ return out;
14919
+ }
14920
+ /**
14921
+ * Set a mat4 to the identity matrix
14922
+ *
14923
+ * @param {mat4} out the receiving matrix
14924
+ * @returns {mat4} out
14925
+ */
14926
+
14927
+ function identity$1(out) {
14928
+ out[0] = 1;
14929
+ out[1] = 0;
14930
+ out[2] = 0;
14931
+ out[3] = 0;
14932
+ out[4] = 0;
14933
+ out[5] = 1;
14934
+ out[6] = 0;
14935
+ out[7] = 0;
14936
+ out[8] = 0;
14937
+ out[9] = 0;
14938
+ out[10] = 1;
14939
+ out[11] = 0;
14940
+ out[12] = 0;
14941
+ out[13] = 0;
14942
+ out[14] = 0;
14943
+ out[15] = 1;
14944
+ return out;
14945
+ }
14946
+ /**
14947
+ * Scales the mat4 by the dimensions in the given vec3 not using vectorization
14948
+ *
14949
+ * @param {mat4} out the receiving matrix
14950
+ * @param {ReadonlyMat4} a the matrix to scale
14951
+ * @param {ReadonlyVec3} v the vec3 to scale the matrix by
14952
+ * @returns {mat4} out
14953
+ **/
14954
+
14955
+ function scale(out, a, v) {
14956
+ var x = v[0],
14957
+ y = v[1],
14958
+ z = v[2];
14959
+ out[0] = a[0] * x;
14960
+ out[1] = a[1] * x;
14961
+ out[2] = a[2] * x;
14962
+ out[3] = a[3] * x;
14963
+ out[4] = a[4] * y;
14964
+ out[5] = a[5] * y;
14965
+ out[6] = a[6] * y;
14966
+ out[7] = a[7] * y;
14967
+ out[8] = a[8] * z;
14968
+ out[9] = a[9] * z;
14969
+ out[10] = a[10] * z;
14970
+ out[11] = a[11] * z;
14971
+ out[12] = a[12];
14972
+ out[13] = a[13];
14973
+ out[14] = a[14];
14974
+ out[15] = a[15];
14975
+ return out;
14976
+ }
14872
14977
  var ImagePool = /*#__PURE__*/function () {
14873
14978
  function ImagePool(canvasConfig) {
14874
14979
  this.canvasConfig = void 0;
@@ -14919,7 +15024,7 @@
14919
15024
  }
14920
15025
  });
14921
15026
  };
14922
- _proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, callback) {
15027
+ _proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, $offscreenCanvas, dpr, callback) {
14923
15028
  var patternKey = this.generatePatternKey(pattern);
14924
15029
  if (patternKey && this.patternCache[patternKey]) {
14925
15030
  return this.patternCache[patternKey];
@@ -14928,17 +15033,29 @@
14928
15033
  repetition = pattern.repetition,
14929
15034
  transform = pattern.transform;
14930
15035
  var src;
15036
+ var needScaleWithDPR = false;
14931
15037
  // Image URL
14932
15038
  if (isString(image)) {
14933
15039
  src = this.getImageSync(image, callback);
15040
+ } else if ($offscreenCanvas) {
15041
+ src = $offscreenCanvas;
15042
+ needScaleWithDPR = true;
14934
15043
  } else {
14935
15044
  src = image;
14936
15045
  }
14937
15046
  // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
14938
15047
  var canvasPattern = src && context.createPattern(src, repetition);
14939
- // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern/setTransform
14940
- if (transform) {
14941
- var mat = gLite.parsedTransformToMat4(gLite.parseTransform(transform));
15048
+ if (canvasPattern) {
15049
+ var mat;
15050
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern/setTransform
15051
+ if (transform) {
15052
+ mat = gLite.parsedTransformToMat4(gLite.parseTransform(transform));
15053
+ } else {
15054
+ mat = identity$1(create$3());
15055
+ }
15056
+ if (needScaleWithDPR) {
15057
+ scale(mat, mat, [1 / dpr, 1 / dpr, 1]);
15058
+ }
14942
15059
  canvasPattern.setTransform({
14943
15060
  a: mat[0],
14944
15061
  b: mat[1],
@@ -15017,6 +15134,8 @@
15017
15134
  // only generate cache for Image
15018
15135
  if (isString(image)) {
15019
15136
  return "pattern-" + image + "-" + repetition;
15137
+ } else if (image instanceof gLite.Rect) {
15138
+ return "pattern-" + image.entity + "-" + repetition;
15020
15139
  }
15021
15140
  };
15022
15141
  return ImagePool;