@galacean/engine-core 0.0.0-experimental-uploadSameBuffer.0 → 0.0.0-experimental-renderSort.2

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.
@@ -1948,13 +1948,15 @@ var Logger = {
1948
1948
  ];
1949
1949
  })();
1950
1950
  (function() {
1951
- /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
1951
+ // _heightMultiplier used to measure the height of text, but in miniprogram performance is different from h5.
1952
+ // so can set _heightMultiplier to adapt miniprogram, the larger the value, the worse the performance.
1953
+ /** @internal */ TextUtils._heightMultiplier = 2;
1952
1954
  })();
1953
1955
  (function() {
1954
- TextUtils._measureBaseline = "M";
1956
+ /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
1955
1957
  })();
1956
1958
  (function() {
1957
- TextUtils._heightMultiplier = 2;
1959
+ TextUtils._measureBaseline = "M";
1958
1960
  })();
1959
1961
  (function() {
1960
1962
  TextUtils._baselineMultiplier = 1.4;
@@ -2038,7 +2040,7 @@ var Logger = {
2038
2040
  var _this = this, engine = _this._engine;
2039
2041
  var fontAtlas = new FontAtlas(engine);
2040
2042
  var texture = new Texture2D(engine, 256, 256, exports.TextureFormat.R8G8B8A8, false);
2041
- texture.filterMode = exports.TextureFilterMode.Point;
2043
+ texture.filterMode = exports.TextureFilterMode.Bilinear;
2042
2044
  fontAtlas.texture = texture;
2043
2045
  fontAtlas.isGCIgnored = texture.isGCIgnored = true;
2044
2046
  this._fontAtlases.push(fontAtlas);
@@ -12610,6 +12612,8 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
12610
12612
  }
12611
12613
  mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
12612
12614
  batchedQueue[curMeshIndex] = preElement;
12615
+ // Set data option use Discard, or will resulted in performance slowdown when open antialias and cross-rendering of 3D and 2D elements.
12616
+ // Device: iphone X(16.7.2)、iphone 15 pro max(17.1.1)、iphone XR(17.1.2) etc.
12613
12617
  this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, exports.SetDataOptions.Discard);
12614
12618
  this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, exports.SetDataOptions.Discard);
12615
12619
  };
@@ -18540,7 +18544,7 @@ var /**
18540
18544
  /**
18541
18545
  * @internal
18542
18546
  */ _proto._render = function _render(context) {
18543
- if (this._text === "" || this.enableWrapping && this.width <= 0 || this.overflowMode === exports.OverflowMode.Truncate && this.height <= 0) {
18547
+ if (this._isTextNoVisible()) {
18544
18548
  return;
18545
18549
  }
18546
18550
  if (this._isContainDirtyFlag(0x10)) {
@@ -18632,8 +18636,8 @@ var /**
18632
18636
  }
18633
18637
  };
18634
18638
  _proto._updateLocalData = function _updateLocalData() {
18635
- var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
18636
18639
  var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
18640
+ var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
18637
18641
  var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
18638
18642
  var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
18639
18643
  var charRenderDataPool = TextRenderer._charRenderDataPool;
@@ -18701,7 +18705,7 @@ var /**
18701
18705
  var left = startX * pixelsPerUnitReciprocal;
18702
18706
  var right = (startX + w) * pixelsPerUnitReciprocal;
18703
18707
  var top = (startY + ascent) * pixelsPerUnitReciprocal;
18704
- var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
18708
+ var bottom = (startY - descent) * pixelsPerUnitReciprocal;
18705
18709
  localPositions.set(left, top, right, bottom);
18706
18710
  i === firstLine && (maxY = Math.max(maxY, top));
18707
18711
  minY = Math.min(minY, bottom);
@@ -18742,6 +18746,9 @@ var /**
18742
18746
  Renderer1.prototype._onTransformChanged.call(this, bit);
18743
18747
  this._setDirtyFlagTrue(0x4 | 0x8);
18744
18748
  };
18749
+ _proto._isTextNoVisible = function _isTextNoVisible() {
18750
+ return this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || this.overflowMode === exports.OverflowMode.Truncate && this.height <= 0;
18751
+ };
18745
18752
  _create_class(TextRenderer, [
18746
18753
  {
18747
18754
  key: "color",
@@ -18944,6 +18951,16 @@ var /**
18944
18951
  get: /**
18945
18952
  * The bounding volume of the TextRenderer.
18946
18953
  */ function get() {
18954
+ if (this._isTextNoVisible()) {
18955
+ if (this._isContainDirtyFlag(0x8)) {
18956
+ var localBounds = this._localBounds;
18957
+ localBounds.min.set(0, 0, 0);
18958
+ localBounds.max.set(0, 0, 0);
18959
+ this._updateBounds(this._bounds);
18960
+ this._setDirtyFlagFalse(0x8);
18961
+ }
18962
+ return this._bounds;
18963
+ }
18947
18964
  this._isContainDirtyFlag(0x1) && this._resetSubFont();
18948
18965
  this._isContainDirtyFlag(0x2) && this._updateLocalData();
18949
18966
  this._isContainDirtyFlag(0x4) && this._updatePosition();
@@ -21850,7 +21867,7 @@ var passNum = 0;
21850
21867
  */ _proto._quickSort = function _quickSort(a, from, to, compareFunc) {
21851
21868
  while(true){
21852
21869
  // Insertion sort is faster for short arrays.
21853
- if (to - from <= 10) {
21870
+ if (to - from <= 10000000) {
21854
21871
  this._insertionSort(a, from, to, compareFunc);
21855
21872
  return;
21856
21873
  }
@@ -21945,12 +21962,38 @@ var passNum = 0;
21945
21962
  /**
21946
21963
  * @internal
21947
21964
  */ RenderQueue._compareFromNearToFar = function _compareFromNearToFar(a, b) {
21948
- return a.data.component.priority - b.data.component.priority || a.data.material._priority - b.data.material._priority || a.data.component._distanceForSort - b.data.component._distanceForSort;
21965
+ var dataA = a.data;
21966
+ var dataB = b.data;
21967
+ var componentA = dataA.component;
21968
+ var componentB = dataB.component;
21969
+ var priorityOrder = componentA.priority - componentB.priority;
21970
+ if (priorityOrder !== 0) {
21971
+ return priorityOrder;
21972
+ }
21973
+ // make suer from the same renderer.
21974
+ if (componentA.instanceId === componentB.instanceId) {
21975
+ return dataA.material._priority - dataB.material._priority || componentA._distanceForSort - componentB._distanceForSort;
21976
+ } else {
21977
+ return componentA._distanceForSort - componentB._distanceForSort;
21978
+ }
21949
21979
  };
21950
21980
  /**
21951
21981
  * @internal
21952
21982
  */ RenderQueue._compareFromFarToNear = function _compareFromFarToNear(a, b) {
21953
- return a.data.component.priority - b.data.component.priority || a.data.material._priority - b.data.material._priority || b.data.component._distanceForSort - a.data.component._distanceForSort;
21983
+ var dataA = a.data;
21984
+ var dataB = b.data;
21985
+ var componentA = dataA.component;
21986
+ var componentB = dataB.component;
21987
+ var priorityOrder = componentA.priority - componentB.priority;
21988
+ if (priorityOrder !== 0) {
21989
+ return priorityOrder;
21990
+ }
21991
+ // make suer from the same renderer.
21992
+ if (componentA.instanceId === componentB.instanceId) {
21993
+ return dataA.material._priority - dataB.material._priority || componentB._distanceForSort - componentA._distanceForSort;
21994
+ } else {
21995
+ return componentB._distanceForSort - componentA._distanceForSort;
21996
+ }
21954
21997
  };
21955
21998
  return RenderQueue;
21956
21999
  }();
package/dist/module.js CHANGED
@@ -1943,13 +1943,15 @@ var Logger = {
1943
1943
  ];
1944
1944
  })();
1945
1945
  (function() {
1946
- /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
1946
+ // _heightMultiplier used to measure the height of text, but in miniprogram performance is different from h5.
1947
+ // so can set _heightMultiplier to adapt miniprogram, the larger the value, the worse the performance.
1948
+ /** @internal */ TextUtils._heightMultiplier = 2;
1947
1949
  })();
1948
1950
  (function() {
1949
- TextUtils._measureBaseline = "M";
1951
+ /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
1950
1952
  })();
1951
1953
  (function() {
1952
- TextUtils._heightMultiplier = 2;
1954
+ TextUtils._measureBaseline = "M";
1953
1955
  })();
1954
1956
  (function() {
1955
1957
  TextUtils._baselineMultiplier = 1.4;
@@ -2033,7 +2035,7 @@ var Logger = {
2033
2035
  var _this = this, engine = _this._engine;
2034
2036
  var fontAtlas = new FontAtlas(engine);
2035
2037
  var texture = new Texture2D(engine, 256, 256, TextureFormat.R8G8B8A8, false);
2036
- texture.filterMode = TextureFilterMode.Point;
2038
+ texture.filterMode = TextureFilterMode.Bilinear;
2037
2039
  fontAtlas.texture = texture;
2038
2040
  fontAtlas.isGCIgnored = texture.isGCIgnored = true;
2039
2041
  this._fontAtlases.push(fontAtlas);
@@ -12605,6 +12607,8 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
12605
12607
  }
12606
12608
  mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
12607
12609
  batchedQueue[curMeshIndex] = preElement;
12610
+ // Set data option use Discard, or will resulted in performance slowdown when open antialias and cross-rendering of 3D and 2D elements.
12611
+ // Device: iphone X(16.7.2)、iphone 15 pro max(17.1.1)、iphone XR(17.1.2) etc.
12608
12612
  this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, SetDataOptions.Discard);
12609
12613
  this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, SetDataOptions.Discard);
12610
12614
  };
@@ -18535,7 +18539,7 @@ var /**
18535
18539
  /**
18536
18540
  * @internal
18537
18541
  */ _proto._render = function _render(context) {
18538
- if (this._text === "" || this.enableWrapping && this.width <= 0 || this.overflowMode === OverflowMode.Truncate && this.height <= 0) {
18542
+ if (this._isTextNoVisible()) {
18539
18543
  return;
18540
18544
  }
18541
18545
  if (this._isContainDirtyFlag(0x10)) {
@@ -18627,8 +18631,8 @@ var /**
18627
18631
  }
18628
18632
  };
18629
18633
  _proto._updateLocalData = function _updateLocalData() {
18630
- var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
18631
18634
  var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
18635
+ var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
18632
18636
  var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
18633
18637
  var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
18634
18638
  var charRenderDataPool = TextRenderer._charRenderDataPool;
@@ -18696,7 +18700,7 @@ var /**
18696
18700
  var left = startX * pixelsPerUnitReciprocal;
18697
18701
  var right = (startX + w) * pixelsPerUnitReciprocal;
18698
18702
  var top = (startY + ascent) * pixelsPerUnitReciprocal;
18699
- var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
18703
+ var bottom = (startY - descent) * pixelsPerUnitReciprocal;
18700
18704
  localPositions.set(left, top, right, bottom);
18701
18705
  i === firstLine && (maxY = Math.max(maxY, top));
18702
18706
  minY = Math.min(minY, bottom);
@@ -18737,6 +18741,9 @@ var /**
18737
18741
  Renderer1.prototype._onTransformChanged.call(this, bit);
18738
18742
  this._setDirtyFlagTrue(0x4 | 0x8);
18739
18743
  };
18744
+ _proto._isTextNoVisible = function _isTextNoVisible() {
18745
+ return this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || this.overflowMode === OverflowMode.Truncate && this.height <= 0;
18746
+ };
18740
18747
  _create_class(TextRenderer, [
18741
18748
  {
18742
18749
  key: "color",
@@ -18939,6 +18946,16 @@ var /**
18939
18946
  get: /**
18940
18947
  * The bounding volume of the TextRenderer.
18941
18948
  */ function get() {
18949
+ if (this._isTextNoVisible()) {
18950
+ if (this._isContainDirtyFlag(0x8)) {
18951
+ var localBounds = this._localBounds;
18952
+ localBounds.min.set(0, 0, 0);
18953
+ localBounds.max.set(0, 0, 0);
18954
+ this._updateBounds(this._bounds);
18955
+ this._setDirtyFlagFalse(0x8);
18956
+ }
18957
+ return this._bounds;
18958
+ }
18942
18959
  this._isContainDirtyFlag(0x1) && this._resetSubFont();
18943
18960
  this._isContainDirtyFlag(0x2) && this._updateLocalData();
18944
18961
  this._isContainDirtyFlag(0x4) && this._updatePosition();
@@ -21845,7 +21862,7 @@ var passNum = 0;
21845
21862
  */ _proto._quickSort = function _quickSort(a, from, to, compareFunc) {
21846
21863
  while(true){
21847
21864
  // Insertion sort is faster for short arrays.
21848
- if (to - from <= 10) {
21865
+ if (to - from <= 10000000) {
21849
21866
  this._insertionSort(a, from, to, compareFunc);
21850
21867
  return;
21851
21868
  }
@@ -21940,12 +21957,38 @@ var passNum = 0;
21940
21957
  /**
21941
21958
  * @internal
21942
21959
  */ RenderQueue._compareFromNearToFar = function _compareFromNearToFar(a, b) {
21943
- return a.data.component.priority - b.data.component.priority || a.data.material._priority - b.data.material._priority || a.data.component._distanceForSort - b.data.component._distanceForSort;
21960
+ var dataA = a.data;
21961
+ var dataB = b.data;
21962
+ var componentA = dataA.component;
21963
+ var componentB = dataB.component;
21964
+ var priorityOrder = componentA.priority - componentB.priority;
21965
+ if (priorityOrder !== 0) {
21966
+ return priorityOrder;
21967
+ }
21968
+ // make suer from the same renderer.
21969
+ if (componentA.instanceId === componentB.instanceId) {
21970
+ return dataA.material._priority - dataB.material._priority || componentA._distanceForSort - componentB._distanceForSort;
21971
+ } else {
21972
+ return componentA._distanceForSort - componentB._distanceForSort;
21973
+ }
21944
21974
  };
21945
21975
  /**
21946
21976
  * @internal
21947
21977
  */ RenderQueue._compareFromFarToNear = function _compareFromFarToNear(a, b) {
21948
- return a.data.component.priority - b.data.component.priority || a.data.material._priority - b.data.material._priority || b.data.component._distanceForSort - a.data.component._distanceForSort;
21978
+ var dataA = a.data;
21979
+ var dataB = b.data;
21980
+ var componentA = dataA.component;
21981
+ var componentB = dataB.component;
21982
+ var priorityOrder = componentA.priority - componentB.priority;
21983
+ if (priorityOrder !== 0) {
21984
+ return priorityOrder;
21985
+ }
21986
+ // make suer from the same renderer.
21987
+ if (componentA.instanceId === componentB.instanceId) {
21988
+ return dataA.material._priority - dataB.material._priority || componentB._distanceForSort - componentA._distanceForSort;
21989
+ } else {
21990
+ return componentB._distanceForSort - componentA._distanceForSort;
21991
+ }
21949
21992
  };
21950
21993
  return RenderQueue;
21951
21994
  }();