diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-08-12 16:22:34 +0200 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-08-12 16:22:34 +0200 |
| commit | 950104a8d304ebc9e4499186bc4cac8e6721b6ff (patch) | |
| tree | 639937cae0cd246949eefc601a21fa859060bebf /Samples/DebugLogAnalyzer/src | |
| parent | b6ecef09f591097bac7450857b52dbb525469115 (diff) | |
it's now possible to run vkvgBackend in DebugLogView on cairo
Diffstat (limited to 'Samples/DebugLogAnalyzer/src')
| -rw-r--r-- | Samples/DebugLogAnalyzer/src/DebugInterface.cs | 36 | ||||
| -rw-r--r-- | Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs | 20 |
2 files changed, 33 insertions, 23 deletions
diff --git a/Samples/DebugLogAnalyzer/src/DebugInterface.cs b/Samples/DebugLogAnalyzer/src/DebugInterface.cs index 08927566..40656bfe 100644 --- a/Samples/DebugLogAnalyzer/src/DebugInterface.cs +++ b/Samples/DebugLogAnalyzer/src/DebugInterface.cs @@ -6,6 +6,7 @@ using System; using Crow.Drawing; using System.Threading; using Samples; +using System.Runtime.InteropServices; namespace Crow { @@ -18,7 +19,11 @@ namespace Crow public DebugInterface (IntPtr hWin) : base (hWin) { SolidBackground = false; - surf = CreateSurface (100, 100); + initBackend (true); + + clientRectangle = new Rectangle (0, 0, 100, 100); + CreateMainSurface (ref clientRectangle); + } public override void Run() @@ -30,14 +35,14 @@ namespace Crow }; t.Start (); } - public bool Terminate; + public bool ShutDown; string source; Action delRegisterForRepaint;//call RegisterForRepaint in the container widget (DebugInterfaceWidget) Action<Exception> delSetCurrentException; Func<object> delGetScreenCoordinate; void interfaceThread () { - while (!Terminate) { + while (!ShutDown) { try { Update(); @@ -70,20 +75,12 @@ namespace Crow Thread.Sleep(1000); } - if (IsDirty) { + if (IsDirty) delRegisterForRepaint(); - //Console.WriteLine ("[DbgIFace]RegisterForRepaint"); - } - + Thread.Sleep (UPDATE_INTERVAL); } } - public IntPtr SurfacePointer { - get { - lock(UpdateMutex) - return surf.Handle; - } - } public void RegisterDebugInterfaceCallback (object w){ Type t = w.GetType(); delRegisterForRepaint = (Action)Delegate.CreateDelegate(typeof(Action), w, t.GetMethod("RegisterForRepaint")); @@ -121,13 +118,18 @@ namespace Crow } } public void Resize (int width, int height) { - + if (!HaveVkvgBackend) + ProcessResize (new Rectangle(0,0,width, height)); + } + public override void ProcessResize(Rectangle bounds) { lock (UpdateMutex) { - clientRectangle = new Rectangle (0, 0, width, height); - surf?.Dispose(); - surf = CreateSurface (width, height); + clientRectangle = bounds.Size; + + CreateMainSurface (ref clientRectangle); + foreach (Widget g in GraphicTree) g.RegisterForLayouting (LayoutingType.All); + RegisterClip (clientRectangle); } } diff --git a/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs b/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs index 8da93de0..113e5e07 100644 --- a/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs +++ b/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs @@ -34,12 +34,12 @@ namespace Crow Action delResetDirtyState; Action delResetDebugger; Action<object, string> delSaveDebugLog; - Func<IntPtr> delGetSurfacePointer; + Func<IntPtr> delGetSurfacePointer; Action<string> delSetSource; FieldInfo fiDbg_IncludeEvents, fiDbg_DiscardEvents, fiDbg_ConsoleOutput; - bool initialized, recording; + bool initialized, recording, hasVkvgBackend; string crowDbgAssemblyLocation; DbgEvtType recordedEvents, discardedEvents; @@ -198,6 +198,11 @@ namespace Crow } crowLoadCtx = new AssemblyLoadContext("CrowDebuggerLoadContext"); + crowLoadCtx.Resolving += (context, assemblyName) => { + return crowLoadCtx.LoadFromAssemblyPath ( + System.IO.Path.Combine ( + System.IO.Path.GetDirectoryName(crowDbgAssemblyLocation), assemblyName.Name + ".dll")); + }; //using (crowLoadCtx.EnterContextualReflection()) { crowAssembly = crowLoadCtx.LoadFromAssemblyPath (crowDbgAssemblyLocation); @@ -210,7 +215,6 @@ namespace Crow } dbgIfaceType = thisAssembly.GetType("Crow.DebugInterface"); - dbgIFace = Activator.CreateInstance (dbgIfaceType, new object[] {IFace.WindowHandle}); delResize = (Action<int, int>)Delegate.CreateDelegate(typeof(Action<int, int>), @@ -252,6 +256,7 @@ namespace Crow null, debuggerType.GetMethod("Reset")); /*delSaveDebugLog = (Action<object, string>)Delegate.CreateDelegate(typeof(Action<object, string>), null, debuggerType.GetMethod("Save", new Type[] {dbgIfaceType, typeof(string)}));*/ + hasVkvgBackend = (bool)dbgIfaceType.GetField ("HaveVkvgBackend", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).GetValue (null); dbgIfaceType.GetMethod("RegisterDebugInterfaceCallback").Invoke (dbgIFace, new object[] {this} ); dbgIfaceType.GetMethod("Run").Invoke (dbgIFace, null); @@ -265,7 +270,6 @@ namespace Crow protected override void onDraw(Context gr) { - Console.WriteLine("onDraw"); gr.SetSource(Colors.RoyalBlue); gr.Paint(); } @@ -376,8 +380,12 @@ namespace Crow bmp?.Dispose (); if (initialized) { - delResize (Slot.Width, Slot.Height); - bmp = IFace.CreateSurface (delGetSurfacePointer()); + delResize (Slot.Width, Slot.Height); + if (hasVkvgBackend) + bmp = IFace.CreateSurfaceForData (delGetSurfacePointer(), Slot.Width, Slot.Height); + else + bmp = IFace.CreateSurface (delGetSurfacePointer()); + } else bmp = IFace.CreateSurface (Slot.Width, Slot.Height); |