From d65351d324043f7c9d74f6dcf966ea40792017a5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Mon, 2 Aug 2021 14:36:36 +0200 Subject: [PATCH] merge step 2 --- Crow/src/GraphicBackends/Mono.Cairo/Cairo.cs | 4 +- .../src/GraphicBackends/Mono.Cairo/Context.cs | 27 ++------ .../GraphicBackends/Mono.Cairo/GLSurface.cs | 2 +- .../Mono.Cairo/ImageSurface.cs | 2 +- Crow/src/GraphicBackends/Mono.Cairo/Matrix.cs | 2 +- .../Mono.Cairo/NativeMethods.cs | 12 ++-- Crow/src/GraphicBackends/Mono.Cairo/Region.cs | 2 +- .../src/GraphicBackends/Mono.Cairo/Surface.cs | 16 ++--- Crow/src/GraphicBackends/vkvg/Context.cs | 13 +++- Crow/src/GraphicBackends/vkvg/Surface.cs | 6 +- Crow/src/Interface.cs | 61 ++++++++++++------- Crow/src/Widgets/Widget.cs | 2 + Directory.Build.props | 15 ++++- Samples/DebugLogAnalyzer/src/DbgLogViewer.cs | 21 +++---- .../DebugLogAnalyzer/src/DebugInterface.cs | 6 +- .../src/DebugInterfaceWidget.cs | 4 +- Samples/PathPainter/Painter.cs | 14 ++--- Samples/PerfTests/Program.cs | 2 +- Samples/common/src/SampleBase.cs | 2 +- Samples/dragNdrop/dragNdrop.cs | 6 +- unitTests/TestBackend.cs | 2 +- 21 files changed, 124 insertions(+), 97 deletions(-) diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Cairo.cs b/Crow/src/GraphicBackends/Mono.Cairo/Cairo.cs index 6428304f..309c7f4a 100644 --- a/Crow/src/GraphicBackends/Mono.Cairo/Cairo.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Cairo.cs @@ -39,13 +39,13 @@ namespace Crow.Drawing public static class CairoAPI { static public int Version { get { - return Cairo.NativeMethods.cairo_version (); + return NativeMethods.cairo_version (); } } static public string VersionString { get { - IntPtr x = Cairo.NativeMethods.cairo_version_string (); + IntPtr x = NativeMethods.cairo_version_string (); return Marshal.PtrToStringAnsi (x); } } diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Context.cs b/Crow/src/GraphicBackends/Mono.Cairo/Context.cs index c69a4231..84c5fd40 100644 --- a/Crow/src/GraphicBackends/Mono.Cairo/Context.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Context.cs @@ -138,7 +138,7 @@ namespace Crow.Drawing { set { NativeMethods.cairo_set_antialias (handle, value); } } - public Cairo.Status Status { + public Status Status { get { return NativeMethods.cairo_status (handle); } @@ -170,7 +170,7 @@ namespace Crow.Drawing { } } - public Cairo.FillRule FillRule { + public FillRule FillRule { set { NativeMethods.cairo_set_fill_rule (handle, value); } @@ -190,7 +190,7 @@ namespace Crow.Drawing { } } - public Cairo.LineCap LineCap { + public LineCap LineCap { set { NativeMethods.cairo_set_line_cap (handle, value); } @@ -200,7 +200,7 @@ namespace Crow.Drawing { } } - public Cairo.LineJoin LineJoin { + public LineJoin LineJoin { set { NativeMethods.cairo_set_line_join (handle, value); } @@ -244,7 +244,7 @@ namespace Crow.Drawing { public Pattern GetSource () { var ptr = NativeMethods.cairo_get_source (handle); - return Cairo.Pattern.Lookup (ptr, false); + return Pattern.Lookup (ptr, false); } public double MiterLimit { @@ -272,7 +272,7 @@ namespace Crow.Drawing { } [Obsolete ("Use GetTarget/SetTarget")] - public Cairo.Surface Target { + public Surface Target { set { if (handle != IntPtr.Zero) NativeMethods.cairo_destroy (handle); @@ -816,21 +816,6 @@ namespace Crow.Drawing { SelectFontFace (family, slant, weight); } - [Obsolete("Use GetFontFace/SetFontFace")] - public FontFace ContextFontFace { - get { - return GetContextFontFace (); - } - set { - SetContextFontFace (value); - } - } - - public FontFace GetContextFontFace () - { - return Cairo.FontFace.Lookup (NativeMethods.cairo_get_font_face (handle), false); - } - public void SetContextFontFace (FontFace value) { NativeMethods.cairo_set_font_face (handle, value == null ? IntPtr.Zero : value.Handle); diff --git a/Crow/src/GraphicBackends/Mono.Cairo/GLSurface.cs b/Crow/src/GraphicBackends/Mono.Cairo/GLSurface.cs index 54522f5c..33042658 100644 --- a/Crow/src/GraphicBackends/Mono.Cairo/GLSurface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/GLSurface.cs @@ -38,7 +38,7 @@ namespace Crow.Drawing { public GLSurface (IntPtr ptr, bool own) : base (ptr, own) {} - public GLSurface (Device device, Cairo.Content content, uint tex, int width, int height) + public GLSurface (Device device, Content content, uint tex, int width, int height) : base (NativeMethods.cairo_gl_surface_create_for_texture (device.Handle, (uint)content, tex, width, height), true) {} diff --git a/Crow/src/GraphicBackends/Mono.Cairo/ImageSurface.cs b/Crow/src/GraphicBackends/Mono.Cairo/ImageSurface.cs index a1a182ca..28330105 100644 --- a/Crow/src/GraphicBackends/Mono.Cairo/ImageSurface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/ImageSurface.cs @@ -49,7 +49,7 @@ namespace Crow.Drawing { } [Obsolete ("Use ImageSurface (byte[] data, Cairo.Format format, int width, int height, int stride)")] - public ImageSurface (ref byte[] data, Cairo.Format format, int width, int height, int stride) + public ImageSurface (ref byte[] data, Format format, int width, int height, int stride) : this (data, format, width, height, stride) { } diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Matrix.cs b/Crow/src/GraphicBackends/Mono.Cairo/Matrix.cs index fc9f393f..0224fd5f 100644 --- a/Crow/src/GraphicBackends/Mono.Cairo/Matrix.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Matrix.cs @@ -114,7 +114,7 @@ namespace Crow.Drawing { NativeMethods.cairo_matrix_rotate (this, radians); } - public Cairo.Status Invert () + public Status Invert () { return NativeMethods.cairo_matrix_invert (this); } diff --git a/Crow/src/GraphicBackends/Mono.Cairo/NativeMethods.cs b/Crow/src/GraphicBackends/Mono.Cairo/NativeMethods.cs index 6bce9f19..f547661e 100644 --- a/Crow/src/GraphicBackends/Mono.Cairo/NativeMethods.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/NativeMethods.cs @@ -270,13 +270,13 @@ namespace Crow.Drawing #region Image Surface [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)] - internal static extern IntPtr cairo_image_surface_create (Cairo.Format format, int width, int height); + internal static extern IntPtr cairo_image_surface_create (Format format, int width, int height); [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)] - internal static extern IntPtr cairo_image_surface_create_for_data (byte[] data, Cairo.Format format, int width, int height, int stride); + internal static extern IntPtr cairo_image_surface_create_for_data (byte[] data, Format format, int width, int height, int stride); [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)] - internal static extern IntPtr cairo_image_surface_create_for_data (IntPtr data, Cairo.Format format, int width, int height, int stride); + internal static extern IntPtr cairo_image_surface_create_for_data (IntPtr data, Format format, int width, int height, int stride); [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)] internal static extern IntPtr cairo_image_surface_create_from_png (string filename); @@ -698,7 +698,7 @@ namespace Crow.Drawing internal static extern int cairo_get_dash_count (IntPtr cr); [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)] - internal static extern void cairo_set_fill_rule (IntPtr cr, Cairo.FillRule fill_rule); + internal static extern void cairo_set_fill_rule (IntPtr cr, FillRule fill_rule); [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)] internal static extern void cairo_set_font_face (IntPtr cr, IntPtr fontFace); @@ -728,7 +728,7 @@ namespace Crow.Drawing internal static extern void cairo_set_miter_limit (IntPtr cr, double limit); [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)] - internal static extern void cairo_set_operator (IntPtr cr, Cairo.Operator op); + internal static extern void cairo_set_operator (IntPtr cr, Operator op); [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)] internal static extern void cairo_set_source (IntPtr cr, IntPtr pattern); @@ -774,7 +774,7 @@ namespace Crow.Drawing #region Surface [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)] - internal static extern IntPtr cairo_surface_create_similar (IntPtr surface, Cairo.Content content, int width, int height); + internal static extern IntPtr cairo_surface_create_similar (IntPtr surface, Content content, int width, int height); [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)] internal static extern void cairo_surface_destroy (IntPtr surface); diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Region.cs b/Crow/src/GraphicBackends/Mono.Cairo/Region.cs index efb8e8f0..9cac680b 100644 --- a/Crow/src/GraphicBackends/Mono.Cairo/Region.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Region.cs @@ -198,6 +198,6 @@ namespace Crow.Drawing NativeMethods.cairo_region_destroy (Handle); handle = NativeMethods.cairo_region_create (); } - public bool OverlapOut (Crow.Rectangle rectangle) => Contains (p.Slot) == RegionOverlap.Out; + public bool OverlapOut (Crow.Rectangle rectangle) => Contains (rectangle) == RegionOverlap.Out; } } diff --git a/Crow/src/GraphicBackends/Mono.Cairo/Surface.cs b/Crow/src/GraphicBackends/Mono.Cairo/Surface.cs index 4b31990c..10967a93 100644 --- a/Crow/src/GraphicBackends/Mono.Cairo/Surface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Surface.cs @@ -91,28 +91,28 @@ namespace Crow.Drawing { } [Obsolete ("Use an ImageSurface constructor instead.")] - public static Cairo.Surface CreateForImage ( - ref byte[] data, Cairo.Format format, int width, int height, int stride) + public static Surface CreateForImage ( + ref byte[] data, Format format, int width, int height, int stride) { IntPtr p = NativeMethods.cairo_image_surface_create_for_data ( data, format, width, height, stride); - return new Cairo.Surface (p, true); + return new Surface (p, true); } [Obsolete ("Use an ImageSurface constructor instead.")] - public static Cairo.Surface CreateForImage ( - Cairo.Format format, int width, int height) + public static Surface CreateForImage ( + Format format, int width, int height) { IntPtr p = NativeMethods.cairo_image_surface_create ( format, width, height); - return new Cairo.Surface (p, true); + return new Surface (p, true); } - public Cairo.Surface CreateSimilar ( - Cairo.Content content, int width, int height) + public Surface CreateSimilar ( + Content content, int width, int height) { IntPtr p = NativeMethods.cairo_surface_create_similar ( this.Handle, content, width, height); diff --git a/Crow/src/GraphicBackends/vkvg/Context.cs b/Crow/src/GraphicBackends/vkvg/Context.cs index bf638de3..d8f45611 100644 --- a/Crow/src/GraphicBackends/vkvg/Context.cs +++ b/Crow/src/GraphicBackends/vkvg/Context.cs @@ -4,6 +4,7 @@ using System; using System.Text; +using System.Linq; using Crow; namespace Crow.Drawing @@ -104,7 +105,8 @@ namespace Crow.Drawing NativeMethods.vkvg_set_matrix(handle, ref value); } } - public void ShowText (ReadOnlySpan s, int tabSize) { + public void ShowText (string text) => ShowText (text.AsSpan()); + public void ShowText (ReadOnlySpan s, int tabSize = 4) { int size = s.Length * 4 + 1; Span bytes = size > 512 ? new byte[size] : stackalloc byte[size]; int encodedBytes = Crow.Text.Encoding.ToUtf8 (s, bytes, tabSize); @@ -345,7 +347,14 @@ namespace Crow.Drawing Encoding.UTF8.GetBytes(s, 0, s.Length, bytes, 0); return bytes; } - + public void SetDash (double [] dashes, double offset = 0) { + if (dashes == null) + NativeMethods.vkvg_set_dash(handle, null, 0, 0); + else { + float[] floats = dashes.Cast ().ToArray (); + NativeMethods.vkvg_set_dash(handle, floats, (uint)dashes.Length, (float)offset); + } + } public float[] Dashes { set diff --git a/Crow/src/GraphicBackends/vkvg/Surface.cs b/Crow/src/GraphicBackends/vkvg/Surface.cs index 654238db..6d7321a5 100644 --- a/Crow/src/GraphicBackends/vkvg/Surface.cs +++ b/Crow/src/GraphicBackends/vkvg/Surface.cs @@ -28,7 +28,11 @@ namespace Crow.Drawing vkvgDev = device; handle = NativeMethods.vkvg_surface_create_from_image (device.Handle, imgPath); } - + public Surface (Device device, IntPtr surfHandle) { + vkvgDev = device; + handle = surfHandle; + AddReference (); + } Surface (IntPtr devHandle, int width, int heigth) { diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index a152e472..99187ba7 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -326,7 +326,27 @@ namespace Crow }; #endregion - + public Surface CreateSurface (ref Rectangle r) { +#if (VKVG) + return new Surface (vkvgDevice, r.Width, r.Height); +#else + return surf.CreateSimilar (Content.ColorAlpha, r.Width, r.Height); +#endif + } + public Surface CreateSurface (int width, int height) { +#if (VKVG) + return new Surface (vkvgDevice, width, height); +#else + return surf.CreateSimilar (Content.ColorAlpha, width, height); +#endif + } + public Surface CreateSurface (IntPtr existingSurfaceHandle) { +#if (VKVG) + return new Surface (vkvgDevice, existingSurfaceHandle); +#else + return Surface.Lookup (existingSurfaceHandle, false); +#endif + } public string WindowTitle { set => Glfw3.SetWindowTitle (hWin, value); } @@ -750,7 +770,7 @@ namespace Crow using (ZipArchive archive = ZipFile.Open (Theme, ZipArchiveMode.Read)) { foreach (ZipArchiveEntry entry in archive.Entries.Where (e => e.FullName.StartsWith ("Images"))) { Console.WriteLine (entry.FullName); - } + } foreach (ZipArchiveEntry entry in archive.Entries.Where (e => e.FullName.StartsWith ("IML"))) { Console.WriteLine (entry.FullName); } @@ -762,7 +782,7 @@ namespace Crow void loadThemeStyle () { if (string.IsNullOrEmpty (Theme)) return; - try { + try { if (Directory.Exists (theme)) { string stylePath = Directory.GetFiles (theme, "*.style").FirstOrDefault (); using (Stream s = new FileStream (stylePath, FileMode.Open, FileAccess.Read)) { @@ -782,7 +802,7 @@ namespace Crow } } catch (Exception e) { throw new Exception ($"[Theme] Error reading theme style ({Theme})", e); - } + } } #endregion @@ -1075,6 +1095,7 @@ namespace Crow PerformanceMeasure.Notify (); } +#if VKVG void resizeVulkanContext () { vkCtx.WaitIdle(); vkCtx.blitSource?.Dispose (); @@ -1086,8 +1107,8 @@ namespace Crow g.RegisterForLayouting (LayoutingType.All); registerRefreshClientRectangle (); - } +#endif /// Layouting loop, this is the first step of the udpate and process registered /// Layouting queue items. Failing LQI's are requeued in this cycle until MaxTry is reached which /// trigger an enqueue for the next Update Cycle @@ -1096,7 +1117,7 @@ namespace Crow if (LayoutingQueue.Count == 0) { Monitor.Exit (LayoutMutex); return; - } + } DbgLogger.StartEvent (DbgEvtType.ProcessLayouting); PerformanceMeasure.Begin (PerformanceMeasure.Kind.Layouting); @@ -1147,7 +1168,7 @@ namespace Crow ctx.Fill (); ctx.Operator = Operator.Over; } - bool solidBackground = false; + bool solidBackground = false; public bool SolidBackground { get => solidBackground; set { @@ -1177,7 +1198,6 @@ namespace Crow if (SolidBackground) clear (ctx); - ctx.Flush(); #endif for (int i = GraphicTree.Count -1; i >= 0 ; i--){ @@ -1268,7 +1288,7 @@ namespace Crow } /*if (DragAndDropInProgress) { - }*/ + }*/ surf.Flush (); } @@ -1421,7 +1441,6 @@ namespace Crow clientRectangle = bounds; #if VKVG - #else switch (Environment.OSVersion.Platform) { case PlatformID.MacOSX: @@ -1545,23 +1564,23 @@ namespace Crow currentCursor?.Dispose (); switch (cursor) { - case MouseCursor.arrow: + case MouseCursor.arrow: case MouseCursor.top_left_arrow: currentCursor = new Cursor (CursorShape.Arrow); break; - case MouseCursor.crosshair: + case MouseCursor.crosshair: currentCursor = new Cursor (CursorShape.Crosshair); break; - case MouseCursor.hand: + case MouseCursor.hand: currentCursor = new Cursor (CursorShape.Hand); break; - case MouseCursor.ibeam: + case MouseCursor.ibeam: currentCursor = new Cursor (CursorShape.IBeam); break; - default: + default: currentCursor = XCursor.Create (this, cursor); break; - } + } currentCursor.Set (hWin); //MouseCursorChanged.Raise (this,new MouseCursorChangedEventArgs(cursor)); @@ -1578,8 +1597,8 @@ namespace Crow dragndropHover = value; } else HoverWidget = value; - } - } + } + } /// /// Ask OS to force the mouse position to the actual coordinate of Interface.MousePosition /// @@ -1634,7 +1653,7 @@ namespace Crow int indexOfTopContainer = GraphicTree.IndexOf (topContainer); if (indexOfTopContainer != 0) { - for (int i = 0; i < indexOfTopContainer; i++) {//check all top containers that are at a higher level + for (int i = 0; i < indexOfTopContainer; i++) {//check all top containers that are at a higher level //if logical parent of top container is the Interface, that's not a popup. if (GraphicTree [i].LogicalParent is Interface) { if (GraphicTree [i].MouseIsIn (e.Position)) { @@ -1762,7 +1781,7 @@ namespace Crow ActiveWidget = null; } return true; - } + } if (_activeWidget == null) return false; @@ -2067,7 +2086,7 @@ namespace Crow public Rectangle ClientRectangle => clientRectangle; public Interface HostContainer => this; - public Rectangle getSlot () => ClientRectangle; + public Rectangle getSlot () => ClientRectangle; public void ChildrenLayoutingConstraints(ILayoutable layoutable, ref LayoutingType layoutType){ } #endregion } diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index 245dddf3..24aaa695 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -1962,7 +1962,9 @@ namespace Crow ctx.SetSource (bmp, rb.X, rb.Y); ctx.Paint (); +#if VKVG ctx.Flush (); +#endif DbgLogger.EndEvent(DbgEvtType.GOPaintCache); } protected virtual void UpdateCache(Context ctx){ diff --git a/Directory.Build.props b/Directory.Build.props index 917e7dfc..58a32622 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -8,11 +8,24 @@ 0.9.7 $(CrowVersion)-beta + + true + + false + + true + + false - true + + + false + 0.2.12-beta diff --git a/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs b/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs index 086e7152..7b91f9f0 100644 --- a/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs +++ b/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs @@ -1,18 +1,15 @@ -using System.Diagnostics; -using System.Runtime.InteropServices.ComTypes; -// Copyright (c) 2013-2020 Jean-Philippe Bruyère +// Copyright (c) 2013-2021 Jean-Philippe Bruyère // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; using System.Collections.Generic; using System.ComponentModel; -using System.IO; using System.Linq; using System.Threading.Tasks; using Crow.Drawing; using Crow.DebugLogger; -using DebugLogAnalyzer; +using System.Diagnostics; namespace Crow { @@ -194,9 +191,7 @@ namespace Crow set { base.Font = value; using (Context gr = new Context (IFace.surf)) { - gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight); - gr.SetFontSize (Font.Size); - + setFontForContext (gr); fe = gr.FontExtents; } updateMargins (); @@ -262,7 +257,7 @@ namespace Crow } DbgEvtType currentFilter; - protected override void onDraw (Cairo.Context gr) + protected override void onDraw (Context gr) { base.onDraw (gr); @@ -346,7 +341,7 @@ namespace Crow } string ticksToMS(long ticks) => Math.Round ((double)ticks / Stopwatch.Frequency * 1000.0, 2).ToString(); - public override void Paint (Cairo.Context ctx) + public override void Paint (Context ctx) { base.Paint (ctx); @@ -386,7 +381,7 @@ namespace Crow ctx.MoveTo (ctxR.X - ctx.TextExtents (str).Width / 2, ctxR.Y + fe.Height); ctx.ShowText (str); - ctx.Operator = Cairo.Operator.Add; + ctx.Operator = Operator.Add; if (hoverLine >= 0) { double y = fe.Height * (hoverLine - ScrollY) + topMargin + cb.Top; @@ -413,7 +408,7 @@ namespace Crow } if (selStart < 0 || selEnd < 0) { - ctx.Operator = Cairo.Operator.Over; + ctx.Operator = Operator.Over; return; } double selStartX = (double)(selStart - ScrollX - minTicks) * xScale + leftMargin + cb.Left; @@ -432,7 +427,7 @@ namespace Crow ctx.SetSource (0.0,0.2,0.8,0.15); //ctx.SetSource (Colors.Jet); ctx.Fill(); - ctx.Operator = Cairo.Operator.Over; + ctx.Operator = Operator.Over; str = $"{ticksToMS(Math.Abs (selEnd - selStart))} (ms)"; diff --git a/Samples/DebugLogAnalyzer/src/DebugInterface.cs b/Samples/DebugLogAnalyzer/src/DebugInterface.cs index d37b0752..08927566 100644 --- a/Samples/DebugLogAnalyzer/src/DebugInterface.cs +++ b/Samples/DebugLogAnalyzer/src/DebugInterface.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2013-2019 Bruyère Jean-Philippe +// Copyright (c) 2013-2021 Bruyère Jean-Philippe // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) @@ -18,7 +18,7 @@ namespace Crow public DebugInterface (IntPtr hWin) : base (hWin) { SolidBackground = false; - surf = new ImageSurface (Format.Argb32, 100, 100); + surf = CreateSurface (100, 100); } public override void Run() @@ -125,7 +125,7 @@ namespace Crow lock (UpdateMutex) { clientRectangle = new Rectangle (0, 0, width, height); surf?.Dispose(); - surf = new ImageSurface (Format.Argb32, width, height); + surf = CreateSurface (width, height); 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 70c4f9b1..8da93de0 100644 --- a/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs +++ b/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs @@ -377,9 +377,9 @@ namespace Crow if (initialized) { delResize (Slot.Width, Slot.Height); - bmp = Crow.Cairo.Surface.Lookup (delGetSurfacePointer(), false); + bmp = IFace.CreateSurface (delGetSurfacePointer()); } else - bmp = IFace.surf.CreateSimilar (Content.ColorAlpha, Slot.Width, Slot.Height); + bmp = IFace.CreateSurface (Slot.Width, Slot.Height); IsDirty = false; } diff --git a/Samples/PathPainter/Painter.cs b/Samples/PathPainter/Painter.cs index 7e3c97bb..3077aa09 100644 --- a/Samples/PathPainter/Painter.cs +++ b/Samples/PathPainter/Painter.cs @@ -1,13 +1,13 @@ -using Crow.Cairo; -using System; -using System.Collections; -using System.Collections.Generic; +// Copyright (c) 2021 Bruyère Jean-Philippe +// +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + +using Crow.Drawing; using System.ComponentModel; -using System.Text; namespace Crow -{ - public class Painter : ScrollingObject +{ + public class Painter : ScrollingObject { #region CTOR protected Painter () { } diff --git a/Samples/PerfTests/Program.cs b/Samples/PerfTests/Program.cs index 14da072a..dddf30ba 100644 --- a/Samples/PerfTests/Program.cs +++ b/Samples/PerfTests/Program.cs @@ -164,7 +164,7 @@ namespace PerfTests if (screenOutput) initSurface (); else - surf = new Crow.Cairo.ImageSurface (Crow.Cairo.Format.Argb32, ClientRectangle.Width, ClientRectangle.Height); + surf = CreateSurface (ClientRectangle.Width, ClientRectangle.Height); initDictionaries (); loadStyling (); diff --git a/Samples/common/src/SampleBase.cs b/Samples/common/src/SampleBase.cs index 9784304a..5b33444a 100644 --- a/Samples/common/src/SampleBase.cs +++ b/Samples/common/src/SampleBase.cs @@ -87,7 +87,7 @@ namespace Samples public int intValue = 500; VerticalAlignment currentVAlign; - DirectoryInfo curDir = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); + DirectoryInfo curDir = new DirectoryInfo(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); public FileSystemInfo[] CurDirectory => curDir.GetFileSystemInfos(); public string MultilineText = $"Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit. Sed non risus.\n\nSuspendisse lectus tortor,\nLorem ipsum dolor sit amet,\nconsectetur adipiscing elit. Sed non risus.\n\nSuspendisse lectus tortor,"; diff --git a/Samples/dragNdrop/dragNdrop.cs b/Samples/dragNdrop/dragNdrop.cs index 9af1c3d3..4b063263 100644 --- a/Samples/dragNdrop/dragNdrop.cs +++ b/Samples/dragNdrop/dragNdrop.cs @@ -1,5 +1,6 @@ using Crow; using Samples; +using Crow.Drawing; namespace tests { @@ -29,9 +30,8 @@ namespace tests Rectangle r = e.DragSource.LastPaintedSlot; startGroup = e.DragSource.Parent as Group; - Crow.Cairo.Surface dragImg = surf.CreateSimilar (Crow.Cairo.Content.ColorAlpha, - r.Width, r.Height); - using (Crow.Cairo.Context gr = new Crow.Cairo.Context(dragImg)) { + Surface dragImg = CreateSurface (ref r); + using (Context gr = new Context(dragImg)) { gr.SetSource (e.DragSource.bmp, 0, 0); gr.Paint (); } diff --git a/unitTests/TestBackend.cs b/unitTests/TestBackend.cs index 4ad680e8..44a60cad 100644 --- a/unitTests/TestBackend.cs +++ b/unitTests/TestBackend.cs @@ -12,7 +12,7 @@ namespace unitTests { public TestInterface (int width = 800, int height = 600) : base (width, height, false, false) { - surf = new Crow.Cairo.ImageSurface (Crow.Cairo.Format.Argb32, ClientRectangle.Width, ClientRectangle.Height); + surf = CreateSurface (ClientRectangle.Width, ClientRectangle.Height); } bool isRunning; public bool IsRunning { -- 2.47.3