diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-04-19 18:19:42 +0200 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-04-19 18:19:42 +0200 |
| commit | 4cad485acceb90664d8b5a8c2ca82c08441988a4 (patch) | |
| tree | a28e6dd5d0d2324956c362781b961824b78a1e2d | |
| parent | d7bd85c20b11c4a3eb53b708524457a18e7ac025 (diff) | |
wip, lots to do...vkvg_backend
121 files changed, 1746 insertions, 48 deletions
diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj index 083b1989..4c40be81 100644 --- a/Crow/Crow.csproj +++ b/Crow/Crow.csproj @@ -43,13 +43,6 @@ <PackageReference Include="glfw-sharp" Version="$(GlfwSharpVersion)" /> </ItemGroup> - <PropertyGroup Condition=" '$(CrowVkvgBackend)' == 'true'"> - <DefineConstants>$(DefineConstants);VKVG</DefineConstants> - </PropertyGroup> - <ItemGroup Condition=" '$(CrowVkvgBackend)' == 'true'"> - <PackageReference Include="vkvg.net" Version="0.2.2-beta" /> - </ItemGroup> - <PropertyGroup Condition=" '$(CrowStbSharp)' == 'true'"> <DefineConstants>$(DefineConstants);STB_SHARP</DefineConstants> </PropertyGroup> @@ -64,9 +57,21 @@ <ProjectReference Include="..\CrowDbgShared\CrowDbgShared.csproj" /> </ItemGroup> + <PropertyGroup Condition=" '$(CrowVkvgBackend)' == 'true'"> + <DefineConstants>$(DefineConstants);VKVG</DefineConstants> + </PropertyGroup> + <ItemGroup Condition=" '$(CrowVkvgBackend)' == 'true'"> + <Compile Include="src\GraphicBackends\vkvg\**\*.*" /> + </ItemGroup> + + <ItemGroup Condition=" '$(CrowVkvgBackend)' != 'true'"> + <Compile Include="src\GraphicBackends\Mono.Cairo\**\*.*" + Exclude="src\GraphicBackends\Mono.Cairo\NativeMethods-internal.cs" /> + </ItemGroup> + <ItemGroup> <Content Include="..\Images\crow.png" Pack="true" PackagePath="" /> - <Compile Include="src\**\*.cs" Exclude="src\Mono.Cairo\NativeMethods-internal.cs" /> + <Compile Include="src\**\*.cs" Exclude="src\GraphicBackends\**\*.*" /> <EmbeddedResource Include="Templates\*.*"> <LogicalName>Crow.%(Filename).template</LogicalName> </EmbeddedResource> diff --git a/Crow/src/Cairo/CairoHelpers.cs b/Crow/src/Cairo/CairoHelpers.cs index a2e036ac..129879a1 100644 --- a/Crow/src/Cairo/CairoHelpers.cs +++ b/Crow/src/Cairo/CairoHelpers.cs @@ -1,38 +1,22 @@ -// -// CairoHelpers.cs +// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com> // -// Author: -// Jean-Philippe Bruyère <jp.bruyere@hotmail.com> -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// 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. +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; using System.Collections.Generic; using System.Linq; using System.Text; +#if VKVG +using vkvg; +#else +using Crow.Cairo; +#endif + namespace Crow { public static class CairoHelpers - { + { public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T> { if (val.CompareTo(min) < 0) return min; @@ -57,18 +41,18 @@ namespace Crow return arr[minp]; } - public static void CairoRectangle(Cairo.Context gr, RectangleD r, double radius, double stroke = 0.0) + public static void CairoRectangle(Context gr, RectangleD r, double radius, double stroke = 0.0) { if (radius > 0) DrawRoundedRectangle (gr, r, radius, stroke); else gr.Rectangle (r, stroke); } - public static void CairoCircle(Cairo.Context gr, RectangleD r) + public static void CairoCircle(Context gr, RectangleD r) { gr.Arc(r.X + r.Width/2.0, r.Y + r.Height/2.0, Math.Min(r.Width,r.Height)/2.0, 0, 2.0*Math.PI); } - public static void DrawRoundedRectangle(Cairo.Context gr, RectangleD r, double radius, double stroke = 0.0) + public static void DrawRoundedRectangle(Context gr, RectangleD r, double radius, double stroke = 0.0) { if (stroke>0.0) { gr.LineWidth = stroke; @@ -78,7 +62,7 @@ namespace Crow }else DrawRoundedRectangle(gr, r.X, r.Y, r.Width, r.Height, radius); } - public static void DrawRoundedRectangle(Cairo.Context gr, double x, double y, double width, double height, double radius) + public static void DrawRoundedRectangle(Context gr, double x, double y, double width, double height, double radius) { gr.Save(); @@ -96,7 +80,7 @@ namespace Crow gr.ClosePath(); gr.Restore(); } - public static void StrokeRaisedRectangle(Cairo.Context gr, Rectangle r, double width = 1) + public static void StrokeRaisedRectangle(Context gr, Rectangle r, double width = 1) { gr.Save(); r.Inflate((int)-width / 2, (int)-width / 2); @@ -115,7 +99,7 @@ namespace Crow gr.Restore(); } - public static void StrokeLoweredRectangle(Cairo.Context gr, Rectangle r, double width = 1) + public static void StrokeLoweredRectangle(Context gr, Rectangle r, double width = 1) { gr.Save(); r.Inflate((int)-width / 2, (int)-width / 2); diff --git a/Crow/src/ExtensionsMethods.cs b/Crow/src/ExtensionsMethods.cs index f8aefaf1..d7ebb3f2 100644 --- a/Crow/src/ExtensionsMethods.cs +++ b/Crow/src/ExtensionsMethods.cs @@ -8,13 +8,19 @@ using System.IO; using System.Linq; using System.Linq.Expressions; +#if VKVG +using vkvg; +#else +using Crow.Cairo; +#endif + namespace Crow { public static class ExtensionsMethods { #region Cairo extensions - public static void Rectangle(this Cairo.Context ctx, Rectangle r, double stroke = 0.0) + public static void Rectangle(this Context ctx, Rectangle r, double stroke = 0.0) { if (stroke > 0.0) { ctx.LineWidth = stroke; @@ -48,7 +54,7 @@ namespace Crow public static PointD Multiply(this PointD p1, double v){ return new PointD(p1.X * v, p1.Y * v); } - public static void DrawCote(this Cairo.Context ctx, PointD p1, PointD p2, + public static void DrawCote(this Context ctx, PointD p1, PointD p2, double stroke = 1.0, bool fill = false, double arrowWidth = 3.0, double arrowLength = 7.0) { PointD vDir = p2.Substract(p1); @@ -85,7 +91,7 @@ namespace Crow ctx.LineWidth = stroke; ctx.Stroke (); } - public static void DrawCoteInverse(this Cairo.Context ctx, PointD p1, PointD p2, + public static void DrawCoteInverse(this Context ctx, PointD p1, PointD p2, double stroke = 1.0, bool fill = false, double arrowWidth = 3.0, double arrowLength = 7.0) { PointD vDir = p2.Substract(p1); @@ -117,7 +123,7 @@ namespace Crow ctx.LineWidth = stroke; ctx.Stroke (); } - public static void DrawCoteFixed(this Cairo.Context ctx, PointD p1, PointD p2, + public static void DrawCoteFixed(this Context ctx, PointD p1, PointD p2, double stroke = 1.0, double coteWidth = 3.0) { PointD vDir = p2.Substract(p1); @@ -135,7 +141,7 @@ namespace Crow ctx.Stroke (); } - public static void AddColorStop(this Cairo.Gradient grad, double offset, Color c) + public static void AddColorStop(this Gradient grad, double offset, Color c) { grad.AddColorStop (offset, c); } diff --git a/Crow/src/Fill/BmpPicture.cs b/Crow/src/Fill/BmpPicture.cs index 0f67323d..e8df7269 100644 --- a/Crow/src/Fill/BmpPicture.cs +++ b/Crow/src/Fill/BmpPicture.cs @@ -5,7 +5,11 @@ using System; using System.IO; using System.Runtime.InteropServices; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Fill/Fill.cs b/Crow/src/Fill/Fill.cs index a11b666e..d9f3c69a 100644 --- a/Crow/src/Fill/Fill.cs +++ b/Crow/src/Fill/Fill.cs @@ -3,7 +3,11 @@ // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Fill/Gradient.cs b/Crow/src/Fill/Gradient.cs index ac6a638e..680e1d0f 100644 --- a/Crow/src/Fill/Gradient.cs +++ b/Crow/src/Fill/Gradient.cs @@ -26,7 +26,11 @@ using System; using System.Collections.Generic; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Fill/Picture.cs b/Crow/src/Fill/Picture.cs index c9b23404..8c885bc8 100644 --- a/Crow/src/Fill/Picture.cs +++ b/Crow/src/Fill/Picture.cs @@ -26,7 +26,11 @@ using System; using System.IO; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using System.Collections.Generic; namespace Crow diff --git a/Crow/src/Fill/SolidColor.cs b/Crow/src/Fill/SolidColor.cs index 8ed77fbe..1c183d97 100644 --- a/Crow/src/Fill/SolidColor.cs +++ b/Crow/src/Fill/SolidColor.cs @@ -9,7 +9,11 @@ using System.Text; using System.Xml.Serialization; using System.Reflection; using System.Diagnostics; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif diff --git a/Crow/src/Fill/SvgPicture.cs b/Crow/src/Fill/SvgPicture.cs index fcd5c4d2..6ce11149 100644 --- a/Crow/src/Fill/SvgPicture.cs +++ b/Crow/src/Fill/SvgPicture.cs @@ -4,7 +4,11 @@ using System; using System.IO; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Font.cs b/Crow/src/Font.cs index f05c6fb1..9ad79450 100644 --- a/Crow/src/Font.cs +++ b/Crow/src/Font.cs @@ -3,7 +3,11 @@ // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using FastEnumUtility; namespace Crow diff --git a/Crow/src/Mono.Cairo/Antialias.cs b/Crow/src/GraphicBackends/Mono.Cairo/Antialias.cs index 64da6443..64da6443 100644 --- a/Crow/src/Mono.Cairo/Antialias.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Antialias.cs diff --git a/Crow/src/Mono.Cairo/Cairo.cs b/Crow/src/GraphicBackends/Mono.Cairo/Cairo.cs index c32c00d8..c32c00d8 100644 --- a/Crow/src/Mono.Cairo/Cairo.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Cairo.cs diff --git a/Crow/src/Mono.Cairo/CairoDebug.cs b/Crow/src/GraphicBackends/Mono.Cairo/CairoDebug.cs index a669d841..a669d841 100644 --- a/Crow/src/Mono.Cairo/CairoDebug.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/CairoDebug.cs diff --git a/Crow/src/Mono.Cairo/Content.cs b/Crow/src/GraphicBackends/Mono.Cairo/Content.cs index f14305a4..f14305a4 100644 --- a/Crow/src/Mono.Cairo/Content.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Content.cs diff --git a/Crow/src/Mono.Cairo/Context.cs b/Crow/src/GraphicBackends/Mono.Cairo/Context.cs index 5cd60dc1..5cd60dc1 100644 --- a/Crow/src/Mono.Cairo/Context.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Context.cs diff --git a/Crow/src/Mono.Cairo/DRMDevice.cs b/Crow/src/GraphicBackends/Mono.Cairo/DRMDevice.cs index 05e142cb..05e142cb 100644 --- a/Crow/src/Mono.Cairo/DRMDevice.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/DRMDevice.cs diff --git a/Crow/src/Mono.Cairo/DRMSurface.cs b/Crow/src/GraphicBackends/Mono.Cairo/DRMSurface.cs index f624967f..f624967f 100644 --- a/Crow/src/Mono.Cairo/DRMSurface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/DRMSurface.cs diff --git a/Crow/src/Mono.Cairo/Device.cs b/Crow/src/GraphicBackends/Mono.Cairo/Device.cs index 484264f0..484264f0 100644 --- a/Crow/src/Mono.Cairo/Device.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Device.cs diff --git a/Crow/src/Mono.Cairo/DirectFBSurface.cs b/Crow/src/GraphicBackends/Mono.Cairo/DirectFBSurface.cs index 64431574..64431574 100644 --- a/Crow/src/Mono.Cairo/DirectFBSurface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/DirectFBSurface.cs diff --git a/Crow/src/Mono.Cairo/Distance.cs b/Crow/src/GraphicBackends/Mono.Cairo/Distance.cs index d716ab1f..d716ab1f 100644 --- a/Crow/src/Mono.Cairo/Distance.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Distance.cs diff --git a/Crow/src/Mono.Cairo/EGLDevice.cs b/Crow/src/GraphicBackends/Mono.Cairo/EGLDevice.cs index 44590c70..44590c70 100644 --- a/Crow/src/Mono.Cairo/EGLDevice.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/EGLDevice.cs diff --git a/Crow/src/Mono.Cairo/Extend.cs b/Crow/src/GraphicBackends/Mono.Cairo/Extend.cs index 4af536dc..4af536dc 100644 --- a/Crow/src/Mono.Cairo/Extend.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Extend.cs diff --git a/Crow/src/Mono.Cairo/FillRule.cs b/Crow/src/GraphicBackends/Mono.Cairo/FillRule.cs index 80f61ed5..80f61ed5 100644 --- a/Crow/src/Mono.Cairo/FillRule.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/FillRule.cs diff --git a/Crow/src/Mono.Cairo/Filter.cs b/Crow/src/GraphicBackends/Mono.Cairo/Filter.cs index a73ea58d..a73ea58d 100644 --- a/Crow/src/Mono.Cairo/Filter.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Filter.cs diff --git a/Crow/src/Mono.Cairo/FontExtents.cs b/Crow/src/GraphicBackends/Mono.Cairo/FontExtents.cs index ea26d9bb..ea26d9bb 100644 --- a/Crow/src/Mono.Cairo/FontExtents.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/FontExtents.cs diff --git a/Crow/src/Mono.Cairo/FontFace.cs b/Crow/src/GraphicBackends/Mono.Cairo/FontFace.cs index 64c428e2..64c428e2 100644 --- a/Crow/src/Mono.Cairo/FontFace.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/FontFace.cs diff --git a/Crow/src/Mono.Cairo/FontOptions.cs b/Crow/src/GraphicBackends/Mono.Cairo/FontOptions.cs index f90a3a4d..f90a3a4d 100644 --- a/Crow/src/Mono.Cairo/FontOptions.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/FontOptions.cs diff --git a/Crow/src/Mono.Cairo/FontSlant.cs b/Crow/src/GraphicBackends/Mono.Cairo/FontSlant.cs index b3d8a1a2..b3d8a1a2 100644 --- a/Crow/src/Mono.Cairo/FontSlant.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/FontSlant.cs diff --git a/Crow/src/Mono.Cairo/FontType.cs b/Crow/src/GraphicBackends/Mono.Cairo/FontType.cs index 5db44d4e..5db44d4e 100644 --- a/Crow/src/Mono.Cairo/FontType.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/FontType.cs diff --git a/Crow/src/Mono.Cairo/FontWeight.cs b/Crow/src/GraphicBackends/Mono.Cairo/FontWeight.cs index 0b8fc6a8..0b8fc6a8 100644 --- a/Crow/src/Mono.Cairo/FontWeight.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/FontWeight.cs diff --git a/Crow/src/Mono.Cairo/Format.cs b/Crow/src/GraphicBackends/Mono.Cairo/Format.cs index 54c8be1e..54c8be1e 100644 --- a/Crow/src/Mono.Cairo/Format.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Format.cs diff --git a/Crow/src/Mono.Cairo/GLSurface.cs b/Crow/src/GraphicBackends/Mono.Cairo/GLSurface.cs index 60384b02..60384b02 100644 --- a/Crow/src/Mono.Cairo/GLSurface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/GLSurface.cs diff --git a/Crow/src/Mono.Cairo/GLXDevice.cs b/Crow/src/GraphicBackends/Mono.Cairo/GLXDevice.cs index 00cbce1f..00cbce1f 100644 --- a/Crow/src/Mono.Cairo/GLXDevice.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/GLXDevice.cs diff --git a/Crow/src/Mono.Cairo/GlitzSurface.cs b/Crow/src/GraphicBackends/Mono.Cairo/GlitzSurface.cs index 4aa24983..4aa24983 100644 --- a/Crow/src/Mono.Cairo/GlitzSurface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/GlitzSurface.cs diff --git a/Crow/src/Mono.Cairo/Glyph.cs b/Crow/src/GraphicBackends/Mono.Cairo/Glyph.cs index ad511562..ad511562 100644 --- a/Crow/src/Mono.Cairo/Glyph.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Glyph.cs diff --git a/Crow/src/Mono.Cairo/Gradient.cs b/Crow/src/GraphicBackends/Mono.Cairo/Gradient.cs index a1799e3f..a1799e3f 100644 --- a/Crow/src/Mono.Cairo/Gradient.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Gradient.cs diff --git a/Crow/src/Mono.Cairo/HintMetrics.cs b/Crow/src/GraphicBackends/Mono.Cairo/HintMetrics.cs index d830f3eb..d830f3eb 100644 --- a/Crow/src/Mono.Cairo/HintMetrics.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/HintMetrics.cs diff --git a/Crow/src/Mono.Cairo/HintStyle.cs b/Crow/src/GraphicBackends/Mono.Cairo/HintStyle.cs index 343daf3e..343daf3e 100644 --- a/Crow/src/Mono.Cairo/HintStyle.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/HintStyle.cs diff --git a/Crow/src/Mono.Cairo/ImageSurface.cs b/Crow/src/GraphicBackends/Mono.Cairo/ImageSurface.cs index 7c70569d..7c70569d 100644 --- a/Crow/src/Mono.Cairo/ImageSurface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/ImageSurface.cs diff --git a/Crow/src/Mono.Cairo/LineCap.cs b/Crow/src/GraphicBackends/Mono.Cairo/LineCap.cs index 1560cda4..1560cda4 100644 --- a/Crow/src/Mono.Cairo/LineCap.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/LineCap.cs diff --git a/Crow/src/Mono.Cairo/LineJoin.cs b/Crow/src/GraphicBackends/Mono.Cairo/LineJoin.cs index 1d5389b5..1d5389b5 100644 --- a/Crow/src/Mono.Cairo/LineJoin.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/LineJoin.cs diff --git a/Crow/src/Mono.Cairo/LinearGradient.cs b/Crow/src/GraphicBackends/Mono.Cairo/LinearGradient.cs index 100d1e6d..100d1e6d 100644 --- a/Crow/src/Mono.Cairo/LinearGradient.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/LinearGradient.cs diff --git a/Crow/src/Mono.Cairo/Matrix.cs b/Crow/src/GraphicBackends/Mono.Cairo/Matrix.cs index 7d5a6acd..7d5a6acd 100644 --- a/Crow/src/Mono.Cairo/Matrix.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Matrix.cs diff --git a/Crow/src/Mono.Cairo/MeshPattern.cs b/Crow/src/GraphicBackends/Mono.Cairo/MeshPattern.cs index 83da70b1..83da70b1 100644 --- a/Crow/src/Mono.Cairo/MeshPattern.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/MeshPattern.cs diff --git a/Crow/src/Mono.Cairo/NativeMethods-internal.cs b/Crow/src/GraphicBackends/Mono.Cairo/NativeMethods-internal.cs index 6e6d507c..6e6d507c 100644 --- a/Crow/src/Mono.Cairo/NativeMethods-internal.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/NativeMethods-internal.cs diff --git a/Crow/src/Mono.Cairo/NativeMethods.cs b/Crow/src/GraphicBackends/Mono.Cairo/NativeMethods.cs index 4f93c411..4f93c411 100644 --- a/Crow/src/Mono.Cairo/NativeMethods.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/NativeMethods.cs diff --git a/Crow/src/Mono.Cairo/Operator.cs b/Crow/src/GraphicBackends/Mono.Cairo/Operator.cs index 1c11cccc..1c11cccc 100644 --- a/Crow/src/Mono.Cairo/Operator.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Operator.cs diff --git a/Crow/src/Mono.Cairo/PSSurface.cs b/Crow/src/GraphicBackends/Mono.Cairo/PSSurface.cs index cf90794e..cf90794e 100644 --- a/Crow/src/Mono.Cairo/PSSurface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/PSSurface.cs diff --git a/Crow/src/Mono.Cairo/Path.cs b/Crow/src/GraphicBackends/Mono.Cairo/Path.cs index a55f03b0..881aa427 100644 --- a/Crow/src/Mono.Cairo/Path.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Path.cs @@ -30,7 +30,11 @@ using System; using System.Runtime.InteropServices; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow.Cairo { diff --git a/Crow/src/Mono.Cairo/Pattern.cs b/Crow/src/GraphicBackends/Mono.Cairo/Pattern.cs index 3e933a19..3e933a19 100644 --- a/Crow/src/Mono.Cairo/Pattern.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Pattern.cs diff --git a/Crow/src/Mono.Cairo/PatternType.cs b/Crow/src/GraphicBackends/Mono.Cairo/PatternType.cs index deac3ab7..deac3ab7 100644 --- a/Crow/src/Mono.Cairo/PatternType.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/PatternType.cs diff --git a/Crow/src/Mono.Cairo/PdfSurface.cs b/Crow/src/GraphicBackends/Mono.Cairo/PdfSurface.cs index 09a2d126..09a2d126 100644 --- a/Crow/src/Mono.Cairo/PdfSurface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/PdfSurface.cs diff --git a/Crow/src/Mono.Cairo/RadialGradient.cs b/Crow/src/GraphicBackends/Mono.Cairo/RadialGradient.cs index 6abe2671..6abe2671 100644 --- a/Crow/src/Mono.Cairo/RadialGradient.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/RadialGradient.cs diff --git a/Crow/src/Mono.Cairo/Region.cs b/Crow/src/GraphicBackends/Mono.Cairo/Region.cs index f2c111d7..f2c111d7 100644 --- a/Crow/src/Mono.Cairo/Region.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Region.cs diff --git a/Crow/src/Mono.Cairo/ScaledFont.cs b/Crow/src/GraphicBackends/Mono.Cairo/ScaledFont.cs index 594d1be9..594d1be9 100644 --- a/Crow/src/Mono.Cairo/ScaledFont.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/ScaledFont.cs diff --git a/Crow/src/Mono.Cairo/SolidPattern.cs b/Crow/src/GraphicBackends/Mono.Cairo/SolidPattern.cs index 6cd89f85..6cd89f85 100644 --- a/Crow/src/Mono.Cairo/SolidPattern.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/SolidPattern.cs diff --git a/Crow/src/Mono.Cairo/Status.cs b/Crow/src/GraphicBackends/Mono.Cairo/Status.cs index 2df15580..2df15580 100644 --- a/Crow/src/Mono.Cairo/Status.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Status.cs diff --git a/Crow/src/Mono.Cairo/SubpixelOrder.cs b/Crow/src/GraphicBackends/Mono.Cairo/SubpixelOrder.cs index 95f3cbee..95f3cbee 100644 --- a/Crow/src/Mono.Cairo/SubpixelOrder.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/SubpixelOrder.cs diff --git a/Crow/src/Mono.Cairo/Surface.cs b/Crow/src/GraphicBackends/Mono.Cairo/Surface.cs index 56c1553f..56c1553f 100644 --- a/Crow/src/Mono.Cairo/Surface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Surface.cs diff --git a/Crow/src/Mono.Cairo/SurfacePattern.cs b/Crow/src/GraphicBackends/Mono.Cairo/SurfacePattern.cs index 53a90d38..53a90d38 100644 --- a/Crow/src/Mono.Cairo/SurfacePattern.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/SurfacePattern.cs diff --git a/Crow/src/Mono.Cairo/SurfaceType.cs b/Crow/src/GraphicBackends/Mono.Cairo/SurfaceType.cs index bd992db0..bd992db0 100644 --- a/Crow/src/Mono.Cairo/SurfaceType.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/SurfaceType.cs diff --git a/Crow/src/Mono.Cairo/SvgSurface.cs b/Crow/src/GraphicBackends/Mono.Cairo/SvgSurface.cs index c7d72988..c7d72988 100644 --- a/Crow/src/Mono.Cairo/SvgSurface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/SvgSurface.cs diff --git a/Crow/src/Mono.Cairo/SvgVersion.cs b/Crow/src/GraphicBackends/Mono.Cairo/SvgVersion.cs index 916fb861..916fb861 100644 --- a/Crow/src/Mono.Cairo/SvgVersion.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/SvgVersion.cs diff --git a/Crow/src/Mono.Cairo/TextExtents.cs b/Crow/src/GraphicBackends/Mono.Cairo/TextExtents.cs index 965ca046..965ca046 100644 --- a/Crow/src/Mono.Cairo/TextExtents.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/TextExtents.cs diff --git a/Crow/src/Mono.Cairo/WGLDevice.cs b/Crow/src/GraphicBackends/Mono.Cairo/WGLDevice.cs index 308cfadd..308cfadd 100644 --- a/Crow/src/Mono.Cairo/WGLDevice.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/WGLDevice.cs diff --git a/Crow/src/Mono.Cairo/Win32Surface.cs b/Crow/src/GraphicBackends/Mono.Cairo/Win32Surface.cs index 4776a19b..4776a19b 100644 --- a/Crow/src/Mono.Cairo/Win32Surface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/Win32Surface.cs diff --git a/Crow/src/Mono.Cairo/XcbSurface.cs b/Crow/src/GraphicBackends/Mono.Cairo/XcbSurface.cs index 32a67848..32a67848 100644 --- a/Crow/src/Mono.Cairo/XcbSurface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/XcbSurface.cs diff --git a/Crow/src/Mono.Cairo/XlibSurface.cs b/Crow/src/GraphicBackends/Mono.Cairo/XlibSurface.cs index 18e810bd..18e810bd 100644 --- a/Crow/src/Mono.Cairo/XlibSurface.cs +++ b/Crow/src/GraphicBackends/Mono.Cairo/XlibSurface.cs diff --git a/Crow/src/GraphicBackends/vkvg/Context.cs b/Crow/src/GraphicBackends/vkvg/Context.cs new file mode 100644 index 00000000..482dfe12 --- /dev/null +++ b/Crow/src/GraphicBackends/vkvg/Context.cs @@ -0,0 +1,347 @@ +// 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; +using System.Text; +using Crow; + +namespace vkvg +{ + public class Context : IDisposable + { + + IntPtr handle = IntPtr.Zero; + + public Context(Surface surf) + { + handle = NativeMethods.vkvg_create(surf.Handle); + } + ~Context() + { + Dispose(false); + } + + public IntPtr Handle => handle; + + public void AddReference() + { + NativeMethods.vkvg_reference(handle); + } + public uint References() => NativeMethods.vkvg_get_reference_count(handle); + + public double LineWidth + { + get => NativeMethods.vkvg_get_line_width(handle); + set { NativeMethods.vkvg_set_line_width(handle, (float)value); } + } + public LineJoin LineJoin + { + get => NativeMethods.vkvg_get_line_join(handle); + set { NativeMethods.vkvg_set_line_join(handle, value); } + } + public LineCap LineCap + { + get => NativeMethods.vkvg_get_line_cap(handle); + set { NativeMethods.vkvg_set_line_cap(handle, value); } + } + public uint FontSize + { + set { NativeMethods.vkvg_set_font_size(handle, value); } + } + public string FontFace + { + set { NativeMethods.vkvg_select_font_face(handle, value); } + } + public Operator Operator + { + set { NativeMethods.vkvg_set_operator(handle, value); } + get { return NativeMethods.vkvg_get_operator(handle); } + } + public FillRule FillRule + { + set { NativeMethods.vkvg_set_fill_rule(handle, value); } + get { return NativeMethods.vkvg_get_fill_rule(handle); } + } + public FontExtents FontExtents + { + get + { + FontExtents f_extents; + NativeMethods.vkvg_font_extents(handle, out f_extents); + return f_extents; + } + } + public TextExtents TextExtents(string s) + { + TextExtents extents = default(TextExtents); + if (!string.IsNullOrEmpty(s)) + NativeMethods.vkvg_text_extents(handle, TerminateUtf8(s), out extents); + return extents; + } + public Matrix Matrix + { + get + { + Matrix m; + NativeMethods.vkvg_get_matrix(handle, out m); + return m; + } + set + { + NativeMethods.vkvg_set_matrix(handle, ref value); + } + } + public void ShowText(string txt) + { + NativeMethods.vkvg_show_text(handle, TerminateUtf8(txt)); + } + public void ShowText(TextRun textRun) + { + NativeMethods.vkvg_show_text_run(handle, textRun.Handle); + } + public void Save() + { + NativeMethods.vkvg_save(handle); + } + public void Restore() + { + NativeMethods.vkvg_restore(handle); + } + public void Flush() + { + NativeMethods.vkvg_flush(handle); + } + public void Clear() + { + NativeMethods.vkvg_clear(handle); + } + public void Paint() + { + NativeMethods.vkvg_paint(handle); + } + public void Arc(float xc, float yc, float radius, float a1, float a2) + { + NativeMethods.vkvg_arc(handle, xc, yc, radius, a1, a2); + } + public void Arc(double xc, double yc, double radius, double a1, double a2) + { + NativeMethods.vkvg_arc(handle, (float)xc, (float)yc, (float)radius, (float)a1, (float)a2); + } + public void ArcNegative(float xc, float yc, float radius, float a1, float a2) + { + NativeMethods.vkvg_arc_negative(handle, xc, yc, radius, a1, a2); + } + public void Rectangle(float x, float y, float width, float height) + { + NativeMethods.vkvg_rectangle(handle, x, y, width, height); + } + public void Scale(float sx, float sy) + { + NativeMethods.vkvg_scale(handle, sx, sy); + } + public void Translate(float dx, float dy) + { + NativeMethods.vkvg_translate(handle, dx, dy); + } + public void Rotate(float alpha) + { + NativeMethods.vkvg_rotate(handle, alpha); + } + public void ArcNegative(double xc, double yc, double radius, double a1, double a2) + { + NativeMethods.vkvg_arc_negative(handle, (float)xc, (float)yc, (float)radius, (float)a1, (float)a2); + } + public void Rectangle(double x, double y, double width, double height) + { + NativeMethods.vkvg_rectangle(handle, (float)x, (float)y, (float)width, (float)height); + } + public void Scale(double sx, double sy) + { + NativeMethods.vkvg_scale(handle, (float)sx, (float)sy); + } + public void Translate(double dx, double dy) + { + NativeMethods.vkvg_translate(handle, (float)dx, (float)dy); + } + public void Translate(PointD p) + { + NativeMethods.vkvg_translate(handle, (float)p.X, (float)p.Y); + } + public void Rotate(double alpha) + { + NativeMethods.vkvg_rotate(handle, (float)alpha); + } + + public void Fill() + { + NativeMethods.vkvg_fill(handle); + } + public void FillPreserve() + { + NativeMethods.vkvg_fill_preserve(handle); + } + public void Stroke() + { + NativeMethods.vkvg_stroke(handle); + } + public void StrokePreserve() + { + NativeMethods.vkvg_stroke_preserve(handle); + } + public void Clip() + { + NativeMethods.vkvg_clip(handle); + } + public void ClipPreserve() + { + NativeMethods.vkvg_clip_preserve(handle); + } + public void ResetClip() + { + NativeMethods.vkvg_reset_clip(handle); + } + public void NewPath() + { + NativeMethods.vkvg_new_path(handle); + } + public void NewSubPath() + { + NativeMethods.vkvg_new_sub_path(handle); + } + public void ClosePath() + { + NativeMethods.vkvg_close_path(handle); + } + public void MoveTo(PointD p) + { + NativeMethods.vkvg_move_to(handle, (float)p.X, (float)p.Y); + } + public void MoveTo(Point p) + { + NativeMethods.vkvg_move_to(handle, p.X, p.Y); + } + public void MoveTo(float x, float y) + { + NativeMethods.vkvg_move_to(handle, x, y); + } + public void RelMoveTo(float x, float y) + { + NativeMethods.vkvg_rel_move_to(handle, x, y); + } + public void LineTo(float x, float y) + { + NativeMethods.vkvg_line_to(handle, x, y); + } + public void LineTo(Point p) + { + NativeMethods.vkvg_line_to(handle, p.X, p.Y); + } + public void LineTo(PointD p) + { + NativeMethods.vkvg_line_to(handle, (float)p.X, (float)p.Y); + } + public void RelLineTo(float x, float y) + { + NativeMethods.vkvg_rel_line_to(handle, x, y); + } + public void CurveTo(float x1, float y1, float x2, float y2, float x3, float y3) + { + NativeMethods.vkvg_curve_to(handle, x1, y1, x2, y2, x3, y3); + } + public void RelCurveTo(float x1, float y1, float x2, float y2, float x3, float y3) + { + NativeMethods.vkvg_rel_curve_to(handle, x1, y1, x2, y2, x3, y3); + } + + public void MoveTo(double x, double y) + { + NativeMethods.vkvg_move_to(handle, (float)x, (float)y); + } + public void RelMoveTo(double x, double y) + { + NativeMethods.vkvg_rel_move_to(handle, (float)x, (float)y); + } + public void LineTo(double x, double y) + { + NativeMethods.vkvg_line_to(handle, (float)x, (float)y); + } + public void RelLineTo(double x, double y) + { + NativeMethods.vkvg_rel_line_to(handle, (float)x, (float)y); + } + public void CurveTo(double x1, double y1, double x2, double y2, double x3, double y3) + { + NativeMethods.vkvg_curve_to(handle, (float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3); + } + public void RelCurveTo(double x1, double y1, double x2, double y2, double x3, double y3) + { + NativeMethods.vkvg_rel_curve_to(handle, (float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3); + } + + public void SetSource(Pattern pat) + { + NativeMethods.vkvg_set_source(handle, pat.Handle); + } + public void SetSource (Color color) + { + NativeMethods.vkvg_set_source_rgba (handle, (float)(color.R / 255.0), (float)(color.G / 255.0), (float)(color.B / 255.0), (float)(color.A / 255.0)); + } + public void SetSource(float r, float g, float b, float a = 1f) + { + NativeMethods.vkvg_set_source_rgba(handle, r, g, b, a); + } + public void SetSource(double r, double g, double b, double a = 1.0) + { + NativeMethods.vkvg_set_source_rgba(handle, (float)r, (float)g, (float)b, (float)a); + } + public void SetSource(Surface surf, float x = 0f, float y = 0f) + { + NativeMethods.vkvg_set_source_surface(handle, surf.Handle, x, y); + } + public void SetSourceSurface(Surface surf, float x = 0f, float y = 0f) + { + NativeMethods.vkvg_set_source_surface(handle, surf.Handle, x, y); + } + public void RenderSvg(IntPtr nsvgImage, string subId = null) + { + NativeMethods.vkvg_render_svg(handle, nsvgImage, subId); + } + internal static byte[] TerminateUtf8(string s) + { + // compute the byte count including the trailing \0 + var byteCount = Encoding.UTF8.GetMaxByteCount(s.Length + 1); + var bytes = new byte[byteCount]; + Encoding.UTF8.GetBytes(s, 0, s.Length, bytes, 0); + return bytes; + } + + public float[] Dashes + { + set + { + if (value == null) + NativeMethods.vkvg_set_dash(handle, null, 0, 0); + else + NativeMethods.vkvg_set_dash(handle, value, (uint)value.Length, 0); + } + } + #region IDisposable implementation + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (!disposing || handle == IntPtr.Zero) + return; + + NativeMethods.vkvg_destroy(handle); + handle = IntPtr.Zero; + } + #endregion + } +} + diff --git a/Crow/src/GraphicBackends/vkvg/Device.cs b/Crow/src/GraphicBackends/vkvg/Device.cs new file mode 100644 index 00000000..84eea519 --- /dev/null +++ b/Crow/src/GraphicBackends/vkvg/Device.cs @@ -0,0 +1,56 @@ +// 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 vkvg +{ + public class Device: IDisposable + { + + IntPtr handle = IntPtr.Zero; + + #region CTORS & DTOR + public Device (IntPtr instance, IntPtr phy, IntPtr dev, uint qFamIdx, SampleCount samples = SampleCount.Sample_1, uint qIndex = 0) + { + handle = NativeMethods.vkvg_device_create_multisample (instance, phy, dev, qFamIdx, qIndex, samples, false); + } + ~Device () + { + Dispose (false); + } + #endregion + + public void GetDpy (out int hdpy, out int vdpy) { + NativeMethods.vkvg_device_get_dpy (handle, out hdpy, out vdpy); + } + public void SetDpy (int hdpy, int vdpy) { + NativeMethods.vkvg_device_set_dpy (handle, hdpy, vdpy); + } + public void AddReference () { + NativeMethods.vkvg_device_reference (handle); + } + public uint References () => NativeMethods.vkvg_device_get_reference_count (handle); + + public IntPtr Handle { get { return handle; }} + + #region IDisposable implementation + public void Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); + } + + protected virtual void Dispose (bool disposing) + { + if (!disposing || handle == IntPtr.Zero) + return; + + NativeMethods.vkvg_device_destroy (handle); + handle = IntPtr.Zero; + } + #endregion + } +} + diff --git a/Crow/src/GraphicBackends/vkvg/Enums.cs b/Crow/src/GraphicBackends/vkvg/Enums.cs new file mode 100644 index 00000000..41c5eb9c --- /dev/null +++ b/Crow/src/GraphicBackends/vkvg/Enums.cs @@ -0,0 +1,143 @@ +// 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 vkvg +{ + public enum Status + { + Success = 0, + NoMemory, + InvalidRestore, + InvalidPopGroup, + NoCurrentPoint, + InvalidMatrix, + InvalidStatus, + NullPointer, + InvalidString, + InvalidPathData, + ReadError, + WriteError, + SurfaceFinished, + SurfaceTypeMismatch, + PatternTypeMismatch, + InvalidContent, + InvalidFormat, + InvalidVisual, + FileNotFound, + InvalidDash + } + + public enum Direction + { + Horizontal = 0, + Vertical = 1 + } + + public enum Format + { + ARGB32, + RGB24, + A8, + A1 + } + + public enum Extend + { + None, + Repeat, + Reflect, + Pad + } + + public enum Filter + { + Fast, + Good, + Best, + Nearest, + Bilinear, + Gaussian, + } + + public enum PatternType + { + Solid, + Surface, + Linear, + Radial, + Mesh, + RasterSource, + } + + public enum Operator + { + Clear, + Source, + Over, + In, + Out, + Atop, + + Dest, + DestOver, + DestIn, + DestOut, + DestAtop, + + Xor, + Add, + Saturate, + } + + public enum FontSlant + { + Normal, + Italic, + Oblique + } + public enum FontWeight + { + Normal, + Bold, + } + + public enum SampleCount + { + Sample_1 = 0x00000001, + Sample_2 = 0x00000002, + Sample_4 = 0x00000004, + Sample_8 = 0x00000008, + Sample_16 = 0x00000010, + Sample_32 = 0x00000020, + Sample_64 = 0x00000040 + } + + public enum LineCap + { + Butt, + Round, + Square + } + + public enum LineJoin + { + Miter, + Round, + Bevel + } + public enum FillRule + { + EvenOdd, + NonZero, + } + public enum Antialias + { + Default, + None, + Grey, + Subpixel, + } +}
\ No newline at end of file diff --git a/Crow/src/GraphicBackends/vkvg/FontExtents.cs b/Crow/src/GraphicBackends/vkvg/FontExtents.cs new file mode 100644 index 00000000..41b025de --- /dev/null +++ b/Crow/src/GraphicBackends/vkvg/FontExtents.cs @@ -0,0 +1,106 @@ +// +// from 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. +// +// 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; +using System.Runtime.InteropServices; + +namespace vkvg +{ + [StructLayout (LayoutKind.Sequential)] + public struct FontExtents + { + float ascent; + float descent; + float height; + float maxXAdvance; + float maxYAdvance; + + public float Ascent { + get { return ascent; } + set { ascent = value; } + } + + public float Descent { + get { return descent; } + set { descent = value; } + } + + public float Height { + get { return height; } + set { height = value; } + } + + public float MaxXAdvance { + get { return maxXAdvance; } + set { maxXAdvance = value; } + } + + public float MaxYAdvance { + get { return maxYAdvance; } + set { maxYAdvance = value; } + } + + public FontExtents (float ascent, float descent, float height, float maxXAdvance, float 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); + } + } +} diff --git a/Crow/src/GraphicBackends/vkvg/Matrix.cs b/Crow/src/GraphicBackends/vkvg/Matrix.cs new file mode 100644 index 00000000..12e9e382 --- /dev/null +++ b/Crow/src/GraphicBackends/vkvg/Matrix.cs @@ -0,0 +1,92 @@ +// 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 vkvg { + public struct Matrix { + float xx; float yx; + float xy; float yy; + float x0; float y0; + + public float XX { get { return xx; } set { xx = value; } } + public float YX { get { return yx; } set { yx = value; } } + public float XY { get { return xy; } set { xy = value; } } + public float YY { get { return yy; } set { yy = value; } } + public float X0 { get { return x0; } set { x0 = value; } } + public float Y0 { get { return y0; } set { y0 = value; } } + + public static Matrix Create (float xx, float yx, float xy, float yy, float x0, float y0) { + Matrix tmp; + NativeMethods.vkvg_matrix_init (out tmp, xx, yx, xy, yy, x0, y0); + return tmp; + } + public static Matrix CreateTranslation (float tx, float ty) { + Matrix tmp; + NativeMethods.vkvg_matrix_init_translate (out tmp, tx, ty); + return tmp; + } + public static Matrix CreateRotation (float radian) { + Matrix tmp; + NativeMethods.vkvg_matrix_init_rotate (out tmp, radian); + return tmp; + } + public static Matrix CreateScale (float sx, float sy) { + Matrix tmp; + NativeMethods.vkvg_matrix_init_scale (out tmp, sx, sy); + return tmp; + } + public static Matrix Identity { + get { + Matrix tmp; + NativeMethods.vkvg_matrix_init_identity (out tmp); + return tmp; + } + } + + public void Translate (float tx, float ty) { + Matrix tmp = this; + NativeMethods.vkvg_matrix_translate (ref tmp, tx, ty); + xx = tmp.xx; yx = tmp.yx; + xy = tmp.xy; yy = tmp.yy; + x0 = tmp.x0; y0 = tmp.y0; + } + public void Rotate (float radian) { + Matrix tmp = this; + NativeMethods.vkvg_matrix_rotate (ref tmp, radian); + xx = tmp.xx; yx = tmp.yx; + xy = tmp.xy; yy = tmp.yy; + x0 = tmp.x0; y0 = tmp.y0; + } + public void Scale (float sx, float sy) { + Matrix tmp = this; + NativeMethods.vkvg_matrix_scale (ref tmp, sx, sy); + xx = tmp.xx; yx = tmp.yx; + xy = tmp.xy; yy = tmp.yy; + x0 = tmp.x0; y0 = tmp.y0; + } + public void Invert () { + Matrix tmp = this; + NativeMethods.vkvg_matrix_invert (ref tmp); + xx = tmp.xx; yx = tmp.yx; + xy = tmp.xy; yy = tmp.yy; + x0 = tmp.x0; y0 = tmp.y0; + } + public void TransformDistance (ref float dx, ref float dy) { + NativeMethods.vkvg_matrix_transform_distance (ref this, ref dx, ref dy); + } + public void TransformPoint (ref float px, ref float py) { + NativeMethods.vkvg_matrix_transform_distance (ref this, ref px, ref py); + } + + public static Matrix operator *(Matrix a, Matrix b) { + Matrix tmp; + NativeMethods.vkvg_matrix_multiply (out tmp, ref a, ref b); + return tmp; + } + + public override string ToString () { + return string.Format ($"({xx};{yx};{xy};{yy};{x0};{y0})"); + } + } +} diff --git a/Crow/src/GraphicBackends/vkvg/NativeMethods.cs b/Crow/src/GraphicBackends/vkvg/NativeMethods.cs new file mode 100644 index 00000000..48f2eb6b --- /dev/null +++ b/Crow/src/GraphicBackends/vkvg/NativeMethods.cs @@ -0,0 +1,272 @@ +// 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; +using System.Runtime.InteropServices; + +namespace vkvg +{ + internal static class NativeMethods + { + const string libvkvg = "vkvg"; + + #region Device + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_device_create(IntPtr instance, IntPtr phy, IntPtr dev, uint qFamIdx, uint qIndex); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_device_destroy(IntPtr device); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_device_create_multisample(IntPtr inst, IntPtr phy, IntPtr vkdev, uint qFamIdx, uint qIndex, SampleCount samples, bool deferredResolve); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_device_reference(IntPtr dev); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint vkvg_device_get_reference_count(IntPtr dev); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_device_set_dpy(IntPtr dev, int hdpy, int vdpy); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_device_get_dpy(IntPtr dev, out int hdpy, out int vdpy); + #endregion + + #region Context + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_create(IntPtr surface); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_destroy(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_flush(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_new_path(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_new_sub_path(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_close_path(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_line_to(IntPtr ctx, float x, float y); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_rel_line_to(IntPtr ctx, float x, float y); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_move_to(IntPtr ctx, float x, float y); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_rel_move_to(IntPtr ctx, float x, float y); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_arc(IntPtr ctx, float xc, float yc, float radius, float a1, float a2); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_arc_negative(IntPtr ctx, float xc, float yc, float radius, float a1, float a2); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_curve_to(IntPtr ctx, float x1, float y1, float x2, float y2, float x3, float y3); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_rel_curve_to(IntPtr ctx, float x1, float y1, float x2, float y2, float x3, float y3); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_rectangle(IntPtr ctx, float x, float y, float width, float height); + + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_scale(IntPtr ctx, float sx, float sy); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_translate(IntPtr ctx, float dx, float dy); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_rotate(IntPtr ctx, float alpha); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_transform(IntPtr ctx, ref Matrix matrix); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_set_matrix(IntPtr ctx, ref Matrix matrix); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_get_matrix(IntPtr ctx, out Matrix matrix); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_identity_matrix(IntPtr ctx); + + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_stroke(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_stroke_preserve(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_clip(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_clip_preserve(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_reset_clip(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_fill(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_fill_preserve(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_paint(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_set_source_rgba(IntPtr ctx, float r, float g, float b, float a); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_set_line_width(IntPtr ctx, float width); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_set_line_cap(IntPtr ctx, LineCap cap); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_set_line_join(IntPtr ctx, LineJoin join); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_set_operator(IntPtr ctx, Operator op); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern FillRule vkvg_get_fill_rule(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_set_fill_rule(IntPtr ctx, FillRule fr); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern Operator vkvg_get_operator(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_set_source_surface(IntPtr ctx, IntPtr surf, float x, float y); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_set_source(IntPtr ctx, IntPtr pattern); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_font_extents(IntPtr ctx, out FontExtents extents); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_text_extents(IntPtr ctx, byte[] utf8, out TextExtents extents); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_select_font_face(IntPtr ctx, string name); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_set_font_size(IntPtr ctx, uint size); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_show_text(IntPtr ctx, byte [] utf8); + + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_save(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_restore(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_clear(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern float vkvg_get_line_width(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern LineCap vkvg_get_line_cap(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern LineJoin vkvg_get_line_join(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_get_source(IntPtr ctx); + + [DllImport (libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_set_dash (IntPtr ctx, float[] dashes, uint dashCount, float offset); + + //void vkvg_set_dash (VkvgContext ctx, const float* dashes, uint32_t num_dashes, float offset); + //void vkvg_get_dash (VkvgContext ctx, const float* dashes, uint32_t* num_dashes, float* offset + + [DllImport (libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_reference(IntPtr ctx); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint vkvg_get_reference_count(IntPtr ctx); + #endregion + + #region TextRun + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_text_run_create(IntPtr ctx, byte[] utf8); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_text_run_destroy(IntPtr textRun); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_show_text_run(IntPtr ctx, IntPtr textRun); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_text_run_get_extents(IntPtr textRun, out TextExtents extents); + #endregion + + #region Pattern + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_pattern_create(); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_pattern_reference(IntPtr pat); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint vkvg_pattern_get_reference_count(IntPtr pat); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_pattern_create_rgba(float r, float g, float b, float a); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_pattern_create_rgb(float r, float g, float b); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_pattern_create_for_surface(IntPtr surf); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_pattern_create_linear(float x0, float y0, float x1, float y1); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_pattern_create_radial(float cx0, float cy0, float radius0, + float cx1, float cy1, float radius1); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_pattern_destroy(IntPtr pat); + + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_pattern_add_color_stop(IntPtr pat, float offset, float r, float g, float b, float a); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_pattern_set_extend(IntPtr pat, Extend extend); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_pattern_set_filter(IntPtr pat, Filter filter); + + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern Extend vkvg_pattern_get_extend(IntPtr pat); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern Filter vkvg_pattern_get_filter(IntPtr pat); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern PatternType vkvg_pattern_get_type(IntPtr pat); + #endregion + + #region Matrices + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_matrix_init_identity(out Matrix matrix); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_matrix_init(out Matrix matrix, + float xx, float yx, + float xy, float yy, + float x0, float y0); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_matrix_init_translate(out Matrix matrix, float tx, float ty); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_matrix_init_scale(out Matrix matrix, float sx, float sy); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_matrix_init_rotate(out Matrix matrix, float radians); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_matrix_translate(ref Matrix matrix, float tx, float ty); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_matrix_scale(ref Matrix matrix, float sx, float sy); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_matrix_rotate(ref Matrix matrix, float radians); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_matrix_multiply(out Matrix result, ref Matrix a, ref Matrix b); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_matrix_transform_distance(ref Matrix matrix, ref float dx, ref float dy); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_matrix_transform_point(ref Matrix matrix, ref float x, ref float y); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_matrix_invert(ref Matrix matrix); + #endregion + + #region Surface + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_surface_create(IntPtr device, uint width, uint height); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_surface_create_from_image(IntPtr dev, string filePath); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_surface_create_from_svg(IntPtr dev, string filePath); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_surface_create_from_svg_fragment(IntPtr dev, byte[] filePath); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_surface_create_from_bitmap(IntPtr dev, ref byte[] data, uint width, uint height); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_surface_destroy(IntPtr surf); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_surface_get_vk_image(IntPtr surf); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern int vkvg_surface_get_width(IntPtr surf); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern int vkvg_surface_get_height(IntPtr surf); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_surface_clear(IntPtr surf); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr vkvg_surface_reference(IntPtr surf); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint vkvg_surface_get_reference_count(IntPtr surf); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_surface_write_to_png(IntPtr surf, [MarshalAs(UnmanagedType.LPStr)]string path); + #endregion + + #region NSVG + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr nsvg_load_file(IntPtr dev, string filePath); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr nsvg_load(IntPtr dev, byte[] fragment); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void nsvg_destroy(IntPtr nsvgImage); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void nsvg_get_size(IntPtr nsvgImage, out int width, out int height); + [DllImport(libvkvg, CallingConvention = CallingConvention.Cdecl)] + internal static extern void vkvg_render_svg(IntPtr ctx, IntPtr nsvgImage, string subId); + #endregion + } +} + diff --git a/Crow/src/GraphicBackends/vkvg/Pattern.cs b/Crow/src/GraphicBackends/vkvg/Pattern.cs new file mode 100644 index 00000000..a66ffdcc --- /dev/null +++ b/Crow/src/GraphicBackends/vkvg/Pattern.cs @@ -0,0 +1,92 @@ +// 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 vkvg +{ + public class Pattern : IDisposable + { + + IntPtr handle = IntPtr.Zero; + + #region CTORS & DTOR + protected Pattern(IntPtr handle) + { + this.handle = handle; + } + public Pattern() + { + handle = NativeMethods.vkvg_pattern_create(); + } + public Pattern(float r, float g, float b) + { + handle = NativeMethods.vkvg_pattern_create_rgb(r, g, b); + } + public Pattern(float r, float g, float b, float a) + { + handle = NativeMethods.vkvg_pattern_create_rgba(r, g, b, a); + } + public Pattern(Surface surf) + { + handle = NativeMethods.vkvg_pattern_create_for_surface(surf.Handle); + } + + ~Pattern() + { + Dispose(false); + } + #endregion + + public static Pattern CreateLinearGradient(float x0, float y0, float x1, float y1) + { + return new Pattern(NativeMethods.vkvg_pattern_create_linear(x0, y0, x1, y1)); + } + public static Pattern CreateRadialGradient(float cx0, float cy0, float radius0, + float cx1, float cy1, float radius1) + { + return new Pattern(NativeMethods.vkvg_pattern_create_radial(cx0, cy0, radius0, cx1, cy1, radius1)); + } + + public void AddReference() + { + NativeMethods.vkvg_pattern_reference(handle); + } + public uint References() => NativeMethods.vkvg_pattern_get_reference_count(handle); + + public IntPtr Handle { get { return handle; } } + + public Extend Extend + { + set { NativeMethods.vkvg_pattern_set_extend(handle, value); } + get { return NativeMethods.vkvg_pattern_get_extend(handle); } + } + public Filter Filter + { + set { NativeMethods.vkvg_pattern_set_filter(handle, value); } + get { return NativeMethods.vkvg_pattern_get_filter(handle); } + } + + public void AddColorStop(float offset, float r, float g, float b, float a = 1f) + { + NativeMethods.vkvg_pattern_add_color_stop(handle, offset, r, g, b, a); + } + + #region IDisposable implementation + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (!disposing || handle == IntPtr.Zero) + return; + + NativeMethods.vkvg_pattern_destroy(handle); + handle = IntPtr.Zero; + } + #endregion + } +}
\ No newline at end of file diff --git a/Crow/src/GraphicBackends/vkvg/Surface.cs b/Crow/src/GraphicBackends/vkvg/Surface.cs new file mode 100644 index 00000000..79f92dcd --- /dev/null +++ b/Crow/src/GraphicBackends/vkvg/Surface.cs @@ -0,0 +1,85 @@ +// 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 vkvg +{ + public class Surface: IDisposable + { + IntPtr handle = IntPtr.Zero; + Device vkvgDev; + + public Surface (Device device, int width, int heigth) + { + vkvgDev = device; + handle = NativeMethods.vkvg_surface_create (device.Handle, (uint)width, (uint)heigth); + } + public Surface (Device device, ref byte[] data, int width, int heigth) + { + vkvgDev = device; + handle = NativeMethods.vkvg_surface_create (device.Handle, (uint)width, (uint)heigth); + } + public Surface (Device device, string imgPath) { + vkvgDev = device; + handle = NativeMethods.vkvg_surface_create_from_image (device.Handle, imgPath); + } + + + Surface (IntPtr devHandle, int width, int heigth) + { + handle = NativeMethods.vkvg_surface_create (devHandle, (uint)width, (uint)heigth); + } + ~Surface () + { + Dispose (false); + } + + public IntPtr Handle { get { return handle; }} + public IntPtr VkImage { get { return NativeMethods.vkvg_surface_get_vk_image (handle); }} + public int Width { get { return NativeMethods.vkvg_surface_get_width (handle); }} + public int Height { get { return NativeMethods.vkvg_surface_get_height (handle); }} + + public void AddReference () { + NativeMethods.vkvg_surface_reference (handle); + } + public uint References () => NativeMethods.vkvg_surface_get_reference_count (handle); + +// public Surface CreateSimilar (uint width, uint height) { +// return new Surface (handle, width, height); +// } +// public Surface CreateSimilar (int width, int height) { +// return new Surface (handle, (uint)width, (uint)height); +// } + + public void Flush () { + throw new NotImplementedException (); + } + + public void WriteToPng (string path) { + NativeMethods.vkvg_surface_write_to_png (handle, path); + } + public void Clear () { + NativeMethods.vkvg_surface_clear (handle); + } + + #region IDisposable implementation + public void Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); + } + + protected virtual void Dispose (bool disposing) + { + if (!disposing || handle == IntPtr.Zero) + return; + + NativeMethods.vkvg_surface_destroy (handle); + handle = IntPtr.Zero; + } + #endregion + } +} + diff --git a/Crow/src/GraphicBackends/vkvg/TextExtents.cs b/Crow/src/GraphicBackends/vkvg/TextExtents.cs new file mode 100644 index 00000000..becca773 --- /dev/null +++ b/Crow/src/GraphicBackends/vkvg/TextExtents.cs @@ -0,0 +1,72 @@ +// 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; +using System.Runtime.InteropServices; + +namespace vkvg +{ + [StructLayout (LayoutKind.Sequential)] + public struct TextExtents + { + float xbearing; + float ybearing; + float width; + float height; + float xadvance; + float yadvance; + + public float XBearing { + get { return xbearing; } + set { xbearing = value; } + } + + public float YBearing { + get { return ybearing; } + set { ybearing = value; } + } + + public float Width { + get { return width; } + set { width = value; } + } + + public float Height { + get { return height; } + set { height = value; } + } + + public float XAdvance { + get { return xadvance; } + set { xadvance = value; } + } + + public float 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); + } + } +} diff --git a/Crow/src/GraphicBackends/vkvg/TextRun.cs b/Crow/src/GraphicBackends/vkvg/TextRun.cs new file mode 100644 index 00000000..95cdf7f3 --- /dev/null +++ b/Crow/src/GraphicBackends/vkvg/TextRun.cs @@ -0,0 +1,54 @@ +// 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 vkvg { + public class TextRun : IDisposable { + + IntPtr handle = IntPtr.Zero; + + #region CTORS & DTOR + protected TextRun(IntPtr handle) { + this.handle = handle; + } + public TextRun(string text) { + handle = NativeMethods.vkvg_text_run_create (handle, Context.TerminateUtf8(text)); + } + + ~TextRun() { + Dispose (false); + } + #endregion + + //public void AddReference () { + // NativeMethods.vkvg_pattern_reference (handle); + //} + //public uint References () => NativeMethods.vkvg_pattern_get_reference_count (handle); + + public IntPtr Handle { get { return handle; } } + + public TextExtents Extents { + get { + TextExtents extents; + NativeMethods.vkvg_text_run_get_extents (handle, out extents); + return extents; + } + } + + #region IDisposable implementation + public void Dispose () { + Dispose (true); + GC.SuppressFinalize (this); + } + + protected virtual void Dispose (bool disposing) { + if (!disposing || handle == IntPtr.Zero) + return; + + NativeMethods.vkvg_text_run_destroy (handle); + handle = IntPtr.Zero; + } + #endregion + } +}
\ No newline at end of file diff --git a/Crow/src/GraphicBackends/vkvg/tmp/FontOptions.cs b/Crow/src/GraphicBackends/vkvg/tmp/FontOptions.cs new file mode 100644 index 00000000..690f2145 --- /dev/null +++ b/Crow/src/GraphicBackends/vkvg/tmp/FontOptions.cs @@ -0,0 +1,74 @@ +//from Mono.Cairo +//fake FontOptions + +using System; + +namespace vkvg +{ + public enum SubpixelOrder + { + Default, + Rgb, + Bgr, + Vrgb, + Vbgr, + } + public enum HintMetrics + { + Default, + Off, + On, + } + public enum HintStyle + { + Default, + None, + Slight, + Medium, + Full, + } + public class FontOptions : IDisposable + { + public FontOptions () { } + + + public FontOptions Copy () => default; + + + public IntPtr Handle { + get ; + } + + + public void Merge (FontOptions other) + { + } + + public void Dispose() {} + + public Antialias Antialias { + get ; + set ; + } + + public HintMetrics HintMetrics { + get ; + set ; + } + + public HintStyle HintStyle { + get ; + set ; + } + + public Status Status { + get ; + } + + public SubpixelOrder SubpixelOrder { + get ; + set ; + } + } +} + diff --git a/Crow/src/GraphicBackends/vkvg/tmp/Rectangles.cs b/Crow/src/GraphicBackends/vkvg/tmp/Rectangles.cs new file mode 100644 index 00000000..c50236ce --- /dev/null +++ b/Crow/src/GraphicBackends/vkvg/tmp/Rectangles.cs @@ -0,0 +1,116 @@ +// Copyright (c) 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.Collections.Generic; +using vkvg; + +namespace Crow { + public enum RegionOverlap { + In, + Out, + Part, + } + public class Region + { + public List<Rectangle> list = new List<Rectangle>(); + public int count + { + get { return list.Count; } + } + public bool IsEmpty => list.Count == 0; + + public void AddRectangle(Rectangle r) + { + if (doesNotContain (r)) { + list.Add (r); + boundsUpToDate = false; + } + } + public void Reset() + { + list = new List<Rectangle>(); + _bounds = default; + boundsUpToDate = true; + } + bool doesNotContain(Rectangle r) + { + foreach (Rectangle rInList in list) + if (rInList.ContainsOrIsEqual(r)) + return false; + return true; + } + + public bool intersect(Rectangle r) + { + foreach (Rectangle rInList in list) + if (rInList.Intersect(r)) + return true; + return false; + } + public void stroke(Context ctx, Color c) + { + foreach (Rectangle r in list) + ctx.Rectangle(r); + + ctx.SetSource(c); + + ctx.LineWidth = 2; + ctx.Stroke (); + } + public void clearAndClip(Context ctx) + { + if (list.Count == 0) + return; + foreach (Rectangle r in list) + ctx.Rectangle(r); + + ctx.ClipPreserve(); + ctx.Operator = Operator.Clear; + ctx.Fill(); + ctx.Operator = Operator.Over; + } + + public void clip(Context ctx) + { + foreach (Rectangle r in list) + ctx.Rectangle(r); + + ctx.Clip(); + } + + Rectangle _bounds; + bool boundsUpToDate = true; + public Rectangle Bounds { + get { + if (!boundsUpToDate) { + if (list.Count > 0) { + _bounds = list [0]; + for (int i = 1; i < list.Count; i++) { + _bounds += list [i]; + } + } else + _bounds = default; + boundsUpToDate = true; + } + return _bounds; + } + } + public void clear(Context ctx) + { + foreach (Rectangle r in list) + ctx.Rectangle(r); + ctx.Operator = Operator.Clear; + ctx.Fill(); + ctx.Operator = Operator.Over; + } + public override string ToString () + { + string tmp = ""; + foreach (Rectangle r in list) { + tmp += r.ToString (); + } + return tmp; + } + } +} diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index 60f0e221..ff2caff4 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -13,7 +13,11 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using Crow.IML; using Glfw; using Path = System.IO.Path; diff --git a/Crow/src/Text/IEditableTextWidget.cs b/Crow/src/Text/IEditableTextWidget.cs index 19f3ebd0..28ca1d07 100644 --- a/Crow/src/Text/IEditableTextWidget.cs +++ b/Crow/src/Text/IEditableTextWidget.cs @@ -2,7 +2,11 @@ // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Widgets/Border.cs b/Crow/src/Widgets/Border.cs index c702d9ac..0dc156f2 100644 --- a/Crow/src/Widgets/Border.cs +++ b/Crow/src/Widgets/Border.cs @@ -3,7 +3,11 @@ // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; using System.ComponentModel; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Widgets/ColorSlider.cs b/Crow/src/Widgets/ColorSlider.cs index 9ac4b8a0..18be2120 100644 --- a/Crow/src/Widgets/ColorSlider.cs +++ b/Crow/src/Widgets/ColorSlider.cs @@ -4,7 +4,11 @@ using System; using System.ComponentModel; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using Glfw; namespace Crow diff --git a/Crow/src/Widgets/DockWindow.cs b/Crow/src/Widgets/DockWindow.cs index af47ce3a..f111c458 100644 --- a/Crow/src/Widgets/DockWindow.cs +++ b/Crow/src/Widgets/DockWindow.cs @@ -4,7 +4,11 @@ using System; using System.Xml.Serialization; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using Glfw; namespace Crow diff --git a/Crow/src/Widgets/Gauge.cs b/Crow/src/Widgets/Gauge.cs index 5964da02..635ace58 100644 --- a/Crow/src/Widgets/Gauge.cs +++ b/Crow/src/Widgets/Gauge.cs @@ -5,7 +5,11 @@ using System; using System.ComponentModel; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { public class Gauge : Widget diff --git a/Crow/src/Widgets/GraduatedSlider.cs b/Crow/src/Widgets/GraduatedSlider.cs index 01b8b4cb..8d286a9f 100644 --- a/Crow/src/Widgets/GraduatedSlider.cs +++ b/Crow/src/Widgets/GraduatedSlider.cs @@ -2,7 +2,11 @@ // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Widgets/Group.cs b/Crow/src/Widgets/Group.cs index 55cc6353..936d5e4a 100644 --- a/Crow/src/Widgets/Group.cs +++ b/Crow/src/Widgets/Group.cs @@ -5,7 +5,11 @@ using System; using System.Collections.Generic; using System.ComponentModel; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using System.Threading; using static Crow.Logger; diff --git a/Crow/src/Widgets/GroupBase.cs b/Crow/src/Widgets/GroupBase.cs index 4c0267f8..69829a6f 100644 --- a/Crow/src/Widgets/GroupBase.cs +++ b/Crow/src/Widgets/GroupBase.cs @@ -5,7 +5,11 @@ using System; using System.Collections.Generic; using System.ComponentModel; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using System.Threading; using static Crow.Logger; diff --git a/Crow/src/Widgets/HueSelector.cs b/Crow/src/Widgets/HueSelector.cs index 64f8217e..11f4ac5a 100644 --- a/Crow/src/Widgets/HueSelector.cs +++ b/Crow/src/Widgets/HueSelector.cs @@ -27,7 +27,11 @@ using System; using System.Xml.Serialization; using System.ComponentModel; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Widgets/Image.cs b/Crow/src/Widgets/Image.cs index 5f8ed06e..c3551d08 100644 --- a/Crow/src/Widgets/Image.cs +++ b/Crow/src/Widgets/Image.cs @@ -3,7 +3,11 @@ // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using System.Xml.Serialization; using System.ComponentModel; using System.Diagnostics; diff --git a/Crow/src/Widgets/Label.cs b/Crow/src/Widgets/Label.cs index c8b4b238..1ec42957 100644 --- a/Crow/src/Widgets/Label.cs +++ b/Crow/src/Widgets/Label.cs @@ -4,7 +4,11 @@ using System; using System.Linq; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using System.ComponentModel; using Glfw; using Crow.Text; diff --git a/Crow/src/Widgets/OldLabel.cs b/Crow/src/Widgets/OldLabel.cs index 17179ae3..c0c94703 100644 --- a/Crow/src/Widgets/OldLabel.cs +++ b/Crow/src/Widgets/OldLabel.cs @@ -5,7 +5,11 @@ using System; using System.Collections.Generic; using System.Linq; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using System.Text.RegularExpressions; using System.ComponentModel; diff --git a/Crow/src/Widgets/OldTextBox.cs b/Crow/src/Widgets/OldTextBox.cs index c236bf4b..01ef5ac0 100644 --- a/Crow/src/Widgets/OldTextBox.cs +++ b/Crow/src/Widgets/OldTextBox.cs @@ -2,7 +2,11 @@ // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using Glfw; using System; diff --git a/Crow/src/Widgets/PrivateContainer.cs b/Crow/src/Widgets/PrivateContainer.cs index 22a34f1c..0c35306a 100644 --- a/Crow/src/Widgets/PrivateContainer.cs +++ b/Crow/src/Widgets/PrivateContainer.cs @@ -3,7 +3,11 @@ // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using static Crow.Logger; namespace Crow { diff --git a/Crow/src/Widgets/ProgressBar.cs b/Crow/src/Widgets/ProgressBar.cs index ca9a1a3d..53f90017 100644 --- a/Crow/src/Widgets/ProgressBar.cs +++ b/Crow/src/Widgets/ProgressBar.cs @@ -3,7 +3,11 @@ // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System.ComponentModel; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Widgets/SaturationValueSelector.cs b/Crow/src/Widgets/SaturationValueSelector.cs index c56dd30c..386a0ce0 100644 --- a/Crow/src/Widgets/SaturationValueSelector.cs +++ b/Crow/src/Widgets/SaturationValueSelector.cs @@ -3,7 +3,11 @@ // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Widgets/Scroller.cs b/Crow/src/Widgets/Scroller.cs index 314a7503..8a8f640d 100644 --- a/Crow/src/Widgets/Scroller.cs +++ b/Crow/src/Widgets/Scroller.cs @@ -4,7 +4,11 @@ using System; using System.ComponentModel; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using Glfw; namespace Crow diff --git a/Crow/src/Widgets/Shape.cs b/Crow/src/Widgets/Shape.cs index dd8fefdf..da00ae37 100644 --- a/Crow/src/Widgets/Shape.cs +++ b/Crow/src/Widgets/Shape.cs @@ -6,7 +6,11 @@ using System; using System.ComponentModel; using System.IO; using System.Text; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Widgets/Slider.cs b/Crow/src/Widgets/Slider.cs index dd977128..9ac69f8e 100644 --- a/Crow/src/Widgets/Slider.cs +++ b/Crow/src/Widgets/Slider.cs @@ -2,7 +2,11 @@ // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using System; using System.ComponentModel; diff --git a/Crow/src/Widgets/TabView.cs b/Crow/src/Widgets/TabView.cs index 8872b92b..c5a7ad3b 100644 --- a/Crow/src/Widgets/TabView.cs +++ b/Crow/src/Widgets/TabView.cs @@ -4,7 +4,11 @@ using System; using System.ComponentModel; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using System.Linq; namespace Crow diff --git a/Crow/src/Widgets/Table copy.cs b/Crow/src/Widgets/Table copy.cs index 5aeaede8..14349c6d 100644 --- a/Crow/src/Widgets/Table copy.cs +++ b/Crow/src/Widgets/Table copy.cs @@ -4,7 +4,11 @@ using System; using System.ComponentModel; using System.Linq; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Widgets/Table.cs b/Crow/src/Widgets/Table.cs index 27cfb963..9fb8e1ad 100644 --- a/Crow/src/Widgets/Table.cs +++ b/Crow/src/Widgets/Table.cs @@ -4,7 +4,11 @@ using System; using System.ComponentModel; using System.Linq; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Widgets/TableRow copy.cs b/Crow/src/Widgets/TableRow copy.cs index 2184d486..0387c38f 100644 --- a/Crow/src/Widgets/TableRow copy.cs +++ b/Crow/src/Widgets/TableRow copy.cs @@ -4,7 +4,11 @@ using System; using System.ComponentModel; using System.Linq; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using Glfw; namespace Crow diff --git a/Crow/src/Widgets/TableRow.cs b/Crow/src/Widgets/TableRow.cs index 1ce02c15..1155ba8c 100644 --- a/Crow/src/Widgets/TableRow.cs +++ b/Crow/src/Widgets/TableRow.cs @@ -4,7 +4,11 @@ using System; using System.ComponentModel; using System.Linq; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using Glfw; namespace Crow diff --git a/Crow/src/Widgets/TemplatedControl.cs b/Crow/src/Widgets/TemplatedControl.cs index 5110d941..2c147dc1 100644 --- a/Crow/src/Widgets/TemplatedControl.cs +++ b/Crow/src/Widgets/TemplatedControl.cs @@ -7,7 +7,11 @@ using System.ComponentModel; using System.IO; using System.Reflection; using System.Xml; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Widgets/TemplatedGroup.cs b/Crow/src/Widgets/TemplatedGroup.cs index a1ac759c..5a3fadf2 100644 --- a/Crow/src/Widgets/TemplatedGroup.cs +++ b/Crow/src/Widgets/TemplatedGroup.cs @@ -8,7 +8,11 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Threading; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using Crow.IML; namespace Crow { diff --git a/Crow/src/Widgets/TestCairoPatch.cs b/Crow/src/Widgets/TestCairoPatch.cs index 99230a05..ba598959 100644 --- a/Crow/src/Widgets/TestCairoPatch.cs +++ b/Crow/src/Widgets/TestCairoPatch.cs @@ -3,7 +3,11 @@ // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Widgets/TextBox.cs b/Crow/src/Widgets/TextBox.cs index ece9adc0..84085298 100644 --- a/Crow/src/Widgets/TextBox.cs +++ b/Crow/src/Widgets/TextBox.cs @@ -2,7 +2,11 @@ // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using Crow.Text; using Glfw; using System; diff --git a/Crow/src/Widgets/TextRun.cs b/Crow/src/Widgets/TextRun.cs index d118974f..9efa5cbf 100644 --- a/Crow/src/Widgets/TextRun.cs +++ b/Crow/src/Widgets/TextRun.cs @@ -7,7 +7,11 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text.RegularExpressions; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Widgets/Trend.cs b/Crow/src/Widgets/Trend.cs index 1a2d1375..808cd769 100644 --- a/Crow/src/Widgets/Trend.cs +++ b/Crow/src/Widgets/Trend.cs @@ -4,7 +4,11 @@ using System.Collections.Generic; using System.ComponentModel; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Crow { diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index c38f373b..08cc52d0 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -8,7 +8,11 @@ using System.ComponentModel; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using System.Diagnostics; using Crow.IML; using System.Threading; diff --git a/Crow/src/rsvg/Handle.cs b/Crow/src/rsvg/Handle.cs index ca06ad25..bd0e725e 100644 --- a/Crow/src/rsvg/Handle.cs +++ b/Crow/src/rsvg/Handle.cs @@ -1,5 +1,9 @@ //Copyright GPL2 +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif namespace Rsvg { diff --git a/Directory.Build.props b/Directory.Build.props index 41e78201..faca4414 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,6 +10,7 @@ <CrowPackageVersion>$(CrowVersion)-beta</CrowPackageVersion> <CrowStbSharp>true</CrowStbSharp> <CrowDebugLogEnabled>false</CrowDebugLogEnabled> + <CrowVkvgBackend>true</CrowVkvgBackend> <GlfwSharpVersion>0.2.11-beta</GlfwSharpVersion> </PropertyGroup> </Project> diff --git a/Samples/DebugLogAnalyzer/src/DbgEventWidget.cs b/Samples/DebugLogAnalyzer/src/DbgEventWidget.cs index 6af3f6df..51ce140e 100644 --- a/Samples/DebugLogAnalyzer/src/DbgEventWidget.cs +++ b/Samples/DebugLogAnalyzer/src/DbgEventWidget.cs @@ -4,7 +4,11 @@ using System; using System.Collections.Generic; using System.ComponentModel; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using Crow.DebugLogger; using DebugLogAnalyzer; diff --git a/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs b/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs index d39cc62a..ddbb9183 100644 --- a/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs +++ b/Samples/DebugLogAnalyzer/src/DbgLogViewer.cs @@ -10,7 +10,11 @@ using System.ComponentModel; using System.IO; using System.Linq; using System.Threading.Tasks; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using Crow.DebugLogger; using DebugLogAnalyzer; diff --git a/Samples/DebugLogAnalyzer/src/DebugInterface.cs b/Samples/DebugLogAnalyzer/src/DebugInterface.cs index 26a1eddf..f29da259 100644 --- a/Samples/DebugLogAnalyzer/src/DebugInterface.cs +++ b/Samples/DebugLogAnalyzer/src/DebugInterface.cs @@ -3,7 +3,11 @@ // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) using System; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using System.Threading; namespace Crow diff --git a/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs b/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs index c8b27d7d..9ac6a63c 100644 --- a/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs +++ b/Samples/DebugLogAnalyzer/src/DebugInterfaceWidget.cs @@ -7,7 +7,11 @@ using Glfw; using System.Reflection; using System.Runtime.Loader; using System.IO; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using System.Diagnostics; using System.Collections.Generic; using Crow.DebugLogger; diff --git a/Samples/PathPainter/Painter.cs b/Samples/PathPainter/Painter.cs index 7e3c97bb..2f7f4c81 100644 --- a/Samples/PathPainter/Painter.cs +++ b/Samples/PathPainter/Painter.cs @@ -1,4 +1,8 @@ -using Crow.Cairo; +#if VKVG +using vkvg; +#else +using Crow.Cairo; +#endif using System; using System.Collections; using System.Collections.Generic; diff --git a/Samples/common/Editor.cs b/Samples/common/Editor.cs index 95de4569..be8dfcdb 100644 --- a/Samples/common/Editor.cs +++ b/Samples/common/Editor.cs @@ -8,7 +8,11 @@ using System; using Glfw; using Crow.Text; using System.Collections.Generic; +#if VKVG +using vkvg; +#else using Crow.Cairo; +#endif using System.Threading.Tasks; using System.Linq; diff --git a/Samples/dragNdrop/dragNdrop.cs b/Samples/dragNdrop/dragNdrop.cs index 2ca41357..9f62ec7f 100644 --- a/Samples/dragNdrop/dragNdrop.cs +++ b/Samples/dragNdrop/dragNdrop.cs @@ -1,4 +1,9 @@ -using Crow; +#if VKVG +using vkvg; +#else +using Crow.Cairo; +#endif + namespace tests { @@ -28,9 +33,9 @@ namespace tests Rectangle r = e.DragSource.LastPaintedSlot; startGroup = e.DragSource.Parent as Group; - Crow.Cairo.Surface dragImg = surf.CreateSimilar (Crow.Cairo.Content.ColorAlpha, + Surface dragImg = surf.CreateSimilar (Content.ColorAlpha, r.Width, r.Height); - using (Crow.Cairo.Context gr = new Crow.Cairo.Context(dragImg)) { + using (Context gr = new Context(dragImg)) { gr.SetSource (e.DragSource.bmp, 0, 0); gr.Paint (); } |