浏览代码

Fix bug in Paragraph.setText.

/main
Yuncong Zhang 5 年前
当前提交
cb3d68a8
共有 3 个文件被更改,包括 28 次插入114 次删除
  1. 71
      Runtime/ui/painting/draw_cmd.cs
  2. 69
      Runtime/ui/renderer/common/draw_cmd.cs
  3. 2
      Runtime/ui/txt/paragraph.cs

71
Runtime/ui/painting/draw_cmd.cs


namespace Unity.UIWidgets.ui {
namespace Unity.UIWidgets.ui {
public abstract uiRect bounds(float margin);
}
public abstract class StateUpdateDrawCmd : DrawCmd {
public override uiRect bounds(float margin) {
return uiRectHelper.zero;
}
public class DrawSave : StateUpdateDrawCmd {
public class DrawSave : DrawCmd {
public class DrawSaveLayer : StateUpdateDrawCmd {
public class DrawSaveLayer : DrawCmd {
public class DrawRestore : StateUpdateDrawCmd {
public class DrawRestore : DrawCmd {
public class DrawTranslate : StateUpdateDrawCmd {
public class DrawTranslate : DrawCmd {
public class DrawScale : StateUpdateDrawCmd {
public class DrawScale : DrawCmd {
public class DrawRotate : StateUpdateDrawCmd {
public class DrawRotate : DrawCmd {
public class DrawSkew : StateUpdateDrawCmd {
public class DrawSkew : DrawCmd {
public class DrawConcat : StateUpdateDrawCmd {
public class DrawConcat : DrawCmd {
public class DrawResetMatrix : StateUpdateDrawCmd {
public class DrawResetMatrix : DrawCmd {
public class DrawSetMatrix : StateUpdateDrawCmd {
public class DrawSetMatrix : DrawCmd {
public class DrawClipRect : StateUpdateDrawCmd {
public class DrawClipRect : DrawCmd {
public class DrawClipRRect : StateUpdateDrawCmd {
public class DrawClipRRect : DrawCmd {
public class DrawClipPath : StateUpdateDrawCmd {
public class DrawClipPath : DrawCmd {
public Path path;
}

public override uiRect bounds(float margin) {
return uiRectHelper.fromRect(this.path.getBoundsWithMargin(margin)).Value;
}
}
public class DrawImage : DrawCmd {

// TODO: Should divide by device pixel ratio here, which is not available as
// this DrawCmd is created. This bounds should only used as an upper bound,
// assuming that device pixel ratio is always >= 1
public override uiRect bounds(float margin) {
return uiRectHelper.fromLTWH(
this.offset.dx - margin, this.offset.dy - margin,
this.image.width + 2 * margin,
this.image.height + 2 * margin);
}
}
public class DrawImageRect : DrawCmd {

public Paint paint;
public override uiRect bounds(float margin) {
return uiRectHelper.fromRect(this.dst.inflate(margin)).Value;
}
}
public class DrawImageNine : DrawCmd {

public Rect dst;
public Paint paint;
public override uiRect bounds(float margin) {
return uiRectHelper.fromLTRB(
this.dst.left + ((this.center.left - this.src.left) * this.src.width) - margin,
this.dst.top + ((this.center.top - this.src.top) * this.src.height) - margin,
this.dst.right - ((this.src.right - this.center.right) * this.src.width) + margin,
this.dst.bottom - ((this.src.bottom - this.center.bottom) * this.src.height) + margin
);
}
public override uiRect bounds(float margin) {
return uiRectHelper.fromRect(this.picture.paintBounds.inflate(margin)).Value;
}
}
public class DrawTextBlob : DrawCmd {

public override uiRect bounds(float margin) {
return uiRectHelper.fromRect(this.textBlob.Value.boundsInText
.translate(this.offset.dx, this.offset.dy)
.inflate(margin)).Value;
}
}
}

69
Runtime/ui/renderer/common/draw_cmd.cs


namespace Unity.UIWidgets.ui {
public abstract class uiDrawCmd : PoolObject {
public abstract void release();
public abstract uiRect bounds(float margin);
public abstract class uiStateUpdateDrawCmd : uiDrawCmd {
public override uiRect bounds(float margin) {
return uiRectHelper.zero;
}
}
public class uiDrawSave : uiStateUpdateDrawCmd {
public class uiDrawSave : uiDrawCmd {
public uiDrawSave() {
}

}
}
public class uiDrawSaveLayer : uiStateUpdateDrawCmd {
public class uiDrawSaveLayer : uiDrawCmd {
public uiDrawSaveLayer() {
}

public uiPaint paint;
}
public class uiDrawRestore : uiStateUpdateDrawCmd {
public class uiDrawRestore : uiDrawCmd {
public uiDrawRestore() {
}

}
}
public class uiDrawTranslate : uiStateUpdateDrawCmd {
public class uiDrawTranslate : uiDrawCmd {
public uiDrawTranslate() {
}

public float dy;
}
public class uiDrawScale : uiStateUpdateDrawCmd {
public class uiDrawScale : uiDrawCmd {
public uiDrawScale() {
}

public float? sy;
}
public class uiDrawRotate : uiStateUpdateDrawCmd {
public class uiDrawRotate : uiDrawCmd {
public uiDrawRotate() {
}

public uiOffset? offset;
}
public class uiDrawSkew : uiStateUpdateDrawCmd {
public class uiDrawSkew : uiDrawCmd {
public uiDrawSkew() {
}

public float sy;
}
public class uiDrawConcat : uiStateUpdateDrawCmd {
public class uiDrawConcat : uiDrawCmd {
public uiDrawConcat() {
}

public uiMatrix3? matrix;
}
public class uiDrawResetMatrix : uiStateUpdateDrawCmd {
public class uiDrawResetMatrix : uiDrawCmd {
public uiDrawResetMatrix() {
}

}
}
public class uiDrawSetMatrix : uiStateUpdateDrawCmd {
public class uiDrawSetMatrix : uiDrawCmd {
public uiDrawSetMatrix() {
}

public uiMatrix3? matrix;
}
public class uiDrawClipRect : uiStateUpdateDrawCmd {
public class uiDrawClipRect : uiDrawCmd {
public uiDrawClipRect() {
}

public uiRect? rect;
}
public class uiDrawClipRRect : uiStateUpdateDrawCmd {
public class uiDrawClipRRect : uiDrawCmd {
public uiDrawClipRRect() {
}

public RRect rrect;
}
public class uiDrawClipPath : uiStateUpdateDrawCmd {
public class uiDrawClipPath : uiDrawCmd {
public uiDrawClipPath() {
}

public uiPath path;
public uiPaint paint;
public override uiRect bounds(float margin) {
return this.path.getBoundsWithMargin(margin);
}
}
public class uiDrawImage : uiDrawCmd {

public Image image;
public uiOffset? offset;
public uiPaint paint;
// TODO: Should divide by device pixel ratio here, which is not available as
// this DrawCmd is created. This bounds should only used as an upper bound,
// assuming that device pixel ratio is always >= 1
public override uiRect bounds(float margin) {
return uiRectHelper.fromLTWH(
this.offset.Value.dx - margin, this.offset.Value.dy - margin,
this.image.width + 2 * margin,
this.image.height + 2 * margin);
}
}
public class uiDrawImageRect : uiDrawCmd {

public uiRect? src;
public uiRect? dst;
public uiPaint paint;
public override uiRect bounds(float margin) {
return uiRectHelper.inflate(this.dst.Value, margin);
}
}
public class uiDrawImageNine : uiDrawCmd {

public uiRect? center;
public uiRect? dst;
public uiPaint paint;
public override uiRect bounds(float margin) {
return uiRectHelper.fromLTRB(
this.dst.Value.left + ((this.center.Value.left - this.src.Value.left) * this.src.Value.width) - margin,
this.dst.Value.top + ((this.center.Value.top - this.src.Value.top) * this.src.Value.height) - margin,
this.dst.Value.right - ((this.src.Value.right - this.center.Value.right) * this.src.Value.width) + margin,
this.dst.Value.bottom - ((this.src.Value.bottom - this.center.Value.bottom) * this.src.Value.height) + margin
);
}
}
public class uiDrawPicture : uiDrawCmd {

}
public Picture picture;
public override uiRect bounds(float margin) {
return uiRectHelper.fromRect(this.picture.paintBounds.inflate(margin)).Value;
}
}
public class uiDrawTextBlob : uiDrawCmd {

public TextBlob? textBlob;
public uiOffset? offset;
public uiPaint paint;
public override uiRect bounds(float margin) {
return uiRectHelper.fromRect(this.textBlob.Value.boundsInText.translate(
this.offset.Value.dx, this.offset.Value.dy).inflate(margin)).Value;
}
}
}

2
Runtime/ui/txt/paragraph.cs


this._needsLayout = true;
if (!skipRequestCharacters) {
for (int i = 0; i < runs.size; i++) {
var style = runs.getStyle(i);
var style = run.style;
var font = FontManager.instance.getOrCreate(style.fontFamily, style.fontWeight, style.fontStyle).font;
font.RequestCharactersInTextureSafe(text.Substring(run.start, run.end - run.start),
style.UnityFontSize, style.UnityFontStyle);

正在加载...
取消
保存