浏览代码

Make glyphPosition a member.

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

20
Runtime/ui/txt/paragraph.cs


float _alphabeticBaseline;
float _ideographicBaseline;
float[] _lineHeights;
GlyphPosition[] glyphPositions;
int _lineCount;
List<PaintRecord> _paintRecords = new List<PaintRecord>();
List<CodeUnitRun> _codeUnitRuns = new List<CodeUnitRun>();

// All text blobs share a single position buffer, which is big enough taking ellipsis into consideration
builder.allocPos(ellipsizedLength);
// this._glyphLines and this._codeUnitRuns will refer to this array for glyph positions
GlyphPosition[] glyphPositions = new GlyphPosition[ellipsizedLength];
if (this.glyphPositions == null || this.glyphPositions.Length < ellipsizedLength) {
this.glyphPositions = new GlyphPosition[ellipsizedLength];
}
// Pointer to the glyphPositions array, to keep track of where the next glyph is stored
int pGlyphPositions = 0;

float glyphXOffset = _positionsBuffer[glyphIndex] + justifyXOffset;
float glyphAdvance = _advancesBuffer[glyphIndex];
builder.setPosition(glyphIndex, glyphXOffset);
glyphPositions[pGlyphPositions++] = new GlyphPosition(runXOffset + glyphXOffset,
this.glyphPositions[pGlyphPositions++] = new GlyphPosition(runXOffset + glyphXOffset,
glyphAdvance, new Range<int>(textStart + glyphIndex, textStart + glyphIndex + 1));
if (wordIndex < wordCount) {
Range<int> word = _wordsBuffer[wordIndex];

// width of this word, and update the entire word
if (!float.IsNaN(wordStartPosition)) {
maxWordWidth = Mathf.Max(maxWordWidth,
glyphPositions[pGlyphPositions - 1].xPos.end - wordStartPosition);
this.glyphPositions[pGlyphPositions - 1].xPos.end - wordStartPosition);
wordStartPosition = float.NaN;
}
}

// Create code unit run
this._codeUnitRuns.Add(new CodeUnitRun(
glyphPositions,
this.glyphPositions,
new Range<float>(glyphPositions[0].xPos.start, glyphPositions.last().xPos.end),
new Range<float>(this.glyphPositions[0].xPos.start, this.glyphPositions.last().xPos.end),
lineNumber, TextDirection.ltr, glyphPositionStyleRunStart, textCount));
lineStyleRunIndex++;

preMaxDescent = maxDescent;
float lineXOffset = this.getLineXOffset(runXOffset);
int count = pGlyphPositions - glyphPositionLineStart;
if (lineXOffset != 0 && glyphPositions != null) {
if (lineXOffset != 0 && this.glyphPositions != null) {
glyphPositions[glyphPositions.Length - i - 1].shiftSelf(lineXOffset);
this.glyphPositions[this.glyphPositions.Length - i - 1].shiftSelf(lineXOffset);
}
}

: this._text.Length;
this._glyphLines[lineNumber] =
new GlyphLine(glyphPositions, glyphPositionLineStart, count, nextLineStart - lineStart);
new GlyphLine(this.glyphPositions, glyphPositionLineStart, count, nextLineStart - lineStart);
for (int i = 0; i < lineStyleRunCount; i++) {
var paintRecord = this._paintRecords[this._paintRecords.Count - 1 - i];
paintRecord.shift(lineXOffset, yOffset);

正在加载...
取消
保存