mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
optimize<CommitGraph>: only record Y-coord of the last added point in line
This commit is contained in:
parent
1a6d3ffe70
commit
3d7325f376
1 changed files with 18 additions and 11 deletions
|
@ -35,22 +35,34 @@ namespace SourceGit.Views.Controls {
|
||||||
public bool IsMerged;
|
public bool IsMerged;
|
||||||
public double LastX;
|
public double LastX;
|
||||||
public double LastY;
|
public double LastY;
|
||||||
|
public double EndY;
|
||||||
public Line Line;
|
public Line Line;
|
||||||
|
|
||||||
private Point end;
|
|
||||||
|
|
||||||
public LineHelper(string next, bool isMerged, int color, Point start) {
|
public LineHelper(string next, bool isMerged, int color, Point start) {
|
||||||
Next = next;
|
Next = next;
|
||||||
IsMerged = isMerged;
|
IsMerged = isMerged;
|
||||||
LastX = start.X;
|
LastX = start.X;
|
||||||
LastY = start.Y;
|
LastY = start.Y;
|
||||||
end = start;
|
EndY = LastY;
|
||||||
|
|
||||||
Line = new Line();
|
Line = new Line();
|
||||||
Line.Color = color % PENS.Length;
|
Line.Color = color % PENS.Length;
|
||||||
Line.Points.Add(start);
|
Line.Points.Add(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LineHelper(string next, bool isMerged, int color, Point start, Point to) {
|
||||||
|
Next = next;
|
||||||
|
IsMerged = isMerged;
|
||||||
|
LastX = to.X;
|
||||||
|
LastY = to.Y;
|
||||||
|
EndY = LastY;
|
||||||
|
|
||||||
|
Line = new Line();
|
||||||
|
Line.Color = color % PENS.Length;
|
||||||
|
Line.Points.Add(start);
|
||||||
|
Line.Points.Add(to);
|
||||||
|
}
|
||||||
|
|
||||||
public void Add(double x, double y, bool isEnd = false) {
|
public void Add(double x, double y, bool isEnd = false) {
|
||||||
if (x > LastX) {
|
if (x > LastX) {
|
||||||
Add(new Point(LastX, LastY));
|
Add(new Point(LastX, LastY));
|
||||||
|
@ -67,9 +79,9 @@ namespace SourceGit.Views.Controls {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Add(Point p) {
|
private void Add(Point p) {
|
||||||
if (p.Y > end.Y) {
|
if (EndY < p.Y) {
|
||||||
Line.Points.Add(p);
|
Line.Points.Add(p);
|
||||||
end = p;
|
EndY = p.Y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,12 +203,7 @@ namespace SourceGit.Views.Controls {
|
||||||
offsetX += UNIT_WIDTH;
|
offsetX += UNIT_WIDTH;
|
||||||
|
|
||||||
// 防止有下一个提交有ended线时,新的分支线与旧线重合
|
// 防止有下一个提交有ended线时,新的分支线与旧线重合
|
||||||
var l = new LineHelper(commit.Parents[j], isMerged, colorIdx, position);
|
unsolved.Add(new LineHelper(commit.Parents[j], isMerged, colorIdx, position, new Point(offsetX, position.Y + HALF_HEIGHT)));
|
||||||
l.Line.Points.Add(new Point(offsetX, position.Y + HALF_HEIGHT));
|
|
||||||
l.LastX = offsetX;
|
|
||||||
l.LastY = position.Y + HALF_HEIGHT;
|
|
||||||
|
|
||||||
unsolved.Add(l);
|
|
||||||
colorIdx++;
|
colorIdx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue