<RootNamespace>Crow.Test</RootNamespace>
<AssemblyName>Crow.Test</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
- <ReleaseVersion>0.7</ReleaseVersion>
+ <ReleaseVersion>0.5</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<Compile Include="src\ReflexionExtensions.cs" />
<Compile Include="src\XCursor.cs" />
<Compile Include="src\GraphicObjects\Grid.cs" />
- <Compile Include="src\GraphicObjects\TextRun.cs" />
<Compile Include="src\GraphicObjects\MessageBox.cs" />
<Compile Include="src\SelectionChangeEventArgs.cs" />
<Compile Include="src\ValueChangeEventArgs.cs" />
<Compile Include="src\ParsingException.cs" />
<Compile Include="src\IMLAttributes.cs" />
<Compile Include="src\GraphicObjects\DockStack.cs" />
+ <Compile Include="vkvg\Context.cs" />
+ <Compile Include="vkvg\Device.cs" />
+ <Compile Include="vkvg\NativeMethods.cs" />
+ <Compile Include="vkvg\Surface.cs" />
+ <Compile Include="vkEngine\enums.cs" />
+ <Compile Include="vkEngine\VkEngine.cs" />
+ <Compile Include="src\CrowApplication.cs" />
+ <Compile Include="vkvg\Enums.cs" />
+ <Compile Include="vkh\Device.cs" />
+ <Compile Include="vkh\enums.cs" />
+ <Compile Include="vkh\NativeMethods.cs" />
+ <Compile Include="vkvg\FontExtents.cs" />
+ <Compile Include="vkvg\TextExtents.cs" />
+ <Compile Include="vkvg\PointD.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Folder Include="src\rsvg\" />
<Folder Include="src\IML\" />
<Folder Include="Icons\" />
+ <Folder Include="vkvg\" />
+ <Folder Include="vkEngine\" />
+ <Folder Include="vkh\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Images\Icons\updown.svg" />
</None>
<None Include="Icons\compiler_warning.svg" />
<None Include="Icons\compiler_warning_orange.svg" />
+ <None Include="src\GraphicObjects\TextRun.cs" />
</ItemGroup>
</Project>
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrowIDE", "CrowIDE\CrowIDE.csproj", "{B6D911CD-1D09-42FC-B300-9187190F2AE1}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vkglfw.net", "..\..\vulkan\vkglfw.net\vkglfw.net.csproj", "{FE2D5F0D-F9F4-4F88-9D32-C33D8A4A42C9}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FE2D5F0D-F9F4-4F88-9D32-C33D8A4A42C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FE2D5F0D-F9F4-4F88-9D32-C33D8A4A42C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FE2D5F0D-F9F4-4F88-9D32-C33D8A4A42C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FE2D5F0D-F9F4-4F88-9D32-C33D8A4A42C9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0
$0.StandardHeader = $1
$1.Text = @\n${FileName}\n \nAuthor:\n ${AuthorName} <${AuthorEmail}>\n\nCopyright (c) 2013-2017 Jean-Philippe Bruyère\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the "Software"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.
- $1.IncludeInNewFiles = True
$0.DotNetNamingPolicy = $2
- $2.DirectoryNamespaceAssociation = None
- $2.ResourceNamePolicy = FileFormatDefault
$0.TextStylePolicy = $3
- $3.FileWidth = 120
- $3.TabsToSpaces = False
$3.EolMarker = Unix
- $3.inheritsSet = VisualStudio
- $3.inheritsScope = text/plain
$3.scope = text/x-csharp
$0.CSharpFormattingPolicy = $4
$4.AfterDelegateDeclarationParameterComma = True
- $4.inheritsSet = Mono
- $4.inheritsScope = text/x-csharp
$4.scope = text/x-csharp
+ $4.IndentSwitchSection = False
+ $4.NewLinesForBracesInProperties = False
+ $4.NewLinesForBracesInAccessors = False
+ $4.NewLinesForBracesInAnonymousMethods = False
+ $4.NewLinesForBracesInControlBlocks = False
+ $4.NewLinesForBracesInAnonymousTypes = False
+ $4.NewLinesForBracesInObjectCollectionArrayInitializers = False
+ $4.NewLinesForBracesInLambdaExpressionBody = False
+ $4.NewLineForElse = False
+ $4.NewLineForCatch = False
+ $4.NewLineForFinally = False
+ $4.NewLineForMembersInObjectInit = False
+ $4.NewLineForMembersInAnonymousTypes = False
+ $4.NewLineForClausesInQuery = False
+ $4.SpacingAfterMethodDeclarationName = True
+ $4.SpaceAfterMethodCallName = True
+ $4.SpaceBeforeOpenSquareBracket = True
$0.VersionControlPolicy = $5
$5.CommitMessageStyle = $6
$6.Indent = @\t
$6.LastFilePostfix = "@:\n "
$6.LineAlign = 0
$6.Wrap = False
- $5.inheritsSet = Mono
description = @C.R.O.W. c# Rapid Open Widgets\n\nCrow is a pure c# widget toolkit with XML definition of interface, bindings, styling...\n
version = 0.5
EndGlobalSection
<StartWorkingDirectory>%24{SolutionDir}\build\%24{ProjectConfigName}</StartWorkingDirectory>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
+ <PropertyGroup Condition=" '$(RunConfiguration)' == 'Custom Command' ">
+ <StartAction>Program</StartAction>
+ <StartProgram>%24{TargetName}</StartProgram>
+ <StartWorkingDirectory>%24{SolutionDir}\build\%24{ProjectConfigName}</StartWorkingDirectory>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
using System.Xml.Serialization;
using System.ComponentModel;
using System.Collections;
-using Cairo;
+using vkvg;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
using System.Xml;
using System.Diagnostics;
-using Cairo;
+using vkvg;
namespace Crow.Coding
{
using System.Xml.Serialization;
using System.ComponentModel;
using System.Collections;
-using Cairo;
+using vkvg;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;
// THE SOFTWARE.
using System;
using System.ComponentModel;
-using Cairo;
+using vkvg;
namespace Crow.Coding
{
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
-using Cairo;
+using vkvg;
namespace Crow.Coding
{
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
-using Cairo;
+using vkvg;
namespace Crow.Coding
{
// THE SOFTWARE.
using System;
using Crow;
+using vkvg;
namespace Crow.Coding
{
{
}
- protected override void onDraw (Cairo.Context gr)
+ protected override void onDraw (Context gr)
{
base.onDraw (gr);
Foreground.SetAsSource (gr);
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
-using Cairo;
+using vkvg;
using Crow;
namespace Test
// THE SOFTWARE.
using System;
using Crow;
-using Cairo;
+using vkvg;
namespace Tutorials2
{
using System;
using Crow;
using System.ComponentModel;
-using Cairo;
+using vkvg;
namespace Tutorials
{
// THE SOFTWARE.
using System;
using Crow;
+using vkvg;
namespace Tests
{
{
return base.measureRawSize (lt) + 6;
}
- protected override void onDraw (Cairo.Context gr)
+ protected override void onDraw (Context gr)
{
gr.Save ();
using System;
using Crow;
-using Tutorials;
+//using Tutorials;
namespace Tests
{
- class HelloWorld : CrowWindow
+ class HelloWorld : CrowApplication
{
public HelloWorld ()
- : base(800, 600,"Crow Test with OpenTK")
+ : base(800, 600)
{
}
- protected override void OnLoad (EventArgs e)
- {
- base.OnLoad (e);
- LoadIMLFragment (@"<SimpleGauge Level='40' Margin='5' Background='Jet' Foreground='Gray' Width='30' Height='50%'/>");
- }
-
[STAThread]
static void Main ()
{
- HelloWorld win = new HelloWorld ();
- win.Run (30);
+ using (HelloWorld win = new HelloWorld ()) {
+
+ //win.Load (@"Interfaces/Divers/0.crow").DataSource = win;
+ win.Load (@"Interfaces/GraphicObject/0.crow");
+ win.Run ();
+ }
}
}
}
\ No newline at end of file
public InterfaceControler(Rectangle ifaceBounds){
iRect = ifaceBounds;
- CrowInterface = new Interface ();
+ //CrowInterface = new Interface ();
CrowInterface.Init ();
#if MEASURE_TIME
<?xml version="1.0"?>
-<GraphicObject Margin="10" Width="Stretched" Height="Stretched" Background="SeaGreen"
- MinimumSize="50,50"/>
\ No newline at end of file
+<Group Background="Red">
+ <Label Background="SeaGreen"/>
+</Group>
\ No newline at end of file
<OutputType>Exe</OutputType>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
- <StartupObject>Tests.BasicTests</StartupObject>
+ <StartupObject>Tests.HelloWorld</StartupObject>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReleaseVersion>0.5</ReleaseVersion>
<StartWorkingDirectory>%24{SolutionDir}\build\%24{ProjectConfigName}</StartWorkingDirectory>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
+ <PropertyGroup Condition=" '$(RunConfiguration)' == 'Custom Command' ">
+ <StartAction>Program</StartAction>
+ <StartProgram>%24{TargetName}</StartProgram>
+ <StartWorkingDirectory>%24{SolutionDir}\build\%24{ProjectConfigName}</StartWorkingDirectory>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
- <Compile Include="BasicTests.cs" />
<Compile Include="OpenGL\Shader.cs" />
<Compile Include="OpenGL\vaoMesh.cs" />
<Compile Include="OpenGL\Texture.cs" />
<Compile Include="HelloWorld.cs" />
- <Compile Include="CrowWindow.cs" />
- <Compile Include="Hello3D.cs" />
<Compile Include="OpenGL\Extensions.cs" />
- <Compile Include="InterfaceControler.cs" />
- <Compile Include="Showcase.cs" />
- <Compile Include="GraphicObjects\ColorCircleSelector.cs" />
- <Compile Include="GraphicObjects\SimpleGauge.cs" />
- <Compile Include="Tutorials\T1_HelloWorld.cs" />
- <Compile Include="Tutorials\T3_OpenGLCube.cs" />
- <Compile Include="Tutorials\T4_Gauge.cs" />
- <Compile Include="Tutorials\T2_IML.cs" />
- <Compile Include="GraphicObjects\HexaContainer.cs" />
- <Compile Include="GraphicObjects\TechBorder.cs" />
</ItemGroup>
<ItemGroup>
<None Include="image\u.svg">
<None Include="Interfaces\TemplatedContainer\testTabView2.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="InterfaceControler.cs" />
+ <None Include="CrowWindow.cs" />
+ <None Include="BasicTests.cs" />
+ <None Include="Hello3D.cs" />
+ <None Include="Showcase.cs" />
+ <None Include="Tutorials\T1_HelloWorld.cs" />
+ <None Include="Tutorials\T3_OpenGLCube.cs" />
+ <None Include="Tutorials\T4_Gauge.cs" />
+ <None Include="Tutorials\T2_IML.cs" />
+ <None Include="GraphicObjects\ColorCircleSelector.cs" />
+ <None Include="GraphicObjects\SimpleGauge.cs" />
+ <None Include="GraphicObjects\HexaContainer.cs" />
+ <None Include="GraphicObjects\TechBorder.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
using System;
using System.IO;
-using Cairo;
+using vkvg;
namespace Crow
{
widthRatio = heightRatio;
}
- using (ImageSurface tmp = new ImageSurface (Format.Argb32, bounds.Width, bounds.Height)) {
+ using (Surface tmp = new Surface (CrowApplication.dev, bounds.Width, bounds.Height)) {
using (Context gr = new Context (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);
- using (ImageSurface imgSurf = new ImageSurface (image, Format.Argb32,
- Dimensions.Width, Dimensions.Height, 4 * Dimensions.Width)) {
+ using (Surface imgSurf = new Surface (CrowApplication.dev, ref image, Dimensions.Width, Dimensions.Height)) {
gr.SetSourceSurface (imgSurf, 0,0);
gr.Paint ();
}
gr.Scale (widthRatio, heightRatio);
gr.Translate ((rect.Width/widthRatio - Dimensions.Width)/2, (rect.Height/heightRatio - Dimensions.Height)/2);
- using (ImageSurface imgSurf = new ImageSurface (image, Format.Argb32,
- Dimensions.Width, Dimensions.Height, 4 * Dimensions.Width)) {
+ using (Surface imgSurf = new Surface (CrowApplication.dev, ref image, Dimensions.Width, Dimensions.Height)) {
gr.SetSourceSurface (imgSurf, 0,0);
gr.Paint ();
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using vkvg;
namespace Crow
{
return arr[minp];
}
- public static void CairoRectangle(Cairo.Context gr, Rectangle r, double radius, double stroke = 0.0)
+ public static void CairoRectangle(Context gr, Rectangle r, double radius, double stroke = 0.0)
{
if (radius > 0)
CairoHelpers.DrawRoundedRectangle (gr, r, radius, stroke);
else
gr.Rectangle (r, stroke);
}
- public static void CairoCircle(Cairo.Context gr, Rectangle r)
+ public static void CairoCircle(Context gr, Rectangle r)
{
gr.Arc(r.X + r.Width/2, r.Y + r.Height/2, Math.Min(r.Width,r.Height)/2, 0, 2*Math.PI);
}
- public static void DrawRoundedRectangle(Cairo.Context gr, Rectangle r, double radius, double stroke = 0.0)
+ public static void DrawRoundedRectangle(Context gr, Rectangle r, double radius, double stroke = 0.0)
{
if (stroke>0.0) {
gr.LineWidth = stroke;
}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();
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);
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);
--- /dev/null
+//
+// CrowApplication.cs
+//
+// 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.
+using System;
+using System.Threading;
+using vkglfw;
+
+namespace Crow
+{
+ public class CrowApplication : IDisposable
+ {
+ public static VkEngine vke;
+ public static vkvg.Device dev;
+
+ Interface iFace;
+ vkvg.Surface surf;
+
+ public CrowApplication (int width, int height)
+ {
+ vke = new VkEngine (width, height);
+ dev = new vkvg.Device (vke);
+ surf = new vkvg.Surface (dev, width, height);
+
+ using (vkvg.Context ctx = new vkvg.Context (surf)) {
+ ctx.SetSource (0.1, 0.1, 0.1);
+ ctx.Paint ();
+ }
+
+
+ iFace = new Interface (surf);
+ iFace.Init ();
+
+ Thread t = new Thread (interfaceThread);
+ t.IsBackground = true;
+ t.Start ();
+ }
+ ~CrowApplication ()
+ {
+ Dispose (false);
+ }
+
+ public void Run () {
+ vke.Run (surf);
+ }
+ public GraphicObject Load (string path){
+ return iFace.AddWidget (path);
+ }
+ void interfaceThread()
+ {
+ while (iFace.ClientRectangle.Size.Width == 0)
+ Thread.Sleep (5);
+
+ while (true) {
+ iFace.Update ();
+ Thread.Sleep (2);
+ }
+ }
+
+ #region IDisposable implementation
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (!disposing)
+ return;
+
+ surf.Dispose ();
+ dev.Dispose ();
+ vke.Dispose ();
+ }
+ #endregion
+
+ }
+}
+
using System;
using System.Linq.Expressions;
+using vkvg;
namespace Crow
{
{
#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;
}else
ctx.Rectangle (r.X, r.Y, r.Width, r.Height);
}
- public static double GetLength(this Cairo.PointD p){
+ public static double GetLength(this PointD p){
return Math.Sqrt (Math.Pow (p.X, 2) + Math.Pow (p.Y, 2));
}
- public static Cairo.PointD GetPerp(this Cairo.PointD p){
- return new Cairo.PointD(-p.Y, p.X);
+ public static PointD GetPerp(this PointD p){
+ return new PointD(-p.Y, p.X);
}
- public static Cairo.PointD GetNormalized(this Cairo.PointD p){
+ public static PointD GetNormalized(this PointD p){
double length = p.GetLength();
p.X /= length;
p.Y /= length;
return p;
}
- public static Cairo.PointD Substract(this Cairo.PointD p1, Cairo.PointD p2){
- return new Cairo.PointD(p1.X - p2.X, p1.Y - p2.Y);
+ public static PointD Substract(this PointD p1, PointD p2){
+ return new PointD(p1.X - p2.X, p1.Y - p2.Y);
}
- public static Cairo.PointD Divide(this Cairo.PointD p1, double d){
- return new Cairo.PointD(p1.X / d, p1.Y / d);
+ public static PointD Divide(this PointD p1, double d){
+ return new PointD(p1.X / d, p1.Y / d);
}
- public static Cairo.PointD Add(this Cairo.PointD p1, Cairo.PointD p2){
- return new Cairo.PointD(p1.X + p2.X, p1.Y + p2.Y);
+ public static PointD Add(this PointD p1, PointD p2){
+ return new PointD(p1.X + p2.X, p1.Y + p2.Y);
}
- public static Cairo.PointD Multiply(this Cairo.PointD p1, double v){
- return new Cairo.PointD(p1.X * v, p1.Y * v);
+ 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, Cairo.PointD p1, Cairo.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)
{
- Cairo.PointD vDir = p2.Substract(p1);
+ PointD vDir = p2.Substract(p1);
vDir = vDir.GetNormalized ();
- Cairo.PointD vPerp = vDir.GetPerp ();
+ PointD vPerp = vDir.GetPerp ();
- Cairo.PointD pA0 = p1.Add(vDir.Multiply(arrowLength));
- Cairo.PointD pA1 = p2.Substract(vDir.Multiply(arrowLength));
+ PointD pA0 = p1.Add(vDir.Multiply(arrowLength));
+ PointD pA1 = p2.Substract(vDir.Multiply(arrowLength));
- Cairo.PointD vA = vPerp.Multiply (arrowWidth);
+ PointD vA = vPerp.Multiply (arrowWidth);
ctx.MoveTo (p1);
ctx.LineTo (pA0.Add (vA));
ctx.LineWidth = stroke;
ctx.Stroke ();
}
- public static void DrawCoteInverse(this Cairo.Context ctx, Cairo.PointD p1, Cairo.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)
{
- Cairo.PointD vDir = p2.Substract(p1);
+ PointD vDir = p2.Substract(p1);
vDir = vDir.GetNormalized ();
- Cairo.PointD vPerp = vDir.GetPerp ();
+ PointD vPerp = vDir.GetPerp ();
- Cairo.PointD pA0 = p1.Add(vDir.Multiply(arrowLength));
- Cairo.PointD pA1 = p2.Substract(vDir.Multiply(arrowLength));
+ PointD pA0 = p1.Add(vDir.Multiply(arrowLength));
+ PointD pA1 = p2.Substract(vDir.Multiply(arrowLength));
- Cairo.PointD vA = vPerp.Multiply (arrowWidth);
+ PointD vA = vPerp.Multiply (arrowWidth);
ctx.MoveTo (p1.Add (vA));
ctx.LineTo (pA0);
ctx.LineWidth = stroke;
ctx.Stroke ();
}
- public static void DrawCoteFixed(this Cairo.Context ctx, Cairo.PointD p1, Cairo.PointD p2,
+ public static void DrawCoteFixed(this Context ctx, PointD p1, PointD p2,
double stroke = 1.0, double coteWidth = 3.0)
{
- Cairo.PointD vDir = p2.Substract(p1);
+ PointD vDir = p2.Substract(p1);
vDir = vDir.GetNormalized ();
- Cairo.PointD vPerp = vDir.GetPerp ();
- Cairo.PointD vA = vPerp.Multiply (coteWidth);
+ PointD vPerp = vDir.GetPerp ();
+ PointD vA = vPerp.Multiply (coteWidth);
ctx.MoveTo (p1.Add (vA));
ctx.LineTo (p1.Substract (vA));
ctx.LineWidth = stroke;
ctx.Stroke ();
}
- public static void SetSourceColor(this Cairo.Context ctx, Color c)
+ public static void SetSourceColor(this Context ctx, Color c)
{
- ctx.SetSourceRGBA(c.R,c.G,c.B,c.A);
+ ctx.SetSource (c.R,c.G,c.B,c.A);
}
public static void AddColorStop(this Cairo.Gradient grad, double offset, Color c)
{
using System;
using System.Collections.Generic;
-using Cairo;
+using vkvg;
namespace Crow
{
// THE SOFTWARE.
using System;
-using Cairo;
+using vkvg;
namespace Crow
{
using System;
using System.Collections.Generic;
-using Cairo;
+using vkvg;
namespace Crow
{
foreach (ColorStop cs in Stops)
grad.AddColorStop (cs.Offset, cs.Color);
- ctx.SetSource (grad);
+ //ctx.SetSource (grad);
grad.Dispose ();
}
#endregion
using System.Xml.Serialization;
using System.ComponentModel;
using System.Diagnostics;
-using Cairo;
+using vkvg;
namespace Crow
{
using System.Diagnostics;
using System.Xml.Serialization;
-using Cairo;
+using vkvg;
using System.ComponentModel;
namespace Crow
// THE SOFTWARE.
using System;
using Crow.IML;
+using vkvg;
namespace Crow
{
// }
Rectangle rIn = default(Rectangle);
- double dockThresh = 0.2;
+ double dockThresh = 0.2f;
GraphicObject focusedChild;
internal GraphicObject stretchedChild;
RegisterForGraphicUpdate ();
}
- protected override void onDraw (Cairo.Context gr)
+ protected override void onDraw (Context gr)
{
gr.Save ();
break;
}
gr.LineWidth = 1;
- gr.SetSourceRGBA (0.4, 0.4, 0.9, 0.4);
+ gr.SetSource (0.4, 0.4, 0.9, 0.4);
gr.FillPreserve ();
- gr.SetSourceRGBA (0.9, 0.9, 1.0, 0.8);
+ gr.SetSource (0.9, 0.9, 1.0, 0.8);
gr.Stroke ();
}
gr.Restore ();
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Cairo;
+using vkvg;
using System.Xml.Serialization;
namespace Crow
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
-using Cairo;
+using vkvg;
using System.Diagnostics;
using Crow.IML;
using System.Threading;
parentElem.AppendChild (xe);
}
public Surface CreateIcon (int dragIconSize = 32) {
- ImageSurface di = new ImageSurface (Format.Argb32, dragIconSize, dragIconSize);
+ Surface di = new Surface (CrowApplication.dev, dragIconSize, dragIconSize);
using (Context ctx = new Context (di)) {
- double div = Math.Max (LastPaintedSlot.Width, LastPaintedSlot.Height);
- double s = (double)dragIconSize / div;
+ float div = Math.Max (LastPaintedSlot.Width, LastPaintedSlot.Height);
+ float s = (float)dragIconSize / div;
ctx.Scale (s, s);
if (bmp == null)
this.onDraw (ctx);
/// are repeated at each cached levels of the tree with correspondig coordinate system. This is done
/// in a dedicated step of the update between layouting and drawing.
/// </summary>
- public Region Clipping;
+ public Cairo.Region Clipping;
#region IValueChange implementation
/// <summary>
/// action.
/// </summary>
protected GraphicObject () {
- Clipping = new Region ();
+ Clipping = new Cairo.Region();
#if DEBUG
uid = currentUid;
currentUid++;
IsDirty = false;
if (bmp != null)
bmp.Dispose ();
- bmp = new ImageSurface (Format.Argb32, Slot.Width, Slot.Height);
+ bmp = new Surface (CrowApplication.dev, Slot.Width, Slot.Height);
using (Context gr = new Context (bmp)) {
- gr.Antialias = Interface.Antialias;
+ //gr.Antialias = Interface.Antialias;
onDraw (gr);
}
bmp.Flush ();
ctx.SetSourceSurface (bmp, rb.X, rb.Y);
ctx.Paint ();
Clipping.Dispose ();
- Clipping = new Region ();
+ Clipping = new Cairo.Region();
}
/// <summary> Chained painting routine on the parent context of the actual cached version
/// of the widget </summary>
}
void paintDisabled(Context gr, Rectangle rb){
gr.Operator = Operator.Xor;
- gr.SetSourceRGBA (0.6, 0.6, 0.6, 0.3);
+ gr.SetSource (0.6, 0.6, 0.6, 0.3);
gr.Rectangle (rb);
gr.Fill ();
gr.Operator = Operator.Over;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml.Serialization;
-using Cairo;
+using vkvg;
using System.Diagnostics;
using System.Reflection;
using System.Threading;
foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
- if (Clipping.Contains (c.Slot + ClientRectangle.Position) == RegionOverlap.Out)
+ if (Clipping.Contains (c.Slot + ClientRectangle.Position) == Cairo.RegionOverlap.Out)
continue;
c.Paint (ref gr);
}
ctx.Paint ();
Clipping.Dispose();
- Clipping = new Region ();
+ Clipping = new Cairo.Region();
}
#endregion
using System;
using System.Xml.Serialization;
using System.ComponentModel;
-using Cairo;
+using vkvg;
namespace Crow
{
// THE SOFTWARE.
using System;
-using Cairo;
+using vkvg;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Diagnostics;
Picture _pic;
string _svgSub;
bool scaled, keepProps;
- double opacity;
+ float opacity;
#region Public properties
/// <summary>
/// </summary>
// TODO:could be moved in GraphicObject
[XmlAttributeAttribute()][DefaultValue(1.0)]
- public virtual double Opacity {
+ public virtual float Opacity {
get { return opacity; }
set {
if (opacity == value)
_pic.Paint (gr, ClientRectangle, _svgSub);
if (Opacity<1.0) {
- gr.SetSourceRGBA (0.0, 0.0, 0.0, 1.0-Opacity);
+ gr.SetSource (0, 0, 0, 1-Opacity);
gr.Operator = Operator.DestOut;
gr.Rectangle (ClientRectangle);
gr.Fill ();
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
-using Cairo;
+using vkvg;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using System.ComponentModel;
if (lines == null)
lines = getLines;
if (!textMeasureIsUpToDate) {
- using (ImageSurface img = new ImageSurface (Format.Argb32, 10, 10)) {
- using (Context gr = new Context (img)) {
+ //using (Surface img = new Surface (CrowApplication.dev, 10, 10)) {
+ if (bmp == null)
+ bmp = new Surface (CrowApplication.dev, 10, 10);
+ using (Context gr = new Context (bmp)) {
//Cairo.FontFace cf = gr.GetContextFontFace ();
- gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
- gr.SetFontSize (Font.Size);
- gr.FontOptions = Interface.FontRenderingOptions;
- gr.Antialias = Interface.Antialias;
+ gr.FontFace = Font.Name;
+// gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+// gr.SetFontSize (Font.Size);
+// gr.FontOptions = Interface.FontRenderingOptions;
+// gr.Antialias = Interface.Antialias;
fe = gr.FontExtents;
te = new TextExtents ();
return -1;
}
}
- }
+ //}
}
return lt == LayoutingType.Height ? cachedTextSize.Height : cachedTextSize.Width;
{
base.onDraw (gr);
- gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
- gr.SetFontSize (Font.Size);
- gr.FontOptions = Interface.FontRenderingOptions;
- gr.Antialias = Interface.Antialias;
+ gr.FontFace = Font.Name;
+// gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+// gr.SetFontSize (Font.Size);
+// gr.FontOptions = Interface.FontRenderingOptions;
+// gr.Antialias = Interface.Antialias;
rText = new Rectangle(new Size(
measureRawSize(LayoutingType.Width), measureRawSize(LayoutingType.Height)));
using System;
using System.Xml.Serialization;
using System.ComponentModel;
-using Cairo;
+using vkvg;
namespace Crow
{
ctx.SetSourceSurface (bmp, rb.X, rb.Y);
ctx.Paint ();
Clipping.Dispose();
- Clipping = new Region ();
+ Clipping = new Cairo.Region();
}
#endregion
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Cairo;
+using vkvg;
using System.Diagnostics;
using System.Xml.Serialization;
using System.ComponentModel;
// THE SOFTWARE.
using System;
-using Cairo;
+using vkvg;
using System.Xml.Serialization;
namespace Crow
using System.Xml.Serialization;
using System.ComponentModel;
using System.Diagnostics;
-using Cairo;
+using vkvg;
namespace Crow
{
using System.Xml.Serialization;
using System.ComponentModel;
using System.Collections;
-using Cairo;
+using vkvg;
namespace Crow
using System.ComponentModel;
using System.IO;
using System.Text;
-using Cairo;
+using vkvg;
namespace Crow
{
#endregion
string path;
- double strokeWidth;
+ float strokeWidth;
public string Path {
get { return path; }
}
}
[XmlAttributeAttribute][DefaultValue(1.0)]
- public double StokeWidth {
+ public float StokeWidth {
get { return strokeWidth; }
set {
if (strokeWidth == value)
continue;
switch (c) {
case 'M':
- gr.MoveTo (sr.ReadDouble (), sr.ReadDouble ());
+ gr.MoveTo ((float)sr.ReadDouble (), (float)sr.ReadDouble ());
break;
case 'm':
- gr.RelMoveTo (sr.ReadDouble (), sr.ReadDouble ());
+ gr.RelMoveTo ((float)sr.ReadDouble (), (float)sr.ReadDouble ());
break;
case 'L':
- gr.LineTo (sr.ReadDouble (), sr.ReadDouble ());
+ gr.LineTo ((float)sr.ReadDouble (), (float)sr.ReadDouble ());
break;
case 'l':
- gr.RelLineTo (sr.ReadDouble (), sr.ReadDouble ());
+ gr.RelLineTo ((float)sr.ReadDouble (), (float)sr.ReadDouble ());
break;
case 'C':
- gr.CurveTo (sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble ());
+ gr.CurveTo ((float)sr.ReadDouble (), (float)sr.ReadDouble (), (float)sr.ReadDouble (), (float)sr.ReadDouble (), (float)sr.ReadDouble (), (float)sr.ReadDouble ());
break;
case 'c':
- gr.RelCurveTo (sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble ());
+ gr.RelCurveTo ((float)sr.ReadDouble (), (float)sr.ReadDouble (), (float)sr.ReadDouble (), (float)sr.ReadDouble (), (float)sr.ReadDouble (), (float)sr.ReadDouble ());
break;
case 'Z':
gr.ClosePath ();
}
}
}
- protected override int measureRawSize (LayoutingType lt)
- {
- if ((lt == LayoutingType.Width && contentSize.Width == 0) || (lt == LayoutingType.Height && contentSize.Height == 0)) {
- using (Surface drawing = new ImageSurface (Format.A1, 1,1)) {
- using (Context ctx = new Context (drawing)) {
- executePath (ctx);
- Rectangle r = ctx.StrokeExtents ();
- contentSize = new Size (r.Right, r.Bottom);
- }
- }
- }
- return lt == LayoutingType.Width ?
- contentSize.Width + 2 * Margin: contentSize.Height + 2 * Margin;
- }
+// protected override int measureRawSize (LayoutingType lt)
+// {
+// if ((lt == LayoutingType.Width && contentSize.Width == 0) || (lt == LayoutingType.Height && contentSize.Height == 0)) {
+// using (Surface drawing = new ImageSurface (Format.A1, 1,1)) {
+// using (Context ctx = new Context (drawing)) {
+// executePath (ctx);
+// Rectangle r = ctx.StrokeExtents ();
+// contentSize = new Size (r.Right, r.Bottom);
+// }
+// }
+// }
+// return lt == LayoutingType.Width ?
+// contentSize.Width + 2 * Margin: contentSize.Height + 2 * Margin;
+// }
}
}
// THE SOFTWARE.
using System;
-using Cairo;
+using vkvg;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Diagnostics;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Diagnostics;
-using Cairo;
+using vkvg;
using System.Linq;
namespace Crow
internal TabView savedParent = null;
void makeFloating (TabView tv) {
- lock (IFace.UpdateMutex) {
- ImageSurface di = new ImageSurface (Format.Argb32, dis, dis);
- IFace.DragImageHeight = dis;
- IFace.DragImageWidth = dis;
- using (Context ctx = new Context (di)) {
- double div = Math.Max (LastPaintedSlot.Width, LastPaintedSlot.Height);
- double s = (double)dis / div;
- ctx.Scale (s, s);
- if (bmp == null)
- this.onDraw (ctx);
- else {
- if (LastPaintedSlot.Width>LastPaintedSlot.Height)
- ctx.SetSourceSurface (bmp, 0, (LastPaintedSlot.Width-LastPaintedSlot.Height)/2);
- else
- ctx.SetSourceSurface (bmp, (LastPaintedSlot.Height-LastPaintedSlot.Width)/2, 0);
-
- ctx.Paint ();
- }
- }
- IFace.DragImage = di;
- }
- tv.RemoveChild (this);
- savedParent = tv;
+// lock (IFace.UpdateMutex) {
+// ImageSurface di = new ImageSurface (Format.Argb32, dis, dis);
+// IFace.DragImageHeight = dis;
+// IFace.DragImageWidth = dis;
+// using (Context ctx = new Context (di)) {
+// double div = Math.Max (LastPaintedSlot.Width, LastPaintedSlot.Height);
+// double s = (double)dis / div;
+// ctx.Scale (s, s);
+// if (bmp == null)
+// this.onDraw (ctx);
+// else {
+// if (LastPaintedSlot.Width>LastPaintedSlot.Height)
+// ctx.SetSourceSurface (bmp, 0, (LastPaintedSlot.Width-LastPaintedSlot.Height)/2);
+// else
+// ctx.SetSourceSurface (bmp, (LastPaintedSlot.Height-LastPaintedSlot.Width)/2, 0);
+//
+// ctx.Paint ();
+// }
+// }
+// IFace.DragImage = di;
+// }
+// tv.RemoveChild (this);
+// savedParent = tv;
}
public override ILayoutable Parent {
using System;
using System.Xml.Serialization;
using System.ComponentModel;
-using Cairo;
+using vkvg;
using System.Diagnostics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
-using Cairo;
+using vkvg;
namespace Crow
{
// THE SOFTWARE.
using System;
-using Cairo;
+using vkvg;
using System.Diagnostics;
using System.Xml.Serialization;
using System.Linq;
using System.Text;
using System.Diagnostics;
-using Cairo;
+using vkvg;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using System.ComponentModel;
}
}
- gr.FontMatrix = new Matrix (widthRatio * Font.Size, 0, 0, heightRatio * Font.Size, 0, 0);
+ //gr.FontMatrix = new Matrix (widthRatio * Font.Size, 0, 0, heightRatio * Font.Size, 0, 0);
int curLineCount = 0;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.ComponentModel;
-using Cairo;
+using vkvg;
namespace Crow
{
double stepX = (double)r.Width / (double)(nbValues-1);
gr.LineWidth = 1.0;
- gr.SetDash (new double[]{ 1.0 },0.0);
+ //gr.SetDash (new double[]{ 1.0 },0.0);
gr.MoveTo (ptrX, values [i] * scaleY);
Foreground.SetAsSource (gr);
- gr.SetDash (new double[]{ }, 0.0);
+ //gr.SetDash (new double[]{ }, 0.0);
while (i >= 0) {
gr.LineTo (ptrX, r.Bottom - values [i] * scaleY);
using System.Threading;
using System.Xml;
using System.Xml.Serialization;
-using Cairo;
+using vkvg;
using System.Globalization;
using Crow.IML;
foreach (string af in Directory.GetFiles (AppDomain.CurrentDomain.BaseDirectory, "*.dll")){
try {
Assembly.LoadFrom (af);
- } catch (Exception ex) {
+ } catch {
Console.WriteLine ("{0} not loaded as assembly.", af);
}
}
- FontRenderingOptions = new FontOptions ();
- FontRenderingOptions.Antialias = Antialias.Subpixel;
- FontRenderingOptions.HintMetrics = HintMetrics.On;
- FontRenderingOptions.HintStyle = HintStyle.Full;
- FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb;
+// FontRenderingOptions = new FontOptions ();
+// FontRenderingOptions.Antialias = Antialias.Subpixel;
+// FontRenderingOptions.HintMetrics = HintMetrics.On;
+// FontRenderingOptions.HintStyle = HintStyle.Full;
+// FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb;
}
- public Interface(){
+ public Interface(Surface surface){
CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
+ this.surf = surface;
+ this.clientRectangle = new Rectangle (0, 0, surface.Width, surface.Height);
}
#endregion
loadCursors ();
loadStyling ();
findAvailableTemplates ();
- initTooltip ();
- initContextMenus ();
+ //initTooltip ();
+ //initContextMenus ();
}
#region Static and constants
/// will not be rendered on screen </summary>
public const int MaxDiscardCount = 5;
/// <summary> Global font rendering settings for Cairo </summary>
- public static FontOptions FontRenderingOptions;
+ //public static FontOptions FontRenderingOptions;
/// <summary> Global font rendering settings for Cairo </summary>
- public static Antialias Antialias = Antialias.Subpixel;
+ //public static Antialias Antialias = Antialias.Subpixel;
/// <summary>
/// Each control need a ref to the root interface containing it, if not set in GraphicObject.currentInterface,
#region Public Fields
/// <summary>Graphic Tree of this interface</summary>
public List<GraphicObject> GraphicTree = new List<GraphicObject>();
- /// <summary>Interface's resulting bitmap</summary>
- public byte[] bmp;
- /// <summary>resulting bitmap limited to last redrawn part</summary>
- public byte[] dirtyBmp;
- /// <summary>True when host has to repaint Interface</summary>
public bool IsDirty = false;
/// <summary>Coordinate of the dirty bmp on the original bmp</summary>
public Rectangle DirtyRect;
/// <summary>Client rectangle in the host context</summary>
Rectangle clientRectangle;
/// <summary>Clipping rectangles on the root context</summary>
- Region clipping = new Region();
+ Cairo.Region clipping = new Cairo.Region();
/// <summary>Main Cairo context</summary>
Context ctx;
/// <summary>Main Cairo surface</summary>
- Surface surf;
+ public Surface surf;
#endregion
#region Default values and Style loading
drawingMeasure.StartCycle();
#endif
if (DragImage != null)
- clipping.UnionRectangle(new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight));
- using (surf = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, ClientRectangle.Width * 4)) {
+ clipping.UnionRectangle(new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight));
using (ctx = new Context (surf)){
if (!clipping.IsEmpty) {
GraphicObject p = GraphicTree[i];
if (!p.Visible)
continue;
- if (clipping.Contains (p.Slot) == RegionOverlap.Out)
+ if (clipping.Contains (p.Slot) == Cairo.RegionOverlap.Out)
continue;
ctx.Save ();
ctx.Save ();
ctx.ResetClip ();
ctx.SetSourceSurface (DragImage, DragImageX, DragImageY);
- ctx.PaintWithAlpha (0.8);
+ //ctx.PaintWithAlpha (0.8);
ctx.Restore ();
DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight);
IsDirty = true;
#if DEBUG_CLIP_RECTANGLE
clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5));
#endif
+ /*
lock (RenderMutex) {
// Array.Copy (bmp, dirtyBmp, bmp.Length);
} else
IsDirty = false;
}
+ */
clipping.Dispose ();
- clipping = new Region ();
+ clipping = new Cairo.Region();
}
//surf.WriteToPng (@"/mnt/data/test.png");
- }
+
}
#if MEASURE_TIME
drawingMeasure.StopCycle();
public void ProcessResize(Rectangle bounds){
lock (UpdateMutex) {
clientRectangle = bounds;
- int stride = 4 * ClientRectangle.Width;
- int bmpSize = Math.Abs (stride) * ClientRectangle.Height;
- bmp = new byte[bmpSize];
- dirtyBmp = new byte[bmpSize];
+// int stride = 4 * ClientRectangle.Width;
+// int bmpSize = Math.Abs (stride) * ClientRectangle.Height;
+// bmp = new byte[bmpSize];
+// dirtyBmp = new byte[bmpSize];
foreach (GraphicObject g in GraphicTree)
g.RegisterForLayouting (LayoutingType.All);
//
-// Mono.Cairo.Context.cs
+// Mono.Context.cs
//
// Author:
// Duncan Mak (duncan@ximian.com)
//
-// Mono.Cairo.Context.cs
+// Mono.Context.cs
//
// Author:
// Duncan Mak (duncan@ximian.com)
using System;
using System.Runtime.InteropServices;
using System.Text;
-using Cairo;
+using vkvg;
namespace Cairo {
- [Obsolete ("Renamed Cairo.Context per suggestion from cairo binding guidelines.")]
+ [Obsolete ("Renamed Context per suggestion from cairo binding guidelines.")]
public class Graphics : Context {
public Graphics (IntPtr state) : base (state) {}
public Graphics (Surface surface) : base (surface) {}
//
-// Mono.Cairo.Context.cs
+// Mono.Context.cs
//
// Author:
// Duncan Mak (duncan@ximian.com)
internal static extern bool cairo_region_contains_point (IntPtr region, int x, int y);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern RegionOverlap cairo_region_contains_rectangle (IntPtr region, ref Crow.Rectangle rectangle);
+ internal static extern Cairo.RegionOverlap cairo_region_contains_rectangle (IntPtr region, ref Crow.Rectangle rectangle);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
internal static extern IntPtr cairo_region_copy (IntPtr original);
//
-// Mono.Cairo.Context.cs
+// Mono.Context.cs
//
// Author:
// Miguel de Icaza (miguel@novell.com)
using System;
using System.Runtime.InteropServices;
-using Cairo;
+using vkvg;
namespace Cairo {
//
-// Mono.Cairo.Context.cs
+// Mono.Context.cs
//
// Author:
// Duncan Mak (duncan@ximian.com)
//
-// Mono.Cairo.Context.cs
+// Mono.Context.cs
//
// Author:
// Duncan Mak (duncan@ximian.com)
get { return NativeMethods.cairo_region_is_empty (Handle); }
}
- public RegionOverlap Contains (Crow.Rectangle rectangle)
+ public Cairo.RegionOverlap Contains (Crow.Rectangle rectangle)
{
return NativeMethods.cairo_region_contains_rectangle (Handle, ref rectangle);
}
using System;
using System.IO;
-using Cairo;
+using vkvg;
using System.Collections.Generic;
namespace Crow
{
return new Cairo.Point(p.X, p.Y);
}
- public static implicit operator Cairo.PointD(Point p)
+ public static implicit operator vkvg.PointD(Point p)
{
- return new Cairo.PointD(p.X, p.Y);
+ return new vkvg.PointD(p.X, p.Y);
}
public static implicit operator System.Drawing.Point(Point p)
{
using System.Xml.Serialization;
using System.Reflection;
using System.Diagnostics;
-using Cairo;
+using vkvg;
public override void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle))
{
- ctx.SetSourceRGBA (color.R, color.G, color.B, color.A);
+ ctx.SetSource (color.R, color.G, color.B, color.A);
}
public static object Parse(string s)
{
using System;
using System.IO;
-using Cairo;
+using vkvg;
namespace Crow
{
widthRatio = heightRatio;
}
- using (ImageSurface tmp = new ImageSurface (Format.Argb32, bounds.Width, bounds.Height)) {
- using (Context gr = new Context (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);
-
- hSVG.RenderCairo (gr);
- }
- ctx.SetSource (tmp);
- }
+// using (Surface tmp = new Surface (bounds.Width, bounds.Height)) {
+// using (Context gr = new Context (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);
+//
+// hSVG.RenderCairo (gr);
+// }
+// ctx.SetSource (tmp);
+// }
}
#endregion
//Copyright GPL2
-using Cairo;
+using vkvg;
namespace Rsvg {
[DllImport("rsvg-2")]
static extern void rsvg_handle_render_cairo_sub(IntPtr raw, IntPtr cr, string id);
- public void RenderCairoSub(Cairo.Context cr, string id) {
+ public void RenderCairoSub(Context cr, string id) {
rsvg_handle_render_cairo_sub(Raw, cr == null ? IntPtr.Zero : cr.Handle, id);
}
--- /dev/null
+//
+// VkEngine.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// Copyright (c) 2018 jp
+//
+// 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;
+using vkh;
+
+namespace vkglfw
+{
+ public delegate void VKEmousebuttonfun(IntPtr win, MouseButton but, KeyAction action, KeyModifiers mods);
+ public delegate void VKEcursorposfun(IntPtr win, double x, double y);
+ public delegate void VKEscrollfun(IntPtr win, double xdelta, double ydelta);
+ public delegate void VKEkeyfun(IntPtr win, Key key, int scancode, KeyAction action, KeyModifiers mods);
+ public delegate void VKEcharfun(IntPtr win, uint codepoint);
+
+ public class VkEngine : IDisposable
+ {
+ const string libvkglfw = "vkglfw";
+
+ [DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr vkengine_create (VkPhysicalDeviceType devType, uint width, uint height);
+
+ [DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void vkengine_close (IntPtr e);
+
+ [DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void vkengine_destroy (IntPtr vkengine_handle);
+
+ [DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void vkengine_blitter_run (IntPtr vkengine_handle, IntPtr vkImage);
+
+ [DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr vkengine_get_device (IntPtr vkengine_handle);
+
+ [DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr vkengine_get_physical_device (IntPtr vkengine_handle);
+
+ //[DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ //internal static extern void vkengine_get_queues_properties (IntPtr e, ref IntPtr ptrProps, out uint count);
+
+ //[DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ //internal static extern void vkengine_free_ptr (IntPtr ptr);
+
+ [DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr vkengine_get_queue (IntPtr vkengine_handle);
+
+ [DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern uint vkengine_get_queue_fam_idx (IntPtr vkengine_handle);
+
+ [DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void vkengine_set_mouse_but_callback (IntPtr e, VKEmousebuttonfun onMouseBut);
+ [DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void vkengine_set_cursor_pos_callback (IntPtr e, VKEcursorposfun onMouseMove);
+ [DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void vkengine_set_scroll_callback (IntPtr e, VKEscrollfun onScroll);
+ [DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void vkengine_set_key_callback (IntPtr e, VKEkeyfun onKey);
+ [DllImport (libvkglfw, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void vkengine_set_char_callback (IntPtr e, VKEcharfun onChar);
+
+
+ void onMouseButton(IntPtr win, MouseButton but, KeyAction action, KeyModifiers mods){}
+ void onMouseMove(IntPtr win, double x, double y){
+ Console.WriteLine("mouse ({0},{1})", x, y);
+ }
+ void onScroll(IntPtr win, double xdelta, double ydelta){}
+ void onKey(IntPtr win, Key key, int scancode, KeyAction action, KeyModifiers mods){
+ if (key == Key.Escape && action == KeyAction.Press)
+ vkengine_close (handle);
+ }
+ void onChar(IntPtr win, uint codepoint){}
+
+ IntPtr handle = IntPtr.Zero;
+
+ public VkEngine (int width, int height)
+ {
+ handle = vkengine_create (VkPhysicalDeviceType.DiscreteGPU, (uint)width, (uint)height);
+
+ vkengine_set_mouse_but_callback (handle, onMouseButton);
+ vkengine_set_cursor_pos_callback (handle, onMouseMove);
+ vkengine_set_scroll_callback (handle, onScroll);
+ vkengine_set_key_callback (handle, onKey);
+ vkengine_set_char_callback (handle, onChar);
+ }
+ ~VkEngine ()
+ {
+ Dispose (false);
+ }
+
+// public QueueFamilyProperties[] AvailableQueues {
+// get {
+// IntPtr ptr = IntPtr.Zero, p;
+// uint count;
+// vkengine_get_queues_properties (handle, ref ptr, out count);
+// QueueFamilyProperties[] qfps = new QueueFamilyProperties[count];
+// p = ptr;
+// for (int i = 0; i < count; i++) {
+// qfps[i] = (QueueFamilyProperties)Marshal.PtrToStructure(p, typeof(QueueFamilyProperties));
+// p += Marshal.SizeOf(typeof(QueueFamilyProperties));
+// }
+// vkengine_free_ptr (ptr);
+// return qfps;
+// }
+// }
+
+ public IntPtr Handle { get { return handle; }}
+ public IntPtr Device { get { return vkengine_get_device (handle); }}
+ public IntPtr Phy { get { return vkengine_get_physical_device (handle); }}
+ public IntPtr Queue { get { return vkengine_get_queue (handle); }}
+ public uint QueueFamIdx { get { return vkengine_get_queue_fam_idx (handle); }}
+
+ public void Run (vkvg.Surface surf) {
+ vkengine_blitter_run (handle, surf.VkImage);
+ }
+
+ #region IDisposable implementation
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (!disposing || handle == IntPtr.Zero)
+ return;
+
+ vkengine_destroy (handle);
+ handle = IntPtr.Zero;
+ }
+ #endregion
+ }
+}
+
--- /dev/null
+//
+// enums.cs
+//
+// Author:
+// Copyright (c) 2013 Antonie Blom
+//
+//
+// 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 vkglfw
+{
+ public enum VkPhysicalDeviceType {
+ Other = 0,
+ IntegratedGPU = 1,
+ DiscreteGPU = 2,
+ VirtualGPU = 3,
+ CPU = 4,
+ }
+ //taken from pencil.gaming (Copyright (c) 2013 Antonie Blom)
+ public enum KeyModifiers
+ {
+ Shift = 1 << 0, //1
+ Control = 1 << 1, //2
+ Alt = 1 << 2, //4
+ Super = 1 << 3 //8
+ }
+ public enum KeyAction {
+ Release = 0,
+ Press,
+ Repeat,
+ }
+ public enum MouseButton {
+ Button1 = 0,
+ Button2,
+ Button3,
+ Button4,
+ Button5,
+ Button6,
+ Button7,
+ Button8,
+ LeftButton = 0,
+ RightButton,
+ MiddleButton,
+ }
+ public enum Joystick {
+ Joystick1 = 0,
+ Joystick2,
+ Joystick3,
+ Joystick4,
+ Joystick5,
+ Joystick6,
+ Joystick7,
+ Joystick8,
+ Joystick9,
+ Joystick10,
+ Joystick11,
+ Joystick12,
+ Joystick13,
+ Joystick14,
+ Joystick15,
+ Joystick16,
+ }
+ public enum Key {
+ Space = 32,
+ Apostrophe = 39,
+ Comma = 44,
+ Minus,
+ Period,
+ Slash,
+ Zero,
+ One,
+ Two,
+ Three,
+ Four,
+ Five,
+ Six,
+ Seven,
+ Eight,
+ Nine,
+ Semicolon = 59,
+ Equal = 61,
+ A = 65,
+ B,
+ C,
+ D,
+ E,
+ F,
+ G,
+ H,
+ I,
+ J,
+ K,
+ L,
+ M,
+ N,
+ O,
+ P,
+ Q,
+ R,
+ S,
+ T,
+ U,
+ V,
+ W,
+ X,
+ Y,
+ Z,
+ LeftBracket,
+ Backslash,
+ RightBracket,
+ GraveAccent = 96,
+ World1 = 161,
+ World2,
+ Escape = 256,
+ Enter,
+ Tab,
+ Backspace,
+ Insert,
+ Delete,
+ Right,
+ Left,
+ Down,
+ Up,
+ PageUp,
+ PageDown,
+ Home,
+ End,
+ CapsLock = 280,
+ ScrollLock,
+ NumLock,
+ PrintScreen,
+ Pause,
+ F1 = 290,
+ F2,
+ F3,
+ F4,
+ F5,
+ F6,
+ F7,
+ F8,
+ F9,
+ F10,
+ F11,
+ F12,
+ F13,
+ F14,
+ F15,
+ F16,
+ F17,
+ F18,
+ F19,
+ F20,
+ F21,
+ F22,
+ F23,
+ F24,
+ F25,
+ KP0 = 320,
+ KP1,
+ KP2,
+ KP3,
+ KP4,
+ KP5,
+ KP6,
+ KP7,
+ KP8,
+ KP9,
+ KPDecimal,
+ KPDivide,
+ KPMultiply,
+ KPSubtract,
+ KPAdd,
+ KPEnter,
+ KPEqual,
+ LeftShift = 340,
+ LeftControl,
+ LeftAlt,
+ LeftSuper,
+ RightShift,
+ RightControl,
+ RightAlt,
+ RightSuper,
+ Menu,
+ }
+}
+
--- /dev/null
+//
+// Context.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// Copyright (c) 2018 jp
+//
+// 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 vkh
+{
+ public class Device: IDisposable
+ {
+
+ IntPtr handle = IntPtr.Zero;
+
+ public Device (vkglfw.VkEngine engine)
+ {
+ //handle = NativeMethods.vkvg_device_create (engine.Phy, engine.Device, engine.Queue, engine.QueueFamIdx);
+ }
+ ~Device ()
+ {
+ Dispose (false);
+ }
+
+ 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
+ }
+}
+
--- /dev/null
+//
+// NativeMethods.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// Copyright (c) 2018 jp
+//
+// 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 vkh
+{
+ internal static class NativeMethods
+ {
+ const string libvkh = "vkh";
+
+ #region Device
+ [DllImport (libvkh, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr vkh_device_create (IntPtr phy, IntPtr dev, IntPtr queue, uint qFamIdx);
+ [DllImport (libvkh, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr vkh_device_destroy (IntPtr device);
+ #endregion
+ }
+}
+
--- /dev/null
+//
+// enums.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// Copyright (c) 2018 jp
+//
+// 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 vkh
+{
+ [Flags]
+ public enum QueueFlags : uint{
+ Graphic = 0x01,
+ Compute = 0x02,
+ Transfer = 0x04,
+ SparseBinding = 0x08
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Extent3D {
+ public uint width;
+ public uint height;
+ public uint depth;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Extent2D {
+ public uint width;
+ public uint height;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct QueueFamilyProperties {
+ public QueueFlags queueFlags;
+ public uint queueCount;
+ public uint timestampValidBits;
+ public Extent3D minImageTransferGranularity;
+ }
+}
+
--- /dev/null
+//
+// Context.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// Copyright (c) 2018 jp
+//
+// 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 Crow;
+using System.Text;
+
+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 { get { return handle; }}
+
+ public double LineWidth {
+ set { NativeMethods.vkvg_set_line_width (handle, (float)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 FontExtents FontExtents {
+ get {
+ FontExtents f_extents;
+ NativeMethods.vkvg_font_extents (handle, out f_extents);
+ return f_extents;
+ }
+ }
+ public TextExtents TextExtents(string s)
+ {
+ TextExtents extents;
+ NativeMethods.vkvg_text_extents (handle, TerminateUtf8(s), out extents);
+ return extents;
+ }
+ public void ShowText (string txt) {
+ NativeMethods.vkvg_show_text (handle, txt);
+ }
+ public void Save () {
+ NativeMethods.vkvg_save (handle);
+ }
+ public void Restore () {
+ NativeMethods.vkvg_restore (handle);
+ }
+ public void Flush () {
+ NativeMethods.vkvg_flush (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 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 ClosePath () {
+ NativeMethods.vkvg_close_path (handle);
+ }
+
+// public void Rectangle (float x, float y, float width, float height){
+// NativeMethods.vkvg_rectangle ();
+// }
+ public void MoveTo (PointD p){
+ NativeMethods.vkvg_move_to (handle, (float)p.X, (float)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 (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);
+ }
+
+ private 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;
+ }
+
+ #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
+ }
+}
+
--- /dev/null
+//
+// Context.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// Copyright (c) 2018 jp
+//
+// 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 vkvg
+{
+ public class Device: IDisposable
+ {
+
+ IntPtr handle = IntPtr.Zero;
+
+ public Device (vkglfw.VkEngine engine)
+ {
+ handle = NativeMethods.vkvg_device_create (engine.Phy, engine.Device, engine.QueueFamIdx, 0);
+ }
+ ~Device ()
+ {
+ Dispose (false);
+ }
+
+ 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
+ }
+}
+
--- /dev/null
+//
+// Enums.cs
+//
+// 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.
+using System;
+
+namespace vkvg
+{
+ 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,
+ }
+}
+
--- /dev/null
+//
+// 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 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);
+ }
+ }
+}
--- /dev/null
+//
+// NativeMethods.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// Copyright (c) 2018 jp
+//
+// 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 vkvg
+{
+ internal static class NativeMethods
+ {
+ const string libvkvg = "vkvg";
+
+ #region Device
+ [DllImport (libvkvg, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr vkvg_device_create (IntPtr phy, IntPtr dev, uint qFamIdx, uint qIndex);
+ [DllImport (libvkvg, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr vkvg_device_destroy (IntPtr device);
+ #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_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_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_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_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_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_operator (IntPtr ctx, Operator op);
+ [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_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, string text);
+ [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);
+ #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_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);
+ #endregion
+ }
+}
+
--- /dev/null
+//
+// Mono.Context.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+// Miguel de Icaza (miguel@novell.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// Alp Toker (alp@atoker.com)
+//
+// (C) Ximian Inc, 2003.
+// (C) Novell Inc, 2003.
+//
+// This is an OO wrapper API for the Cairo API.
+//
+// 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.
+//
+
+namespace vkvg {
+
+ public struct PointD
+ {
+ public PointD (double x, double y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+
+ double x, y;
+ public double X {
+ get { return x; }
+ set { x = value; }
+ }
+
+ public double Y {
+ get { return y; }
+ set { y = value; }
+ }
+ }
+}
--- /dev/null
+//
+// Context.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// Copyright (c) 2018 jp
+//
+// 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 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 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 () {}
+ #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
+ }
+}
+
--- /dev/null
+//
+// 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 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);
+ }
+ }
+}