]> O.S.I.I.S - jp/crow.git/commitdiff
wip, save commit
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 23 Nov 2021 03:19:32 +0000 (04:19 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 23 Nov 2021 03:19:32 +0000 (04:19 +0100)
78 files changed:
Backends/CairoBackend/CairoBackend.csproj
Backends/CairoBackend/src/Cairo.cs
Backends/CairoBackend/src/CairoDebug.cs
Backends/CairoBackend/src/Content.cs
Backends/CairoBackend/src/Context.cs
Backends/CairoBackend/src/DRMDevice.cs
Backends/CairoBackend/src/DRMSurface.cs
Backends/CairoBackend/src/Device.cs
Backends/CairoBackend/src/DirectFBSurface.cs
Backends/CairoBackend/src/Distance.cs
Backends/CairoBackend/src/EGLDevice.cs
Backends/CairoBackend/src/Extend.cs [deleted file]
Backends/CairoBackend/src/FillRule.cs [deleted file]
Backends/CairoBackend/src/Filter.cs [deleted file]
Backends/CairoBackend/src/FontExtents.cs [deleted file]
Backends/CairoBackend/src/FontFace.cs
Backends/CairoBackend/src/FontOptions.cs
Backends/CairoBackend/src/FontSlant.cs [deleted file]
Backends/CairoBackend/src/FontType.cs
Backends/CairoBackend/src/FontWeight.cs [deleted file]
Backends/CairoBackend/src/GLSurface.cs
Backends/CairoBackend/src/GLXDevice.cs
Backends/CairoBackend/src/GlitzSurface.cs
Backends/CairoBackend/src/Glyph.cs
Backends/CairoBackend/src/Gradient.cs
Backends/CairoBackend/src/HintMetrics.cs
Backends/CairoBackend/src/HintStyle.cs
Backends/CairoBackend/src/ImageSurface.cs
Backends/CairoBackend/src/LineCap.cs [deleted file]
Backends/CairoBackend/src/LineJoin.cs [deleted file]
Backends/CairoBackend/src/LinearGradient.cs
Backends/CairoBackend/src/Matrix.cs
Backends/CairoBackend/src/MeshPattern.cs
Backends/CairoBackend/src/NativeMethods-internal.cs
Backends/CairoBackend/src/NativeMethods.cs
Backends/CairoBackend/src/PSSurface.cs
Backends/CairoBackend/src/Path.cs
Backends/CairoBackend/src/Pattern.cs
Backends/CairoBackend/src/PatternType.cs [deleted file]
Backends/CairoBackend/src/PdfSurface.cs
Backends/CairoBackend/src/RadialGradient.cs
Backends/CairoBackend/src/Region.cs
Backends/CairoBackend/src/ScaledFont.cs
Backends/CairoBackend/src/SolidPattern.cs
Backends/CairoBackend/src/Status.cs
Backends/CairoBackend/src/SubpixelOrder.cs
Backends/CairoBackend/src/Surface.cs
Backends/CairoBackend/src/SurfacePattern.cs
Backends/CairoBackend/src/SurfaceType.cs
Backends/CairoBackend/src/SvgSurface.cs
Backends/CairoBackend/src/SvgVersion.cs
Backends/CairoBackend/src/TextExtents.cs [deleted file]
Backends/CairoBackend/src/WGLDevice.cs
Backends/CairoBackend/src/Win32Surface.cs
Backends/CairoBackend/src/XcbSurface.cs
Backends/CairoBackend/src/XlibSurface.cs
Backends/CairoBackend/src/rsvg/SvgHandle.cs
Backends/VkvgBackend/VkvgBackend.csproj
Crow/Crow.csproj
Crow/src/Fill/BmpPicture.cs
Crow/src/Interface.cs
Crow/src/StbImage.cs [deleted file]
Crow/src/Widgets/ColorPicker.cs
Crow/src/Widgets/DockWindow.cs
Crow/src/Widgets/GroupBase.cs
Crow/src/Widgets/Label.cs
Crow/src/Widgets/PrivateContainer.cs
Crow/src/Widgets/ScrollingStack.cs
Crow/src/Widgets/Shape.cs
Crow/src/Widgets/TemplatedControl.cs
Crow/src/Widgets/Widget.cs
Drawing2D/Drawing2D.csproj
Drawing2D/src/Device.cs [deleted file]
Drawing2D/src/IContext.cs
Drawing2D/src/IDevice.cs [new file with mode: 0644]
Drawing2D/src/ISurface.cs [new file with mode: 0644]
Drawing2D/src/StbImage.cs [new file with mode: 0644]
Drawing2D/src/Surface.cs [deleted file]

index f4fe4d57ae6cc731f56910a44c0c277e5a5b71cf..dc9cb60a7da20bfbe0958fe337df898c4be9d5cf 100644 (file)
@@ -1,15 +1,18 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-               <TargetFramework>netcoreapp3.0</TargetFramework>
+         <TargetFramework>netcoreapp3.0</TargetFramework>
+         <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
   </PropertyGroup>
 
-       <ItemGroup>
-               <Compile Include="src\**\*.cs" />
-       </ItemGroup>
+  <ItemGroup>
+         <Compile Include="src\**\*.cs" Exclude="src\NativeMethods-internal.cs"/>
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="glfw-sharp" Version="$(GlfwSharpVersion)" />
+    <ProjectReference Include="..\..\Drawing2D\Drawing2D.csproj" />
+  </ItemGroup>
 
-       <ItemGroup>
-         <ProjectReference Include="..\..\Drawing2D\Drawing2D.csproj" />
-       </ItemGroup>
 
 </Project>
index 309c7f4a51ca85c5ce033c82168a6a865399a6ea..55f1335cc2912ca3b108e21193e78d825bdcf8c3 100644 (file)
@@ -34,7 +34,7 @@
 using System;
 using System.Runtime.InteropServices;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        public static class CairoAPI {
                static public int Version {
index 890793da41bef2fea6a0cfad31174ef4eba4ae34..c3e92beb2fd2715956f39b41e299df585880f9f9 100644 (file)
@@ -28,8 +28,8 @@
 
 using System;
 
-namespace Crow.Drawing {
-
+namespace Crow.CairoBackend
+{
        static class CairoDebug
        {
                static System.Collections.Generic.Dictionary<IntPtr,string> traces;
index a908a0d80b05dfd5508c9b01c3dcdb9efa0977a3..9096bf07088fd3ece223f479cd25f0aea8d22535 100644 (file)
@@ -30,7 +30,7 @@
 
 using System;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        //[Flags]
        public enum Content
index 5b92166c0bc649a1806ab52e01b1754c701fc515..965297be606f006f04f30a1508f4facba6d23fb1 100644 (file)
@@ -39,15 +39,9 @@ using System.Runtime.InteropServices;
 using System.Text;
 using Drawing2D;
 
-namespace Crow.Drawing {
-
-       [Obsolete ("Renamed Cairo.Context per suggestion from cairo binding guidelines.")]
-       public class Graphics : Context {
-               public Graphics (IntPtr state) : base (state) {}
-               public Graphics (Surface surface) : base (surface) {}
-       }
-
-       public class Context : IDisposable
+namespace Crow.CairoBackend
+{
+       public class Context : IContext
        {
                IntPtr handle = IntPtr.Zero;
 
@@ -81,7 +75,7 @@ namespace Crow.Drawing {
                        }
                }
 
-               public Context (Surface surface) : this (NativeMethods.cairo_create (surface.Handle), true)
+               public Context (ISurface surface) : this (NativeMethods.cairo_create (surface.Handle), true)
                {
                }
 
@@ -698,17 +692,6 @@ namespace Crow.Drawing {
                        NativeMethods.cairo_identity_matrix (handle);
                }
 
-               [Obsolete ("Use SetFontSize() instead.")]
-               public void FontSetSize (double scale)
-               {
-                       SetFontSize (scale);
-               }
-
-               [Obsolete ("Use SetFontSize() instead.")]
-               public double FontSize {
-                       set { SetFontSize (value); }
-               }
-
                public Matrix FontMatrix {
                        get {
                                Matrix m;
@@ -811,12 +794,6 @@ namespace Crow.Drawing {
                        NativeMethods.cairo_copy_page (handle);
                }
 
-               [Obsolete ("Use SelectFontFace() instead.")]
-               public void FontFace (string family, FontSlant slant, FontWeight weight)
-               {
-                       SelectFontFace (family, slant, weight);
-               }
-
                public void SetContextFontFace (FontFace value)
                {
                        NativeMethods.cairo_set_font_face (handle, value == null ? IntPtr.Zero : value.Handle);
index c08ad0307f264d770e9f03c6ef2274cb0dc6f3b1..7bca9e6ada0296ed18c4c52876fbb188e1a22d68 100644 (file)
@@ -29,7 +29,7 @@
 //
 using System;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        public class DRMDevice : Device
        {
index b1fcfb76711d69057a22ea8b2882ced4bc0586f6..cf57d1763d857885e04ce8a13f2e2a823b1bc567 100644 (file)
 // distribute, sublicense, and/or sell copies of the Software, and to
 // permit persons to whom the Software is furnished to do so, subject to
 // the following conditions:
-// 
+//
 // The above copyright notice and this permission notice shall be
 // included in all copies or substantial portions of the Software.
-// 
+//
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 //
 
 using System;
+using Drawing2D;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        public class DRMSurface : Surface
        {
-               
+
                public DRMSurface (IntPtr ptr, bool own) : base (ptr, own)
                {}
 
index 426d4ca26dd93e56e5b5988223dd851e78edc820..5191a23d259c896b3c29dbbeb21ad79b2940ea28 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 using System;
+using Drawing2D;
+using Glfw;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
-       public class Device : IDisposable
+       public class Device : IDevice
        {
                IntPtr handle = IntPtr.Zero;
+               /// <summary> Global font rendering settings for Cairo </summary>
+               FontOptions FontRenderingOptions;
+               /// <summary> Global font rendering settings for Cairo </summary>
+               Antialias Antialias = Antialias.Subpixel;
 
                protected Device()
                {
+                       FontRenderingOptions = new FontOptions ();
+                       FontRenderingOptions.Antialias = Antialias.Subpixel;
+                       FontRenderingOptions.HintMetrics = HintMetrics.On;
+                       FontRenderingOptions.HintStyle = HintStyle.Full;
+                       FontRenderingOptions.SubpixelOrder = SubpixelOrder.Default;
                }
 
                protected Device (IntPtr ptr) : this (ptr, true)
@@ -94,8 +105,50 @@ namespace Crow.Drawing
                                return;
 
                        NativeMethods.cairo_device_destroy (handle);
+
+                       FontRenderingOptions.Dispose ();
                        handle = IntPtr.Zero;
                }
+
+               public void GetDpy(out int hdpy, out int vdpy)
+               {
+                       throw new NotImplementedException();
+               }
+
+               public void SetDpy(int hdpy, int vdpy)
+               {
+                       throw new NotImplementedException();
+               }
+
+               public virtual ISurface CreateSurface(int width, int height)
+               {
+                       throw new NotImplementedException();
+               }
+               public ISurface CreateSurface (IntPtr nativeWindoPointer, int width, int height) {
+                       switch (Environment.OSVersion.Platform) {
+                       case PlatformID.Unix:
+                               IntPtr disp = Glfw3.GetX11Display ();
+                               IntPtr nativeWin = Glfw3.GetX11Window (nativeWindoPointer);
+                               Int32 scr = Glfw3.GetX11DefaultScreen (disp);
+                               IntPtr visual = Glfw3.GetX11DefaultVisual (disp, scr);
+                               return new XlibSurface (disp, nativeWin, visual, width, height);
+                       case PlatformID.Win32NT:
+                       case PlatformID.Win32S:
+                       case PlatformID.Win32Windows:
+                               IntPtr hWin32 = Glfw3.GetWin32Window (nativeWindoPointer);
+                               IntPtr hdc = Glfw3.GetWin32DC (hWin32);
+                               return new Win32Surface (hdc);
+                       }
+                       throw new PlatformNotSupportedException ("Unable to create cairo surface.");
+               }
+
+               public virtual IContext CreateContext(ISurface surf)
+               {
+                       Context gr = new Context (surf);
+                       gr.FontOptions = FontRenderingOptions;
+                       gr.Antialias = Antialias;
+                       throw new NotImplementedException();
+               }
        }
 }
 
index 4f52ec72ad15cbbd1cbb6f13627713b5b645a31e..ca7cd718334d3e495cbb63d9981f36485f2afbfb 100644 (file)
@@ -28,7 +28,7 @@
 
 using System;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
        public class DirectFBSurface : Surface
        {
                internal DirectFBSurface (IntPtr handle, bool owns) : base (handle, owns)
index eaa7d5a3bbe65472cde1101f2a50e2a4bf951daa..160fa1e7982de29346e0b0aac3c7f5afd2aa4a86 100644 (file)
@@ -34,7 +34,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        public struct Distance
        {
index 93150884edd09e7bf49d6cc575a1f65ee93b3952..1f73ef4faa6f4add866143328f93f5bb6e4ae463 100644 (file)
@@ -29,7 +29,7 @@
 //
 using System;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        public class EGLDevice : Device
        {
diff --git a/Backends/CairoBackend/src/Extend.cs b/Backends/CairoBackend/src/Extend.cs
deleted file mode 100644 (file)
index 01a7969..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// Mono.Cairo.Extend.cs
-//
-// Authors:
-//   Duncan Mak (duncan@ximian.com)
-//   Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//   John Luke (john.luke@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2005 John Luke
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Crow.Drawing
-{
-       
-       public enum Extend
-       {
-               None,
-               Repeat,
-               Reflect,
-               Pad,
-       }
-}
diff --git a/Backends/CairoBackend/src/FillRule.cs b/Backends/CairoBackend/src/FillRule.cs
deleted file mode 100644 (file)
index 314a783..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Mono.Cairo.FillRule.cs
-//
-// Authors:
-//   Duncan Mak (duncan@ximian.com)
-//   Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Crow.Drawing
-{
-       
-       public enum FillRule
-       {
-               Winding,
-               EvenOdd
-       }
-}
diff --git a/Backends/CairoBackend/src/Filter.cs b/Backends/CairoBackend/src/Filter.cs
deleted file mode 100644 (file)
index 5b52104..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// Mono.Cairo.Filter.cs
-//
-// Authors:
-//   Duncan Mak (duncan@ximian.com)
-//   Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Crow.Drawing
-{
-       
-       public enum Filter
-       {
-               Fast,
-               Good,
-               Best,
-               Nearest,
-               Bilinear,
-               Gaussian,
-       }
-}
diff --git a/Backends/CairoBackend/src/FontExtents.cs b/Backends/CairoBackend/src/FontExtents.cs
deleted file mode 100644 (file)
index 73164b2..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-// Mono.Cairo.FontExtents.cs
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-//          Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-//
-// This is a simplistic binding of the Cairo API to C#. All functions
-// in cairo.h are transcribed into their C# equivelants
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace Crow.Drawing
-{
-       [StructLayout (LayoutKind.Sequential)]
-       public struct FontExtents
-       {
-               double ascent;
-               double descent;
-               double height;
-               double maxXAdvance;
-               double maxYAdvance;
-
-               public double Ascent {
-                       get { return ascent; }
-                       set { ascent = value; }
-               }
-
-               public double Descent {
-                       get { return descent; }
-                       set { descent = value; }
-               }
-
-               public double Height {
-                       get { return height; }
-                       set { height = value; }
-               }
-
-               public double MaxXAdvance {
-                       get { return maxXAdvance; }
-                       set { maxXAdvance = value; }
-               }
-
-               public double MaxYAdvance {
-                       get { return maxYAdvance; }
-                       set { maxYAdvance = value; }
-               }
-
-               public FontExtents (double ascent, double descent, double height, double maxXAdvance, double maxYAdvance)
-               {
-                       this.ascent = ascent;
-                       this.descent = descent;
-                       this.height = height;
-                       this.maxXAdvance = maxXAdvance;
-                       this.maxYAdvance = maxYAdvance;
-               }
-
-               public override bool Equals (object obj)
-               {
-                       if (obj is FontExtents)
-                               return this == (FontExtents) obj;
-                       return false;
-               }
-
-               public override int GetHashCode ()
-               {
-                       return (int) Ascent ^ (int) Descent ^ (int) Height ^ (int) MaxXAdvance ^ (int) MaxYAdvance;
-               }
-
-               public static bool operator == (FontExtents extents, FontExtents other)
-               {
-                       return extents.Ascent == other.Ascent && extents.Descent == other.Descent && extents.Height == other.Height && extents.MaxXAdvance == other.MaxXAdvance && extents.MaxYAdvance == other.MaxYAdvance;
-               }
-
-               public static bool operator != (FontExtents extents, FontExtents other)
-               {
-                       return !(extents == other);
-               }
-       }
-}
index e4fd1a6e2dd769a36ed7382b99b81cacbbf83cae..5b97dc25bc8dd4b265b4f6886c565c7d5f41e85e 100644 (file)
@@ -32,7 +32,7 @@
 //
 using System;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        public class FontFace : IDisposable
        {
index 977b6993fd4bd4f1d32094b5c655790101a36a2d..ee952bb3f95869a170ce14c40f074fca26ced964 100644 (file)
 // distribute, sublicense, and/or sell copies of the Software, and to
 // permit persons to whom the Software is furnished to do so, subject to
 // the following conditions:
-// 
+//
 // The above copyright notice and this permission notice shall be
 // included in all copies or substantial portions of the Software.
-// 
+//
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -27,8 +27,9 @@
 //
 
 using System;
+using Drawing2D;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        public class FontOptions : IDisposable
        {
@@ -107,7 +108,7 @@ namespace Crow.Drawing
                {
                        return (int) NativeMethods.cairo_font_options_hash (handle);
                }
-               
+
                public void Merge (FontOptions other)
                {
                        if (other == null)
diff --git a/Backends/CairoBackend/src/FontSlant.cs b/Backends/CairoBackend/src/FontSlant.cs
deleted file mode 100644 (file)
index 4ce74a2..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// Mono.Cairo.FontSlant.cs
-//
-// Authors:
-//   Duncan Mak (duncan@ximian.com)
-//   Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Crow.Drawing
-{
-       
-       public enum FontSlant
-       {
-               Normal,
-               Italic,
-               Oblique
-       }
-}
index 80d672c459ef7d3de7819d0de089cc8a664afa23..664c2f58f8e3cc9123dc5d7533d0b950b75f751d 100644 (file)
@@ -28,9 +28,8 @@
 
 using System;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
-       
        public enum FontType
        {
                Toy,
diff --git a/Backends/CairoBackend/src/FontWeight.cs b/Backends/CairoBackend/src/FontWeight.cs
deleted file mode 100644 (file)
index 51c0e8d..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Mono.Cairo.FontWeight.cs
-//
-// Authors:
-//   Duncan Mak (duncan@ximian.com)
-//   Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Crow.Drawing
-{
-       
-       public enum FontWeight
-       {
-               Normal,
-               Bold,
-       }
-}
index 451120248b41dfced7e379ed47ff550270fa5e0e..117bd60f499a04582865de1691d01f220d012efc 100644 (file)
@@ -30,7 +30,7 @@
 
 using System;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        public class GLSurface : Surface
        {
index 086cf1f442077dd349a026574dc281fe44efc795..8c080df5ab49c4c26d06f5c0c086b61b12942cf7 100644 (file)
@@ -29,7 +29,7 @@
 //
 using System;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        public class GLXDevice : Device
        {
index fc12c6737efa81135c9bb85102b3d7e1036948bf..4497877bf49b130895979b1e1ee87b5fa823403a 100644 (file)
@@ -28,7 +28,7 @@
 
 using System;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
        public class GlitzSurface : Surface
        {
                internal GlitzSurface (IntPtr handle, bool owns) : base (handle, owns)
index c015e6de2a657d84e3b6b2bc8eab49a399e22152..fdd8436be636c36d0090cc6fe645a31df3258bcb 100644 (file)
@@ -30,7 +30,7 @@
 using System;
 using System.Runtime.InteropServices;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        [StructLayout(LayoutKind.Sequential)]
        public struct Glyph
index c9b8116cf20d1d491385d721c5e70ac9b5ff2888..3dd0d9d2a975fe01d2f732651cce410924923b64 100644 (file)
@@ -28,8 +28,9 @@
 //
 
 using System;
-using Color = Crow.Color;
-namespace Crow.Drawing {
+using Color = Drawing2D.Color;
+
+namespace Crow.CairoBackend {
 
        public class Gradient : Pattern
        {
index fbb78ad6cfee32611f162050f416af5b000137f4..8f4f95c16057def68105b5c735ceb368c9df2316 100644 (file)
@@ -29,7 +29,7 @@
 
 using System;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        
        public enum HintMetrics
index 713dafae6d0d4736c0f8b5e78efe9d205d2fbc5a..6616174740e0048c81a0471d4c59e266e69baabc 100644 (file)
@@ -29,7 +29,7 @@
 
 using System;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        
        public enum HintStyle
index 283301059dbd5212e783d4647444086b4eb82995..c2e5dec90328294040968d7ba63addf73f76c7e8 100644 (file)
@@ -34,8 +34,9 @@
 
 using System;
 using System.Runtime.InteropServices;
+using Drawing2D;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        public class ImageSurface : Surface
        {
@@ -70,7 +71,7 @@ namespace Crow.Drawing {
                }
 
                public override int Width => NativeMethods.cairo_image_surface_get_width (Handle);
-               public override int Height => NativeMethods.cairo_image_surface_get_height (Handle);            
+               public override int Height => NativeMethods.cairo_image_surface_get_height (Handle);
 
                public byte[] Data {
                        get {
diff --git a/Backends/CairoBackend/src/LineCap.cs b/Backends/CairoBackend/src/LineCap.cs
deleted file mode 100644 (file)
index b9fcb22..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Mono.Cairo.LineCap.cs
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-//          Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Crow.Drawing
-{
-       
-       public enum LineCap
-       {
-               Butt,
-               Round,
-               Square,
-       }
-}
diff --git a/Backends/CairoBackend/src/LineJoin.cs b/Backends/CairoBackend/src/LineJoin.cs
deleted file mode 100644 (file)
index 2ec44b6..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// Mono.Cairo.LineJoin.cs
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-//          Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Crow.Drawing
-{
-       
-       public enum LineJoin
-       {
-               Miter,
-               Round,
-               Bevel
-       }
-}
-
index 3b98be039c32bbb7cfa4a95a84b1c003acf4188b..32b83db23948055b59104608012c5662f8507fd5 100644 (file)
@@ -30,7 +30,7 @@
 using System;
 using Drawing2D;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        public class LinearGradient : Gradient
        {
index 0224fd5f2d5a3f87964b80035c3dd25bc2245bde..b19256885f7133a3b50331c05183785ce0f0bc32 100644 (file)
@@ -34,7 +34,7 @@
 using System;
 using System.Runtime.InteropServices;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        [StructLayout(LayoutKind.Sequential)]
        public class Matrix //: ICloneable
index aef35481d873dfcf17553677f6333768cc682a3d..f25767052355ac638976b702063fb6704cfebeae 100644 (file)
@@ -30,7 +30,7 @@
 using System;
 using Drawing2D;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        public class MeshPattern : Pattern
        {
index 6e6d507c06ff48d8e61d3a42f016b9406b4b6a4c..714ff63a4041d93ac1cd44ec66c3ee94727a8b6b 100644 (file)
@@ -34,8 +34,9 @@
 using System;
 using System.Runtime.InteropServices;
 using System.Runtime.CompilerServices;
+using Drawing2D;
 
-namespace Cairo
+namespace Crow.CairoBackend
 {
        // sort the functions like in the following page so it is easier to find what is missing
        // http://cairographics.org/manual/index-all.html
index 48ee42f7f1dc75011e739cb9aba5b9ca7b13aafa..27f61154d229e7eefa1ecc34bc2ce35f698c6ad7 100644 (file)
@@ -35,7 +35,7 @@ using System;
 using System.Runtime.InteropServices;
 using Drawing2D;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        // sort the functions like in the following page so it is easier to find what is missing
        // http://cairographics.org/manual/index-all.html
index ca3c1d7d4f24ffa948530ed656f7598e003e9344..fadb1b2e69c6dcb20112b2502159844d0b42035e 100644 (file)
@@ -28,7 +28,7 @@
 
 using System;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        public class PSSurface : Surface
        {
index 9d5e9456b758767f11fd8bb8f26b7932709acfde..54ae4300ef09e83e42fc69463ff43e06d93999a0 100644 (file)
@@ -32,7 +32,7 @@ using System;
 using System.Runtime.InteropServices;
 
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        public class Path : IDisposable
        {
index 1180e6320d383b56d1e01d52241bcf80e9418b62..545dda36d5d50f263ad78ddc9ec237bd1af45a59 100644 (file)
@@ -29,8 +29,9 @@
 
 using System;
 using System.Collections;
+using Drawing2D;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
    
        public class Pattern : IDisposable
        {
diff --git a/Backends/CairoBackend/src/PatternType.cs b/Backends/CairoBackend/src/PatternType.cs
deleted file mode 100644 (file)
index 008d8e5..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// Mono.Cairo.PatternType.cs
-//
-// Authors:
-//    John Luke
-//
-// (C) John Luke, 2006.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Crow.Drawing {
-
-       
-       public enum PatternType
-       {
-               Solid,
-               Surface,
-               Linear,
-               Radial,
-               Mesh,
-               RasterSource
-       }
-}
-
index 16287b762a5eb45738a8dee7cc827fcb095c505c..676b596b9b081e0046e43a275ec7bc9b99aa3492 100644 (file)
@@ -28,7 +28,7 @@
 
 using System;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        public class PdfSurface : Surface
        {
index e76f7df167c1291017b580510a0e02c59f794e23..d27aa548e83c2dfefae517920cded329810748f4 100644 (file)
@@ -29,7 +29,7 @@
 
 using System;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        public class RadialGradient : Gradient
        {
index f4fa75729794e2236300ac7eb2a93e3b1476d80e..5466b121416b3793c4c4434146a1c1c1f8a53cfd 100644 (file)
@@ -24,7 +24,7 @@ using System;
 using System.Runtime.InteropServices;
 using Drawing2D;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        [StructLayout(LayoutKind.Sequential)]
        public struct RectangleList {
index 1d70646d52a778082711fe251411ac70918d96e7..8fc245e209f6a423a7e7e955452a5b6dced31758 100644 (file)
@@ -25,9 +25,9 @@
 
 using System;
 using System.Runtime.InteropServices;
+using Drawing2D;
 
-namespace Crow.Drawing {
-   
+namespace Crow.CairoBackend {
        public class ScaledFont : IDisposable
        {
                protected IntPtr handle = IntPtr.Zero;
index 5c5da80b8e4d9019566640d0c201b7f99c22478e..8d52fb0189484b8cd7eecd7f956d4470b029ce4e 100644 (file)
@@ -28,8 +28,8 @@
 //
 
 using System;
-using Color = Crow.Color;
-namespace Crow.Drawing {
+using Color = Drawing2D.Color;
+namespace Crow.CairoBackend {
 
        public class SolidPattern : Pattern
        {
index 9a0b8eed7595f7bbd06aeb2a7a15f73d5cd0e0aa..79252f64caeadeb25f55a201fea48af92a56016a 100644 (file)
@@ -32,7 +32,7 @@
 
 using System;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        
        public enum Status
index a67776df698e1f94ca585ff7b5cf47085586bee3..569225f5cfa552969031ea73d97f4b84ddfb8522 100644 (file)
@@ -28,9 +28,8 @@
 
 using System;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
-       
        public enum SubpixelOrder
        {
                Default,
index 92256fadf6e84fedef253ec0386852c6176cb716..b41af1a4722ce40e5a5ec1231caf2dc07fbe17f3 100644 (file)
@@ -37,9 +37,9 @@ using System;
 using System.Collections;
 using Drawing2D;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
-       public class Surface : IDisposable
+       public class Surface : ISurface
        {
                IntPtr handle = IntPtr.Zero;
 
@@ -226,5 +226,20 @@ namespace Crow.Drawing {
                public uint ReferenceCount {
                        get { return NativeMethods.cairo_surface_get_reference_count (handle); }
                }
+
+               public void WriteTo(IntPtr bitmap)
+               {
+                       throw new NotImplementedException();
+               }
+
+               public void Clear()
+               {
+                       throw new NotImplementedException();
+               }
+
+               public ISurface CreateSimilar(int width, int height)
+               {
+                       throw new NotImplementedException();
+               }
        }
 }
index 6c4539c8d720511e9f248dd56d73fa6027968d1d..7b06265fcda6593c5659d42bfadc27fee8fbde5c 100644 (file)
@@ -28,8 +28,9 @@
 //
 
 using System;
+using Drawing2D;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        public class SurfacePattern : Pattern
        {
index 5333e536c8213af1038c97f61a2be3cf77c63158..816635c9df04a026b0779bbef8ebc68b99cee967 100644 (file)
@@ -28,9 +28,7 @@
 
 using System;
 
-namespace Crow.Drawing {
-
-       
+namespace Crow.CairoBackend {
        public enum SurfaceType
        {
                Image,
index 4e22148d6232fcad278c9f4edccad7723fbfaf92..3eca66828858ee563079eb757a33657032e6d55f 100644 (file)
@@ -28,7 +28,7 @@
 
 using System;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        public class SvgSurface : Surface
        {
index 85bc6caf2fdf392b0d2a5da96533029c53649f1f..f79cc6777794d9ccb2b6b27c5eee90455e614306 100644 (file)
@@ -28,9 +28,7 @@
 
 using System;
 
-namespace Crow.Drawing {
-
-       
+namespace Crow.CairoBackend {
        public enum SvgVersion
        {
                // FIXME: yuck
diff --git a/Backends/CairoBackend/src/TextExtents.cs b/Backends/CairoBackend/src/TextExtents.cs
deleted file mode 100644 (file)
index 4dd606f..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-//
-// Mono.Cairo.TextExtents.cs
-//
-// Authors:
-//   Duncan Mak (duncan@ximian.com)
-//   Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace Crow.Drawing
-{
-       [StructLayout (LayoutKind.Sequential)]
-       public struct TextExtents
-       {
-               double xbearing;
-               double ybearing;
-               double width;
-               double height;
-               double xadvance;
-               double yadvance;
-               
-               public double XBearing {
-                       get { return xbearing; }
-                       set { xbearing = value; }
-               }
-               
-               public double YBearing {
-                       get { return ybearing; }
-                       set { ybearing = value; }
-               }
-               
-               public double Width {
-                       get { return width; }
-                       set { width = value; }
-               }
-               
-               public double Height {
-                       get { return height; }
-                       set { height = value; }
-               }
-               
-               public double XAdvance {
-                       get { return xadvance; }
-                       set { xadvance = value; }
-               }
-               
-               public double YAdvance {
-                       get { return yadvance; }
-                       set { yadvance = value; }
-               }
-
-               public override bool Equals (object obj)
-               {
-                       if (obj is TextExtents)
-                               return this == (TextExtents)obj;
-                       return false;
-               }
-
-               public override int GetHashCode ()
-               {
-                       return (int)XBearing ^ (int)YBearing ^ (int)Width ^ (int)Height ^ (int)XAdvance ^ (int)YAdvance;
-               }
-
-               public static bool operator == (TextExtents extents, TextExtents other)
-               {
-                       return extents.XBearing == other.XBearing && extents.YBearing == other.YBearing && extents.Width == other.Width && extents.Height == other.Height && extents.XAdvance == other.XAdvance && extents.YAdvance == other.YAdvance;
-               }
-
-               public static bool operator != (TextExtents extents, TextExtents other)
-               {
-                       return !(extents == other);
-               }
-       }
-}
index fda7d93f7c2b0c808490dbba779ba3498b1ea625..181799488c74b588278d1d3809e6a39e30aeb784 100644 (file)
@@ -29,7 +29,7 @@
 //
 using System;
 
-namespace Crow.Drawing
+namespace Crow.CairoBackend
 {
        public class WGLDevice : Device
        {
index 53b79e92a07e0438188fc34675d1772ffee90186..f620673e400be1b09c6dab289a525224a8515588 100644 (file)
 // distribute, sublicense, and/or sell copies of the Software, and to
 // permit persons to whom the Software is furnished to do so, subject to
 // the following conditions:
-// 
+//
 // The above copyright notice and this permission notice shall be
 // included in all copies or substantial portions of the Software.
-// 
+//
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
 using System;
 
-namespace Crow.Drawing {
-       
+namespace Crow.CairoBackend {
+
        public class Win32Surface : Surface
        {
                internal Win32Surface (IntPtr handle, bool owns) : base (handle, owns)
                {
                }
-               
+
                public Win32Surface (IntPtr hdc)
                        : base (NativeMethods.cairo_win32_surface_create (hdc), true)
                {
index 72c4dbe899d3e0c5773a8eb43c10924306129d72..affc46f80d2d43ddf3c822bafb22d4a4ad6c7365 100644 (file)
 // distribute, sublicense, and/or sell copies of the Software, and to
 // permit persons to whom the Software is furnished to do so, subject to
 // the following conditions:
-// 
+//
 // The above copyright notice and this permission notice shall be
 // included in all copies or substantial portions of the Software.
-// 
+//
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -28,7 +28,7 @@
 
 using System;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
        public class XcbSurface : Surface
        {
                internal XcbSurface (IntPtr handle, bool owns) : base (handle, owns)
@@ -46,7 +46,7 @@ namespace Crow.Drawing {
                        return new XcbSurface (ptr, true);
                }
                public override void SetSize (int width, int height)
-               {                       
+               {
                        NativeMethods.cairo_xcb_surface_set_size (Handle, width, height);
                }
        }
index fbe9e01f80e257db1c192049d20e3e3d13394872..602400e55bdef9be67cf8696b4045f99481ec01b 100644 (file)
 // distribute, sublicense, and/or sell copies of the Software, and to
 // permit persons to whom the Software is furnished to do so, subject to
 // the following conditions:
-// 
+//
 // The above copyright notice and this permission notice shall be
 // included in all copies or substantial portions of the Software.
-// 
+//
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -36,7 +36,7 @@
 
 using System;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
        public class XlibSurface : Surface
        {
@@ -68,8 +68,8 @@ namespace Crow.Drawing {
                public int Depth => NativeMethods.cairo_xlib_surface_get_depth (Handle);
                public IntPtr Display => NativeMethods.cairo_xlib_surface_get_display (Handle);
                public IntPtr Drawable => NativeMethods.cairo_xlib_surface_get_drawable (Handle);
-               public override int Width => NativeMethods.cairo_xlib_surface_get_width (Handle);               
-               public override int Height => NativeMethods.cairo_xlib_surface_get_height (Handle);             
+               public override int Width => NativeMethods.cairo_xlib_surface_get_width (Handle);
+               public override int Height => NativeMethods.cairo_xlib_surface_get_height (Handle);
 
                public IntPtr Screen => NativeMethods.cairo_xlib_surface_get_screen (Handle);
                public IntPtr Visual=> NativeMethods.cairo_xlib_surface_get_visual (Handle);
index fc2d8a2b138823db1c93af670435e07e75b8a5f8..1622ecfaf015200dfba848cc56d0b0af1d0f1147 100644 (file)
@@ -3,7 +3,7 @@ using System;
 using System.Runtime.InteropServices;
 using Drawing2D;
 
-namespace Crow.Drawing {
+namespace Crow.CairoBackend {
 
 
        public sealed class SvgHandle : IDisposable {
@@ -43,12 +43,12 @@ namespace Crow.Drawing {
                        Raw = rsvg_handle_new();
                }
                public  SvgHandle (byte[] data)
-               {                       
+               {
                        Raw = rsvg_handle_new_from_data(data, new UIntPtr ((ulong) (data == null ? 0 : data.Length)), out IntPtr error);
                        if (error != IntPtr.Zero) throw new Exception (error.ToString());
                }
                public SvgHandle (string file_name)
-               {                       
+               {
                        Raw = rsvg_handle_new_from_file(file_name, out IntPtr error);
                        if (error != IntPtr.Zero) throw new Exception (error.ToString());
                }
@@ -60,10 +60,10 @@ namespace Crow.Drawing {
 
                public void Render(Context cr) =>
                        rsvg_handle_render_cairo (Raw, cr == null ? IntPtr.Zero : cr.Handle);
-               
+
                public void Render (Context cr, string id) =>
                        rsvg_handle_render_cairo_sub (Raw, cr == null ? IntPtr.Zero : cr.Handle, id);
-               
+
                [StructLayout(LayoutKind.Sequential)]
                struct DimensionData {
 
@@ -79,7 +79,7 @@ namespace Crow.Drawing {
                                        return DimensionData.Zero;
                                return (DimensionData) Marshal.PtrToStructure (raw, typeof (DimensionData));
                        }
-               }               
+               }
                public Size Dimensions {
                        get {
                                DimensionData dimension_data;
@@ -91,9 +91,9 @@ namespace Crow.Drawing {
                        }
                }
 
-               public void Dispose() {                 
+               public void Dispose() {
                        bool raw_ret = rsvg_handle_close(Raw, out IntPtr error);
-                       if (error != IntPtr.Zero) throw new Exception (error.ToString());                       
+                       if (error != IntPtr.Zero) throw new Exception (error.ToString());
                }
        }
 }
index f4fe4d57ae6cc731f56910a44c0c277e5a5b71cf..c14bad89ccbc5a6885dc50509aaca0aefd18784c 100644 (file)
@@ -2,6 +2,7 @@
 
   <PropertyGroup>
                <TargetFramework>netcoreapp3.0</TargetFramework>
+               <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
   </PropertyGroup>
 
        <ItemGroup>
index 5a7fdc4e0deebd5c0df7037cd10d366ed01e893b..ea3b3a02a79a99884fe65a66213240adf277d020 100644 (file)
                <PackageReference Include="glfw-sharp" Version="$(GlfwSharpVersion)" />
        </ItemGroup>
 
-       <PropertyGroup Condition=" '$(CrowStbSharp)' == 'true'">
-               <DefineConstants>$(DefineConstants);STB_SHARP</DefineConstants>
-       </PropertyGroup>
-       <ItemGroup Condition=" '$(CrowStbSharp)' == 'true'">
-               <PackageReference Include="StbImageSharp" Version="2.22.4" />
-       </ItemGroup>
-
        <PropertyGroup Condition=" '$(CrowDebugLogEnabled)' == 'true'">
                <DefineConstants>$(DefineConstants);DEBUG_LOG</DefineConstants>
        </PropertyGroup>
index faefd4ed4c872a22da7c3efbb8f5aa6343cbc0d0..3f59c3d6b931a28b1b2d7ce201a26ae360f0ebff 100644 (file)
@@ -62,21 +62,21 @@ namespace Crow
        #endif
                        Dimensions = new Size (stbi.Width, stbi.Height);
 #else
-                               using (StbImage stbi = new StbImage (stream)) {
-                                       image = new byte [stbi.Size];
+                       using (StbImage stbi = new StbImage (stream)) {
+                               image = new byte [stbi.Size];
        #if VKVG
-                                       Marshal.Copy (stbi.Handle, image, 0, stbi.Size);
+                               Marshal.Copy (stbi.Handle, image, 0, stbi.Size);
        #else
-                                       for (int i = 0; i < stbi.Size; i+=4) {
-                                               //rgba to argb for cairo. ???? looks like bgra to me.
-                                               image [i] = Marshal.ReadByte (stbi.Handle, i + 2);
-                                               image [i + 1] = Marshal.ReadByte (stbi.Handle, i + 1);
-                                               image [i + 2] = Marshal.ReadByte (stbi.Handle, i);
-                                               image [i + 3] = Marshal.ReadByte (stbi.Handle, i + 3);
-                                       }
-       #endif
-                                       Dimensions = new Size (stbi.Width, stbi.Height);
+                               for (int i = 0; i < stbi.Size; i+=4) {
+                                       //rgba to argb for cairo. ???? looks like bgra to me.
+                                       image [i] = Marshal.ReadByte (stbi.Handle, i + 2);
+                                       image [i + 1] = Marshal.ReadByte (stbi.Handle, i + 1);
+                                       image [i + 2] = Marshal.ReadByte (stbi.Handle, i);
+                                       image [i + 3] = Marshal.ReadByte (stbi.Handle, i + 3);
                                }
+       #endif
+                               Dimensions = new Size (stbi.Width, stbi.Height);
+                       }
 #endif
                }
                internal static sharedPicture CreateSharedPicture (Stream stream) {
@@ -129,21 +129,13 @@ namespace Crow
                                        widthRatio = heightRatio;
                        }
 
-#if VKVG
-                       using (Surface tmp = new Surface (iFace.vkvgDevice, bounds.Width, bounds.Height)) {
-#else
-                       using (Surface tmp = new ImageSurface (Format.Argb32, bounds.Width, bounds.Height)) {
-#endif
-                               using (IContext gr = new Context (tmp)) {
+                       using (ISurface tmp = iFace.Device.CreateSurface (bounds.Width, bounds.Height)) {
+                               using (IContext gr = iFace.Device.CreateContext (tmp)) {
                                        gr.Translate (bounds.Left, bounds.Top);
                                        gr.Scale (widthRatio, heightRatio);
                                        gr.Translate ((bounds.Width/widthRatio - Dimensions.Width)/2, (bounds.Height/heightRatio - Dimensions.Height)/2);
-#if VKVG
-                                       using (Surface imgSurf = new Surface (iFace.vkvgDevice, image, Dimensions.Width, Dimensions.Height))
-#else
-                                       using (Surface imgSurf = new ImageSurface (image, Format.Argb32, Dimensions.Width, Dimensions.Height, 4 * Dimensions.Width))
-#endif
-                                       {
+
+                                       using (ISurface imgSurf = iFace.Device.CreateSurface (bounds.Width, bounds.Height)) {
                                                gr.SetSource (imgSurf, 0,0);
                                                gr.Paint ();
                                        }
@@ -151,7 +143,7 @@ namespace Crow
                                ctx.SetSource (tmp);
                        }
                }
-#endregion
+               #endregion
 
                /// <summary>
                /// paint the image in the rectangle given in arguments according
index 4db0163fc660ee8470e1404a2018326195d8d45f..be1a203f1601189e01dfcd851e3ecf22f85625d0 100644 (file)
@@ -122,11 +122,6 @@ namespace Crow
                        if (!Directory.Exists (CROW_CONFIG_ROOT))
                                Directory.CreateDirectory (CROW_CONFIG_ROOT);
 
-                       FontRenderingOptions = new FontOptions ();
-                       FontRenderingOptions.Antialias = Antialias.Subpixel;
-                       FontRenderingOptions.HintMetrics = HintMetrics.On;
-                       FontRenderingOptions.HintStyle = HintStyle.Full;
-                       FontRenderingOptions.SubpixelOrder = SubpixelOrder.Default;
                }
                /// <summary>
                /// Each time this array is set, the resolved Assemblies will be
@@ -288,27 +283,7 @@ namespace Crow
                        initBackend ();
                        vkCtx.CreateSurface (clientRectangle.Width, clientRectangle.Height, ref surf);
 #else
-                       switch (Environment.OSVersion.Platform) {
-                       case PlatformID.MacOSX:
-                               break;
-                       case PlatformID.Unix:
-                               IntPtr disp = Glfw3.GetX11Display ();
-                               IntPtr nativeWin = Glfw3.GetX11Window (hWin);
-                               Int32 scr = Glfw3.GetX11DefaultScreen (disp);
-                               IntPtr visual = Glfw3.GetX11DefaultVisual (disp, scr);
-                               surf = new XlibSurface (disp, nativeWin, visual, clientRectangle.Width, clientRectangle.Height);
-                               break;
-                       case PlatformID.Win32NT:
-                       case PlatformID.Win32S:
-                       case PlatformID.Win32Windows:
-                               IntPtr hWin32 = Glfw3.GetWin32Window (hWin);
-                               IntPtr hdc = Glfw3.GetWin32DC (hWin32);
-                               surf = new Win32Surface (hdc);
-                               break;
-                       case PlatformID.Xbox:
-                       case PlatformID.WinCE:
-                               throw new PlatformNotSupportedException ("Unable to create cairo surface.");
-                       }
+
 #endif
                }
                /// <summary>
@@ -321,44 +296,12 @@ namespace Crow
                        vkCtx.CreateSurface (clientRectangle.Width, clientRectangle.Height, ref surf);
 #else
                        surf = new ImageSurface (Format.ARGB32, r.Width, r.Height);
-#endif
-               }
-               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 Surface CreateSurfaceForData (IntPtr data, int width, int height) {
-#if (VKVG)
-                       throw new NotImplementedException ();
-#else
-                       return new ImageSurface (data, Format.Argb32, width, height, width * 4);
 #endif
                }
                public IntPtr SurfacePointer {
                        get {
                                lock(UpdateMutex)
-#if (VKVG)
-                                       return (vkCtx as OffscreenVulkanContext).bitmap;
-#else
                                        return surf.Handle;
-#endif
                        }
                }
                /// <summary>
@@ -679,10 +622,6 @@ namespace Crow
                /// <summary> Above this count, the layouting is discard for the widget and it
                /// will not be rendered on screen </summary>
                public static int MaxDiscardCount = 5;
-               /// <summary> Global font rendering settings for Cairo </summary>
-               public static FontOptions FontRenderingOptions;
-               /// <summary> Global font rendering settings for Cairo </summary>
-               public static Antialias Antialias = Antialias.Subpixel;
 
                /// <summary>
                /// Each control need a ref to the root interface containing it, if not set in Widget.currentInterface,
@@ -712,8 +651,8 @@ namespace Crow
                public event EventHandler<KeyEventArgs> KeyboardKeyUp;*/
                #endregion
 
-               /// <summary>Main Cairo surface</summary>
-               public Surface surf;
+               /// <summary>Main backend surface</summary>
+               public ISurface surf;
 
                #region Public Fields
                /// <summary>Graphic Tree of this interface</summary>
@@ -767,7 +706,7 @@ namespace Crow
                public DragDropEventArgs DragAndDropOperation = null;
                internal Widget dragndropHover;
 
-               public Surface DragImage = null;
+               public ISurface DragImage = null;
                public Rectangle DragImageBounds, lastDragImageBounds;
                public bool DragImageFolowMouse;//prevent dragImg to be moved by mouse
                public void ClearDragImage () {
@@ -780,7 +719,7 @@ namespace Crow
                                DragImageBounds = lastDragImageBounds = default;
                        }
                }
-               public void CreateDragImage (Surface img, Rectangle bounds, bool followMouse = true) {
+               public void CreateDragImage (ISurface img, Rectangle bounds, bool followMouse = true) {
                        lock (UpdateMutex) {
                                if (DragImage != null)
                                        ClearDragImage ();
diff --git a/Crow/src/StbImage.cs b/Crow/src/StbImage.cs
deleted file mode 100644 (file)
index 8cb4d75..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) 2019  Jean-Philippe Bruyère <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.Runtime.InteropServices;
-
-namespace Crow {
-    public class StbImage : IDisposable {
-        const string stblib = "stb";
-
-        [DllImport (stblib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load")]
-        static extern IntPtr Load ([MarshalAs (UnmanagedType.LPStr)] string filename, out int x, out int y, out int channels_in_file, int desired_channels);
-
-               [DllImport (stblib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_from_memory")]
-        static extern IntPtr Load (IntPtr bitmap, int byteCount, out int x, out int y, out int channels_in_file, int desired_channels);        
-
-        [DllImport (stblib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_image_free")]
-        static extern void FreeImage (IntPtr img);
-
-               public readonly IntPtr Handle;
-               public readonly int Width;
-               public readonly int Height;
-               public readonly int Channels;
-               public int Size => Width * Height * Channels;
-
-               /// <summary>
-               /// Open image file with STBI library
-               /// </summary>
-               /// <param name="path">file path</param>
-               /// <param name="requestedChannels">Force returned channels count, set 0 for original count</param>
-               public StbImage (string path, int requestedChannels = 4) {
-                       Handle = StbImage.Load (path, out Width, out Height, out Channels, requestedChannels);
-                       if (Handle == IntPtr.Zero)
-                               throw new Exception ($"STBI image loading error.");
-                       if (requestedChannels > 0)
-                               Channels = requestedChannels;
-               }
-               /// <summary>
-               /// Open image in memory with STBI library
-               /// </summary>
-               /// <param name="bitmap">raw bitmap datas</param>
-               /// <param name="bitmapByteCount">Bitmap byte count.</param>
-               /// <param name="requestedChannels">Force returned channels count, set 0 for original count</param>
-               public StbImage (IntPtr bitmap, ulong bitmapByteCount, int requestedChannels = 4) {
-                       Handle = StbImage.Load (bitmap, (int)bitmapByteCount, out Width, out Height, out Channels, requestedChannels);
-                       if (Handle == IntPtr.Zero)
-                               throw new Exception ($"STBI image loading error.");
-                       if (requestedChannels > 0)
-                               Channels = requestedChannels;
-               }
-               public StbImage (Stream stream, int requestedChannels = 4)
-               {
-                       byte [] buff = new byte [stream.Length];
-                       stream.Read (buff, 0, (int)stream.Length);
-                       GCHandle hnd = GCHandle.Alloc (buff, GCHandleType.Pinned);
-                       Handle = StbImage.Load (hnd.AddrOfPinnedObject(), (int)stream.Length, out Width, out Height, out Channels, requestedChannels);
-                       hnd.Free ();
-                       if (Handle == IntPtr.Zero)
-                               throw new Exception ($"STBI image loading error.");
-                       if (requestedChannels > 0)
-                               Channels = requestedChannels;
-               }
-               public void Dispose () {
-                       StbImage.FreeImage (Handle);
-               }
-       }
-}
index 58810666ef1f6374920c89569cd625c4243a51ef..3b31ea43d1845663c3ac8182fef78413216abfe2 100644 (file)
@@ -7,6 +7,7 @@ using System.Xml.Serialization;
 using System.ComponentModel;
 using System.Collections.Generic;
 using System.Linq;
+using Drawing2D;
 
 namespace Crow
 {
index d0b571915985accf6639ceb48287b9f59a626b20..6c6c49f9c21a24dc6ef83de2fe94b5046618dd09 100644 (file)
@@ -200,8 +200,8 @@ namespace Crow
                                        r.Inflate (r.Width / -3, r.Height / -3);
                                        break;
                                }
-                   Surface dragImg = IFace.CreateSurface (r.Width, r.Height);
-                               using (IContext gr = new Context(dragImg)) {
+                   ISurface dragImg = IFace.Device.CreateSurface (r.Width, r.Height);
+                               using (IContext gr = IFace.Device.CreateContext (dragImg)) {
                                        gr.LineWidth = 1;
                                        gr.Rectangle (0,0,r.Width,r.Height);
                                        gr.SetSource (0.2,0.3,0.9,0.5);
index 1de8787f8b5da7b659e8a361e823d8dd77ceb44b..1f62eb902eafd292ac56357af90e6b8a6d9e30b1 100644 (file)
@@ -7,7 +7,7 @@ using System.Collections.Generic;
 using System.ComponentModel;
 
 using System.Threading;
-
+using Drawing2D;
 using static Crow.Logger;
 
 
@@ -251,7 +251,7 @@ namespace Crow
                {
                        DbgLogger.StartEvent(DbgEvtType.GOUpdateCache, this);
                        if (!Clipping.IsEmpty) {
-                               using (IContext gr = new Context (bmp)) {
+                               using (IContext gr = IFace.Device.CreateContext (bmp)) {
                                        for (int i = 0; i < Clipping.NumRectangles; i++)
                                                gr.Rectangle(Clipping.GetRectangle(i));
                                        gr.ClipPreserve();
index e012f352f87049f79789f1dbc9c64e8f0f2b020a..3c3795c4641929d7aca270ae2e50b378dbbf1d02 100644 (file)
@@ -514,8 +514,9 @@ namespace Crow
                        int hoverLine = _multiline ?
                                (int)Math.Min (Math.Max (0, Math.Floor (mouseLocalPos.Y / (fe.Ascent + fe.Descent))), lines.Count - 1) : 0;
                        hoverLoc = new CharLocation (hoverLine, -1, mouseLocalPos.X);
-                       using (IContext gr = new Context (IFace.surf)) {
-                               setFontForContext (gr);
+                       using (IContext gr = IFace.Device.CreateContext (IFace.surf)) {
+                               gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                               gr.SetFontSize (Font.Size);
                                updateLocation (gr, ClientRectangle.Width, ref hoverLoc);
                        }
                }
@@ -533,7 +534,8 @@ namespace Crow
                                return false;
                        }
                        if (!CurrentLoc.Value.HasVisualX) {
-                               setFontForContext (ctx);
+                               ctx.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                               ctx.SetFontSize (Font.Size);
                                lock (linesMutex) {
                                        if (currentLoc?.Column < 0) {
                                                updateLocation (ctx, ClientRectangle.Width, ref currentLoc);
@@ -648,8 +650,9 @@ namespace Crow
                                getLines ();
 
                        if (!textMeasureIsUpToDate) {
-                               using (IContext gr = new Context (IFace.surf)) {
-                                       setFontForContext (gr);
+                               using (IContext gr = IFace.Device.CreateContext (IFace.surf)) {
+                                       gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                                       gr.SetFontSize (Font.Size);
                                        measureTextBounds (gr);
                                }
                        }
@@ -663,7 +666,8 @@ namespace Crow
                        try {
                                base.onDraw (gr);
 
-                               setFontForContext (gr);
+                               gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+                               gr.SetFontSize (Font.Size);
 
                                if (!textMeasureIsUpToDate) {
                                        lock (linesMutex)
index 498ba80b7f9002dec7c7ad29d1ba48b62911e321..3b705ea51ef0050a1fdee63a2b8e102e600030d6 100644 (file)
@@ -215,7 +215,7 @@ namespace Crow
 
                        Rectangle rb = Slot + Parent.ClientRectangle.Position;
                        if (!Clipping.IsEmpty) {
-                               using (IContext gr = new Context (bmp)) {
+                               using (IContext gr = IFace.Device.CreateContext (bmp)) {
                                        for (int i = 0; i < Clipping.NumRectangles; i++)
                                                gr.Rectangle(Clipping.GetRectangle(i));
                                        gr.ClipPreserve();
index de9c0005edd19649f3aa339e2edac294294ae443..c67bf7d1dbaec49e7be92644017e2de9d3c6dbfd 100644 (file)
@@ -4,7 +4,7 @@
 
 using System;
 using System.ComponentModel;
-
+using Drawing2D;
 
 namespace Crow {
        public class ScrollingStack : GenericStack {
@@ -136,7 +136,7 @@ namespace Crow {
                {
                        DbgLogger.StartEvent(DbgEvtType.GOUpdateCache, this);
                        if (!Clipping.IsEmpty) {
-                               using (IContext gr = new Context (bmp)) {
+                               using (IContext gr = IFace.Device.CreateContext (bmp)) {
                                        for (int i = 0; i < Clipping.NumRectangles; i++)
                                                gr.Rectangle(Clipping.GetRectangle(i));
                                        gr.ClipPreserve();
index c6cca0d60429b1b863fb30689e89c19d698fec05..fea5d1e3e6816ee82571f36ff59d59b5c0a658e0 100644 (file)
@@ -244,7 +244,7 @@ namespace Crow
                                if (size != default (Size))
                                        contentSize = size;
                                else {
-                                       using (IContext ctx = new Context (IFace.surf)) {
+                                       using (IContext ctx = IFace.Device.CreateContext (IFace.surf)) {
                                                using (PathParser parser = new PathParser (path))
                                                        parser.Draw (ctx, true);
                                                Rectangle r = ctx.StrokeExtents ();
index a59576d3a9e105dfeee2979468e7068a338f0e77..09f4f5cf49300cfe19a6cf23d74aa0df2a37ad0f 100644 (file)
@@ -6,7 +6,7 @@ using System;
 using System.ComponentModel;
 using System.IO;
 using System.Xml;
-
+using Drawing2D;
 
 namespace Crow
 {
index 45c62efa31aa972e29012281e50c73bc4eb35404..875fa1a7284c7e67a13d9954e4ea536461cce233 100644 (file)
@@ -189,7 +189,7 @@ namespace Crow
 #endif
 
                /// <summary>
-               /// The interface this widget is bound to when instantiated, 
+               /// The interface this widget is bound to when instantiated,
                /// </summary>
                public readonly Interface IFace = null;
 
@@ -330,7 +330,7 @@ namespace Crow
                /// <summary>Prevent requeuing multiple times the same widget</summary>
                public bool IsQueueForClipping = false;
                /// <summary>drawing Cache, if null, a redraw is done on repaint, cached or not</summary>
-               public Surface bmp;
+               public ISurface bmp;
                /// <summary>
                /// If the widget dirty state is set to true, a full redraw will be triggered on paint.
                /// </summary>
@@ -1928,16 +1928,7 @@ namespace Crow
                #endregion
 
                protected void setFontForContext (IContext gr) {
-#if VKVG
-                       gr.FontFace = Font.Name;
-                       gr.FontSize = (uint)Font.Size;
 
-#else
-                       gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
-                       gr.SetFontSize (Font.Size);
-                       gr.FontOptions = Interface.FontRenderingOptions;
-                       gr.Antialias = Interface.Antialias;
-#endif
                }
 
                #region Rendering
@@ -1978,9 +1969,8 @@ namespace Crow
                        //bmp = new ImageSurface(Format.Argb32, Slot.Width, Slot.Height);
 
                        DbgLogger.StartEvent (DbgEvtType.GOCreateContext, this);
-                       using (IContext gr = new Context (bmp)) {
+                       using (IContext gr = IFace.Device.CreateContext (bmp)) {
                                DbgLogger.EndEvent (DbgEvtType.GOCreateContext);
-                               gr.Antialias = Interface.Antialias;
                                onDraw (gr);
                        }
 
index 0bb94879748c5ffe3922967eed6543a59f24f4f9..33b36ca2fad741f550e2ab9abd4fde4caf273f9c 100644 (file)
                <PackageReference Include="Enums.NET" Version="4.0.0" />
        </ItemGroup>
 
+       <PropertyGroup Condition=" '$(CrowStbSharp)' == 'true'">
+               <DefineConstants>$(DefineConstants);STB_SHARP</DefineConstants>
+       </PropertyGroup>
+       <ItemGroup Condition=" '$(CrowStbSharp)' == 'true'">
+               <Compile Remove="src\StbImage.cs" />
+               <PackageReference Include="StbImageSharp" Version="2.22.4" />
+       </ItemGroup>
+
 
 </Project>
diff --git a/Drawing2D/src/Device.cs b/Drawing2D/src/Device.cs
deleted file mode 100644 (file)
index 8beb1b7..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) 2018-2020  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
-//
-// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
-
-using System;
-
-namespace Drawing2D
-{
-       public interface IDevice: IDisposable
-       {
-               //IntPtr Handle => handle;
-
-               void GetDpy (out int hdpy, out int vdpy);
-               void SetDpy (int hdpy, int vdpy);
-               ISurface CreateSurface (int width, int height);
-       }
-}
-
index d393289b976342ae4fad0d55ee843f1b77f62e60..9e080613fc0fe9c40337583fec4cc223be76c106 100644 (file)
@@ -14,11 +14,11 @@ namespace Drawing2D
                double LineWidth { get; set; }
                LineJoin LineJoin { get; set; }
                LineCap LineCap { get; set; }
-               uint FontSize { get; set; }
-               string FontFace { get; set; }
+               void SetFontSize (double scale);
+               void SelectFontFace (string family, FontSlant slant, FontWeight weight);
                Operator Operator { get; set; }
                FillRule FillRule { get; set; }
-               FontExtents FontExtents { get; set; }
+               FontExtents FontExtents { get; }
                Antialias Antialias  { get; set; }
                TextExtents TextExtents (ReadOnlySpan<char> s, int tabSize = 4);
                void TextExtents (ReadOnlySpan<char> s, int tabSize, out TextExtents extents);
diff --git a/Drawing2D/src/IDevice.cs b/Drawing2D/src/IDevice.cs
new file mode 100644 (file)
index 0000000..0222489
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (c) 2018-2020  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+using System;
+
+namespace Drawing2D
+{
+       public interface IDevice: IDisposable
+       {
+               //IntPtr Handle => handle;
+
+               void GetDpy (out int hdpy, out int vdpy);
+               void SetDpy (int hdpy, int vdpy);
+               ISurface CreateSurface (int width, int height);
+               
+               IContext CreateContext (ISurface surf);
+       }
+}
+
diff --git a/Drawing2D/src/ISurface.cs b/Drawing2D/src/ISurface.cs
new file mode 100644 (file)
index 0000000..37bb510
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright (c) 2022  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+using System;
+
+namespace Drawing2D
+{
+       public interface ISurface: IDisposable
+       {
+               IntPtr Handle { get; }
+               int Width { get; }
+               int Height { get; }
+
+               void Flush ();
+
+               void WriteToPng (string path);
+               void WriteTo (IntPtr bitmap);
+               void Clear ();
+               ISurface CreateSimilar (int width, int height);
+       }
+}
+
diff --git a/Drawing2D/src/StbImage.cs b/Drawing2D/src/StbImage.cs
new file mode 100644 (file)
index 0000000..a55f377
--- /dev/null
@@ -0,0 +1,68 @@
+// Copyright (c) 2019-2021  Jean-Philippe Bruyère <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.Runtime.InteropServices;
+
+namespace Drawing2D {
+    public class StbImage : IDisposable {
+        const string stblib = "stb";
+
+        [DllImport (stblib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load")]
+        static extern IntPtr Load ([MarshalAs (UnmanagedType.LPStr)] string filename, out int x, out int y, out int channels_in_file, int desired_channels);
+
+               [DllImport (stblib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_from_memory")]
+        static extern IntPtr Load (IntPtr bitmap, int byteCount, out int x, out int y, out int channels_in_file, int desired_channels);        
+
+        [DllImport (stblib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_image_free")]
+        static extern void FreeImage (IntPtr img);
+
+               public readonly IntPtr Handle;
+               public readonly int Width;
+               public readonly int Height;
+               public readonly int Channels;
+               public int Size => Width * Height * Channels;
+
+               /// <summary>
+               /// Open image file with STBI library
+               /// </summary>
+               /// <param name="path">file path</param>
+               /// <param name="requestedChannels">Force returned channels count, set 0 for original count</param>
+               public StbImage (string path, int requestedChannels = 4) {
+                       Handle = StbImage.Load (path, out Width, out Height, out Channels, requestedChannels);
+                       if (Handle == IntPtr.Zero)
+                               throw new Exception ($"STBI image loading error.");
+                       if (requestedChannels > 0)
+                               Channels = requestedChannels;
+               }
+               /// <summary>
+               /// Open image in memory with STBI library
+               /// </summary>
+               /// <param name="bitmap">raw bitmap datas</param>
+               /// <param name="bitmapByteCount">Bitmap byte count.</param>
+               /// <param name="requestedChannels">Force returned channels count, set 0 for original count</param>
+               public StbImage (IntPtr bitmap, ulong bitmapByteCount, int requestedChannels = 4) {
+                       Handle = StbImage.Load (bitmap, (int)bitmapByteCount, out Width, out Height, out Channels, requestedChannels);
+                       if (Handle == IntPtr.Zero)
+                               throw new Exception ($"STBI image loading error.");
+                       if (requestedChannels > 0)
+                               Channels = requestedChannels;
+               }
+               public StbImage (Stream stream, int requestedChannels = 4)
+               {
+                       byte [] buff = new byte [stream.Length];
+                       stream.Read (buff, 0, (int)stream.Length);
+                       GCHandle hnd = GCHandle.Alloc (buff, GCHandleType.Pinned);
+                       Handle = StbImage.Load (hnd.AddrOfPinnedObject(), (int)stream.Length, out Width, out Height, out Channels, requestedChannels);
+                       hnd.Free ();
+                       if (Handle == IntPtr.Zero)
+                               throw new Exception ($"STBI image loading error.");
+                       if (requestedChannels > 0)
+                               Channels = requestedChannels;
+               }
+               public void Dispose () {
+                       StbImage.FreeImage (Handle);
+               }
+       }
+}
diff --git a/Drawing2D/src/Surface.cs b/Drawing2D/src/Surface.cs
deleted file mode 100644 (file)
index 696f1ae..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2022  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
-//
-// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
-
-using System;
-
-namespace Drawing2D
-{
-       public interface ISurface: IDisposable
-       {
-               //IntPtr Handle { get; }
-               int Width { get; }
-               int Height { get; }
-
-               void Flush ();
-
-               void WriteToPng (string path);
-               void WriteTo (IntPtr bitmap);
-               void Clear ();
-               ISurface CreateSimilar (int width, int height);
-       }
-}
-