浏览代码

Merge pull request #393 from UnityTech/fix_aa_shapehintbug

fix unmatched save restore issue
/main
GitHub 5 年前
当前提交
3af9ead9
共有 2 个文件被更改,包括 33 次插入15 次删除
  1. 8
      Runtime/ui/painting/canvas.cs
  2. 40
      Runtime/ui/painting/picture.cs

8
Runtime/ui/painting/canvas.cs


}
public void restore() {
this._saveCount--;
this._recorder.addDrawCmd(new DrawRestore {
});
if (this._saveCount > 1) {
this._saveCount--;
this._recorder.addDrawCmd(new DrawRestore {
});
}
}
public int getSaveCount() {

40
Runtime/ui/painting/picture.cs


});
}
void restoreToCount(int count) {
count = this._states.Count - count;
while (count > 0) {
this.addDrawCmd(new DrawRestore());
count--;
}
}
void restore() {
var stateToRestore = this._getState();
this._states.RemoveAt(this._states.Count - 1);
var state = this._getState();
if (!stateToRestore.saveLayer) {
state.paintBounds = stateToRestore.paintBounds;
}
else {
var paintBounds = stateToRestore.paintBounds.shift(stateToRestore.layerOffset);
paintBounds = state.xform.mapRect(paintBounds);
this._addPaintBounds(paintBounds);
}
}
this.restoreToCount(1);
if (this._states.Count > 1) {
throw new Exception("unmatched save/restore commands");
}

}
case DrawRestore _: {
var stateToRestore = this._getState();
this._states.RemoveAt(this._states.Count - 1);
var state = this._getState();
if (!stateToRestore.saveLayer) {
state.paintBounds = stateToRestore.paintBounds;
//check for underflow
if (this._states.Count > 1) {
this.restore();
else {
var paintBounds = stateToRestore.paintBounds.shift(stateToRestore.layerOffset);
paintBounds = state.xform.mapRect(paintBounds);
this._addPaintBounds(paintBounds);
}
break;
}

正在加载...
取消
保存