Add profile events for undo operations
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FlaxEditor.History;
|
||||
using FlaxEditor.Utilities;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.Collections;
|
||||
|
||||
namespace FlaxEditor
|
||||
@@ -38,9 +39,6 @@ namespace FlaxEditor
|
||||
/// <summary>
|
||||
/// Gets the undo operations stack.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The undo operations stack.
|
||||
/// </value>
|
||||
public HistoryStack UndoOperationsStack { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -136,8 +134,11 @@ namespace FlaxEditor
|
||||
{
|
||||
if (!Enabled)
|
||||
return;
|
||||
Profiler.BeginEvent("Undo.RecordBegin");
|
||||
|
||||
_snapshots.Add(snapshotInstance, new UndoInternal(snapshotInstance, actionString));
|
||||
|
||||
Profiler.EndEvent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -150,11 +151,10 @@ namespace FlaxEditor
|
||||
{
|
||||
if (!Enabled)
|
||||
return;
|
||||
Profiler.BeginEvent("Undo.RecordEnd");
|
||||
|
||||
if (snapshotInstance == null)
|
||||
{
|
||||
snapshotInstance = _snapshots.Last().Key;
|
||||
}
|
||||
var action = _snapshots[snapshotInstance].End(snapshotInstance);
|
||||
_snapshots.Remove(snapshotInstance);
|
||||
|
||||
@@ -178,6 +178,8 @@ namespace FlaxEditor
|
||||
UndoOperationsStack.Push(action);
|
||||
OnAction(action);
|
||||
}
|
||||
|
||||
Profiler.EndEvent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -233,8 +235,11 @@ namespace FlaxEditor
|
||||
{
|
||||
if (!Enabled)
|
||||
return;
|
||||
Profiler.BeginEvent("Undo.RecordMultiBegin");
|
||||
|
||||
_snapshots.Add(snapshotInstances, new UndoMultiInternal(snapshotInstances, actionString));
|
||||
|
||||
Profiler.EndEvent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -247,11 +252,10 @@ namespace FlaxEditor
|
||||
{
|
||||
if (!Enabled)
|
||||
return;
|
||||
Profiler.BeginEvent("Undo.RecordMultiEnd");
|
||||
|
||||
if (snapshotInstance == null)
|
||||
{
|
||||
snapshotInstance = (object[])_snapshots.Last().Key;
|
||||
}
|
||||
var action = _snapshots[snapshotInstance].End(snapshotInstance);
|
||||
_snapshots.Remove(snapshotInstance);
|
||||
|
||||
@@ -275,6 +279,8 @@ namespace FlaxEditor
|
||||
UndoOperationsStack.Push(action);
|
||||
OnAction(action);
|
||||
}
|
||||
|
||||
Profiler.EndEvent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -325,12 +331,10 @@ namespace FlaxEditor
|
||||
{
|
||||
if (action == null)
|
||||
throw new ArgumentNullException();
|
||||
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
UndoOperationsStack.Push(action);
|
||||
|
||||
OnAction(action);
|
||||
}
|
||||
|
||||
@@ -341,11 +345,14 @@ namespace FlaxEditor
|
||||
{
|
||||
if (!Enabled || !CanUndo)
|
||||
return;
|
||||
Profiler.BeginEvent("Undo.PerformUndo");
|
||||
|
||||
var action = (IUndoAction)UndoOperationsStack.PopHistory();
|
||||
action.Undo();
|
||||
|
||||
OnUndo(action);
|
||||
|
||||
Profiler.EndEvent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -355,11 +362,14 @@ namespace FlaxEditor
|
||||
{
|
||||
if (!Enabled || !CanRedo)
|
||||
return;
|
||||
Profiler.BeginEvent("Undo.PerformRedo");
|
||||
|
||||
var action = (IUndoAction)UndoOperationsStack.PopReverse();
|
||||
action.Do();
|
||||
|
||||
OnRedo(action);
|
||||
|
||||
Profiler.EndEvent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user