Skip to content

Commit 473ae3b

Browse files
committed
enhance: improve commit graph render performance
Signed-off-by: leo <longshuang@msn.cn>
1 parent 6da1d15 commit 473ae3b

1 file changed

Lines changed: 17 additions & 42 deletions

File tree

‎src/Views/CommitGraph.cs‎

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -77,30 +77,28 @@ private void DrawCurves(DrawingContext context, Models.CommitGraph graph, double
7777
var grayedPen = new Pen(new SolidColorBrush(Colors.Gray, 0.4), Models.CommitGraph.Pens[0].Thickness);
7878
var onlyHighlightCurrentBranch = OnlyHighlightCurrentBranch;
7979

80-
if (onlyHighlightCurrentBranch)
80+
foreach (var link in graph.Links)
8181
{
82-
foreach (var link in graph.Links)
83-
{
84-
if (link.IsMerged)
85-
continue;
86-
87-
var startY = link.Start.Y * rowHeight;
88-
var endY = link.End.Y * rowHeight;
82+
var startY = link.Start.Y * rowHeight;
83+
var endY = link.End.Y * rowHeight;
8984

90-
if (endY < top)
91-
continue;
92-
if (startY > bottom)
93-
break;
85+
if (endY < top)
86+
continue;
87+
if (startY > bottom)
88+
break;
9489

95-
var geo = new StreamGeometry();
96-
using (var ctx = geo.Open())
97-
{
98-
ctx.BeginFigure(new Point(link.Start.X, startY), false);
99-
ctx.QuadraticBezierTo(new Point(link.Control.X, link.Control.Y * rowHeight), new Point(link.End.X, endY));
100-
}
90+
var pen = Models.CommitGraph.Pens[link.Color];
91+
if (onlyHighlightCurrentBranch && !link.IsMerged)
92+
pen = grayedPen;
10193

102-
context.DrawGeometry(null, grayedPen, geo);
94+
var geo = new StreamGeometry();
95+
using (var ctx = geo.Open())
96+
{
97+
ctx.BeginFigure(new Point(link.Start.X, startY), false);
98+
ctx.QuadraticBezierTo(new Point(link.Control.X, link.Control.Y * rowHeight), new Point(link.End.X, endY));
10399
}
100+
101+
context.DrawGeometry(null, pen, geo);
104102
}
105103

106104
foreach (var line in graph.Paths)
@@ -174,29 +172,6 @@ private void DrawCurves(DrawingContext context, Models.CommitGraph graph, double
174172
else
175173
context.DrawGeometry(null, pen, geo);
176174
}
177-
178-
foreach (var link in graph.Links)
179-
{
180-
if (onlyHighlightCurrentBranch && !link.IsMerged)
181-
continue;
182-
183-
var startY = link.Start.Y * rowHeight;
184-
var endY = link.End.Y * rowHeight;
185-
186-
if (endY < top)
187-
continue;
188-
if (startY > bottom)
189-
break;
190-
191-
var geo = new StreamGeometry();
192-
using (var ctx = geo.Open())
193-
{
194-
ctx.BeginFigure(new Point(link.Start.X, startY), false);
195-
ctx.QuadraticBezierTo(new Point(link.Control.X, link.Control.Y * rowHeight), new Point(link.End.X, endY));
196-
}
197-
198-
context.DrawGeometry(null, Models.CommitGraph.Pens[link.Color], geo);
199-
}
200175
}
201176

202177
private void DrawAnchors(DrawingContext context, Models.CommitGraph graph, double top, double bottom, double rowHeight)

0 commit comments

Comments
 (0)