From 61d58bc83b6e4af1a7e98e30c3fbdaf31388026a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Fri, 23 Jul 2021 07:58:34 +0200 Subject: [PATCH] ctx & surf debug events --- Crow/src/DebugUtils/DbgEvtType.cs | 3 +++ Crow/src/DebugUtils/DbgWidgetEvent.cs | 4 +++ Crow/src/DebugUtils/DebugLogger.cs | 2 +- Crow/src/ExtensionsMethods.cs | 9 +++++-- .../src/DebugInterfaceWidget.cs | 26 +++++++++++++++++++ Samples/DebugLogAnalyzer/ui/main.crow | 1 + 6 files changed, 42 insertions(+), 3 deletions(-) diff --git a/Crow/src/DebugUtils/DbgEvtType.cs b/Crow/src/DebugUtils/DbgEvtType.cs index be7f66dd..89e86076 100644 --- a/Crow/src/DebugUtils/DbgEvtType.cs +++ b/Crow/src/DebugUtils/DbgEvtType.cs @@ -75,6 +75,9 @@ namespace Crow GOUpdateCache = Widget | Drawing | 0x03, GOPaintCache = Widget | Drawing | 0x04, GOPaint = Widget | Drawing | 0x05, + GOCreateSurface = Widget | Drawing | 0x06, + GOCreateContext = Widget | Drawing | 0x07, + GOLockUpdate = Widget | Lock | 0x01, GOLockClipping = Widget | Lock | 0x02, diff --git a/Crow/src/DebugUtils/DbgWidgetEvent.cs b/Crow/src/DebugUtils/DbgWidgetEvent.cs index 383fc94a..d147ba25 100644 --- a/Crow/src/DebugUtils/DbgWidgetEvent.cs +++ b/Crow/src/DebugUtils/DbgWidgetEvent.cs @@ -52,6 +52,10 @@ namespace Crow.DebugLogger return Colors.MediumVioletRed; case DbgEvtType.GODraw: return Colors.SteelBlue; + case DbgEvtType.GOCreateSurface: + return Colors.SkyBlue; + case DbgEvtType.GOCreateContext: + return Colors.DeepSkyBlue; case DbgEvtType.GORecreateCache: return Colors.CornflowerBlue; case DbgEvtType.GOUpdateCache: diff --git a/Crow/src/DebugUtils/DebugLogger.cs b/Crow/src/DebugUtils/DebugLogger.cs index b773b990..07313382 100644 --- a/Crow/src/DebugUtils/DebugLogger.cs +++ b/Crow/src/DebugUtils/DebugLogger.cs @@ -265,7 +265,7 @@ lock (logMutex) { public static void Save(Interface iface, string dbgLogFilePath = "debug.log") { #if DEBUG_LOG using (Stream stream = new FileStream (dbgLogFilePath, FileMode.Create, FileAccess.Write)) - Save (iface, stream); + Save (iface, stream, 0); Console.WriteLine ($"Crow Debug Log saved to: {System.IO.Path.GetFullPath(dbgLogFilePath)}"); #endif } diff --git a/Crow/src/ExtensionsMethods.cs b/Crow/src/ExtensionsMethods.cs index 45610be2..c435f7ca 100644 --- a/Crow/src/ExtensionsMethods.cs +++ b/Crow/src/ExtensionsMethods.cs @@ -193,8 +193,13 @@ namespace Crow return null; } - public static FileSystemInfo [] GetFileSystemInfosOrdered (this DirectoryInfo di) - => di.GetFileSystemInfos ().OrderBy (f => f.Attributes).ThenBy (f => f.Name).ToArray (); + public static FileSystemInfo [] GetFileSystemInfosOrdered (this DirectoryInfo di) { + try { + return di.GetFileSystemInfos ().OrderBy (f => f.Attributes).ThenBy (f => f.Name).ToArray (); + } catch { + return null; + } + } internal static bool IsAnyLineBreakCharacter (this char c) => c == '\n' || c == '\r' || c == '\u0085' || c == '\u2028' || c == '\u2029'; diff --git a/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs b/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs index 3ba9faaa..c74bae64 100644 --- a/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs +++ b/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs @@ -129,6 +129,16 @@ namespace Crow NotifyValueChangedAuto (value); } } + public string DebugLogFileFolder => System.IO.Path.GetDirectoryName (DebugLogFilePath); + public Command CMDSelectDebugLogFilePath => new Command ("...", + () => { + FileDialog dlg = IFace.LoadIMLFragment (@" + "); + dlg.OkClicked += (sender, e) => DebugLogFilePath = (sender as FileDialog).SelectedFileFullPath; + dlg.DataSource = this; + } + ); int firstWidgetIndexToSave, lastWidgetIndexToSave; public int FirstWidgetIndexToSave { get => firstWidgetIndexToSave; @@ -430,7 +440,23 @@ namespace Crow } void loadLogFromDebugLogFilePath () { + DebugLogAnalyzer.Program dla = IFace as DebugLogAnalyzer.Program; + + widgets = new List(); + events = new List(); + DbgLogger.Load(DebugLogFilePath, events, widgets); + + lock (dla.UpdateMutex) { + for (int i = 0; i < widgets.Count; i++) { + widgets[i].listIndex = dla.Widgets.Count; + dla.Widgets.Add (widgets[i]); + } + for (int i = 0; i < events.Count; i++) { + dla.Events.Add (events[i]); + updateWidgetEvents (dla.Widgets, events[i]); + } + } } public virtual object GetScreenCoordinates () => ScreenCoordinates(Slot).TopLeft; diff --git a/Samples/DebugLogAnalyzer/ui/main.crow b/Samples/DebugLogAnalyzer/ui/main.crow index d6ed6054..bbeffe0f 100644 --- a/Samples/DebugLogAnalyzer/ui/main.crow +++ b/Samples/DebugLogAnalyzer/ui/main.crow @@ -73,6 +73,7 @@