Optimize managed memory allocations
This commit is contained in:
@@ -19,6 +19,7 @@ namespace FlaxEditor.GUI
|
||||
private Button _closeButton;
|
||||
private Button _minimizeButton;
|
||||
private Button _maximizeButton;
|
||||
private LocalizedString _charChromeRestore, _charChromeMaximize;
|
||||
private Window _window;
|
||||
#endif
|
||||
private MainMenuButton _selected;
|
||||
@@ -151,14 +152,12 @@ namespace FlaxEditor.GUI
|
||||
_maximizeButton.Clicked += () =>
|
||||
{
|
||||
if (_window.IsMaximized)
|
||||
{
|
||||
_window.Restore();
|
||||
}
|
||||
else
|
||||
{
|
||||
_window.Maximize();
|
||||
}
|
||||
};
|
||||
_charChromeRestore = ((char)EditorAssets.SegMDL2Icons.ChromeRestore).ToString();
|
||||
_charChromeMaximize = ((char)EditorAssets.SegMDL2Icons.ChromeMaximize).ToString();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -175,7 +174,7 @@ namespace FlaxEditor.GUI
|
||||
|
||||
if (_maximizeButton != null)
|
||||
{
|
||||
_maximizeButton.Text = ((char)(_window.IsMaximized ? EditorAssets.SegMDL2Icons.ChromeRestore : EditorAssets.SegMDL2Icons.ChromeMaximize)).ToString();
|
||||
_maximizeButton.Text = _window.IsMaximized ? _charChromeRestore : _charChromeMaximize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,18 +10,11 @@
|
||||
#include "FlaxEngine.Gen.h"
|
||||
#include "Engine/Core/Core.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Utilities.h"
|
||||
#include "Engine/Core/ObjectsRemovalService.h"
|
||||
#include "Engine/Core/Types/String.h"
|
||||
#include "Engine/Platform/Platform.h"
|
||||
#include "Engine/Platform/CPUInfo.h"
|
||||
#include "Engine/Platform/MemoryStats.h"
|
||||
#include "Engine/Platform/Window.h"
|
||||
#include "Engine/Platform/FileSystem.h"
|
||||
#include "Engine/Serialization/FileWriteStream.h"
|
||||
#include "Engine/Serialization/FileReadStream.h"
|
||||
#include "Engine/Level/Level.h"
|
||||
#include "Engine/Renderer/Renderer.h"
|
||||
#include "Engine/Physics/Physics.h"
|
||||
#include "Engine/Threading/Threading.h"
|
||||
#include "Engine/Threading/MainThreadTask.h"
|
||||
|
||||
@@ -60,15 +60,7 @@ namespace FlaxEngine
|
||||
|
||||
private static List<PostProcessEffect> _postFx;
|
||||
private static IntPtr[] _postFxPtr;
|
||||
private static readonly PostFxComparer _postFxComparer = new PostFxComparer();
|
||||
|
||||
internal sealed class PostFxComparer : IComparer<PostProcessEffect>
|
||||
{
|
||||
public int Compare(PostProcessEffect x, PostProcessEffect y)
|
||||
{
|
||||
return x.Order - y.Order;
|
||||
}
|
||||
}
|
||||
private static Comparison<PostProcessEffect> _postFxComparison = (x, y) => x.Order - y.Order;
|
||||
|
||||
internal IntPtr[] GetPostFx(out int count)
|
||||
{
|
||||
@@ -103,7 +95,7 @@ namespace FlaxEngine
|
||||
}
|
||||
|
||||
// Sort postFx
|
||||
_postFx.Sort(_postFxComparer);
|
||||
_postFx.Sort(_postFxComparison);
|
||||
|
||||
// Convert into unmanaged objects
|
||||
count = _postFx.Count;
|
||||
|
||||
@@ -12,6 +12,15 @@ namespace UtilsInternal
|
||||
{
|
||||
Platform::MemoryCopy(destination, source, length);
|
||||
}
|
||||
|
||||
MonoObject* ExtractArrayFromList(MonoObject* obj)
|
||||
{
|
||||
auto klass = mono_object_get_class(obj);
|
||||
auto field = mono_class_get_field_from_name(klass, "_items");
|
||||
MonoObject* o;
|
||||
mono_field_get_value(obj, field, &o);
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
namespace DebugLogHandlerInternal
|
||||
@@ -70,6 +79,7 @@ void registerFlaxEngineInternalCalls()
|
||||
{
|
||||
AnimGraphExecutor::initRuntime();
|
||||
ADD_INTERNAL_CALL("FlaxEngine.Utils::MemoryCopy", &UtilsInternal::MemoryCopy);
|
||||
ADD_INTERNAL_CALL("FlaxEngine.Utils::Internal_ExtractArrayFromList", &UtilsInternal::ExtractArrayFromList);
|
||||
ADD_INTERNAL_CALL("FlaxEngine.DebugLogHandler::Internal_LogWrite", &DebugLogHandlerInternal::LogWrite);
|
||||
ADD_INTERNAL_CALL("FlaxEngine.DebugLogHandler::Internal_Log", &DebugLogHandlerInternal::Log);
|
||||
ADD_INTERNAL_CALL("FlaxEngine.DebugLogHandler::Internal_LogException", &DebugLogHandlerInternal::LogException);
|
||||
|
||||
@@ -180,16 +180,12 @@ namespace FlaxEngine
|
||||
|
||||
internal static T[] ExtractArrayFromList<T>(List<T> list)
|
||||
{
|
||||
T[] result = null;
|
||||
if (list != null)
|
||||
{
|
||||
// TODO: move it to the native code
|
||||
var field = list.GetType().GetField("_items", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
result = (T[])field.GetValue(list);
|
||||
}
|
||||
return result;
|
||||
return list != null ? (T[])Internal_ExtractArrayFromList(list) : null;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern Array Internal_ExtractArrayFromList(object list);
|
||||
|
||||
/// <summary>
|
||||
/// Reads the color from the binary stream.
|
||||
/// </summary>
|
||||
@@ -249,7 +245,7 @@ namespace FlaxEngine
|
||||
{
|
||||
return new Int2(stream.ReadInt32(), stream.ReadInt32());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reads the Int3 from the binary stream.
|
||||
/// </summary>
|
||||
@@ -259,7 +255,7 @@ namespace FlaxEngine
|
||||
{
|
||||
return new Int3(stream.ReadInt32(), stream.ReadInt32(), stream.ReadInt32());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reads the Int4 from the binary stream.
|
||||
/// </summary>
|
||||
@@ -269,7 +265,7 @@ namespace FlaxEngine
|
||||
{
|
||||
return new Int4(stream.ReadInt32(), stream.ReadInt32(), stream.ReadInt32(), stream.ReadInt32());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reads the Quaternion from the binary stream.
|
||||
/// </summary>
|
||||
@@ -402,7 +398,7 @@ namespace FlaxEngine
|
||||
stream.Write(value.X);
|
||||
stream.Write(value.Y);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Writes the Int3 to the binary stream.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user