浏览代码

Remove computeLineStyleRuns function and lineStyleRuns array.

/main
Yuncong Zhang 5 年前
当前提交
1c9b2971
共有 1 个文件被更改,包括 49 次插入49 次删除
  1. 98
      Runtime/ui/txt/paragraph.cs

98
Runtime/ui/txt/paragraph.cs


? 0
: (this._width - this._lineWidths[lineNumber]) / (words.Length - 1);
LineStyleRun[] lineStyleRuns = this._computeLineStyleRuns(lineRange, ref styleRunIndex, out int totalTextCount, out int maxTextCount);
int lineStyleRunCount = this._countLineStyleRuns(lineRange, styleRunIndex, out int totalTextCount, out int maxTextCount);
layout.allocAdvancesAndPositions(maxTextCount);

GlyphPosition[] lineGlyphPositions = mayConsiderEllipsis
? new GlyphPosition[totalTextCount + ellipsisLength]
: totalTextCount > 0 ? new GlyphPosition[totalTextCount] : null;
PaintRecord[] paintRecords = lineStyleRuns == null ? null : new PaintRecord[lineStyleRuns.Length];
if (lineStyleRuns != null) {
PaintRecord[] paintRecords = lineStyleRunCount == 0 ? null : new PaintRecord[lineStyleRunCount];
if (paintRecords != null) {
for (int i = 0; i < lineStyleRuns.Length; ++i) {
var run = lineStyleRuns[i];
var isLastLineStyleRun = i == lineStyleRuns.Length - 1;
paintRecords[i] = this._generatePaintRecordFromLineStyleRun(
run,
layout,
builder,
isLastLineStyleRun,
lineNumber,
justifyLine,
wordGapWidth,
ref lineLimit,
ref wordIndex,
ref runXOffset,
ref justifyXOffset,
ref maxWordWidth,
words,
lineGlyphPositions,
ref pLineGlyphPositions);
int tLineLimit = lineLimit;
float tMaxWordWidth = maxWordWidth;
// Exclude trailing whitespace from right-justified lines so the last
// visible character in the line will be flush with the right margin.
int lineEndIndex = this._paragraphStyle.textAlign == TextAlign.right ||
this._paragraphStyle.textAlign == TextAlign.center
? lineRange.endExcludingWhitespace
: lineRange.end;
int lineStyleRunIndex = 0;
while (styleRunIndex < this._runs.size) {
var styleRun = this._runs.getRun(styleRunIndex);
if (styleRun.start < lineEndIndex && styleRun.end > lineRange.start) {
int start = Mathf.Max(styleRun.start, lineRange.start);
int end = Mathf.Min(styleRun.end, lineEndIndex);
// Make sure that each line is not empty
if (start < end) {
var isLastLineStyleRun = lineStyleRunIndex == lineStyleRunCount - 1;
paintRecords[lineStyleRunIndex++] = this._generatePaintRecordFromLineStyleRun(
new LineStyleRun(start, end, styleRun.style),
layout,
builder,
isLastLineStyleRun,
lineNumber,
justifyLine,
wordGapWidth,
ref tLineLimit,
ref wordIndex,
ref runXOffset,
ref justifyXOffset,
ref tMaxWordWidth,
words,
lineGlyphPositions,
ref pLineGlyphPositions);
}
}
if (styleRun.end >= lineEndIndex) {
break;
}
styleRunIndex++;
lineLimit = tLineLimit;
maxWordWidth = tMaxWordWidth;
}
float lineXOffset = this.getLineXOffset(runXOffset);

}
LineStyleRun[] _computeLineStyleRuns(LineRange lineRange, ref int styleRunIndex, out int totalTextCount, out int maxTextCount) {
int _countLineStyleRuns(LineRange lineRange, int styleRunIndex, out int totalTextCount, out int maxTextCount) {
// Exclude trailing whitespace from right-justified lines so the last
// visible character in the line will be flush with the right margin.
int lineEndIndex = this._paragraphStyle.textAlign == TextAlign.right ||

// Make sure that each line is not empty
if (start < end) {
lineStyleRunCount++;
}
}
if (styleRun.end >= lineEndIndex) {
break;
}
}
if (lineStyleRunCount == 0) {
return null;
}
LineStyleRun[] lineStyleRuns = new LineStyleRun[lineStyleRunCount];
int pLineStyleRun = 0;
while (styleRunIndex < this._runs.size) {
var styleRun = this._runs.getRun(styleRunIndex);
if (styleRun.start < lineEndIndex && styleRun.end > lineRange.start) {
int start = Mathf.Max(styleRun.start, lineRange.start);
int end = Mathf.Min(styleRun.end, lineEndIndex);
// Make sure that each line is not empty
if (start < end) {
lineStyleRuns[pLineStyleRun++] = new LineStyleRun(start, end, styleRun.style);
}
}

styleRunIndex++;
return lineStyleRuns;
return lineStyleRunCount;
}
PaintRecord _generatePaintRecordFromLineStyleRun(

正在加载...
取消
保存