diff --git a/Source/Editor/GUI/Row.cs b/Source/Editor/GUI/Row.cs
index f6bd5b02a..ca45ec6f5 100644
--- a/Source/Editor/GUI/Row.cs
+++ b/Source/Editor/GUI/Row.cs
@@ -24,6 +24,11 @@ namespace FlaxEditor.GUI
///
public object[] Values { get; set; }
+ ///
+ /// Gets or sets the cell background colors. Null if unused, transparent values are ignored.
+ ///
+ public Color[] BackgroundColors { get; set; }
+
///
/// Gets or sets the row depth level.
///
@@ -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();
diff --git a/Source/Editor/Windows/Profiler/CPU.cs b/Source/Editor/Windows/Profiler/CPU.cs
index 0cbb3fa9b..ba569f04f 100644
--- a/Source/Editor/Windows/Profiler/CPU.cs
+++ b/Source/Editor/Windows/Profiler/CPU.cs
@@ -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);