]> O.S.I.I.S - jp/crow.git/commitdiff
first tests with vkvg as backend vkvg
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 7 May 2018 06:12:56 +0000 (08:12 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 7 May 2018 06:12:56 +0000 (08:12 +0200)
75 files changed:
Crow.Test/Crow.Test.csproj
Crow.csproj
Crow.sln
CrowIDE/CrowIDE.csproj
CrowIDE/src/Editors/CodeBuffer/TextEditor.cs
CrowIDE/src/Editors/ImlVisualEditor.cs
CrowIDE/src/Editors/SourceEditor.cs
CrowIDE/src/Editors/SvgEditor.cs
CrowIDE/src/GraphicObjectDesignContainer.cs
CrowIDE/src/MemberView/MembersView.cs
CrowIDE/src/VerticalLine.cs
Tests/GraphicObjects/ColorCircleSelector.cs
Tests/GraphicObjects/HexaContainer.cs
Tests/GraphicObjects/SimpleGauge.cs
Tests/GraphicObjects/TechBorder.cs
Tests/HelloWorld.cs
Tests/InterfaceControler.cs
Tests/Interfaces/GraphicObject/0.crow
Tests/Tests.csproj
src/BmpPicture.cs
src/Cairo/CairoHelpers.cs
src/CrowApplication.cs [new file with mode: 0644]
src/ExtensionsMethods.cs
src/Fill/Fill.cs
src/Font.cs
src/Gradient.cs
src/GraphicObjects/Border.cs
src/GraphicObjects/Button.cs
src/GraphicObjects/DockStack.cs
src/GraphicObjects/GraduatedSlider.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/HueSelector.cs
src/GraphicObjects/Image.cs
src/GraphicObjects/Label.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/ProgressBar.cs
src/GraphicObjects/SaturationValueSelector.cs
src/GraphicObjects/Scroller.cs
src/GraphicObjects/ScrollingObject.cs
src/GraphicObjects/Shape.cs
src/GraphicObjects/Slider.cs
src/GraphicObjects/TabItem.cs
src/GraphicObjects/TabView.cs
src/GraphicObjects/TemplatedControl.cs
src/GraphicObjects/TextBox.cs
src/GraphicObjects/TextRun.cs
src/GraphicObjects/Trend.cs
src/Interface.cs
src/Mono.Cairo/Color.cs
src/Mono.Cairo/Context.cs
src/Mono.Cairo/Distance.cs
src/Mono.Cairo/NativeMethods.cs
src/Mono.Cairo/Path.cs
src/Mono.Cairo/Point.cs
src/Mono.Cairo/PointD.cs
src/Mono.Cairo/Region.cs
src/Picture.cs
src/Point.cs
src/SolidColor.cs
src/SvgPicture.cs
src/rsvg/Handle.cs
vkEngine/VkEngine.cs [new file with mode: 0644]
vkEngine/enums.cs [new file with mode: 0644]
vkh/Device.cs [new file with mode: 0644]
vkh/NativeMethods.cs [new file with mode: 0644]
vkh/enums.cs [new file with mode: 0644]
vkvg/Context.cs [new file with mode: 0644]
vkvg/Device.cs [new file with mode: 0644]
vkvg/Enums.cs [new file with mode: 0644]
vkvg/FontExtents.cs [new file with mode: 0644]
vkvg/NativeMethods.cs [new file with mode: 0644]
vkvg/PointD.cs [new file with mode: 0644]
vkvg/Surface.cs [new file with mode: 0644]
vkvg/TextExtents.cs [new file with mode: 0644]

index cf7b10a02e8fa54289ff6e79231f12c069dedb4b..12c612c865783bdb1d3abf8d30fb1338c850a0d9 100644 (file)
@@ -10,7 +10,7 @@
     <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>
index 1b5b3406bf82884fd9a7d1531c6027a3043bc311..2580dfce255774958ad8eb436cd03133e0eedf7d 100644 (file)
@@ -88,7 +88,6 @@
     <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>
index 4d3e4799a67c4b3fde83e9f15040bd191ec63be1..fdcd2fd30f22adcc1e533a2a5dbc8d3079ca5ac2 100644 (file)
--- a/Crow.sln
+++ b/Crow.sln
@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crow.Test", "Crow.Test\Crow
 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
@@ -29,27 +31,39 @@ Global
                {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
@@ -57,7 +71,6 @@ Global
                $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
index 1cae7289c95a09b3ad0899e9c7a0ef6902841203..b0ed9dadd8169c04d41f61bf78ddbeb276d8450d 100644 (file)
     <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" />
index 6b7234dc23131c7cf8c0e523bfc19cff30b97e5b..cbb42e283e36491220af47faad3859e6b8b50742 100644 (file)
@@ -28,7 +28,7 @@ using System;
 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;
index b1759fbc93dec010d30279727ffd890623bbedc8..842130809504a30c1c3746c628306b8c8a4a1a44 100644 (file)
@@ -29,7 +29,7 @@ using Crow.IML;
 using System.Text;
 using System.Xml;
 using System.Diagnostics;
-using Cairo;
+using vkvg;
 
 namespace Crow.Coding
 {
index 4234a6835f639a58c121ea62daff1d9b0e3d397f..a25e13a94aff6082628be7cd4fc3bea8368d5390 100644 (file)
@@ -28,7 +28,7 @@ using System;
 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;
index 219eea67f263b46c241452feb0faa23c66d4b99a..bf01f96aaa2d93f1c136520a358c86449ce7d02d 100644 (file)
@@ -25,7 +25,7 @@
 // THE SOFTWARE.
 using System;
 using System.ComponentModel;
-using Cairo;
+using vkvg;
 
 namespace Crow.Coding
 {
index 4540898baf3518063cc109ef074c793bc4cc4e26..31528fd43fe585d435178a62ca09c73fa0cc88e1 100644 (file)
@@ -24,7 +24,7 @@
 // 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
 {
index d8a9ddcd7660bc2d9de1ba9cb9e787ad93d01b5f..fc85a08d7797751a5641906fb8814a54898f04bc 100644 (file)
@@ -25,7 +25,7 @@ using System.ComponentModel;
 using System.Reflection;
 using System.Collections.Generic;
 using System.Linq;
-using Cairo;
+using vkvg;
 
 namespace Crow.Coding
 {      
index 03afeea8894c441b5edcb47f6df326d77f78f50d..da442b96db1f95196870d96c8168f151a144449a 100644 (file)
@@ -25,6 +25,7 @@
 // THE SOFTWARE.
 using System;
 using Crow;
+using vkvg;
 
 namespace Crow.Coding
 {
@@ -34,7 +35,7 @@ namespace Crow.Coding
                {
                }
 
-               protected override void onDraw (Cairo.Context gr)
+               protected override void onDraw (Context gr)
                {
                        base.onDraw (gr);
                        Foreground.SetAsSource (gr);
index 7ab9a9bf6d80314868421a9dbc61a8bc10f8d6de..a6fe502de4735274d84b6860e2eca0196fa14990 100644 (file)
@@ -24,7 +24,7 @@
 // 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
index 23964e9c53e757bedc040a654c348ec121bdef7a..22eb1a819d834a66ce0a660bba33bcf02f1d2b06 100644 (file)
@@ -25,7 +25,7 @@
 // THE SOFTWARE.
 using System;
 using Crow;
-using Cairo;
+using vkvg;
 
 namespace Tutorials2
 {      
index ce92abefda55fb723733940be74e713a0ccf4c81..2ff9635cf02076e7b6872d2b07419b7f9704cf7f 100644 (file)
@@ -26,7 +26,7 @@
 using System;
 using Crow;
 using System.ComponentModel;
-using Cairo;
+using vkvg;
 
 namespace Tutorials
 {
index 4f818e51e7ccaa44fb4ba8416afc16359da3d5d8..dd16c30cd02980e0e468186182b846d36f7b7c58 100644 (file)
@@ -25,6 +25,7 @@
 // THE SOFTWARE.
 using System;
 using Crow;
+using vkvg;
 
 namespace Tests
 {
@@ -37,7 +38,7 @@ namespace Tests
                {
                        return base.measureRawSize (lt) + 6;
                }
-               protected override void onDraw (Cairo.Context gr)
+               protected override void onDraw (Context gr)
                {
                        gr.Save ();
 
index 75cc9bd59f7ac2965206ae2c7309f67db57ba18b..8149ac0e171cd3d63b783532165ebc08d48e9a69 100644 (file)
 
 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
index 034cab39334911ef337ac2a523f1204cda0d6f0c..68bfc63bb3a14b43227bdee2332ed218d627a75f 100644 (file)
@@ -133,7 +133,7 @@ namespace Crow
                public InterfaceControler(Rectangle ifaceBounds){
                        iRect = ifaceBounds;
 
-                       CrowInterface = new Interface ();
+                       //CrowInterface = new Interface ();
                        CrowInterface.Init ();
 
                        #if MEASURE_TIME
index 7fdd607f4dd023268bac24581783f61467589d6b..4856f1c3ccf9f2de1fd50ee7df0ae78a371da390 100755 (executable)
@@ -1,3 +1,4 @@
 <?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
index c86ff9cb203835ef88bdc57effb1bf92cb111a43..082f1aab1289109d9a08fcf95d2fd68fca6af9e0 100644 (file)
@@ -8,7 +8,7 @@
     <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\" />
index e3af9c79781761a5a6abb6fdffce3788b3a17470..a549f3392d2107a831cf02850b32d590070e93ef 100644 (file)
@@ -26,7 +26,7 @@
 
 using System;
 using System.IO;
-using Cairo;
+using vkvg;
 
 namespace Crow
 {
@@ -110,14 +110,13 @@ 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 ();
                                        }
@@ -157,8 +156,7 @@ namespace Crow
                        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 ();
                        }
index 44060259b301448a19bcf4ecd2423c26dd6bed8b..2290e319af8f437842393b6b72cc9f94086dfee4 100644 (file)
@@ -28,6 +28,7 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using vkvg;
 
 namespace Crow
 {
@@ -57,18 +58,18 @@ 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;
@@ -78,7 +79,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 +97,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 +116,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/src/CrowApplication.cs b/src/CrowApplication.cs
new file mode 100644 (file)
index 0000000..3f7f8ad
--- /dev/null
@@ -0,0 +1,101 @@
+//
+// 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
+
+       }
+}
+
index 340a8ceb511eabb01fb80179d04e727132259755..3d9716f8e61f9e36b7201f70fcf82ed2f012fa14 100644 (file)
@@ -26,6 +26,7 @@
 
 using System;
 using System.Linq.Expressions;
+using vkvg;
 
 namespace Crow
 {
@@ -33,7 +34,7 @@ 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;
@@ -43,41 +44,41 @@ namespace Crow
                        }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));
@@ -104,17 +105,17 @@ namespace Crow
                        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);
@@ -136,13 +137,13 @@ namespace Crow
                        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));
@@ -153,9 +154,9 @@ namespace Crow
                        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)
                {
index d98e47cfe4a0a00e2065d1c133ebf1ba5c1f11b8..5e36832b05a07b14b2ab8c380b7400f45ed97f4f 100644 (file)
@@ -26,7 +26,7 @@
 
 using System;
 using System.Collections.Generic;
-using Cairo;
+using vkvg;
 
 namespace Crow
 {
index bab2c853059864dd702e237c4a4e1cf4f697c95c..e6782026b07108fca4cea177a4c32fd11ed5ea7c 100644 (file)
@@ -25,7 +25,7 @@
 // THE SOFTWARE.
 
 using System;
-using Cairo;
+using vkvg;
 
 namespace Crow
 {
index 0806e885b8aab9f24395cca6dbce0cffa709e7a3..cc69579588e7a53194dae7a5a65ced2cc36de5e5 100644 (file)
@@ -26,7 +26,7 @@
 
 using System;
 using System.Collections.Generic;
-using Cairo;
+using vkvg;
 
 namespace Crow
 {
@@ -99,7 +99,7 @@ namespace Crow
                        foreach (ColorStop cs in Stops)
                                grad.AddColorStop (cs.Offset, cs.Color);
                        
-                       ctx.SetSource (grad);
+                       //ctx.SetSource (grad);
                        grad.Dispose ();
                }
                #endregion
index adeb32e70a9903abbc784cfce03af5b9cfe6a435..2c11d1dbf3ff88d177519ab66ba3114414cb7bbf 100644 (file)
@@ -28,7 +28,7 @@ using System;
 using System.Xml.Serialization;
 using System.ComponentModel;
 using System.Diagnostics;
-using Cairo;
+using vkvg;
 
 namespace Crow
 {
index 8b60dcb9269bd85fa005172cffb69d109f7c6467..43d03a02619b3a4df712a5e8348ca01abad71441 100644 (file)
@@ -33,7 +33,7 @@ using System.Text;
 using System.Diagnostics;
 
 using System.Xml.Serialization;
-using Cairo;
+using vkvg;
 using System.ComponentModel;
 
 namespace Crow
index ae8b9c89093a9fec17bba8be91606f602c2726e7..7cb4fe2acb11725468288956774cc51b8cf741dc 100644 (file)
@@ -25,6 +25,7 @@
 // THE SOFTWARE.
 using System;
 using Crow.IML;
+using vkvg;
 
 namespace Crow
 {
@@ -82,7 +83,7 @@ namespace Crow
 //             }
 
                Rectangle rIn = default(Rectangle);
-               double dockThresh = 0.2;
+               double dockThresh = 0.2f;
                GraphicObject focusedChild;
                internal GraphicObject stretchedChild;
 
@@ -178,7 +179,7 @@ namespace Crow
                        RegisterForGraphicUpdate ();
                }
 
-               protected override void onDraw (Cairo.Context gr)
+               protected override void onDraw (Context gr)
                {
                        gr.Save ();
 
@@ -237,9 +238,9 @@ namespace Crow
                                        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 ();  
index e1d4dd46e8a45f872811842542f1ea6d477b0801..932378ba84a963fa4e1a2568e1cd95b2ea5ea791 100644 (file)
@@ -28,7 +28,7 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
-using Cairo;
+using vkvg;
 using System.Xml.Serialization;
 
 namespace Crow
index bc955368194a78cd5b9eef983216a730d65e4fcb..07954a632ab8e80680ae74433998364b6b1bf081 100644 (file)
@@ -31,7 +31,7 @@ using System.Xml.Serialization;
 using System.Reflection;
 using System.Reflection.Emit;
 using System.Runtime.CompilerServices;
-using Cairo;
+using vkvg;
 using System.Diagnostics;
 using Crow.IML;
 using System.Threading;
@@ -127,10 +127,10 @@ namespace Crow
                        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);
@@ -206,7 +206,7 @@ namespace Crow
                /// 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>
@@ -233,7 +233,7 @@ namespace Crow
                /// action.
                /// </summary>
                protected GraphicObject () {
-                       Clipping = new Region ();
+                       Clipping = new Cairo.Region();
                        #if DEBUG
                        uid = currentUid;
                        currentUid++;
@@ -1628,9 +1628,9 @@ namespace Crow
                        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 ();
@@ -1650,7 +1650,7 @@ namespace Crow
                        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>
@@ -1692,7 +1692,7 @@ namespace Crow
                }
                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;
index a90947a56cedcce61bca0d052d24cd39c9fbd7b3..2d64fde1526389129b051e99130b2803650708fd 100644 (file)
@@ -28,7 +28,7 @@ using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Xml.Serialization;
-using Cairo;
+using vkvg;
 using System.Diagnostics;
 using System.Reflection;
 using System.Threading;
@@ -332,7 +332,7 @@ namespace Crow
                                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);
                                }
@@ -349,7 +349,7 @@ namespace Crow
                        ctx.Paint ();
 
                        Clipping.Dispose();
-                       Clipping = new Region ();
+                       Clipping = new Cairo.Region();
                }
                #endregion
 
index 67f4ec6ee0b8a0c0381e4f97aec02c1a274a72e6..ad33243d038d358286ce717d63f658036bcc4571 100644 (file)
@@ -27,7 +27,7 @@
 using System;
 using System.Xml.Serialization;
 using System.ComponentModel;
-using Cairo;
+using vkvg;
 
 namespace Crow
 {
index e83183c003c34ee423b6279791e052b3aa2896da..dd383fc80c4184771ec4497d8901c068dc523a60 100644 (file)
@@ -25,7 +25,7 @@
 // THE SOFTWARE.
 
 using System;
-using Cairo;
+using vkvg;
 using System.Xml.Serialization;
 using System.ComponentModel;
 using System.Diagnostics;
@@ -43,7 +43,7 @@ namespace Crow
                Picture _pic;
                string _svgSub;
                bool scaled, keepProps;
-               double opacity;
+               float opacity;
 
                #region Public properties
                /// <summary>
@@ -138,7 +138,7 @@ namespace Crow
                /// </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)
@@ -203,7 +203,7 @@ namespace Crow
                        _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 ();
index 0e0d9fe19ee0262ad4711e2740372cd54263826c..da332d02e4574a0055ded6f24efbf8ec654334d6 100644 (file)
@@ -28,7 +28,7 @@ using System;
 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;
@@ -447,14 +447,17 @@ namespace Crow
                        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 ();
@@ -476,7 +479,7 @@ namespace Crow
                                                        return -1;
                                                }                                       
                                        }
-                               }
+                               //}
 
                        }
                        return lt == LayoutingType.Height ? cachedTextSize.Height : cachedTextSize.Width;
@@ -485,10 +488,11 @@ namespace Crow
                {
                        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)));
index d66372475240fbacfb659e84be0946d95178e8be..45aae6c14591ba44ee5555a5ee9b36fc0a8e2eab 100644 (file)
@@ -27,7 +27,7 @@
 using System;
 using System.Xml.Serialization;
 using System.ComponentModel;
-using Cairo;
+using vkvg;
 
 namespace Crow
 {
@@ -211,7 +211,7 @@ namespace Crow
                        ctx.SetSourceSurface (bmp, rb.X, rb.Y);
                        ctx.Paint ();
                        Clipping.Dispose();
-                       Clipping = new Region ();
+                       Clipping = new Cairo.Region();
                }
                #endregion
 
index e8165fd2e19f239400529df671a9164a2615e5d4..d86e6b38fc73ef2f0dc4608914858c603e189e04 100644 (file)
@@ -28,7 +28,7 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
-using Cairo;
+using vkvg;
 using System.Diagnostics;
 using System.Xml.Serialization;
 using System.ComponentModel;
index 485a33d2e027615e971bc4da3f22fecba21bfc36..e7da3ab7fd6f8746b22e48abd6f05a33163efb03 100644 (file)
@@ -25,7 +25,7 @@
 // THE SOFTWARE.
 
 using System;
-using Cairo;
+using vkvg;
 using System.Xml.Serialization;
 
 namespace Crow
index 30dd14800c2d4a05e15d2ae4760c5bba90611c3e..72252c70a4889ba8cca8086430fecad539651d98 100644 (file)
@@ -28,7 +28,7 @@ using System;
 using System.Xml.Serialization;
 using System.ComponentModel;
 using System.Diagnostics;
-using Cairo;
+using vkvg;
 
 namespace Crow
 {
index de4b21132df992f567ab7c1a3001718f8618921e..893fe4668f095d057516effe0436145179474525 100644 (file)
@@ -28,7 +28,7 @@ using System;
 using System.Xml.Serialization;
 using System.ComponentModel;
 using System.Collections;
-using Cairo;
+using vkvg;
 
 
 namespace Crow
index a4b3193e8eb54f8e1048740dd2cdf197e805e56f..77345b31794b1ad773505808921920e99be28565 100644 (file)
@@ -28,7 +28,7 @@ using System.Xml.Serialization;
 using System.ComponentModel;
 using System.IO;
 using System.Text;
-using Cairo;
+using vkvg;
 
 namespace Crow
 {
@@ -62,7 +62,7 @@ namespace Crow
                #endregion
 
                string path;
-               double strokeWidth;
+               float strokeWidth;
 
                public string Path {
                        get { return path; }
@@ -76,7 +76,7 @@ namespace Crow
                        }
                }
                [XmlAttributeAttribute][DefaultValue(1.0)]
-               public double StokeWidth {
+               public float StokeWidth {
                        get { return strokeWidth; }
                        set {
                                if (strokeWidth == value)
@@ -113,22 +113,22 @@ namespace Crow
                                                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 ();
@@ -145,20 +145,20 @@ namespace Crow
                                }
                        }
                }
-               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;
+//             }
        }
 }
 
index 2bdd5b8ab0c2c8e5693ea39f30384152e19464e8..33915a266618f954fbe6856a0dfecf5e3fa698a9 100644 (file)
@@ -25,7 +25,7 @@
 // THE SOFTWARE.
 
 using System;
-using Cairo;
+using vkvg;
 using System.Xml.Serialization;
 using System.ComponentModel;
 using System.Diagnostics;
index 473fc313e4c11dd59c0fb37313a914e7745ca218..37a33ac03cb06b37b9cff448cf86dce86a82ebc1 100644 (file)
@@ -28,7 +28,7 @@ using System;
 using System.Xml.Serialization;
 using System.ComponentModel;
 using System.Diagnostics;
-using Cairo;
+using vkvg;
 using System.Linq;
 
 namespace Crow
@@ -159,29 +159,29 @@ 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 {
index 304e820d8065224048978e9f422a58ed6cfea4a4..339f707cad77ddf9b5969d2aade82f1105d592dd 100644 (file)
@@ -27,7 +27,7 @@
 using System;
 using System.Xml.Serialization;
 using System.ComponentModel;
-using Cairo;
+using vkvg;
 using System.Diagnostics;
 using System.Linq;
 
index 54991a415960e24b1e85080c36cfdb12302f49f4..d51268ed4ea3d2c4b5c7b11572af751c8967f93a 100644 (file)
@@ -34,7 +34,7 @@ using System.Linq;
 using System.Collections.Generic;
 using System.Text;
 using System.Reflection;
-using Cairo;
+using vkvg;
 
 namespace Crow
 {
index e29ff9bf44c81157fa800e2a05a0ba9a0fcddd23..7bfa62e0b19f07e9ac63987147f9b24b48d9e47a 100644 (file)
@@ -25,7 +25,7 @@
 // THE SOFTWARE.
 
 using System;
-using Cairo;
+using vkvg;
 using System.Diagnostics;
 using System.Xml.Serialization;
 
index 17e3b7701f871e3e30cf552d086a545300bef08a..1f0bb271af91c26be85ebc94a182e5869a2bbb7a 100644 (file)
@@ -29,7 +29,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Diagnostics;
-using Cairo;
+using vkvg;
 using System.Text.RegularExpressions;
 using System.Xml.Serialization;
 using System.ComponentModel;
@@ -259,7 +259,7 @@ namespace Crow
                                }
                        }
 
-                       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;
index e9d3c2d3d08a84631abe51b958417388308c317e..d1a835eb21fbff6a65850750d787210d4aa4ac92 100644 (file)
@@ -28,7 +28,7 @@ using System;
 using System.Collections.Generic;
 using System.Xml.Serialization;
 using System.ComponentModel;
-using Cairo;
+using vkvg;
 
 namespace Crow
 {
@@ -156,7 +156,7 @@ 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);
 
 
 
@@ -175,7 +175,7 @@ namespace Crow
                        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);
index cc62a1aa82f02518d51d010d22c2c672802e58e6..f9821b73b6ca97eb434d95ac21f966cafe30255c 100644 (file)
@@ -33,7 +33,7 @@ using System.Reflection;
 using System.Threading;
 using System.Xml;
 using System.Xml.Serialization;
-using Cairo;
+using vkvg;
 using System.Globalization;
 using Crow.IML;
 
@@ -83,19 +83,21 @@ namespace Crow
                        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
 
@@ -104,8 +106,8 @@ namespace Crow
                        loadCursors ();
                        loadStyling ();
                        findAvailableTemplates ();
-                       initTooltip ();
-                       initContextMenus ();
+                       //initTooltip ();
+                       //initContextMenus ();
                }
 
                #region Static and constants
@@ -139,9 +141,9 @@ namespace Crow
                /// 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,
@@ -181,11 +183,6 @@ namespace Crow
                #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;
@@ -231,11 +228,11 @@ namespace Crow
                /// <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
@@ -643,8 +640,7 @@ namespace Crow
                        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) {
 
@@ -660,7 +656,7 @@ namespace Crow
                                                        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 ();
@@ -676,7 +672,7 @@ namespace Crow
                                                                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;
@@ -687,6 +683,7 @@ namespace Crow
                                                #if DEBUG_CLIP_RECTANGLE
                                                clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5));
                                                #endif
+                                       /*
                                                lock (RenderMutex) {
 //                                                     Array.Copy (bmp, dirtyBmp, bmp.Length);
 
@@ -714,11 +711,12 @@ namespace Crow
                                                        } else
                                                                IsDirty = false;
                                                }
+                                               */
                                                clipping.Dispose ();
-                                               clipping = new Region ();
+                                               clipping = new Cairo.Region();
                                        }
                                        //surf.WriteToPng (@"/mnt/data/test.png");
-                               }
+
                        }
                        #if MEASURE_TIME
                        drawingMeasure.StopCycle();
@@ -840,10 +838,10 @@ namespace Crow
                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);
index 030089e882b81bbbc6e8e7ff33872413d5e86a72..4d76565fef778f645353f5ff5163eaa90d1b0858 100644 (file)
@@ -1,5 +1,5 @@
 //
-// Mono.Cairo.Context.cs
+// Mono.Context.cs
 //
 // Author:
 //   Duncan Mak (duncan@ximian.com)
index 264774dd49922bdbe6684e837521407ec7601d51..120a661fe6271f1a18b5c4d88da83b193e4be8bd 100644 (file)
@@ -1,5 +1,5 @@
 //
-// 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) {}
index 7cba3729ceae93fbcf228d46a307b9ae3adcbe70..68300e9d383f5447ac23a8a0d1c3988c663535e9 100644 (file)
@@ -1,5 +1,5 @@
 //
-// Mono.Cairo.Context.cs
+// Mono.Context.cs
 //
 // Author:
 //   Duncan Mak (duncan@ximian.com)
index 535013699587ee9d5c7a61f9914d3d7b19966f32..7237f061a5270b24258e835bf47bc1b201ba3a72 100644 (file)
@@ -548,7 +548,7 @@ namespace Cairo
                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);
index 184c606cf3470b851e09c0c51de29ea8f7972d95..6807f38dad183b78e2f0dc39106e9f7ef20bbab1 100644 (file)
@@ -1,5 +1,5 @@
 //
-// Mono.Cairo.Context.cs
+// Mono.Context.cs
 //
 // Author:
 //   Miguel de Icaza (miguel@novell.com)
@@ -30,7 +30,7 @@
 
 using System;
 using System.Runtime.InteropServices;
-using Cairo;
+using vkvg;
 
 namespace Cairo {
 
index e72ca6c529ce690000e7b403b0bfeccfaaf108df..d21abdc29253b64f93413a2f038fc2d37e884464 100644 (file)
@@ -1,5 +1,5 @@
 //
-// Mono.Cairo.Context.cs
+// Mono.Context.cs
 //
 // Author:
 //   Duncan Mak (duncan@ximian.com)
index c2e3587d1f78ff10c394a54fab5881e692c9500d..8c2b2e022402bdfd26391fe2145724e76ebe9cea 100644 (file)
@@ -1,5 +1,5 @@
 //
-// Mono.Cairo.Context.cs
+// Mono.Context.cs
 //
 // Author:
 //   Duncan Mak (duncan@ximian.com)
index 4a82842ae5c05743f13c7fca1029cd5539dda311..937457d17d93ef8a9348d939c2fd78e3a76e03ae 100644 (file)
@@ -138,7 +138,7 @@ namespace Cairo
                        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);
                }
index 3784780b812dbcae8def3491e482634dc238fc46..81069f315faec9c5ba3db5f1ff9a26a9b4e02701 100644 (file)
@@ -26,7 +26,7 @@
 
 using System;
 using System.IO;
-using Cairo;
+using vkvg;
 using System.Collections.Generic;
 
 namespace Crow
index 6175efc7b71bbaeab0bb34e1def84d6cd9fc8d09..cc486ac897c8386a2c49d5ffae836ba4303142c8 100644 (file)
@@ -62,9 +62,9 @@ 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)
         {
index d6423d318ad8259bd60a026f6dbc03abd66409bc..4cb212b155a4a11f165ed7a8b84d5c00ead1891a 100644 (file)
@@ -31,7 +31,7 @@ using System.Text;
 using System.Xml.Serialization;
 using System.Reflection;
 using System.Diagnostics;
-using Cairo;
+using vkvg;
 
 
 
@@ -51,7 +51,7 @@ namespace Crow
 
                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)
                {
index f676a4975d3796be9b280a4cca519415df4695eb..1e03010d72064b32381b2db590c9b3cf2df4be39 100644 (file)
@@ -26,7 +26,7 @@
 
 using System;
 using System.IO;
-using Cairo;
+using vkvg;
 
 namespace Crow
 {
@@ -95,16 +95,16 @@ 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
 
index e13f79ad57f4ae65d5625272f93326b171e97d54..46a907c1cd2c2fc8ee0a69fc26d4e235c8c6e564 100644 (file)
@@ -1,5 +1,5 @@
 //Copyright GPL2
-using Cairo;
+using vkvg;
 
 
 namespace Rsvg {
@@ -108,7 +108,7 @@ 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);
                }
 
diff --git a/vkEngine/VkEngine.cs b/vkEngine/VkEngine.cs
new file mode 100644 (file)
index 0000000..d4a43c5
--- /dev/null
@@ -0,0 +1,156 @@
+//
+// 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
+       }
+}
+
diff --git a/vkEngine/enums.cs b/vkEngine/enums.cs
new file mode 100644 (file)
index 0000000..549d440
--- /dev/null
@@ -0,0 +1,203 @@
+//
+// 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,
+       }
+}
+
diff --git a/vkh/Device.cs b/vkh/Device.cs
new file mode 100644 (file)
index 0000000..83a9917
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// 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
+       }
+}
+
diff --git a/vkh/NativeMethods.cs b/vkh/NativeMethods.cs
new file mode 100644 (file)
index 0000000..e18d4f8
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// 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
+       }
+}
+
diff --git a/vkh/enums.cs b/vkh/enums.cs
new file mode 100644 (file)
index 0000000..2d7b23c
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// 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;
+       }
+}
+
diff --git a/vkvg/Context.cs b/vkvg/Context.cs
new file mode 100644 (file)
index 0000000..029bd42
--- /dev/null
@@ -0,0 +1,243 @@
+//
+// 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
+       }
+}
+
diff --git a/vkvg/Device.cs b/vkvg/Device.cs
new file mode 100644 (file)
index 0000000..09eca7a
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// 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
+       }
+}
+
diff --git a/vkvg/Enums.cs b/vkvg/Enums.cs
new file mode 100644 (file)
index 0000000..499ad13
--- /dev/null
@@ -0,0 +1,61 @@
+//
+// 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,
+       }
+}
+
diff --git a/vkvg/FontExtents.cs b/vkvg/FontExtents.cs
new file mode 100644 (file)
index 0000000..c7f793d
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// 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);
+               }
+       }
+}
diff --git a/vkvg/NativeMethods.cs b/vkvg/NativeMethods.cs
new file mode 100644 (file)
index 0000000..1cd3854
--- /dev/null
@@ -0,0 +1,137 @@
+//
+// 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
+       }
+}
+
diff --git a/vkvg/PointD.cs b/vkvg/PointD.cs
new file mode 100644 (file)
index 0000000..a36f817
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// 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; }
+               }
+       }
+}
diff --git a/vkvg/Surface.cs b/vkvg/Surface.cs
new file mode 100644 (file)
index 0000000..f8595c2
--- /dev/null
@@ -0,0 +1,90 @@
+//
+// 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
+       }
+}
+
diff --git a/vkvg/TextExtents.cs b/vkvg/TextExtents.cs
new file mode 100644 (file)
index 0000000..2305d9a
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// 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);
+               }
+       }
+}