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