@@ -190,15 +190,16 @@ public LineRange(int start, int end, int endExcludingWhitespace, int endIncludin
190
190
List < float > _lineWidths = new List < float > ( ) ;
191
191
// float[] _lineBaseLines;
192
192
GlyphLine [ ] _glyphLines ;
193
+ GlyphPosition [ ] glyphPositions ;
194
+ PaintRecord [ ] _paintRecords ;
195
+ CodeUnitRun [ ] _codeUnitRuns ;
196
+ float [ ] _lineHeights ;
197
+ float [ ] _textBlobPositions ;
193
198
float _maxIntrinsicWidth ;
194
199
float _minIntrinsicWidth ;
195
200
float _alphabeticBaseline ;
196
201
float _ideographicBaseline ;
197
- float [ ] _lineHeights ;
198
- GlyphPosition [ ] glyphPositions ;
199
202
int _lineCount ;
200
- PaintRecord [ ] _paintRecords ;
201
- CodeUnitRun [ ] _codeUnitRuns ;
202
203
int _paintRecordsCount ;
203
204
int _codeUnitRunsCount ;
204
205
bool _didExceedMaxLines ;
@@ -320,7 +321,10 @@ public void layout(ParagraphConstraints constraints) {
320
321
int ellipsizedLength = this . _text . Length + ( this . _paragraphStyle . ellipsis ? . Length ?? 0 ) ;
321
322
322
323
// All text blobs share a single position buffer, which is big enough taking ellipsis into consideration
323
- builder . allocPos ( ellipsizedLength ) ;
324
+ if ( this . _textBlobPositions == null || this . _textBlobPositions . Length < ellipsizedLength ) {
325
+ this . _textBlobPositions = new float [ ellipsizedLength ] ;
326
+ }
327
+ builder . setPositions ( this . _textBlobPositions ) ;
324
328
// this._glyphLines and this._codeUnitRuns will refer to this array for glyph positions
325
329
if ( this . glyphPositions == null || this . glyphPositions . Length < ellipsizedLength ) {
326
330
this . glyphPositions = new GlyphPosition [ ellipsizedLength ] ;
@@ -480,12 +484,11 @@ public void layout(ParagraphConstraints constraints) {
480
484
runXOffset += advance ;
481
485
482
486
// Create code unit run
483
- CodeUnitRun codeUnitRun = new CodeUnitRun (
487
+ this . _codeUnitRuns [ this . _codeUnitRunsCount ++ ] = new CodeUnitRun (
484
488
this . glyphPositions ,
485
489
new Range < int > ( start , end ) ,
486
490
new Range < float > ( this . glyphPositions [ 0 ] . xPos . start , this . glyphPositions . last ( ) . xPos . end ) ,
487
491
lineNumber , TextDirection . ltr , glyphPositionStyleRunStart , textCount ) ;
488
- this . _codeUnitRuns [ this . _codeUnitRunsCount ++ ] = codeUnitRun ;
489
492
490
493
lineStyleRunIndex ++ ;
491
494
}
0 commit comments