From 1978bc24090b165a2feba5a799a41430e9f78dbb Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 27 May 2016 19:44:25 +0200 Subject: [PATCH] Apply colours (optionally) to event browser and timeline bar. Refs #270 --- renderdocui/Code/PersistantConfig.cs | 3 +++ renderdocui/Windows/EventBrowser.cs | 22 +++++++++++++++++++++ renderdocui/Windows/TimelineBar.cs | 29 +++++++++++++++++++++++----- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/renderdocui/Code/PersistantConfig.cs b/renderdocui/Code/PersistantConfig.cs index 0013c7fbc..d6e2591d8 100644 --- a/renderdocui/Code/PersistantConfig.cs +++ b/renderdocui/Code/PersistantConfig.cs @@ -105,6 +105,9 @@ namespace renderdocui.Code public TimeUnit EventBrowser_TimeUnit = TimeUnit.Microseconds; public bool EventBrowser_HideEmpty = false; + public bool EventBrowser_ApplyColours = true; + public bool EventBrowser_ColourEventRow = true; + public int Formatter_MinFigures = 2; public int Formatter_MaxFigures = 5; public int Formatter_NegExp = 5; diff --git a/renderdocui/Windows/EventBrowser.cs b/renderdocui/Windows/EventBrowser.cs index ac0920e62..32750987b 100644 --- a/renderdocui/Windows/EventBrowser.cs +++ b/renderdocui/Windows/EventBrowser.cs @@ -260,6 +260,28 @@ namespace renderdocui.Windows else drawNode = MakeNode(eventNum, drawcall.drawcallID, drawcall.name, 0.0); + if (m_Core.Config.EventBrowser_ApplyColours) + { + // if alpha isn't 0, assume the colour is valid + if ((drawcall.flags & (DrawcallFlags.PushMarker | DrawcallFlags.SetMarker)) > 0 && drawcall.markerColour[3] > 0.0f) + { + float red = drawcall.markerColour[0]; + float green = drawcall.markerColour[1]; + float blue = drawcall.markerColour[2]; + float alpha = drawcall.markerColour[3]; + + drawNode.TreeLineColor = drawcall.GetColor(); + drawNode.TreeLineWidth = 3.0f; + + if (m_Core.Config.EventBrowser_ColourEventRow) + { + drawNode.BackColor = drawcall.GetColor(); + if (drawcall.ShouldUseWhiteText()) + drawNode.ForeColor = Color.White; + } + } + } + DeferredEvent def = new DeferredEvent(); def.eventID = eventNum; def.marker = (drawcall.flags & DrawcallFlags.SetMarker) != 0; diff --git a/renderdocui/Windows/TimelineBar.cs b/renderdocui/Windows/TimelineBar.cs index ae55d946f..3559e6633 100644 --- a/renderdocui/Windows/TimelineBar.cs +++ b/renderdocui/Windows/TimelineBar.cs @@ -242,7 +242,7 @@ namespace renderdocui.Windows m_ranges[m_ranges.Count-1].last = eid; } - private RectangleF DrawBar(Graphics g, Color back, RectangleF rect, float startSeg, float segWidth, string text, bool visible) + private RectangleF DrawBar(Graphics g, Color back, Color fore, RectangleF rect, float startSeg, float segWidth, string text, bool visible) { var subRect = GetSubrect(rect, startSeg, segWidth); subRect.Height = barHeight; @@ -250,6 +250,7 @@ namespace renderdocui.Windows if (subRect.Contains(markerPos) && visible && showMarker && markerPos.Y < ClientRectangle.Height - pipRadius*6) { back = Color.LightYellow; + fore = Color.Black; Cursor = Cursors.Hand; } @@ -284,7 +285,8 @@ namespace renderdocui.Windows if (visible) { g.Clip = new Region(textRect); - g.DrawString(text, barFont, Brushes.Black, textRect.X, textRect.Y); + using (var brush = new SolidBrush(fore)) + g.DrawString(text, barFont, brush, textRect.X, textRect.Y); g.ResetClip(); } @@ -300,6 +302,10 @@ namespace renderdocui.Windows private class Section { public string Name = ""; + + public Color color; + public Color textcolor; + public bool Expanded = false; public List
subsections = null; public List draws = null; @@ -352,6 +358,16 @@ namespace renderdocui.Windows if (s.Count == 1 && (s[0].flags & (DrawcallFlags.PushMarker | DrawcallFlags.MultiDraw)) > 0) { sec = GatherEvents(s[0].children); + if (m_Core.Config.EventBrowser_ApplyColours) + { + sec.color = s[0].GetColor(); + sec.textcolor = s[0].ShouldUseWhiteText() ? Color.White : Color.Black; + } + else + { + sec.color = Color.Transparent; + sec.textcolor = Color.Black; + } sec.Name = s[0].name; } else @@ -490,8 +506,6 @@ namespace renderdocui.Windows for (int i = 0; i < section.subsections.Count; i++) widths[i] /= rect.Width; - var col = depth % 2 == 0 ? lightBack : darkBack; - var clipRect = rect; clipRect.Height -= pipRadius * 6; @@ -500,8 +514,13 @@ namespace renderdocui.Windows var s = section.subsections[i]; if (s.Name.Length > 0) { + var col = depth % 2 == 0 ? lightBack : darkBack; + + if (s.color.A > 0) + col = s.color; + g.Clip = new Region(clipRect); - var childRect = DrawBar(g, col, rect, start, widths[i], (s.Expanded ? "- " : "+ ") + s.Name, visible); + var childRect = DrawBar(g, col, s.textcolor, rect, start, widths[i], (s.Expanded ? "- " : "+ ") + s.Name, visible); g.ResetClip(); RenderSection(depth + 1, g, childRect, s, visible && s.Expanded, visible ? childRect.Top : lastVisibleHeight);