浏览代码

Optimize getNextLineStartRect.

/main
Yuncong Zhang 5 年前
当前提交
947151ff
共有 2 个文件被更改,包括 5 次插入7 次删除
  1. 6
      Runtime/painting/text_painter.cs
  2. 6
      Runtime/ui/txt/paragraph.cs

6
Runtime/painting/text_painter.cs


var prevCodeUnit = this._text.codeUnitAt(offset);
if (prevCodeUnit == null) // out of upper bounds
{
var rectNextLine = this._paragraph.getNextLineStartRect();
if (rectNextLine != null) {
return new Offset(((TextBox) rectNextLine).start, ((TextBox) rectNextLine).top);
var rectNextLineTop = this._paragraph.getNextLineStartRectTop();
if (rectNextLineTop != null) {
return new Offset(0, (float) rectNextLineTop);
}
}
}

6
Runtime/ui/txt/paragraph.cs


return result;
}
public TextBox? getNextLineStartRect() {
public float? getNextLineStartRectTop() {
var top = (lineNumber > 0) ? this._lineHeights[lineNumber - 1] : 0;
var bottom = this._lineHeights[lineNumber];
return TextBox.fromLTBD(0, top, 0, bottom, TextDirection.ltr);
return lineNumber > 0 ? this._lineHeights[lineNumber - 1] : 0;
}
internal PositionWithAffinity getGlyphPositionAtCoordinate(float dx, float dy) {

正在加载...
取消
保存