|
|
|
|
|
|
internal TextBlob(string text, int textOffset, int textSize, Vector2d[] positions, Rect bounds, |
|
|
|
TextStyle style) { |
|
|
|
this.instanceId = ++_nextInstanceId; |
|
|
|
this.positions = positions; |
|
|
|
this._positions = positions; |
|
|
|
get { return this.bounds.translate(this.positions[0].x, this.positions[0].y); } |
|
|
|
get { return this.bounds.translate(this._positions[this.textOffset].x, this._positions[this.textOffset].y); } |
|
|
|
return this.bounds.translate(this.positions[0].x + offset.dx, this.positions[0].y + offset.dy); |
|
|
|
return this.bounds.translate(this._positions[this.textOffset].x + offset.dx, |
|
|
|
this._positions[this.textOffset].y + offset.dy); |
|
|
|
} |
|
|
|
|
|
|
|
public Vector2d getPosition(int i) { |
|
|
|
return this._positions[this.textOffset + i]; |
|
|
|
} |
|
|
|
|
|
|
|
static long _nextInstanceId; |
|
|
|
|
|
|
internal readonly int textSize; |
|
|
|
internal readonly Vector2d[] positions; |
|
|
|
readonly Vector2d[] _positions; |
|
|
|
} |
|
|
|
|
|
|
|
public class TextBlobBuilder { |
|
|
|
|
|
|
this._text = text; |
|
|
|
this._textOffset = offset; |
|
|
|
this._size = size; |
|
|
|
this.allocPos(size); |
|
|
|
// Allocate a single buffer for all text blobs that share this text, to save memory and GC.
|
|
|
|
// It is assumed that all of `text` is being used. This may cause great waste if a long text is passed
|
|
|
|
// but only a small part of it is to be rendered, which is not the case for now.
|
|
|
|
this.allocPos(text.Length); |
|
|
|
} |
|
|
|
|
|
|
|
internal void allocPos(int size) { |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void setPosition(int i, Vector2d position) { |
|
|
|
this.positions[this._textOffset + i] = position; |
|
|
|
} |
|
|
|
|
|
|
|
public void setBounds(Rect bounds) { |
|
|
|
this._bounds = bounds; |
|
|
|
} |
|
|
|
|
|
|
this._size, this.positions, this._bounds, this._style); |
|
|
|
this.positions = null; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |