浏览代码

Remove paintRecords array, and add to this._paintRecords directly.

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

30
Runtime/ui/txt/paragraph.cs


GlyphPosition[] lineGlyphPositions = mayConsiderEllipsis
? new GlyphPosition[totalTextCount + ellipsisLength]
: totalTextCount > 0 ? new GlyphPosition[totalTextCount] : null;
PaintRecord[] paintRecords = lineStyleRunCount == 0 ? null : new PaintRecord[lineStyleRunCount];
if (paintRecords != null) {
if (lineStyleRunCount != 0) {
int pLineGlyphPositions = 0;
int tLineLimit = lineLimit;
float tMaxWordWidth = maxWordWidth;

// Make sure that each line is not empty
if (start < end) {
var isLastLineStyleRun = lineStyleRunIndex == lineStyleRunCount - 1;
paintRecords[lineStyleRunIndex++] = this._generatePaintRecordFromLineStyleRun(
this._paintRecords.Add(this._generatePaintRecordFromLineStyleRun(
new LineStyleRun(start, end, styleRun.style),
layout,
builder,

ref tMaxWordWidth,
words,
lineGlyphPositions,
ref pLineGlyphPositions);
ref pLineGlyphPositions));
}
}

maxWordWidth = tMaxWordWidth;
}
this._computeLineOffset(lineNumber, paintRecords, ref yOffset, ref preMaxDescent);
this._computeLineOffset(lineNumber, lineStyleRunCount, ref yOffset, ref preMaxDescent);
this._addPaintRecordsWithOffset(paintRecords, lineXOffset, yOffset);
this._shiftPaintRecords(lineStyleRunCount, lineXOffset, yOffset);
}
int _countLineStyleRuns(LineRange lineRange, int styleRunIndex, out int totalTextCount, out int maxTextCount) {

this._glyphLines.Add(new GlyphLine(lineGlyphPositions, nextLineStart - lineStart));
}
void _computeLineOffset(int lineNumber, PaintRecord[] paintRecords, ref float yOffset, ref float preMaxDescent) {
void _computeLineOffset(int lineNumber, int lineStyleRunCount, ref float yOffset, ref float preMaxDescent) {
float maxLineSpacing = 0;
float maxDescent = 0;

maxDescent = Mathf.Max(descent, maxDescent);
}
if (paintRecords != null) {
foreach (var paintRecord in paintRecords) {
if (lineStyleRunCount != 0) {
for (int i = 0; i < lineStyleRunCount; i++) {
var paintRecord = this._paintRecords[this._paintRecords.Count - i - 1];
updateLineMetrics(paintRecord.metrics, paintRecord.style.height);
}
} else {

preMaxDescent = maxDescent;
}
void _addPaintRecordsWithOffset(PaintRecord[] paintRecords, float lineXOffset, float yOffset) {
if (paintRecords != null) {
for (int i = 0; i < paintRecords.Length; i++) {
PaintRecord paintRecord = paintRecords[i];
paintRecord.shift(lineXOffset, yOffset);
this._paintRecords.Add(paintRecord);
}
void _shiftPaintRecords(int paintRecordsCount, float lineXOffset, float yOffset) {
for (int i = 0; i < paintRecordsCount; i++) {
var paintRecord = this._paintRecords[this._paintRecords.Count - 1 - i];
paintRecord.shift(lineXOffset, yOffset);
this._paintRecords[this._paintRecords.Count - 1 - i] = paintRecord;
}
}

正在加载...
取消
保存