Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 388fddc

Browse files
author
Yuncong Zhang
committed
Remove Glyphline._positions.
1 parent c911ac9 commit 388fddc

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

Runtime/ui/txt/paragraph.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,18 @@ struct GlyphLine {
140140
public readonly int count;
141141
public readonly int totalCountUnits;
142142

143-
readonly GlyphPosition[] _positions;
144-
145-
public GlyphLine(GlyphPosition[] positions, int start, int count, int totalCountUnits) {
146-
this._positions = positions;
143+
public GlyphLine(int start, int count, int totalCountUnits) {
147144
this.start = start;
148145
this.count = count;
149146
this.totalCountUnits = totalCountUnits;
150147
}
151148

152-
public GlyphPosition get(int i) {
153-
return this._positions[this.start + i];
149+
public GlyphPosition get(int i, GlyphPosition[] glyphPositions) {
150+
return glyphPositions[this.start + i];
154151
}
155152

156-
public GlyphPosition last() {
157-
return this._positions[this.start + this.count - 1];
153+
public GlyphPosition last(GlyphPosition[] glyphPositions) {
154+
return glyphPositions[this.start + this.count - 1];
158155
}
159156
}
160157

@@ -483,7 +480,8 @@ public void layout(ParagraphConstraints constraints) {
483480
// Create code unit run
484481
this._codeUnitRuns[this._codeUnitRunsCount++] = new CodeUnitRun(
485482
new Range<int>(start, end),
486-
new Range<float>(this._glyphPositions[0].xPos.start, this._glyphPositions.last().xPos.end),
483+
new Range<float>(this._glyphPositions[glyphPositionStyleRunStart].xPos.start,
484+
this._glyphPositions[pGlyphPositions-1].xPos.end),
487485
lineNumber, TextDirection.ltr, glyphPositionStyleRunStart, textCount);
488486

489487
lineStyleRunIndex++;
@@ -551,7 +549,7 @@ void updateLineMetrics(FontMetrics metrics, float styleHeight) {
551549
? this._lineRanges[lineNumber + 1].start
552550
: this._text.Length;
553551
this._glyphLines[lineNumber] =
554-
new GlyphLine(this._glyphPositions, glyphPositionLineStart, count, nextLineStart - lineStart);
552+
new GlyphLine(glyphPositionLineStart, count, nextLineStart - lineStart);
555553
for (int i = 0; i < lineStyleRunCount; i++) {
556554
var paintRecord = this._paintRecords[this._paintRecordsCount - 1 - i];
557555
paintRecord.shift(lineXOffset, yOffset);
@@ -731,17 +729,17 @@ internal PositionWithAffinity getGlyphPositionAtCoordinate(float dx, float dy) {
731729
bool gpSet = false;
732730
for (int xIndex = 0; xIndex < glyphLine.count; ++xIndex) {
733731
float glyphEnd = xIndex < glyphLine.count - 1
734-
? glyphLine.get(xIndex + 1).xPos.start
735-
: glyphLine.get(xIndex).xPos.end;
732+
? glyphLine.get(xIndex + 1, this._glyphPositions).xPos.start
733+
: glyphLine.get(xIndex, this._glyphPositions).xPos.end;
736734
if (dx < glyphEnd) {
737-
gp = glyphLine.get(xIndex);
735+
gp = glyphLine.get(xIndex, this._glyphPositions);
738736
gpSet = true;
739737
break;
740738
}
741739
}
742740

743741
if (!gpSet) {
744-
GlyphPosition lastGlyph = glyphLine.last();
742+
GlyphPosition lastGlyph = glyphLine.last(this._glyphPositions);
745743
return new PositionWithAffinity(lastGlyph.codeUnit + 1, TextAffinity.upstream);
746744
}
747745

0 commit comments

Comments
 (0)