Limit graph zoom and label start and stop
This commit is contained in:
parent
985117958c
commit
a6dec90b29
3 changed files with 50 additions and 23 deletions
|
@ -84,6 +84,11 @@ namespace Ryujinx.Profiler
|
||||||
return (long)(seconds * Stopwatch.Frequency);
|
return (long)(seconds * Stopwatch.Frequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long ConvertMSToTicks(double ms)
|
||||||
|
{
|
||||||
|
return (long)((ms / 1000) * Stopwatch.Frequency);
|
||||||
|
}
|
||||||
|
|
||||||
public static Dictionary<ProfileConfig, TimingInfo> GetProfilingData()
|
public static Dictionary<ProfileConfig, TimingInfo> GetProfilingData()
|
||||||
{
|
{
|
||||||
if (!ProfilingEnabled())
|
if (!ProfilingEnabled())
|
||||||
|
|
|
@ -265,23 +265,28 @@ namespace Ryujinx.Profiler.UI
|
||||||
{
|
{
|
||||||
ProcessEvents();
|
ProcessEvents();
|
||||||
|
|
||||||
switch (_graphControlKey)
|
if (_graphControlKey != Key.F35)
|
||||||
{
|
{
|
||||||
case Key.Left:
|
switch (_graphControlKey)
|
||||||
_graphPosition += (float)(GraphMoveSpeed * e.Time);
|
{
|
||||||
break;
|
case Key.Left:
|
||||||
|
_graphPosition += (long) (GraphMoveSpeed * e.Time);
|
||||||
|
break;
|
||||||
|
|
||||||
case Key.Right:
|
case Key.Right:
|
||||||
_graphPosition = MathF.Max(_graphPosition - (float)(GraphMoveSpeed * e.Time), 0);
|
_graphPosition = Math.Max(_graphPosition - (long) (GraphMoveSpeed * e.Time), 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Key.Up:
|
case Key.Up:
|
||||||
_graphZoom = MathF.Min(_graphZoom + (float)(GraphZoomSpeed * e.Time), 100.0f);
|
_graphZoom = MathF.Min(_graphZoom + (float) (GraphZoomSpeed * e.Time), 100.0f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Key.Down:
|
case Key.Down:
|
||||||
_graphZoom = MathF.Max(_graphZoom - (float)(GraphZoomSpeed * e.Time), 1f);
|
_graphZoom = MathF.Max(_graphZoom - (float) (GraphZoomSpeed * e.Time), 1f);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_redrawPending = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_processEventTimer = 0;
|
_processEventTimer = 0;
|
||||||
|
|
|
@ -6,11 +6,11 @@ namespace Ryujinx.Profiler.UI
|
||||||
{
|
{
|
||||||
public partial class ProfileWindow
|
public partial class ProfileWindow
|
||||||
{
|
{
|
||||||
private const float GraphMoveSpeed = 100;
|
private const float GraphMoveSpeed = 20000;
|
||||||
private const float GraphZoomSpeed = 5;
|
private const float GraphZoomSpeed = 10;
|
||||||
|
|
||||||
private float _graphZoom = 1;
|
private float _graphZoom = 1;
|
||||||
private float _graphPosition = 0;
|
private float _graphPosition = 0;
|
||||||
|
|
||||||
private void DrawGraph(float xOffset, float yOffset, float width)
|
private void DrawGraph(float xOffset, float yOffset, float width)
|
||||||
{
|
{
|
||||||
|
@ -19,9 +19,18 @@ namespace Ryujinx.Profiler.UI
|
||||||
int left, right;
|
int left, right;
|
||||||
float top, bottom;
|
float top, bottom;
|
||||||
|
|
||||||
int verticalIndex = 0;
|
int verticalIndex = 0;
|
||||||
float barHeight = (LineHeight - LinePadding);
|
float barHeight = (LineHeight - LinePadding);
|
||||||
long timeWidth = (long)(Profile.HistoryLength / _graphZoom);
|
long history = Profile.HistoryLength;
|
||||||
|
long timeWidthTicks = (long)(history / (double)_graphZoom);
|
||||||
|
long graphPositionTicks = Profile.ConvertMSToTicks(_graphPosition);
|
||||||
|
|
||||||
|
// Reset start point if out of bounds
|
||||||
|
if (timeWidthTicks + graphPositionTicks > history)
|
||||||
|
{
|
||||||
|
graphPositionTicks = history - timeWidthTicks;
|
||||||
|
_graphPosition = (float)Profile.ConvertTicksToMS(graphPositionTicks);
|
||||||
|
}
|
||||||
|
|
||||||
GL.Enable(EnableCap.ScissorTest);
|
GL.Enable(EnableCap.ScissorTest);
|
||||||
GL.Begin(PrimitiveType.Triangles);
|
GL.Begin(PrimitiveType.Triangles);
|
||||||
|
@ -30,8 +39,8 @@ namespace Ryujinx.Profiler.UI
|
||||||
GL.Color3(Color.Green);
|
GL.Color3(Color.Green);
|
||||||
foreach (Timestamp timestamp in entry.Value.GetAllTimestamps())
|
foreach (Timestamp timestamp in entry.Value.GetAllTimestamps())
|
||||||
{
|
{
|
||||||
left = (int)(xOffset + width + _graphPosition - (((float)_captureTime - timestamp.BeginTime) / timeWidth) * width);
|
left = (int)(xOffset + width - ((float)(_captureTime - (timestamp.BeginTime + graphPositionTicks)) / timeWidthTicks) * width);
|
||||||
right = (int)(xOffset + width + _graphPosition - (((float)_captureTime - timestamp.EndTime) / timeWidth) * width);
|
right = (int)(xOffset + width - ((float)(_captureTime - (timestamp.EndTime + graphPositionTicks)) / timeWidthTicks) * width);
|
||||||
bottom = GetLineY(yOffset, LineHeight, LinePadding, true, verticalIndex);
|
bottom = GetLineY(yOffset, LineHeight, LinePadding, true, verticalIndex);
|
||||||
top = bottom + barHeight;
|
top = bottom + barHeight;
|
||||||
|
|
||||||
|
@ -56,7 +65,7 @@ namespace Ryujinx.Profiler.UI
|
||||||
long entryBegin = entry.Value.BeginTime;
|
long entryBegin = entry.Value.BeginTime;
|
||||||
if (entryBegin != -1)
|
if (entryBegin != -1)
|
||||||
{
|
{
|
||||||
left = (int)(xOffset + width + _graphPosition - (((float)_captureTime - entryBegin) / timeWidth) * width);
|
left = (int)(xOffset + width + _graphPosition - (((float)_captureTime - entryBegin) / timeWidthTicks) * width);
|
||||||
bottom = GetLineY(yOffset, LineHeight, LinePadding, true, verticalIndex);
|
bottom = GetLineY(yOffset, LineHeight, LinePadding, true, verticalIndex);
|
||||||
top = bottom + barHeight;
|
top = bottom + barHeight;
|
||||||
right = (int)(xOffset + width);
|
right = (int)(xOffset + width);
|
||||||
|
@ -82,6 +91,14 @@ namespace Ryujinx.Profiler.UI
|
||||||
|
|
||||||
GL.End();
|
GL.End();
|
||||||
GL.Disable(EnableCap.ScissorTest);
|
GL.Disable(EnableCap.ScissorTest);
|
||||||
|
|
||||||
|
string label = $"-{MathF.Round(_graphPosition, 2)} ms";
|
||||||
|
|
||||||
|
// Dummy draw for measure
|
||||||
|
float labelWidth = _fontService.DrawText(label, 0, 0, LineHeight, false);
|
||||||
|
_fontService.DrawText(label, xOffset + width - labelWidth - LinePadding, FilterHeight + LinePadding, LineHeight);
|
||||||
|
|
||||||
|
_fontService.DrawText($"-{MathF.Round((float)(Profile.ConvertTicksToMS(timeWidthTicks) + _graphPosition), 2)} ms", xOffset + LinePadding, FilterHeight + LinePadding, LineHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue