From: Jean-Philippe Bruyère Date: Fri, 2 Jul 2021 12:59:09 +0000 (+0200) Subject: lock on ext method search, IList in dbg log X-Git-Tag: v0.9.5-beta~12 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=feeb0691af647cad8f7ce7c60fd3ec14591df56a;p=jp%2Fcrow.git lock on ext method search, IList in dbg log --- diff --git a/Crow/src/IML/CompilerServices.cs b/Crow/src/IML/CompilerServices.cs index 32bb258f..e5d426d1 100644 --- a/Crow/src/IML/CompilerServices.cs +++ b/Crow/src/IML/CompilerServices.cs @@ -387,26 +387,28 @@ namespace Crow.IML internal static MethodInfo SearchExtMethod (Type t, string methodName) { string key = t.Name + "." + methodName; - if (knownExtMethods.ContainsKey (key)) - return knownExtMethods [key]; - - //System.Diagnostics.Console.WriteLine ($"*** search extension method: {t};{methodName} => key={key}"); - - MethodInfo mi = null; - if (!TryGetExtensionMethods (Assembly.GetEntryAssembly (), t, methodName, out mi)) { - if (!TryGetExtensionMethods (t.Module.Assembly, t, methodName, out mi)) { - foreach (Assembly a in Interface.crowAssemblies) { - if (TryGetExtensionMethods (a, t, methodName, out mi)) - break; + lock (knownExtMethods) { + if (knownExtMethods.ContainsKey (key)) + return knownExtMethods [key]; + + //System.Diagnostics.Console.WriteLine ($"*** search extension method: {t};{methodName} => key={key}"); + + MethodInfo mi = null; + if (!TryGetExtensionMethods (Assembly.GetEntryAssembly (), t, methodName, out mi)) { + if (!TryGetExtensionMethods (t.Module.Assembly, t, methodName, out mi)) { + foreach (Assembly a in Interface.crowAssemblies) { + if (TryGetExtensionMethods (a, t, methodName, out mi)) + break; + } + if (mi == null) + TryGetExtensionMethods (Assembly.GetExecutingAssembly (), t, methodName, out mi);//crow Assembly } - if (mi == null) - TryGetExtensionMethods (Assembly.GetExecutingAssembly (), t, methodName, out mi);//crow Assembly } - } - //add key even if mi is null to prevent searching again and again for propertyless bindings - knownExtMethods.Add (key, mi); - return mi; + //add key even if mi is null to prevent searching again and again for propertyless bindings + knownExtMethods.Add (key, mi); + return mi; + } } public static bool TryGetExtensionMethods (Assembly assembly, Type extendedType, string methodName, out MethodInfo foundMI) diff --git a/Crow/src/Mono.Cairo/Context.cs b/Crow/src/Mono.Cairo/Context.cs index eb855157..5ed2bbd4 100644 --- a/Crow/src/Mono.Cairo/Context.cs +++ b/Crow/src/Mono.Cairo/Context.cs @@ -210,7 +210,7 @@ namespace Crow.Cairo { } } - public void SetDash (double [] dashes, double offset) + public void SetDash (double [] dashes, double offset = 0) { NativeMethods.cairo_set_dash (handle, dashes, dashes.Length, offset); } diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index 42f5da83..7255ca45 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -1556,6 +1556,13 @@ namespace Crow /// query a repaint, if control is cached, cache will not be updated and simply repainted. /// if not cached, repaint will trigger the onDraw method. /// + /// + /// This could be usefull in widget with complex drawing, that need some markers on top: the main part + /// of the drawing could take place in the onDraw method, and the markers (single line, rectangle, ...) + /// could be drawn in the Paint method. Such widget must have 'CacheEnabled=true' and to simply update the + /// markers without a full redraw, just call 'RegisterForRepaint'. + /// + /// public void RegisterForRepaint () { if (RegisteredLayoutings == LayoutingType.None && !IsDirty) IFace.EnqueueForRepaint (this); diff --git a/CrowDbgShared/CrowDbgShared.csproj b/CrowDbgShared/CrowDbgShared.csproj deleted file mode 100644 index 0ae49780..00000000 --- a/CrowDbgShared/CrowDbgShared.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - Library - netstandard2.1 - false - - - - - - - - diff --git a/CrowDbgShared/src/SharedDelegates.cs b/CrowDbgShared/src/SharedDelegates.cs deleted file mode 100644 index aee1ef1e..00000000 --- a/CrowDbgShared/src/SharedDelegates.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2013-2021 Bruyère Jean-Philippe jp_bruyere@hotmail.com -// -// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) - -using System; -using System.IO; -using System.Diagnostics; -using System.Collections.Generic; -using System.Linq; -using Glfw; - -namespace CrowDbgShared -{ - public delegate void InterfaceResizeDelegate(int a, int b); - public delegate bool InterfaceMouseMoveDelegate(int a, int b); - public delegate bool InterfaceMouseButtonDelegate(MouseButton button); - public delegate void VoidDelegate(); - public delegate IntPtr IntPtrGetterDelegate(); -} - diff --git a/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs b/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs index 89cf3e0c..2ac0326f 100644 --- a/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs +++ b/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs @@ -47,8 +47,8 @@ namespace Crow DbgWidgetRecord curWidget, hoverWidget; DbgEvent curEvent, hoverEvent; - List events = new List (); - List widgets = new List (); + IList events = new List (); + IList widgets = new List (); public DbgEvtType Filter { @@ -61,7 +61,7 @@ namespace Crow RegisterForGraphicUpdate(); } } - public List Events { + public IList Events { get => events; set { if (events == value) @@ -91,7 +91,7 @@ namespace Crow RegisterForGraphicUpdate (); } } - public List Widgets { + public IList Widgets { get => widgets; set { if (widgets == value) @@ -159,6 +159,7 @@ namespace Crow return; hoverEvent = value; NotifyValueChanged (nameof (HoverEvent), hoverEvent); + RegisterForRepaint (); } } @@ -201,8 +202,20 @@ namespace Crow updateMargins (); } } - - void drawEvents (Context ctx, List evts) + RectangleD getWidgetEvtBounds (DbgEvent evt, ref Rectangle cb, double penY) { + double x = xScale * (evt.begin - minTicks - ScrollX); + double w = Math.Max (Math.Max (2.0, 2.0 * xScale), (double)(evt.end - evt.begin) * xScale); + if (x < 0.0) { + w += x; + x = 0.0; + } + x += leftMargin + cb.Left; + double rightDiff = x + w - cb.Right; + if (rightDiff > 0) + w -= rightDiff; + return new RectangleD(x, penY, w, fe.Height); + } + void drawEvents (Context ctx, IList evts) { if (evts == null || evts.Count == 0) return; @@ -224,26 +237,8 @@ namespace Crow penY += (lIdx) * fe.Height; ctx.SetSource (evt.Color); - - double x = xScale * (evt.begin - minTicks - ScrollX); - double w = Math.Max (Math.Max (2.0, 2.0 * xScale), (double)(evt.end - evt.begin) * xScale); - if (x < 0.0) { - w += x; - x = 0.0; - } - x += leftMargin + cb.Left; - double rightDiff = x + w - cb.Right; - if (rightDiff > 0) - w -= rightDiff; - RectangleD r = new RectangleD(x, penY, w, fe.Height); - ctx.Rectangle (r); + ctx.Rectangle (getWidgetEvtBounds (evt, ref cb, penY)); ctx.Fill (); - /*if (evt == CurrentEvent) { - r.Inflate(2,2); - ctx.SetSource(Colors.White); - ctx.Rectangle(r); - ctx.Stroke(); - }*/ } } else if (evt.type.HasFlag (DbgEvtType.IFace)) { double x = xScale * (evt.begin - minTicks - ScrollX); @@ -400,6 +395,12 @@ namespace Crow ctx.SetSource (0.1, 0.1, 0.1, 0.4); ctx.Rectangle (ContextCoordinates (r)); ctx.Fill (); + + if (hoverEvent is DbgWidgetEvent wevt) { + ctx.SetSource (1.0,1.0,1.0,0.7); + ctx.SetDash (new double[] {1, 2}); + ctx.Rectangle ((Rectangle)getWidgetEvtBounds (wevt, ref cb, y).Inflated (1), 1); + } } if (currentLine >= ScrollY && currentLine < scrollY + visibleLines) { @@ -439,6 +440,8 @@ namespace Crow ctx.SetSource (Colors.Black); ctx.ShowText (str); + + } public override void OnLayoutChanges (LayoutingType layoutType) { @@ -477,7 +480,7 @@ namespace Crow if (lastLine >= 0 && hoverLine >= 0) ScrollY += lastLine - hoverLine; updateMouseLocalPos (e.Position); - } else { + } else if (widgets != null) { HoverWidget = (hoverLine < 0 || hoverLine >= widgets.Count) ? null : widgets [hoverLine]; //HoverEvent = hoverWidget?.Events.FirstOrDefault (ev => ev.begin <= hoverTick && ev.end >= hoverTick); double tickPerPixel = (double)visibleTicks / ClientRectangle.Width; diff --git a/Samples/DebugLogAnalyzer/src/DebugInterface.cs b/Samples/DebugLogAnalyzer/src/DebugInterface.cs index 64de2163..4f6a84aa 100644 --- a/Samples/DebugLogAnalyzer/src/DebugInterface.cs +++ b/Samples/DebugLogAnalyzer/src/DebugInterface.cs @@ -13,7 +13,7 @@ namespace Crow static DebugInterface() { DbgLogger.IncludeEvents = DbgEvtType.None; DbgLogger.DiscardEvents = DbgEvtType.None; - DbgLogger.ConsoleOutput = true; + DbgLogger.ConsoleOutput = false; } public DebugInterface (IntPtr hWin) : base (hWin) { diff --git a/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs b/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs index 38d94f3d..a1bb8156 100644 --- a/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs +++ b/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs @@ -120,15 +120,6 @@ namespace Crow NotifyValueChangedAuto (discardedEvents); } } - public bool DebugLogToFile { - get => initialized ? !(bool)fiDbg_ConsoleOutput.GetValue (dbgIFace) : false; - set { - if (!initialized || DebugLogToFile == value) - return; - fiDbg_ConsoleOutput.SetValue (dbgIFace, !value); - NotifyValueChangedAuto (DebugLogToFile); - } - } public string DebugLogFilePath { get => Configuration.Global.Get ("DebugLogFilePath"); set { diff --git a/Samples/DebugLogAnalyzer/ui/dbg.style b/Samples/DebugLogAnalyzer/ui/dbg.style index 33a5e9f4..ee2b14c1 100644 --- a/Samples/DebugLogAnalyzer/ui/dbg.style +++ b/Samples/DebugLogAnalyzer/ui/dbg.style @@ -17,6 +17,7 @@ DbgLogViewer { MouseWheelSpeed="3"; Font="mono, 8"; Background="Onyx"; + CacheEnabled = "true"; } DbgEventView { Height="Fit"; @@ -29,4 +30,8 @@ labWidgetRecordList { Margin="0"; Width="24"; TextAlignment="Right"; +} + +DbgEventWidget { + CacheEnabled = "true"; } \ No newline at end of file diff --git a/Samples/DebugLogAnalyzer/ui/main.crow b/Samples/DebugLogAnalyzer/ui/main.crow index 28433b11..d6ed6054 100644 --- a/Samples/DebugLogAnalyzer/ui/main.crow +++ b/Samples/DebugLogAnalyzer/ui/main.crow @@ -70,11 +70,10 @@