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

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/main.js CHANGED
@@ -1947,13 +1947,15 @@ var Logger = {
1947
1947
  ];
1948
1948
  })();
1949
1949
  (function() {
1950
- /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
1950
+ // _heightMultiplier used to measure the height of text, but in miniprogram performance is different from h5.
1951
+ // so can set _heightMultiplier to adapt miniprogram, the larger the value, the worse the performance.
1952
+ /** @internal */ TextUtils._heightMultiplier = 2;
1951
1953
  })();
1952
1954
  (function() {
1953
- TextUtils._measureBaseline = "M";
1955
+ /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
1954
1956
  })();
1955
1957
  (function() {
1956
- TextUtils._heightMultiplier = 2;
1958
+ TextUtils._measureBaseline = "M";
1957
1959
  })();
1958
1960
  (function() {
1959
1961
  TextUtils._baselineMultiplier = 1.4;
@@ -2037,7 +2039,7 @@ var Logger = {
2037
2039
  var _this = this, engine = _this._engine;
2038
2040
  var fontAtlas = new FontAtlas(engine);
2039
2041
  var texture = new Texture2D(engine, 256, 256, exports.TextureFormat.R8G8B8A8, false);
2040
- texture.filterMode = exports.TextureFilterMode.Point;
2042
+ texture.filterMode = exports.TextureFilterMode.Bilinear;
2041
2043
  fontAtlas.texture = texture;
2042
2044
  fontAtlas.isGCIgnored = texture.isGCIgnored = true;
2043
2045
  this._fontAtlases.push(fontAtlas);
@@ -12609,6 +12611,8 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
12609
12611
  }
12610
12612
  mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
12611
12613
  batchedQueue[curMeshIndex] = preElement;
12614
+ // Set data option use Discard, or will resulted in performance slowdown when open antialias and cross-rendering of 3D and 2D elements.
12615
+ // Device: iphone X(16.7.2)、iphone 15 pro max(17.1.1)、iphone XR(17.1.2) etc.
12612
12616
  this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, exports.SetDataOptions.Discard);
12613
12617
  this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, exports.SetDataOptions.Discard);
12614
12618
  };
@@ -18539,7 +18543,7 @@ var /**
18539
18543
  /**
18540
18544
  * @internal
18541
18545
  */ _proto._render = function _render(context) {
18542
- if (this._text === "" || this.enableWrapping && this.width <= 0 || this.overflowMode === exports.OverflowMode.Truncate && this.height <= 0) {
18546
+ if (this._isTextNoVisible()) {
18543
18547
  return;
18544
18548
  }
18545
18549
  if (this._isContainDirtyFlag(0x10)) {
@@ -18631,8 +18635,8 @@ var /**
18631
18635
  }
18632
18636
  };
18633
18637
  _proto._updateLocalData = function _updateLocalData() {
18634
- var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
18635
18638
  var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
18639
+ var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
18636
18640
  var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
18637
18641
  var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
18638
18642
  var charRenderDataPool = TextRenderer._charRenderDataPool;
@@ -18700,7 +18704,7 @@ var /**
18700
18704
  var left = startX * pixelsPerUnitReciprocal;
18701
18705
  var right = (startX + w) * pixelsPerUnitReciprocal;
18702
18706
  var top = (startY + ascent) * pixelsPerUnitReciprocal;
18703
- var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
18707
+ var bottom = (startY - descent) * pixelsPerUnitReciprocal;
18704
18708
  localPositions.set(left, top, right, bottom);
18705
18709
  i === firstLine && (maxY = Math.max(maxY, top));
18706
18710
  minY = Math.min(minY, bottom);
@@ -18741,6 +18745,9 @@ var /**
18741
18745
  Renderer1.prototype._onTransformChanged.call(this, bit);
18742
18746
  this._setDirtyFlagTrue(0x4 | 0x8);
18743
18747
  };
18748
+ _proto._isTextNoVisible = function _isTextNoVisible() {
18749
+ return this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || this.overflowMode === exports.OverflowMode.Truncate && this.height <= 0;
18750
+ };
18744
18751
  _create_class(TextRenderer, [
18745
18752
  {
18746
18753
  key: "color",
@@ -18943,6 +18950,16 @@ var /**
18943
18950
  get: /**
18944
18951
  * The bounding volume of the TextRenderer.
18945
18952
  */ function get() {
18953
+ if (this._isTextNoVisible()) {
18954
+ if (this._isContainDirtyFlag(0x8)) {
18955
+ var localBounds = this._localBounds;
18956
+ localBounds.min.set(0, 0, 0);
18957
+ localBounds.max.set(0, 0, 0);
18958
+ this._updateBounds(this._bounds);
18959
+ this._setDirtyFlagFalse(0x8);
18960
+ }
18961
+ return this._bounds;
18962
+ }
18946
18963
  this._isContainDirtyFlag(0x1) && this._resetSubFont();
18947
18964
  this._isContainDirtyFlag(0x2) && this._updateLocalData();
18948
18965
  this._isContainDirtyFlag(0x4) && this._updatePosition();
@@ -21858,38 +21875,45 @@ var passNum = 0;
21858
21875
  var v0 = a[from];
21859
21876
  var v1 = a[to - 1];
21860
21877
  var v2 = a[third_index];
21878
+ var swapFlag = false;
21861
21879
  var c01 = compareFunc(v0, v1);
21862
21880
  if (c01 > 0) {
21863
21881
  // v1 < v0, so swap them.
21864
21882
  var tmp = v0;
21865
21883
  v0 = v1;
21866
21884
  v1 = tmp;
21885
+ swapFlag = true;
21867
21886
  } // v0 <= v1.
21868
21887
  var c02 = compareFunc(v0, v2);
21869
- if (c02 >= 0) {
21870
- // v2 <= v0 <= v1.
21888
+ if (c02 > 0) {
21889
+ // v2 < v0.
21871
21890
  var tmp1 = v0;
21872
21891
  v0 = v2;
21873
21892
  v2 = v1;
21874
21893
  v1 = tmp1;
21894
+ swapFlag = true;
21875
21895
  } else {
21876
- // v0 <= v1 && v0 < v2
21896
+ // v2 >= v0
21877
21897
  var c12 = compareFunc(v1, v2);
21878
21898
  if (c12 > 0) {
21879
21899
  // v0 <= v2 < v1
21880
21900
  var tmp2 = v1;
21881
21901
  v1 = v2;
21882
21902
  v2 = tmp2;
21903
+ swapFlag = true;
21883
21904
  }
21884
21905
  }
21885
21906
  // v0 <= v1 <= v2
21886
- a[from] = v0;
21887
- a[to - 1] = v2;
21888
- var pivot = v1;
21889
21907
  var low_end = from + 1; // Upper bound of elements lower than pivot.
21890
21908
  var high_start = to - 1; // Lower bound of elements greater than pivot.
21891
- a[third_index] = a[low_end];
21892
- a[low_end] = pivot;
21909
+ var pivot = v2;
21910
+ if (swapFlag) {
21911
+ a[from] = v0;
21912
+ a[to - 1] = v2;
21913
+ pivot = v1;
21914
+ a[third_index] = a[low_end];
21915
+ a[low_end] = pivot;
21916
+ }
21893
21917
  // From low_end to i are elements equal to pivot.
21894
21918
  // From i to high_start are elements that haven't been compared yet.
21895
21919
  partition: for(var i = low_end + 1; i < high_start; i++){
@@ -21944,12 +21968,38 @@ var passNum = 0;
21944
21968
  /**
21945
21969
  * @internal
21946
21970
  */ RenderQueue._compareFromNearToFar = function _compareFromNearToFar(a, b) {
21947
- 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;
21971
+ var dataA = a.data;
21972
+ var dataB = b.data;
21973
+ var componentA = dataA.component;
21974
+ var componentB = dataB.component;
21975
+ var priorityOrder = componentA.priority - componentB.priority;
21976
+ if (priorityOrder !== 0) {
21977
+ return priorityOrder;
21978
+ }
21979
+ // make suer from the same renderer.
21980
+ if (componentA.instanceId === componentB.instanceId) {
21981
+ return dataA.material._priority - dataB.material._priority || componentA._distanceForSort - componentB._distanceForSort;
21982
+ } else {
21983
+ return componentA._distanceForSort - componentB._distanceForSort;
21984
+ }
21948
21985
  };
21949
21986
  /**
21950
21987
  * @internal
21951
21988
  */ RenderQueue._compareFromFarToNear = function _compareFromFarToNear(a, b) {
21952
- 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;
21989
+ var dataA = a.data;
21990
+ var dataB = b.data;
21991
+ var componentA = dataA.component;
21992
+ var componentB = dataB.component;
21993
+ var priorityOrder = componentA.priority - componentB.priority;
21994
+ if (priorityOrder !== 0) {
21995
+ return priorityOrder;
21996
+ }
21997
+ // make suer from the same renderer.
21998
+ if (componentA.instanceId === componentB.instanceId) {
21999
+ return dataA.material._priority - dataB.material._priority || componentB._distanceForSort - componentA._distanceForSort;
22000
+ } else {
22001
+ return componentB._distanceForSort - componentA._distanceForSort;
22002
+ }
21953
22003
  };
21954
22004
  return RenderQueue;
21955
22005
  }();