Variable name cleanup

This commit is contained in:
Andy Adshead 2019-01-26 20:54:35 +00:00
commit 8d3b23c3eb
6 changed files with 130 additions and 116 deletions

View file

@ -11,8 +11,8 @@ namespace Ryujinx.Profiler
private Stopwatch SW; private Stopwatch SW;
internal ConcurrentDictionary<ProfileConfig, TimingInfo> Timers; internal ConcurrentDictionary<ProfileConfig, TimingInfo> Timers;
private readonly object sessionLock = new object(); private readonly object SessionLock = new object();
private int sessionCounter = 0; private int SessionCounter = 0;
public InternalProfile() public InternalProfile()
{ {
@ -69,9 +69,9 @@ namespace Ryujinx.Profiler
public string GetSession() public string GetSession()
{ {
// Can be called from multiple threads so locked to ensure no duplicate sessions are generated // Can be called from multiple threads so locked to ensure no duplicate sessions are generated
lock (sessionLock) lock (SessionLock)
{ {
return (sessionCounter++).ToString(); return (SessionCounter++).ToString();
} }
} }

View file

@ -9,7 +9,7 @@ namespace Ryujinx.Profiler
public string Category; public string Category;
public string SessionGroup, SessionItem; public string SessionGroup, SessionItem;
private string cachedTag, cachedSession; private string CachedTag, CachedSession;
public string Search => $"{Category}.{SessionGroup}.{SessionItem}"; public string Search => $"{Category}.{SessionGroup}.{SessionItem}";
@ -17,9 +17,9 @@ namespace Ryujinx.Profiler
{ {
get get
{ {
if (cachedTag == null) if (CachedTag == null)
cachedTag = $"{Category}{(Session == "" ? "" : $" ({Session})")}"; CachedTag = $"{Category}{(Session == "" ? "" : $" ({Session})")}";
return cachedTag; return CachedTag;
} }
} }
@ -27,27 +27,27 @@ namespace Ryujinx.Profiler
{ {
get get
{ {
if (cachedSession == null) if (CachedSession == null)
{ {
if (SessionGroup != null && SessionItem != null) if (SessionGroup != null && SessionItem != null)
{ {
cachedSession = $"{SessionGroup}: {SessionItem}"; CachedSession = $"{SessionGroup}: {SessionItem}";
} }
else if (SessionGroup != null) else if (SessionGroup != null)
{ {
cachedSession = $"{SessionGroup}"; CachedSession = $"{SessionGroup}";
} }
else if (SessionItem != null) else if (SessionItem != null)
{ {
cachedSession = $"---: {SessionItem}"; CachedSession = $"---: {SessionItem}";
} }
else else
{ {
cachedSession = ""; CachedSession = "";
} }
} }
return cachedSession; return CachedSession;
} }
} }
} }

View file

@ -10,10 +10,10 @@ namespace Ryujinx.Profiler.UI
{ {
public class ProfileButton public class ProfileButton
{ {
private int padding; private int Padding;
private FontService FontService; private FontService FontService;
private int X, Y, Right, Top, Height; private int X, Y, Right, Top, Height;
private int textX, textY; private int TextX, TextY;
private string Label; private string Label;
private Action Clicked; private Action Clicked;
private bool Visible; private bool Visible;
@ -55,8 +55,8 @@ namespace Ryujinx.Profiler.UI
Height = height; Height = height;
X = x; X = x;
Y = y; Y = y;
textX = x + padding / 2; TextX = x + padding / 2;
textY = y + padding / 2; TextY = y + padding / 2;
Top = y + height + padding; Top = y + height + padding;
Right = x + width + padding; Right = x + width + padding;
} }
@ -79,7 +79,7 @@ namespace Ryujinx.Profiler.UI
GL.Vertex2(X, Y); GL.Vertex2(X, Y);
GL.End(); GL.End();
FontService.DrawText(Label, textX, textY, Height); FontService.DrawText(Label, TextX, TextY, Height);
} }
public bool ProcessClick(int x, int y) public bool ProcessClick(int x, int y)

View file

@ -26,28 +26,28 @@ namespace Ryujinx
Pause = 6, Pause = 6,
} }
private bool visible = true, initComplete = false, viewportUpdated = true; private bool VisibleLocal = true, InitComplete = false, ViewportUpdated = true;
public bool visibleChanged; public bool VisibleChangedLocal;
private FontService fontService; private FontService FontServ;
private List<KeyValuePair<ProfileConfig, TimingInfo>> rawPofileData, profileData; private List<KeyValuePair<ProfileConfig, TimingInfo>> RawPofileData, ProfileData;
private float scrollPos = 0; private float ScrollPos = 0;
private float minScroll = 0, maxScroll = 0; private float MinScroll = 0, MaxScroll = 0;
private ProfileButton[] buttons; private ProfileButton[] Buttons;
private IComparer<KeyValuePair<ProfileConfig, TimingInfo>> sortAction; private IComparer<KeyValuePair<ProfileConfig, TimingInfo>> SortAction;
private string FilterText = ""; private string FilterText = "";
private double BackspaceDownTime, UpdateTimer; private double BackspaceDownTime, UpdateTimer;
private bool BackspaceDown = false, prevBackspaceDown = false, regexEnabled = false, ProfileUpdated = false; private bool BackspaceDown = false, PrevBackspaceDown = false, RegexEnabled = false, ProfileUpdated = false;
private bool showInactive = true, Paused = false; private bool ShowInactive = true, Paused = false;
public ProfileWindow() public ProfileWindow()
: base(1280, 720) : base(1280, 720)
{ {
Location = new Point(DisplayDevice.Default.Width - 1280, (DisplayDevice.Default.Height - 720) - 50); Location = new Point(DisplayDevice.Default.Width - 1280, (DisplayDevice.Default.Height - 720) - 50);
Title = "Profiler"; Title = "Profiler";
sortAction = null; SortAction = null;
BackspaceDownTime = 0; BackspaceDownTime = 0;
// Large number to force an update on first update // Large number to force an update on first update
@ -57,8 +57,8 @@ namespace Ryujinx
#region Public Methods #region Public Methods
public void ToggleVisible() public void ToggleVisible()
{ {
visible = !visible; VisibleLocal = !VisibleLocal;
visibleChanged = true; VisibleChangedLocal = true;
} }
#endregion #endregion
@ -70,26 +70,26 @@ namespace Ryujinx
protected override void OnLoad(EventArgs e) protected override void OnLoad(EventArgs e)
{ {
GL.ClearColor(Color.MidnightBlue); GL.ClearColor(Color.MidnightBlue);
fontService = new FontService(); FontServ = new FontService();
fontService.InitalizeTextures(); FontServ.InitalizeTextures();
fontService.UpdateScreenHeight(Height); FontServ.UpdateScreenHeight(Height);
buttons = new ProfileButton[7]; Buttons = new ProfileButton[7];
buttons[(int)ButtonIndex.TagTitle] = new ProfileButton(fontService, () => sortAction = new ProfileSorters.TagAscending()); Buttons[(int)ButtonIndex.TagTitle] = new ProfileButton(FontServ, () => SortAction = new ProfileSorters.TagAscending());
buttons[(int)ButtonIndex.InstantTitle] = new ProfileButton(fontService, () => sortAction = new ProfileSorters.InstantAscending()); Buttons[(int)ButtonIndex.InstantTitle] = new ProfileButton(FontServ, () => SortAction = new ProfileSorters.InstantAscending());
buttons[(int)ButtonIndex.AverageTitle] = new ProfileButton(fontService, () => sortAction = new ProfileSorters.AverageAscending()); Buttons[(int)ButtonIndex.AverageTitle] = new ProfileButton(FontServ, () => SortAction = new ProfileSorters.AverageAscending());
buttons[(int)ButtonIndex.TotalTitle] = new ProfileButton(fontService, () => sortAction = new ProfileSorters.TotalAscending()); Buttons[(int)ButtonIndex.TotalTitle] = new ProfileButton(FontServ, () => SortAction = new ProfileSorters.TotalAscending());
buttons[(int)ButtonIndex.FilterBar] = new ProfileButton(fontService, () => Buttons[(int)ButtonIndex.FilterBar] = new ProfileButton(FontServ, () =>
{ {
ProfileUpdated = true; ProfileUpdated = true;
regexEnabled = !regexEnabled; RegexEnabled = !RegexEnabled;
}); });
buttons[(int)ButtonIndex.ShowHideInactive] = new ProfileButton(fontService, () => Buttons[(int)ButtonIndex.ShowHideInactive] = new ProfileButton(FontServ, () =>
{ {
ProfileUpdated = true; ProfileUpdated = true;
showInactive = !showInactive; ShowInactive = !ShowInactive;
}); });
buttons[(int)ButtonIndex.Pause] = new ProfileButton(fontService, () => Buttons[(int)ButtonIndex.Pause] = new ProfileButton(FontServ, () =>
{ {
ProfileUpdated = true; ProfileUpdated = true;
Paused = !Paused; Paused = !Paused;
@ -105,7 +105,7 @@ namespace Ryujinx
/// <remarks>There is no need to call the base implementation.</remarks> /// <remarks>There is no need to call the base implementation.</remarks>
protected override void OnResize(EventArgs e) protected override void OnResize(EventArgs e)
{ {
viewportUpdated = true; ViewportUpdated = true;
} }
#endregion #endregion
@ -115,8 +115,8 @@ namespace Ryujinx
/// </summary> /// </summary>
protected override void OnClosing(CancelEventArgs e) protected override void OnClosing(CancelEventArgs e)
{ {
visible = false; VisibleLocal = false;
visibleChanged = true; VisibleChangedLocal = true;
e.Cancel = true; e.Cancel = true;
base.OnClosing(e); base.OnClosing(e);
} }
@ -130,12 +130,12 @@ namespace Ryujinx
/// <remarks>There is no need to call the base implementation.</remarks> /// <remarks>There is no need to call the base implementation.</remarks>
protected override void OnUpdateFrame(FrameEventArgs e) protected override void OnUpdateFrame(FrameEventArgs e)
{ {
initComplete = true; InitComplete = true;
// Backspace handling // Backspace handling
if (BackspaceDown) if (BackspaceDown)
{ {
if (!prevBackspaceDown) if (!PrevBackspaceDown)
{ {
BackspaceDownTime = 0; BackspaceDownTime = 0;
FilterBackspace(); FilterBackspace();
@ -150,42 +150,42 @@ namespace Ryujinx
} }
} }
} }
prevBackspaceDown = BackspaceDown; PrevBackspaceDown = BackspaceDown;
// Get timing data if enough time has passed // Get timing data if enough time has passed
UpdateTimer += e.Time; UpdateTimer += e.Time;
if (!Paused && (UpdateTimer > Profile.GetUpdateRate())) if (!Paused && (UpdateTimer > Profile.GetUpdateRate()))
{ {
UpdateTimer %= Profile.GetUpdateRate(); UpdateTimer %= Profile.GetUpdateRate();
rawPofileData = Profile.GetProfilingData().ToList(); RawPofileData = Profile.GetProfilingData().ToList();
ProfileUpdated = true; ProfileUpdated = true;
} }
// Filtering // Filtering
if (ProfileUpdated) if (ProfileUpdated)
{ {
if (showInactive) if (ShowInactive)
{ {
profileData = rawPofileData; ProfileData = RawPofileData;
} }
else else
{ {
profileData = rawPofileData.FindAll(kvp => kvp.Value.Instant > 0.001f); ProfileData = RawPofileData.FindAll(kvp => kvp.Value.Instant > 0.001f);
} }
if (sortAction != null) if (SortAction != null)
{ {
profileData.Sort(sortAction); ProfileData.Sort(SortAction);
} }
if (regexEnabled) if (RegexEnabled)
{ {
try try
{ {
Regex filterRegex = new Regex(FilterText, RegexOptions.IgnoreCase); Regex filterRegex = new Regex(FilterText, RegexOptions.IgnoreCase);
if (FilterText != "") if (FilterText != "")
{ {
profileData = profileData.Where((pair => filterRegex.IsMatch(pair.Key.Search))).ToList(); ProfileData = ProfileData.Where((pair => filterRegex.IsMatch(pair.Key.Search))).ToList();
} }
} }
catch (ArgumentException argException) catch (ArgumentException argException)
@ -196,7 +196,7 @@ namespace Ryujinx
else else
{ {
// Regular filtering // Regular filtering
profileData = profileData.Where((pair => pair.Key.Search.ToLower().Contains(FilterText.ToLower()))).ToList(); ProfileData = ProfileData.Where((pair => pair.Key.Search.ToLower().Contains(FilterText.ToLower()))).ToList();
} }
ProfileUpdated = false; ProfileUpdated = false;
@ -212,19 +212,19 @@ namespace Ryujinx
/// <remarks>There is no need to call the base implementation.</remarks> /// <remarks>There is no need to call the base implementation.</remarks>
protected override void OnRenderFrame(FrameEventArgs e) protected override void OnRenderFrame(FrameEventArgs e)
{ {
if (visibleChanged) if (VisibleChangedLocal)
{ {
Visible = visible; Visible = VisibleLocal;
visibleChanged = false; VisibleChangedLocal = false;
} }
if (!visible || !initComplete) if (!VisibleLocal || !InitComplete)
{ {
return; return;
} }
// Update viewport // Update viewport
if (viewportUpdated) if (ViewportUpdated)
{ {
GL.Viewport(0, 0, Width, Height); GL.Viewport(0, 0, Width, Height);
@ -232,16 +232,16 @@ namespace Ryujinx
GL.LoadIdentity(); GL.LoadIdentity();
GL.Ortho(0, Width, 0, Height, 0.0, 4.0); GL.Ortho(0, Width, 0, Height, 0.0, 4.0);
fontService.UpdateScreenHeight(Height); FontServ.UpdateScreenHeight(Height);
viewportUpdated = false; ViewportUpdated = false;
} }
// Frame setup // Frame setup
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.ClearColor(Color.Black); GL.ClearColor(Color.Black);
fontService.fontColor = Color.White; FontServ.fontColor = Color.White;
int verticalIndex = 0; int verticalIndex = 0;
int lineHeight = 16; int lineHeight = 16;
int titleHeight = 24; int titleHeight = 24;
@ -252,7 +252,7 @@ namespace Ryujinx
float width; float width;
float maxWidth = 0; float maxWidth = 0;
float yOffset = scrollPos - titleHeight; float yOffset = ScrollPos - titleHeight;
float xOffset = 10; float xOffset = 10;
// Background lines to make reading easier // Background lines to make reading easier
@ -260,7 +260,7 @@ namespace Ryujinx
GL.Scissor(0, filterHeight, Width, Height - titleHeight - filterHeight); GL.Scissor(0, filterHeight, Width, Height - titleHeight - filterHeight);
GL.Begin(PrimitiveType.Triangles); GL.Begin(PrimitiveType.Triangles);
GL.Color3(0.2f, 0.2f, 0.2f); GL.Color3(0.2f, 0.2f, 0.2f);
for (int i = 0; i < profileData.Count; i += 2) for (int i = 0; i < ProfileData.Count; i += 2)
{ {
float top = GetLineY(yOffset, lineHeight, linePadding, false, i - 1); float top = GetLineY(yOffset, lineHeight, linePadding, false, i - 1);
float bottom = GetLineY(yOffset, lineHeight, linePadding, false, i); float bottom = GetLineY(yOffset, lineHeight, linePadding, false, i);
@ -278,14 +278,14 @@ namespace Ryujinx
GL.Vertex2(0, bottom); GL.Vertex2(0, bottom);
} }
GL.End(); GL.End();
maxScroll = (lineHeight + linePadding) * (profileData.Count - 1); MaxScroll = (lineHeight + linePadding) * (ProfileData.Count - 1);
// Display category // Display category
verticalIndex = 0; verticalIndex = 0;
foreach (var entry in profileData) foreach (var entry in ProfileData)
{ {
float y = GetLineY(yOffset, lineHeight, linePadding, true, verticalIndex++); float y = GetLineY(yOffset, lineHeight, linePadding, true, verticalIndex++);
width = fontService.DrawText(entry.Key.Category, xOffset, y, lineHeight); width = FontServ.DrawText(entry.Key.Category, xOffset, y, lineHeight);
if (width > maxWidth) if (width > maxWidth)
{ {
maxWidth = width; maxWidth = width;
@ -293,7 +293,7 @@ namespace Ryujinx
} }
GL.Disable(EnableCap.ScissorTest); GL.Disable(EnableCap.ScissorTest);
width = fontService.DrawText("Category", xOffset, Height - titleFontHeight, titleFontHeight); width = FontServ.DrawText("Category", xOffset, Height - titleFontHeight, titleFontHeight);
if (width > maxWidth) if (width > maxWidth)
maxWidth = width; maxWidth = width;
@ -304,10 +304,10 @@ namespace Ryujinx
maxWidth = 0; maxWidth = 0;
verticalIndex = 0; verticalIndex = 0;
GL.Enable(EnableCap.ScissorTest); GL.Enable(EnableCap.ScissorTest);
foreach (var entry in profileData) foreach (var entry in ProfileData)
{ {
float y = GetLineY(yOffset, lineHeight, linePadding, true, verticalIndex++); float y = GetLineY(yOffset, lineHeight, linePadding, true, verticalIndex++);
width = fontService.DrawText(entry.Key.SessionGroup, xOffset, y, lineHeight); width = FontServ.DrawText(entry.Key.SessionGroup, xOffset, y, lineHeight);
if (width > maxWidth) if (width > maxWidth)
{ {
maxWidth = width; maxWidth = width;
@ -315,7 +315,7 @@ namespace Ryujinx
} }
GL.Disable(EnableCap.ScissorTest); GL.Disable(EnableCap.ScissorTest);
width = fontService.DrawText("Group", xOffset, Height - titleFontHeight, titleFontHeight); width = FontServ.DrawText("Group", xOffset, Height - titleFontHeight, titleFontHeight);
if (width > maxWidth) if (width > maxWidth)
maxWidth = width; maxWidth = width;
@ -325,10 +325,10 @@ namespace Ryujinx
maxWidth = 0; maxWidth = 0;
verticalIndex = 0; verticalIndex = 0;
GL.Enable(EnableCap.ScissorTest); GL.Enable(EnableCap.ScissorTest);
foreach (var entry in profileData) foreach (var entry in ProfileData)
{ {
float y = GetLineY(yOffset, lineHeight, linePadding, true, verticalIndex++); float y = GetLineY(yOffset, lineHeight, linePadding, true, verticalIndex++);
width = fontService.DrawText(entry.Key.SessionItem, xOffset, y, lineHeight); width = FontServ.DrawText(entry.Key.SessionItem, xOffset, y, lineHeight);
if (width > maxWidth) if (width > maxWidth)
{ {
maxWidth = width; maxWidth = width;
@ -336,15 +336,15 @@ namespace Ryujinx
} }
GL.Disable(EnableCap.ScissorTest); GL.Disable(EnableCap.ScissorTest);
width = fontService.DrawText("Item", xOffset, Height - titleFontHeight, titleFontHeight); width = FontServ.DrawText("Item", xOffset, Height - titleFontHeight, titleFontHeight);
if (width > maxWidth) if (width > maxWidth)
maxWidth = width; maxWidth = width;
xOffset += maxWidth + columnSpacing; xOffset += maxWidth + columnSpacing;
buttons[(int)ButtonIndex.TagTitle].UpdateSize(0, Height - titleFontHeight, 0, (int)xOffset, titleFontHeight); Buttons[(int)ButtonIndex.TagTitle].UpdateSize(0, Height - titleFontHeight, 0, (int)xOffset, titleFontHeight);
// Time bars // Time bars
if (profileData.Count != 0) if (ProfileData.Count != 0)
{ {
width = Width - xOffset - 370; width = Width - xOffset - 370;
long maxAverage, maxTotal; long maxAverage, maxTotal;
@ -353,7 +353,7 @@ namespace Ryujinx
// Get max values // Get max values
var maxInstant = maxAverage = maxTotal = 0; var maxInstant = maxAverage = maxTotal = 0;
foreach (KeyValuePair<ProfileConfig, TimingInfo> kvp in profileData) foreach (KeyValuePair<ProfileConfig, TimingInfo> kvp in ProfileData)
{ {
maxInstant = Math.Max(maxInstant, kvp.Value.Instant); maxInstant = Math.Max(maxInstant, kvp.Value.Instant);
maxAverage = Math.Max(maxAverage, kvp.Value.AverageTime); maxAverage = Math.Max(maxAverage, kvp.Value.AverageTime);
@ -362,7 +362,7 @@ namespace Ryujinx
GL.Enable(EnableCap.ScissorTest); GL.Enable(EnableCap.ScissorTest);
GL.Begin(PrimitiveType.Triangles); GL.Begin(PrimitiveType.Triangles);
foreach (var entry in profileData) foreach (var entry in ProfileData)
{ {
// Instant // Instant
GL.Color3(Color.Blue); GL.Color3(Color.Blue);
@ -413,44 +413,44 @@ namespace Ryujinx
GL.Disable(EnableCap.ScissorTest); GL.Disable(EnableCap.ScissorTest);
} }
fontService.DrawText("Blue: Instant, Green: Avg, Red: Total", xOffset, Height - titleFontHeight, titleFontHeight); FontServ.DrawText("Blue: Instant, Green: Avg, Red: Total", xOffset, Height - titleFontHeight, titleFontHeight);
xOffset = Width - 360; xOffset = Width - 360;
// Display timestamps // Display timestamps
verticalIndex = 0; verticalIndex = 0;
GL.Enable(EnableCap.ScissorTest); GL.Enable(EnableCap.ScissorTest);
foreach (var entry in profileData) foreach (var entry in ProfileData)
{ {
float y = GetLineY(yOffset, lineHeight, linePadding, true, verticalIndex++); float y = GetLineY(yOffset, lineHeight, linePadding, true, verticalIndex++);
fontService.DrawText($"{Profile.ConvertTicksToMS(entry.Value.Instant):F3} ({entry.Value.InstantCount})", xOffset, y, lineHeight); FontServ.DrawText($"{Profile.ConvertTicksToMS(entry.Value.Instant):F3} ({entry.Value.InstantCount})", xOffset, y, lineHeight);
fontService.DrawText($"{Profile.ConvertTicksToMS(entry.Value.AverageTime):F3}", columnSpacing + 120 + xOffset, y, lineHeight); FontServ.DrawText($"{Profile.ConvertTicksToMS(entry.Value.AverageTime):F3}", columnSpacing + 120 + xOffset, y, lineHeight);
fontService.DrawText($"{Profile.ConvertTicksToMS(entry.Value.TotalTime):F3}", columnSpacing + columnSpacing + 200 + xOffset, y, lineHeight); FontServ.DrawText($"{Profile.ConvertTicksToMS(entry.Value.TotalTime):F3}", columnSpacing + columnSpacing + 200 + xOffset, y, lineHeight);
} }
GL.Disable(EnableCap.ScissorTest); GL.Disable(EnableCap.ScissorTest);
float yHeight = Height - titleFontHeight; float yHeight = Height - titleFontHeight;
fontService.DrawText("Instant (ms, count)", xOffset, yHeight, titleFontHeight); FontServ.DrawText("Instant (ms, count)", xOffset, yHeight, titleFontHeight);
buttons[(int)ButtonIndex.InstantTitle].UpdateSize((int)xOffset, (int)yHeight, 0, (int)(columnSpacing + 100), titleFontHeight); Buttons[(int)ButtonIndex.InstantTitle].UpdateSize((int)xOffset, (int)yHeight, 0, (int)(columnSpacing + 100), titleFontHeight);
fontService.DrawText("Average (ms)", columnSpacing + 120 + xOffset, yHeight, titleFontHeight); FontServ.DrawText("Average (ms)", columnSpacing + 120 + xOffset, yHeight, titleFontHeight);
buttons[(int)ButtonIndex.AverageTitle].UpdateSize((int)(columnSpacing + 120 + xOffset), (int)yHeight, 0, (int)(columnSpacing + 100), titleFontHeight); Buttons[(int)ButtonIndex.AverageTitle].UpdateSize((int)(columnSpacing + 120 + xOffset), (int)yHeight, 0, (int)(columnSpacing + 100), titleFontHeight);
fontService.DrawText("Total (ms)", columnSpacing + columnSpacing + 200 + xOffset, yHeight, titleFontHeight); FontServ.DrawText("Total (ms)", columnSpacing + columnSpacing + 200 + xOffset, yHeight, titleFontHeight);
buttons[(int)ButtonIndex.TotalTitle].UpdateSize((int)(columnSpacing + columnSpacing + 200 + xOffset), (int)yHeight, 0, Width, titleFontHeight); Buttons[(int)ButtonIndex.TotalTitle].UpdateSize((int)(columnSpacing + columnSpacing + 200 + xOffset), (int)yHeight, 0, Width, titleFontHeight);
// Show/Hide Inactive // Show/Hide Inactive
float widthShowHideButton = buttons[(int)ButtonIndex.ShowHideInactive].UpdateSize($"{(showInactive ? "Hide" : "Show")} Inactive", 5, 5, 4, 16); float widthShowHideButton = Buttons[(int)ButtonIndex.ShowHideInactive].UpdateSize($"{(ShowInactive ? "Hide" : "Show")} Inactive", 5, 5, 4, 16);
// Play/Pause // Play/Pause
width = buttons[(int)ButtonIndex.Pause].UpdateSize(Paused ? "Play" : "Pause", 15 + (int)widthShowHideButton, 5, 4, 16) + widthShowHideButton; width = Buttons[(int)ButtonIndex.Pause].UpdateSize(Paused ? "Play" : "Pause", 15 + (int)widthShowHideButton, 5, 4, 16) + widthShowHideButton;
// Filter bar // Filter bar
fontService.DrawText($"{(regexEnabled ? "Regex " : "Filter")}: {FilterText}", 25 + width, 7, 16); FontServ.DrawText($"{(RegexEnabled ? "Regex " : "Filter")}: {FilterText}", 25 + width, 7, 16);
buttons[(int) ButtonIndex.FilterBar].UpdateSize((int)(25 + width), 0, 0, Width, filterHeight); Buttons[(int) ButtonIndex.FilterBar].UpdateSize((int)(25 + width), 0, 0, Width, filterHeight);
// Draw buttons // Draw buttons
foreach (ProfileButton button in buttons) foreach (ProfileButton button in Buttons)
{ {
button.Draw(); button.Draw();
} }
@ -522,7 +522,7 @@ namespace Ryujinx
protected override void OnMouseUp(MouseButtonEventArgs e) protected override void OnMouseUp(MouseButtonEventArgs e)
{ {
foreach (ProfileButton button in buttons) foreach (ProfileButton button in Buttons)
{ {
if (button.ProcessClick(e.X, Height - e.Y)) if (button.ProcessClick(e.X, Height - e.Y))
return; return;
@ -535,11 +535,11 @@ namespace Ryujinx
protected override void OnMouseWheel(MouseWheelEventArgs e) protected override void OnMouseWheel(MouseWheelEventArgs e)
{ {
scrollPos += e.Delta * -30; ScrollPos += e.Delta * -30;
if (scrollPos < minScroll) if (ScrollPos < MinScroll)
scrollPos = minScroll; ScrollPos = MinScroll;
if (scrollPos > maxScroll) if (ScrollPos > MaxScroll)
scrollPos = maxScroll; ScrollPos = MaxScroll;
} }
} }
} }

View file

@ -4,18 +4,19 @@ namespace Ryujinx.Profiler.UI
{ {
public class ProfileWindowManager public class ProfileWindowManager
{ {
private ProfileWindow window; private ProfileWindow Window;
private Thread ProfileThread;
public ProfileWindowManager() public ProfileWindowManager()
{ {
if (Profile.ProfilingEnabled()) if (Profile.ProfilingEnabled())
{ {
Thread profileThread = new Thread(() => ProfileThread = new Thread(() =>
{ {
window = new ProfileWindow(); Window = new ProfileWindow();
window.Run(60, 60); Window.Run(60, 60);
}); });
profileThread.Start(); ProfileThread.Start();
} }
} }
@ -23,8 +24,21 @@ namespace Ryujinx.Profiler.UI
{ {
if (Profile.ProfilingEnabled()) if (Profile.ProfilingEnabled())
{ {
window.ToggleVisible(); Window.ToggleVisible();
} }
} }
public void Close()
{
if (Window != null)
{
Window.Close();
Window.Dispose();
}
ProfileThread.Join();
Window = null;
}
} }
} }

View file

@ -19,7 +19,7 @@ namespace Ryujinx.Profiler.UI.SharpFontHelpers
private const int SheetWidth = 256; private const int SheetWidth = 256;
private const int SheetHeight = 256; private const int SheetHeight = 256;
private int ScreenWidth, ScreenHeight; private int ScreenWidth, ScreenHeight;
private int characterTextureSheet; private int CharacterTextureSheet;
private CharacterInfo[] characters; private CharacterInfo[] characters;
public Color fontColor = Color.Black; public Color fontColor = Color.Black;
@ -62,8 +62,8 @@ namespace Ryujinx.Profiler.UI.SharpFontHelpers
} }
// Convert raw data into texture // Convert raw data into texture
characterTextureSheet = GL.GenTexture(); CharacterTextureSheet = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, characterTextureSheet); GL.BindTexture(TextureTarget.Texture2D, CharacterTextureSheet);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
@ -93,7 +93,7 @@ namespace Ryujinx.Profiler.UI.SharpFontHelpers
if (draw) if (draw)
{ {
// Use font map texture // Use font map texture
GL.BindTexture(TextureTarget.Texture2D, characterTextureSheet); GL.BindTexture(TextureTarget.Texture2D, CharacterTextureSheet);
// Enable blending and textures // Enable blending and textures
GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Texture2D);