<Compile Include="src\PerformanceMeasure.cs" />
<Compile Include="src\IML\BindingMember.cs" />
<Compile Include="src\CrowThread.cs" />
+ <Compile Include="src\Mono.Cairo\Antialias.cs" />
+ <Compile Include="src\Mono.Cairo\Cairo.cs" />
+ <Compile Include="src\Mono.Cairo\CairoDebug.cs" />
+ <Compile Include="src\Mono.Cairo\Color.cs" />
+ <Compile Include="src\Mono.Cairo\Content.cs" />
+ <Compile Include="src\Mono.Cairo\Context.cs" />
+ <Compile Include="src\Mono.Cairo\Device.cs" />
+ <Compile Include="src\Mono.Cairo\DirectFBSurface.cs" />
+ <Compile Include="src\Mono.Cairo\Distance.cs" />
+ <Compile Include="src\Mono.Cairo\EGLDevice.cs" />
+ <Compile Include="src\Mono.Cairo\Extend.cs" />
+ <Compile Include="src\Mono.Cairo\FillRule.cs" />
+ <Compile Include="src\Mono.Cairo\Filter.cs" />
+ <Compile Include="src\Mono.Cairo\FontExtents.cs" />
+ <Compile Include="src\Mono.Cairo\FontFace.cs" />
+ <Compile Include="src\Mono.Cairo\FontOptions.cs" />
+ <Compile Include="src\Mono.Cairo\FontSlant.cs" />
+ <Compile Include="src\Mono.Cairo\FontType.cs" />
+ <Compile Include="src\Mono.Cairo\FontWeight.cs" />
+ <Compile Include="src\Mono.Cairo\Format.cs" />
+ <Compile Include="src\Mono.Cairo\GlitzSurface.cs" />
+ <Compile Include="src\Mono.Cairo\GLSurface.cs" />
+ <Compile Include="src\Mono.Cairo\GLXDevice.cs" />
+ <Compile Include="src\Mono.Cairo\Glyph.cs" />
+ <Compile Include="src\Mono.Cairo\Gradient.cs" />
+ <Compile Include="src\Mono.Cairo\HintMetrics.cs" />
+ <Compile Include="src\Mono.Cairo\HintStyle.cs" />
+ <Compile Include="src\Mono.Cairo\ImageSurface.cs" />
+ <Compile Include="src\Mono.Cairo\LinearGradient.cs" />
+ <Compile Include="src\Mono.Cairo\LineCap.cs" />
+ <Compile Include="src\Mono.Cairo\LineJoin.cs" />
+ <Compile Include="src\Mono.Cairo\Matrix.cs" />
+ <Compile Include="src\Mono.Cairo\NativeMethods.cs" />
+ <Compile Include="src\Mono.Cairo\Operator.cs" />
+ <Compile Include="src\Mono.Cairo\Path.cs" />
+ <Compile Include="src\Mono.Cairo\Pattern.cs" />
+ <Compile Include="src\Mono.Cairo\PatternType.cs" />
+ <Compile Include="src\Mono.Cairo\PdfSurface.cs" />
+ <Compile Include="src\Mono.Cairo\Point.cs" />
+ <Compile Include="src\Mono.Cairo\PointD.cs" />
+ <Compile Include="src\Mono.Cairo\PSSurface.cs" />
+ <Compile Include="src\Mono.Cairo\RadialGradient.cs" />
+ <Compile Include="src\Mono.Cairo\Rectangle.cs" />
+ <Compile Include="src\Mono.Cairo\Region.cs" />
+ <Compile Include="src\Mono.Cairo\ScaledFont.cs" />
+ <Compile Include="src\Mono.Cairo\SolidPattern.cs" />
+ <Compile Include="src\Mono.Cairo\Status.cs" />
+ <Compile Include="src\Mono.Cairo\SubpixelOrder.cs" />
+ <Compile Include="src\Mono.Cairo\Surface.cs" />
+ <Compile Include="src\Mono.Cairo\SurfacePattern.cs" />
+ <Compile Include="src\Mono.Cairo\SurfaceType.cs" />
+ <Compile Include="src\Mono.Cairo\SvgSurface.cs" />
+ <Compile Include="src\Mono.Cairo\SvgVersion.cs" />
+ <Compile Include="src\Mono.Cairo\TextExtents.cs" />
+ <Compile Include="src\Mono.Cairo\WGLDevice.cs" />
+ <Compile Include="src\Mono.Cairo\Win32Surface.cs" />
+ <Compile Include="src\Mono.Cairo\XcbSurface.cs" />
+ <Compile Include="src\Mono.Cairo\XlibSurface.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Drawing" />
- <Reference Include="cairo-sharp">
- <Package>gtk-sharp-3.0</Package>
- </Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
{4B57740A-75FB-4978-A8E8-8B1793B7474F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B57740A-75FB-4978-A8E8-8B1793B7474F}.Release|Any CPU.Build.0 = Release|Any CPU
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Any CPU.Build.0 = Release|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6D911CD-1D09-42FC-B300-9187190F2AE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B6D911CD-1D09-42FC-B300-9187190F2AE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6D911CD-1D09-42FC-B300-9187190F2AE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6D911CD-1D09-42FC-B300-9187190F2AE1}.Release|Any CPU.Build.0 = Release|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5));
#endif
lock (RenderMutex) {
- if (IsDirty)
- DirtyRect += clipping.Bounds;
- else
- DirtyRect = clipping.Bounds;
-
- DirtyRect.Left = Math.Max (0, DirtyRect.Left);
- DirtyRect.Top = Math.Max (0, DirtyRect.Top);
- DirtyRect.Width = Math.Min (ClientRectangle.Width - DirtyRect.Left, DirtyRect.Width);
- DirtyRect.Height = Math.Min (ClientRectangle.Height - DirtyRect.Top, DirtyRect.Height);
- DirtyRect.Width = Math.Max (0, DirtyRect.Width);
- DirtyRect.Height = Math.Max (0, DirtyRect.Height);
-
- if (DirtyRect.Width > 0 && DirtyRect.Height >0) {
- dirtyBmp = new byte[4 * DirtyRect.Width * DirtyRect.Height];
- for (int y = 0; y < DirtyRect.Height; y++) {
- Array.Copy (bmp,
- ((DirtyRect.Top + y) * ClientRectangle.Width * 4) + DirtyRect.Left * 4,
- dirtyBmp, y * DirtyRect.Width * 4, DirtyRect.Width * 4);
- }
- IsDirty = true;
- } else
- IsDirty = false;
+ Array.Copy (bmp, dirtyBmp, bmp.Length);
+ IsDirty = true;
+// if (IsDirty)
+// DirtyRect += clipping.Bounds;
+// else
+// DirtyRect = clipping.Bounds;
+//
+// DirtyRect.Left = Math.Max (0, DirtyRect.Left);
+// DirtyRect.Top = Math.Max (0, DirtyRect.Top);
+// DirtyRect.Width = Math.Min (ClientRectangle.Width - DirtyRect.Left, DirtyRect.Width);
+// DirtyRect.Height = Math.Min (ClientRectangle.Height - DirtyRect.Top, DirtyRect.Height);
+// DirtyRect.Width = Math.Max (0, DirtyRect.Width);
+// DirtyRect.Height = Math.Max (0, DirtyRect.Height);
+//
+// if (DirtyRect.Width > 0 && DirtyRect.Height >0) {
+// dirtyBmp = new byte[4 * DirtyRect.Width * DirtyRect.Height];
+// for (int y = 0; y < DirtyRect.Height; y++) {
+// Array.Copy (bmp,
+// ((DirtyRect.Top + y) * ClientRectangle.Width * 4) + DirtyRect.Left * 4,
+// dirtyBmp, y * DirtyRect.Width * 4, DirtyRect.Width * 4);
+// }
+//
+// } else
+// IsDirty = false;
}
clipping.Reset ();
}
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);
--- /dev/null
+//
+// Mono.Cairo.Antialias.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ [Serializable]
+ public enum Antialias
+ {
+ Default,
+ None,
+ Gray,
+ Subpixel,
+ }
+}
--- /dev/null
+//
+// Cairo.cs - a simplistic binding of the Cairo API to C#.
+//
+// Authors: Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// John Luke (john.luke@gmail.com)
+// Alp Toker (alp@atoker.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005 John Luke
+// Copyright (C) 2006 Alp Toker
+//
+// 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 Cairo
+{
+ public static class CairoAPI {
+ static public int Version {
+ get {
+ return Cairo.NativeMethods.cairo_version ();
+ }
+ }
+
+ static public string VersionString {
+ get {
+ IntPtr x = Cairo.NativeMethods.cairo_version_string ();
+ return Marshal.PtrToStringAnsi (x);
+ }
+ }
+ }
+}
--- /dev/null
+//
+// CairoDebug.cs
+//
+// Author:
+// Michael Hutchinson (mhutch@xamarin.com)
+//
+// Copyright (C) 2013 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ static class CairoDebug
+ {
+ static System.Collections.Generic.Dictionary<IntPtr,string> traces;
+
+ public static readonly bool Enabled;
+
+ static CairoDebug ()
+ {
+ var dbg = Environment.GetEnvironmentVariable ("MONO_CAIRO_DEBUG_DISPOSE");
+ if (dbg == null)
+ return;
+ Enabled = true;
+ traces = new System.Collections.Generic.Dictionary<IntPtr,string> ();
+ }
+
+ public static void OnAllocated (IntPtr obj)
+ {
+ if (!Enabled)
+ throw new InvalidOperationException ();
+
+ traces[obj] = Environment.StackTrace;
+ }
+
+ public static void OnDisposed<T> (IntPtr obj, bool disposing)
+ {
+ if (disposing && !Enabled)
+ throw new InvalidOperationException ();
+
+ if (Environment.HasShutdownStarted)
+ return;
+
+ if (!disposing) {
+ Console.Error.WriteLine ("{0} is leaking, programmer is missing a call to Dispose", typeof(T).FullName);
+ if (Enabled) {
+ string val;
+ if (traces.TryGetValue (obj, out val)) {
+ Console.Error.WriteLine ("Allocated from:");
+ Console.Error.WriteLine (val);
+ }
+ } else {
+ Console.Error.WriteLine ("Set MONO_CAIRO_DEBUG_DISPOSE to track allocation traces");
+ }
+ }
+
+ if (Enabled)
+ traces.Remove (obj);
+ }
+ }
+
+}
--- /dev/null
+//
+// Mono.Cairo.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 Cairo {
+
+ public struct Color
+ {
+ public Color(double r, double g, double b) : this (r, g, b, 1.0)
+ {
+ }
+
+ public Color(double r, double g, double b, double a)
+ {
+ this.r = r;
+ this.g = g;
+ this.b = b;
+ this.a = a;
+ }
+
+ double r, g, b, a;
+
+ public double R {
+ get { return r; }
+ set { r = value; }
+ }
+
+ public double G {
+ get { return g; }
+ set { g = value; }
+ }
+
+ public double B {
+ get { return b; }
+ set { b = value; }
+ }
+
+ public double A {
+ get { return a; }
+ set { a = value; }
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Content.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ //[Flags]
+ [Serializable]
+ public enum Content
+ {
+ Color = 0x1000,
+ Alpha = 0x2000,
+ ColorAlpha = 0x3000,
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.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.
+//
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using Cairo;
+
+namespace Cairo {
+
+ [Obsolete ("Renamed Cairo.Context per suggestion from cairo binding guidelines.")]
+ public class Graphics : Context {
+ public Graphics (IntPtr state) : base (state) {}
+ public Graphics (Surface surface) : base (surface) {}
+ }
+
+ public class Context : IDisposable
+ {
+ IntPtr handle = IntPtr.Zero;
+
+ static int native_glyph_size, c_compiler_long_size;
+
+ static Context ()
+ {
+ //
+ // This is used to determine what kind of structure
+ // we should use to marshal Glyphs, as the public
+ // definition in Cairo uses `long', which can be
+ // 32 bits or 64 bits depending on the platform.
+ //
+ // We assume that sizeof(long) == sizeof(void*)
+ // except in the case of Win64 where sizeof(long)
+ // is 32 bits
+ //
+ int ptr_size = Marshal.SizeOf (typeof (IntPtr));
+
+ PlatformID platform = Environment.OSVersion.Platform;
+ if (platform == PlatformID.Win32NT ||
+ platform == PlatformID.Win32S ||
+ platform == PlatformID.Win32Windows ||
+ platform == PlatformID.WinCE ||
+ ptr_size == 4){
+ c_compiler_long_size = 4;
+ native_glyph_size = Marshal.SizeOf (typeof (NativeGlyph_4byte_longs));
+ } else {
+ c_compiler_long_size = 8;
+ native_glyph_size = Marshal.SizeOf (typeof (Glyph));
+ }
+ }
+
+ public Context (Surface surface) : this (NativeMethods.cairo_create (surface.Handle), true)
+ {
+ }
+
+
+ public Context (IntPtr handle, bool owner)
+ {
+ this.handle = handle;
+ if (!owner)
+ NativeMethods.cairo_reference (handle);
+ if (CairoDebug.Enabled)
+ CairoDebug.OnAllocated (handle);
+ }
+
+ [Obsolete]
+ public Context (IntPtr state) : this (state, true)
+ {
+ }
+
+ ~Context ()
+ {
+ Dispose (false);
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (!disposing || CairoDebug.Enabled)
+ CairoDebug.OnDisposed<Context> (handle, disposing);
+
+ if (!disposing|| handle == IntPtr.Zero)
+ return;
+
+ NativeMethods.cairo_destroy (handle);
+ handle = IntPtr.Zero;
+
+ }
+
+ public void Save ()
+ {
+ NativeMethods.cairo_save (handle);
+ }
+
+ public void Restore ()
+ {
+ NativeMethods.cairo_restore (handle);
+ }
+
+ public Antialias Antialias {
+ get { return NativeMethods.cairo_get_antialias (handle); }
+ set { NativeMethods.cairo_set_antialias (handle, value); }
+ }
+
+ public Cairo.Status Status {
+ get {
+ return NativeMethods.cairo_status (handle);
+ }
+ }
+
+ public IntPtr Handle {
+ get {
+ return handle;
+ }
+ }
+
+ public Operator Operator {
+ set {
+ NativeMethods.cairo_set_operator (handle, value);
+ }
+
+ get {
+ return NativeMethods.cairo_get_operator (handle);
+ }
+ }
+
+ [Obsolete ("Use SetSourceColor method")]
+ public Color Color {
+ set {
+ SetSourceColor (value);
+ }
+ }
+
+ [Obsolete ("Use SetSourceRGBA method")]
+ public Cairo.Color ColorRgb {
+ set {
+ Color = new Color (value.R, value.G, value.B);
+ }
+ }
+
+ public double Tolerance {
+ get {
+ return NativeMethods.cairo_get_tolerance (handle);
+ }
+
+ set {
+ NativeMethods.cairo_set_tolerance (handle, value);
+ }
+ }
+
+ public Cairo.FillRule FillRule {
+ set {
+ NativeMethods.cairo_set_fill_rule (handle, value);
+ }
+
+ get {
+ return NativeMethods.cairo_get_fill_rule (handle);
+ }
+ }
+
+ public double LineWidth {
+ set {
+ NativeMethods.cairo_set_line_width (handle, value);
+ }
+
+ get {
+ return NativeMethods.cairo_get_line_width (handle);
+ }
+ }
+
+ public Cairo.LineCap LineCap {
+ set {
+ NativeMethods.cairo_set_line_cap (handle, value);
+ }
+
+ get {
+ return NativeMethods.cairo_get_line_cap (handle);
+ }
+ }
+
+ public Cairo.LineJoin LineJoin {
+ set {
+ NativeMethods.cairo_set_line_join (handle, value);
+ }
+
+ get {
+ return NativeMethods.cairo_get_line_join (handle);
+ }
+ }
+
+ public void SetDash (double [] dashes, double offset)
+ {
+ NativeMethods.cairo_set_dash (handle, dashes, dashes.Length, offset);
+ }
+
+ [Obsolete("Use GetSource/SetSource")]
+ public Pattern Pattern {
+ set {
+ SetSource (value);
+ }
+ get {
+ return GetSource ();
+ }
+ }
+
+ //This is obsolete because it wasn't obvious it needed to be disposed
+ [Obsolete("Use GetSource/SetSource")]
+ public Pattern Source {
+ set {
+ SetSource (value);
+ }
+ get {
+ return GetSource ();
+ }
+ }
+
+ public void SetSource (Pattern source)
+ {
+ NativeMethods.cairo_set_source (handle, source.Handle);
+ }
+
+ public Pattern GetSource ()
+ {
+ var ptr = NativeMethods.cairo_get_source (handle);
+ return Cairo.Pattern.Lookup (ptr, false);
+ }
+
+ public double MiterLimit {
+ set {
+ NativeMethods.cairo_set_miter_limit (handle, value);
+ }
+
+ get {
+ return NativeMethods.cairo_get_miter_limit (handle);
+ }
+ }
+
+ public PointD CurrentPoint {
+ get {
+ double x, y;
+ NativeMethods.cairo_get_current_point (handle, out x, out y);
+ return new PointD (x, y);
+ }
+ }
+
+ public bool HasCurrentPoint {
+ get {
+ return NativeMethods.cairo_has_current_point (handle);
+ }
+ }
+
+ [Obsolete ("Use GetTarget/SetTarget")]
+ public Cairo.Surface Target {
+ set {
+ if (handle != IntPtr.Zero)
+ NativeMethods.cairo_destroy (handle);
+
+ handle = NativeMethods.cairo_create (value.Handle);
+ }
+
+ get {
+ return GetTarget ();
+ }
+ }
+
+ public Surface GetTarget ()
+ {
+ return Surface.Lookup (NativeMethods.cairo_get_target (handle), false);
+ }
+
+ public void SetTarget (Surface target)
+ {
+ if (handle != IntPtr.Zero)
+ NativeMethods.cairo_destroy (handle);
+ handle = NativeMethods.cairo_create (target.Handle);
+ }
+
+ [Obsolete("Use GetScaledFont/SetScaledFont")]
+ public ScaledFont ScaledFont {
+ set {
+ SetScaledFont (value);
+ }
+
+ get {
+ return GetScaledFont ();
+ }
+ }
+
+ public ScaledFont GetScaledFont ()
+ {
+ return new ScaledFont (NativeMethods.cairo_get_scaled_font (handle), false);
+ }
+
+ public void SetScaledFont (ScaledFont font)
+ {
+ NativeMethods.cairo_set_scaled_font (handle, font.Handle);
+ }
+
+ public uint ReferenceCount {
+ get { return NativeMethods.cairo_get_reference_count (handle); }
+ }
+
+ public void SetSourceColor (Color color)
+ {
+ NativeMethods.cairo_set_source_rgba (handle, color.R, color.G, color.B, color.A);
+ }
+
+ public void SetSourceRGB (double r, double g, double b)
+ {
+ NativeMethods.cairo_set_source_rgb (handle, r, g, b);
+ }
+
+ public void SetSourceRGBA (double r, double g, double b, double a)
+ {
+ NativeMethods.cairo_set_source_rgba (handle, r, g, b, a);
+ }
+
+ //[Obsolete ("Use SetSource method (with double parameters)")]
+ public void SetSourceSurface (Surface source, int x, int y)
+ {
+ NativeMethods.cairo_set_source_surface (handle, source.Handle, x, y);
+ }
+
+ public void SetSource (Surface source, double x, double y)
+ {
+ NativeMethods.cairo_set_source_surface (handle, source.Handle, x, y);
+ }
+
+ public void SetSource (Surface source)
+ {
+ NativeMethods.cairo_set_source_surface (handle, source.Handle, 0, 0);
+ }
+
+#region Path methods
+
+ public void NewPath ()
+ {
+ NativeMethods.cairo_new_path (handle);
+ }
+
+ public void NewSubPath ()
+ {
+ NativeMethods.cairo_new_sub_path (handle);
+ }
+
+ public void MoveTo (PointD p)
+ {
+ MoveTo (p.X, p.Y);
+ }
+
+ public void MoveTo (double x, double y)
+ {
+ NativeMethods.cairo_move_to (handle, x, y);
+ }
+
+ public void LineTo (PointD p)
+ {
+ LineTo (p.X, p.Y);
+ }
+
+ public void LineTo (double x, double y)
+ {
+ NativeMethods.cairo_line_to (handle, x, y);
+ }
+
+ public void CurveTo (PointD p1, PointD p2, PointD p3)
+ {
+ CurveTo (p1.X, p1.Y, p2.X, p2.Y, p3.X, p3.Y);
+ }
+
+ public void CurveTo (double x1, double y1, double x2, double y2, double x3, double y3)
+ {
+ NativeMethods.cairo_curve_to (handle, x1, y1, x2, y2, x3, y3);
+ }
+
+ public void RelMoveTo (Distance d)
+ {
+ RelMoveTo (d.Dx, d.Dy);
+ }
+
+ public void RelMoveTo (double dx, double dy)
+ {
+ NativeMethods.cairo_rel_move_to (handle, dx, dy);
+ }
+
+ public void RelLineTo (Distance d)
+ {
+ RelLineTo (d.Dx, d.Dy);
+ }
+
+ public void RelLineTo (double dx, double dy)
+ {
+ NativeMethods.cairo_rel_line_to (handle, dx, dy);
+ }
+
+ public void RelCurveTo (Distance d1, Distance d2, Distance d3)
+ {
+ RelCurveTo (d1.Dx, d1.Dy, d2.Dx, d2.Dy, d3.Dx, d3.Dy);
+ }
+
+ public void RelCurveTo (double dx1, double dy1, double dx2, double dy2, double dx3, double dy3)
+ {
+ NativeMethods.cairo_rel_curve_to (handle, dx1, dy1, dx2, dy2, dx3, dy3);
+ }
+
+ public void Arc (double xc, double yc, double radius, double angle1, double angle2)
+ {
+ NativeMethods.cairo_arc (handle, xc, yc, radius, angle1, angle2);
+ }
+
+ public void ArcNegative (double xc, double yc, double radius, double angle1, double angle2)
+ {
+ NativeMethods.cairo_arc_negative (handle, xc, yc, radius, angle1, angle2);
+ }
+
+ public void Rectangle (Rectangle rectangle)
+ {
+ Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
+ }
+
+ public void Rectangle (PointD p, double width, double height)
+ {
+ Rectangle (p.X, p.Y, width, height);
+ }
+
+ public void Rectangle (double x, double y, double width, double height)
+ {
+ NativeMethods.cairo_rectangle (handle, x, y, width, height);
+ }
+
+ public void ClosePath ()
+ {
+ NativeMethods.cairo_close_path (handle);
+ }
+
+ public Path CopyPath ()
+ {
+ return new Path (NativeMethods.cairo_copy_path (handle));
+ }
+
+ public Path CopyPathFlat ()
+ {
+ return new Path (NativeMethods.cairo_copy_path_flat (handle));
+ }
+
+ public void AppendPath (Path path)
+ {
+ NativeMethods.cairo_append_path (handle, path.Handle);
+ }
+
+#endregion
+
+#region Painting Methods
+ public void Paint ()
+ {
+ NativeMethods.cairo_paint (handle);
+ }
+
+ public void PaintWithAlpha (double alpha)
+ {
+ NativeMethods.cairo_paint_with_alpha (handle, alpha);
+ }
+
+ public void Mask (Pattern pattern)
+ {
+ NativeMethods.cairo_mask (handle, pattern.Handle);
+ }
+
+ public void MaskSurface (Surface surface, double surface_x, double surface_y)
+ {
+ NativeMethods.cairo_mask_surface (handle, surface.Handle, surface_x, surface_y);
+ }
+
+ public void Stroke ()
+ {
+ NativeMethods.cairo_stroke (handle);
+ }
+
+ public void StrokePreserve ()
+ {
+ NativeMethods.cairo_stroke_preserve (handle);
+ }
+
+ public Rectangle StrokeExtents ()
+ {
+ double x1, y1, x2, y2;
+ NativeMethods.cairo_stroke_extents (handle, out x1, out y1, out x2, out y2);
+ return new Rectangle (x1, y1, x2 - x1, y2 - y1);
+ }
+
+ public void Fill ()
+ {
+ NativeMethods.cairo_fill (handle);
+ }
+
+ public Rectangle FillExtents ()
+ {
+ double x1, y1, x2, y2;
+ NativeMethods.cairo_fill_extents (handle, out x1, out y1, out x2, out y2);
+ return new Rectangle (x1, y1, x2 - x1, y2 - y1);
+ }
+
+ public void FillPreserve ()
+ {
+ NativeMethods.cairo_fill_preserve (handle);
+ }
+
+#endregion
+
+ public void Clip ()
+ {
+ NativeMethods.cairo_clip (handle);
+ }
+
+ public void ClipPreserve ()
+ {
+ NativeMethods.cairo_clip_preserve (handle);
+ }
+
+ public void ResetClip ()
+ {
+ NativeMethods.cairo_reset_clip (handle);
+ }
+
+ public bool InClip (double x, double y)
+ {
+ return NativeMethods.cairo_in_clip (handle, x, y);
+ }
+
+ public bool InStroke (double x, double y)
+ {
+ return NativeMethods.cairo_in_stroke (handle, x, y);
+ }
+
+ public bool InFill (double x, double y)
+ {
+ return NativeMethods.cairo_in_fill (handle, x, y);
+ }
+
+ public Pattern PopGroup ()
+ {
+ return Pattern.Lookup (NativeMethods.cairo_pop_group (handle), true);
+ }
+
+ public void PopGroupToSource ()
+ {
+ NativeMethods.cairo_pop_group_to_source (handle);
+ }
+
+ public void PushGroup ()
+ {
+ NativeMethods.cairo_push_group (handle);
+ }
+
+ public void PushGroup (Content content)
+ {
+ NativeMethods.cairo_push_group_with_content (handle, content);
+ }
+
+ [Obsolete ("Use GetGroupTarget()")]
+ public Surface GroupTarget {
+ get {
+ return GetGroupTarget ();
+ }
+ }
+
+ public Surface GetGroupTarget ()
+ {
+ IntPtr surface = NativeMethods.cairo_get_group_target (handle);
+ return Surface.Lookup (surface, false);
+ }
+
+ public void Rotate (double angle)
+ {
+ NativeMethods.cairo_rotate (handle, angle);
+ }
+
+ public void Scale (double sx, double sy)
+ {
+ NativeMethods.cairo_scale (handle, sx, sy);
+ }
+
+ public void Translate (double tx, double ty)
+ {
+ NativeMethods.cairo_translate (handle, tx, ty);
+ }
+
+ public void Transform (Matrix m)
+ {
+ NativeMethods.cairo_transform (handle, m);
+ }
+
+ [Obsolete("Use UserToDevice instead")]
+ public void TransformPoint (ref double x, ref double y)
+ {
+ NativeMethods.cairo_user_to_device (handle, ref x, ref y);
+ }
+
+ [Obsolete("Use UserToDeviceDistance instead")]
+ public void TransformDistance (ref double dx, ref double dy)
+ {
+ NativeMethods.cairo_user_to_device_distance (handle, ref dx, ref dy);
+ }
+
+ [Obsolete("Use InverseTransformPoint instead")]
+ public void InverseTransformPoint (ref double x, ref double y)
+ {
+ NativeMethods.cairo_device_to_user (handle, ref x, ref y);
+ }
+
+ [Obsolete("Use DeviceToUserDistance instead")]
+ public void InverseTransformDistance (ref double dx, ref double dy)
+ {
+ NativeMethods.cairo_device_to_user_distance (handle, ref dx, ref dy);
+ }
+
+ public void UserToDevice (ref double x, ref double y)
+ {
+ NativeMethods.cairo_user_to_device (handle, ref x, ref y);
+ }
+
+ public void UserToDeviceDistance (ref double dx, ref double dy)
+ {
+ NativeMethods.cairo_user_to_device_distance (handle, ref dx, ref dy);
+ }
+
+ public void DeviceToUser (ref double x, ref double y)
+ {
+ NativeMethods.cairo_device_to_user (handle, ref x, ref y);
+ }
+
+ public void DeviceToUserDistance (ref double dx, ref double dy)
+ {
+ NativeMethods.cairo_device_to_user_distance (handle, ref dx, ref dy);
+ }
+
+ public Matrix Matrix {
+ set {
+ NativeMethods.cairo_set_matrix (handle, value);
+ }
+
+ get {
+ Matrix m = new Matrix();
+ NativeMethods.cairo_get_matrix (handle, m);
+ return m;
+ }
+ }
+
+ public void SetFontSize (double scale)
+ {
+ NativeMethods.cairo_set_font_size (handle, scale);
+ }
+
+ public void IdentityMatrix ()
+ {
+ NativeMethods.cairo_identity_matrix (handle);
+ }
+
+ [Obsolete ("Use SetFontSize() instead.")]
+ public void FontSetSize (double scale)
+ {
+ SetFontSize (scale);
+ }
+
+ [Obsolete ("Use SetFontSize() instead.")]
+ public double FontSize {
+ set { SetFontSize (value); }
+ }
+
+ public Matrix FontMatrix {
+ get {
+ Matrix m;
+ NativeMethods.cairo_get_font_matrix (handle, out m);
+ return m;
+ }
+ set { NativeMethods.cairo_set_font_matrix (handle, value); }
+ }
+
+ public FontOptions FontOptions {
+ get {
+ FontOptions options = new FontOptions ();
+ NativeMethods.cairo_get_font_options (handle, options.Handle);
+ return options;
+ }
+ set { NativeMethods.cairo_set_font_options (handle, value.Handle); }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct NativeGlyph_4byte_longs {
+ public int index;
+ public double x;
+ public double y;
+
+ public NativeGlyph_4byte_longs (Glyph source)
+ {
+ index = (int) source.index;
+ x = source.x;
+ y = source.y;
+ }
+ }
+
+ static internal IntPtr FromGlyphToUnManagedMemory(Glyph [] glyphs)
+ {
+ IntPtr dest = Marshal.AllocHGlobal (native_glyph_size * glyphs.Length);
+ long pos = dest.ToInt64();
+
+ if (c_compiler_long_size == 8){
+ foreach (Glyph g in glyphs){
+ Marshal.StructureToPtr (g, (IntPtr)pos, false);
+ pos += native_glyph_size;
+ }
+ } else {
+ foreach (Glyph g in glyphs){
+ NativeGlyph_4byte_longs n = new NativeGlyph_4byte_longs (g);
+
+ Marshal.StructureToPtr (n, (IntPtr)pos, false);
+ pos += native_glyph_size;
+ }
+ }
+
+ return dest;
+ }
+
+ public void ShowGlyphs (Glyph[] glyphs)
+ {
+ IntPtr ptr;
+
+ ptr = FromGlyphToUnManagedMemory (glyphs);
+
+ NativeMethods.cairo_show_glyphs (handle, ptr, glyphs.Length);
+
+ Marshal.FreeHGlobal (ptr);
+ }
+
+ [Obsolete("The matrix argument was never used, use ShowGlyphs(Glyphs []) instead")]
+ public void ShowGlyphs (Matrix matrix, Glyph[] glyphs)
+ {
+ ShowGlyphs (glyphs);
+ }
+
+ [Obsolete("The matrix argument was never used, use GlyphPath(Glyphs []) instead")]
+ public void GlyphPath (Matrix matrix, Glyph[] glyphs)
+ {
+ GlyphPath (glyphs);
+ }
+
+ public void GlyphPath (Glyph[] glyphs)
+ {
+ IntPtr ptr;
+
+ ptr = FromGlyphToUnManagedMemory (glyphs);
+
+ NativeMethods.cairo_glyph_path (handle, ptr, glyphs.Length);
+
+ Marshal.FreeHGlobal (ptr);
+
+ }
+
+ public FontExtents FontExtents {
+ get {
+ FontExtents f_extents;
+ NativeMethods.cairo_font_extents (handle, out f_extents);
+ return f_extents;
+ }
+ }
+
+ public void CopyPage ()
+ {
+ NativeMethods.cairo_copy_page (handle);
+ }
+
+ [Obsolete ("Use SelectFontFace() instead.")]
+ public void FontFace (string family, FontSlant slant, FontWeight weight)
+ {
+ SelectFontFace (family, slant, weight);
+ }
+
+ [Obsolete("Use GetFontFace/SetFontFace")]
+ public FontFace ContextFontFace {
+ get {
+ return GetContextFontFace ();
+ }
+ set {
+ SetContextFontFace (value);
+ }
+ }
+
+ public FontFace GetContextFontFace ()
+ {
+ return Cairo.FontFace.Lookup (NativeMethods.cairo_get_font_face (handle), false);
+ }
+
+ public void SetContextFontFace (FontFace value)
+ {
+ NativeMethods.cairo_set_font_face (handle, value == null ? IntPtr.Zero : value.Handle);
+ }
+
+ public void SelectFontFace (string family, FontSlant slant, FontWeight weight)
+ {
+ NativeMethods.cairo_select_font_face (handle, family, slant, weight);
+ }
+
+ public void ShowPage ()
+ {
+ NativeMethods.cairo_show_page (handle);
+ }
+
+ private static byte[] TerminateUtf8(byte[] utf8)
+ {
+ if (utf8.Length > 0 && utf8[utf8.Length - 1] == 0)
+ return utf8;
+ var termedArray = new byte[utf8.Length + 1];
+ Array.Copy(utf8, termedArray, utf8.Length);
+ termedArray[utf8.Length] = 0;
+ return termedArray;
+ }
+
+ 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;
+ }
+
+ public void ShowText(string str)
+ {
+ NativeMethods.cairo_show_text (handle, TerminateUtf8(str));
+ }
+
+ public void ShowText(byte[] utf8)
+ {
+ NativeMethods.cairo_show_text (handle, TerminateUtf8(utf8));
+ }
+
+ public void TextPath(string str)
+ {
+ NativeMethods.cairo_text_path (handle, TerminateUtf8(str));
+ }
+
+ public void TextPath(byte[] utf8)
+ {
+ NativeMethods.cairo_text_path (handle, TerminateUtf8(utf8));
+ }
+
+ public TextExtents TextExtents(string s)
+ {
+ TextExtents extents;
+ NativeMethods.cairo_text_extents (handle, TerminateUtf8(s), out extents);
+ return extents;
+ }
+
+ public TextExtents TextExtents(byte[] utf8)
+ {
+ TextExtents extents;
+ NativeMethods.cairo_text_extents (handle, TerminateUtf8(utf8), out extents);
+ return extents;
+ }
+
+ public TextExtents GlyphExtents (Glyph[] glyphs)
+ {
+ IntPtr ptr = FromGlyphToUnManagedMemory (glyphs);
+
+ TextExtents extents;
+
+ NativeMethods.cairo_glyph_extents (handle, ptr, glyphs.Length, out extents);
+
+ Marshal.FreeHGlobal (ptr);
+
+ return extents;
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Device.cs
+//
+// Authors:
+// JP Bruyère (jp_bruyere@hotmail.com)
+//
+// This is an OO wrapper API for the Cairo API
+//
+// Copyright (C) 2016 JP 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 Cairo
+{
+ public class Device : IDisposable
+ {
+ IntPtr handle = IntPtr.Zero;
+
+ protected Device()
+ {
+ }
+
+ protected Device (IntPtr ptr) : this (ptr, true)
+ {
+ }
+
+ protected Device (IntPtr handle, bool owner)
+ {
+ this.handle = handle;
+ if (!owner)
+ NativeMethods.cairo_device_reference (handle);
+ if (CairoDebug.Enabled)
+ CairoDebug.OnAllocated (handle);
+ }
+
+ ~Device ()
+ {
+ Dispose (false);
+ }
+
+ public IntPtr Handle {
+ get {
+ return handle;
+ }
+ }
+ public string Status {
+ get {
+ return System.Runtime.InteropServices.Marshal.PtrToStringAuto(NativeMethods.cairo_status_to_string (NativeMethods.cairo_device_status (handle)));
+ }
+ }
+ public void SetThreadAware (bool value){
+ NativeMethods.cairo_gl_device_set_thread_aware (handle, value ? 1 : 0);
+ }
+ public Status Acquire()
+ {
+ return NativeMethods.cairo_device_acquire (handle);
+ }
+ public void Release()
+ {
+ NativeMethods.cairo_device_release (handle);
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (!disposing || CairoDebug.Enabled)
+ CairoDebug.OnDisposed<Device> (handle, disposing);
+
+ if (!disposing || handle == IntPtr.Zero)
+ return;
+
+ NativeMethods.cairo_device_destroy (handle);
+ handle = IntPtr.Zero;
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.DirectFBSurface.cs
+//
+// Authors:
+// Alp Toker
+//
+// (C) Alp Toker, 2006.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+ public class DirectFBSurface : Surface
+ {
+ internal DirectFBSurface (IntPtr handle, bool owns) : base (handle, owns)
+ {
+ }
+
+ public DirectFBSurface (IntPtr dfb, IntPtr dfb_surface)
+ : base (NativeMethods.cairo_directfb_surface_create (dfb, dfb_surface), true)
+ {
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.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 Cairo {
+
+ public struct Distance
+ {
+ public Distance (double dx, double dy)
+ {
+ this.dx = dx;
+ this.dy = dy;
+ }
+
+ double dx, dy;
+ public double Dx {
+ get { return dx; }
+ set { dx = value; }
+ }
+
+ public double Dy {
+ get { return dy; }
+ set { dy = value; }
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Device.cs
+//
+// Authors:
+// JP Bruyère (jp_bruyere@hotmail.com)
+//
+// This is an OO wrapper API for the Cairo API
+//
+// Copyright (C) 2016 JP 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 Cairo
+{
+ public class EGLDevice : Device
+ {
+ public EGLDevice (IntPtr dpy, IntPtr gl_ctx) : base (NativeMethods.cairo_egl_device_create (dpy, gl_ctx), true)
+ {
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.Extend.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// John Luke (john.luke@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005 John Luke
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ [Serializable]
+ public enum Extend
+ {
+ None,
+ Repeat,
+ Reflect,
+ Pad,
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.FillRule.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ [Serializable]
+ public enum FillRule
+ {
+ Winding,
+ EvenOdd
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Filter.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ [Serializable]
+ public enum Filter
+ {
+ Fast,
+ Good,
+ Best,
+ Nearest,
+ Bilinear,
+ Gaussian,
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.FontExtents.cs
+//
+// Authors: Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+//
+// This is a simplistic binding of the Cairo API to C#. All functions
+// in cairo.h are transcribed into their C# equivelants
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Cairo
+{
+ [StructLayout (LayoutKind.Sequential)]
+ public struct FontExtents
+ {
+ double ascent;
+ double descent;
+ double height;
+ double maxXAdvance;
+ double maxYAdvance;
+
+ public double Ascent {
+ get { return ascent; }
+ set { ascent = value; }
+ }
+
+ public double Descent {
+ get { return descent; }
+ set { descent = value; }
+ }
+
+ public double Height {
+ get { return height; }
+ set { height = value; }
+ }
+
+ public double MaxXAdvance {
+ get { return maxXAdvance; }
+ set { maxXAdvance = value; }
+ }
+
+ public double MaxYAdvance {
+ get { return maxYAdvance; }
+ set { maxYAdvance = value; }
+ }
+
+ public FontExtents (double ascent, double descent, double height, double maxXAdvance, double maxYAdvance)
+ {
+ this.ascent = ascent;
+ this.descent = descent;
+ this.height = height;
+ this.maxXAdvance = maxXAdvance;
+ this.maxYAdvance = maxYAdvance;
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (obj is FontExtents)
+ return this == (FontExtents) obj;
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ return (int) Ascent ^ (int) Descent ^ (int) Height ^ (int) MaxXAdvance ^ (int) MaxYAdvance;
+ }
+
+ public static bool operator == (FontExtents extents, FontExtents other)
+ {
+ return extents.Ascent == other.Ascent && extents.Descent == other.Descent && extents.Height == other.Height && extents.MaxXAdvance == other.MaxXAdvance && extents.MaxYAdvance == other.MaxYAdvance;
+ }
+
+ public static bool operator != (FontExtents extents, FontExtents other)
+ {
+ return !(extents == other);
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.FontFace.cs
+//
+// Author:
+// Alp Toker (alp@atoker.com)
+// Miguel de Icaza (miguel@novell.com)
+//
+// (C) Ximian Inc, 2003.
+//
+// This is an OO wrapper API for the Cairo API.
+//
+// Copyright (C) 2004, 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace Cairo
+{
+ public class FontFace : IDisposable
+ {
+ IntPtr handle;
+
+ internal static FontFace Lookup (IntPtr handle, bool owner)
+ {
+ if (handle == IntPtr.Zero)
+ return null;
+ return new FontFace (handle, owner);
+ }
+
+ ~FontFace ()
+ {
+ Dispose (false);
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (!disposing || CairoDebug.Enabled)
+ CairoDebug.OnDisposed<FontFace> (handle, disposing);
+
+ if (!disposing|| handle == IntPtr.Zero)
+ return;
+
+ NativeMethods.cairo_font_face_destroy (handle);
+ handle = IntPtr.Zero;
+ }
+
+ [Obsolete]
+ public FontFace (IntPtr handle) : this (handle, true)
+ {
+ }
+
+ public FontFace (IntPtr handle, bool owned)
+ {
+ this.handle = handle;
+ if (!owned)
+ NativeMethods.cairo_font_face_reference (handle);
+ if (CairoDebug.Enabled)
+ CairoDebug.OnAllocated (handle);
+ }
+
+ public IntPtr Handle {
+ get {
+ return handle;
+ }
+ }
+
+ public Status Status {
+ get {
+ return NativeMethods.cairo_font_face_status (handle);
+ }
+ }
+
+ public FontType FontType {
+ get {
+ return NativeMethods.cairo_font_face_get_type (handle);
+ }
+ }
+
+ public uint ReferenceCount {
+ get { return NativeMethods.cairo_font_face_get_reference_count (handle); }
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.FontOptions.cs
+//
+// Author:
+// John Luke (john.luke@gmail.com)
+//
+// (C) John Luke 2005.
+//
+// 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 Cairo
+{
+ public class FontOptions : IDisposable
+ {
+ IntPtr handle;
+
+ public FontOptions () : this (NativeMethods.cairo_font_options_create ())
+ {
+ }
+
+ ~FontOptions ()
+ {
+ Dispose (false);
+ }
+
+ internal FontOptions (IntPtr handle)
+ {
+ this.handle = handle;
+ if (CairoDebug.Enabled)
+ CairoDebug.OnAllocated (handle);
+ }
+
+ public FontOptions Copy ()
+ {
+ return new FontOptions (NativeMethods.cairo_font_options_copy (handle));
+ }
+
+ [Obsolete ("Use Dispose()")]
+ public void Destroy ()
+ {
+ Dispose ();
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (!disposing || CairoDebug.Enabled)
+ CairoDebug.OnDisposed<FontOptions> (handle, disposing);
+
+ if (!disposing|| handle == IntPtr.Zero)
+ return;
+
+ NativeMethods.cairo_font_options_destroy (handle);
+ handle = IntPtr.Zero;
+ }
+
+ public static bool operator == (FontOptions options, FontOptions other)
+ {
+ return Equals (options, other);
+ }
+
+ public static bool operator != (FontOptions options, FontOptions other)
+ {
+ return !(options == other);
+ }
+
+ public override bool Equals (object other)
+ {
+ return Equals (other as FontOptions);
+ }
+
+ bool Equals (FontOptions options)
+ {
+ return options != null && NativeMethods.cairo_font_options_equal (Handle, options.Handle);
+ }
+
+ public IntPtr Handle {
+ get { return handle; }
+ }
+
+ public override int GetHashCode ()
+ {
+ return (int) NativeMethods.cairo_font_options_hash (handle);
+ }
+
+ public void Merge (FontOptions other)
+ {
+ if (other == null)
+ throw new ArgumentNullException ("other");
+ NativeMethods.cairo_font_options_merge (handle, other.Handle);
+ }
+
+ public Antialias Antialias {
+ get { return NativeMethods.cairo_font_options_get_antialias (handle); }
+ set { NativeMethods.cairo_font_options_set_antialias (handle, value); }
+ }
+
+ public HintMetrics HintMetrics {
+ get { return NativeMethods.cairo_font_options_get_hint_metrics (handle);}
+ set { NativeMethods.cairo_font_options_set_hint_metrics (handle, value); }
+ }
+
+ public HintStyle HintStyle {
+ get { return NativeMethods.cairo_font_options_get_hint_style (handle);}
+ set { NativeMethods.cairo_font_options_set_hint_style (handle, value); }
+ }
+
+ public Status Status {
+ get { return NativeMethods.cairo_font_options_status (handle); }
+ }
+
+ public SubpixelOrder SubpixelOrder {
+ get { return NativeMethods.cairo_font_options_get_subpixel_order (handle);}
+ set { NativeMethods.cairo_font_options_set_subpixel_order (handle, value); }
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.FontSlant.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ [Serializable]
+ public enum FontSlant
+ {
+ Normal,
+ Italic,
+ Oblique
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.FontType.cs
+//
+// Authors:
+// John Luke
+//
+// (C) John Luke, 2006.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ [Serializable]
+ public enum FontType
+ {
+ Toy,
+ FreeType,
+ Win32,
+ Atsui,
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.FontWeight.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ [Serializable]
+ public enum FontWeight
+ {
+ Normal,
+ Bold,
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Format.cs
+//
+// Authors: Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ [Serializable]
+ public enum Format
+ {
+ Argb32 = 0,
+ Rgb24 = 1,
+ A8 = 2,
+ A1 = 3,
+ Rgb16565 = 4,
+
+ //[Obsolete ("Use Argb32")]
+ ARGB32 = Argb32,
+ //[Obsolete ("Use Rgb24")]
+ RGB24 = Rgb24,
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.GLSurface.cs
+//
+// Authors:
+// JP Bruyère (jp_bruyere@hotmail.com)
+//
+// This is an OO wrapper API for the Cairo API
+//
+// Copyright (C) 2016 JP 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 Cairo {
+
+ public class GLSurface : Surface
+ {
+
+ public GLSurface (IntPtr ptr, bool own) : base (ptr, own)
+ {}
+
+ public GLSurface (Device device, Cairo.Content content, uint tex, int width, int height)
+ : base (NativeMethods.cairo_gl_surface_create_for_texture (device.Handle, (uint)content, tex, width, height), true)
+ {}
+
+ public GLSurface (EGLDevice device, IntPtr eglSurf, int width, int height)
+ : base (NativeMethods.cairo_gl_surface_create_for_egl (device.Handle, eglSurf, width, height), true)
+ {}
+
+ public GLSurface (GLXDevice device, IntPtr window, int width, int height)
+ : base (NativeMethods.cairo_gl_surface_create_for_window (device.Handle, window, width, height),true)
+ {}
+
+ public GLSurface (WGLDevice device, IntPtr hdc, int width, int height)
+ : base (NativeMethods.cairo_gl_surface_create_for_dc (device.Handle, hdc, width, height), true)
+ {}
+
+ public void SwapBuffers(){
+ NativeMethods.cairo_gl_surface_swapbuffers (this.Handle);
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Device.cs
+//
+// Authors:
+// JP Bruyère (jp_bruyere@hotmail.com)
+//
+// This is an OO wrapper API for the Cairo API
+//
+// Copyright (C) 2016 JP 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 Cairo
+{
+ public class GLXDevice : Device
+ {
+ public GLXDevice (IntPtr dpy, IntPtr gl_ctx) : base (NativeMethods.cairo_glx_device_create (dpy, gl_ctx), true)
+ {
+ }
+
+ public IntPtr Display {
+ get { return NativeMethods.cairo_glx_device_get_display (Handle); }
+ }
+
+ public IntPtr Context {
+ get { return NativeMethods.cairo_glx_device_get_context (Handle); }
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.GlitzSurface.cs
+//
+// Authors:
+// Alp Toker
+//
+// (C) Alp Toker, 2006.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+ public class GlitzSurface : Surface
+ {
+ internal GlitzSurface (IntPtr handle, bool owns) : base (handle, owns)
+ {
+ }
+
+ public GlitzSurface (IntPtr glitz_surface)
+ : base (NativeMethods.cairo_glitz_surface_create (glitz_surface), true)
+ {
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Glyph.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 Cairo
+{
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Glyph
+ {
+ internal long index;
+ internal double x;
+ internal double y;
+
+ public Glyph (long index, double x, double y)
+ {
+ this.index = index;
+ this.x = x;
+ this.y = y;
+ }
+
+ public long Index {
+ get { return index; }
+ set { index = value; }
+ }
+
+ public double X {
+ get { return x; }
+ set { x = value; }
+ }
+
+ public double Y {
+ get { return y; }
+ set { y = value; }
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (obj is Glyph)
+ return this == (Glyph)obj;
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ return (int) Index ^ (int) X ^ (int) Y;
+ }
+
+ internal static IntPtr GlyphsToIntPtr (Glyph[] glyphs)
+ {
+ int size = Marshal.SizeOf (glyphs[0]);
+ IntPtr dest = Marshal.AllocHGlobal (size * glyphs.Length);
+ long pos = dest.ToInt64 ();
+ for (int i = 0; i < glyphs.Length; i++, pos += size)
+ Marshal.StructureToPtr (glyphs[i], (IntPtr) pos, false);
+ return dest;
+ }
+
+ public static bool operator == (Glyph glyph, Glyph other)
+ {
+ return glyph.Index == other.Index && glyph.X == other.X && glyph.Y == other.Y;
+ }
+
+ public static bool operator != (Glyph glyph, Glyph other)
+ {
+ return !(glyph == other);
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Gradient.cs
+//
+// Author: Jordi Mas (jordi@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// (C) Ximian Inc, 2004.
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ public class Gradient : Pattern
+ {
+ protected Gradient (IntPtr handle, bool owned) : base (handle, owned)
+ {
+ }
+
+ [Obsolete]
+ protected Gradient ()
+ {
+ }
+
+ public int ColorStopCount {
+ get {
+ int cnt;
+ NativeMethods.cairo_pattern_get_color_stop_count (Handle, out cnt);
+ return cnt;
+ }
+ }
+
+ public Status AddColorStop (double offset, Color c)
+ {
+ NativeMethods.cairo_pattern_add_color_stop_rgba (Handle, offset, c.R, c.G, c.B, c.A);
+ return Status;
+ }
+
+ public Status AddColorStopRgb (double offset, Color c)
+ {
+ NativeMethods.cairo_pattern_add_color_stop_rgb (Handle, offset, c.R, c.G, c.B);
+ return Status;
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.HintMetrics.cs
+//
+// Authors: Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ [Serializable]
+ public enum HintMetrics
+ {
+ Default,
+ Off,
+ On,
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.HintStyle.cs
+//
+// Authors: Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ [Serializable]
+ public enum HintStyle
+ {
+ Default,
+ None,
+ Slight,
+ Medium,
+ Full,
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.ImageSurface.cs
+//
+// Authors:
+// Duncan Mak
+// Miguel de Icaza.
+//
+// (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.
+//
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Cairo {
+
+ public class ImageSurface : Surface
+ {
+ internal ImageSurface (IntPtr handle, bool owns) : base (handle, owns)
+ {
+ }
+
+ public ImageSurface (Format format, int width, int height)
+ : base (NativeMethods.cairo_image_surface_create (format, width, height), true)
+ {
+ }
+
+ [Obsolete ("Use ImageSurface (byte[] data, Cairo.Format format, int width, int height, int stride)")]
+ public ImageSurface (ref byte[] data, Cairo.Format format, int width, int height, int stride)
+ : this (data, format, width, height, stride)
+ {
+ }
+
+ public ImageSurface (byte[] data, Format format, int width, int height, int stride)
+ : base (NativeMethods.cairo_image_surface_create_for_data (data, format, width, height, stride), true)
+ {
+ }
+
+ public ImageSurface (IntPtr data, Format format, int width, int height, int stride)
+ : base (NativeMethods.cairo_image_surface_create_for_data (data, format, width, height, stride), true)
+ {
+ }
+
+ public ImageSurface (string filename)
+ : base (NativeMethods.cairo_image_surface_create_from_png (filename), true)
+ {
+ }
+
+ public int Width {
+ get { return NativeMethods.cairo_image_surface_get_width (Handle); }
+ }
+
+ public int Height {
+ get { return NativeMethods.cairo_image_surface_get_height (Handle); }
+ }
+
+ public byte[] Data {
+ get {
+ IntPtr ptr = NativeMethods.cairo_image_surface_get_data (Handle);
+ int length = Height * Stride;
+ byte[] data = new byte[length];
+ Marshal.Copy (ptr, data, 0, length);
+ return data;
+ }
+ }
+
+ public IntPtr DataPtr {
+ get {
+ return NativeMethods.cairo_image_surface_get_data (Handle);
+ }
+ }
+
+ public Format Format {
+ get { return NativeMethods.cairo_image_surface_get_format (Handle); }
+ }
+
+ public int Stride {
+ get { return NativeMethods.cairo_image_surface_get_stride (Handle); }
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.LineCap.cs
+//
+// Authors: Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ [Serializable]
+ public enum LineCap
+ {
+ Butt,
+ Round,
+ Square,
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.LineJoin.cs
+//
+// Authors: Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ [Serializable]
+ public enum LineJoin
+ {
+ Miter,
+ Round,
+ Bevel
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.LinearGradient.cs
+//
+// Author: Jordi Mas (jordi@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// (C) Ximian Inc, 2004.
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ public class LinearGradient : Gradient
+ {
+ internal LinearGradient (IntPtr handle, bool owned) : base (handle, owned)
+ {
+ }
+
+ public LinearGradient (double x0, double y0, double x1, double y1)
+ : base (NativeMethods.cairo_pattern_create_linear (x0, y0, x1, y1), true)
+ {
+ }
+
+ public PointD[] LinearPoints {
+ get {
+ double x0, y0, x1, y1;
+ PointD[] points = new PointD [2];
+
+ NativeMethods.cairo_pattern_get_linear_points (Handle, out x0, out y0, out x1, out y1);
+
+ points[0] = new PointD (x0, y0);
+ points[1] = new PointD (x1, y1);
+ return points;
+ }
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.Matrix.cs
+//
+// Author: Duncan Mak
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// Idan Gazit (idan@fastmail.fm)
+//
+// (C) Ximian Inc, 2003 - 2005.
+//
+// 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.
+//
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Cairo {
+
+ [StructLayout(LayoutKind.Sequential)]
+ public class Matrix : ICloneable
+ {
+ public double Xx;
+ public double Yx;
+ public double Xy;
+ public double Yy;
+ public double X0;
+ public double Y0;
+
+ public Matrix (double xx, double yx, double xy, double yy,
+ double x0, double y0)
+ {
+ this.Xx = xx; this.Yx = yx; this.Xy = xy;
+ this.Yy = yy; this.X0 = x0; this.Y0 = y0;
+ }
+
+ public Matrix ()
+ {
+ this.InitIdentity ();
+ }
+
+ public bool IsIdentity ()
+ {
+ return (this == new Matrix ());
+ }
+
+ public void InitIdentity ()
+ {
+ // this.Init(1,0,0,1,0,0);
+ NativeMethods.cairo_matrix_init_identity (this);
+ }
+
+ public void Init (double xx, double yx, double xy, double yy,
+ double x0, double y0)
+ {
+ this.Xx = xx; this.Yx = yx; this.Xy = xy;
+ this.Yy = yy; this.X0 = x0; this.Y0 = y0;
+ }
+
+ public void InitTranslate (double tx, double ty)
+ {
+ //this.Init (1, 0, 0, 1, tx, ty);
+ NativeMethods.cairo_matrix_init_translate (this, tx, ty);
+ }
+
+ public void Translate (double tx, double ty)
+ {
+ NativeMethods.cairo_matrix_translate (this, tx, ty);
+ }
+
+ public void InitScale (double sx, double sy)
+ {
+ //this.Init (sx, 0, 0, sy, 0, 0);
+ NativeMethods.cairo_matrix_init_scale (this, sx, sy);
+ }
+
+ public void Scale (double sx, double sy)
+ {
+ NativeMethods.cairo_matrix_scale (this, sx, sy);
+ }
+
+ public void InitRotate (double radians)
+ {
+ /*
+ double s, c;
+ s = Math.Sin (radians);
+ c = Math.Cos (radians);
+ this.Init (c, s, -s, c, 0, 0);
+ */
+ NativeMethods.cairo_matrix_init_rotate (this, radians);
+ }
+
+ public void Rotate (double radians)
+ {
+ NativeMethods.cairo_matrix_rotate (this, radians);
+ }
+
+ public Cairo.Status Invert ()
+ {
+ return NativeMethods.cairo_matrix_invert (this);
+ }
+
+ public void Multiply (Matrix b)
+ {
+ Matrix a = (Matrix) this.Clone ();
+ NativeMethods.cairo_matrix_multiply (this, a, b);
+ }
+
+ public static Matrix Multiply (Matrix a, Matrix b) {
+ Matrix result = new Matrix ();
+ NativeMethods.cairo_matrix_multiply (result, a, b);
+ return result;
+ }
+
+
+ public void TransformDistance (ref double dx, ref double dy)
+ {
+ NativeMethods.cairo_matrix_transform_distance (this, ref dx, ref dy);
+ }
+
+ public void TransformPoint (ref double x, ref double y)
+ {
+ NativeMethods.cairo_matrix_transform_point (this, ref x, ref y);
+ }
+
+ public override String ToString ()
+ {
+ String s = String.Format ("xx:{0:##0.0#} yx:{1:##0.0#} xy:{2:##0.0#} yy:{3:##0.0#} x0:{4:##0.0#} y0:{5:##0.0#}",
+ this.Xx, this.Yx, this.Xy, this.Yy, this.X0, this.Y0);
+ return s;
+ }
+
+ public static bool operator == (Matrix lhs, Matrix rhs)
+ {
+ return (lhs.Xx == rhs.Xx &&
+ lhs.Xy == rhs.Xy &&
+ lhs.Yx == rhs.Yx &&
+ lhs.Yy == rhs.Yy &&
+ lhs.X0 == rhs.X0 &&
+ lhs.Y0 == rhs.Y0 );
+ }
+
+ public static bool operator != (Matrix lhs, Matrix rhs)
+ {
+ return !(lhs==rhs);
+ }
+
+
+
+ public override bool Equals(object o)
+ {
+ if (! (o is Matrix))
+ return false;
+ else
+ return (this == (Matrix) o);
+ }
+
+ public override int GetHashCode()
+ {
+ return (int)this.Xx ^ (int)this.Xx>>32 ^
+ (int)this.Xy ^ (int)this.Xy>>32 ^
+ (int)this.Yx ^ (int)this.Yx>>32 ^
+ (int)this.Yy ^ (int)this.Yy>>32 ^
+ (int)this.X0 ^ (int)this.X0>>32 ^
+ (int)this.Y0 ^ (int)this.Y0>>32;
+ }
+
+ public object Clone()
+ {
+ return this.MemberwiseClone ();
+ }
+
+ }
+}
--- /dev/null
+//
+// Cairo.cs - a simplistic binding of the Cairo API to C#.
+//
+// Authors: Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// John Luke (john.luke@gmail.com)
+// Alp Toker (alp@atoker.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005 John Luke
+// Copyright (C) 2006 Alp Toker
+//
+// 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 Cairo
+{
+ // sort the functions like in the following page so it is easier to find what is missing
+ // http://cairographics.org/manual/index-all.html
+
+ internal static class NativeMethods
+ {
+#if MONOTOUCH
+ const string cairo = "__Internal";
+#else
+ const string cairo = "libcairo-2.dll";
+#endif
+
+ //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ //internal static extern void cairo_append_path (IntPtr cr, Path path);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_arc (IntPtr cr, double xc, double yc, double radius, double angle1, double angle2);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_arc_negative (IntPtr cr, double xc, double yc, double radius, double angle1, double angle2);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_atsui_font_face_create_for_atsu_font_id (IntPtr font_id);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_clip (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_clip_preserve (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_clip_extents (IntPtr cr, out double x1, out double y1, out double x2, out double y2);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_close_path (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_copy_page (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_copy_path (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_copy_path_flat (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_append_path (IntPtr cr, IntPtr path);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_create (IntPtr target);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_curve_to (IntPtr cr, double x1, double y1, double x2, double y2, double x3, double y3);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_debug_reset_static_data ();
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_destroy (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_device_to_user (IntPtr cr, ref double x, ref double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_device_to_user_distance (IntPtr cr, ref double dx, ref double dy);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_fill (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_fill_extents (IntPtr cr, out double x1, out double y1, out double x2, out double y2);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_fill_preserve (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_font_extents (IntPtr cr, out FontExtents extents);
+
+ // FontFace
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_font_face_destroy (IntPtr font_face);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern FontType cairo_font_face_get_type (IntPtr font_face);
+
+ //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ //internal static extern void cairo_font_face_get_user_data (IntPtr font_face);
+
+ //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ //internal static extern void cairo_font_face_set_user_data (IntPtr font_face);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_font_face_reference (IntPtr font_face);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_font_face_status (IntPtr font_face);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern uint cairo_font_face_get_reference_count (IntPtr surface);
+
+ // FontOptions
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_font_options_copy (IntPtr original);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_font_options_create ();
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_font_options_destroy (IntPtr options);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ [return: MarshalAs (UnmanagedType.U1)]
+ internal static extern bool cairo_font_options_equal (IntPtr options, IntPtr other);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Antialias cairo_font_options_get_antialias (IntPtr options);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern HintMetrics cairo_font_options_get_hint_metrics (IntPtr options);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern HintStyle cairo_font_options_get_hint_style (IntPtr options);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern SubpixelOrder cairo_font_options_get_subpixel_order (IntPtr options);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern long cairo_font_options_hash (IntPtr options);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_font_options_merge (IntPtr options, IntPtr other);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_font_options_set_antialias (IntPtr options, Antialias aa);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_font_options_set_hint_metrics (IntPtr options, HintMetrics metrics);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_font_options_set_hint_style (IntPtr options, HintStyle style);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_font_options_set_subpixel_order (IntPtr options, SubpixelOrder order);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_font_options_status (IntPtr options);
+
+ // Freetype / FontConfig
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_ft_font_face_create_for_ft_face (IntPtr face, int load_flags);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_ft_font_face_create_for_pattern (IntPtr fc_pattern);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_ft_font_options_substitute (FontOptions options, IntPtr pattern);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_ft_scaled_font_lock_face (IntPtr scaled_font);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_ft_scaled_font_unlock_face (IntPtr scaled_font);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Antialias cairo_get_antialias (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_get_current_point (IntPtr cr, out double x, out double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern FillRule cairo_get_fill_rule (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_get_font_face (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_get_font_matrix (IntPtr cr, out Matrix matrix);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_get_font_options (IntPtr cr, IntPtr options);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_get_group_target (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern LineCap cairo_get_line_cap (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern LineJoin cairo_get_line_join (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern double cairo_get_line_width (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_get_matrix (IntPtr cr, Matrix matrix);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern double cairo_get_miter_limit (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Operator cairo_get_operator (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern uint cairo_get_reference_count (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_get_source (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_get_target (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern double cairo_get_tolerance (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_glitz_surface_create (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_glyph_extents (IntPtr cr, IntPtr glyphs, int num_glyphs, out TextExtents extents);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_glyph_path (IntPtr cr, IntPtr glyphs, int num_glyphs);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ [return: MarshalAs (UnmanagedType.U1)]
+ internal static extern bool cairo_has_current_point (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_identity_matrix (IntPtr cr);
+
+ // ImageSurface
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_image_surface_create (Cairo.Format format, int width, int height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_image_surface_create_for_data (byte[] data, Cairo.Format format, int width, int height, int stride);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_image_surface_create_for_data (IntPtr data, Cairo.Format format, int width, int height, int stride);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_image_surface_create_from_png (string filename);
+
+ //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ //internal static extern IntPtr cairo_image_surface_create_from_png_stream (string filename);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_image_surface_get_data (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Format cairo_image_surface_get_format (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern int cairo_image_surface_get_height (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern int cairo_image_surface_get_stride (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern int cairo_image_surface_get_width (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ [return: MarshalAs (UnmanagedType.U1)]
+ internal static extern bool cairo_in_clip (IntPtr cr, double x, double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ [return: MarshalAs (UnmanagedType.U1)]
+ internal static extern bool cairo_in_fill (IntPtr cr, double x, double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ [return: MarshalAs (UnmanagedType.U1)]
+ internal static extern bool cairo_in_stroke (IntPtr cr, double x, double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_line_to (IntPtr cr, double x, double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_mask (IntPtr cr, IntPtr pattern);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_mask_surface (IntPtr cr, IntPtr surface, double x, double y);
+
+ // Matrix
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_matrix_init (Matrix matrix, double xx, double yx, double xy, double yy, double x0, double y0);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_matrix_init_identity (Matrix matrix);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_matrix_init_rotate (Matrix matrix, double radians);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_matrix_init_scale (Matrix matrix, double sx, double sy);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_matrix_init_translate (Matrix matrix, double tx, double ty);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_matrix_invert (Matrix matrix);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_matrix_multiply (Matrix result, Matrix a, Matrix b);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_matrix_scale (Matrix matrix, double sx, double sy);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_matrix_rotate (Matrix matrix, double radians);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_matrix_transform_distance (Matrix matrix, ref double dx, ref double dy);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_matrix_transform_point (Matrix matrix, ref double x, ref double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_matrix_translate (Matrix matrix, double tx, double ty);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_move_to (IntPtr cr, double x, double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_new_path (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_new_sub_path (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_paint (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_paint_with_alpha (IntPtr cr, double alpha);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_path_destroy (IntPtr path);
+
+ // Pattern
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_pattern_add_color_stop_rgb (IntPtr pattern, double offset, double red, double green, double blue);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_pattern_add_color_stop_rgba (IntPtr pattern, double offset, double red, double green, double blue, double alpha);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_pattern_get_color_stop_count (IntPtr pattern, out int count);
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_pattern_get_color_stop_rgba (IntPtr pattern, int index, out double offset, out double red, out double green, out double blue, out double alpha);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_pattern_create_for_surface (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_pattern_get_surface (IntPtr pattern, out IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_pattern_create_linear (double x0, double y0, double x1, double y1);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_pattern_get_linear_points (IntPtr pattern, out double x0, out double y0, out double x1, out double y1);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_pattern_create_radial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_pattern_get_radial_circles (IntPtr pattern, out double x0, out double y0, out double r0, out double x1, out double y1, out double r1);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_pattern_create_rgb (double r, double g, double b);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_pattern_create_rgba (double r, double g, double b, double a);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_pattern_get_rgba (IntPtr pattern, out double red, out double green, out double blue, out double alpha);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_pattern_destroy (IntPtr pattern);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Extend cairo_pattern_get_extend (IntPtr pattern);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Filter cairo_pattern_get_filter (IntPtr pattern);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_pattern_get_matrix (IntPtr pattern, Matrix matrix);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern PatternType cairo_pattern_get_type (IntPtr pattern);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_pattern_reference (IntPtr pattern);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_pattern_set_extend (IntPtr pattern, Extend extend);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_pattern_set_filter (IntPtr pattern, Filter filter);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_pattern_set_matrix (IntPtr pattern, Matrix matrix);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_pattern_status (IntPtr pattern);
+
+ // PdfSurface
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_pdf_surface_create (string filename, double width, double height);
+
+ //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ //internal static extern IntPtr cairo_pdf_surface_create_for_stream (string filename, double width, double height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_pdf_surface_set_size (IntPtr surface, double x, double y);
+
+ // PostscriptSurface
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_ps_surface_create (string filename, double width, double height);
+
+ //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ //internal static extern IntPtr cairo_ps_surface_create_for_stream (string filename, double width, double height);
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_ps_surface_dsc_begin_page_setup (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_ps_surface_dsc_begin_setup (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_ps_surface_dsc_comment (IntPtr surface, string comment);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_ps_surface_set_size (IntPtr surface, double x, double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_pop_group (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_pop_group_to_source (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_push_group (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_push_group_with_content (IntPtr cr, Content content);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_quartz_surface_create (IntPtr context, bool flipped, int width, int height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_rectangle (IntPtr cr, double x, double y, double width, double height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_reference (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ 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 RectangleInt rectangle);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_region_copy (IntPtr original);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_region_create ();
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_region_create_rectangle (ref RectangleInt rect);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_region_create_rectangles (RectangleInt[] rects, int count);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_region_destroy (IntPtr region);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern bool cairo_region_equal (IntPtr a, IntPtr b);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_region_get_extents (IntPtr region, out RectangleInt extents);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_region_get_rectangle (IntPtr region, int nth, out RectangleInt rectangle);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_region_intersect (IntPtr dst, IntPtr other);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_region_intersect_rectangle (IntPtr dst, ref RectangleInt rectangle);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern bool cairo_region_is_empty (IntPtr region);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern int cairo_region_num_rectangles (IntPtr region);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_region_reference (IntPtr region);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_region_status (IntPtr region);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_region_subtract (IntPtr dst, IntPtr other);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_region_subtract_rectangle (IntPtr dst, ref RectangleInt rectangle);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_region_translate (IntPtr region, int dx, int dy);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_region_union (IntPtr dst, IntPtr other);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_region_union_rectangle (IntPtr dst, ref RectangleInt rectangle);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_region_xor (IntPtr dst, IntPtr other);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_region_xor_rectangle (IntPtr dst, ref RectangleInt rectangle);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_rel_curve_to (IntPtr cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_rel_line_to (IntPtr cr, double dx, double dy);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_rel_move_to (IntPtr cr, double dx, double dy);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_reset_clip (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_restore (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_rotate (IntPtr cr, double angle);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_save (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_scale (IntPtr cr, double sx, double sy);
+
+ // ScaledFont
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_scaled_font_create (IntPtr fontFace, Matrix matrix, Matrix ctm, IntPtr options);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_scaled_font_destroy (IntPtr scaled_font);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_scaled_font_extents (IntPtr scaled_font, out FontExtents extents);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_scaled_font_get_ctm (IntPtr scaled_font, out Matrix matrix);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_scaled_font_get_font_face (IntPtr scaled_font);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_scaled_font_get_font_matrix (IntPtr scaled_font, out Matrix matrix);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_scaled_font_get_font_options (IntPtr scaled_font);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern FontType cairo_scaled_font_get_type (IntPtr scaled_font);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_scaled_font_glyph_extents (IntPtr scaled_font, IntPtr glyphs, int num_glyphs, out TextExtents extents);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_scaled_font_reference (IntPtr scaled_font);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_scaled_font_status (IntPtr scaled_font);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_scaled_font (IntPtr cr, IntPtr scaled_font);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_get_scaled_font (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_scaled_font_text_extents (IntPtr scaled_font, byte[] utf8, out TextExtents extents);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_select_font_face (IntPtr cr, string family, FontSlant slant, FontWeight weight);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_antialias (IntPtr cr, Antialias antialias);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_dash (IntPtr cr, double [] dashes, int ndash, double offset);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_get_dash (IntPtr cr, IntPtr dashes, out double offset);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern int cairo_get_dash_count (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_fill_rule (IntPtr cr, Cairo.FillRule fill_rule);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_font_face (IntPtr cr, IntPtr fontFace);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_font_matrix (IntPtr cr, Matrix matrix);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_font_options (IntPtr cr, IntPtr options);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_font_size (IntPtr cr, double size);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_line_cap (IntPtr cr, LineCap line_cap);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_line_join (IntPtr cr, LineJoin line_join);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_line_width (IntPtr cr, double width);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_matrix (IntPtr cr, Matrix matrix);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_miter_limit (IntPtr cr, double limit);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_operator (IntPtr cr, Cairo.Operator op);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_source (IntPtr cr, IntPtr pattern);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_source_rgb (IntPtr cr, double red, double green, double blue);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_source_rgba (IntPtr cr, double red, double green, double blue, double alpha);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_source_surface (IntPtr cr, IntPtr surface, double x, double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_set_tolerance (IntPtr cr, double tolerance);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_show_glyphs (IntPtr ct, IntPtr glyphs, int num_glyphs);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_show_page (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_show_text (IntPtr cr, byte[] utf8);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_status (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_status_to_string (Status status);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_stroke (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_stroke_extents (IntPtr cr, out double x1, out double y1, out double x2, out double y2);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_stroke_preserve (IntPtr cr);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_rectangle_list_destroy (IntPtr rectangle_list);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_copy_clip_rectangle_list (IntPtr cr);
+
+ // Surface
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_surface_create_similar (IntPtr surface, Cairo.Content content, int width, int height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_surface_destroy (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_surface_finish (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_surface_flush (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Content cairo_surface_get_content (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_surface_get_device_offset (IntPtr surface, out double x, out double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_surface_get_font_options (IntPtr surface, IntPtr FontOptions);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern uint cairo_surface_get_reference_count (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern SurfaceType cairo_surface_get_type (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_surface_mark_dirty (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_surface_mark_dirty_rectangle (IntPtr surface, int x, int y, int width, int height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_surface_reference (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_surface_set_device_offset (IntPtr surface, double x, double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_surface_set_fallback_resolution (IntPtr surface, double x, double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_surface_status (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_surface_write_to_png (IntPtr surface, string filename);
+
+ //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ //internal static extern void cairo_surface_write_to_png_stream (IntPtr surface, WriteFunc writeFunc);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_svg_surface_create (string fileName, double width, double height);
+
+ //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ //internal static extern IntPtr cairo_svg_surface_create_for_stream (double width, double height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_svg_surface_restrict_to_version (IntPtr surface, SvgVersion version);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_text_extents (IntPtr cr, byte[] utf8, out TextExtents extents);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_text_path (IntPtr ct, byte[] utf8);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_transform (IntPtr cr, Matrix matrix);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_translate (IntPtr cr, double tx, double ty);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_user_to_device (IntPtr cr, ref double x, ref double y);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_user_to_device_distance (IntPtr cr, ref double dx, ref double dy);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern int cairo_version ();
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_version_string ();
+
+ // DirectFBSurface
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_directfb_surface_create (IntPtr dfb, IntPtr surface);
+
+ // win32 fonts
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_win32_font_face_create_for_logfontw (IntPtr logfontw);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_win32_scaled_font_done_font (IntPtr scaled_font);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern double cairo_win32_scaled_font_get_metrics_factor (IntPtr scaled_font);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_win32_scaled_font_select_font (IntPtr scaled_font, IntPtr hdc);
+
+ // win32 surface
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_win32_surface_create (IntPtr hdc);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_win32_surface_create_with_ddb (IntPtr hdc, Format format, int width, int height);
+
+ // XcbSurface
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_xcb_surface_create (IntPtr connection, uint drawable, IntPtr visual, int width, int height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_xcb_surface_create_for_bitmap (IntPtr connection, uint bitmap, IntPtr screen, int width, int height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_xcb_surface_set_size (IntPtr surface, int width, int height);
+
+ // XlibSurface
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_xlib_surface_create (IntPtr display, IntPtr drawable, IntPtr visual, int width, int height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_xlib_surface_create_for_bitmap (IntPtr display, IntPtr bitmap, IntPtr screen, int width, int height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern int cairo_xlib_surface_get_depth (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_xlib_surface_get_display (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_xlib_surface_get_drawable (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern int cairo_xlib_surface_get_height (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_xlib_surface_get_screen (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_xlib_surface_get_visual (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern int cairo_xlib_surface_get_width (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_xlib_surface_set_drawable (IntPtr surface, IntPtr drawable, int width, int height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_xlib_surface_set_size (IntPtr surface, int width, int height);
+
+ #region GLSurface
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_gl_surface_create (IntPtr device, uint content, int width, int height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_gl_surface_create_for_texture (IntPtr device, uint content, uint tex, int width, int height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_gl_surface_set_size (IntPtr surface, int width, int height);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern int cairo_gl_surface_get_width (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern int cairo_gl_surface_get_height (IntPtr surface);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_gl_surface_swapbuffers (IntPtr surf);
+ #endregion
+
+ #region GLX Functions
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_glx_device_create (IntPtr dpy, IntPtr gl_ctx);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_glx_device_get_display (IntPtr device);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_glx_device_get_context (IntPtr device);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_gl_surface_create_for_window (IntPtr device, IntPtr window, int width, int height);
+ #endregion
+
+ #region WGL Fucntions
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_wgl_device_create (IntPtr hglrc);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_wgl_device_get_context (IntPtr device);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_gl_surface_create_for_dc (IntPtr device, IntPtr hdc, int width, int height);
+ #endregion
+
+ #region EGL Functions
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_egl_device_create (IntPtr dpy, IntPtr gl_ctx);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_gl_surface_create_for_egl (IntPtr device, IntPtr eglSurface, int width, int height);
+ #endregion
+
+ #region Device
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern IntPtr cairo_device_reference (IntPtr device);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_device_status(IntPtr device);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_device_destroy (IntPtr device);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern Status cairo_device_acquire(IntPtr device);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_device_release(IntPtr device);
+
+ [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
+ internal static extern void cairo_gl_device_set_thread_aware(IntPtr device, int value);
+ #endregion
+ }
+}
\ No newline at end of file
--- /dev/null
+//
+// Mono.Cairo.Operator.cs
+//
+// Authors: Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// John Luke (john.luke@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005 John Luke
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ [Serializable]
+ public enum Operator
+ {
+ Clear,
+ Source,
+ Over,
+ In,
+ Out,
+ Atop,
+
+ Dest,
+ DestOver,
+ DestIn,
+ DestOut,
+ DestAtop,
+
+ Xor,
+ Add,
+ Saturate,
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.PostscriptSurface.cs
+//
+// Authors:
+// John Luke
+//
+// (C) John Luke, 2006.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ public class PSSurface : Surface
+ {
+ internal PSSurface (IntPtr handle, bool owns) : base (handle, owns)
+ {
+ }
+
+ public PSSurface (string filename, double width, double height)
+ : base (NativeMethods.cairo_ps_surface_create (filename, width, height), true)
+ {
+ }
+
+ public void BeginPageSetup ()
+ {
+ NativeMethods.cairo_ps_surface_dsc_begin_page_setup (Handle);
+ }
+
+ public void BeginSetup ()
+ {
+ NativeMethods.cairo_ps_surface_dsc_begin_setup (Handle);
+ }
+
+ public void DscComment (string comment)
+ {
+ NativeMethods.cairo_ps_surface_dsc_comment (Handle, comment);
+ }
+
+ public void SetSize (double width, double height)
+ {
+ NativeMethods.cairo_ps_surface_set_size (Handle, width, height);
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Context.cs
+//
+// Author:
+// Miguel de Icaza (miguel@novell.com)
+//
+// This is an OO wrapper API for the Cairo API.
+//
+// Copyright 2007 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;
+using Cairo;
+
+namespace Cairo {
+
+ public class Path : IDisposable
+ {
+ IntPtr handle = IntPtr.Zero;
+
+ internal Path (IntPtr handle)
+ {
+ this.handle = handle;
+ if (CairoDebug.Enabled)
+ CairoDebug.OnAllocated (handle);
+ }
+
+ ~Path ()
+ {
+ Dispose (false);
+ }
+
+ public IntPtr Handle { get { return handle; } }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (!disposing || CairoDebug.Enabled)
+ CairoDebug.OnDisposed<Path> (handle, disposing);
+
+ if (!disposing|| handle == IntPtr.Zero)
+ return;
+
+ NativeMethods.cairo_path_destroy (handle);
+ handle = IntPtr.Zero;
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Pattern.cs
+//
+// Author: Jordi Mas (jordi@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// (C) Ximian Inc, 2004.
+//
+// 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.Collections;
+
+namespace Cairo {
+
+ public class Pattern : IDisposable
+ {
+ [Obsolete]
+ protected IntPtr pattern = IntPtr.Zero;
+
+ public static Pattern Lookup (IntPtr pattern, bool owner)
+ {
+ if (pattern == IntPtr.Zero)
+ return null;
+
+ PatternType pt = NativeMethods.cairo_pattern_get_type (pattern);
+ switch (pt) {
+ case PatternType.Solid:
+ return new SolidPattern (pattern, owner);
+ case PatternType.Surface:
+ return new SurfacePattern (pattern, owner);
+ case PatternType.Linear:
+ return new LinearGradient (pattern, owner);
+ case PatternType.Radial:
+ return new RadialGradient (pattern, owner);
+ default:
+ return new Pattern (pattern, owner);
+ }
+ }
+
+ [Obsolete]
+ protected Pattern ()
+ {
+ }
+
+ internal Pattern (IntPtr handle, bool owned)
+ {
+ Handle = handle;
+ if (!owned)
+ NativeMethods.cairo_pattern_reference (handle);
+ if (CairoDebug.Enabled)
+ CairoDebug.OnAllocated (handle);
+ }
+
+ ~Pattern ()
+ {
+ Dispose (false);
+ }
+
+ [Obsolete ("Use the SurfacePattern constructor")]
+ public Pattern (Surface surface)
+ : this ( NativeMethods.cairo_pattern_create_for_surface (surface.Handle), true)
+ {
+ }
+
+ [Obsolete]
+ protected void Reference ()
+ {
+ NativeMethods.cairo_pattern_reference (pattern);
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (!disposing || CairoDebug.Enabled)
+ CairoDebug.OnDisposed<Pattern> (Handle, disposing);
+
+ if (!disposing|| Handle == IntPtr.Zero)
+ return;
+
+ NativeMethods.cairo_pattern_destroy (Handle);
+ Handle = IntPtr.Zero;
+ }
+
+ [Obsolete ("Use Dispose()")]
+ public void Destroy ()
+ {
+ Dispose ();
+ }
+
+ public Status Status
+ {
+ get { return NativeMethods.cairo_pattern_status (Handle); }
+ }
+
+ public Extend Extend
+ {
+ get { return NativeMethods.cairo_pattern_get_extend (Handle); }
+ set { NativeMethods.cairo_pattern_set_extend (Handle, value); }
+ }
+
+ public Matrix Matrix {
+ set {
+ NativeMethods.cairo_pattern_set_matrix (Handle, value);
+ }
+
+ get {
+ Matrix m = new Matrix ();
+ NativeMethods.cairo_pattern_get_matrix (Handle, m);
+ return m;
+ }
+ }
+
+#pragma warning disable 612
+ public IntPtr Handle {
+ get { return pattern; }
+ private set { pattern = value; }
+ }
+#pragma warning restore 612
+
+ [Obsolete]
+ public IntPtr Pointer {
+ get { return pattern; }
+ }
+
+ public PatternType PatternType {
+ get { return NativeMethods.cairo_pattern_get_type (Handle); }
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.PatternType.cs
+//
+// Authors:
+// John Luke
+//
+// (C) John Luke, 2006.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ [Serializable]
+ public enum PatternType
+ {
+ Solid,
+ Surface,
+ Linear,
+ Radial,
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.PdfSurface.cs
+//
+// Authors:
+// John Luke
+//
+// (C) John Luke, 2006.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ public class PdfSurface : Surface
+ {
+ internal PdfSurface (IntPtr handle, bool owns) : base (handle, owns)
+ {
+ }
+
+ public PdfSurface (string filename, double width, double height)
+ : base (NativeMethods.cairo_pdf_surface_create (filename, width, height), true)
+ {
+ }
+
+ public void SetSize (double width, double height)
+ {
+ NativeMethods.cairo_pdf_surface_set_size (Handle, width, height);
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.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 Cairo {
+ public struct Point
+ {
+ public Point (int x, int y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+
+ int x, y;
+ public int X {
+ get { return x; }
+ set { x = value; }
+ }
+
+ public int Y {
+ get { return y; }
+ set { y = value; }
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.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 Cairo {
+
+ public struct PointD
+ {
+ public PointD (double x, double y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+
+ double x, y;
+ public double X {
+ get { return x; }
+ set { x = value; }
+ }
+
+ public double Y {
+ get { return y; }
+ set { y = value; }
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Pattern.cs
+//
+// Author: Jordi Mas (jordi@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// (C) Ximian Inc, 2004.
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ public class RadialGradient : Gradient
+ {
+ internal RadialGradient (IntPtr handle, bool owned) : base (handle, owned)
+ {
+ }
+
+ public RadialGradient (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1)
+ : base (NativeMethods.cairo_pattern_create_radial (cx0, cy0, radius0, cx1, cy1, radius1), true)
+ {
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.Rectangle.cs
+//
+// Author:
+// John Luke (john.luke@gmail.com)
+//
+// (C) John Luke 2005.
+//
+// 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 Cairo
+{
+ public struct Rectangle
+ {
+ double x;
+ double y;
+ double width;
+ double height;
+
+ public Rectangle (double x, double y, double width, double height)
+ {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+ public Rectangle (Point point, double width, double height)
+ {
+ x = point.X;
+ y = point.Y;
+ this.width = width;
+ this.height = height;
+ }
+
+ public double X {
+ get { return x; }
+ }
+
+ public double Y {
+ get { return y; }
+ }
+
+ public double Width {
+ get { return width; }
+ }
+
+ public double Height {
+ get { return height; }
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (obj is Rectangle)
+ return this == (Rectangle)obj;
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ return (int) (x + y + width + height);
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("x:{0} y:{1} w:{2} h:{3}", x, y, width, height);
+ }
+
+ public static bool operator == (Rectangle rectangle, Rectangle other)
+ {
+ return rectangle.X == other.X && rectangle.Y == other.Y && rectangle.Width == other.Width && rectangle.Height == other.Height;
+ }
+
+ public static bool operator != (Rectangle rectangle, Rectangle other)
+ {
+ return !(rectangle == other);
+ }
+ }
+}
--- /dev/null
+// Copyright (C) 2011 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 Cairo
+{
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct RectangleInt {
+ public int X;
+ public int Y;
+ public int Width;
+ public int Height;
+ }
+
+ public enum RegionOverlap {
+ In,
+ Out,
+ Part,
+ }
+
+ public class Region : IDisposable {
+
+ IntPtr handle;
+ public IntPtr Handle {
+ get { return handle; }
+ }
+
+ [Obsolete]
+ public Region (IntPtr handle) : this (handle, false) {}
+
+ public Region (IntPtr handle, bool owned)
+ {
+ this.handle = handle;
+ if (!owned)
+ NativeMethods.cairo_region_reference (handle);
+ if (CairoDebug.Enabled)
+ CairoDebug.OnAllocated (handle);
+ }
+
+ public Region () : this (NativeMethods.cairo_region_create () , true)
+ {
+ }
+
+ public Region (RectangleInt rect)
+ {
+ handle = NativeMethods.cairo_region_create_rectangle (ref rect);
+ }
+
+ public Region (RectangleInt[] rects)
+ {
+ handle = NativeMethods.cairo_region_create_rectangles (rects, rects.Length);
+ }
+
+ public Region Copy ()
+ {
+ return new Region (NativeMethods.cairo_region_copy (Handle), true);
+ }
+
+ ~Region ()
+ {
+ Dispose (false);
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (!disposing || CairoDebug.Enabled)
+ CairoDebug.OnDisposed<Region> (handle, disposing);
+
+ if (!disposing|| handle == IntPtr.Zero)
+ return;
+
+ NativeMethods.cairo_region_destroy (Handle);
+ handle = IntPtr.Zero;
+ }
+
+ public override bool Equals (object obj)
+ {
+ return (obj is Region) && NativeMethods.cairo_region_equal (Handle, (obj as Region).Handle);
+ }
+
+ public override int GetHashCode ()
+ {
+ return Handle.GetHashCode ();
+ }
+
+ public Status Status {
+ get { return NativeMethods.cairo_region_status (Handle); }
+ }
+
+ public RectangleInt Extents {
+ get {
+ RectangleInt result;
+ NativeMethods.cairo_region_get_extents (Handle, out result);
+ return result;
+ }
+ }
+
+ public int NumRectangles {
+ get { return NativeMethods.cairo_region_num_rectangles (Handle); }
+ }
+
+ public RectangleInt GetRectangle (int nth)
+ {
+ RectangleInt val;
+ NativeMethods.cairo_region_get_rectangle (Handle, nth, out val);
+ return val;
+ }
+
+ public bool IsEmpty {
+ get { return NativeMethods.cairo_region_is_empty (Handle); }
+ }
+
+ public RegionOverlap ContainsPoint (RectangleInt rectangle)
+ {
+ return NativeMethods.cairo_region_contains_rectangle (Handle, ref rectangle);
+ }
+
+ public bool ContainsPoint (int x, int y)
+ {
+ return NativeMethods.cairo_region_contains_point (Handle, x, y);
+ }
+
+ public void Translate (int dx, int dy)
+ {
+ NativeMethods.cairo_region_translate (Handle, dx, dy);
+ }
+
+ public Status Subtract (Region other)
+ {
+ return NativeMethods.cairo_region_subtract (Handle, other.Handle);
+ }
+
+ public Status SubtractRectangle (RectangleInt rectangle)
+ {
+ return NativeMethods.cairo_region_subtract_rectangle (Handle, ref rectangle);
+ }
+
+ public Status Intersect (Region other)
+ {
+ return NativeMethods.cairo_region_intersect (Handle, other.Handle);
+ }
+
+ public Status IntersectRectangle (RectangleInt rectangle)
+ {
+ return NativeMethods.cairo_region_intersect_rectangle (Handle, ref rectangle);
+ }
+
+ public Status Union (Region other)
+ {
+ return NativeMethods.cairo_region_union (Handle, other.Handle);
+ }
+
+ public Status UnionRectangle (RectangleInt rectangle)
+ {
+ return NativeMethods.cairo_region_union_rectangle (Handle, ref rectangle);
+ }
+
+ public Status Xor (Region other)
+ {
+ return NativeMethods.cairo_region_xor (Handle, other.Handle);
+ }
+
+ public Status XorRectangle (RectangleInt rectangle)
+ {
+ return NativeMethods.cairo_region_xor_rectangle (Handle, ref rectangle);
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.ScaledFont.cs
+//
+// (c) 2008 Jordi Mas i Hernandez (jordimash@gmail.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 Cairo {
+
+ public class ScaledFont : IDisposable
+ {
+ protected IntPtr handle = IntPtr.Zero;
+
+ internal ScaledFont (IntPtr handle, bool owner)
+ {
+ this.handle = handle;
+ if (!owner)
+ NativeMethods.cairo_scaled_font_reference (handle);
+ if (CairoDebug.Enabled)
+ CairoDebug.OnAllocated (handle);
+ }
+
+ public ScaledFont (FontFace fontFace, Matrix matrix, Matrix ctm, FontOptions options)
+ : this (NativeMethods.cairo_scaled_font_create (fontFace.Handle, matrix, ctm, options.Handle), true)
+ {
+ }
+
+ ~ScaledFont ()
+ {
+ Dispose (false);
+ }
+
+ public IntPtr Handle {
+ get {
+ return handle;
+ }
+ }
+
+ public FontExtents FontExtents {
+ get {
+ FontExtents extents;
+ NativeMethods.cairo_scaled_font_extents (handle, out extents);
+ return extents;
+ }
+ }
+
+ public Matrix FontMatrix {
+ get {
+ Matrix m;
+ NativeMethods.cairo_scaled_font_get_font_matrix (handle, out m);
+ return m;
+ }
+ }
+
+ public FontType FontType {
+ get {
+ return NativeMethods.cairo_scaled_font_get_type (handle);
+ }
+ }
+
+ public TextExtents GlyphExtents (Glyph[] glyphs)
+ {
+ IntPtr ptr = Context.FromGlyphToUnManagedMemory (glyphs);
+ TextExtents extents;
+
+ NativeMethods.cairo_scaled_font_glyph_extents (handle, ptr, glyphs.Length, out extents);
+
+ Marshal.FreeHGlobal (ptr);
+ return extents;
+ }
+
+ public Status Status
+ {
+ get { return NativeMethods.cairo_scaled_font_status (handle); }
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (!disposing || CairoDebug.Enabled)
+ CairoDebug.OnDisposed<ScaledFont> (handle, disposing);
+
+ if (!disposing|| handle == IntPtr.Zero)
+ return;
+
+ NativeMethods.cairo_scaled_font_destroy (handle);
+ handle = IntPtr.Zero;
+ }
+
+ [Obsolete]
+ protected void Reference ()
+ {
+ NativeMethods.cairo_scaled_font_reference (handle);
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.Pattern.cs
+//
+// Author: Jordi Mas (jordi@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// (C) Ximian Inc, 2004.
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ public class SolidPattern : Pattern
+ {
+ internal SolidPattern (IntPtr handle, bool owned) : base (handle, owned)
+ {
+ }
+
+ public SolidPattern (Color color)
+ : base (NativeMethods.cairo_pattern_create_rgba (color.R, color.G, color.B, color.A), true)
+ {
+ }
+
+ public SolidPattern (double r, double g, double b)
+ : base (NativeMethods.cairo_pattern_create_rgb (r, g, b), true)
+ {
+ }
+
+ public SolidPattern (double r, double g, double b, double a)
+ : base (NativeMethods.cairo_pattern_create_rgba (r, g, b, a), true)
+ {
+ }
+
+ public SolidPattern (Color color, bool solid)
+ : base (solid
+ ? NativeMethods.cairo_pattern_create_rgb (color.R, color.G, color.B)
+ : NativeMethods.cairo_pattern_create_rgba (color.R, color.G, color.B, color.A),
+ true)
+ {
+ }
+
+ public Color Color {
+ get {
+ double red, green, blue, alpha;
+ NativeMethods.cairo_pattern_get_rgba (Handle, out red, out green, out blue, out alpha);
+ return new Color (red, green, blue, alpha);
+ }
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.Status.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// John Luke (john.luke@gmail.com)
+// Alp Toker (alp@atoker.com)
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005 John Luke
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo
+{
+ [Serializable]
+ public enum Status
+ {
+ Success = 0,
+ NoMemory,
+ InvalidRestore,
+ InvalidPopGroup,
+ NoCurrentPoint,
+ InvalidMatrix,
+ InvalidStatus,
+ NullPointer,
+ InvalidString,
+ InvalidPathData,
+ ReadError,
+ WriteError,
+ SurfaceFinished,
+ SurfaceTypeMismatch,
+ PatternTypeMismatch,
+ InvalidContent,
+ InvalidFormat,
+ InvalidVisual,
+ FileNotFound,
+ InvalidDash,
+ InvalidDscComment,
+ InvalidIndex,
+ ClipNotRepresentable,
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Cairo.cs
+//
+// Authors:
+// John Luke (john.luke@gmail.com)
+//
+// Copyright (C) John Luke 2005
+//
+// 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 Cairo
+{
+ [Serializable]
+ public enum SubpixelOrder
+ {
+ Default,
+ Rgb,
+ Bgr,
+ Vrgb,
+ Vbgr,
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Surface.cs
+//
+// Authors:
+// Duncan Mak
+// Miguel de Icaza.
+// Alp Toker
+//
+// (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.
+//
+
+using System;
+using System.Collections;
+
+namespace Cairo {
+
+ public class Surface : IDisposable
+ {
+ [Obsolete]
+ protected static Hashtable surfaces = new Hashtable ();
+
+ IntPtr handle = IntPtr.Zero;
+
+ [Obsolete]
+ protected Surface()
+ {
+ }
+
+ [Obsolete]
+ protected Surface (IntPtr ptr) : this (ptr, true)
+ {
+ }
+
+ protected Surface (IntPtr handle, bool owner)
+ {
+ this.handle = handle;
+ if (!owner)
+ NativeMethods.cairo_surface_reference (handle);
+ if (CairoDebug.Enabled)
+ CairoDebug.OnAllocated (handle);
+ }
+
+ public static Surface Lookup (IntPtr surface, bool owned)
+ {
+ SurfaceType st = NativeMethods.cairo_surface_get_type (surface);
+ switch (st) {
+ case SurfaceType.Image:
+ return new ImageSurface (surface, owned);
+ case SurfaceType.Xlib:
+ return new XlibSurface (surface, owned);
+ case SurfaceType.Xcb:
+ return new XcbSurface (surface, owned);
+ case SurfaceType.Glitz:
+ return new GlitzSurface (surface, owned);
+ case SurfaceType.Win32:
+ return new Win32Surface (surface, owned);
+ case SurfaceType.Pdf:
+ return new PdfSurface (surface, owned);
+ case SurfaceType.PS:
+ return new PSSurface (surface, owned);
+ case SurfaceType.DirectFB:
+ return new DirectFBSurface (surface, owned);
+ case SurfaceType.Svg:
+ return new SvgSurface (surface, owned);
+ case SurfaceType.GL:
+ return new GLSurface (surface, owned);
+ default:
+ return new Surface (surface, owned);
+ }
+ }
+
+ [Obsolete ("Use an ImageSurface constructor instead.")]
+ public static Cairo.Surface CreateForImage (
+ ref byte[] data, Cairo.Format format, int width, int height, int stride)
+ {
+ IntPtr p = NativeMethods.cairo_image_surface_create_for_data (
+ data, format, width, height, stride);
+
+ return new Cairo.Surface (p, true);
+ }
+
+ [Obsolete ("Use an ImageSurface constructor instead.")]
+ public static Cairo.Surface CreateForImage (
+ Cairo.Format format, int width, int height)
+ {
+ IntPtr p = NativeMethods.cairo_image_surface_create (
+ format, width, height);
+
+ return new Cairo.Surface (p, true);
+ }
+
+
+ public Cairo.Surface CreateSimilar (
+ Cairo.Content content, int width, int height)
+ {
+ IntPtr p = NativeMethods.cairo_surface_create_similar (
+ this.Handle, content, width, height);
+
+ return new Cairo.Surface (p, true);
+ }
+
+ ~Surface ()
+ {
+ Dispose (false);
+ }
+
+ //[Obsolete ("Use Context.SetSource() followed by Context.Paint()")]
+ public void Show (Context gr, double x, double y)
+ {
+ NativeMethods.cairo_set_source_surface (gr.Handle, handle, x, y);
+ NativeMethods.cairo_paint (gr.Handle);
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (!disposing || CairoDebug.Enabled)
+ CairoDebug.OnDisposed<Surface> (handle, disposing);
+
+ if (!disposing|| handle == IntPtr.Zero)
+ return;
+
+ NativeMethods.cairo_surface_destroy (handle);
+ handle = IntPtr.Zero;
+ }
+
+ public Status Finish ()
+ {
+ NativeMethods.cairo_surface_finish (handle);
+ return Status;
+ }
+
+ public void Flush ()
+ {
+ NativeMethods.cairo_surface_flush (handle);
+ }
+
+ public void MarkDirty ()
+ {
+ NativeMethods.cairo_surface_mark_dirty (Handle);
+ }
+
+ public void MarkDirty (Rectangle rectangle)
+ {
+ NativeMethods.cairo_surface_mark_dirty_rectangle (Handle, (int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, (int)rectangle.Height);
+ }
+
+ public IntPtr Handle {
+ get {
+ return handle;
+ }
+ }
+
+ public PointD DeviceOffset {
+ get {
+ double x, y;
+ NativeMethods.cairo_surface_get_device_offset (handle, out x, out y);
+ return new PointD (x, y);
+ }
+
+ set {
+ NativeMethods.cairo_surface_set_device_offset (handle, value.X, value.Y);
+ }
+ }
+
+ [Obsolete ("Use Dispose()")]
+ public void Destroy()
+ {
+ Dispose ();
+ }
+
+ public void SetFallbackResolution (double x, double y)
+ {
+ NativeMethods.cairo_surface_set_fallback_resolution (handle, x, y);
+ }
+
+ public void WriteToPng (string filename)
+ {
+ NativeMethods.cairo_surface_write_to_png (handle, filename);
+ }
+
+ [Obsolete ("Use Handle instead.")]
+ public IntPtr Pointer {
+ get {
+ return handle;
+ }
+ }
+
+ public Status Status {
+ get { return NativeMethods.cairo_surface_status (handle); }
+ }
+
+ public Content Content {
+ get { return NativeMethods.cairo_surface_get_content (handle); }
+ }
+
+ public SurfaceType SurfaceType {
+ get { return NativeMethods.cairo_surface_get_type (handle); }
+ }
+
+ public uint ReferenceCount {
+ get { return NativeMethods.cairo_surface_get_reference_count (handle); }
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Pattern.cs
+//
+// Author: Jordi Mas (jordi@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+// (C) Ximian Inc, 2004.
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ public class SurfacePattern : Pattern
+ {
+ internal SurfacePattern (IntPtr handle, bool owned) : base (handle, owned)
+ {
+ }
+
+ public SurfacePattern (Surface surface)
+ : base (NativeMethods.cairo_pattern_create_for_surface (surface.Handle), true)
+ {
+ }
+
+ //no idea why this is here, the base one is identical, but we can't remove it now
+ public new Extend Extend {
+ set { NativeMethods.cairo_pattern_set_extend (Handle, value); }
+ get { return NativeMethods.cairo_pattern_get_extend (Handle); }
+ }
+
+ public Filter Filter {
+ set { NativeMethods.cairo_pattern_set_filter (Handle, value); }
+ get { return NativeMethods.cairo_pattern_get_filter (Handle); }
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.SurfaceType.cs
+//
+// Authors:
+// John Luke
+//
+// (C) John Luke, 2006.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ [Serializable]
+ public enum SurfaceType
+ {
+ Image,
+ Pdf,
+ PS,
+ Xlib,
+ Xcb,
+ Glitz,
+ Quartz,
+ Win32,
+ BeOS,
+ DirectFB,
+ Svg,
+ OS2,
+ Win32Printing,
+ QuartzImage,
+ Script,
+ Qt,
+ Recording,
+ VG,
+ GL,
+ Drm,
+ Tee,
+ Xml,
+ Skia,
+ SubSurface
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.SvgSurface.cs
+//
+// Authors:
+// John Luke
+//
+// (C) John Luke, 2006.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ public class SvgSurface : Surface
+ {
+ internal SvgSurface (IntPtr handle, bool owns) : base (handle, owns)
+ {
+ }
+
+ public SvgSurface (string filename, double width, double height)
+ : base (NativeMethods.cairo_svg_surface_create (filename, width, height), true)
+ {
+ }
+
+ public void RestrictToVersion (SvgVersion version)
+ {
+ NativeMethods.cairo_svg_surface_restrict_to_version (Handle, version);
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.SvgVersion.cs
+//
+// Authors:
+// John Luke
+//
+// (C) John Luke, 2006.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ [Serializable]
+ public enum SvgVersion
+ {
+ // FIXME: yuck
+ OnePointOne = 0,
+ OnePointTwo,
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.TextExtents.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Hisham Mardam Bey (hisham.mardambey@gmail.com)
+//
+// (C) Ximian, Inc. 2003
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Cairo
+{
+ [StructLayout (LayoutKind.Sequential)]
+ public struct TextExtents
+ {
+ double xbearing;
+ double ybearing;
+ double width;
+ double height;
+ double xadvance;
+ double yadvance;
+
+ public double XBearing {
+ get { return xbearing; }
+ set { xbearing = value; }
+ }
+
+ public double YBearing {
+ get { return ybearing; }
+ set { ybearing = value; }
+ }
+
+ public double Width {
+ get { return width; }
+ set { width = value; }
+ }
+
+ public double Height {
+ get { return height; }
+ set { height = value; }
+ }
+
+ public double XAdvance {
+ get { return xadvance; }
+ set { xadvance = value; }
+ }
+
+ public double YAdvance {
+ get { return yadvance; }
+ set { yadvance = value; }
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (obj is TextExtents)
+ return this == (TextExtents)obj;
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ return (int)XBearing ^ (int)YBearing ^ (int)Width ^ (int)Height ^ (int)XAdvance ^ (int)YAdvance;
+ }
+
+ public static bool operator == (TextExtents extents, TextExtents other)
+ {
+ return extents.XBearing == other.XBearing && extents.YBearing == other.YBearing && extents.Width == other.Width && extents.Height == other.Height && extents.XAdvance == other.XAdvance && extents.YAdvance == other.YAdvance;
+ }
+
+ public static bool operator != (TextExtents extents, TextExtents other)
+ {
+ return !(extents == other);
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.Device.cs
+//
+// Authors:
+// JP Bruyère (jp_bruyere@hotmail.com)
+//
+// This is an OO wrapper API for the Cairo API
+//
+// Copyright (C) 2016 JP 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 Cairo
+{
+ public class WGLDevice : Device
+ {
+ public WGLDevice (IntPtr hglrc) : base (NativeMethods.cairo_wgl_device_create (hglrc), true)
+ {
+ }
+
+ public IntPtr Context {
+ get { return NativeMethods.cairo_wgl_device_get_context (Handle); }
+ }
+ }
+}
+
--- /dev/null
+//
+// Mono.Cairo.Win32Surface.cs
+//
+// Authors:
+// John Luke
+//
+// (C) John Luke, 2006.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+
+ public class Win32Surface : Surface
+ {
+ internal Win32Surface (IntPtr handle, bool owns) : base (handle, owns)
+ {
+ }
+
+ public Win32Surface (IntPtr hdc)
+ : base (NativeMethods.cairo_win32_surface_create (hdc), true)
+ {
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.XcbSurface.cs
+//
+// Authors:
+// Alp Toker
+//
+// (C) Alp Toker, 2006.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Cairo {
+ public class XcbSurface : Surface
+ {
+ internal XcbSurface (IntPtr handle, bool owns) : base (handle, owns)
+ {
+ }
+
+ public XcbSurface (IntPtr connection, uint drawable, IntPtr visual, int width, int height)
+ : base (NativeMethods.cairo_xcb_surface_create (connection, drawable, visual, width, height), true)
+ {
+ }
+
+ public static XcbSurface FromBitmap (IntPtr connection, uint bitmap, IntPtr screen, int width, int height)
+ {
+ IntPtr ptr = NativeMethods.cairo_xcb_surface_create_for_bitmap (connection, bitmap, screen, width, height);
+ return new XcbSurface (ptr, true);
+ }
+
+ public void SetSize (int width, int height)
+ {
+ NativeMethods.cairo_xcb_surface_set_size (Handle, width, height);
+ }
+ }
+}
--- /dev/null
+//
+// Mono.Cairo.XlibSurface.cs
+//
+// Authors:
+// Duncan Mak
+// Miguel de Icaza.
+//
+// (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.
+//
+
+using System;
+
+namespace Cairo {
+
+ public class XlibSurface : Surface
+ {
+ public XlibSurface (IntPtr display, IntPtr drawable, IntPtr visual, int width, int height)
+ : base (NativeMethods.cairo_xlib_surface_create (display, drawable, visual, width, height), true)
+ {
+ }
+
+ public XlibSurface (IntPtr ptr, bool own) : base (ptr, own)
+ {
+ }
+
+ public static XlibSurface FromBitmap (IntPtr display, IntPtr bitmap, IntPtr screen, int width, int height)
+ {
+ IntPtr ptr = NativeMethods.cairo_xlib_surface_create_for_bitmap (display, bitmap, screen, width, height);
+ return new XlibSurface(ptr, true);
+ }
+
+ public void SetDrawable (IntPtr drawable, int width, int height)
+ {
+ NativeMethods.cairo_xlib_surface_set_drawable (Handle, drawable, width, height);
+ }
+
+ public void SetSize (int width, int height)
+ {
+ NativeMethods.cairo_xlib_surface_set_size (Handle, width, height);
+ }
+
+ public int Depth {
+ get { return NativeMethods.cairo_xlib_surface_get_depth (Handle); }
+ }
+
+ public IntPtr Display {
+ get { return NativeMethods.cairo_xlib_surface_get_display (Handle); }
+ }
+
+ public IntPtr Drawable {
+ get { return NativeMethods.cairo_xlib_surface_get_drawable (Handle); }
+ }
+
+ public int Height {
+ get { return NativeMethods.cairo_xlib_surface_get_height (Handle); }
+ }
+
+ public IntPtr Screen {
+ get { return NativeMethods.cairo_xlib_surface_get_screen (Handle); }
+ }
+
+ public IntPtr Visual {
+ get { return NativeMethods.cairo_xlib_surface_get_visual (Handle); }
+ }
+
+ public int Width {
+ get { return NativeMethods.cairo_xlib_surface_get_width (Handle); }
+ }
+
+ }
+}
using System;
using System.Diagnostics;
using System.IO;
-using OpenTK.Platform.Linux;
using System.Collections.Generic;
-using OpenTK;
-using OpenTK.Platform.Egl;
using Cairo;
+using Crow.Linux;
namespace testDrm
{
- // Stores platform-specific information about a display
- class LinuxDisplay
- {
- public int FD;
- public IntPtr Connector;
- public IntPtr Crtc;
- public IntPtr Encoder;
-
- unsafe public ModeConnector* pConnector { get { return (ModeConnector*)Connector; } }
- unsafe public ModeCrtc* pCrtc { get { return (ModeCrtc*)Crtc; } }
- unsafe public ModeEncoder* pEncoder { get { return (ModeEncoder*)Encoder; } }
- /*
- public ModeInfo Mode
- {
- get
- {
- if (Crtc == IntPtr.Zero)
- throw new InvalidOperationException();
-
- unsafe
- {
- return pCrtc->mode;
- }
- }
- }
- */
-
- public ModeInfo OriginalMode;
-
- public int Id
- {
- get
- {
- if (Crtc == IntPtr.Zero)
- throw new InvalidOperationException();
-
- unsafe
- {
- return (int)pCrtc->crtc_id;
- }
- }
- }
-
- public LinuxDisplay(int fd, IntPtr c, IntPtr e, IntPtr r)
- {
- FD = fd;
- Connector = c;
- Encoder = e;
- Crtc = r;
- unsafe
- {
- OriginalMode = pCrtc->mode; // in case we change resolution later on
- }
- }
- }
+
static class TestDrm
- {
- const string gpu_path = "/dev/dri"; // card0, card1, ...
-
- [STAThread]
+ {
static void Main ()
{
-
-// using (Surface s = new ImageSurface (Format.Argb32,800,600)) {
-//
-// }
-// IntPtr gbm_device;
-// IntPtr egl_display;
-//
-// int gpu_fd = CreateDisplay(out gbm_device, out egl_display);
- using (DrmDevice drm = new DrmDevice ()) {
- drm.RenderingLoop ();
+ using (Application drm = new Application ()) {
+ //drm.CrowInterface.LoadInterface (@"/mnt/data2/devel/crow/Tests/Interfaces/Divers/colorPicker.crow");
+ drm.CrowInterface.LoadInterface (@"/mnt/data2/devel/crow/Tests/Interfaces/Divers/0.crow");
+ drm.CrowInterface.LoadInterface (@"/mnt/data2/devel/crow/Tests/Interfaces/Divers/0.crow");
+ drm.CrowInterface.LoadInterface (@"/mnt/data2/devel/crow/Tests/Interfaces/Divers/0.crow");
+ drm.CrowInterface.LoadInterface (@"/mnt/data2/devel/crow/Tests/Interfaces/Divers/0.crow");
+ //drm.CrowInterface.LoadInterface (@"/mnt/data2/devel/crow/Tests/Interfaces/GraphicObject/2.crow");
+ drm.Run ();
}
}
-
- static int CreateDisplay(out IntPtr gbm_device, out IntPtr egl_display)
- {
- // Query all GPUs until we find one that has a connected display.
- // This is necessary in multi-gpu systems, where only one GPU
- // can output a signal.
- // Todo: allow OpenTK to drive multiple GPUs
- // Todo: allow OpenTK to run on an offscreen GPU
- // Todo: allow the user to pick a GPU
- int fd = 0;
- gbm_device = IntPtr.Zero;
- egl_display = IntPtr.Zero;
-
- var files = Directory.GetFiles(gpu_path);
- foreach (var gpu in files)
- {
- if (System.IO.Path.GetFileName(gpu).StartsWith("card"))
- {
- int test_fd = SetupDisplay(gpu, out gbm_device, out egl_display);
- if (test_fd >= 0)
- {
- try
- {
- if (QueryDisplays(test_fd, null))
- {
- fd = test_fd;
- break;
- }
- }
- catch (Exception e)
- {
- Debug.WriteLine(e.ToString());
- }
-
- Console.WriteLine("[KMS] GPU '{0}' is not connected, skipping.", gpu);
- Libc.close(test_fd);
- }
- }
- }
-
- if (fd == 0)
- {
- Console.WriteLine("[Error] No valid GPU found, bailing out.");
- throw new PlatformNotSupportedException();
- }
-
- return fd;
- }
- static bool QueryDisplays(int fd, List<LinuxDisplay> displays)
- {
- unsafe
- {
- bool has_displays = false;
- if (displays != null)
- {
- displays.Clear();
- }
-
- ModeRes* resources = (ModeRes*)Drm.ModeGetResources(fd);
- if (resources == null)
- {
- Console.WriteLine("[KMS] Drm.ModeGetResources failed.");
- return false;
- }
- Console.WriteLine("[KMS] DRM found {0} connectors", resources->count_connectors);
-
- // Search for a valid connector
- ModeConnector* connector = null;
- for (int i = 0; i < resources->count_connectors; i++)
- {
- connector = (ModeConnector*)Drm.ModeGetConnector(fd, *(resources->connectors + i));
- if (connector != null)
- {
- bool success = false;
- LinuxDisplay display = null;
- try
- {
- if (connector->connection == ModeConnection.Connected && connector->count_modes > 0)
- {
- success = QueryDisplay(fd, connector, out display);
- has_displays |= success;
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("[KMS] Failed to add display. Error: {0}", e);
- }
-
- if (success && displays != null)
- {
- displays.Add(display);
- }
- else
- {
- Drm.ModeFreeConnector((IntPtr)connector);
- connector = null;
- }
- }
- }
-
- return has_displays;
- }
- }
- unsafe static bool QueryDisplay(int fd, ModeConnector* c, out LinuxDisplay display)
- {
- display = null;
-
- // Find corresponding encoder
- ModeEncoder* encoder = GetEncoder(fd, c);
- if (encoder == null)
- return false;
-
- ModeCrtc* crtc = GetCrtc(fd, encoder);
- if (crtc == null)
- return false;
-
- display = new LinuxDisplay(fd, (IntPtr)c, (IntPtr)encoder, (IntPtr)crtc);
- return true;
- }
- unsafe static ModeEncoder* GetEncoder(int fd, ModeConnector* c)
- {
- ModeEncoder* encoder = null;
- for (int i = 0; i < c->count_encoders && encoder == null; i++)
- {
- ModeEncoder* e = (ModeEncoder*)Drm.ModeGetEncoder(fd, *(c->encoders + i));
-
- if (e == null)
- continue;
-
- if (e->encoder_id == c->encoder_id)
- encoder = e;
- else
- Drm.ModeFreeEncoder((IntPtr)e);
- }
-
- if (encoder != null)
- Console.WriteLine("[KMS] Encoder {0} found for connector {1}", encoder->encoder_id, c->connector_id);
- else
- Console.WriteLine("[KMS] Failed to find encoder for connector {0}", c->connector_id);
-
- return encoder;
- }
-
- unsafe static ModeCrtc* GetCrtc(int fd, ModeEncoder* encoder)
- {
- ModeCrtc* crtc = (ModeCrtc*)Drm.ModeGetCrtc(fd, encoder->crtc_id);
- if (crtc != null)
- {
- Console.WriteLine("[KMS] CRTC {0} found for encoder {1}",
- encoder->crtc_id, encoder->encoder_id);
- }
- else
- {
- Console.WriteLine("[KMS] Failed to find crtc {0} for encoder {1}",
- encoder->crtc_id, encoder->encoder_id);
- }
- return crtc;
- }
-
- unsafe static void GetModes(LinuxDisplay display, DisplayResolution[] modes, out DisplayResolution current)
- {
- int mode_count = display.pConnector->count_modes;
- Console.WriteLine("[KMS] Display supports {0} mode(s)", mode_count);
- for (int i = 0; i < mode_count; i++)
- {
- ModeInfo* mode = display.pConnector->modes + i;
- if (mode != null)
- {
- Console.WriteLine("Mode {0}: {1}x{2} @{3}", i,
- mode->hdisplay, mode->vdisplay, mode->vrefresh);
- DisplayResolution res = GetDisplayResolution(mode);
- modes[i] = res;
- }
- }
-
- if (display.pCrtc->mode_valid != 0)
- {
- ModeInfo cmode = display.pCrtc->mode;
- current = GetDisplayResolution(&cmode);
- }
- else
- {
- current = GetDisplayResolution(display.pConnector->modes);
- }
- Console.WriteLine("Current mode: {0}", current.ToString());
- }
- unsafe static DisplayResolution GetDisplayResolution(ModeInfo* mode)
- {
- return new DisplayResolution(
- 0, 0,
- mode->hdisplay, mode->vdisplay,
- 32, // This is actually part of the framebuffer, not the DisplayResolution
- mode->vrefresh);
- }
-
- unsafe static ModeInfo* GetModeInfo(LinuxDisplay display, DisplayResolution resolution)
- {
- for (int i = 0; i < display.pConnector->count_modes; i++)
- {
- ModeInfo* mode = display.pConnector->modes + i;
- if (mode != null &&
- mode->hdisplay == resolution.Width &&
- mode->vdisplay == resolution.Height)
- {
- return mode;
- }
- }
- return null;
- }
-
- static int SetupDisplay(string gpu, out IntPtr gbm_device, out IntPtr egl_display)
- {
- Console.WriteLine("[KMS] Attempting to use gpu '{0}'.", gpu);
-
- gbm_device = IntPtr.Zero;
- egl_display = IntPtr.Zero;
-
- int fd = Libc.open(gpu, OpenFlags.ReadWrite | OpenFlags.CloseOnExec);
- if (fd < 0)
- {
- Console.WriteLine("[KMS] Failed to open gpu");
- return fd;
- }
- Console.WriteLine("[KMS] GPU '{0}' opened as fd:{1}", gpu, fd);
-
- gbm_device = Gbm.CreateDevice(fd);
- if (gbm_device == IntPtr.Zero)
- {
- throw new NotSupportedException("[KMS] Failed to create GBM device");
- }
- Console.WriteLine("[KMS] GBM {0:x} created successfully; ", gbm_device);
-
- egl_display = Egl.GetDisplay(gbm_device);
- if (egl_display == IntPtr.Zero)
- {
- throw new NotSupportedException("[KMS] Failed to create EGL display");
- }
- Console.WriteLine("[KMS] EGL display {0:x} created successfully", egl_display);
-
- int major, minor;
- if (!Egl.Initialize(egl_display, out major, out minor))
- {
- ErrorCode error = Egl.GetError();
- throw new NotSupportedException("[KMS] Failed to initialize EGL display. Error code: " + error);
- }
- Console.WriteLine("[KMS] EGL {0}.{1} initialized successfully on display {2:x}", major, minor, egl_display);
-
- return fd;
- }
}
}
+++ /dev/null
-//
-// Mono.Cairo.Antialias.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- [Serializable]
- public enum Antialias
- {
- Default,
- None,
- Gray,
- Subpixel,
- }
-}
+++ /dev/null
-//
-// Cairo.cs - a simplistic binding of the Cairo API to C#.
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-// John Luke (john.luke@gmail.com)
-// Alp Toker (alp@atoker.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2005 John Luke
-// Copyright (C) 2006 Alp Toker
-//
-// 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 Cairo
-{
- public static class CairoAPI {
- static public int Version {
- get {
- return Cairo.NativeMethods.cairo_version ();
- }
- }
-
- static public string VersionString {
- get {
- IntPtr x = Cairo.NativeMethods.cairo_version_string ();
- return Marshal.PtrToStringAnsi (x);
- }
- }
- }
-}
+++ /dev/null
-//
-// CairoDebug.cs
-//
-// Author:
-// Michael Hutchinson (mhutch@xamarin.com)
-//
-// Copyright (C) 2013 Xamarin Inc. (http://www.xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- static class CairoDebug
- {
- static System.Collections.Generic.Dictionary<IntPtr,string> traces;
-
- public static readonly bool Enabled;
-
- static CairoDebug ()
- {
- var dbg = Environment.GetEnvironmentVariable ("MONO_CAIRO_DEBUG_DISPOSE");
- if (dbg == null)
- return;
- Enabled = true;
- traces = new System.Collections.Generic.Dictionary<IntPtr,string> ();
- }
-
- public static void OnAllocated (IntPtr obj)
- {
- if (!Enabled)
- throw new InvalidOperationException ();
-
- traces[obj] = Environment.StackTrace;
- }
-
- public static void OnDisposed<T> (IntPtr obj, bool disposing)
- {
- if (disposing && !Enabled)
- throw new InvalidOperationException ();
-
- if (Environment.HasShutdownStarted)
- return;
-
- if (!disposing) {
- Console.Error.WriteLine ("{0} is leaking, programmer is missing a call to Dispose", typeof(T).FullName);
- if (Enabled) {
- string val;
- if (traces.TryGetValue (obj, out val)) {
- Console.Error.WriteLine ("Allocated from:");
- Console.Error.WriteLine (val);
- }
- } else {
- Console.Error.WriteLine ("Set MONO_CAIRO_DEBUG_DISPOSE to track allocation traces");
- }
- }
-
- if (Enabled)
- traces.Remove (obj);
- }
- }
-
-}
+++ /dev/null
-//
-// Mono.Cairo.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 Cairo {
-
- public struct Color
- {
- public Color(double r, double g, double b) : this (r, g, b, 1.0)
- {
- }
-
- public Color(double r, double g, double b, double a)
- {
- this.r = r;
- this.g = g;
- this.b = b;
- this.a = a;
- }
-
- double r, g, b, a;
-
- public double R {
- get { return r; }
- set { r = value; }
- }
-
- public double G {
- get { return g; }
- set { g = value; }
- }
-
- public double B {
- get { return b; }
- set { b = value; }
- }
-
- public double A {
- get { return a; }
- set { a = value; }
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Content.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- //[Flags]
- [Serializable]
- public enum Content
- {
- Color = 0x1000,
- Alpha = 0x2000,
- ColorAlpha = 0x3000,
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.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.
-//
-
-using System;
-using System.Runtime.InteropServices;
-using System.Text;
-using Cairo;
-
-namespace Cairo {
-
- [Obsolete ("Renamed Cairo.Context per suggestion from cairo binding guidelines.")]
- public class Graphics : Context {
- public Graphics (IntPtr state) : base (state) {}
- public Graphics (Surface surface) : base (surface) {}
- }
-
- public class Context : IDisposable
- {
- IntPtr handle = IntPtr.Zero;
-
- static int native_glyph_size, c_compiler_long_size;
-
- static Context ()
- {
- //
- // This is used to determine what kind of structure
- // we should use to marshal Glyphs, as the public
- // definition in Cairo uses `long', which can be
- // 32 bits or 64 bits depending on the platform.
- //
- // We assume that sizeof(long) == sizeof(void*)
- // except in the case of Win64 where sizeof(long)
- // is 32 bits
- //
- int ptr_size = Marshal.SizeOf (typeof (IntPtr));
-
- PlatformID platform = Environment.OSVersion.Platform;
- if (platform == PlatformID.Win32NT ||
- platform == PlatformID.Win32S ||
- platform == PlatformID.Win32Windows ||
- platform == PlatformID.WinCE ||
- ptr_size == 4){
- c_compiler_long_size = 4;
- native_glyph_size = Marshal.SizeOf (typeof (NativeGlyph_4byte_longs));
- } else {
- c_compiler_long_size = 8;
- native_glyph_size = Marshal.SizeOf (typeof (Glyph));
- }
- }
-
- public Context (Surface surface) : this (NativeMethods.cairo_create (surface.Handle), true)
- {
- }
-
-
- public Context (IntPtr handle, bool owner)
- {
- this.handle = handle;
- if (!owner)
- NativeMethods.cairo_reference (handle);
- if (CairoDebug.Enabled)
- CairoDebug.OnAllocated (handle);
- }
-
- [Obsolete]
- public Context (IntPtr state) : this (state, true)
- {
- }
-
- ~Context ()
- {
- Dispose (false);
- }
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- protected virtual void Dispose (bool disposing)
- {
- if (!disposing || CairoDebug.Enabled)
- CairoDebug.OnDisposed<Context> (handle, disposing);
-
- if (!disposing|| handle == IntPtr.Zero)
- return;
-
- NativeMethods.cairo_destroy (handle);
- handle = IntPtr.Zero;
-
- }
-
- public void Save ()
- {
- NativeMethods.cairo_save (handle);
- }
-
- public void Restore ()
- {
- NativeMethods.cairo_restore (handle);
- }
-
- public Antialias Antialias {
- get { return NativeMethods.cairo_get_antialias (handle); }
- set { NativeMethods.cairo_set_antialias (handle, value); }
- }
-
- public Cairo.Status Status {
- get {
- return NativeMethods.cairo_status (handle);
- }
- }
-
- public IntPtr Handle {
- get {
- return handle;
- }
- }
-
- public Operator Operator {
- set {
- NativeMethods.cairo_set_operator (handle, value);
- }
-
- get {
- return NativeMethods.cairo_get_operator (handle);
- }
- }
-
- [Obsolete ("Use SetSourceColor method")]
- public Color Color {
- set {
- SetSourceColor (value);
- }
- }
-
- [Obsolete ("Use SetSourceRGBA method")]
- public Cairo.Color ColorRgb {
- set {
- Color = new Color (value.R, value.G, value.B);
- }
- }
-
- public double Tolerance {
- get {
- return NativeMethods.cairo_get_tolerance (handle);
- }
-
- set {
- NativeMethods.cairo_set_tolerance (handle, value);
- }
- }
-
- public Cairo.FillRule FillRule {
- set {
- NativeMethods.cairo_set_fill_rule (handle, value);
- }
-
- get {
- return NativeMethods.cairo_get_fill_rule (handle);
- }
- }
-
- public double LineWidth {
- set {
- NativeMethods.cairo_set_line_width (handle, value);
- }
-
- get {
- return NativeMethods.cairo_get_line_width (handle);
- }
- }
-
- public Cairo.LineCap LineCap {
- set {
- NativeMethods.cairo_set_line_cap (handle, value);
- }
-
- get {
- return NativeMethods.cairo_get_line_cap (handle);
- }
- }
-
- public Cairo.LineJoin LineJoin {
- set {
- NativeMethods.cairo_set_line_join (handle, value);
- }
-
- get {
- return NativeMethods.cairo_get_line_join (handle);
- }
- }
-
- public void SetDash (double [] dashes, double offset)
- {
- NativeMethods.cairo_set_dash (handle, dashes, dashes.Length, offset);
- }
-
- [Obsolete("Use GetSource/SetSource")]
- public Pattern Pattern {
- set {
- SetSource (value);
- }
- get {
- return GetSource ();
- }
- }
-
- //This is obsolete because it wasn't obvious it needed to be disposed
- [Obsolete("Use GetSource/SetSource")]
- public Pattern Source {
- set {
- SetSource (value);
- }
- get {
- return GetSource ();
- }
- }
-
- public void SetSource (Pattern source)
- {
- NativeMethods.cairo_set_source (handle, source.Handle);
- }
-
- public Pattern GetSource ()
- {
- var ptr = NativeMethods.cairo_get_source (handle);
- return Cairo.Pattern.Lookup (ptr, false);
- }
-
- public double MiterLimit {
- set {
- NativeMethods.cairo_set_miter_limit (handle, value);
- }
-
- get {
- return NativeMethods.cairo_get_miter_limit (handle);
- }
- }
-
- public PointD CurrentPoint {
- get {
- double x, y;
- NativeMethods.cairo_get_current_point (handle, out x, out y);
- return new PointD (x, y);
- }
- }
-
- public bool HasCurrentPoint {
- get {
- return NativeMethods.cairo_has_current_point (handle);
- }
- }
-
- [Obsolete ("Use GetTarget/SetTarget")]
- public Cairo.Surface Target {
- set {
- if (handle != IntPtr.Zero)
- NativeMethods.cairo_destroy (handle);
-
- handle = NativeMethods.cairo_create (value.Handle);
- }
-
- get {
- return GetTarget ();
- }
- }
-
- public Surface GetTarget ()
- {
- return Surface.Lookup (NativeMethods.cairo_get_target (handle), false);
- }
-
- public void SetTarget (Surface target)
- {
- if (handle != IntPtr.Zero)
- NativeMethods.cairo_destroy (handle);
- handle = NativeMethods.cairo_create (target.Handle);
- }
-
- [Obsolete("Use GetScaledFont/SetScaledFont")]
- public ScaledFont ScaledFont {
- set {
- SetScaledFont (value);
- }
-
- get {
- return GetScaledFont ();
- }
- }
-
- public ScaledFont GetScaledFont ()
- {
- return new ScaledFont (NativeMethods.cairo_get_scaled_font (handle), false);
- }
-
- public void SetScaledFont (ScaledFont font)
- {
- NativeMethods.cairo_set_scaled_font (handle, font.Handle);
- }
-
- public uint ReferenceCount {
- get { return NativeMethods.cairo_get_reference_count (handle); }
- }
-
- public void SetSourceColor (Color color)
- {
- NativeMethods.cairo_set_source_rgba (handle, color.R, color.G, color.B, color.A);
- }
-
- public void SetSourceRGB (double r, double g, double b)
- {
- NativeMethods.cairo_set_source_rgb (handle, r, g, b);
- }
-
- public void SetSourceRGBA (double r, double g, double b, double a)
- {
- NativeMethods.cairo_set_source_rgba (handle, r, g, b, a);
- }
-
- //[Obsolete ("Use SetSource method (with double parameters)")]
- public void SetSourceSurface (Surface source, int x, int y)
- {
- NativeMethods.cairo_set_source_surface (handle, source.Handle, x, y);
- }
-
- public void SetSource (Surface source, double x, double y)
- {
- NativeMethods.cairo_set_source_surface (handle, source.Handle, x, y);
- }
-
- public void SetSource (Surface source)
- {
- NativeMethods.cairo_set_source_surface (handle, source.Handle, 0, 0);
- }
-
-#region Path methods
-
- public void NewPath ()
- {
- NativeMethods.cairo_new_path (handle);
- }
-
- public void NewSubPath ()
- {
- NativeMethods.cairo_new_sub_path (handle);
- }
-
- public void MoveTo (PointD p)
- {
- MoveTo (p.X, p.Y);
- }
-
- public void MoveTo (double x, double y)
- {
- NativeMethods.cairo_move_to (handle, x, y);
- }
-
- public void LineTo (PointD p)
- {
- LineTo (p.X, p.Y);
- }
-
- public void LineTo (double x, double y)
- {
- NativeMethods.cairo_line_to (handle, x, y);
- }
-
- public void CurveTo (PointD p1, PointD p2, PointD p3)
- {
- CurveTo (p1.X, p1.Y, p2.X, p2.Y, p3.X, p3.Y);
- }
-
- public void CurveTo (double x1, double y1, double x2, double y2, double x3, double y3)
- {
- NativeMethods.cairo_curve_to (handle, x1, y1, x2, y2, x3, y3);
- }
-
- public void RelMoveTo (Distance d)
- {
- RelMoveTo (d.Dx, d.Dy);
- }
-
- public void RelMoveTo (double dx, double dy)
- {
- NativeMethods.cairo_rel_move_to (handle, dx, dy);
- }
-
- public void RelLineTo (Distance d)
- {
- RelLineTo (d.Dx, d.Dy);
- }
-
- public void RelLineTo (double dx, double dy)
- {
- NativeMethods.cairo_rel_line_to (handle, dx, dy);
- }
-
- public void RelCurveTo (Distance d1, Distance d2, Distance d3)
- {
- RelCurveTo (d1.Dx, d1.Dy, d2.Dx, d2.Dy, d3.Dx, d3.Dy);
- }
-
- public void RelCurveTo (double dx1, double dy1, double dx2, double dy2, double dx3, double dy3)
- {
- NativeMethods.cairo_rel_curve_to (handle, dx1, dy1, dx2, dy2, dx3, dy3);
- }
-
- public void Arc (double xc, double yc, double radius, double angle1, double angle2)
- {
- NativeMethods.cairo_arc (handle, xc, yc, radius, angle1, angle2);
- }
-
- public void ArcNegative (double xc, double yc, double radius, double angle1, double angle2)
- {
- NativeMethods.cairo_arc_negative (handle, xc, yc, radius, angle1, angle2);
- }
-
- public void Rectangle (Rectangle rectangle)
- {
- Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
- }
-
- public void Rectangle (PointD p, double width, double height)
- {
- Rectangle (p.X, p.Y, width, height);
- }
-
- public void Rectangle (double x, double y, double width, double height)
- {
- NativeMethods.cairo_rectangle (handle, x, y, width, height);
- }
-
- public void ClosePath ()
- {
- NativeMethods.cairo_close_path (handle);
- }
-
- public Path CopyPath ()
- {
- return new Path (NativeMethods.cairo_copy_path (handle));
- }
-
- public Path CopyPathFlat ()
- {
- return new Path (NativeMethods.cairo_copy_path_flat (handle));
- }
-
- public void AppendPath (Path path)
- {
- NativeMethods.cairo_append_path (handle, path.Handle);
- }
-
-#endregion
-
-#region Painting Methods
- public void Paint ()
- {
- NativeMethods.cairo_paint (handle);
- }
-
- public void PaintWithAlpha (double alpha)
- {
- NativeMethods.cairo_paint_with_alpha (handle, alpha);
- }
-
- public void Mask (Pattern pattern)
- {
- NativeMethods.cairo_mask (handle, pattern.Handle);
- }
-
- public void MaskSurface (Surface surface, double surface_x, double surface_y)
- {
- NativeMethods.cairo_mask_surface (handle, surface.Handle, surface_x, surface_y);
- }
-
- public void Stroke ()
- {
- NativeMethods.cairo_stroke (handle);
- }
-
- public void StrokePreserve ()
- {
- NativeMethods.cairo_stroke_preserve (handle);
- }
-
- public Rectangle StrokeExtents ()
- {
- double x1, y1, x2, y2;
- NativeMethods.cairo_stroke_extents (handle, out x1, out y1, out x2, out y2);
- return new Rectangle (x1, y1, x2 - x1, y2 - y1);
- }
-
- public void Fill ()
- {
- NativeMethods.cairo_fill (handle);
- }
-
- public Rectangle FillExtents ()
- {
- double x1, y1, x2, y2;
- NativeMethods.cairo_fill_extents (handle, out x1, out y1, out x2, out y2);
- return new Rectangle (x1, y1, x2 - x1, y2 - y1);
- }
-
- public void FillPreserve ()
- {
- NativeMethods.cairo_fill_preserve (handle);
- }
-
-#endregion
-
- public void Clip ()
- {
- NativeMethods.cairo_clip (handle);
- }
-
- public void ClipPreserve ()
- {
- NativeMethods.cairo_clip_preserve (handle);
- }
-
- public void ResetClip ()
- {
- NativeMethods.cairo_reset_clip (handle);
- }
-
- public bool InClip (double x, double y)
- {
- return NativeMethods.cairo_in_clip (handle, x, y);
- }
-
- public bool InStroke (double x, double y)
- {
- return NativeMethods.cairo_in_stroke (handle, x, y);
- }
-
- public bool InFill (double x, double y)
- {
- return NativeMethods.cairo_in_fill (handle, x, y);
- }
-
- public Pattern PopGroup ()
- {
- return Pattern.Lookup (NativeMethods.cairo_pop_group (handle), true);
- }
-
- public void PopGroupToSource ()
- {
- NativeMethods.cairo_pop_group_to_source (handle);
- }
-
- public void PushGroup ()
- {
- NativeMethods.cairo_push_group (handle);
- }
-
- public void PushGroup (Content content)
- {
- NativeMethods.cairo_push_group_with_content (handle, content);
- }
-
- [Obsolete ("Use GetGroupTarget()")]
- public Surface GroupTarget {
- get {
- return GetGroupTarget ();
- }
- }
-
- public Surface GetGroupTarget ()
- {
- IntPtr surface = NativeMethods.cairo_get_group_target (handle);
- return Surface.Lookup (surface, false);
- }
-
- public void Rotate (double angle)
- {
- NativeMethods.cairo_rotate (handle, angle);
- }
-
- public void Scale (double sx, double sy)
- {
- NativeMethods.cairo_scale (handle, sx, sy);
- }
-
- public void Translate (double tx, double ty)
- {
- NativeMethods.cairo_translate (handle, tx, ty);
- }
-
- public void Transform (Matrix m)
- {
- NativeMethods.cairo_transform (handle, m);
- }
-
- [Obsolete("Use UserToDevice instead")]
- public void TransformPoint (ref double x, ref double y)
- {
- NativeMethods.cairo_user_to_device (handle, ref x, ref y);
- }
-
- [Obsolete("Use UserToDeviceDistance instead")]
- public void TransformDistance (ref double dx, ref double dy)
- {
- NativeMethods.cairo_user_to_device_distance (handle, ref dx, ref dy);
- }
-
- [Obsolete("Use InverseTransformPoint instead")]
- public void InverseTransformPoint (ref double x, ref double y)
- {
- NativeMethods.cairo_device_to_user (handle, ref x, ref y);
- }
-
- [Obsolete("Use DeviceToUserDistance instead")]
- public void InverseTransformDistance (ref double dx, ref double dy)
- {
- NativeMethods.cairo_device_to_user_distance (handle, ref dx, ref dy);
- }
-
- public void UserToDevice (ref double x, ref double y)
- {
- NativeMethods.cairo_user_to_device (handle, ref x, ref y);
- }
-
- public void UserToDeviceDistance (ref double dx, ref double dy)
- {
- NativeMethods.cairo_user_to_device_distance (handle, ref dx, ref dy);
- }
-
- public void DeviceToUser (ref double x, ref double y)
- {
- NativeMethods.cairo_device_to_user (handle, ref x, ref y);
- }
-
- public void DeviceToUserDistance (ref double dx, ref double dy)
- {
- NativeMethods.cairo_device_to_user_distance (handle, ref dx, ref dy);
- }
-
- public Matrix Matrix {
- set {
- NativeMethods.cairo_set_matrix (handle, value);
- }
-
- get {
- Matrix m = new Matrix();
- NativeMethods.cairo_get_matrix (handle, m);
- return m;
- }
- }
-
- public void SetFontSize (double scale)
- {
- NativeMethods.cairo_set_font_size (handle, scale);
- }
-
- public void IdentityMatrix ()
- {
- NativeMethods.cairo_identity_matrix (handle);
- }
-
- [Obsolete ("Use SetFontSize() instead.")]
- public void FontSetSize (double scale)
- {
- SetFontSize (scale);
- }
-
- [Obsolete ("Use SetFontSize() instead.")]
- public double FontSize {
- set { SetFontSize (value); }
- }
-
- public Matrix FontMatrix {
- get {
- Matrix m;
- NativeMethods.cairo_get_font_matrix (handle, out m);
- return m;
- }
- set { NativeMethods.cairo_set_font_matrix (handle, value); }
- }
-
- public FontOptions FontOptions {
- get {
- FontOptions options = new FontOptions ();
- NativeMethods.cairo_get_font_options (handle, options.Handle);
- return options;
- }
- set { NativeMethods.cairo_set_font_options (handle, value.Handle); }
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct NativeGlyph_4byte_longs {
- public int index;
- public double x;
- public double y;
-
- public NativeGlyph_4byte_longs (Glyph source)
- {
- index = (int) source.index;
- x = source.x;
- y = source.y;
- }
- }
-
- static internal IntPtr FromGlyphToUnManagedMemory(Glyph [] glyphs)
- {
- IntPtr dest = Marshal.AllocHGlobal (native_glyph_size * glyphs.Length);
- long pos = dest.ToInt64();
-
- if (c_compiler_long_size == 8){
- foreach (Glyph g in glyphs){
- Marshal.StructureToPtr (g, (IntPtr)pos, false);
- pos += native_glyph_size;
- }
- } else {
- foreach (Glyph g in glyphs){
- NativeGlyph_4byte_longs n = new NativeGlyph_4byte_longs (g);
-
- Marshal.StructureToPtr (n, (IntPtr)pos, false);
- pos += native_glyph_size;
- }
- }
-
- return dest;
- }
-
- public void ShowGlyphs (Glyph[] glyphs)
- {
- IntPtr ptr;
-
- ptr = FromGlyphToUnManagedMemory (glyphs);
-
- NativeMethods.cairo_show_glyphs (handle, ptr, glyphs.Length);
-
- Marshal.FreeHGlobal (ptr);
- }
-
- [Obsolete("The matrix argument was never used, use ShowGlyphs(Glyphs []) instead")]
- public void ShowGlyphs (Matrix matrix, Glyph[] glyphs)
- {
- ShowGlyphs (glyphs);
- }
-
- [Obsolete("The matrix argument was never used, use GlyphPath(Glyphs []) instead")]
- public void GlyphPath (Matrix matrix, Glyph[] glyphs)
- {
- GlyphPath (glyphs);
- }
-
- public void GlyphPath (Glyph[] glyphs)
- {
- IntPtr ptr;
-
- ptr = FromGlyphToUnManagedMemory (glyphs);
-
- NativeMethods.cairo_glyph_path (handle, ptr, glyphs.Length);
-
- Marshal.FreeHGlobal (ptr);
-
- }
-
- public FontExtents FontExtents {
- get {
- FontExtents f_extents;
- NativeMethods.cairo_font_extents (handle, out f_extents);
- return f_extents;
- }
- }
-
- public void CopyPage ()
- {
- NativeMethods.cairo_copy_page (handle);
- }
-
- [Obsolete ("Use SelectFontFace() instead.")]
- public void FontFace (string family, FontSlant slant, FontWeight weight)
- {
- SelectFontFace (family, slant, weight);
- }
-
- [Obsolete("Use GetFontFace/SetFontFace")]
- public FontFace ContextFontFace {
- get {
- return GetContextFontFace ();
- }
- set {
- SetContextFontFace (value);
- }
- }
-
- public FontFace GetContextFontFace ()
- {
- return Cairo.FontFace.Lookup (NativeMethods.cairo_get_font_face (handle), false);
- }
-
- public void SetContextFontFace (FontFace value)
- {
- NativeMethods.cairo_set_font_face (handle, value == null ? IntPtr.Zero : value.Handle);
- }
-
- public void SelectFontFace (string family, FontSlant slant, FontWeight weight)
- {
- NativeMethods.cairo_select_font_face (handle, family, slant, weight);
- }
-
- public void ShowPage ()
- {
- NativeMethods.cairo_show_page (handle);
- }
-
- private static byte[] TerminateUtf8(byte[] utf8)
- {
- if (utf8.Length > 0 && utf8[utf8.Length - 1] == 0)
- return utf8;
- var termedArray = new byte[utf8.Length + 1];
- Array.Copy(utf8, termedArray, utf8.Length);
- termedArray[utf8.Length] = 0;
- return termedArray;
- }
-
- 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;
- }
-
- public void ShowText(string str)
- {
- NativeMethods.cairo_show_text (handle, TerminateUtf8(str));
- }
-
- public void ShowText(byte[] utf8)
- {
- NativeMethods.cairo_show_text (handle, TerminateUtf8(utf8));
- }
-
- public void TextPath(string str)
- {
- NativeMethods.cairo_text_path (handle, TerminateUtf8(str));
- }
-
- public void TextPath(byte[] utf8)
- {
- NativeMethods.cairo_text_path (handle, TerminateUtf8(utf8));
- }
-
- public TextExtents TextExtents(string s)
- {
- TextExtents extents;
- NativeMethods.cairo_text_extents (handle, TerminateUtf8(s), out extents);
- return extents;
- }
-
- public TextExtents TextExtents(byte[] utf8)
- {
- TextExtents extents;
- NativeMethods.cairo_text_extents (handle, TerminateUtf8(utf8), out extents);
- return extents;
- }
-
- public TextExtents GlyphExtents (Glyph[] glyphs)
- {
- IntPtr ptr = FromGlyphToUnManagedMemory (glyphs);
-
- TextExtents extents;
-
- NativeMethods.cairo_glyph_extents (handle, ptr, glyphs.Length, out extents);
-
- Marshal.FreeHGlobal (ptr);
-
- return extents;
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Device.cs
-//
-// Authors:
-// JP Bruyère (jp_bruyere@hotmail.com)
-//
-// This is an OO wrapper API for the Cairo API
-//
-// Copyright (C) 2016 JP 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 Cairo
-{
- public class Device : IDisposable
- {
- IntPtr handle = IntPtr.Zero;
-
- protected Device()
- {
- }
-
- protected Device (IntPtr ptr) : this (ptr, true)
- {
- }
-
- protected Device (IntPtr handle, bool owner)
- {
- this.handle = handle;
- if (!owner)
- NativeMethods.cairo_device_reference (handle);
- if (CairoDebug.Enabled)
- CairoDebug.OnAllocated (handle);
- }
-
- ~Device ()
- {
- Dispose (false);
- }
-
- public IntPtr Handle {
- get {
- return handle;
- }
- }
- public string Status {
- get {
- return System.Runtime.InteropServices.Marshal.PtrToStringAuto(NativeMethods.cairo_status_to_string (NativeMethods.cairo_device_status (handle)));
- }
- }
- public void SetThreadAware (bool value){
- NativeMethods.cairo_gl_device_set_thread_aware (handle, value ? 1 : 0);
- }
- public Status Acquire()
- {
- return NativeMethods.cairo_device_acquire (handle);
- }
- public void Release()
- {
- NativeMethods.cairo_device_release (handle);
- }
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- protected virtual void Dispose (bool disposing)
- {
- if (!disposing || CairoDebug.Enabled)
- CairoDebug.OnDisposed<Device> (handle, disposing);
-
- if (!disposing || handle == IntPtr.Zero)
- return;
-
- NativeMethods.cairo_device_destroy (handle);
- handle = IntPtr.Zero;
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.DirectFBSurface.cs
-//
-// Authors:
-// Alp Toker
-//
-// (C) Alp Toker, 2006.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
- public class DirectFBSurface : Surface
- {
- internal DirectFBSurface (IntPtr handle, bool owns) : base (handle, owns)
- {
- }
-
- public DirectFBSurface (IntPtr dfb, IntPtr dfb_surface)
- : base (NativeMethods.cairo_directfb_surface_create (dfb, dfb_surface), true)
- {
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.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 Cairo {
-
- public struct Distance
- {
- public Distance (double dx, double dy)
- {
- this.dx = dx;
- this.dy = dy;
- }
-
- double dx, dy;
- public double Dx {
- get { return dx; }
- set { dx = value; }
- }
-
- public double Dy {
- get { return dy; }
- set { dy = value; }
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Device.cs
-//
-// Authors:
-// JP Bruyère (jp_bruyere@hotmail.com)
-//
-// This is an OO wrapper API for the Cairo API
-//
-// Copyright (C) 2016 JP 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 Cairo
-{
- public class EGLDevice : Device
- {
- public EGLDevice (IntPtr dpy, IntPtr gl_ctx) : base (NativeMethods.cairo_egl_device_create (dpy, gl_ctx), true)
- {
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.Extend.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-// John Luke (john.luke@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2005 John Luke
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- [Serializable]
- public enum Extend
- {
- None,
- Repeat,
- Reflect,
- Pad,
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.FillRule.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- [Serializable]
- public enum FillRule
- {
- Winding,
- EvenOdd
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Filter.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- [Serializable]
- public enum Filter
- {
- Fast,
- Good,
- Best,
- Nearest,
- Bilinear,
- Gaussian,
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.FontExtents.cs
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-//
-// This is a simplistic binding of the Cairo API to C#. All functions
-// in cairo.h are transcribed into their C# equivelants
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace Cairo
-{
- [StructLayout (LayoutKind.Sequential)]
- public struct FontExtents
- {
- double ascent;
- double descent;
- double height;
- double maxXAdvance;
- double maxYAdvance;
-
- public double Ascent {
- get { return ascent; }
- set { ascent = value; }
- }
-
- public double Descent {
- get { return descent; }
- set { descent = value; }
- }
-
- public double Height {
- get { return height; }
- set { height = value; }
- }
-
- public double MaxXAdvance {
- get { return maxXAdvance; }
- set { maxXAdvance = value; }
- }
-
- public double MaxYAdvance {
- get { return maxYAdvance; }
- set { maxYAdvance = value; }
- }
-
- public FontExtents (double ascent, double descent, double height, double maxXAdvance, double maxYAdvance)
- {
- this.ascent = ascent;
- this.descent = descent;
- this.height = height;
- this.maxXAdvance = maxXAdvance;
- this.maxYAdvance = maxYAdvance;
- }
-
- public override bool Equals (object obj)
- {
- if (obj is FontExtents)
- return this == (FontExtents) obj;
- return false;
- }
-
- public override int GetHashCode ()
- {
- return (int) Ascent ^ (int) Descent ^ (int) Height ^ (int) MaxXAdvance ^ (int) MaxYAdvance;
- }
-
- public static bool operator == (FontExtents extents, FontExtents other)
- {
- return extents.Ascent == other.Ascent && extents.Descent == other.Descent && extents.Height == other.Height && extents.MaxXAdvance == other.MaxXAdvance && extents.MaxYAdvance == other.MaxYAdvance;
- }
-
- public static bool operator != (FontExtents extents, FontExtents other)
- {
- return !(extents == other);
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.FontFace.cs
-//
-// Author:
-// Alp Toker (alp@atoker.com)
-// Miguel de Icaza (miguel@novell.com)
-//
-// (C) Ximian Inc, 2003.
-//
-// This is an OO wrapper API for the Cairo API.
-//
-// Copyright (C) 2004, 2007 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-using System;
-
-namespace Cairo
-{
- public class FontFace : IDisposable
- {
- IntPtr handle;
-
- internal static FontFace Lookup (IntPtr handle, bool owner)
- {
- if (handle == IntPtr.Zero)
- return null;
- return new FontFace (handle, owner);
- }
-
- ~FontFace ()
- {
- Dispose (false);
- }
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- protected virtual void Dispose (bool disposing)
- {
- if (!disposing || CairoDebug.Enabled)
- CairoDebug.OnDisposed<FontFace> (handle, disposing);
-
- if (!disposing|| handle == IntPtr.Zero)
- return;
-
- NativeMethods.cairo_font_face_destroy (handle);
- handle = IntPtr.Zero;
- }
-
- [Obsolete]
- public FontFace (IntPtr handle) : this (handle, true)
- {
- }
-
- public FontFace (IntPtr handle, bool owned)
- {
- this.handle = handle;
- if (!owned)
- NativeMethods.cairo_font_face_reference (handle);
- if (CairoDebug.Enabled)
- CairoDebug.OnAllocated (handle);
- }
-
- public IntPtr Handle {
- get {
- return handle;
- }
- }
-
- public Status Status {
- get {
- return NativeMethods.cairo_font_face_status (handle);
- }
- }
-
- public FontType FontType {
- get {
- return NativeMethods.cairo_font_face_get_type (handle);
- }
- }
-
- public uint ReferenceCount {
- get { return NativeMethods.cairo_font_face_get_reference_count (handle); }
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.FontOptions.cs
-//
-// Author:
-// John Luke (john.luke@gmail.com)
-//
-// (C) John Luke 2005.
-//
-// 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 Cairo
-{
- public class FontOptions : IDisposable
- {
- IntPtr handle;
-
- public FontOptions () : this (NativeMethods.cairo_font_options_create ())
- {
- }
-
- ~FontOptions ()
- {
- Dispose (false);
- }
-
- internal FontOptions (IntPtr handle)
- {
- this.handle = handle;
- if (CairoDebug.Enabled)
- CairoDebug.OnAllocated (handle);
- }
-
- public FontOptions Copy ()
- {
- return new FontOptions (NativeMethods.cairo_font_options_copy (handle));
- }
-
- [Obsolete ("Use Dispose()")]
- public void Destroy ()
- {
- Dispose ();
- }
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- protected virtual void Dispose (bool disposing)
- {
- if (!disposing || CairoDebug.Enabled)
- CairoDebug.OnDisposed<FontOptions> (handle, disposing);
-
- if (!disposing|| handle == IntPtr.Zero)
- return;
-
- NativeMethods.cairo_font_options_destroy (handle);
- handle = IntPtr.Zero;
- }
-
- public static bool operator == (FontOptions options, FontOptions other)
- {
- return Equals (options, other);
- }
-
- public static bool operator != (FontOptions options, FontOptions other)
- {
- return !(options == other);
- }
-
- public override bool Equals (object other)
- {
- return Equals (other as FontOptions);
- }
-
- bool Equals (FontOptions options)
- {
- return options != null && NativeMethods.cairo_font_options_equal (Handle, options.Handle);
- }
-
- public IntPtr Handle {
- get { return handle; }
- }
-
- public override int GetHashCode ()
- {
- return (int) NativeMethods.cairo_font_options_hash (handle);
- }
-
- public void Merge (FontOptions other)
- {
- if (other == null)
- throw new ArgumentNullException ("other");
- NativeMethods.cairo_font_options_merge (handle, other.Handle);
- }
-
- public Antialias Antialias {
- get { return NativeMethods.cairo_font_options_get_antialias (handle); }
- set { NativeMethods.cairo_font_options_set_antialias (handle, value); }
- }
-
- public HintMetrics HintMetrics {
- get { return NativeMethods.cairo_font_options_get_hint_metrics (handle);}
- set { NativeMethods.cairo_font_options_set_hint_metrics (handle, value); }
- }
-
- public HintStyle HintStyle {
- get { return NativeMethods.cairo_font_options_get_hint_style (handle);}
- set { NativeMethods.cairo_font_options_set_hint_style (handle, value); }
- }
-
- public Status Status {
- get { return NativeMethods.cairo_font_options_status (handle); }
- }
-
- public SubpixelOrder SubpixelOrder {
- get { return NativeMethods.cairo_font_options_get_subpixel_order (handle);}
- set { NativeMethods.cairo_font_options_set_subpixel_order (handle, value); }
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.FontSlant.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- [Serializable]
- public enum FontSlant
- {
- Normal,
- Italic,
- Oblique
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.FontType.cs
-//
-// Authors:
-// John Luke
-//
-// (C) John Luke, 2006.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- [Serializable]
- public enum FontType
- {
- Toy,
- FreeType,
- Win32,
- Atsui,
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.FontWeight.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- [Serializable]
- public enum FontWeight
- {
- Normal,
- Bold,
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Format.cs
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- [Serializable]
- public enum Format
- {
- Argb32 = 0,
- Rgb24 = 1,
- A8 = 2,
- A1 = 3,
- Rgb16565 = 4,
-
- //[Obsolete ("Use Argb32")]
- ARGB32 = Argb32,
- //[Obsolete ("Use Rgb24")]
- RGB24 = Rgb24,
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.GLSurface.cs
-//
-// Authors:
-// JP Bruyère (jp_bruyere@hotmail.com)
-//
-// This is an OO wrapper API for the Cairo API
-//
-// Copyright (C) 2016 JP 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 Cairo {
-
- public class GLSurface : Surface
- {
-
- public GLSurface (IntPtr ptr, bool own) : base (ptr, own)
- {}
-
- public GLSurface (Device device, Cairo.Content content, uint tex, int width, int height)
- : base (NativeMethods.cairo_gl_surface_create_for_texture (device.Handle, (uint)content, tex, width, height), true)
- {}
-
- public GLSurface (EGLDevice device, IntPtr eglSurf, int width, int height)
- : base (NativeMethods.cairo_gl_surface_create_for_egl (device.Handle, eglSurf, width, height), true)
- {}
-
- public GLSurface (GLXDevice device, IntPtr window, int width, int height)
- : base (NativeMethods.cairo_gl_surface_create_for_window (device.Handle, window, width, height),true)
- {}
-
- public GLSurface (WGLDevice device, IntPtr hdc, int width, int height)
- : base (NativeMethods.cairo_gl_surface_create_for_dc (device.Handle, hdc, width, height), true)
- {}
-
- public void SwapBuffers(){
- NativeMethods.cairo_gl_surface_swapbuffers (this.Handle);
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Device.cs
-//
-// Authors:
-// JP Bruyère (jp_bruyere@hotmail.com)
-//
-// This is an OO wrapper API for the Cairo API
-//
-// Copyright (C) 2016 JP 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 Cairo
-{
- public class GLXDevice : Device
- {
- public GLXDevice (IntPtr dpy, IntPtr gl_ctx) : base (NativeMethods.cairo_glx_device_create (dpy, gl_ctx), true)
- {
- }
-
- public IntPtr Display {
- get { return NativeMethods.cairo_glx_device_get_display (Handle); }
- }
-
- public IntPtr Context {
- get { return NativeMethods.cairo_glx_device_get_context (Handle); }
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.GlitzSurface.cs
-//
-// Authors:
-// Alp Toker
-//
-// (C) Alp Toker, 2006.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
- public class GlitzSurface : Surface
- {
- internal GlitzSurface (IntPtr handle, bool owns) : base (handle, owns)
- {
- }
-
- public GlitzSurface (IntPtr glitz_surface)
- : base (NativeMethods.cairo_glitz_surface_create (glitz_surface), true)
- {
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Glyph.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 Cairo
-{
- [StructLayout(LayoutKind.Sequential)]
- public struct Glyph
- {
- internal long index;
- internal double x;
- internal double y;
-
- public Glyph (long index, double x, double y)
- {
- this.index = index;
- this.x = x;
- this.y = y;
- }
-
- public long Index {
- get { return index; }
- set { index = value; }
- }
-
- public double X {
- get { return x; }
- set { x = value; }
- }
-
- public double Y {
- get { return y; }
- set { y = value; }
- }
-
- public override bool Equals (object obj)
- {
- if (obj is Glyph)
- return this == (Glyph)obj;
- return false;
- }
-
- public override int GetHashCode ()
- {
- return (int) Index ^ (int) X ^ (int) Y;
- }
-
- internal static IntPtr GlyphsToIntPtr (Glyph[] glyphs)
- {
- int size = Marshal.SizeOf (glyphs[0]);
- IntPtr dest = Marshal.AllocHGlobal (size * glyphs.Length);
- long pos = dest.ToInt64 ();
- for (int i = 0; i < glyphs.Length; i++, pos += size)
- Marshal.StructureToPtr (glyphs[i], (IntPtr) pos, false);
- return dest;
- }
-
- public static bool operator == (Glyph glyph, Glyph other)
- {
- return glyph.Index == other.Index && glyph.X == other.X && glyph.Y == other.Y;
- }
-
- public static bool operator != (Glyph glyph, Glyph other)
- {
- return !(glyph == other);
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Gradient.cs
-//
-// Author: Jordi Mas (jordi@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-// (C) Ximian Inc, 2004.
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- public class Gradient : Pattern
- {
- protected Gradient (IntPtr handle, bool owned) : base (handle, owned)
- {
- }
-
- [Obsolete]
- protected Gradient ()
- {
- }
-
- public int ColorStopCount {
- get {
- int cnt;
- NativeMethods.cairo_pattern_get_color_stop_count (Handle, out cnt);
- return cnt;
- }
- }
-
- public Status AddColorStop (double offset, Color c)
- {
- NativeMethods.cairo_pattern_add_color_stop_rgba (Handle, offset, c.R, c.G, c.B, c.A);
- return Status;
- }
-
- public Status AddColorStopRgb (double offset, Color c)
- {
- NativeMethods.cairo_pattern_add_color_stop_rgb (Handle, offset, c.R, c.G, c.B);
- return Status;
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.HintMetrics.cs
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- [Serializable]
- public enum HintMetrics
- {
- Default,
- Off,
- On,
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.HintStyle.cs
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- [Serializable]
- public enum HintStyle
- {
- Default,
- None,
- Slight,
- Medium,
- Full,
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.ImageSurface.cs
-//
-// Authors:
-// Duncan Mak
-// Miguel de Icaza.
-//
-// (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.
-//
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace Cairo {
-
- public class ImageSurface : Surface
- {
- internal ImageSurface (IntPtr handle, bool owns) : base (handle, owns)
- {
- }
-
- public ImageSurface (Format format, int width, int height)
- : base (NativeMethods.cairo_image_surface_create (format, width, height), true)
- {
- }
-
- [Obsolete ("Use ImageSurface (byte[] data, Cairo.Format format, int width, int height, int stride)")]
- public ImageSurface (ref byte[] data, Cairo.Format format, int width, int height, int stride)
- : this (data, format, width, height, stride)
- {
- }
-
- public ImageSurface (byte[] data, Format format, int width, int height, int stride)
- : base (NativeMethods.cairo_image_surface_create_for_data (data, format, width, height, stride), true)
- {
- }
-
- public ImageSurface (IntPtr data, Format format, int width, int height, int stride)
- : base (NativeMethods.cairo_image_surface_create_for_data (data, format, width, height, stride), true)
- {
- }
-
- public ImageSurface (string filename)
- : base (NativeMethods.cairo_image_surface_create_from_png (filename), true)
- {
- }
-
- public int Width {
- get { return NativeMethods.cairo_image_surface_get_width (Handle); }
- }
-
- public int Height {
- get { return NativeMethods.cairo_image_surface_get_height (Handle); }
- }
-
- public byte[] Data {
- get {
- IntPtr ptr = NativeMethods.cairo_image_surface_get_data (Handle);
- int length = Height * Stride;
- byte[] data = new byte[length];
- Marshal.Copy (ptr, data, 0, length);
- return data;
- }
- }
-
- public IntPtr DataPtr {
- get {
- return NativeMethods.cairo_image_surface_get_data (Handle);
- }
- }
-
- public Format Format {
- get { return NativeMethods.cairo_image_surface_get_format (Handle); }
- }
-
- public int Stride {
- get { return NativeMethods.cairo_image_surface_get_stride (Handle); }
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.LineCap.cs
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- [Serializable]
- public enum LineCap
- {
- Butt,
- Round,
- Square,
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.LineJoin.cs
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- [Serializable]
- public enum LineJoin
- {
- Miter,
- Round,
- Bevel
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.LinearGradient.cs
-//
-// Author: Jordi Mas (jordi@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-// (C) Ximian Inc, 2004.
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- public class LinearGradient : Gradient
- {
- internal LinearGradient (IntPtr handle, bool owned) : base (handle, owned)
- {
- }
-
- public LinearGradient (double x0, double y0, double x1, double y1)
- : base (NativeMethods.cairo_pattern_create_linear (x0, y0, x1, y1), true)
- {
- }
-
- public PointD[] LinearPoints {
- get {
- double x0, y0, x1, y1;
- PointD[] points = new PointD [2];
-
- NativeMethods.cairo_pattern_get_linear_points (Handle, out x0, out y0, out x1, out y1);
-
- points[0] = new PointD (x0, y0);
- points[1] = new PointD (x1, y1);
- return points;
- }
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.Matrix.cs
-//
-// Author: Duncan Mak
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-// Idan Gazit (idan@fastmail.fm)
-//
-// (C) Ximian Inc, 2003 - 2005.
-//
-// 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.
-//
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace Cairo {
-
- [StructLayout(LayoutKind.Sequential)]
- public class Matrix : ICloneable
- {
- public double Xx;
- public double Yx;
- public double Xy;
- public double Yy;
- public double X0;
- public double Y0;
-
- public Matrix (double xx, double yx, double xy, double yy,
- double x0, double y0)
- {
- this.Xx = xx; this.Yx = yx; this.Xy = xy;
- this.Yy = yy; this.X0 = x0; this.Y0 = y0;
- }
-
- public Matrix ()
- {
- this.InitIdentity ();
- }
-
- public bool IsIdentity ()
- {
- return (this == new Matrix ());
- }
-
- public void InitIdentity ()
- {
- // this.Init(1,0,0,1,0,0);
- NativeMethods.cairo_matrix_init_identity (this);
- }
-
- public void Init (double xx, double yx, double xy, double yy,
- double x0, double y0)
- {
- this.Xx = xx; this.Yx = yx; this.Xy = xy;
- this.Yy = yy; this.X0 = x0; this.Y0 = y0;
- }
-
- public void InitTranslate (double tx, double ty)
- {
- //this.Init (1, 0, 0, 1, tx, ty);
- NativeMethods.cairo_matrix_init_translate (this, tx, ty);
- }
-
- public void Translate (double tx, double ty)
- {
- NativeMethods.cairo_matrix_translate (this, tx, ty);
- }
-
- public void InitScale (double sx, double sy)
- {
- //this.Init (sx, 0, 0, sy, 0, 0);
- NativeMethods.cairo_matrix_init_scale (this, sx, sy);
- }
-
- public void Scale (double sx, double sy)
- {
- NativeMethods.cairo_matrix_scale (this, sx, sy);
- }
-
- public void InitRotate (double radians)
- {
- /*
- double s, c;
- s = Math.Sin (radians);
- c = Math.Cos (radians);
- this.Init (c, s, -s, c, 0, 0);
- */
- NativeMethods.cairo_matrix_init_rotate (this, radians);
- }
-
- public void Rotate (double radians)
- {
- NativeMethods.cairo_matrix_rotate (this, radians);
- }
-
- public Cairo.Status Invert ()
- {
- return NativeMethods.cairo_matrix_invert (this);
- }
-
- public void Multiply (Matrix b)
- {
- Matrix a = (Matrix) this.Clone ();
- NativeMethods.cairo_matrix_multiply (this, a, b);
- }
-
- public static Matrix Multiply (Matrix a, Matrix b) {
- Matrix result = new Matrix ();
- NativeMethods.cairo_matrix_multiply (result, a, b);
- return result;
- }
-
-
- public void TransformDistance (ref double dx, ref double dy)
- {
- NativeMethods.cairo_matrix_transform_distance (this, ref dx, ref dy);
- }
-
- public void TransformPoint (ref double x, ref double y)
- {
- NativeMethods.cairo_matrix_transform_point (this, ref x, ref y);
- }
-
- public override String ToString ()
- {
- String s = String.Format ("xx:{0:##0.0#} yx:{1:##0.0#} xy:{2:##0.0#} yy:{3:##0.0#} x0:{4:##0.0#} y0:{5:##0.0#}",
- this.Xx, this.Yx, this.Xy, this.Yy, this.X0, this.Y0);
- return s;
- }
-
- public static bool operator == (Matrix lhs, Matrix rhs)
- {
- return (lhs.Xx == rhs.Xx &&
- lhs.Xy == rhs.Xy &&
- lhs.Yx == rhs.Yx &&
- lhs.Yy == rhs.Yy &&
- lhs.X0 == rhs.X0 &&
- lhs.Y0 == rhs.Y0 );
- }
-
- public static bool operator != (Matrix lhs, Matrix rhs)
- {
- return !(lhs==rhs);
- }
-
-
-
- public override bool Equals(object o)
- {
- if (! (o is Matrix))
- return false;
- else
- return (this == (Matrix) o);
- }
-
- public override int GetHashCode()
- {
- return (int)this.Xx ^ (int)this.Xx>>32 ^
- (int)this.Xy ^ (int)this.Xy>>32 ^
- (int)this.Yx ^ (int)this.Yx>>32 ^
- (int)this.Yy ^ (int)this.Yy>>32 ^
- (int)this.X0 ^ (int)this.X0>>32 ^
- (int)this.Y0 ^ (int)this.Y0>>32;
- }
-
- public object Clone()
- {
- return this.MemberwiseClone ();
- }
-
- }
-}
+++ /dev/null
-//
-// Cairo.cs - a simplistic binding of the Cairo API to C#.
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-// John Luke (john.luke@gmail.com)
-// Alp Toker (alp@atoker.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2005 John Luke
-// Copyright (C) 2006 Alp Toker
-//
-// 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 Cairo
-{
- // sort the functions like in the following page so it is easier to find what is missing
- // http://cairographics.org/manual/index-all.html
-
- internal static class NativeMethods
- {
-#if MONOTOUCH
- const string cairo = "__Internal";
-#else
- const string cairo = "libcairo-2.dll";
-#endif
-
- //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- //internal static extern void cairo_append_path (IntPtr cr, Path path);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_arc (IntPtr cr, double xc, double yc, double radius, double angle1, double angle2);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_arc_negative (IntPtr cr, double xc, double yc, double radius, double angle1, double angle2);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_atsui_font_face_create_for_atsu_font_id (IntPtr font_id);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_clip (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_clip_preserve (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_clip_extents (IntPtr cr, out double x1, out double y1, out double x2, out double y2);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_close_path (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_copy_page (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_copy_path (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_copy_path_flat (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_append_path (IntPtr cr, IntPtr path);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_create (IntPtr target);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_curve_to (IntPtr cr, double x1, double y1, double x2, double y2, double x3, double y3);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_debug_reset_static_data ();
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_destroy (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_device_to_user (IntPtr cr, ref double x, ref double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_device_to_user_distance (IntPtr cr, ref double dx, ref double dy);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_fill (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_fill_extents (IntPtr cr, out double x1, out double y1, out double x2, out double y2);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_fill_preserve (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_font_extents (IntPtr cr, out FontExtents extents);
-
- // FontFace
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_font_face_destroy (IntPtr font_face);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern FontType cairo_font_face_get_type (IntPtr font_face);
-
- //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- //internal static extern void cairo_font_face_get_user_data (IntPtr font_face);
-
- //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- //internal static extern void cairo_font_face_set_user_data (IntPtr font_face);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_font_face_reference (IntPtr font_face);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_font_face_status (IntPtr font_face);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern uint cairo_font_face_get_reference_count (IntPtr surface);
-
- // FontOptions
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_font_options_copy (IntPtr original);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_font_options_create ();
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_font_options_destroy (IntPtr options);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- [return: MarshalAs (UnmanagedType.U1)]
- internal static extern bool cairo_font_options_equal (IntPtr options, IntPtr other);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Antialias cairo_font_options_get_antialias (IntPtr options);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern HintMetrics cairo_font_options_get_hint_metrics (IntPtr options);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern HintStyle cairo_font_options_get_hint_style (IntPtr options);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern SubpixelOrder cairo_font_options_get_subpixel_order (IntPtr options);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern long cairo_font_options_hash (IntPtr options);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_font_options_merge (IntPtr options, IntPtr other);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_font_options_set_antialias (IntPtr options, Antialias aa);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_font_options_set_hint_metrics (IntPtr options, HintMetrics metrics);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_font_options_set_hint_style (IntPtr options, HintStyle style);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_font_options_set_subpixel_order (IntPtr options, SubpixelOrder order);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_font_options_status (IntPtr options);
-
- // Freetype / FontConfig
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_ft_font_face_create_for_ft_face (IntPtr face, int load_flags);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_ft_font_face_create_for_pattern (IntPtr fc_pattern);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_ft_font_options_substitute (FontOptions options, IntPtr pattern);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_ft_scaled_font_lock_face (IntPtr scaled_font);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_ft_scaled_font_unlock_face (IntPtr scaled_font);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Antialias cairo_get_antialias (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_get_current_point (IntPtr cr, out double x, out double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern FillRule cairo_get_fill_rule (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_get_font_face (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_get_font_matrix (IntPtr cr, out Matrix matrix);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_get_font_options (IntPtr cr, IntPtr options);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_get_group_target (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern LineCap cairo_get_line_cap (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern LineJoin cairo_get_line_join (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern double cairo_get_line_width (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_get_matrix (IntPtr cr, Matrix matrix);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern double cairo_get_miter_limit (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Operator cairo_get_operator (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern uint cairo_get_reference_count (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_get_source (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_get_target (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern double cairo_get_tolerance (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_glitz_surface_create (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_glyph_extents (IntPtr cr, IntPtr glyphs, int num_glyphs, out TextExtents extents);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_glyph_path (IntPtr cr, IntPtr glyphs, int num_glyphs);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- [return: MarshalAs (UnmanagedType.U1)]
- internal static extern bool cairo_has_current_point (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_identity_matrix (IntPtr cr);
-
- // ImageSurface
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_image_surface_create (Cairo.Format format, int width, int height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_image_surface_create_for_data (byte[] data, Cairo.Format format, int width, int height, int stride);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_image_surface_create_for_data (IntPtr data, Cairo.Format format, int width, int height, int stride);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_image_surface_create_from_png (string filename);
-
- //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- //internal static extern IntPtr cairo_image_surface_create_from_png_stream (string filename);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_image_surface_get_data (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Format cairo_image_surface_get_format (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern int cairo_image_surface_get_height (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern int cairo_image_surface_get_stride (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern int cairo_image_surface_get_width (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- [return: MarshalAs (UnmanagedType.U1)]
- internal static extern bool cairo_in_clip (IntPtr cr, double x, double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- [return: MarshalAs (UnmanagedType.U1)]
- internal static extern bool cairo_in_fill (IntPtr cr, double x, double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- [return: MarshalAs (UnmanagedType.U1)]
- internal static extern bool cairo_in_stroke (IntPtr cr, double x, double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_line_to (IntPtr cr, double x, double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_mask (IntPtr cr, IntPtr pattern);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_mask_surface (IntPtr cr, IntPtr surface, double x, double y);
-
- // Matrix
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_matrix_init (Matrix matrix, double xx, double yx, double xy, double yy, double x0, double y0);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_matrix_init_identity (Matrix matrix);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_matrix_init_rotate (Matrix matrix, double radians);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_matrix_init_scale (Matrix matrix, double sx, double sy);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_matrix_init_translate (Matrix matrix, double tx, double ty);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_matrix_invert (Matrix matrix);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_matrix_multiply (Matrix result, Matrix a, Matrix b);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_matrix_scale (Matrix matrix, double sx, double sy);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_matrix_rotate (Matrix matrix, double radians);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_matrix_transform_distance (Matrix matrix, ref double dx, ref double dy);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_matrix_transform_point (Matrix matrix, ref double x, ref double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_matrix_translate (Matrix matrix, double tx, double ty);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_move_to (IntPtr cr, double x, double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_new_path (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_new_sub_path (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_paint (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_paint_with_alpha (IntPtr cr, double alpha);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_path_destroy (IntPtr path);
-
- // Pattern
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_pattern_add_color_stop_rgb (IntPtr pattern, double offset, double red, double green, double blue);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_pattern_add_color_stop_rgba (IntPtr pattern, double offset, double red, double green, double blue, double alpha);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_pattern_get_color_stop_count (IntPtr pattern, out int count);
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_pattern_get_color_stop_rgba (IntPtr pattern, int index, out double offset, out double red, out double green, out double blue, out double alpha);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_pattern_create_for_surface (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_pattern_get_surface (IntPtr pattern, out IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_pattern_create_linear (double x0, double y0, double x1, double y1);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_pattern_get_linear_points (IntPtr pattern, out double x0, out double y0, out double x1, out double y1);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_pattern_create_radial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_pattern_get_radial_circles (IntPtr pattern, out double x0, out double y0, out double r0, out double x1, out double y1, out double r1);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_pattern_create_rgb (double r, double g, double b);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_pattern_create_rgba (double r, double g, double b, double a);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_pattern_get_rgba (IntPtr pattern, out double red, out double green, out double blue, out double alpha);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_pattern_destroy (IntPtr pattern);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Extend cairo_pattern_get_extend (IntPtr pattern);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Filter cairo_pattern_get_filter (IntPtr pattern);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_pattern_get_matrix (IntPtr pattern, Matrix matrix);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern PatternType cairo_pattern_get_type (IntPtr pattern);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_pattern_reference (IntPtr pattern);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_pattern_set_extend (IntPtr pattern, Extend extend);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_pattern_set_filter (IntPtr pattern, Filter filter);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_pattern_set_matrix (IntPtr pattern, Matrix matrix);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_pattern_status (IntPtr pattern);
-
- // PdfSurface
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_pdf_surface_create (string filename, double width, double height);
-
- //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- //internal static extern IntPtr cairo_pdf_surface_create_for_stream (string filename, double width, double height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_pdf_surface_set_size (IntPtr surface, double x, double y);
-
- // PostscriptSurface
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_ps_surface_create (string filename, double width, double height);
-
- //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- //internal static extern IntPtr cairo_ps_surface_create_for_stream (string filename, double width, double height);
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_ps_surface_dsc_begin_page_setup (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_ps_surface_dsc_begin_setup (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_ps_surface_dsc_comment (IntPtr surface, string comment);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_ps_surface_set_size (IntPtr surface, double x, double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_pop_group (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_pop_group_to_source (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_push_group (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_push_group_with_content (IntPtr cr, Content content);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_quartz_surface_create (IntPtr context, bool flipped, int width, int height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_rectangle (IntPtr cr, double x, double y, double width, double height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_reference (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- 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 RectangleInt rectangle);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_region_copy (IntPtr original);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_region_create ();
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_region_create_rectangle (ref RectangleInt rect);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_region_create_rectangles (RectangleInt[] rects, int count);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_region_destroy (IntPtr region);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern bool cairo_region_equal (IntPtr a, IntPtr b);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_region_get_extents (IntPtr region, out RectangleInt extents);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_region_get_rectangle (IntPtr region, int nth, out RectangleInt rectangle);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_region_intersect (IntPtr dst, IntPtr other);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_region_intersect_rectangle (IntPtr dst, ref RectangleInt rectangle);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern bool cairo_region_is_empty (IntPtr region);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern int cairo_region_num_rectangles (IntPtr region);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_region_reference (IntPtr region);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_region_status (IntPtr region);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_region_subtract (IntPtr dst, IntPtr other);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_region_subtract_rectangle (IntPtr dst, ref RectangleInt rectangle);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_region_translate (IntPtr region, int dx, int dy);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_region_union (IntPtr dst, IntPtr other);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_region_union_rectangle (IntPtr dst, ref RectangleInt rectangle);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_region_xor (IntPtr dst, IntPtr other);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_region_xor_rectangle (IntPtr dst, ref RectangleInt rectangle);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_rel_curve_to (IntPtr cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_rel_line_to (IntPtr cr, double dx, double dy);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_rel_move_to (IntPtr cr, double dx, double dy);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_reset_clip (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_restore (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_rotate (IntPtr cr, double angle);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_save (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_scale (IntPtr cr, double sx, double sy);
-
- // ScaledFont
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_scaled_font_create (IntPtr fontFace, Matrix matrix, Matrix ctm, IntPtr options);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_scaled_font_destroy (IntPtr scaled_font);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_scaled_font_extents (IntPtr scaled_font, out FontExtents extents);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_scaled_font_get_ctm (IntPtr scaled_font, out Matrix matrix);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_scaled_font_get_font_face (IntPtr scaled_font);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_scaled_font_get_font_matrix (IntPtr scaled_font, out Matrix matrix);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_scaled_font_get_font_options (IntPtr scaled_font);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern FontType cairo_scaled_font_get_type (IntPtr scaled_font);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_scaled_font_glyph_extents (IntPtr scaled_font, IntPtr glyphs, int num_glyphs, out TextExtents extents);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_scaled_font_reference (IntPtr scaled_font);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_scaled_font_status (IntPtr scaled_font);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_scaled_font (IntPtr cr, IntPtr scaled_font);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_get_scaled_font (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_scaled_font_text_extents (IntPtr scaled_font, byte[] utf8, out TextExtents extents);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_select_font_face (IntPtr cr, string family, FontSlant slant, FontWeight weight);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_antialias (IntPtr cr, Antialias antialias);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_dash (IntPtr cr, double [] dashes, int ndash, double offset);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_get_dash (IntPtr cr, IntPtr dashes, out double offset);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern int cairo_get_dash_count (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_fill_rule (IntPtr cr, Cairo.FillRule fill_rule);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_font_face (IntPtr cr, IntPtr fontFace);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_font_matrix (IntPtr cr, Matrix matrix);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_font_options (IntPtr cr, IntPtr options);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_font_size (IntPtr cr, double size);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_line_cap (IntPtr cr, LineCap line_cap);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_line_join (IntPtr cr, LineJoin line_join);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_line_width (IntPtr cr, double width);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_matrix (IntPtr cr, Matrix matrix);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_miter_limit (IntPtr cr, double limit);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_operator (IntPtr cr, Cairo.Operator op);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_source (IntPtr cr, IntPtr pattern);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_source_rgb (IntPtr cr, double red, double green, double blue);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_source_rgba (IntPtr cr, double red, double green, double blue, double alpha);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_source_surface (IntPtr cr, IntPtr surface, double x, double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_set_tolerance (IntPtr cr, double tolerance);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_show_glyphs (IntPtr ct, IntPtr glyphs, int num_glyphs);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_show_page (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_show_text (IntPtr cr, byte[] utf8);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_status (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_status_to_string (Status status);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_stroke (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_stroke_extents (IntPtr cr, out double x1, out double y1, out double x2, out double y2);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_stroke_preserve (IntPtr cr);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_rectangle_list_destroy (IntPtr rectangle_list);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_copy_clip_rectangle_list (IntPtr cr);
-
- // Surface
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_surface_create_similar (IntPtr surface, Cairo.Content content, int width, int height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_surface_destroy (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_surface_finish (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_surface_flush (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Content cairo_surface_get_content (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_surface_get_device_offset (IntPtr surface, out double x, out double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_surface_get_font_options (IntPtr surface, IntPtr FontOptions);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern uint cairo_surface_get_reference_count (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern SurfaceType cairo_surface_get_type (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_surface_mark_dirty (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_surface_mark_dirty_rectangle (IntPtr surface, int x, int y, int width, int height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_surface_reference (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_surface_set_device_offset (IntPtr surface, double x, double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_surface_set_fallback_resolution (IntPtr surface, double x, double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_surface_status (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_surface_write_to_png (IntPtr surface, string filename);
-
- //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- //internal static extern void cairo_surface_write_to_png_stream (IntPtr surface, WriteFunc writeFunc);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_svg_surface_create (string fileName, double width, double height);
-
- //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- //internal static extern IntPtr cairo_svg_surface_create_for_stream (double width, double height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_svg_surface_restrict_to_version (IntPtr surface, SvgVersion version);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_text_extents (IntPtr cr, byte[] utf8, out TextExtents extents);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_text_path (IntPtr ct, byte[] utf8);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_transform (IntPtr cr, Matrix matrix);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_translate (IntPtr cr, double tx, double ty);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_user_to_device (IntPtr cr, ref double x, ref double y);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_user_to_device_distance (IntPtr cr, ref double dx, ref double dy);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern int cairo_version ();
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_version_string ();
-
- // DirectFBSurface
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_directfb_surface_create (IntPtr dfb, IntPtr surface);
-
- // win32 fonts
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_win32_font_face_create_for_logfontw (IntPtr logfontw);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_win32_scaled_font_done_font (IntPtr scaled_font);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern double cairo_win32_scaled_font_get_metrics_factor (IntPtr scaled_font);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_win32_scaled_font_select_font (IntPtr scaled_font, IntPtr hdc);
-
- // win32 surface
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_win32_surface_create (IntPtr hdc);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_win32_surface_create_with_ddb (IntPtr hdc, Format format, int width, int height);
-
- // XcbSurface
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_xcb_surface_create (IntPtr connection, uint drawable, IntPtr visual, int width, int height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_xcb_surface_create_for_bitmap (IntPtr connection, uint bitmap, IntPtr screen, int width, int height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_xcb_surface_set_size (IntPtr surface, int width, int height);
-
- // XlibSurface
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_xlib_surface_create (IntPtr display, IntPtr drawable, IntPtr visual, int width, int height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_xlib_surface_create_for_bitmap (IntPtr display, IntPtr bitmap, IntPtr screen, int width, int height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern int cairo_xlib_surface_get_depth (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_xlib_surface_get_display (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_xlib_surface_get_drawable (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern int cairo_xlib_surface_get_height (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_xlib_surface_get_screen (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_xlib_surface_get_visual (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern int cairo_xlib_surface_get_width (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_xlib_surface_set_drawable (IntPtr surface, IntPtr drawable, int width, int height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_xlib_surface_set_size (IntPtr surface, int width, int height);
-
- #region GLSurface
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_gl_surface_create (IntPtr device, uint content, int width, int height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_gl_surface_create_for_texture (IntPtr device, uint content, uint tex, int width, int height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_gl_surface_set_size (IntPtr surface, int width, int height);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern int cairo_gl_surface_get_width (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern int cairo_gl_surface_get_height (IntPtr surface);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_gl_surface_swapbuffers (IntPtr surf);
- #endregion
-
- #region GLX Functions
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_glx_device_create (IntPtr dpy, IntPtr gl_ctx);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_glx_device_get_display (IntPtr device);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_glx_device_get_context (IntPtr device);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_gl_surface_create_for_window (IntPtr device, IntPtr window, int width, int height);
- #endregion
-
- #region WGL Fucntions
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_wgl_device_create (IntPtr hglrc);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_wgl_device_get_context (IntPtr device);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_gl_surface_create_for_dc (IntPtr device, IntPtr hdc, int width, int height);
- #endregion
-
- #region EGL Functions
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_egl_device_create (IntPtr dpy, IntPtr gl_ctx);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_gl_surface_create_for_egl (IntPtr device, IntPtr eglSurface, int width, int height);
- #endregion
-
- #region Device
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern IntPtr cairo_device_reference (IntPtr device);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_device_status(IntPtr device);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_device_destroy (IntPtr device);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern Status cairo_device_acquire(IntPtr device);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_device_release(IntPtr device);
-
- [DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
- internal static extern void cairo_gl_device_set_thread_aware(IntPtr device, int value);
- #endregion
- }
-}
\ No newline at end of file
+++ /dev/null
-//
-// Mono.Cairo.Operator.cs
-//
-// Authors: Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-// John Luke (john.luke@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2005 John Luke
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- [Serializable]
- public enum Operator
- {
- Clear,
- Source,
- Over,
- In,
- Out,
- Atop,
-
- Dest,
- DestOver,
- DestIn,
- DestOut,
- DestAtop,
-
- Xor,
- Add,
- Saturate,
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.PostscriptSurface.cs
-//
-// Authors:
-// John Luke
-//
-// (C) John Luke, 2006.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- public class PSSurface : Surface
- {
- internal PSSurface (IntPtr handle, bool owns) : base (handle, owns)
- {
- }
-
- public PSSurface (string filename, double width, double height)
- : base (NativeMethods.cairo_ps_surface_create (filename, width, height), true)
- {
- }
-
- public void BeginPageSetup ()
- {
- NativeMethods.cairo_ps_surface_dsc_begin_page_setup (Handle);
- }
-
- public void BeginSetup ()
- {
- NativeMethods.cairo_ps_surface_dsc_begin_setup (Handle);
- }
-
- public void DscComment (string comment)
- {
- NativeMethods.cairo_ps_surface_dsc_comment (Handle, comment);
- }
-
- public void SetSize (double width, double height)
- {
- NativeMethods.cairo_ps_surface_set_size (Handle, width, height);
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Context.cs
-//
-// Author:
-// Miguel de Icaza (miguel@novell.com)
-//
-// This is an OO wrapper API for the Cairo API.
-//
-// Copyright 2007 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;
-using Cairo;
-
-namespace Cairo {
-
- public class Path : IDisposable
- {
- IntPtr handle = IntPtr.Zero;
-
- internal Path (IntPtr handle)
- {
- this.handle = handle;
- if (CairoDebug.Enabled)
- CairoDebug.OnAllocated (handle);
- }
-
- ~Path ()
- {
- Dispose (false);
- }
-
- public IntPtr Handle { get { return handle; } }
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- protected virtual void Dispose (bool disposing)
- {
- if (!disposing || CairoDebug.Enabled)
- CairoDebug.OnDisposed<Path> (handle, disposing);
-
- if (!disposing|| handle == IntPtr.Zero)
- return;
-
- NativeMethods.cairo_path_destroy (handle);
- handle = IntPtr.Zero;
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Pattern.cs
-//
-// Author: Jordi Mas (jordi@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-// (C) Ximian Inc, 2004.
-//
-// 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.Collections;
-
-namespace Cairo {
-
- public class Pattern : IDisposable
- {
- [Obsolete]
- protected IntPtr pattern = IntPtr.Zero;
-
- public static Pattern Lookup (IntPtr pattern, bool owner)
- {
- if (pattern == IntPtr.Zero)
- return null;
-
- PatternType pt = NativeMethods.cairo_pattern_get_type (pattern);
- switch (pt) {
- case PatternType.Solid:
- return new SolidPattern (pattern, owner);
- case PatternType.Surface:
- return new SurfacePattern (pattern, owner);
- case PatternType.Linear:
- return new LinearGradient (pattern, owner);
- case PatternType.Radial:
- return new RadialGradient (pattern, owner);
- default:
- return new Pattern (pattern, owner);
- }
- }
-
- [Obsolete]
- protected Pattern ()
- {
- }
-
- internal Pattern (IntPtr handle, bool owned)
- {
- Handle = handle;
- if (!owned)
- NativeMethods.cairo_pattern_reference (handle);
- if (CairoDebug.Enabled)
- CairoDebug.OnAllocated (handle);
- }
-
- ~Pattern ()
- {
- Dispose (false);
- }
-
- [Obsolete ("Use the SurfacePattern constructor")]
- public Pattern (Surface surface)
- : this ( NativeMethods.cairo_pattern_create_for_surface (surface.Handle), true)
- {
- }
-
- [Obsolete]
- protected void Reference ()
- {
- NativeMethods.cairo_pattern_reference (pattern);
- }
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- protected virtual void Dispose (bool disposing)
- {
- if (!disposing || CairoDebug.Enabled)
- CairoDebug.OnDisposed<Pattern> (Handle, disposing);
-
- if (!disposing|| Handle == IntPtr.Zero)
- return;
-
- NativeMethods.cairo_pattern_destroy (Handle);
- Handle = IntPtr.Zero;
- }
-
- [Obsolete ("Use Dispose()")]
- public void Destroy ()
- {
- Dispose ();
- }
-
- public Status Status
- {
- get { return NativeMethods.cairo_pattern_status (Handle); }
- }
-
- public Extend Extend
- {
- get { return NativeMethods.cairo_pattern_get_extend (Handle); }
- set { NativeMethods.cairo_pattern_set_extend (Handle, value); }
- }
-
- public Matrix Matrix {
- set {
- NativeMethods.cairo_pattern_set_matrix (Handle, value);
- }
-
- get {
- Matrix m = new Matrix ();
- NativeMethods.cairo_pattern_get_matrix (Handle, m);
- return m;
- }
- }
-
-#pragma warning disable 612
- public IntPtr Handle {
- get { return pattern; }
- private set { pattern = value; }
- }
-#pragma warning restore 612
-
- [Obsolete]
- public IntPtr Pointer {
- get { return pattern; }
- }
-
- public PatternType PatternType {
- get { return NativeMethods.cairo_pattern_get_type (Handle); }
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.PatternType.cs
-//
-// Authors:
-// John Luke
-//
-// (C) John Luke, 2006.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- [Serializable]
- public enum PatternType
- {
- Solid,
- Surface,
- Linear,
- Radial,
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.PdfSurface.cs
-//
-// Authors:
-// John Luke
-//
-// (C) John Luke, 2006.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- public class PdfSurface : Surface
- {
- internal PdfSurface (IntPtr handle, bool owns) : base (handle, owns)
- {
- }
-
- public PdfSurface (string filename, double width, double height)
- : base (NativeMethods.cairo_pdf_surface_create (filename, width, height), true)
- {
- }
-
- public void SetSize (double width, double height)
- {
- NativeMethods.cairo_pdf_surface_set_size (Handle, width, height);
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.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 Cairo {
- public struct Point
- {
- public Point (int x, int y)
- {
- this.x = x;
- this.y = y;
- }
-
- int x, y;
- public int X {
- get { return x; }
- set { x = value; }
- }
-
- public int Y {
- get { return y; }
- set { y = value; }
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.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 Cairo {
-
- public struct PointD
- {
- public PointD (double x, double y)
- {
- this.x = x;
- this.y = y;
- }
-
- double x, y;
- public double X {
- get { return x; }
- set { x = value; }
- }
-
- public double Y {
- get { return y; }
- set { y = value; }
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Pattern.cs
-//
-// Author: Jordi Mas (jordi@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-// (C) Ximian Inc, 2004.
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- public class RadialGradient : Gradient
- {
- internal RadialGradient (IntPtr handle, bool owned) : base (handle, owned)
- {
- }
-
- public RadialGradient (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1)
- : base (NativeMethods.cairo_pattern_create_radial (cx0, cy0, radius0, cx1, cy1, radius1), true)
- {
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.Rectangle.cs
-//
-// Author:
-// John Luke (john.luke@gmail.com)
-//
-// (C) John Luke 2005.
-//
-// 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 Cairo
-{
- public struct Rectangle
- {
- double x;
- double y;
- double width;
- double height;
-
- public Rectangle (double x, double y, double width, double height)
- {
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- }
-
- public Rectangle (Point point, double width, double height)
- {
- x = point.X;
- y = point.Y;
- this.width = width;
- this.height = height;
- }
-
- public double X {
- get { return x; }
- }
-
- public double Y {
- get { return y; }
- }
-
- public double Width {
- get { return width; }
- }
-
- public double Height {
- get { return height; }
- }
-
- public override bool Equals (object obj)
- {
- if (obj is Rectangle)
- return this == (Rectangle)obj;
- return false;
- }
-
- public override int GetHashCode ()
- {
- return (int) (x + y + width + height);
- }
-
- public override string ToString ()
- {
- return String.Format ("x:{0} y:{1} w:{2} h:{3}", x, y, width, height);
- }
-
- public static bool operator == (Rectangle rectangle, Rectangle other)
- {
- return rectangle.X == other.X && rectangle.Y == other.Y && rectangle.Width == other.Width && rectangle.Height == other.Height;
- }
-
- public static bool operator != (Rectangle rectangle, Rectangle other)
- {
- return !(rectangle == other);
- }
- }
-}
+++ /dev/null
-// Copyright (C) 2011 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 Cairo
-{
-
- [StructLayout(LayoutKind.Sequential)]
- public struct RectangleInt {
- public int X;
- public int Y;
- public int Width;
- public int Height;
- }
-
- public enum RegionOverlap {
- In,
- Out,
- Part,
- }
-
- public class Region : IDisposable {
-
- IntPtr handle;
- public IntPtr Handle {
- get { return handle; }
- }
-
- [Obsolete]
- public Region (IntPtr handle) : this (handle, false) {}
-
- public Region (IntPtr handle, bool owned)
- {
- this.handle = handle;
- if (!owned)
- NativeMethods.cairo_region_reference (handle);
- if (CairoDebug.Enabled)
- CairoDebug.OnAllocated (handle);
- }
-
- public Region () : this (NativeMethods.cairo_region_create () , true)
- {
- }
-
- public Region (RectangleInt rect)
- {
- handle = NativeMethods.cairo_region_create_rectangle (ref rect);
- }
-
- public Region (RectangleInt[] rects)
- {
- handle = NativeMethods.cairo_region_create_rectangles (rects, rects.Length);
- }
-
- public Region Copy ()
- {
- return new Region (NativeMethods.cairo_region_copy (Handle), true);
- }
-
- ~Region ()
- {
- Dispose (false);
- }
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- protected virtual void Dispose (bool disposing)
- {
- if (!disposing || CairoDebug.Enabled)
- CairoDebug.OnDisposed<Region> (handle, disposing);
-
- if (!disposing|| handle == IntPtr.Zero)
- return;
-
- NativeMethods.cairo_region_destroy (Handle);
- handle = IntPtr.Zero;
- }
-
- public override bool Equals (object obj)
- {
- return (obj is Region) && NativeMethods.cairo_region_equal (Handle, (obj as Region).Handle);
- }
-
- public override int GetHashCode ()
- {
- return Handle.GetHashCode ();
- }
-
- public Status Status {
- get { return NativeMethods.cairo_region_status (Handle); }
- }
-
- public RectangleInt Extents {
- get {
- RectangleInt result;
- NativeMethods.cairo_region_get_extents (Handle, out result);
- return result;
- }
- }
-
- public int NumRectangles {
- get { return NativeMethods.cairo_region_num_rectangles (Handle); }
- }
-
- public RectangleInt GetRectangle (int nth)
- {
- RectangleInt val;
- NativeMethods.cairo_region_get_rectangle (Handle, nth, out val);
- return val;
- }
-
- public bool IsEmpty {
- get { return NativeMethods.cairo_region_is_empty (Handle); }
- }
-
- public RegionOverlap ContainsPoint (RectangleInt rectangle)
- {
- return NativeMethods.cairo_region_contains_rectangle (Handle, ref rectangle);
- }
-
- public bool ContainsPoint (int x, int y)
- {
- return NativeMethods.cairo_region_contains_point (Handle, x, y);
- }
-
- public void Translate (int dx, int dy)
- {
- NativeMethods.cairo_region_translate (Handle, dx, dy);
- }
-
- public Status Subtract (Region other)
- {
- return NativeMethods.cairo_region_subtract (Handle, other.Handle);
- }
-
- public Status SubtractRectangle (RectangleInt rectangle)
- {
- return NativeMethods.cairo_region_subtract_rectangle (Handle, ref rectangle);
- }
-
- public Status Intersect (Region other)
- {
- return NativeMethods.cairo_region_intersect (Handle, other.Handle);
- }
-
- public Status IntersectRectangle (RectangleInt rectangle)
- {
- return NativeMethods.cairo_region_intersect_rectangle (Handle, ref rectangle);
- }
-
- public Status Union (Region other)
- {
- return NativeMethods.cairo_region_union (Handle, other.Handle);
- }
-
- public Status UnionRectangle (RectangleInt rectangle)
- {
- return NativeMethods.cairo_region_union_rectangle (Handle, ref rectangle);
- }
-
- public Status Xor (Region other)
- {
- return NativeMethods.cairo_region_xor (Handle, other.Handle);
- }
-
- public Status XorRectangle (RectangleInt rectangle)
- {
- return NativeMethods.cairo_region_xor_rectangle (Handle, ref rectangle);
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.ScaledFont.cs
-//
-// (c) 2008 Jordi Mas i Hernandez (jordimash@gmail.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 Cairo {
-
- public class ScaledFont : IDisposable
- {
- protected IntPtr handle = IntPtr.Zero;
-
- internal ScaledFont (IntPtr handle, bool owner)
- {
- this.handle = handle;
- if (!owner)
- NativeMethods.cairo_scaled_font_reference (handle);
- if (CairoDebug.Enabled)
- CairoDebug.OnAllocated (handle);
- }
-
- public ScaledFont (FontFace fontFace, Matrix matrix, Matrix ctm, FontOptions options)
- : this (NativeMethods.cairo_scaled_font_create (fontFace.Handle, matrix, ctm, options.Handle), true)
- {
- }
-
- ~ScaledFont ()
- {
- Dispose (false);
- }
-
- public IntPtr Handle {
- get {
- return handle;
- }
- }
-
- public FontExtents FontExtents {
- get {
- FontExtents extents;
- NativeMethods.cairo_scaled_font_extents (handle, out extents);
- return extents;
- }
- }
-
- public Matrix FontMatrix {
- get {
- Matrix m;
- NativeMethods.cairo_scaled_font_get_font_matrix (handle, out m);
- return m;
- }
- }
-
- public FontType FontType {
- get {
- return NativeMethods.cairo_scaled_font_get_type (handle);
- }
- }
-
- public TextExtents GlyphExtents (Glyph[] glyphs)
- {
- IntPtr ptr = Context.FromGlyphToUnManagedMemory (glyphs);
- TextExtents extents;
-
- NativeMethods.cairo_scaled_font_glyph_extents (handle, ptr, glyphs.Length, out extents);
-
- Marshal.FreeHGlobal (ptr);
- return extents;
- }
-
- public Status Status
- {
- get { return NativeMethods.cairo_scaled_font_status (handle); }
- }
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- protected virtual void Dispose (bool disposing)
- {
- if (!disposing || CairoDebug.Enabled)
- CairoDebug.OnDisposed<ScaledFont> (handle, disposing);
-
- if (!disposing|| handle == IntPtr.Zero)
- return;
-
- NativeMethods.cairo_scaled_font_destroy (handle);
- handle = IntPtr.Zero;
- }
-
- [Obsolete]
- protected void Reference ()
- {
- NativeMethods.cairo_scaled_font_reference (handle);
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.Pattern.cs
-//
-// Author: Jordi Mas (jordi@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-// (C) Ximian Inc, 2004.
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- public class SolidPattern : Pattern
- {
- internal SolidPattern (IntPtr handle, bool owned) : base (handle, owned)
- {
- }
-
- public SolidPattern (Color color)
- : base (NativeMethods.cairo_pattern_create_rgba (color.R, color.G, color.B, color.A), true)
- {
- }
-
- public SolidPattern (double r, double g, double b)
- : base (NativeMethods.cairo_pattern_create_rgb (r, g, b), true)
- {
- }
-
- public SolidPattern (double r, double g, double b, double a)
- : base (NativeMethods.cairo_pattern_create_rgba (r, g, b, a), true)
- {
- }
-
- public SolidPattern (Color color, bool solid)
- : base (solid
- ? NativeMethods.cairo_pattern_create_rgb (color.R, color.G, color.B)
- : NativeMethods.cairo_pattern_create_rgba (color.R, color.G, color.B, color.A),
- true)
- {
- }
-
- public Color Color {
- get {
- double red, green, blue, alpha;
- NativeMethods.cairo_pattern_get_rgba (Handle, out red, out green, out blue, out alpha);
- return new Color (red, green, blue, alpha);
- }
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.Status.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-// John Luke (john.luke@gmail.com)
-// Alp Toker (alp@atoker.com)
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2005 John Luke
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo
-{
- [Serializable]
- public enum Status
- {
- Success = 0,
- NoMemory,
- InvalidRestore,
- InvalidPopGroup,
- NoCurrentPoint,
- InvalidMatrix,
- InvalidStatus,
- NullPointer,
- InvalidString,
- InvalidPathData,
- ReadError,
- WriteError,
- SurfaceFinished,
- SurfaceTypeMismatch,
- PatternTypeMismatch,
- InvalidContent,
- InvalidFormat,
- InvalidVisual,
- FileNotFound,
- InvalidDash,
- InvalidDscComment,
- InvalidIndex,
- ClipNotRepresentable,
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Cairo.cs
-//
-// Authors:
-// John Luke (john.luke@gmail.com)
-//
-// Copyright (C) John Luke 2005
-//
-// 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 Cairo
-{
- [Serializable]
- public enum SubpixelOrder
- {
- Default,
- Rgb,
- Bgr,
- Vrgb,
- Vbgr,
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Surface.cs
-//
-// Authors:
-// Duncan Mak
-// Miguel de Icaza.
-// Alp Toker
-//
-// (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.
-//
-
-using System;
-using System.Collections;
-
-namespace Cairo {
-
- public class Surface : IDisposable
- {
- [Obsolete]
- protected static Hashtable surfaces = new Hashtable ();
-
- IntPtr handle = IntPtr.Zero;
-
- [Obsolete]
- protected Surface()
- {
- }
-
- [Obsolete]
- protected Surface (IntPtr ptr) : this (ptr, true)
- {
- }
-
- protected Surface (IntPtr handle, bool owner)
- {
- this.handle = handle;
- if (!owner)
- NativeMethods.cairo_surface_reference (handle);
- if (CairoDebug.Enabled)
- CairoDebug.OnAllocated (handle);
- }
-
- public static Surface Lookup (IntPtr surface, bool owned)
- {
- SurfaceType st = NativeMethods.cairo_surface_get_type (surface);
- switch (st) {
- case SurfaceType.Image:
- return new ImageSurface (surface, owned);
- case SurfaceType.Xlib:
- return new XlibSurface (surface, owned);
- case SurfaceType.Xcb:
- return new XcbSurface (surface, owned);
- case SurfaceType.Glitz:
- return new GlitzSurface (surface, owned);
- case SurfaceType.Win32:
- return new Win32Surface (surface, owned);
- case SurfaceType.Pdf:
- return new PdfSurface (surface, owned);
- case SurfaceType.PS:
- return new PSSurface (surface, owned);
- case SurfaceType.DirectFB:
- return new DirectFBSurface (surface, owned);
- case SurfaceType.Svg:
- return new SvgSurface (surface, owned);
- case SurfaceType.GL:
- return new GLSurface (surface, owned);
- default:
- return new Surface (surface, owned);
- }
- }
-
- [Obsolete ("Use an ImageSurface constructor instead.")]
- public static Cairo.Surface CreateForImage (
- ref byte[] data, Cairo.Format format, int width, int height, int stride)
- {
- IntPtr p = NativeMethods.cairo_image_surface_create_for_data (
- data, format, width, height, stride);
-
- return new Cairo.Surface (p, true);
- }
-
- [Obsolete ("Use an ImageSurface constructor instead.")]
- public static Cairo.Surface CreateForImage (
- Cairo.Format format, int width, int height)
- {
- IntPtr p = NativeMethods.cairo_image_surface_create (
- format, width, height);
-
- return new Cairo.Surface (p, true);
- }
-
-
- public Cairo.Surface CreateSimilar (
- Cairo.Content content, int width, int height)
- {
- IntPtr p = NativeMethods.cairo_surface_create_similar (
- this.Handle, content, width, height);
-
- return new Cairo.Surface (p, true);
- }
-
- ~Surface ()
- {
- Dispose (false);
- }
-
- //[Obsolete ("Use Context.SetSource() followed by Context.Paint()")]
- public void Show (Context gr, double x, double y)
- {
- NativeMethods.cairo_set_source_surface (gr.Handle, handle, x, y);
- NativeMethods.cairo_paint (gr.Handle);
- }
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- protected virtual void Dispose (bool disposing)
- {
- if (!disposing || CairoDebug.Enabled)
- CairoDebug.OnDisposed<Surface> (handle, disposing);
-
- if (!disposing|| handle == IntPtr.Zero)
- return;
-
- NativeMethods.cairo_surface_destroy (handle);
- handle = IntPtr.Zero;
- }
-
- public Status Finish ()
- {
- NativeMethods.cairo_surface_finish (handle);
- return Status;
- }
-
- public void Flush ()
- {
- NativeMethods.cairo_surface_flush (handle);
- }
-
- public void MarkDirty ()
- {
- NativeMethods.cairo_surface_mark_dirty (Handle);
- }
-
- public void MarkDirty (Rectangle rectangle)
- {
- NativeMethods.cairo_surface_mark_dirty_rectangle (Handle, (int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, (int)rectangle.Height);
- }
-
- public IntPtr Handle {
- get {
- return handle;
- }
- }
-
- public PointD DeviceOffset {
- get {
- double x, y;
- NativeMethods.cairo_surface_get_device_offset (handle, out x, out y);
- return new PointD (x, y);
- }
-
- set {
- NativeMethods.cairo_surface_set_device_offset (handle, value.X, value.Y);
- }
- }
-
- [Obsolete ("Use Dispose()")]
- public void Destroy()
- {
- Dispose ();
- }
-
- public void SetFallbackResolution (double x, double y)
- {
- NativeMethods.cairo_surface_set_fallback_resolution (handle, x, y);
- }
-
- public void WriteToPng (string filename)
- {
- NativeMethods.cairo_surface_write_to_png (handle, filename);
- }
-
- [Obsolete ("Use Handle instead.")]
- public IntPtr Pointer {
- get {
- return handle;
- }
- }
-
- public Status Status {
- get { return NativeMethods.cairo_surface_status (handle); }
- }
-
- public Content Content {
- get { return NativeMethods.cairo_surface_get_content (handle); }
- }
-
- public SurfaceType SurfaceType {
- get { return NativeMethods.cairo_surface_get_type (handle); }
- }
-
- public uint ReferenceCount {
- get { return NativeMethods.cairo_surface_get_reference_count (handle); }
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Pattern.cs
-//
-// Author: Jordi Mas (jordi@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-// (C) Ximian Inc, 2004.
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- public class SurfacePattern : Pattern
- {
- internal SurfacePattern (IntPtr handle, bool owned) : base (handle, owned)
- {
- }
-
- public SurfacePattern (Surface surface)
- : base (NativeMethods.cairo_pattern_create_for_surface (surface.Handle), true)
- {
- }
-
- //no idea why this is here, the base one is identical, but we can't remove it now
- public new Extend Extend {
- set { NativeMethods.cairo_pattern_set_extend (Handle, value); }
- get { return NativeMethods.cairo_pattern_get_extend (Handle); }
- }
-
- public Filter Filter {
- set { NativeMethods.cairo_pattern_set_filter (Handle, value); }
- get { return NativeMethods.cairo_pattern_get_filter (Handle); }
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.SurfaceType.cs
-//
-// Authors:
-// John Luke
-//
-// (C) John Luke, 2006.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- [Serializable]
- public enum SurfaceType
- {
- Image,
- Pdf,
- PS,
- Xlib,
- Xcb,
- Glitz,
- Quartz,
- Win32,
- BeOS,
- DirectFB,
- Svg,
- OS2,
- Win32Printing,
- QuartzImage,
- Script,
- Qt,
- Recording,
- VG,
- GL,
- Drm,
- Tee,
- Xml,
- Skia,
- SubSurface
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.SvgSurface.cs
-//
-// Authors:
-// John Luke
-//
-// (C) John Luke, 2006.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- public class SvgSurface : Surface
- {
- internal SvgSurface (IntPtr handle, bool owns) : base (handle, owns)
- {
- }
-
- public SvgSurface (string filename, double width, double height)
- : base (NativeMethods.cairo_svg_surface_create (filename, width, height), true)
- {
- }
-
- public void RestrictToVersion (SvgVersion version)
- {
- NativeMethods.cairo_svg_surface_restrict_to_version (Handle, version);
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.SvgVersion.cs
-//
-// Authors:
-// John Luke
-//
-// (C) John Luke, 2006.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- [Serializable]
- public enum SvgVersion
- {
- // FIXME: yuck
- OnePointOne = 0,
- OnePointTwo,
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.TextExtents.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//
-// (C) Ximian, Inc. 2003
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace Cairo
-{
- [StructLayout (LayoutKind.Sequential)]
- public struct TextExtents
- {
- double xbearing;
- double ybearing;
- double width;
- double height;
- double xadvance;
- double yadvance;
-
- public double XBearing {
- get { return xbearing; }
- set { xbearing = value; }
- }
-
- public double YBearing {
- get { return ybearing; }
- set { ybearing = value; }
- }
-
- public double Width {
- get { return width; }
- set { width = value; }
- }
-
- public double Height {
- get { return height; }
- set { height = value; }
- }
-
- public double XAdvance {
- get { return xadvance; }
- set { xadvance = value; }
- }
-
- public double YAdvance {
- get { return yadvance; }
- set { yadvance = value; }
- }
-
- public override bool Equals (object obj)
- {
- if (obj is TextExtents)
- return this == (TextExtents)obj;
- return false;
- }
-
- public override int GetHashCode ()
- {
- return (int)XBearing ^ (int)YBearing ^ (int)Width ^ (int)Height ^ (int)XAdvance ^ (int)YAdvance;
- }
-
- public static bool operator == (TextExtents extents, TextExtents other)
- {
- return extents.XBearing == other.XBearing && extents.YBearing == other.YBearing && extents.Width == other.Width && extents.Height == other.Height && extents.XAdvance == other.XAdvance && extents.YAdvance == other.YAdvance;
- }
-
- public static bool operator != (TextExtents extents, TextExtents other)
- {
- return !(extents == other);
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.Device.cs
-//
-// Authors:
-// JP Bruyère (jp_bruyere@hotmail.com)
-//
-// This is an OO wrapper API for the Cairo API
-//
-// Copyright (C) 2016 JP 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 Cairo
-{
- public class WGLDevice : Device
- {
- public WGLDevice (IntPtr hglrc) : base (NativeMethods.cairo_wgl_device_create (hglrc), true)
- {
- }
-
- public IntPtr Context {
- get { return NativeMethods.cairo_wgl_device_get_context (Handle); }
- }
- }
-}
-
+++ /dev/null
-//
-// Mono.Cairo.Win32Surface.cs
-//
-// Authors:
-// John Luke
-//
-// (C) John Luke, 2006.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
-
- public class Win32Surface : Surface
- {
- internal Win32Surface (IntPtr handle, bool owns) : base (handle, owns)
- {
- }
-
- public Win32Surface (IntPtr hdc)
- : base (NativeMethods.cairo_win32_surface_create (hdc), true)
- {
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.XcbSurface.cs
-//
-// Authors:
-// Alp Toker
-//
-// (C) Alp Toker, 2006.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace Cairo {
- public class XcbSurface : Surface
- {
- internal XcbSurface (IntPtr handle, bool owns) : base (handle, owns)
- {
- }
-
- public XcbSurface (IntPtr connection, uint drawable, IntPtr visual, int width, int height)
- : base (NativeMethods.cairo_xcb_surface_create (connection, drawable, visual, width, height), true)
- {
- }
-
- public static XcbSurface FromBitmap (IntPtr connection, uint bitmap, IntPtr screen, int width, int height)
- {
- IntPtr ptr = NativeMethods.cairo_xcb_surface_create_for_bitmap (connection, bitmap, screen, width, height);
- return new XcbSurface (ptr, true);
- }
-
- public void SetSize (int width, int height)
- {
- NativeMethods.cairo_xcb_surface_set_size (Handle, width, height);
- }
- }
-}
+++ /dev/null
-//
-// Mono.Cairo.XlibSurface.cs
-//
-// Authors:
-// Duncan Mak
-// Miguel de Icaza.
-//
-// (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.
-//
-
-using System;
-
-namespace Cairo {
-
- public class XlibSurface : Surface
- {
- public XlibSurface (IntPtr display, IntPtr drawable, IntPtr visual, int width, int height)
- : base (NativeMethods.cairo_xlib_surface_create (display, drawable, visual, width, height), true)
- {
- }
-
- public XlibSurface (IntPtr ptr, bool own) : base (ptr, own)
- {
- }
-
- public static XlibSurface FromBitmap (IntPtr display, IntPtr bitmap, IntPtr screen, int width, int height)
- {
- IntPtr ptr = NativeMethods.cairo_xlib_surface_create_for_bitmap (display, bitmap, screen, width, height);
- return new XlibSurface(ptr, true);
- }
-
- public void SetDrawable (IntPtr drawable, int width, int height)
- {
- NativeMethods.cairo_xlib_surface_set_drawable (Handle, drawable, width, height);
- }
-
- public void SetSize (int width, int height)
- {
- NativeMethods.cairo_xlib_surface_set_size (Handle, width, height);
- }
-
- public int Depth {
- get { return NativeMethods.cairo_xlib_surface_get_depth (Handle); }
- }
-
- public IntPtr Display {
- get { return NativeMethods.cairo_xlib_surface_get_display (Handle); }
- }
-
- public IntPtr Drawable {
- get { return NativeMethods.cairo_xlib_surface_get_drawable (Handle); }
- }
-
- public int Height {
- get { return NativeMethods.cairo_xlib_surface_get_height (Handle); }
- }
-
- public IntPtr Screen {
- get { return NativeMethods.cairo_xlib_surface_get_screen (Handle); }
- }
-
- public IntPtr Visual {
- get { return NativeMethods.cairo_xlib_surface_get_visual (Handle); }
- }
-
- public int Width {
- get { return NativeMethods.cairo_xlib_surface_get_width (Handle); }
- }
-
- }
-}
--- /dev/null
+//
+// DrmKms.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 OpenTK.Platform.Linux;
+using OpenTK;
+using System.IO;
+using System.Collections.Generic;
+using System.Diagnostics;
+using OpenTK.Platform.Egl;
+using System.Runtime.InteropServices;
+using System.Threading;
+
+namespace Crow.Linux
+{
+ public class Application : IDisposable
+ {
+ #region Crow interface
+ public Interface CrowInterface;
+ public bool mouseIsInInterface = false;
+
+ void interfaceThread()
+ {
+ while (CrowInterface.ClientRectangle.Size.Width == 0)
+ Thread.Sleep (5);
+
+ while (true) {
+ CrowInterface.Update ();
+ Thread.Sleep (1);
+ }
+ }
+ void initCrow (){
+ CrowInterface = new Interface ();
+
+ Thread t = new Thread (interfaceThread);
+ t.IsBackground = true;
+ t.Start ();
+
+ updateCrowInterfaceBounds ();
+ }
+ void updateCrowInterfaceBounds () {
+ CrowInterface.ProcessResize (new Size (originalMode.hdisplay, originalMode.vdisplay));
+ }
+ #endregion
+
+ volatile bool run = true;
+
+ int fd_gpu = 0;
+ int major, minor;
+
+ IntPtr gbm_device, gbm_surface, egl_display, egl_config, egl_surface, egl_ctx;
+
+ int r, g, b, a;
+
+ BufferObject cursor_custom;
+ BufferObject cursor_default;
+ BufferObject cursor_empty;
+
+
+ ModeInfo originalMode;
+
+ public IntPtr Connector, Crtc, Encoder;
+ unsafe ModeCrtc* saved_crtc;
+ unsafe ModeConnector* pConnector { get { return (ModeConnector*)Connector; } }
+ unsafe ModeCrtc* pCrtc { get { return (ModeCrtc*)Crtc; } }
+ unsafe ModeEncoder* pEncoder { get { return (ModeEncoder*)Encoder; } }
+
+ Cairo.EGLDevice cairoDev;
+ Cairo.GLSurface cairoSurf;
+
+ public Application(string gpu_path = "/dev/dri/card0"){
+ DestroyFB = HandleDestroyFB;
+ DestroyFBPtr = Marshal.GetFunctionPointerForDelegate(DestroyFB);
+ PageFlip = HandlePageFlip;
+ PageFlipPtr = Marshal.GetFunctionPointerForDelegate(PageFlip);
+
+ gbm_device = IntPtr.Zero;
+ egl_display = IntPtr.Zero;
+
+ fd_gpu = Libc.open(gpu_path, OpenFlags.ReadWrite | OpenFlags.CloseOnExec);
+ if (fd_gpu < 0)
+ throw new NotSupportedException("[KMS] Failed to open gpu");
+ Console.WriteLine("[KMS] GPU '{0}' opened as fd:{1}", gpu_path, fd_gpu);
+
+ initDrm ();
+
+ initGbm ();
+
+ initEgl ();
+
+ initCairo ();
+
+ initInput ();
+
+ initCrow ();
+ }
+
+ #region init
+ unsafe void initDrm(){
+ ModeRes* resources = (ModeRes*)Drm.ModeGetResources(fd_gpu);
+ if (resources == null)
+ throw new NotSupportedException("[KMS] Drm.ModeGetResources failed.");
+
+ ModeConnector* connector = null;
+ for (int i = 0; i < resources->count_connectors; i++) {
+ connector = (ModeConnector*)Drm.ModeGetConnector (fd_gpu, *(resources->connectors + i));
+ if (connector != null) {
+ if (connector->connection == ModeConnection.Connected && connector->count_encoders > 0)
+ break;
+ Drm.ModeFreeConnector ((IntPtr)connector);
+ connector = null;
+ }
+ }
+ if (connector == null)
+ throw new NotSupportedException("[KMS] No connected screen found");
+
+ Connector = (IntPtr)connector;
+ Encoder = Drm.ModeGetEncoder (fd_gpu, connector->encoder_id);
+ Crtc = Drm.ModeGetCrtc(fd_gpu, pEncoder->crtc_id);
+ saved_crtc = (ModeCrtc*) Drm.ModeGetCrtc (fd_gpu, pEncoder->crtc_id);
+
+ originalMode = pCrtc->mode;
+ Console.WriteLine ("[DRM]: current mode = {0} X {1} at {2} Hz", originalMode.hdisplay, originalMode.vdisplay, originalMode.vrefresh);
+ }
+ void initGbm (){
+ gbm_device = Gbm.CreateDevice(fd_gpu);
+ if (gbm_device == IntPtr.Zero)
+ throw new NotSupportedException("[GBM] Failed to create GBM device");
+
+ gbm_surface = Gbm.CreateSurface(gbm_device, originalMode.hdisplay, originalMode.vdisplay, SurfaceFormat.ARGB8888, SurfaceFlags.Rendering | SurfaceFlags.Scanout);
+ if (gbm_surface == IntPtr.Zero)
+ throw new NotSupportedException("[GBM] Failed to create GBM surface for rendering");
+ }
+
+ unsafe void initEgl () {
+ IntPtr[] configs = new IntPtr[1];
+ int[] contextAttrib = new int[] {
+ Egl.CONTEXT_CLIENT_VERSION, 2,
+ Egl.NONE
+ };
+ int[] attribList = new int[]
+ {
+ Egl.SURFACE_TYPE, Egl.WINDOW_BIT,
+ Egl.RENDERABLE_TYPE, Egl.OPENGL_BIT,
+ Egl.RED_SIZE, 1,
+ Egl.GREEN_SIZE, 1,
+ Egl.BLUE_SIZE, 1,
+ Egl.ALPHA_SIZE, 0,
+
+ //Egl.DEPTH_SIZE, 24,
+ //Egl.STENCIL_SIZE, 0,
+
+ //Egl.SAMPLE_BUFFERS, 2,
+ //Egl.SAMPLES, 0,
+ Egl.NONE
+ };
+ int num_configs;
+
+ egl_display = Egl.GetDisplay(gbm_device);
+ if (egl_display == IntPtr.Zero)
+ throw new NotSupportedException("[KMS] Failed to create EGL display");
+ Console.WriteLine("[EGL] EGL display {0:x} created successfully", egl_display);
+
+ if (!Egl.Initialize(egl_display, out major, out minor))
+ throw new NotSupportedException("[EGL] Failed to initialize EGL display. Error code: " + Egl.GetError());
+
+ if (!Egl.BindAPI (RenderApi.GL))
+ throw new NotSupportedException("[EGL] Failed to bind EGL Api: " + Egl.GetError());
+
+ Console.WriteLine ("[EGL] Version: " + Marshal.PtrToStringAuto (Egl.QueryString (egl_display, Egl.VERSION)));
+ Console.WriteLine ("[EGL] Vendor: " + Marshal.PtrToStringAuto (Egl.QueryString (egl_display, Egl.VENDOR)));
+ Console.WriteLine ("[EGL] Extensions: " + Marshal.PtrToStringAuto (Egl.QueryString (egl_display, Egl.EXTENSIONS)));
+ Console.WriteLine ("[EGL] Extensions: " + Marshal.PtrToStringAuto (Egl.QueryString(IntPtr.Zero, Egl.EXTENSIONS)));
+
+ if (!Egl.ChooseConfig(egl_display, attribList, configs, configs.Length, out num_configs) || num_configs == 0)
+ throw new NotSupportedException(String.Format("Failed to retrieve GraphicsMode, error {0}", Egl.GetError()));
+
+
+ // See what we really got
+ int d, s, sample_buffers, samples;
+ IntPtr active_config = configs[0];
+ Egl.GetConfigAttrib(egl_display, active_config, Egl.RED_SIZE, out r);
+ Egl.GetConfigAttrib(egl_display, active_config, Egl.GREEN_SIZE, out g);
+ Egl.GetConfigAttrib(egl_display, active_config, Egl.BLUE_SIZE, out b);
+ Egl.GetConfigAttrib(egl_display, active_config, Egl.ALPHA_SIZE, out a);
+ //Egl.GetConfigAttrib(egl_display, active_config, Egl.DEPTH_SIZE, out d);
+ //Egl.GetConfigAttrib(egl_display, active_config, Egl.STENCIL_SIZE, out s);
+ //Egl.GetConfigAttrib(egl_display, active_config, Egl.SAMPLE_BUFFERS, out sample_buffers);
+ //Egl.GetConfigAttrib(egl_display, active_config, Egl.SAMPLES, out samples);
+// Console.WriteLine ("EGL context: {0},{1},{2},{3} depth={4} stencil={5} samples={6} sample buffers={7}",
+// r, g, b, a, d, s, samples, sample_buffers);
+ egl_config = active_config;
+
+ egl_ctx = Egl.CreateContext(egl_display, egl_config, IntPtr.Zero, contextAttrib);
+
+ egl_surface = Egl.CreateWindowSurface(egl_display, egl_config, gbm_surface, IntPtr.Zero);
+
+ if (egl_surface==IntPtr.Zero)
+ throw new NotSupportedException(String.Format("[EGL] Failed to create window surface, error {0}.", Egl.GetError()));
+
+ if (!Egl.MakeCurrent(egl_display, egl_surface, egl_surface, egl_ctx))
+ throw new NotSupportedException(string.Format("Failed to make context {0} current. Error: {1}", gbm_surface, Egl.GetError()));
+
+ cursor_default = CreateCursor(gbm_device, Cursors.Default);
+ cursor_empty = CreateCursor(gbm_device, Cursors.Empty);
+
+ SetCursor(Cursors.Default);
+ unsafe {
+ Drm.MoveCursor (fd_gpu, pEncoder->crtc_id, 0, 0);
+ }
+ }
+
+ void initCairo (){
+ cairoDev = new Cairo.EGLDevice (egl_display, egl_ctx);
+
+ cairoSurf = new Cairo.GLSurface (cairoDev, egl_surface, originalMode.hdisplay, originalMode.vdisplay);
+ //cairoSurf = new Cairo.EGLSurface (cairoDev, egl_surface, 1600, 900);
+
+ cairoDev.SetThreadAware (false);
+
+ if (cairoDev.Acquire () != Cairo.Status.Success)
+ Console.WriteLine ("[Cairo]: Failed to acquire egl device.");
+ }
+ #endregion
+
+ #region cursor
+ static BufferObject CreateCursor(IntPtr gbm, MouseCursor cursor)
+ {
+ if (cursor.Width > 64 || cursor.Height > 64)
+ {
+ Debug.Print("[KMS] Cursor size {0}x{1} unsupported. Maximum is 64x64.",
+ cursor.Width, cursor.Height);
+ return default(BufferObject);
+ }
+
+ int width = 64;
+ int height = 64;
+ SurfaceFormat format = SurfaceFormat.ARGB8888;
+ SurfaceFlags usage = SurfaceFlags.Cursor64x64 | SurfaceFlags.Write;
+
+ Debug.Print("[KMS] Gbm.CreateBuffer({0:X}, {1}, {2}, {3}, {4}).",
+ gbm, width, height, format, usage);
+
+ BufferObject bo = Gbm.CreateBuffer(
+ gbm, width, height, format, usage);
+
+ if (bo == BufferObject.Zero)
+ {
+ Debug.Print("[KMS] Failed to create buffer.");
+ return bo;
+ }
+
+ // Copy cursor.Data into a new buffer of the correct size
+ byte[] cursor_data = new byte[width * height * 4];
+ for (int y = 0; y < cursor.Height; y++)
+ {
+ int dst_offset = y * width * 4;
+ int src_offset = y * cursor.Width * 4;
+ int src_length = cursor.Width * 4;
+ Array.Copy(
+ cursor.Data, src_offset,
+ cursor_data, dst_offset,
+ src_length);
+ }
+ bo.Write(cursor_data);
+
+ return bo;
+ }
+ void SetCursor(MouseCursor cursor)
+ {
+ BufferObject bo = default(BufferObject);
+ if (cursor == MouseCursor.Default)
+ {
+ bo = cursor_default;
+ }
+ else if (cursor == MouseCursor.Empty)
+ {
+ bo = cursor_empty;
+ }
+ else
+ {
+ if (cursor_custom != BufferObject.Zero)
+ cursor_custom.Dispose();
+ cursor_custom = CreateCursor(gbm_device, cursor);
+ bo = cursor_custom;
+ }
+
+ // If we failed to create a proper cursor, try falling back
+ // to the empty cursor. We do not want to crash here!
+ if (bo == BufferObject.Zero)
+ {
+ bo = cursor_empty;
+ }
+
+ if (bo != BufferObject.Zero)
+ {
+ unsafe {
+ Console.WriteLine ("Cursor ({0},{1})", cursor.X, cursor.Y);
+ Drm.SetCursor (fd_gpu, pEncoder->crtc_id,
+ bo.Handle, bo.Width, bo.Height, cursor.X, cursor.Y);
+ }
+ }
+ }
+ #endregion
+
+ int getFbFromBo (BufferObject bo){
+ int width = bo.Width;
+ int height = bo.Height;
+ int bpp = 32;
+ int depth = 24;
+ int stride = bo.Stride;
+ int hndBO = bo.Handle;
+
+ int fb;
+ int ret = Drm.ModeAddFB (fd_gpu, width, height,(byte)depth, (byte)bpp, stride, hndBO, out fb);
+ if (ret != 0)
+ throw new Exception ("[DRM]: ModeAddFB failed.");
+ bo.SetUserData ((IntPtr)fb, DestroyFBPtr);
+ return fb;
+ }
+
+ public void Run(){
+ BufferObject bo;
+ int fb;
+
+ PollFD fds = new PollFD();
+ fds.fd = fd_gpu;
+ fds.events = PollFlags.In;
+
+ EventContext evctx = new EventContext();
+ evctx.version = EventContext.Version;
+ evctx.page_flip_handler = PageFlipPtr;
+
+ int timeout = -1;//block ? -1 : 0;
+
+ using (Cairo.Context ctx = new Cairo.Context (cairoSurf)) {
+ ctx.Rectangle (0, 0, originalMode.hdisplay, originalMode.vdisplay);
+ ctx.SetSourceRGB (0, 0, 0);
+ ctx.Fill ();
+ }
+
+ cairoSurf.SwapBuffers ();
+
+ bo = Gbm.LockFrontBuffer (gbm_surface);
+ fb = getFbFromBo (bo);
+
+ SetScanoutRegion (fb);
+
+ while (run){
+ BufferObject next_bo;
+ bool update = false;
+
+ if (updateMousePos) {
+ lock (Sync) {
+ updateMousePos = false;
+ unsafe {
+ Drm.MoveCursor (fd_gpu, pEncoder->crtc_id, MouseX-8, MouseY-4);
+ }
+ }
+ }
+
+ if (Monitor.TryEnter (CrowInterface.RenderMutex)) {
+ if (CrowInterface.IsDirty) {
+ CrowInterface.IsDirty = false;
+ update = true;
+ using (Cairo.Context ctx = new Cairo.Context (cairoSurf)) {
+ using (Cairo.Surface d = new Cairo.ImageSurface (CrowInterface.dirtyBmp, Cairo.Format.Argb32,
+ originalMode.hdisplay, originalMode.vdisplay, originalMode.hdisplay * 4)) {
+ ctx.SetSourceSurface (d, 0, 0);
+ ctx.Operator = Cairo.Operator.Source;
+ ctx.Paint ();
+ }
+ }
+ }
+ Monitor.Exit (CrowInterface.RenderMutex);
+ }
+
+ if (!update)
+ continue;
+ update = false;
+
+ cairoSurf.Flush ();
+ cairoSurf.SwapBuffers ();
+
+ if (Gbm.HasFreeBuffers (gbm_surface) == 0)
+ throw new Exception ("[GBM]: Out of free buffers.");
+
+ next_bo = Gbm.LockFrontBuffer (gbm_surface);
+ if (next_bo == BufferObject.Zero)
+ throw new Exception ("[GBM]: Failed to lock front buffer.");
+
+ fb = getFbFromBo (next_bo);
+
+ unsafe{
+ int is_flip_queued = 1;
+
+ while (Drm.ModePageFlip (fd_gpu, pEncoder->crtc_id, fb, PageFlipFlags.FlipEvent, ref is_flip_queued) < 0) {
+ //Console.WriteLine ("[DRM] Failed to enqueue framebuffer flip.");
+ continue;
+ }
+
+ while (is_flip_queued != 0)
+ {
+ fds.revents = 0;
+ if (Libc.poll (ref fds, 1, timeout) < 0)
+ break;
+
+ if ((fds.revents & (PollFlags.Hup | PollFlags.Error)) != 0)
+ break;
+
+ if ((fds.revents & PollFlags.In) != 0)
+ Drm.HandleEvent (fd_gpu, ref evctx);
+ else
+ break;
+ }
+// if (is_flip_queued != 0)
+// Console.WriteLine ("flip canceled");
+
+ Gbm.ReleaseBuffer (gbm_surface, bo);
+ Drm.ModeRmFB(fd_gpu, fb);
+
+ bo = next_bo;
+ next_bo = BufferObject.Zero;
+
+ }
+ }
+ }
+
+ #region rendering
+
+
+
+ // We only support a SwapInterval of 0 (immediate)
+ // or 1 (vsynced).
+ // Todo: add support for SwapInterval of -1 (adaptive).
+ // This requires a small change in WaitFlip().
+ int swap_interval=0;
+
+ readonly IntPtr PageFlipPtr;
+ readonly PageFlipCallback PageFlip;
+
+ readonly IntPtr DestroyFBPtr;
+ readonly DestroyUserDataCallback DestroyFB;
+
+ void HandlePageFlip(int fd, int sequence, int tv_sec, int tv_usec, ref int user_data)
+ {
+ user_data = 0;
+ }
+
+
+ void HandleDestroyFB(BufferObject bo, IntPtr data)
+ {
+ Console.WriteLine ("DestroyFB");
+ IntPtr gbm = bo.Device;
+ int fb = data.ToInt32();
+
+ if (fb != 0)
+ Drm.ModeRmFB(fd_gpu, fb);
+ }
+
+ void SetScanoutRegion(int buffer)
+ {
+ unsafe
+ {
+ ModeInfo* mode = pConnector->modes;
+ int connector_id = pConnector->connector_id;
+ int crtc_id = pEncoder->crtc_id;
+
+ int ret = Drm.ModeSetCrtc (fd_gpu, crtc_id, buffer, 0, 0, &connector_id, 1, mode);
+
+ if (ret != 0)
+ Debug.Print("[KMS] Drm.ModeSetCrtc{0}, {1}, {2} failed. Error: {3}",
+ fd_gpu, crtc_id, buffer, ret);
+ }
+ }
+ #endregion
+
+ #region IDisposable implementation
+ public void Dispose ()
+ {
+ cairoDev.Release ();
+ cairoSurf.Dispose ();
+ cairoDev.Dispose ();
+
+// if (fb != 0)
+// Drm.ModeRmFB (fd_gpu, fb);
+// if (bo != BufferObject.Zero)
+// Gbm.ReleaseBuffer (gbm_surface, bo);
+// if (next_fb != 0)
+// Drm.ModeRmFB (fd_gpu, next_fb);
+// if (next_bo != BufferObject.Zero)
+// Gbm.ReleaseBuffer (gbm_surface, next_bo);
+
+ if (Egl.GetCurrentContext () == egl_ctx) {
+ Console.WriteLine ("destroying context");
+ Egl.DestroyContext (egl_display, egl_ctx);
+ }else
+ Console.WriteLine ("not current");
+
+ cairoDev.Dispose ();
+
+ unsafe{
+ Drm.ModeSetCrtc (fd_gpu, saved_crtc->crtc_id, saved_crtc->buffer_id,
+ saved_crtc->x, saved_crtc->y, &pConnector->connector_id, 1, &saved_crtc->mode);
+ Drm.ModeFreeCrtc ((IntPtr)saved_crtc);
+ }
+
+ Drm.ModeFreeCrtc (Crtc);
+ Drm.ModeFreeConnector(Connector);
+ Drm.ModeFreeEncoder(Encoder);
+ Libc.close(fd_gpu);
+ }
+ #endregion
+
+ #region tests
+ unsafe void dumpDrmResources(){
+ ModeRes* resources = (ModeRes*)Drm.ModeGetResources(fd_gpu);
+ if (resources == null)
+ throw new NotSupportedException("[KMS] Drm.ModeGetResources failed.");
+ Console.WriteLine("[KMS] DRM found {0} connectors", resources->count_connectors);
+
+ Console.WriteLine ("[ENCODERS]");
+ for (int j = 0; j < resources->count_encoders; j++) {
+ ModeEncoder* e = (ModeEncoder*)Drm.ModeGetEncoder(fd_gpu, *(resources->encoders + j));
+
+ if (e == null)
+ continue;
+ Console.WriteLine ("{0}\t{1}\t{2}",e->encoder_id, e->encoder_type, e->crtc_id);
+
+ Drm.ModeFreeEncoder((IntPtr)e);
+ }
+
+ Console.WriteLine ("\n[CONNECTORS]");
+ ModeConnector* connector = null;
+ for (int i = 0; i < resources->count_connectors; i++)
+ {
+ connector = (ModeConnector*)Drm.ModeGetConnector(fd_gpu, *(resources->connectors + i));
+ if (connector != null)
+ {
+ Console.WriteLine ("{0}\t{1}\t{2}\t{3}",
+ connector->connector_id,
+ connector->connector_type,
+ connector->connection,
+ connector->encoder_id);
+
+ for (int j = 0; j < connector->count_modes; j++) {
+ ModeInfo* mode = connector->modes + j;
+ if (mode == null)
+ continue;
+ Console.WriteLine ("\t{0,-20}{1,5}{2,5}{3,4} hz",
+ new string(mode->name),
+ mode->hdisplay,
+ mode->vdisplay,
+ mode->vrefresh);
+ }
+ Drm.ModeFreeConnector((IntPtr)connector);
+ connector = null;
+ }
+ }
+ }
+ #endregion
+
+ #region INPUT
+ Thread input_thread;
+ long exit;
+
+ static readonly object Sync = new object();
+ static readonly Crow.Key[] KeyMap = Evdev.KeyMap;
+ static long DeviceFDCount;
+
+ IntPtr udev;
+ IntPtr input_context;
+
+ int input_fd = 0;
+
+ InputInterface input_interface = new InputInterface(
+ OpenRestricted, CloseRestricted);
+ static CloseRestrictedCallback CloseRestricted = CloseRestrictedHandler;
+ static void CloseRestrictedHandler(int fd, IntPtr data)
+ {
+ Debug.Print("[Input] Closing fd {0}", fd);
+ int ret = Libc.close(fd);
+
+ if (ret < 0)
+ {
+ Debug.Print("[Input] Failed to close fd {0}. Error: {1}", fd, ret);
+ }
+ else
+ {
+ Interlocked.Decrement(ref DeviceFDCount);
+ }
+ }
+
+ static OpenRestrictedCallback OpenRestricted = OpenRestrictedHandler;
+ static int OpenRestrictedHandler(IntPtr path, int flags, IntPtr data)
+ {
+ int fd = Libc.open(path, (OpenFlags)flags);
+ Debug.Print("[Input] Opening '{0}' with flags {1}. fd:{2}",
+ Marshal.PtrToStringAnsi(path), (OpenFlags)flags, fd);
+
+ if (fd >= 0)
+ {
+ Interlocked.Increment(ref DeviceFDCount);
+ }
+
+ return fd;
+ }
+
+ void initInput (){
+ Semaphore ready = new Semaphore(0, 1);
+ input_thread = new Thread (InputThreadLoop);
+ input_thread.IsBackground = true;
+ input_thread.Start(ready);
+ }
+
+ void InputThreadLoop(object semaphore)
+ {
+ Debug.Print("[Input] Running on thread {0}", Thread.CurrentThread.ManagedThreadId);
+ Setup();
+
+ // Inform the parent thread that initialization has completed successfully
+ (semaphore as Semaphore).Release();
+ Debug.Print("[Input] Released main thread.", input_context);
+
+ // Use a blocking poll for input messages, in order to reduce CPU usage
+ PollFD poll_fd = new PollFD();
+ poll_fd.fd = input_fd;
+ poll_fd.events = PollFlags.In;
+ Debug.Print("[Input] Created PollFD({0}, {1})", poll_fd.fd, poll_fd.events);
+
+ Debug.Print("[Input] Entering input loop.", poll_fd.fd, poll_fd.events);
+ while (Interlocked.Read(ref exit) == 0)
+ {
+ int ret = Libc.poll(ref poll_fd, 1, -1);
+ ErrorNumber error = (ErrorNumber)Marshal.GetLastWin32Error();
+ bool is_error =
+ ret < 0 && !(error == ErrorNumber.Again || error == ErrorNumber.Interrupted) ||
+ (poll_fd.revents & (PollFlags.Hup | PollFlags.Error | PollFlags.Invalid)) != 0;
+
+ if (ret > 0 && (poll_fd.revents & (PollFlags.In | PollFlags.Pri)) != 0)
+ ProcessEvents(input_context);
+
+ if (is_error)
+ {
+ Debug.Print("[Input] Exiting input loop {0} due to poll error [ret:{1} events:{2}]. Error: {3}.",
+ input_thread.ManagedThreadId, ret, poll_fd.revents, error);
+ Interlocked.Increment(ref exit);
+ }
+ }
+ Debug.Print("[Input] Exited input loop.", poll_fd.fd, poll_fd.events);
+ }
+
+ void Setup()
+ {
+ // Todo: add static path fallback when udev is not installed.
+ udev = Udev.New();
+ if (udev == IntPtr.Zero)
+ {
+ Debug.Print("[Input] Udev.New() failed.");
+ Interlocked.Increment(ref exit);
+ return;
+ }
+ Debug.Print("[Input] Udev.New() = {0:x}", udev);
+
+ input_context = LibInput.CreateContext(input_interface, IntPtr.Zero, udev);
+ if (input_context == IntPtr.Zero)
+ {
+ Debug.Print("[Input] LibInput.CreateContext({0:x}) failed.", udev);
+ Interlocked.Increment(ref exit);
+ return;
+ }
+ Debug.Print("[Input] LibInput.CreateContext({0:x}) = {1:x}", udev, input_context);
+
+ string seat_id = "seat0";
+ int seat_assignment = LibInput.AssignSeat(input_context, seat_id);
+ if (seat_assignment == -1)
+ {
+ Debug.Print("[Input] LibInput.AssignSeat({0:x}) = {1} failed.", input_context, seat_id);
+ Interlocked.Increment(ref exit);
+ return;
+ }
+ Debug.Print("[Input] LibInput.AssignSeat({0:x}) = {1}", input_context, seat_id);
+
+ input_fd = LibInput.GetFD(input_context);
+ if (input_fd < 0)
+ {
+ Debug.Print("[Input] LibInput.GetFD({0:x}) failed.", input_context);
+ Interlocked.Increment(ref exit);
+ return;
+ }
+ Debug.Print("[Input] LibInput.GetFD({0:x}) = {1}.", input_context, input_fd);
+
+ ProcessEvents(input_context);
+ LibInput.Resume(input_context);
+ Debug.Print("[Input] LibInput.Resume({0:x})", input_context);
+
+ if (Interlocked.Read(ref DeviceFDCount) <= 0)
+ {
+ Debug.Print("[Error] Failed to open any input devices.");
+ Debug.Print("[Error] Ensure that you have access to '/dev/input/event*'.");
+ Interlocked.Increment(ref exit);
+ }
+ }
+
+ void ProcessEvents(IntPtr input_context)
+ {
+ // Process all events in the event queue
+ while (true)
+ {
+ // Data available
+ int ret = LibInput.Dispatch(input_context);
+ if (ret != 0)
+ {
+ Debug.Print("[Input] LibInput.Dispatch({0:x}) failed. Error: {1}",
+ input_context, ret);
+ break;
+ }
+
+ IntPtr pevent = LibInput.GetEvent(input_context);
+ if (pevent == IntPtr.Zero)
+ {
+ break;
+ }
+
+ IntPtr device = LibInput.GetDevice(pevent);
+ InputEventType type = LibInput.GetEventType(pevent);
+
+ lock (Sync)
+ {
+ switch (type)
+ {
+// case InputEventType.DeviceAdded:
+// HandleDeviceAdded(input_context, device);
+// break;
+//
+// case InputEventType.DeviceRemoved:
+// HandleDeviceRemoved(input_context, device);
+// break;
+//
+ case InputEventType.KeyboardKey:
+ run = false;
+ //HandleKeyboard(GetKeyboard(device), LibInput.GetKeyboardEvent(pevent));
+ break;
+//
+// case InputEventType.PointerAxis:
+// HandlePointerAxis(GetMouse(device), LibInput.GetPointerEvent(pevent));
+// break;
+//
+ case InputEventType.PointerButton:
+ handlePointerButton (LibInput.GetPointerEvent(pevent));
+ break;
+
+ case InputEventType.PointerMotion:
+ handlePointerMotion (LibInput.GetPointerEvent(pevent));
+ break;
+
+// case InputEventType.PointerMotionAbsolute:
+// HandlePointerMotionAbsolute(GetMouse(device), LibInput.GetPointerEvent(pevent));
+// break;
+ }
+ }
+
+ LibInput.DestroyEvent(pevent);
+ }
+ }
+ int MouseX = 0, MouseY = 0;
+ volatile bool updateMousePos = true;
+
+ int roundDelta (double d){
+ return d > 0 ? (int)Math.Ceiling(d) : (int)Math.Floor (d);
+ }
+
+ void handlePointerMotion(PointerEvent e)
+ {
+ MouseX += roundDelta (e.DeltaX);
+ MouseY += roundDelta (e.DeltaY);
+
+ Rectangle bounds = CrowInterface.ClientRectangle;
+ if (MouseX < bounds.Left)
+ MouseX = bounds.Left;
+ else if (MouseX > bounds.Right)
+ MouseX = bounds.Right;
+
+ if (MouseY < bounds.Top)
+ MouseY = bounds.Top;
+ else if (MouseY > bounds.Bottom)
+ MouseY = bounds.Bottom;
+
+ CrowInterface.ProcessMouseMove (MouseX, MouseY);
+
+ updateMousePos = true;
+ }
+ void handlePointerButton (PointerEvent e)
+ {
+ int but = 0;
+ switch (e.Button) {
+ case EvdevButton.LEFT:
+ but = 0;
+ break;
+ case EvdevButton.MIDDLE:
+ but = 1;
+ break;
+ case EvdevButton.RIGHT:
+ but = 2;
+ break;
+ }
+ if (e.ButtonState == OpenTK.Platform.Linux.ButtonState.Pressed)
+ CrowInterface.ProcessMouseButtonDown (but);
+ else
+ CrowInterface.ProcessMouseButtonUp (but);
+ }
+ #endregion
+ }
+}
+
+++ /dev/null
-//
-// DrmKms.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 OpenTK.Platform.Linux;
-using OpenTK;
-using System.IO;
-using System.Collections.Generic;
-using System.Diagnostics;
-using OpenTK.Platform.Egl;
-using System.Runtime.InteropServices;
-using System.Threading;
-
-namespace testDrm
-{
- public class DrmDevice : IDisposable
- {
- volatile bool run = true;
-
- int fd = 0;
- int major, minor;
- IntPtr gbm_device, gbm_surface, egl_display, egl_config, egl_surface, egl_ctx;
-
- int r, g, b, a;
-
- BufferObject cursor_custom;
- BufferObject cursor_default;
- BufferObject cursor_empty;
-
-
- ModeInfo originalMode;
-
- public IntPtr Connector;
- public IntPtr Crtc;
- public IntPtr Encoder;
- unsafe ModeConnector* pConnector { get { return (ModeConnector*)Connector; } }
- unsafe ModeCrtc* pCrtc { get { return (ModeCrtc*)Crtc; } }
- unsafe ModeEncoder* pEncoder { get { return (ModeEncoder*)Encoder; } }
-
- Cairo.EGLDevice cairoDev;
- Cairo.GLSurface cairoSurf;
-
- public DrmDevice(string gpu_path = "/dev/dri/card0"){
-
- PageFlip = HandlePageFlip;
- PageFlipPtr = Marshal.GetFunctionPointerForDelegate(PageFlip);
-
- gbm_device = IntPtr.Zero;
- egl_display = IntPtr.Zero;
-
- fd = Libc.open(gpu_path, OpenFlags.ReadWrite | OpenFlags.CloseOnExec);
- if (fd < 0)
- throw new NotSupportedException("[KMS] Failed to open gpu");
- Console.WriteLine("[KMS] GPU '{0}' opened as fd:{1}", gpu_path, fd);
-
- initDrm ();
-
- initGbm ();
-
- initEgl ();
-
- initCairo ();
-
- initInput ();
- }
-
- #region init
- unsafe void initDrm(){
- ModeRes* resources = (ModeRes*)Drm.ModeGetResources(fd);
- if (resources == null)
- throw new NotSupportedException("[KMS] Drm.ModeGetResources failed.");
-
- ModeConnector* connector = null;
- for (int i = 0; i < resources->count_connectors; i++) {
- connector = (ModeConnector*)Drm.ModeGetConnector (fd, *(resources->connectors + i));
- if (connector != null) {
- if (connector->connection == ModeConnection.Connected && connector->count_encoders > 0)
- break;
- Drm.ModeFreeConnector ((IntPtr)connector);
- connector = null;
- }
- }
- if (connector == null)
- throw new NotSupportedException("[KMS] No connected screen found");
-
- Connector = (IntPtr)connector;
- Encoder = Drm.ModeGetEncoder (fd, connector->encoder_id);
- Crtc = Drm.ModeGetCrtc(fd, pEncoder->crtc_id);
-
- originalMode = pCrtc->mode;
- Console.WriteLine ("[DRM]: current mode = {0} X {1} at {2} Hz", originalMode.hdisplay, originalMode.vdisplay, originalMode.vrefresh);
- }
- void initGbm (){
- gbm_device = Gbm.CreateDevice(fd);
- if (gbm_device == IntPtr.Zero)
- throw new NotSupportedException("[GBM] Failed to create GBM device");
-
- gbm_surface = Gbm.CreateSurface(gbm_device, originalMode.hdisplay, originalMode.vdisplay, SurfaceFormat.ARGB8888, SurfaceFlags.Rendering | SurfaceFlags.Scanout);
- if (gbm_surface == IntPtr.Zero)
- throw new NotSupportedException("[GBM] Failed to create GBM surface for rendering");
- }
-
- unsafe void initEgl () {
- IntPtr[] configs = new IntPtr[1];
- int[] contextAttrib = new int[] {
- Egl.CONTEXT_CLIENT_VERSION, 2,
- Egl.NONE
- };
- int[] attribList = new int[]
- {
- Egl.SURFACE_TYPE, Egl.WINDOW_BIT,
- Egl.RENDERABLE_TYPE, Egl.OPENGL_BIT,
- Egl.RED_SIZE, 1,
- Egl.GREEN_SIZE, 1,
- Egl.BLUE_SIZE, 1,
- Egl.ALPHA_SIZE, 0,
-
- //Egl.DEPTH_SIZE, 24,
- //Egl.STENCIL_SIZE, 0,
-
- //Egl.SAMPLE_BUFFERS, 2,
- //Egl.SAMPLES, 0,
- Egl.NONE
- };
- int num_configs;
-
- egl_display = Egl.GetDisplay(gbm_device);
- if (egl_display == IntPtr.Zero)
- throw new NotSupportedException("[KMS] Failed to create EGL display");
- Console.WriteLine("[EGL] EGL display {0:x} created successfully", egl_display);
-
- if (!Egl.Initialize(egl_display, out major, out minor))
- throw new NotSupportedException("[EGL] Failed to initialize EGL display. Error code: " + Egl.GetError());
-
- if (!Egl.BindAPI (RenderApi.GL))
- throw new NotSupportedException("[EGL] Failed to bind EGL Api: " + Egl.GetError());
-
- Console.WriteLine ("[EGL] Version: " + Marshal.PtrToStringAuto (Egl.QueryString (egl_display, Egl.VERSION)));
- Console.WriteLine ("[EGL] Vendor: " + Marshal.PtrToStringAuto (Egl.QueryString (egl_display, Egl.VENDOR)));
- Console.WriteLine ("[EGL] Extensions: " + Marshal.PtrToStringAuto (Egl.QueryString (egl_display, Egl.EXTENSIONS)));
-
- if (!Egl.ChooseConfig(egl_display, attribList, configs, configs.Length, out num_configs) || num_configs == 0)
- throw new NotSupportedException(String.Format("Failed to retrieve GraphicsMode, error {0}", Egl.GetError()));
-
-
- // See what we really got
- int d, s, sample_buffers, samples;
- IntPtr active_config = configs[0];
- Egl.GetConfigAttrib(egl_display, active_config, Egl.RED_SIZE, out r);
- Egl.GetConfigAttrib(egl_display, active_config, Egl.GREEN_SIZE, out g);
- Egl.GetConfigAttrib(egl_display, active_config, Egl.BLUE_SIZE, out b);
- Egl.GetConfigAttrib(egl_display, active_config, Egl.ALPHA_SIZE, out a);
- //Egl.GetConfigAttrib(egl_display, active_config, Egl.DEPTH_SIZE, out d);
- //Egl.GetConfigAttrib(egl_display, active_config, Egl.STENCIL_SIZE, out s);
- //Egl.GetConfigAttrib(egl_display, active_config, Egl.SAMPLE_BUFFERS, out sample_buffers);
- //Egl.GetConfigAttrib(egl_display, active_config, Egl.SAMPLES, out samples);
-// Console.WriteLine ("EGL context: {0},{1},{2},{3} depth={4} stencil={5} samples={6} sample buffers={7}",
-// r, g, b, a, d, s, samples, sample_buffers);
- egl_config = active_config;
-
- egl_ctx = Egl.CreateContext(egl_display, egl_config, IntPtr.Zero, contextAttrib);
-
- egl_surface = Egl.CreateWindowSurface(egl_display, egl_config, gbm_surface, IntPtr.Zero);
-
- if (egl_surface==IntPtr.Zero)
- throw new NotSupportedException(String.Format("[EGL] Failed to create window surface, error {0}.", Egl.GetError()));
-
- if (!Egl.MakeCurrent(egl_display, egl_surface, egl_surface, egl_ctx))
- throw new NotSupportedException(string.Format("Failed to make context {0} current. Error: {1}", gbm_surface, Egl.GetError()));
-
- cursor_default = CreateCursor(gbm_device, Cursors.Default);
- cursor_empty = CreateCursor(gbm_device, Cursors.Empty);
-
- SetCursor(MouseCursor.Default);
- unsafe {
- Drm.MoveCursor (fd, pEncoder->crtc_id, 50, 50);
- }
- }
-
- void initCairo (){
- cairoDev = new Cairo.EGLDevice (egl_display, egl_ctx);
-
- cairoSurf = new Cairo.GLSurface (cairoDev, egl_surface, originalMode.hdisplay, originalMode.vdisplay);
- //cairoSurf = new Cairo.EGLSurface (cairoDev, egl_surface, 1600, 900);
-
- cairoDev.SetThreadAware (false);
-
- if (cairoDev.Acquire () != Cairo.Status.Success)
- Console.WriteLine ("[Cairo]: Failed to acquire egl device.");
- }
- #endregion
-
- #region cursor
- static BufferObject CreateCursor(IntPtr gbm, MouseCursor cursor)
- {
- if (cursor.Width > 64 || cursor.Height > 64)
- {
- Debug.Print("[KMS] Cursor size {0}x{1} unsupported. Maximum is 64x64.",
- cursor.Width, cursor.Height);
- return default(BufferObject);
- }
-
- int width = 64;
- int height = 64;
- SurfaceFormat format = SurfaceFormat.ARGB8888;
- SurfaceFlags usage = SurfaceFlags.Cursor64x64 | SurfaceFlags.Write;
-
- Debug.Print("[KMS] Gbm.CreateBuffer({0:X}, {1}, {2}, {3}, {4}).",
- gbm, width, height, format, usage);
-
- BufferObject bo = Gbm.CreateBuffer(
- gbm, width, height, format, usage);
-
- if (bo == BufferObject.Zero)
- {
- Debug.Print("[KMS] Failed to create buffer.");
- return bo;
- }
-
- // Copy cursor.Data into a new buffer of the correct size
- byte[] cursor_data = new byte[width * height * 4];
- for (int y = 0; y < cursor.Height; y++)
- {
- int dst_offset = y * width * 4;
- int src_offset = y * cursor.Width * 4;
- int src_length = cursor.Width * 4;
- Array.Copy(
- cursor.Data, src_offset,
- cursor_data, dst_offset,
- src_length);
- }
- bo.Write(cursor_data);
-
- return bo;
- }
- void SetCursor(MouseCursor cursor)
- {
- BufferObject bo = default(BufferObject);
- if (cursor == MouseCursor.Default)
- {
- bo = cursor_default;
- }
- else if (cursor == MouseCursor.Empty)
- {
- bo = cursor_empty;
- }
- else
- {
- if (cursor_custom != BufferObject.Zero)
- cursor_custom.Dispose();
- cursor_custom = CreateCursor(gbm_device, cursor);
- bo = cursor_custom;
- }
-
- // If we failed to create a proper cursor, try falling back
- // to the empty cursor. We do not want to crash here!
- if (bo == BufferObject.Zero)
- {
- bo = cursor_empty;
- }
-
- if (bo != BufferObject.Zero)
- {
- unsafe {
- Drm.SetCursor (fd, pEncoder->crtc_id,
- bo.Handle, bo.Width, bo.Height, cursor.X, cursor.Y);
- }
- }
- }
- #endregion
- int x, y;
-
- void drawR (Cairo.Context ctx, int inc, double r, double g, double b){
- ctx.Rectangle (x+inc, y+inc, 200, 200);
- ctx.SetSourceRGB (r, g, b);
- ctx.Fill ();
- }
- public void RenderingLoop(){
- while (run){
- if (updateMousePos) {
- lock (Sync) {
- updateMousePos = false;
- unsafe {
- Drm.MoveCursor (fd, pEncoder->crtc_id, MouseX, MouseY);
- }
- }
- }
-
- if (x > 700) {
- x = y = 0;
- } else {
- x+=1;
- y+=1;
- }
- using (Cairo.Context ctx = new Cairo.Context (cairoSurf)) {
- ctx.Rectangle (0, 0, 1024, 780);
- ctx.SetSourceRGB (0, 0, 1);
- ctx.Fill ();
- drawR (ctx, 0, 0, 1, 0);
- }
- cairoSurf.Flush ();
-
- cairoSurf.SwapBuffers ();
-
-// if (!Egl.SwapBuffers(egl_display, egl_surface))
-// throw new NotSupportedException(string.Format("Failed to swap buffers for context {0} current. Error: {1}", gbm_device, Egl.GetError()));
-
- if (Gbm.HasFreeBuffers (gbm_surface) == 0)
- throw new Exception ("[GBM]: Out of free buffers.");
-
- next_bo = Gbm.LockFrontBuffer (gbm_surface);
- if (next_bo == BufferObject.Zero)
- throw new Exception ("[GBM]: Failed to lock front buffer.");
-
- int width = next_bo.Width;
- int height = next_bo.Height;
- int bpp = 32;
- int depth = 24;
- int stride = next_bo.Stride;
- int hndBO = next_bo.Handle;
-
- int next_fb;
- int ret = Drm.ModeAddFB (fd, width, height,(byte)depth, (byte)bpp, stride, hndBO, out next_fb);
- if (ret != 0)
- throw new Exception ("[DRM]: ModeAddFB failed.");
-
- SetScanoutRegion (next_fb);
-
- is_flip_queued = true;
- unsafe{
- ret = Drm.ModePageFlip (fd, pEncoder->crtc_id, next_fb, PageFlipFlags.FlipEvent, IntPtr.Zero);
- }
- if (ret < 0)
- throw new Exception ("[DRM] Failed to enqueue framebuffer flip.");
-
- PollFD fds = new PollFD();
- fds.fd = fd;
- fds.events = PollFlags.In;
-
- EventContext evctx = new EventContext();
- evctx.version = EventContext.Version;
- evctx.page_flip_handler = PageFlipPtr;
-
- int timeout = -1;//block ? -1 : 0;
-
- while (is_flip_queued)
- {
- fds.revents = 0;
- if (Libc.poll(ref fds, 1, timeout) < 0)
- break;
-
- if ((fds.revents & (PollFlags.Hup | PollFlags.Error)) != 0)
- break;
-
- if ((fds.revents & PollFlags.In) != 0)
- Drm.HandleEvent(fd, ref evctx);
- else
- break;
- }
- }
- }
-
- #region rendering
- BufferObject bo, next_bo;
- int fb, next_fb;
- bool is_flip_queued;
- // We only support a SwapInterval of 0 (immediate)
- // or 1 (vsynced).
- // Todo: add support for SwapInterval of -1 (adaptive).
- // This requires a small change in WaitFlip().
- int swap_interval=0;
-
- readonly IntPtr PageFlipPtr;
- readonly PageFlipCallback PageFlip;
-
- void HandlePageFlip(int fd, int sequence, int tv_sec, int tv_usec, IntPtr user_data)
- {
- is_flip_queued = false;
- if (fb != 0)
- Drm.ModeRmFB (fd, fb);
- fb = next_fb;
- next_fb = 0;
- if (bo != BufferObject.Zero)
- Gbm.ReleaseBuffer (gbm_surface, bo);
- bo = next_bo;
- next_bo = BufferObject.Zero;
- }
-
- static readonly DestroyUserDataCallback DestroyFB = HandleDestroyFB;
- static void HandleDestroyFB(BufferObject bo, IntPtr data)
- {
- IntPtr gbm = bo.Device;
- int fb = data.ToInt32();
- Debug.Print("[KMS] Destroying framebuffer {0}", fb);
-
- if (fb != 0)
- Drm.ModeRmFB(Gbm.DeviceGetFD(gbm), fb);
- }
-
- public void SwapBuffers()
- {
- if (!Egl.SwapBuffers(egl_display, egl_surface))
- throw new NotSupportedException(string.Format("Failed to swap buffers for context {0} current. Error: {1}", gbm_device, Egl.GetError()));
-
- if (is_flip_queued)
- {
- // Todo: if we don't wait for the page flip,
- // we drop all rendering buffers and get a crash
- // in Egl.SwapBuffers(). We need to fix that
- // before we can disable vsync.
- WaitFlip(true); // WaitFlip(SwapInterval > 0)
- if (is_flip_queued)
- {
- Debug.Print("[KMS] Dropping frame");
- return;
- }
- }
-
- next_bo = Gbm.LockFrontBuffer (gbm_surface);
- int fb = GetFramebuffer(next_bo);
- QueueFlip(fb);
- }
-
- public void Update()
- {
- WaitFlip(true);
-
- if (!Egl.SwapBuffers(egl_display, egl_surface))
- throw new NotSupportedException(string.Format("Failed to swap buffers for context {0} current. Error: {1}", gbm_device, Egl.GetError()));
-
- bo = Gbm.LockFrontBuffer (gbm_surface);
- int fb = GetFramebuffer(bo);
- SetScanoutRegion(fb);
- }
-
-
- void WaitFlip(bool block)
- {
- PollFD fds = new PollFD();
- fds.fd = fd;
- fds.events = PollFlags.In;
-
- EventContext evctx = new EventContext();
- evctx.version = EventContext.Version;
- evctx.page_flip_handler = PageFlipPtr;
-
- int timeout = block ? -1 : 0;
-
- while (is_flip_queued)
- {
- fds.revents = 0;
- if (Libc.poll(ref fds, 1, timeout) < 0)
- break;
-
- if ((fds.revents & (PollFlags.Hup | PollFlags.Error)) != 0)
- break;
-
- if ((fds.revents & PollFlags.In) != 0)
- Drm.HandleEvent(fd, ref evctx);
- else
- break;
- }
-
- // Page flip has taken place, update buffer objects
- if (!is_flip_queued)
- {
- Gbm.ReleaseBuffer(gbm_surface, bo);
- bo = next_bo;
- }
- }
-
- void QueueFlip(int buffer)
- {
- unsafe
- {
- int ret = Drm.ModePageFlip (fd, pEncoder->crtc_id, buffer, PageFlipFlags.FlipEvent, IntPtr.Zero);
- if (ret < 0)
- Debug.Print("[KMS] Failed to enqueue framebuffer flip. Error: {0}", ret);
-
- is_flip_queued = true;
- }
- }
-
- void SetScanoutRegion(int buffer)
- {
- unsafe
- {
- ModeInfo* mode = pConnector->modes;
- int connector_id = pConnector->connector_id;
- int crtc_id = pEncoder->crtc_id;
-
- int x = 0;
- int y = 0;
- int connector_count = 1;
- int ret = Drm.ModeSetCrtc(fd, crtc_id, buffer, x, y, &connector_id, connector_count, mode);
-
- if (ret != 0)
- {
- Debug.Print("[KMS] Drm.ModeSetCrtc{0}, {1}, {2}, {3}, {4:x}, {5}, {6:x}) failed. Error: {7}",
- fd, crtc_id, buffer, x, y, (IntPtr)connector_id, connector_count, (IntPtr)mode, ret);
- }
- }
- }
-
- int GetFramebuffer(BufferObject bo)
- {
- if (bo == BufferObject.Zero)
- goto fail;
-
- int bo_handle = bo.Handle;
- if (bo_handle == 0)
- {
- Debug.Print("[KMS] Gbm.BOGetHandle({0:x}) failed.", bo);
- goto fail;
- }
-
- int width = bo.Width;
- int height = bo.Height;
- int bpp = 32;
- int depth = 24;
- int stride = bo.Stride;
-
- if (width == 0 || height == 0 || bpp == 0)
- {
- Debug.Print("[KMS] Invalid framebuffer format: {0}x{1} {2} {3} {4}",
- width, height, stride, bpp, depth);
- goto fail;
- }
-
- int buffer;
- int ret = Drm.ModeAddFB (fd, width, height,(byte)depth, (byte)bpp, stride, bo_handle,out buffer);
- if (ret != 0)
- {
- Debug.Print("[KMS] Drm.ModeAddFB({0}, {1}, {2}, {3}, {4}, {5}, {6}) failed. Error: {7}",
- fd, width, height, depth, bpp, stride, bo_handle, ret);
- goto fail;
- }
-
- bo.SetUserData((IntPtr)buffer, DestroyFB);
- return buffer;
-
- fail:
- Debug.Print("[Error] Failed to create framebuffer.");
- return -1;
- }
- #endregion
-
- #region IDisposable implementation
- public void Dispose ()
- {
- cairoDev.Release ();
- cairoSurf.Dispose ();
- cairoDev.Dispose ();
-
- if (fb != 0)
- Drm.ModeRmFB (fd, fb);
- if (bo != BufferObject.Zero)
- Gbm.ReleaseBuffer (gbm_surface, bo);
- if (next_fb != 0)
- Drm.ModeRmFB (fd, next_fb);
- if (next_bo != BufferObject.Zero)
- Gbm.ReleaseBuffer (gbm_surface, next_bo);
-
- if (Egl.GetCurrentContext () == egl_ctx) {
- Console.WriteLine ("destroying context");
- Egl.DestroyContext (egl_display, egl_ctx);
- }else
- Console.WriteLine ("not current");
-
- cairoDev.Dispose ();
-
- Drm.ModeFreeCrtc (Crtc);
- Drm.ModeFreeConnector(Connector);
- Drm.ModeFreeEncoder(Encoder);
- Libc.close(fd);
- }
- #endregion
-
- #region tests
- unsafe void dumpDrmResources(){
- ModeRes* resources = (ModeRes*)Drm.ModeGetResources(fd);
- if (resources == null)
- throw new NotSupportedException("[KMS] Drm.ModeGetResources failed.");
- Console.WriteLine("[KMS] DRM found {0} connectors", resources->count_connectors);
-
- Console.WriteLine ("[ENCODERS]");
- for (int j = 0; j < resources->count_encoders; j++) {
- ModeEncoder* e = (ModeEncoder*)Drm.ModeGetEncoder(fd, *(resources->encoders + j));
-
- if (e == null)
- continue;
- Console.WriteLine ("{0}\t{1}\t{2}",e->encoder_id, e->encoder_type, e->crtc_id);
-
- Drm.ModeFreeEncoder((IntPtr)e);
- }
-
- Console.WriteLine ("\n[CONNECTORS]");
- ModeConnector* connector = null;
- for (int i = 0; i < resources->count_connectors; i++)
- {
- connector = (ModeConnector*)Drm.ModeGetConnector(fd, *(resources->connectors + i));
- if (connector != null)
- {
- Console.WriteLine ("{0}\t{1}\t{2}\t{3}",
- connector->connector_id,
- connector->connector_type,
- connector->connection,
- connector->encoder_id);
-
- for (int j = 0; j < connector->count_modes; j++) {
- ModeInfo* mode = connector->modes + j;
- if (mode == null)
- continue;
- Console.WriteLine ("\t{0,-20}{1,5}{2,5}{3,4} hz",
- new string(mode->name),
- mode->hdisplay,
- mode->vdisplay,
- mode->vrefresh);
- }
- Drm.ModeFreeConnector((IntPtr)connector);
- connector = null;
- }
- }
- }
-
- unsafe static void GetModes(LinuxDisplay display, DisplayResolution[] modes, out DisplayResolution current)
- {
- int mode_count = display.pConnector->count_modes;
- Console.WriteLine("[KMS] Display supports {0} mode(s)", mode_count);
- for (int i = 0; i < mode_count; i++)
- {
- ModeInfo* mode = display.pConnector->modes + i;
- if (mode != null)
- {
- Console.WriteLine("Mode {0}: {1}x{2} @{3}", i,
- mode->hdisplay, mode->vdisplay, mode->vrefresh);
- DisplayResolution res = GetDisplayResolution(mode);
- modes[i] = res;
- }
- }
-
- if (display.pCrtc->mode_valid != 0)
- {
- ModeInfo cmode = display.pCrtc->mode;
- current = GetDisplayResolution(&cmode);
- }
- else
- {
- current = GetDisplayResolution(display.pConnector->modes);
- }
- Console.WriteLine("Current mode: {0}", current.ToString());
- }
- unsafe static DisplayResolution GetDisplayResolution(ModeInfo* mode)
- {
- return new DisplayResolution(
- 0, 0,
- mode->hdisplay, mode->vdisplay,
- 32, // This is actually part of the framebuffer, not the DisplayResolution
- mode->vrefresh);
- }
-
- unsafe static ModeInfo* GetModeInfo(LinuxDisplay display, DisplayResolution resolution)
- {
- for (int i = 0; i < display.pConnector->count_modes; i++)
- {
- ModeInfo* mode = display.pConnector->modes + i;
- if (mode != null &&
- mode->hdisplay == resolution.Width &&
- mode->vdisplay == resolution.Height)
- {
- return mode;
- }
- }
- return null;
- }
-
- SurfaceFormat GetSurfaceFormat()
- {
- int format;
- Egl.GetConfigAttrib(egl_display, egl_config,
- Egl.NATIVE_VISUAL_ID, out format);
- if (format == 0)
- throw new Exception ("[KMS] Failed to retrieve EGL visual from GBM surface. Error: " + Egl.GetError());
-
- return (SurfaceFormat)format;
- }
- #endregion
-
- #region INPUT
- Thread input_thread;
- long exit;
-
- static readonly object Sync = new object();
- static readonly Crow.Key[] KeyMap = Evdev.KeyMap;
- static long DeviceFDCount;
-
- IntPtr udev;
- IntPtr input_context;
-
- int input_fd = 0;
-
- InputInterface input_interface = new InputInterface(
- OpenRestricted, CloseRestricted);
- static CloseRestrictedCallback CloseRestricted = CloseRestrictedHandler;
- static void CloseRestrictedHandler(int fd, IntPtr data)
- {
- Debug.Print("[Input] Closing fd {0}", fd);
- int ret = Libc.close(fd);
-
- if (ret < 0)
- {
- Debug.Print("[Input] Failed to close fd {0}. Error: {1}", fd, ret);
- }
- else
- {
- Interlocked.Decrement(ref DeviceFDCount);
- }
- }
-
- static OpenRestrictedCallback OpenRestricted = OpenRestrictedHandler;
- static int OpenRestrictedHandler(IntPtr path, int flags, IntPtr data)
- {
- int fd = Libc.open(path, (OpenFlags)flags);
- Debug.Print("[Input] Opening '{0}' with flags {1}. fd:{2}",
- Marshal.PtrToStringAnsi(path), (OpenFlags)flags, fd);
-
- if (fd >= 0)
- {
- Interlocked.Increment(ref DeviceFDCount);
- }
-
- return fd;
- }
-
- void initInput (){
- Semaphore ready = new Semaphore(0, 1);
- input_thread = new Thread (InputThreadLoop);
- input_thread.IsBackground = true;
- input_thread.Start(ready);
- }
-
- void InputThreadLoop(object semaphore)
- {
- Debug.Print("[Input] Running on thread {0}", Thread.CurrentThread.ManagedThreadId);
- Setup();
-
- // Inform the parent thread that initialization has completed successfully
- (semaphore as Semaphore).Release();
- Debug.Print("[Input] Released main thread.", input_context);
-
- // Use a blocking poll for input messages, in order to reduce CPU usage
- PollFD poll_fd = new PollFD();
- poll_fd.fd = input_fd;
- poll_fd.events = PollFlags.In;
- Debug.Print("[Input] Created PollFD({0}, {1})", poll_fd.fd, poll_fd.events);
-
- Debug.Print("[Input] Entering input loop.", poll_fd.fd, poll_fd.events);
- while (Interlocked.Read(ref exit) == 0)
- {
- int ret = Libc.poll(ref poll_fd, 1, -1);
- ErrorNumber error = (ErrorNumber)Marshal.GetLastWin32Error();
- bool is_error =
- ret < 0 && !(error == ErrorNumber.Again || error == ErrorNumber.Interrupted) ||
- (poll_fd.revents & (PollFlags.Hup | PollFlags.Error | PollFlags.Invalid)) != 0;
-
- if (ret > 0 && (poll_fd.revents & (PollFlags.In | PollFlags.Pri)) != 0)
- ProcessEvents(input_context);
-
- if (is_error)
- {
- Debug.Print("[Input] Exiting input loop {0} due to poll error [ret:{1} events:{2}]. Error: {3}.",
- input_thread.ManagedThreadId, ret, poll_fd.revents, error);
- Interlocked.Increment(ref exit);
- }
- }
- Debug.Print("[Input] Exited input loop.", poll_fd.fd, poll_fd.events);
- }
-
- void Setup()
- {
- // Todo: add static path fallback when udev is not installed.
- udev = Udev.New();
- if (udev == IntPtr.Zero)
- {
- Debug.Print("[Input] Udev.New() failed.");
- Interlocked.Increment(ref exit);
- return;
- }
- Debug.Print("[Input] Udev.New() = {0:x}", udev);
-
- input_context = LibInput.CreateContext(input_interface, IntPtr.Zero, udev);
- if (input_context == IntPtr.Zero)
- {
- Debug.Print("[Input] LibInput.CreateContext({0:x}) failed.", udev);
- Interlocked.Increment(ref exit);
- return;
- }
- Debug.Print("[Input] LibInput.CreateContext({0:x}) = {1:x}", udev, input_context);
-
- string seat_id = "seat0";
- int seat_assignment = LibInput.AssignSeat(input_context, seat_id);
- if (seat_assignment == -1)
- {
- Debug.Print("[Input] LibInput.AssignSeat({0:x}) = {1} failed.", input_context, seat_id);
- Interlocked.Increment(ref exit);
- return;
- }
- Debug.Print("[Input] LibInput.AssignSeat({0:x}) = {1}", input_context, seat_id);
-
- input_fd = LibInput.GetFD(input_context);
- if (input_fd < 0)
- {
- Debug.Print("[Input] LibInput.GetFD({0:x}) failed.", input_context);
- Interlocked.Increment(ref exit);
- return;
- }
- Debug.Print("[Input] LibInput.GetFD({0:x}) = {1}.", input_context, input_fd);
-
- ProcessEvents(input_context);
- LibInput.Resume(input_context);
- Debug.Print("[Input] LibInput.Resume({0:x})", input_context);
-
- if (Interlocked.Read(ref DeviceFDCount) <= 0)
- {
- Debug.Print("[Error] Failed to open any input devices.");
- Debug.Print("[Error] Ensure that you have access to '/dev/input/event*'.");
- Interlocked.Increment(ref exit);
- }
- }
-
- void ProcessEvents(IntPtr input_context)
- {
- // Process all events in the event queue
- while (true)
- {
- // Data available
- int ret = LibInput.Dispatch(input_context);
- if (ret != 0)
- {
- Debug.Print("[Input] LibInput.Dispatch({0:x}) failed. Error: {1}",
- input_context, ret);
- break;
- }
-
- IntPtr pevent = LibInput.GetEvent(input_context);
- if (pevent == IntPtr.Zero)
- {
- break;
- }
-
- IntPtr device = LibInput.GetDevice(pevent);
- InputEventType type = LibInput.GetEventType(pevent);
-
- lock (Sync)
- {
- switch (type)
- {
-// case InputEventType.DeviceAdded:
-// HandleDeviceAdded(input_context, device);
-// break;
-//
-// case InputEventType.DeviceRemoved:
-// HandleDeviceRemoved(input_context, device);
-// break;
-//
- case InputEventType.KeyboardKey:
- run = false;
- //HandleKeyboard(GetKeyboard(device), LibInput.GetKeyboardEvent(pevent));
- break;
-//
-// case InputEventType.PointerAxis:
-// HandlePointerAxis(GetMouse(device), LibInput.GetPointerEvent(pevent));
-// break;
-//
-// case InputEventType.PointerButton:
-// HandlePointerButton(GetMouse(device), LibInput.GetPointerEvent(pevent));
-// break;
-
- case InputEventType.PointerMotion:
- HandlePointerMotion(LibInput.GetPointerEvent(pevent));
- break;
-
-// case InputEventType.PointerMotionAbsolute:
-// HandlePointerMotionAbsolute(GetMouse(device), LibInput.GetPointerEvent(pevent));
-// break;
- }
- }
-
- LibInput.DestroyEvent(pevent);
- }
- }
- int MouseX = 0, MouseY = 0;
- volatile bool updateMousePos = true;
-
- void HandlePointerMotion(PointerEvent e)
- {
- MouseX += (int)e.DeltaX;
- MouseY += (int)e.DeltaY;
- updateMousePos = true;
- }
-
- #endregion
- }
-}
-
//
// Author:
// Stefanos A. <stapostol@gmail.com>
+// Bruyère JP <jp_bruyere@hotmail.com>
//
-// Copyright (c) 2006-2014 Stefanos Apostolopoulos
+// Copyright (c) 2006-2017 Stefanos Apostolopoulos
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
#pragma warning disable 0649 // field is never assigned
-namespace OpenTK.Platform.Linux
+namespace Crow.Linux
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void VBlankCallback(int fd,
int sequence,
int tv_sec,
int tv_usec,
- IntPtr user_data);
+ ref int user_data);
class Drm
{
[DllImport(lib, EntryPoint = "drmModePageFlip", CallingConvention = CallingConvention.Cdecl)]
public static extern int ModePageFlip(int fd, int crtc_id, int fb_id,
- PageFlipFlags flags, IntPtr user_data);
+ PageFlipFlags flags, ref int user_data);
[DllImport(lib, EntryPoint = "drmModeSetCrtc", CallingConvention = CallingConvention.Cdecl)]
unsafe public static extern int ModeSetCrtc(int fd, int crtcId, int bufferId,
[DllImport(lib, EntryPoint = "drmModeMoveCursor", CallingConvention = CallingConvention.Cdecl)]
public static extern int MoveCursor(int fd, int crtcId, int x, int y);
-
}
enum ModeConnection
using System;
using System.Runtime.InteropServices;
-namespace OpenTK.Platform.Linux
+namespace Crow.Linux
{
using Device = IntPtr; // struct gbm_device*
using Surface = IntPtr;
public static extern int BOGetStride(IntPtr bo);
[DllImport(lib, EntryPoint = "gbm_bo_set_user_data", CallingConvention = CallingConvention.Cdecl)]
- public static extern void BOSetUserData(IntPtr bo, IntPtr data, DestroyUserDataCallback callback);
+ public static extern void BOSetUserData(IntPtr bo, IntPtr data, IntPtr callback);
+
+// [DllImport(lib, EntryPoint = "gbm_bo_get_user_data", CallingConvention = CallingConvention.Cdecl)]
+// public static extern IntPtr BOGetUserData (IntPtr bo);
[DllImport(lib, EntryPoint = "gbm_create_device", CallingConvention = CallingConvention.Cdecl)]
public static extern Device CreateDevice(int fd);
}
}
- public void SetUserData(IntPtr data, DestroyUserDataCallback destroyFB)
+ public void SetUserData(IntPtr data, IntPtr destroyFB)
{
Gbm.BOSetUserData(buffer, data, destroyFB);
}
<Compile Include="src\Egl.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="src\DrmDevice.cs" />
<Compile Include="src\Linux\DefaultCursor.cs" />
<Compile Include="src\MouseCursor.cs" />
<Compile Include="src\WindowIcon.cs" />
- <Compile Include="Mono.Cairo\Antialias.cs" />
- <Compile Include="Mono.Cairo\Cairo.cs" />
- <Compile Include="Mono.Cairo\CairoDebug.cs" />
- <Compile Include="Mono.Cairo\Color.cs" />
- <Compile Include="Mono.Cairo\Content.cs" />
- <Compile Include="Mono.Cairo\Context.cs" />
- <Compile Include="Mono.Cairo\DirectFBSurface.cs" />
- <Compile Include="Mono.Cairo\Distance.cs" />
- <Compile Include="Mono.Cairo\Extend.cs" />
- <Compile Include="Mono.Cairo\FillRule.cs" />
- <Compile Include="Mono.Cairo\Filter.cs" />
- <Compile Include="Mono.Cairo\FontExtents.cs" />
- <Compile Include="Mono.Cairo\FontFace.cs" />
- <Compile Include="Mono.Cairo\FontOptions.cs" />
- <Compile Include="Mono.Cairo\FontSlant.cs" />
- <Compile Include="Mono.Cairo\FontType.cs" />
- <Compile Include="Mono.Cairo\FontWeight.cs" />
- <Compile Include="Mono.Cairo\Format.cs" />
- <Compile Include="Mono.Cairo\GlitzSurface.cs" />
- <Compile Include="Mono.Cairo\Glyph.cs" />
- <Compile Include="Mono.Cairo\Gradient.cs" />
- <Compile Include="Mono.Cairo\HintMetrics.cs" />
- <Compile Include="Mono.Cairo\HintStyle.cs" />
- <Compile Include="Mono.Cairo\ImageSurface.cs" />
- <Compile Include="Mono.Cairo\LineCap.cs" />
- <Compile Include="Mono.Cairo\LineJoin.cs" />
- <Compile Include="Mono.Cairo\LinearGradient.cs" />
- <Compile Include="Mono.Cairo\Matrix.cs" />
- <Compile Include="Mono.Cairo\NativeMethods.cs" />
- <Compile Include="Mono.Cairo\Operator.cs" />
- <Compile Include="Mono.Cairo\PSSurface.cs" />
- <Compile Include="Mono.Cairo\Path.cs" />
- <Compile Include="Mono.Cairo\Pattern.cs" />
- <Compile Include="Mono.Cairo\PatternType.cs" />
- <Compile Include="Mono.Cairo\PdfSurface.cs" />
- <Compile Include="Mono.Cairo\Point.cs" />
- <Compile Include="Mono.Cairo\PointD.cs" />
- <Compile Include="Mono.Cairo\RadialGradient.cs" />
- <Compile Include="Mono.Cairo\Rectangle.cs" />
- <Compile Include="Mono.Cairo\Region.cs" />
- <Compile Include="Mono.Cairo\ScaledFont.cs" />
- <Compile Include="Mono.Cairo\SolidPattern.cs" />
- <Compile Include="Mono.Cairo\Status.cs" />
- <Compile Include="Mono.Cairo\SubpixelOrder.cs" />
- <Compile Include="Mono.Cairo\Surface.cs" />
- <Compile Include="Mono.Cairo\SurfacePattern.cs" />
- <Compile Include="Mono.Cairo\SurfaceType.cs" />
- <Compile Include="Mono.Cairo\SvgSurface.cs" />
- <Compile Include="Mono.Cairo\SvgVersion.cs" />
- <Compile Include="Mono.Cairo\TextExtents.cs" />
- <Compile Include="Mono.Cairo\Win32Surface.cs" />
- <Compile Include="Mono.Cairo\XcbSurface.cs" />
- <Compile Include="Mono.Cairo\XlibSurface.cs" />
- <Compile Include="Mono.Cairo\Device.cs" />
- <Compile Include="Mono.Cairo\GLSurface.cs" />
- <Compile Include="Mono.Cairo\GLXDevice.cs" />
- <Compile Include="Mono.Cairo\WGLDevice.cs" />
- <Compile Include="Mono.Cairo\EGLDevice.cs" />
+ <Compile Include="src\Application.cs" />
+ <Compile Include="src\DRMDevice.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Folder Include="src\" />
- <Folder Include="Mono.Cairo\" />
</ItemGroup>
<ItemGroup>
<None Include="src\Linux\LinuxFactory.cs" />