Add red tint highlight for CPU profiler table entries based on event duration
This commit is contained in:
@@ -24,6 +24,11 @@ namespace FlaxEditor.GUI
|
||||
/// </summary>
|
||||
public object[] Values { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the cell background colors. Null if unused, transparent values are ignored.
|
||||
/// </summary>
|
||||
public Color[] BackgroundColors { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the row depth level.
|
||||
/// </summary>
|
||||
@@ -58,6 +63,7 @@ namespace FlaxEditor.GUI
|
||||
{
|
||||
float x = 0;
|
||||
int end = Mathf.Min(Values.Length, _table.Columns.Length);
|
||||
var backgroundColors = BackgroundColors;
|
||||
for (int i = 0; i < end; i++)
|
||||
{
|
||||
var column = _table.Columns[i];
|
||||
@@ -98,6 +104,8 @@ namespace FlaxEditor.GUI
|
||||
rect.Width -= leftDepthMargin;
|
||||
|
||||
Render2D.PushClip(rect);
|
||||
if (backgroundColors != null && backgroundColors[i].A > 0)
|
||||
Render2D.FillRectangle(rect, backgroundColors[i]);
|
||||
Render2D.DrawText(style.FontMedium, text, rect, style.Foreground, column.CellAlignment, TextAlignment.Center);
|
||||
Render2D.PopClip();
|
||||
|
||||
|
||||
@@ -452,7 +452,6 @@ namespace FlaxEditor.Windows.Profiler
|
||||
var data = _events.Get(_mainChart.SelectedSampleIndex);
|
||||
if (data == null || data.Length == 0)
|
||||
return;
|
||||
|
||||
float totalTimeMs = _mainChart.SelectedSample;
|
||||
|
||||
// Add rows
|
||||
@@ -501,17 +500,24 @@ namespace FlaxEditor.Windows.Profiler
|
||||
row = new Row
|
||||
{
|
||||
Values = new object[6],
|
||||
BackgroundColors = new Color[6],
|
||||
};
|
||||
for (int k = 0; k < row.BackgroundColors.Length; k++)
|
||||
row.BackgroundColors[k] = Color.Transparent;
|
||||
}
|
||||
{
|
||||
// Event
|
||||
row.Values[0] = name;
|
||||
|
||||
// Total (%)
|
||||
row.Values[1] = (int)(time / totalTimeMs * 1000.0f) / 10.0f;
|
||||
float rowTotalTimePerc = (float)(time / totalTimeMs);
|
||||
row.Values[1] = (int)(rowTotalTimePerc * 1000.0f) / 10.0f;
|
||||
row.BackgroundColors[1] = Color.Red.AlphaMultiplied(Mathf.Min(1, rowTotalTimePerc) * 0.5f);
|
||||
|
||||
// Self (%)
|
||||
row.Values[2] = (int)((time - subEventsTimeTotal) / time * 1000.0f) / 10.0f;
|
||||
float rowSelfTimePerc = (float)((time - subEventsTimeTotal) / totalTimeMs);
|
||||
row.Values[2] = (int)(rowSelfTimePerc * 1000.0f) / 10.0f;
|
||||
row.BackgroundColors[2] = Color.Red.AlphaMultiplied(Mathf.Min(1, rowSelfTimePerc) * 0.5f);
|
||||
|
||||
// Time ms
|
||||
row.Values[3] = (float)((time * 10000.0f) / 10000.0f);
|
||||
|
||||
Reference in New Issue
Block a user