Limit graph zoom and label start and stop

This commit is contained in:
Andy Adshead 2019-01-29 03:12:13 +00:00
commit a6dec90b29
3 changed files with 50 additions and 23 deletions

View file

@ -84,6 +84,11 @@ namespace Ryujinx.Profiler
return (long)(seconds * Stopwatch.Frequency);
}
public static long ConvertMSToTicks(double ms)
{
return (long)((ms / 1000) * Stopwatch.Frequency);
}
public static Dictionary<ProfileConfig, TimingInfo> GetProfilingData()
{
if (!ProfilingEnabled())

View file

@ -265,14 +265,16 @@ namespace Ryujinx.Profiler.UI
{
ProcessEvents();
if (_graphControlKey != Key.F35)
{
switch (_graphControlKey)
{
case Key.Left:
_graphPosition += (float)(GraphMoveSpeed * e.Time);
_graphPosition += (long) (GraphMoveSpeed * e.Time);
break;
case Key.Right:
_graphPosition = MathF.Max(_graphPosition - (float)(GraphMoveSpeed * e.Time), 0);
_graphPosition = Math.Max(_graphPosition - (long) (GraphMoveSpeed * e.Time), 0);
break;
case Key.Up:
@ -284,6 +286,9 @@ namespace Ryujinx.Profiler.UI
break;
}
_redrawPending = true;
}
_processEventTimer = 0;
}
}

View file

@ -6,8 +6,8 @@ namespace Ryujinx.Profiler.UI
{
public partial class ProfileWindow
{
private const float GraphMoveSpeed = 100;
private const float GraphZoomSpeed = 5;
private const float GraphMoveSpeed = 20000;
private const float GraphZoomSpeed = 10;
private float _graphZoom = 1;
private float _graphPosition = 0;
@ -21,7 +21,16 @@ namespace Ryujinx.Profiler.UI
int verticalIndex = 0;
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.Begin(PrimitiveType.Triangles);
@ -30,8 +39,8 @@ namespace Ryujinx.Profiler.UI
GL.Color3(Color.Green);
foreach (Timestamp timestamp in entry.Value.GetAllTimestamps())
{
left = (int)(xOffset + width + _graphPosition - (((float)_captureTime - timestamp.BeginTime) / timeWidth) * width);
right = (int)(xOffset + width + _graphPosition - (((float)_captureTime - timestamp.EndTime) / timeWidth) * width);
left = (int)(xOffset + width - ((float)(_captureTime - (timestamp.BeginTime + graphPositionTicks)) / timeWidthTicks) * width);
right = (int)(xOffset + width - ((float)(_captureTime - (timestamp.EndTime + graphPositionTicks)) / timeWidthTicks) * width);
bottom = GetLineY(yOffset, LineHeight, LinePadding, true, verticalIndex);
top = bottom + barHeight;
@ -56,7 +65,7 @@ namespace Ryujinx.Profiler.UI
long entryBegin = entry.Value.BeginTime;
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);
top = bottom + barHeight;
right = (int)(xOffset + width);
@ -82,6 +91,14 @@ namespace Ryujinx.Profiler.UI
GL.End();
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);
}
}
}